static void configureNewManager(DocumentmanagerConfig config, DocumentTypeManager manager) { if (config == null) { return; } setupAnnotationTypesWithoutPayloads(config, manager); setupAnnotationRefTypes(config, manager); log.log(LogLevel.DEBUG, "Configuring document manager with " + config.datatype().size() + " data types."); ArrayList<DocumentmanagerConfig.Datatype> failed = new ArrayList<>(); failed.addAll(config.datatype()); while (!failed.isEmpty()) { ArrayList<DocumentmanagerConfig.Datatype> tmp = failed; failed = new ArrayList<>(); for (int i = 0; i < tmp.size(); i++) { DocumentmanagerConfig.Datatype thisDataType = tmp.get(i); int id = thisDataType.id(); try { registerTypeIdMapping(config, manager, thisDataType, id); } catch (IllegalArgumentException e) { failed.add(thisDataType); } } } addStructInheritance(config, manager); addAnnotationTypePayloads(config, manager); addAnnotationTypeInheritance(config, manager); manager.replaceTemporaryTypes(); }
private static void setupAnnotationRefTypes(DocumentmanagerConfig config, DocumentTypeManager manager) { for (int i = 0; i < config.datatype().size(); i++) { DocumentmanagerConfig.Datatype thisDataType = config.datatype(i); int id = thisDataType.id(); for (Object o : thisDataType.annotationreftype()) { DocumentmanagerConfig.Datatype.Annotationreftype annRefType = (DocumentmanagerConfig.Datatype.Annotationreftype) o; AnnotationType annotationType = manager.getAnnotationTypeRegistry().getType(annRefType.annotation()); if (annotationType == null) { throw new IllegalArgumentException("Found reference to " + annRefType.annotation() + ", which does not exist!"); } AnnotationReferenceDataType type = new AnnotationReferenceDataType(annotationType, id); manager.register(type); } } }
private static void addStructInheritance(DocumentmanagerConfig config, DocumentTypeManager manager) { for (int i = 0; i < config.datatype().size(); i++) { DocumentmanagerConfig.Datatype thisDataType = config.datatype(i); int id = thisDataType.id(); for (Object o : thisDataType.structtype()) { DocumentmanagerConfig.Datatype.Structtype struct = (DocumentmanagerConfig.Datatype.Structtype) o; StructDataType thisStruct = (StructDataType) manager.getDataType(id, ""); for (DocumentmanagerConfig.Datatype.Structtype.Inherits parent : struct.inherits()) { StructDataType parentStruct = (StructDataType) manager.getDataType(parent.name()); thisStruct.inherit(parentStruct); } } } } }
public Builder(DocumentmanagerConfig config) { enablecompression(config.enablecompression()); for (Datatype d : config.datatype()) { datatype(new Datatype.Builder(d)); } for (Annotationtype a : config.annotationtype()) { annotationtype(new Annotationtype.Builder(a)); } }