protected void writeFacet(JsonGenerator jg, CompositeType facet, boolean expandSchemas) throws IOException { jg.writeStringField("name", facet.getName()); if (facet.getSchemaNames() != null && facet.getSchemaNames().length > 0) { jg.writeArrayFieldStart("schemas"); if (expandSchemas) { for (Schema schema : facet.getSchemas()) { writeSchemaObject(jg, schema); } } else { for (String schemaName : facet.getSchemaNames()) { jg.writeString(schemaName); } } jg.writeEndArray(); } } }
@Override protected void writeEntityBody(CompositeType facet, JsonGenerator jg) throws IOException { jg.writeStringField("name", facet.getName()); if (facet.getSchemaNames() != null && facet.getSchemaNames().length > 0) { jg.writeArrayFieldStart("schemas"); Writer<Schema> schemaWriter = registry.getWriter(ctx, Schema.class, APPLICATION_JSON_TYPE); for (Schema schema : facet.getSchemas()) { OutputStream out = new OutputStreamWithJsonWriter(jg); schemaWriter.write(schema, Schema.class, Schema.class, APPLICATION_JSON_TYPE, out); } jg.writeEndArray(); } }
/** * Creates all the models. */ private void initModels() { SchemaManager schemaManager = Framework.getService(SchemaManager.class); log.debug("Schemas fields from descriptor: " + repositoryDescriptor.schemaFields); // document types for (DocumentType docType : schemaManager.getDocumentTypes()) { initDocTypeOrMixinModel(docType.getName(), docType.getSchemas(), allDocTypeSchemas, typeFragments, typePropertyInfos, typeComplexChildren, true); initDocTypePrefetch(docType); initDocTypeMixins(docType); inferSuperType(docType); } // mixins for (CompositeType type : schemaManager.getFacets()) { initDocTypeOrMixinModel(type.getName(), type.getSchemas(), allMixinSchemas, mixinFragments, mixinPropertyInfos, mixinComplexChildren, false); log.debug("Fragments for facet " + type.getName() + ": " + getMixinFragments(type.getName())); } // proxy schemas initProxySchemas(schemaManager.getProxySchemas(null)); // second pass to get subtypes (needs all supertypes) for (DocumentType documentType : schemaManager.getDocumentTypes()) { inferSubTypes(documentType); } // init no per instance query facets initNoPerDocumentQueryFacets(schemaManager); }