/** * Construct compiled definitions * * @param model model definition * @param namespaceDAO namespace DAO */ private void constructDefinitions(M2Model model, NamespaceDAO namespaceDAO) { NamespacePrefixResolver localPrefixes = createLocalPrefixResolver(model, namespaceDAO); // Construct Model Definition modelDefinition = new M2ModelDefinition(model, localPrefixes); // Construct Property Types for (M2DataType propType : model.getPropertyTypes()) { M2DataTypeDefinition def = new M2DataTypeDefinition(modelDefinition, propType, localPrefixes); if (dataTypes.containsKey(def.getName())) { throw new DictionaryException( "Found duplicate property type definition " + propType.getName()); } dataTypes.put(def.getName(), def); } // Construct Type Definitions for (M2Type type : model.getTypes()) { M2TypeDefinition def = new M2TypeDefinition(modelDefinition, type, localPrefixes, properties, associations); if (classes.containsKey(def.getName())) { throw new DictionaryException( "Found duplicate class definition " + type.getName() + " (a type)"); } classes.put(def.getName(), def); types.put(def.getName(), def); } // Construct Aspect Definitions for (M2Aspect aspect : model.getAspects()) { M2AspectDefinition def = new M2AspectDefinition(modelDefinition, aspect, localPrefixes, properties, associations); if (classes.containsKey(def.getName())) { throw new DictionaryException( "Found duplicate class definition " + aspect.getName() + " (an aspect)"); } classes.put(def.getName(), def); aspects.put(def.getName(), def); } // Construct Constraint Definitions for (M2Constraint constraint : model.getConstraints()) { M2ConstraintDefinition def = new M2ConstraintDefinition(modelDefinition, null, constraint, localPrefixes); QName qname = def.getName(); if (constraints.containsKey(qname)) { throw new DictionaryException( "Found duplicate constraint definition " + constraint.getName() + " (an aspect)"); } constraints.put(qname, def); } }
/** * Resolve dependencies between model items * * @param query support for querying other items in model */ private void resolveDependencies(ModelQuery query, NamespaceDAO namespaceDAO) { NamespacePrefixResolver prefixResolver = createLocalPrefixResolver(model, namespaceDAO); for (DataTypeDefinition def : dataTypes.values()) { ((M2DataTypeDefinition) def).resolveDependencies(query); } for (ClassDefinition def : classes.values()) { ((M2ClassDefinition) def).resolveDependencies(query, prefixResolver, constraints); } }