public SchemaImpl(SchemaImpl schema) { this(); this.name = schema.getId(); this.parent = schema.getParent(); this.children = new ArrayList<String>(schema.getChildren()); this.pluralName = schema.getPluralName(); this.load(schema); }
protected void processParent(SchemaImpl schema) { SchemaImpl parent = null; Class<?> parentClass = parentClasses.get(schema); String parentName = schema.getParent(); if (parentClass == null && parentName != null) { parent = schemasByName.get(parentName); if (parent == null) { throw new IllegalArgumentException("Failed to find parent schema for [" + parentName + "] for type [" + schema.getId() + "]"); } } else if (parentClass != null) { parent = schemasByClass.get(parentClass); if (parent == null) { throw new IllegalArgumentException("Failed to find parent schema for class [" + parentClass + "] for type [" + schema.getId() + "]"); } } if (parent != null) { schema.setParent(parent.getId()); parent.getChildren().add(schema.getId()); schema.load(parent); } }
@Override public Schema parseSchema(String name) { SchemaImpl schema = readSchema(name); Class<?> clz = typeToClass.get(name); processParent(schema); List<Field> fields = getFields(clz); for (Map.Entry<String, Field> entry : schema.getResourceFields().entrySet()) { Field field = entry.getValue(); if (field instanceof FieldImpl) { ((FieldImpl)field).setName(entry.getKey()); } fields.add(field); } Map<String, Field> resourceFields = sortFields(fields); schema.setResourceFields(resourceFields); schema.getResourceActions().putAll(getResourceActions(clz)); schema.getCollectionActions().putAll(getCollectionActions(clz)); for (SchemaPostProcessor processor : postProcessors) { schema = processor.postProcess(schema, this); } addToMap(schemasByName, schema, schema); if (clz == null && schema.getParent() != null) { clz = typeToClass.get(schema.getParent()); if (clz != null) { addToMap(typeToClass, schema, clz); } } return schema; }
mergedSchema.setResourceMethods(newSchema.getResourceMethods()); if (mergedSchema.getParent().equals(mergedSchema.getId())) { mergedSchema.setParent(parentSchema.getParent());