public Model input( Reader reader ) throws ModelloException, ModelValidationException { return loadModel( reader ); }
public boolean hasMetadataPlugin( String metadataId ) { return hasPlugin( metadataId ); } }
public boolean hasGeneratorPlugin( String generatorId ) { return hasPlugin( generatorId ); } }
Map<String, String> modelAttributes = modelReader.getAttributesForModel(); upgradeModifiedAttribute( "xsd.target-namespace", modelAttributes, "xsd.targetNamespace", modelAttributes, "attribute 'xsd.target-namespace' for model element is deprecated: " + "it has been renamed to 'xsd.targetNamespace'" ); Map<String, String> classAttributes = modelReader.getAttributesForClass( clazz ); upgradeModifiedAttribute( "xml.namespace", classAttributes, modelAttributes, "attribute 'xml.namespace' for class element is deprecated: it should be moved to model element" ); upgradeModifiedAttribute( "xml.schemaLocation", classAttributes, modelAttributes, "attribute 'xml.schemaLocation' for class element is deprecated: it should be moved to model element" ); Map<String, String> fieldAttributes = modelReader.getAttributesForField( field ); Map<String, String> associationAttributes = modelReader.getAttributesForAssociation( (ModelAssociation)field ); upgradeModifiedAttribute( "java.adder", fieldAttributes, associationAttributes, "attribute 'java.adder' for field element is deprecated: it should be moved to association" ); upgradeModifiedAttribute( "java.generate-create", associationAttributes, "java.bidi", associationAttributes, "attribute 'java.generate-create' for association " + "element is deprecated: it has been renamed to 'java.bidi'" ); upgradeModifiedAttribute( "java.generate-break", associationAttributes, "java.bidi", associationAttributes, "attribute 'java.generate-break' for association " + "element is deprecated: it has been renamed to 'java.bidi'" ); upgradeModifiedAttribute( "java.use-interface", associationAttributes,
public Model loadModel( Reader reader ) throws ModelloException, ModelValidationException { ModelReader modelReader = new ModelReader(); Model model = modelReader.loadModel( reader ); model.initialize(); // keep backward compatibility with Modello attributes model changes upgradeModelloModel( modelReader, model ); handlePluginsMetadata( modelReader, model ); validate( model ); return model; }
throws ModelloException Collection<MetadataPlugin> plugins = metadataPluginManager.getPlugins().values(); Map<String, String> attributes = modelReader.getAttributesForModel(); Map<String, String> attributes = modelReader.getAttributesForClass( clazz ); Map<String, String> fieldAttributes = modelReader.getAttributesForField( modelAssociation ); Map<String, String> associationAttributes = modelReader.getAttributesForAssociation( modelAssociation ); attributes = modelReader.getAttributesForField( field ); Map<String, String> attributes = modelReader.getAttributesForInterface( iface );
public void output( Model model, Writer writer ) throws ModelloException { saveModel( model, writer ); } }
private void upgradeModifiedAttribute( String name, Map<String, String> from, Map<String, String> to, String warn ) { upgradeModifiedAttribute( name, from, name, to, warn ); }
public ModelloGenerator getGeneratorPlugin( String generatorId ) { ModelloGenerator generator = getPlugin( generatorId ); if ( generator == null ) { throw new ModelloRuntimeException( "No such generator plugin: '" + generatorId + "'." ); } return generator; }
public MetadataPlugin getMetadataPlugin( String metadataId ) { MetadataPlugin metadata = getPlugin( metadataId ); if ( metadata == null ) { throw new ModelloRuntimeException( "No such metadata plugin: '" + metadataId + "'." ); } return metadata; }
private void upgradeModifiedAttribute( String name, Map<String, String> from, String newName, Map<String, String> to, String warn ) { String value = from.remove( name ); if ( value != null ) { getLogger().warn( warn ); to.put( newName, value ); } }
public Model loadModel( File file ) throws IOException, ModelloException, ModelValidationException { Reader reader = null; try { reader = ReaderFactory.newXmlReader( file ); return loadModel( reader ); } finally { IOUtil.close( reader ); } }
public void generate( Model model, String outputType, Properties parameters ) throws ModelloException { if ( model == null ) { throw new ModelloRuntimeException( "Illegal argument: model == null." ); } if ( outputType == null ) { throw new ModelloRuntimeException( "Illegal argument: outputType == null." ); } if ( parameters == null ) { parameters = new Properties(); } ModelloGenerator generator = generatorPluginManager.getGeneratorPlugin( outputType ); generator.generate( model, parameters ); } }