Author: chatellier Date: 2009-04-26 20:40:15 +0000 (Sun, 26 Apr 2009) New Revision: 483 Added: eugene/trunk/src/site/en/ eugene/trunk/src/site/en/rst/ eugene/trunk/src/site/en/rst/LutinGenerator.rst eugene/trunk/src/site/resources/ eugene/trunk/src/site/resources/images/ eugene/trunk/src/test/java/org/nuiton/eugene/GeneratorTaskTest.java maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java Removed: eugene/trunk/src/site/en/LutinGenerator.rst eugene/trunk/src/site/rst/en/ eugene/trunk/src/site/rst/images/ maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/GeneratorPlugin.java Modified: eugene/trunk/changelog.txt eugene/trunk/pom.xml eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorTask.java eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorUtil.java eugene/trunk/src/main/java/org/nuiton/eugene/PackageValidator.java eugene/trunk/src/main/java/org/nuiton/eugene/StateModelGenerator.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAssociationClass.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAttribute.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelDependency.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelOperation.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelParameter.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/AttributeNamesValidator.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/NameBasedValidator.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelStateChartImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelTransitionImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModel.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java eugene/trunk/src/main/java/org/nuiton/eugene/package-info.java eugene/trunk/src/site/rst/generatorHelp.txt eugene/trunk/src/site/rst/index.rst eugene/trunk/src/site/site.xml maven-eugene-plugin/trunk/changelog.txt maven-eugene-plugin/trunk/pom.xml maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/helper/ResourceResolver.java Log: Improve eugene ant task. Recode eugene plugin without ant. Modified: eugene/trunk/changelog.txt =================================================================== --- eugene/trunk/changelog.txt 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/changelog.txt 2009-04-26 20:40:15 UTC (rev 483) @@ -1,3 +1,8 @@ +1.0.0 xxx xxx + * Improve ant task + * Move to org.nuiton groupid + * Rename project to Eugene + 0.65 chatellier 200903xx * Format all code, add generic Modified: eugene/trunk/pom.xml =================================================================== --- eugene/trunk/pom.xml 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/pom.xml 2009-04-26 20:40:15 UTC (rev 483) @@ -9,7 +9,7 @@ <parent> <groupId>org.codelutin</groupId> <artifactId>lutinproject</artifactId> - <version>3.4</version> + <version>3.5</version> </parent> <groupId>org.nuiton</groupId> @@ -52,7 +52,7 @@ <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.7.1</version> - <scope>compile</scope> + <scope>provided</scope> </dependency> <dependency> @@ -68,6 +68,12 @@ <artifactId>jaxen</artifactId> <version>1.1.1</version> <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>com.ibm.icu</groupId> + <artifactId>icu4j</artifactId> + </exclusion> + </exclusions> </dependency> <!-- Meta model uml d'eclipse --> @@ -107,34 +113,37 @@ <!-- name du projet du labs --> <labs.project>lutingenerator</labs.project> - <lutinutil.version>1.0.3</lutinutil.version> + <lutinutil.version>1.0.4</lutinutil.version> </properties> <build> <defaultGoal>install</defaultGoal> + <resources> + <resource> + <directory>${maven.src.dir}/main/xsl</directory> + <includes> + <include>**/*.xsl</include> + </includes> + </resource> + </resources> + <plugins> - <!-- Always process jrst files, but only called on pre-site phase --> + <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-jrst-plugin</artifactId> - <version>0.8.4</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> <configuration> - <directoryIn>${maven.src.dir}/site</directoryIn> - <directoryOut>${maven.site.gen.dir}</directoryOut> - <defaultLocale>fr</defaultLocale> - <inputEncoding>${project.build.sourceEncoding}</inputEncoding> - <outputEncoding>${project.build.sourceEncoding}</outputEncoding> + <locales>fr,en</locales> </configuration> - <executions> - <execution> - <phase>pre-site</phase> - <goals> - <goal>jrst</goal> - </goals> - </execution> - </executions> + <dependencies> + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>doxia-module-jrst</artifactId> + <version>1.0.0</version> + </dependency> + </dependencies> </plugin> <plugin> Modified: eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorTask.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorTask.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorTask.java 2009-04-26 20:40:15 UTC (rev 483) @@ -18,36 +18,34 @@ package org.nuiton.eugene; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.ServiceLoader; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.Path; import org.codelutin.util.Resource; +import org.codelutin.util.ZipUtil; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -61,11 +59,11 @@ * <taskdef name="generator" classname="org.nuiton.eugene.GeneratorTask" * classpath="${compile.classpath}:${targetbuild}:${resources}" /> * - * <target name="generate" depends="pre-compile" description="generate"> + * <target name="generate" description="generate"> * <generator srcdir="${modelDir}" destdir="${targetgen}" - * resolver="ResourceResolver" - * templates="ClassInfoGenerator,JavaBeanGenerator" - * properties="defaultPackage=org.codelutin,fullPackagePath=org.codelutin,extraPackages=org.codelutin" + * resolver="org.nuiton.exemple.ResourceResolver" + * templates="org.nuiton.example.JavaBeanGenerator" + * properties="defaultPackage=org.nuiton,fullPackagePath=org.nuiton,extraPackages=org.nuiton" * classpath="${compile.classpath}:${targetbuild}:${resources}" /> * </target> * </pre> @@ -75,100 +73,89 @@ * @author Benjamin Poussin <poussin@codelutin.com> Copyright Code Lutin * @version $Revision$ * - * Mise a jour: $Date$ - * par : $Author$ + * Mise a jour: $Date$ + * par : $Author$ */ public class GeneratorTask extends MatchingTask { // GeneratorTask + /** Ant classpath to use. */ + protected Path classpath; + /** Template used in generation (comma separated). */ - protected String templates = null; + protected String templates; - /** Template to exclude in templates list. */ - protected List<String> excludeTemplates; - /** Model directory. */ - protected File srcDir = null; + protected File srcDir; /** Single model file. */ - protected File srcFile = null; + protected File srcFile; /** Destination directory. */ - protected File destDir = null; + protected File destDir; + /** + * Transformation to do on model (comma separated). + * + * Values are : + * - object (transform into object model) + * - state (transform into state model) + */ + protected String transformations = "object"; + /** URI Resolver. */ - protected String resolver = null; + protected String resolver; - /** Additional generator properties. */ + /** + * Additional generator properties. + * + * Values are : + * - fullPackagePath : full package path + * - extraPackages : extra package path + * - defaultPackage (extra generated model files) + */ protected Properties properties = new Properties(); /** Overwrite already existing generated files. */ - protected boolean overwrite = true; + protected boolean overwrite; - /** - * Ant classpath to use. - */ - private Path classpath = null; - - /** Enconding. Default to UTF-8. */ + /** Encoding. Default to UTF-8. */ protected String encoding = "UTF-8"; - /** log. */ - private static final Log log = LogFactory.getLog(GeneratorTask.class); + /** Generation directory (default to 'build') */ + protected String buildDirectory = "build"; - public GeneratorTask() { - + /** + * Set the optional classpath to the XSL processor + * + * @param classpath the classpath to use when loading the XSL processor + */ + public void setClasspath(Path classpath) { + Path antDefaulClasspath = createClasspath(); + antDefaulClasspath.append(classpath); } - protected void doExecute(File srcFile, File destDir, Generator[] generators) - throws BuildException { - doExecute(new File[] { srcFile }, destDir, generators); - - } - - protected void doExecute(File[] srcFiles, File destDir, - Generator[] generators) throws BuildException { - - srcFiles = doConvertFiles(srcFiles, destDir); - - for (Generator generator : generators) { - if (generator != null) { - log("Applying " + generator.getClass().getName() + " into " - + destDir); - generator.setProperties(properties); - generator.setOverwrite(overwrite); - for (int i = 0; i < srcFiles.length; i++) { - if (srcFiles[i].getName().endsWith(".objectmodel")) { - generator.generate(srcFiles[i], destDir); - } - } - } - } - } - - public void setOverwrite(boolean v) { - overwrite = v; - } - + /** + * Set templates (fully-qualified-name) to use + * + * (comma-separated). + * + * @param templates template to use. + */ public void setTemplates(String templates) { this.templates = templates; } - public void setExcludeTemplates(List<String> excludeTemplates) { - this.excludeTemplates = excludeTemplates; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - /** - * Set the optional classpath to the XSL processor + * Transformation to do. * - * @param classpath - * the classpath to use when loading the XSL processor + * Values are : + * - object (transform into object model) + * - state (transform into state model) + * + * @param transformations transformations */ - public void setClasspath(Path classpath) { - createClasspath().append(classpath); + public void setTransformations(String transformations) { + this.transformations = transformations; } /** @@ -176,7 +163,7 @@ * * @return a path instance to be configured by the Ant core. */ - public Path createClasspath() { + protected Path createClasspath() { if (classpath == null) { classpath = new Path(getProject()); } @@ -184,10 +171,9 @@ } /** - * Permet d'ajouter des properties. exemple: toto=1,package=org.codelutin + * Permet d'ajouter des properties. exemple: toto=1,package=org.nuiton * - * @param properties - * properties + * @param properties properties */ public void setProperties(String properties) { String[] props = properties.split(","); @@ -195,71 +181,83 @@ String[] pv = prop.split("="); this.properties.put(pv[0], pv[1]); } - Logger.getLogger(getClass().getName() + ".setProperties").log( - Level.FINE, "Properties " + this.properties); } + /** + * Set overwrite value. + * + * @param overwrite overwrite value + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + + /** + * Set encoding. + * + * @param encoding encoding + */ + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + /** + * Set source directory. + * + * @param srcDir source directory + */ public void setSrcdir(File srcDir) { this.srcDir = srcDir; } + /** + * Set source file. + * + * @param srcFile source file + */ + public void setSrcfile(File srcFile) { + this.srcFile = srcFile; + } + + /** + * Set destination directory + * + * @param destDir destination directory + */ public void setDestdir(File destDir) { this.destDir = destDir; } - public void setSrcFile(File srcFile) { - this.srcFile = srcFile; + /** + * Set build directory. + * + * @param buildDirectory build directory + */ + public void setBuilddirectory(String buildDirectory) { + this.buildDirectory = buildDirectory; } + /** + * Set URI resolver (FQN). + * + * @param resolver uri resolver + */ public void setResolver(String resolver) { this.resolver = resolver; } + /** + * {@inheritDoc} + */ @Override public void execute() throws BuildException { - Generator[] generators; + + // check if (templates == null) { throw new BuildException("templates attribute must be set!", getLocation()); } - List<String> templateGenerators = Arrays.asList(templates.split(",")); - for (Iterator<String> it = templateGenerators.iterator(); it.hasNext();) { - String templateGenerator = it.next(); - if (excludeTemplates != null - && excludeTemplates.contains(templateGenerator)) { - it.remove(); - } - } - generators = new Generator[templateGenerators.size()]; - for (int i = 0; i < templateGenerators.size(); i++) { - String templateName = templateGenerators.get(i); - try { - generators[i] = newGeneratorInstance(templateName); - // generators[i] = (Generator) - // Class.forName(templateName).newInstance(); - generators[i].setExcludeTemplates(excludeTemplates); - generators[i].setEncoding(encoding); - - } catch (ClassCastException eee) { - System.out.println("Generator don't herite Generator Class : " - + templateName); - eee.printStackTrace(); - } catch (ClassNotFoundException eee) { - System.out - .println("Unable to find generator : " + templateName); - eee.printStackTrace(); - } catch (InstantiationException eee) { - System.out.println("Unable to instanciate template : " - + templateName); - eee.printStackTrace(); - } catch (IllegalAccessException eee) { - System.out.println("Unable to parse topia input file : " - + templateName); - eee.printStackTrace(); - } - } - if (destDir == null) { throw new BuildException("destDir attribute must be set!", getLocation()); @@ -272,7 +270,7 @@ if (srcFile == null && srcDir == null) { throw new BuildException( - "srcFile or srcdir attribute must be set!", getLocation()); + "srcFile or srcDir attribute must be set!", getLocation()); } if (srcFile != null && !srcFile.isFile()) { @@ -280,229 +278,387 @@ + "\" does not exist or is not a file", getLocation()); } + String[] templateGenerators = templates.split(","); + Generator[] generators = new Generator[templateGenerators.length]; + for (int i = 0; i < templateGenerators.length; i++) { + String templateName = templateGenerators[i].trim(); + try { + generators[i] = (Generator) Class.forName(templateName) + .newInstance(); + generators[i].setEncoding(encoding); + generators[i].setProperties(properties); + generators[i].setOverwrite(overwrite); + + } catch (ClassCastException e) { + log("Generator don't herite Generator Class", e, + Project.MSG_ERR); + } catch (ClassNotFoundException e) { + log("Unable to find generator" + templateName, e, + Project.MSG_ERR); + } catch (InstantiationException e) { + log("Unable to instanciate template" + templateName, e, + Project.MSG_ERR); + } catch (IllegalAccessException e) { + log("Unable to parse topia input file" + templateName, e, + Project.MSG_ERR); + } + } + if (srcFile != null) { // generate the source files doExecute(srcFile, destDir, generators); } else { DirectoryScanner scanner; - String[] includedFilenames; scanner = getDirectoryScanner(srcDir); // Process all the files marked for styling - includedFilenames = scanner.getIncludedFiles(); - File[] includedFiles = new File[includedFilenames.length]; + String[] includedFilenames = scanner.getIncludedFiles(); + List<File> includedFiles = new ArrayList<File>( + includedFilenames.length); for (int i = 0; i < includedFilenames.length; ++i) { - includedFiles[i] = new File(srcDir, includedFilenames[i]); + includedFiles.add(new File(srcDir, includedFilenames[i])); } doExecute(includedFiles, destDir, generators); } } - private File[] doConvertFiles(File[] srcFiles, File destDir) { + /** + * Equivalent to <tt>doExecute(new File[] { srcFile }, destDir, generators)</tt>. + * + * @param srcFile file to apply generator to + * @param destDir destination directory + * @param generators generators to apply + * @throws BuildException if can't generate + */ + protected void doExecute(File srcFile, File destDir, Generator[] generators) + throws BuildException { + doExecute(Collections.singletonList(srcFile), destDir, generators); + } + + /** + * Execute generation on specified files. + * + * @param srcFiles files to apply generator to + * @param destDir destination directory + * @param generators generators to apply + * @throws BuildException if can't generate + */ + protected void doExecute(List<File> srcFiles, File destDir, + Generator[] generators) throws BuildException { + + // log classpath + log("Using classpath : " + classpath); + + List<File> modelFiles = doConvertFiles(srcFiles, destDir); + + for (Generator generator : generators) { + if (generator != null) { + for (File modelFile : modelFiles) { + log("Applying " + generator.getClass().getSimpleName() + + " on " + modelFile.getAbsolutePath(), + Project.MSG_INFO); + generator.generate(modelFile, destDir); + } + } + } + } + + /** + * Convert srcFiles and return only eugene models files. + * + * Do following convertions : + * - unzip archive (zipped files) + * - xslt transformation (xmi files) + * - do nothing on model files + * + * @param srcFiles + * @param destDir + * @return model file list + */ + protected List<File> doConvertFiles(List<File> srcFiles, File destDir) { + List<File> result = new ArrayList<File>(); - for (File file : srcFiles) { - if (file.getName().endsWith(".objectmodel")) { - result.add(file); - } else { - File xmiFile = null; - String xmiVersion = null; - String destFileName = file.getName().substring(0, - file.getName().lastIndexOf('.')); - File destUnZipDir = new File("tmp-" + destFileName); + // transform tranformations list + String[] transformationsArray = transformations.split(","); - // unzip files - if (file.getName().endsWith(".zargo") - || file.getName().endsWith(".zuml")) { + for (File file : srcFiles) { - // destination folder - destUnZipDir.mkdir(); + File currentFile = file; - unzip(file, destUnZipDir); + // unzip if needed + // after loop file is xmi + if (isArchiveFile(currentFile)) { - xmiFile = new File(destUnZipDir.getAbsolutePath() - + File.separator + destFileName + ".xmi"); - } else if (file.getName().endsWith(".uml") - || file.getName().endsWith(".xmi")) { - xmiFile = file; + File unzipDirectory = new File(buildDirectory, "xmi"); + if (unzipDirectory.exists()) { + unzipDirectory.mkdirs(); } + // log + log("Unzip " + currentFile.getAbsolutePath() + " into " + + unzipDirectory.getAbsolutePath(), Project.MSG_INFO); + try { + ZipUtil.uncompress(file, unzipDirectory); + } catch (IOException e) { + throw new BuildException("Error on unzip archive", e); + } - System.out.println(xmiFile); + String xmiName = currentFile.getName().substring(0, + currentFile.getName().lastIndexOf('.')) + + ".xmi"; + currentFile = new File(unzipDirectory, xmiName); + } - // XMI to ObjectModel - xmiVersion = getXmiVersion(xmiFile); - String omFileName = srcDir + File.separator + destFileName - + ".objectmodel"; - if (xmiVersion.equals("1.2")) { - XMLtransform(xmiFile.getAbsolutePath(), omFileName, - "xmi1.2ToObjectModel.xsl"); - } else if (xmiVersion.equals("2.1")) { - XMLtransform(xmiFile.getAbsolutePath(), omFileName, - "xmi2.1ToObjectModel.xsl"); - } + // transform file if needed + // after loop file is model (object, state, ui) + if (isXmiFile(currentFile)) { + String xmiVersion = getXmiVersion(currentFile); - result.add(new File(omFileName)); + if (xmiVersion != null) { - // delete unzipped files - if (file.getName().endsWith(".zargo") - || file.getName().endsWith(".zuml")) { + // model directory + File outputDirectory = new File(buildDirectory, "models"); + outputDirectory.mkdirs(); + // single model name + String modelName = currentFile.getName().substring(0, + currentFile.getName().lastIndexOf('.')); - delete(destUnZipDir); + for (String transformation : transformationsArray) { + + // object + if (transformation.trim().equalsIgnoreCase("object")) { + File outputFile = new File(outputDirectory, + modelName + ".objectmodel"); + if (xmiVersion.equals("1.2")) { + log("Apply XMI 1.2 to object model XSLT on " + + currentFile.getAbsolutePath(), + Project.MSG_INFO); + executeXSLT(currentFile, outputFile, + "xmi1.2ToObjectModel.xsl"); + } else if (xmiVersion.equals("2.1")) { + log("Apply XMI 2.1 to object model XSLT on " + + currentFile.getAbsolutePath(), + Project.MSG_INFO); + executeXSLT(currentFile, outputFile, + "xmi2.1ToObjectModel.xsl"); + } + + // can have more than one model file + // for one xmi + result.add(outputFile); + } + + // state + else if (transformation.trim() + .equalsIgnoreCase("state")) { + File outputFile = new File(outputDirectory, + modelName + ".statemodel"); + if (xmiVersion.equals("1.2")) { + log("Apply XMI 1.2 to state model XSLT on " + + currentFile.getAbsolutePath(), + Project.MSG_INFO); + executeXSLT(currentFile, outputFile, + "xmi1.2ToStateModel.xsl"); + } else if (xmiVersion.equals("2.1")) { + throw new BuildException( + "State model transformation is not supported for xmi 2.1"); + } + + // can have more than one model file + // for one xmi + result.add(outputFile); + } + } + } else { + throw new BuildException( + "Can't get xmi version from file : " + + currentFile.getAbsolutePath()); } + } + // others files + // we can have model files or non model file + else if (isModelFile(currentFile)) { + result.add(currentFile); } + } - return result.toArray(new File[result.size()]); + + return result; } - private void unzip(File zipFile, File destFile) { - try { + /** + * Test if file is an archive. + * + * @param file file to test + * @return test result + */ + protected boolean isArchiveFile(File file) { + String fileName = file.getName(); - // uncompress zip archive - ZipInputStream zipin = new ZipInputStream(new FileInputStream( - zipFile)); - ZipEntry zipe = null; - while ((zipe = zipin.getNextEntry()) != null) { - FileOutputStream fileout = new FileOutputStream(destFile - .getAbsolutePath() - + File.separator + zipe.getName()); + boolean result = fileName.endsWith(".zargo") + || fileName.endsWith(".zuml"); + return result; + } - // write current file - byte[] buf = new byte[1024]; - int rsize; - while ((rsize = zipin.read(buf)) > -1) - fileout.write(buf, 0, rsize); + /** + * Test if file is a xmi. + * + * @param file file to test + * @return test result + */ + protected boolean isXmiFile(File file) { + String fileName = file.getName(); - zipin.closeEntry(); - fileout.close(); - } - zipin.close(); - } catch (Exception e) { - System.out.println("Unzip error"); - e.printStackTrace(); - } + boolean result = fileName.endsWith(".uml") || fileName.endsWith(".xmi"); + return result; } - private void delete(File dir) { - if (dir.exists()) { - File[] files = dir.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - delete(files[i]); - } else { - files[i].delete(); - } - } - } - dir.delete(); + /** + * Test if file is a model + * + * @param file file to test + * @return test result + */ + protected boolean isModelFile(File file) { + String fileName = file.getName(); + + boolean result = fileName.endsWith(".objectmodel") + || fileName.endsWith(".statemodel"); + return result; } - private String getXmiVersion(File XMIFile) { + /** + * Try to find xmi version on a file. + * + * @param xmiFile file to inspect + * @return version or null if version can't have been found + */ + protected String getXmiVersion(File xmiFile) { String version = null; + + SAXParserFactory factory = SAXParserFactory.newInstance(); + try { - SAXParserFactory fabrique = SAXParserFactory.newInstance(); - SAXParser parser = fabrique.newSAXParser(); + SAXParser parser = factory.newSAXParser(); - DefaultHandler handler = new XmiVersionHandler(); - parser.parse(XMIFile, handler); + XmiVersionHandler handler = new XmiVersionHandler(); + parser.parse(xmiFile, handler); - } catch (Exception e) { - version = e.getMessage(); + version = handler.getVersion(); + } catch (ParserConfigurationException e) { + log("Can't parse file as xmi", e, Project.MSG_DEBUG); + } catch (SAXException e) { + log("Can't parse file as xmi", e, Project.MSG_DEBUG); + } catch (IOException e) { + log("Can't parse file as xmi", e, Project.MSG_DEBUG); } + return version; } - private class XmiVersionHandler extends DefaultHandler { + /** + * Sax handler to find xmi version into xmi document. + */ + protected class XmiVersionHandler extends DefaultHandler { + public String version = null; public XmiVersionHandler() { super(); } + public String getVersion() { + return version; + } + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equals("XMI")) { version = attributes.getValue("xmi.version"); + log("XMI version found : " + version, Project.MSG_DEBUG); } + if (version == null) { version = attributes.getValue("xmi:version"); + log("XMI version found : " + version, Project.MSG_DEBUG); } - if (log.isInfoEnabled()) { - log.info("XMI version found : " + version); - } - throw new SAXException(version); } - - public void startDocument() throws SAXException { - if (log.isInfoEnabled()) { - log.info("Parsing XMI version..."); - } - } - - public void endDocument() throws SAXException { - if (log.isInfoEnabled()) { - log.info("XMI version not found"); - } - } } - private void XMLtransform(String xmlFrom, String xmlTo, String xsl) { + /** + * Do XSLT transformation on given file using specific stylesheet. + * + * @param xmiFile xmi file to transform + * @param modelFile result of transformation + * @param stylesheet stylesheet to use + */ + protected void executeXSLT(File xmiFile, File modelFile, String stylesheet) { - if (log.isDebugEnabled()) { - log.debug("XMLtransform : java.class.path = " - + System.getProperty("java.class.path")); - } - // Transformation XSL try { - String[] jars = classpath.list(); - URL[] jarsURL = new URL[jars.length]; - for (int i = 0; i < jars.length; i++) { - jarsURL[i] = new File(jars[i]).toURI().toURL(); + // transform ant classpath into + // URLclassloader + ClassLoader urlLoader = null; + if (classpath != null) { + String[] jars = classpath.list(); + URL[] jarsURL = new URL[jars.length]; + for (int i = 0; i < jars.length; i++) { + jarsURL[i] = new File(jars[i]).toURI().toURL(); + } + urlLoader = new URLClassLoader(jarsURL); + } else { + urlLoader = Thread.currentThread().getContextClassLoader(); } - URLClassLoader urlLoader = new URLClassLoader(jarsURL); - - URIResolver tresolver = (URIResolver) Class.forName(resolver, true, - urlLoader).newInstance(); - - // FIXME remove hard coded factory name - Iterator<TransformerFactory> itTransformerFactory = - ServiceLoader.load(TransformerFactory.class, urlLoader).iterator(); + // Load Transformer with service loader + Iterator<TransformerFactory> itTransformerFactory = ServiceLoader + .load(TransformerFactory.class, urlLoader).iterator(); if (!itTransformerFactory.hasNext()) { - throw new BuildException("No XLTS Transformer found"); + throw new BuildException("No XSLT Transformer found"); } - // take first impl found TransformerFactory transformerFactory = itTransformerFactory.next(); - URL uxsl = Resource.getURL(xsl); + URL uxsl = Resource.getURL(stylesheet); StreamSource stylesource = new StreamSource(uxsl.openStream()); - Transformer transformer = transformerFactory.newTransformer(stylesource); - transformer.setParameter("fullPackagePath", properties - .getProperty("fullPackagePath")); - transformer.setParameter("extraPackages", properties - .getProperty("extraPackages")); - transformer.setURIResolver(tresolver); - if (log.isInfoEnabled()) { - log.info("FROM: " + xmlFrom); - log.info("TO: " + xmlTo); + Transformer transformer = transformerFactory + .newTransformer(stylesource); + + if (properties.containsKey("fullPackagePath")) { + transformer.setParameter("fullPackagePath", properties + .getProperty("fullPackagePath")); } - transformer.transform(new StreamSource(xmlFrom), new StreamResult( - xmlTo)); - } catch (Exception e) { - System.out.println("Transformation error"); - e.printStackTrace(); + + if (properties.containsKey("extraPackages")) { + transformer.setParameter("extraPackages", properties + .getProperty("extraPackages")); + } + + if (resolver != null && !resolver.isEmpty()) { + URIResolver tresolver = (URIResolver) Class.forName(resolver, + true, urlLoader).newInstance(); + transformer.setURIResolver(tresolver); + } + + transformer.transform(new StreamSource(xmiFile.getAbsolutePath()), + new StreamResult(modelFile.getAbsolutePath())); + } catch (TransformerException e) { + throw new BuildException("Transformation exception (xslt)", e); + } catch (MalformedURLException e) { + throw new BuildException("Invalid jar url", e); + } catch (InstantiationException e) { + throw new BuildException("Can't init resolver", e); + } catch (IllegalAccessException e) { + throw new BuildException("Can't access resolver", e); + } catch (ClassNotFoundException e) { + throw new BuildException("Can't found resolver", e); + } catch (IOException e) { + throw new BuildException("Error while trying to access stylesheet", + e); } } - protected Generator newGeneratorInstance(String fqn) - throws ClassNotFoundException, IllegalAccessException, - InstantiationException { - Generator newInstance = (Generator) Class.forName(fqn).newInstance(); - - return newInstance; - } } // GeneratorTask Modified: eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorUtil.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2009-04-26 20:40:15 UTC (rev 483) @@ -35,12 +35,12 @@ /** * GeneratorUtil. * - * Created: 25 ao?t 2003 + * Created: 25 aout 2003 * * @author Benjamin Poussin <poussin@codelutin.com> Copyright Code Lutin - * @version $Revision: 317 $ - * Mise à jour: $Date: 2008-09-25 10:45:22 +0200 (jeu 25 sep 2008) $ - * By : $Author: thimel $ + * @version $Revision$ + * Mise à jour: $Date$ + * By : $Author$ */ public class GeneratorUtil { @@ -85,7 +85,7 @@ /** * return all classifiers belonging to the given package recursively. The Collection may be empty. - * @see ObjectModelCassifier + * @see ObjectModelClassifier * * @return a Collection containing all classifiers belonging to the given package recursively. */ @@ -112,7 +112,7 @@ * ou le type defini si la cardinalité n'est pas multiple * * @param attribute - * @return + * @return attribute type */ public static String getAttributeType(ObjectModelParameter attribute, boolean useGenerics) { @@ -139,8 +139,9 @@ */ public static boolean isPrimitiveAttributeType( ObjectModelAttribute attribute) { - if (isNMultiplicity(attribute)) + if (isNMultiplicity(attribute)) { return false; + } String type = attribute.getType(); return ("byte".equals(type) || "short".equals(type) || "int".equals(type) || "long".equals(type) @@ -153,75 +154,103 @@ * @return a String with the corresponding attribute init value */ public static String getInitValue(ObjectModelAttribute attribute) { - if (isNMultiplicity(attribute)) + if (isNMultiplicity(attribute)) { return "new java.util.ArrayList()"; + } return getInitValue(attribute.getType()); } public static String getInitValue(String type) { - if ("byte".equals(type)) + if ("byte".equals(type)) { return "0"; - if ("short".equals(type)) + } + if ("short".equals(type)) { return "0"; - if ("int".equals(type)) + } + if ("int".equals(type)) { return "0"; - if ("long".equals(type)) + } + if ("long".equals(type)) { return "0"; - if ("float".equals(type)) + } + if ("float".equals(type)) { return "0"; - if ("double".equals(type)) + } + if ("double".equals(type)) { return "0"; - if ("char".equals(type)) + } + if ("char".equals(type)) { return "\u0000"; - if ("boolean".equals(type)) + } + if ("boolean".equals(type)) { return "false"; - if ("java.lang.String".equals(type)) + } + if ("java.lang.String".equals(type)) { return null; - if ("java.lang.Date".equals(type)) + } + if ("java.lang.Date".equals(type)) { return null; + } return null; } public static String getCastValue(String type, String o) { - if ("byte".equals(type)) + if ("byte".equals(type)) { return "((Byte)" + o + ").byteValue()"; - if ("short".equals(type)) + } + if ("short".equals(type)) { return "((Short)" + o + ").shortValue()"; - if ("int".equals(type)) + } + if ("int".equals(type)) { return "((Integer)" + o + ").intValue()"; - if ("long".equals(type)) + } + if ("long".equals(type)) { return "((Long)" + o + ").longValue()"; - if ("float".equals(type)) + } + if ("float".equals(type)) { return "((Float)" + o + ").floatValue()"; - if ("double".equals(type)) + } + if ("double".equals(type)) { return "((Double)" + o + ").doubleValue()"; - if ("char".equals(type)) + } + if ("char".equals(type)) { return "((Character)" + o + ").charValue()"; - if ("boolean".equals(type)) + } + if ("boolean".equals(type)) { return "((Boolean)" + o + ").booleanValue()"; - if ("void".equals(type)) + } + if ("void".equals(type)) { return ""; + } return "(" + type + ")" + o; } public static String getHashCodeExpression(String type, String o) { String result = o; - if ("byte".equals(type)) + if ("byte".equals(type)) { result = "new Byte(" + o + ")"; - if ("short".equals(type)) + } + if ("short".equals(type)) { result = "new Short(" + o + ")"; - if ("int".equals(type)) + } + if ("int".equals(type)) { result = "new Integer(" + o + ")"; - if ("long".equals(type)) + } + if ("long".equals(type)) { result = "new Long(" + o + ")"; - if ("float".equals(type)) + } + if ("float".equals(type)) { result = "new Float(" + o + ")"; - if ("double".equals(type)) + } + if ("double".equals(type)) { result = "new Double(" + o + ")"; - if ("char".equals(type)) + } + if ("char".equals(type)) { result = "new Character(" + o + ")"; - if ("boolean".equals(type)) + } + if ("boolean".equals(type)) { result = "new Boolean(" + o + ")"; + } return result + ".hashCode()"; } @@ -276,8 +305,9 @@ * @return true is the multiplicity of the given attribute is exactly 1 */ public static boolean isOneMultiplicity(ObjectModelAttribute attribute) { - if (attribute == null) + if (attribute == null) { return false; + } return ((attribute.getMinMultiplicity() == 1) && (attribute .getMaxMultiplicity() == 1)); } @@ -320,51 +350,71 @@ public static String getParsingExpression(String type, String attributeStringName) { - if ("byte".equals(type)) + if ("byte".equals(type)) { return "Byte.parseByte(" + attributeStringName + ")"; - if ("short".equals(type)) + } + if ("short".equals(type)) { return "Short.parseShort(" + attributeStringName + ")"; - if ("int".equals(type)) + } + if ("int".equals(type)) { return "Integer.parseInt(" + attributeStringName + ")"; - if ("long".equals(type)) + } + if ("long".equals(type)) { return "Long.parseLong(" + attributeStringName + ")"; - if ("float".equals(type)) + } + if ("float".equals(type)) { return "Float.parseFloat(" + attributeStringName + ")"; - if ("double".equals(type)) + } + if ("double".equals(type)) { return "Double.parseDouble(" + attributeStringName + ")"; - if ("char".equals(type)) + } + if ("char".equals(type)) { return attributeStringName + ".charAt(0)"; - if ("boolean".equals(type)) + } + if ("boolean".equals(type)) { return "Boolean.parseBoolean(" + attributeStringName + ")"; - if ("java.lang.String".equals(type)) + } + if ("java.lang.String".equals(type)) { return attributeStringName; - if ("java.util.Date".equals(type)) + } + if ("java.util.Date".equals(type)) { return "dateParser.parse(" + attributeStringName + ")"; + } return null; } public static String getFormatingExpression(String type, String attributeStringName) { - if ("byte".equals(type)) + if ("byte".equals(type)) { return "Byte.toString(" + attributeStringName + ")"; - if ("short".equals(type)) + } + if ("short".equals(type)) { return "Short.toString(" + attributeStringName + ")"; - if ("int".equals(type)) + } + if ("int".equals(type)) { return "Integer.toString(" + attributeStringName + ")"; - if ("long".equals(type)) + } + if ("long".equals(type)) { return "Long.toString(" + attributeStringName + ")"; - if ("float".equals(type)) + } + if ("float".equals(type)) { return "Float.toString(" + attributeStringName + ")"; - if ("double".equals(type)) + } + if ("double".equals(type)) { return "Double.toString(" + attributeStringName + ")"; - if ("char".equals(type)) + } + if ("char".equals(type)) { return "Character.toString(" + attributeStringName + ")"; - if ("boolean".equals(type)) + } + if ("boolean".equals(type)) { return "Boolean.parseBoolean(" + attributeStringName + ")"; - if ("java.lang.String".equals(type)) + } + if ("java.lang.String".equals(type)) { return attributeStringName; - if ("java.util.Date".equals(type)) + } + if ("java.util.Date".equals(type)) { return "dateParser.format(" + attributeStringName + ")"; + } return null; } Property changes on: eugene/trunk/src/main/java/org/nuiton/eugene/GeneratorUtil.java ___________________________________________________________________ Name: svn:keywords + Date Author Revision Modified: eugene/trunk/src/main/java/org/nuiton/eugene/PackageValidator.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/PackageValidator.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/PackageValidator.java 2009-04-26 20:40:15 UTC (rev 483) @@ -68,10 +68,12 @@ */ public static boolean isValid(String fullPackagePath, String localPackageName, String extraPackages) { - if (localPackageName.startsWith(fullPackagePath)) + if (localPackageName.startsWith(fullPackagePath)) { return true; - if (localPackageName.length() == 0) + } + if (localPackageName.length() == 0) { return false; + } String[] packages = extraPackages.split(","); for (int i = 0; i < packages.length; i++) { packages[i] = packages[i].trim(); Modified: eugene/trunk/src/main/java/org/nuiton/eugene/StateModelGenerator.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/StateModelGenerator.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/StateModelGenerator.java 2009-04-26 20:40:15 UTC (rev 483) @@ -241,7 +241,7 @@ * Return filename from model * * @param stateModel - * @return + * @return model file name */ protected String getFilenameFromModel(StateModel stateModel) { return stateModel.getName(); Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModel.java 2009-04-26 20:40:15 UTC (rev 483) @@ -44,7 +44,7 @@ * * @return a Collection containing all ObjectModelClassifier for this model. */ - public abstract Collection<ObjectModelClassifier> getClassifiers(); + public Collection<ObjectModelClassifier> getClassifiers(); /** * Returns the classifier corresponding to the given qualified name, or null if the model contains no classifier for this qualified name. @@ -52,7 +52,7 @@ * * @return the ObjectModelClassifier of the found classifier, or null if the model contains no classifier for this qualified name. */ - public abstract ObjectModelClassifier getClassifier( + public ObjectModelClassifier getClassifier( String qualifiedClassifierName); /** @@ -61,7 +61,7 @@ * * @return a Collection containing all ObjectModelClass for this model. */ - public abstract Collection<ObjectModelClass> getClasses(); + public Collection<ObjectModelClass> getClasses(); /** * Returns the class corresponding to the given qualified name, or null if the model contains no class for this qualified name. @@ -69,7 +69,7 @@ * * @return the ObjectModelClass of the found class, or null if the model contains no class for this qualified name. */ - public abstract ObjectModelClass getClass(String qualifiedClassName); + public ObjectModelClass getClass(String qualifiedClassName); /** * Indicates whether the model contains the class associated to the given className @@ -77,7 +77,7 @@ * * @return true if the class has been found. */ - public abstract boolean hasClass(String qualifiedClassName); + public boolean hasClass(String qualifiedClassName); /** * Returns all interfaces defined in this model. @@ -85,7 +85,7 @@ * * @return a Collection containing all ObjectModelInterface for this model. */ - public abstract Collection<ObjectModelInterface> getInterfaces(); + public Collection<ObjectModelInterface> getInterfaces(); /** * Returns the interface corresponding to the given qualified name, or null if the model contains no interface for this qualified name. @@ -93,7 +93,7 @@ * * @return the ObjectModelInterface of the found interface, or null if the model contains no interface for this qualified name. */ - public abstract ObjectModelInterface getInterface( + public ObjectModelInterface getInterface( String qualifiedInterfaceName); /** @@ -101,6 +101,6 @@ * * @return a List containing all comments for this model as Strings. */ - public abstract List<String> getComments(); + public List<String> getComments(); } //ObjectModel Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAssociationClass.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAssociationClass.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAssociationClass.java 2009-04-26 20:40:15 UTC (rev 483) @@ -37,7 +37,7 @@ * * @return a List containing all participants attributes for this association class. */ - public abstract List<ObjectModelAttribute> getParticipantsAttributes(); + public List<ObjectModelAttribute> getParticipantsAttributes(); /** * Returns all participants (that is association ends) classifiers for this association class. @@ -45,6 +45,6 @@ * * @return a List containing all participants classifiers for this association class. */ - public abstract List<ObjectModelClassifier> getParticipantsClassifiers(); + public List<ObjectModelClassifier> getParticipantsClassifiers(); } //ObjectModelAssociationClass Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAttribute.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAttribute.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelAttribute.java 2009-04-26 20:40:15 UTC (rev 483) @@ -37,21 +37,21 @@ * * @return the type of this attribute. */ - public abstract String getType(); + public String getType(); /** * Returns whether this attribute is an aggregate or not. * * @return a boolean indicating whether this attribute is an aggregate or not. */ - public abstract boolean isAggregate(); + public boolean isAggregate(); /** * Returns whether this attribute is a composite or not. * * @return a boolean indicating whether this attribute is a composite or not. */ - public abstract boolean isComposite(); + public boolean isComposite(); /** * Returns the visibility of this attribute. @@ -59,7 +59,7 @@ * * @return the visibility of this attribute. */ - public abstract String getVisibility(); + public String getVisibility(); /** * Returns the minimal multiplicity of this attribute. @@ -67,7 +67,7 @@ * * @return the minimal multiplicity of this attribute. */ - public abstract int getMinMultiplicity(); + public int getMinMultiplicity(); /** * Returns the maximal multiplicity of this attribute. @@ -75,21 +75,21 @@ * * @return the maximal multiplicity of this attribute. */ - public abstract int getMaxMultiplicity(); + public int getMaxMultiplicity(); /** * Returns whether this attribute reference a model classifier or not. * * @return a boolean indicating whether this attribute reference a model classifier or not. */ - public abstract boolean referenceClassifier(); + public boolean referenceClassifier(); /** * Returns the classifier referenced by this attribute or null if it does not reference a model classifier. * * @return the ObjectModelClassfifier referenced by this attribute or null if it does not reference a model classifier. */ - public abstract ObjectModelClassifier getClassifier(); + public ObjectModelClassifier getClassifier(); /** * Returns the attribute used to reference this class at the other end of the association or null if this is not an association, or if it is not bi-directionnal. @@ -97,60 +97,65 @@ * * @return the ObjectModelAttribute used to reference this class at the other end of the association or null if this is not an association, or if it is not bi-directionnal. */ - public abstract ObjectModelAttribute getReverseAttribute(); + public ObjectModelAttribute getReverseAttribute(); + /** + * Return attribute reserver attribute name. + * + * @return reverse attribute name or null + */ public String getReverseAttributeName(); /** * max multiplicity of the reverse attribute * @return max multiplicity of the reverse attribute */ - public abstract int getReverseMaxMultiplicity(); + public int getReverseMaxMultiplicity(); /** * Returns the association class associated with this association, or null if there is none. * * @return a ObjectModelClass corresponding to the association class associated with this association, or null if there is none. */ - public abstract ObjectModelClass getAssociationClass(); + public ObjectModelClass getAssociationClass(); /** * Returns whether this association has an associated association class, ot not. * * @return a boolean indicating whether this association has an associated association class, ot not. */ - public abstract boolean hasAssociationClass(); + public boolean hasAssociationClass(); /** * Returns whether this attribute is static or not. * * @return a boolean indicating whether this attribute is static or not. */ - public abstract boolean isStatic(); + public boolean isStatic(); /** * Returns whether this attribute is final or not. * * @return a boolean indicating whether this attribute is final or not. */ - public abstract boolean isFinal(); + public boolean isFinal(); /** * true if this attribute is navigable * @return true if this attribute is navigable */ - public abstract boolean isNavigable(); + public boolean isNavigable(); /** * true if this attribute is isOrdered * @return true if this attribute is isOrdered */ - public abstract boolean isOrdered(); + public boolean isOrdered(); /** * true if this attribute is isIndexed * @return true if this attribute is isIndexed */ - public abstract boolean isIndexed(); + public boolean isIndexed(); } //ObjectModelAttribute Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java 2009-04-26 20:40:15 UTC (rev 483) @@ -40,14 +40,15 @@ * * @return a Collection containing all parent ObjectModelClass for this class. */ - public abstract Collection<ObjectModelClass> getSuperclasses(); + public Collection<ObjectModelClass> getSuperclasses(); /** * Returns the discriminator for the given superclass. * + * @param superclass super class to get discriminator * @return the discriminator for the given superclass as a String if it exists, null otherwise. */ - public abstract String getDiscriminator(ObjectModelClass superclass); + public String getDiscriminator(ObjectModelClass superclass); /** * Returns all known direct specialized classes for this class. @@ -55,15 +56,16 @@ * * @return a Collection containing all known direct specialized ObjectModelClass for this class. */ - public abstract Collection<ObjectModelClass> getSpecialisations(); + public Collection<ObjectModelClass> getSpecialisations(); /** * Returns all known direct specialized classes for this class for the specified discriminator. * @see ObjectModelClass * + * @param discriminator discriminator to get specialisations * @return a Collection containing all known direct specialized ObjectModelClass for this class for the specified discriminator. */ - public abstract Collection<ObjectModelClass> getSpecialisations( + public Collection<ObjectModelClass> getSpecialisations( String discriminator); /** @@ -72,21 +74,22 @@ * * @return a Collection containing all ObjectModelAttribute for this class. */ - public abstract Collection<ObjectModelAttribute> getAttributes(); + public Collection<ObjectModelAttribute> getAttributes(); /** * Returns the attribute corresponding to the given name, or null if the class contains no attribute for this name. * + * @param attributeName attribute name * @return the ObjectModelAttribute of the found attribute, or null if the class contains no attribute for this name. */ - public abstract ObjectModelAttribute getAttribute(String attributeName); + public ObjectModelAttribute getAttribute(String attributeName); /** * Returns whether this class is abstract or not. * * @return a boolean indicating whether this class is abstract or not. */ - public abstract boolean isAbstract(); + public boolean isAbstract(); /** * Returns all operations defined on all Super class extended by this @@ -96,7 +99,7 @@ * are add to list. * @return a Collection of ObjectModelOperation */ - public abstract Collection<ObjectModelOperation> getAllSuperclassOperations( + public Collection<ObjectModelOperation> getAllSuperclassOperations( boolean distinct); /** @@ -104,6 +107,6 @@ * classifier, directly or indirectly. * @return a Collection of ObjectModelAttribute */ - public abstract Collection<ObjectModelAttribute> getAllOtherAttributes(); + public Collection<ObjectModelAttribute> getAllOtherAttributes(); } //ObjectModelClass Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java 2009-04-26 20:40:15 UTC (rev 483) @@ -36,7 +36,7 @@ * * @return the package name of this classifier. */ - public abstract String getPackageName(); + public String getPackageName(); /** * Returns the qualified name of this classifier. @@ -48,7 +48,8 @@ /** * Returns all parent interfaces for this classifier. - * @see ObjectModelclassifier + * + * @see ObjectModelClassifier * * @return a Collection containing all parent ObjectModelInterface for this classifier. */ Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelDependency.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelDependency.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelDependency.java 2009-04-26 20:40:15 UTC (rev 483) @@ -26,8 +26,10 @@ * * @author Florian Desbois <desbois@codelutin.com> * Copyright Code Lutin - * @version $Revision: 478 $ - * + * @version $Revision$ + * + * Last update : $Date$ + * by : $Author$ */ public interface ObjectModelDependency { /** Property changes on: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelDependency.java ___________________________________________________________________ Name: svn:keywords + Date Author Revision Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java 2009-04-26 20:40:15 UTC (rev 483) @@ -38,49 +38,50 @@ * * @return the name of this element. */ - public abstract String getName(); + public String getName(); /** * Returns the element in which this element is defined, or null if there's none. * * @return the ObjectModelElement in which this element is defined, or null if there's none. */ - public abstract ObjectModelElement getDeclaringElement(); + public ObjectModelElement getDeclaringElement(); /** * Returns the whole documentation associated with this element (description + source documentation). * * @return the whole documentation associated with this element. */ - public abstract String getDocumentation(); + public String getDocumentation(); /** * Returns the description associated with this element. * * @return the description associated with this element. */ - public abstract String getDescription(); + public String getDescription(); /** * Returns the source documentation part associated with this element. * * @return the source documentation part associated with this element. */ - public abstract String getSourceDocumentation(); + public String getSourceDocumentation(); /** * Returns the stereotypes names associated with this element. * * @return a Collection containing all stereotypes names associated with this element as String. */ - public abstract Collection<String> getStereotypes(); + public Collection<String> getStereotypes(); /** * Returns whether this element has a stereotype corresponding to the given name, or not. * + * @param stereotypeName stereotype name * @return a boolean indicating whether this element has a stereotype corresponding to the given name, or not. */ - public abstract boolean hasStereotype(String stereotypeName); + public boolean hasStereotype(String stereotypeName); /** * Returns the tagValues associated with this element. @@ -88,27 +89,29 @@ * * @return a Map containing all tagValues associated with this element */ - public abstract Map<String, String> getTagValues(); + public Map<String, String> getTagValues(); /** * Returns the tagValue corresponding to the given name, or null if the element has no associated tagValue for this name. * + * @param tagValue tag value name * @return the value of the found tagValue, or null if the element has no associated tagValue for this name. */ - public abstract String getTagValue(String tagValue); + public String getTagValue(String tagValue); /** * Returns whether this element has a tagValue corresponding to the given name, or not. * + * @param tagValue tag value name * @return a boolean indicating whether this element has a tagValue corresponding to the given name, or not. */ - public abstract boolean hasTagValue(String tagValue); + public boolean hasTagValue(String tagValue); /** * Returns all comments lied to this particular model element * * @return a List containing all comments for this element as Strings. */ - public abstract List<String> getComments(); + public List<String> getComments(); } //ObjectModelElement Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelOperation.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelOperation.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelOperation.java 2009-04-26 20:40:15 UTC (rev 483) @@ -40,7 +40,7 @@ * * @return the return type of this operation. */ - public abstract String getReturnType(); + public String getReturnType(); /** * Returns the visibility of this operation. @@ -48,22 +48,22 @@ * * @return the visibility of this operation. */ - public abstract String getVisibility(); + public String getVisibility(); /** * Returns whether this operation is abstract or not. * * @return a boolean indicating whether this operation is abstract or not. */ - public abstract boolean isAbstract(); + public boolean isAbstract(); /** - * Returns all parameters defined on this opeation. + * Returns all parameters defined on this operation. * @see ObjectModelParameter * - * @return a Collection containing all parameters defined on this opeation. + * @return a Collection containing all parameters defined on this operation. */ - public abstract Collection<ObjectModelParameter> getParameters(); + public Collection<ObjectModelParameter> getParameters(); /** * In implementation you must write a good equals method @@ -76,6 +76,6 @@ * * @return a Set containing the exceptions strings */ - public abstract Set<String> getExceptions(); + public Set<String> getExceptions(); } //ObjectModelOperation Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelParameter.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelParameter.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/ObjectModelParameter.java 2009-04-26 20:40:15 UTC (rev 483) @@ -37,6 +37,6 @@ * * @return the type of this parameter. */ - public abstract String getType(); + public String getType(); } //ObjectModelParameter Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/AttributeNamesValidator.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/AttributeNamesValidator.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/AttributeNamesValidator.java 2009-04-26 20:40:15 UTC (rev 483) @@ -15,8 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - package org.nuiton.eugene.models.object.validator; import org.nuiton.eugene.models.object.ObjectModel; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/NameBasedValidator.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/NameBasedValidator.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/validator/NameBasedValidator.java 2009-04-26 20:40:15 UTC (rev 483) @@ -15,8 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - package org.nuiton.eugene.models.object.validator; import java.util.HashMap; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -61,14 +61,14 @@ public void addSuperclass(ObjectModelImplRef ref) { //if (ref == null) - // return new ObjectModelImplSuperClassRef(); + //return new ObjectModelImplSuperClassRef(); superclassesRefs.add(ref); //return ref; } public void addAttribute(ObjectModelAttributeImpl attribute) { //if (attribute == null) - // return new ObjectModelAttributeImpl(objectModelImpl, this); + //return new ObjectModelAttributeImpl(objectModelImpl, this); attribute.postInit(); attribute.setDeclaringElement(this); attributes.put(attribute.getName(), attribute); Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -19,13 +19,11 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Map; import org.nuiton.eugene.models.object.ObjectModelClassifier; import org.nuiton.eugene.models.object.ObjectModelDependency; import org.nuiton.eugene.models.object.ObjectModelInterface; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -61,7 +61,7 @@ public void addClass(ObjectModelClassImpl clazz) { //if (clazz == null) - // return new ObjectModelClassImpl(this, null); + // return new ObjectModelClassImpl(this, null); clazz.postInit(); clazz.setObjectModelImpl(this); @@ -72,12 +72,13 @@ classes.put(clazz.getQualifiedName(), clazz); classifiers.put(clazz.getQualifiedName(), clazz); } else { - if (!(initialElement instanceof ObjectModelClassImpl)) + if (!(initialElement instanceof ObjectModelClassImpl)) { throw new IllegalArgumentException( "\"" + clazz + "\" is incompatible with already defined element \"" + initialElement + "\""); + } ObjectModelClassImpl initialClazz = (ObjectModelClassImpl) initialElement; // La classe existe déjà. On va prendre tout ce que contient la @@ -92,7 +93,7 @@ public void addAssociationClass(ObjectModelAssociationClassImpl clazz) { //if (clazz == null) - // return new ObjectModelAssociationClassImpl(this, null); + // return new ObjectModelAssociationClassImpl(this, null); clazz.postInit(); clazz.setObjectModelImpl(this); @@ -103,12 +104,13 @@ classes.put(clazz.getQualifiedName(), clazz); classifiers.put(clazz.getQualifiedName(), clazz); } else { - if (!(initialElement instanceof ObjectModelAssociationClassImpl)) + if (!(initialElement instanceof ObjectModelAssociationClassImpl)) { throw new IllegalArgumentException( "\"" + clazz + "\" is incompatible with already defined element \"" + initialElement + "\""); + } ObjectModelAssociationClassImpl initialClazz = (ObjectModelAssociationClassImpl) initialElement; mergeAssociationClasses(initialClazz, clazz); @@ -161,7 +163,7 @@ /** * Returns all classes defined in this model. * - * @see ObjectModelClass. + * @see ObjectModelClass * * @return a Collection containing all ObjectModelClass for this model. */ @@ -204,7 +206,7 @@ public void addInterface(ObjectModelInterfaceImpl interfacez) { //if (interfacez == null) - // return new ObjectModelInterfaceImpl(this, null); + // return new ObjectModelInterfaceImpl(this, null); interfacez.postInit(); interfacez.setObjectModelImpl(this); @@ -254,7 +256,7 @@ /** * Returns all interfaces defined in this model. * - * @see ObjectModelInterface. + * @see ObjectModelInterface * * @return a Collection containing all ObjectModelInterface for this model. */ @@ -371,8 +373,9 @@ } for (it = additionalClazz.superclassesRefs.iterator(); it.hasNext();) { ObjectModelImplRef superclassRef = (ObjectModelImplRef) it.next(); - if (!contains(initialClazz.superclassesRefs, superclassRef)) + if (!contains(initialClazz.superclassesRefs, superclassRef)) { initialClazz.superclassesRefs.add(superclassRef); + } initialClazz.superclasses = null; // On force ainsi à regénérer // l'objet } @@ -387,8 +390,9 @@ .hasNext();) { ObjectModeImplAssociationClassParticipant participant = (ObjectModeImplAssociationClassParticipant) it .next(); - if (!contains(initialAssocClazz.participantsRefs, participant)) + if (!contains(initialAssocClazz.participantsRefs, participant)) { initialAssocClazz.participantsRefs.add(participant); + } initialAssocClazz.participantsAttributes = null; // On force // ainsi à // regénérer @@ -404,10 +408,11 @@ ObjectModelAttributeImpl toFind) { for (Iterator<ObjectModelAttribute> it = coll.iterator(); it.hasNext();) { ObjectModelAttribute attribute = it.next(); - if (attribute.getName().equals(toFind.getName())) // Seul le nom + if (attribute.getName().equals(toFind.getName())) { // Seul le nom // de l'attribut // compte return true; + } } return false; } @@ -423,8 +428,9 @@ } public ObjectModelImplTagValue addTagValue(ObjectModelImplTagValue tagValue) { - if (tagValue == null) + if (tagValue == null) { return new ObjectModelImplTagValue(); + } tagValues.put(tagValue.getName(), tagValue.getValue()); return tagValue; } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -61,7 +61,7 @@ modelTagValues = new HashMap<String, String>(); } - /* (non-Javadoc) + /* * @see org.nuiton.eugene.models.state.StateModel#getName() */ public String getName() { @@ -69,16 +69,18 @@ } /** - * Set model name - * @param name + * Set model name. + * + * @param name model name */ public void setName(String name) { this.name = name; } /** - * Add chart - * @param chart + * Add chart. + * + * @param chart chart */ public void addStateChart(StateModelStateChart chart) { @@ -90,7 +92,7 @@ listStateCharts.add(chart); } - /* (non-Javadoc) + /* * @see org.nuiton.eugene.models.state.StateModel#getStateCharts() */ public List<StateModelStateChart> getStateCharts() { @@ -105,7 +107,7 @@ listStateCharts.addAll(charts); } - /* (non-Javadoc) + /* * @see org.nuiton.eugene.models.state.StateModel#getTagValues() */ public Map<String, String> getTagValues() { Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelStateChartImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelStateChartImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelStateChartImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -31,12 +31,10 @@ public class StateModelStateChartImpl extends StateModelComplexeStateImpl implements StateModelStateChart { - /** - * Package name - */ + /** Package name. */ protected String packageName; - /* (non-Javadoc) + /* * @see org.nuiton.eugene.models.state.StateModelStateChart#getPackageName() */ public String getPackageName() { @@ -44,8 +42,9 @@ } /** - * Set package name - * @param packageName + * Set package name. + * + * @param packageName package name */ public void setPackage(String packageName) { this.packageName = packageName; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelTransitionImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelTransitionImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/state/xml/StateModelTransitionImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -75,6 +75,8 @@ * On ne peut pas le faire directement car le fichier xml n'est * potentielement par ordonne, et par concequent, les etat n'ont pas encore * ete traite. + * + * @param state state to set */ public void setState(StateModelState state) { this.state = state; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModel.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModel.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModel.java 2009-04-26 20:40:15 UTC (rev 483) @@ -42,14 +42,14 @@ * * @return the version of this model. */ - public abstract String getVersion(); + public String getVersion(); /** * Returns the package of this model. * * @return the package of this model. */ - public abstract String getPackage(); + public String getPackage(); /** * Returns the object root defined in this ui model. @@ -57,7 +57,7 @@ * * @return the object root defined in this ui model. */ - public abstract UIModelObject getRoot(); + public UIModelObject getRoot(); /** * Returns all objects defined in this ui model. @@ -65,12 +65,12 @@ * * @return a Collection containing all UIModelObjects for this ui model. */ - public abstract Collection<UIModelObject> getObjects(); + public Collection<UIModelObject> getObjects(); /** * Method used to add objects in this model * @see UIModelObject * */ - public abstract void addObject(UIModelObject object); + public void addObject(UIModelObject object); } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java 2009-04-26 20:40:15 UTC (rev 483) @@ -37,7 +37,7 @@ * Returns a arguments list. * @return a arguments list. */ - public abstract List<Object> getArguments(); + public List<Object> getArguments(); } // UIModelArguments Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java 2009-04-26 20:40:15 UTC (rev 483) @@ -15,8 +15,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - package org.nuiton.eugene.models.ui; /** @@ -39,7 +37,7 @@ * * @return a UIModelObject for this child. */ - public abstract UIModelObject getObject(); + public UIModelObject getObject(); /** * Returns a UIModelConstraint for this child. @@ -47,7 +45,7 @@ * * @return a UIModelConstraint for this child. */ - public abstract UIModelConstraint getConstraint(); + public UIModelConstraint getConstraint(); } // UIModelChild Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java 2009-04-26 20:40:15 UTC (rev 483) @@ -37,14 +37,14 @@ * or String or null * @return the value of this constraint. */ - public abstract Object getValue(); + public Object getValue(); /** * Returns the value of this constraint if the type is String * else return null * @return the value of this constraint. */ - public abstract String getStringValue(); + public String getStringValue(); } // UIModelConstraint Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java 2009-04-26 20:40:15 UTC (rev 483) @@ -35,31 +35,31 @@ * Returns the addListenerMethod of this event * @return addListenerMethod */ - public abstract String getAddMethod(); + public String getAddMethod(); /** * Returns the listenerInterface of this event * @return listenerInterface */ - public abstract String getSource(); + public String getSource(); /** * Returns the listenerMethodName of this event * @return listenerMethodName */ - public abstract String getAction(); + public String getAction(); /** * Returns the handler of this event * @return handler */ - public abstract String getHandler(); + public String getHandler(); /** * Returns the eventPropertyName of this event * @return eventPropertyName */ - public abstract String getArgument(); + public String getArgument(); } // UIModelEvent Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java 2009-04-26 20:40:15 UTC (rev 483) @@ -36,21 +36,21 @@ * Returns null if this object is root * @return the parent of this object. */ - public abstract UIModelObject getParent(); + public UIModelObject getParent(); /** * Returns the type of this object. * * @return the type of this object. */ - public abstract String getType(); + public String getType(); /** * Returns the value of the property "name" of this object * * @return the name of this object. */ - public abstract String getName(); + public String getName(); /** * Returns the constraint of this object @@ -58,7 +58,7 @@ * * @return the constraint of this object. */ - public abstract UIModelConstraint getConstraint(); + public UIModelConstraint getConstraint(); /** * Returns all arguments defined on this object. @@ -66,7 +66,7 @@ * * @return a Collection containing all arguments for this object. */ - public abstract Collection<Object> getArguments(); + public Collection<Object> getArguments(); /** * Returns all properties defined on this object. @@ -74,15 +74,15 @@ * * @return a Collection containing all UIModelProperty for this object. */ - public abstract Collection<UIModelProperty> getProperties(); + public Collection<UIModelProperty> getProperties(); /** * Returns the property defined on this object. * @see UIModelProperty - * @param String the name of the property which must be returned + * @param name the name of the property which must be returned * @return a UIModelProperty for this object with the . */ - public abstract UIModelProperty getProperty(String name); + public UIModelProperty getProperty(String name); /** * Returns all events defined on this object. @@ -90,7 +90,7 @@ * * @return a Collection containing all UIModelEvents for this object. */ - public abstract Collection<UIModelEvent> getEvents(); + public Collection<UIModelEvent> getEvents(); /** * Returns all children defined on this object. @@ -98,7 +98,7 @@ * * @return a Collection containing all UIModelChildren for this object. */ - public abstract Collection<UIModelChild> getChildren(); + public Collection<UIModelChild> getChildren(); /** * Returns the uimodel of this object. @@ -106,6 +106,6 @@ * * @return the uimodel of this object. */ - public abstract UIModel getModel(); + public UIModel getModel(); } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java 2009-04-26 20:40:15 UTC (rev 483) @@ -35,7 +35,7 @@ * * @return the name of this property. */ - public abstract String getName(); + public String getName(); /** * Returns the value of this property. @@ -43,68 +43,68 @@ * or String or Integer or Boolean or Character * @return the value of this property. */ - public abstract Object getValue(); + public Object getValue(); /** * Returns the index of this property if it's indexed property * * @return the index of this property. */ - public abstract int getIndex() throws Exception; + public int getIndex() throws Exception; - public abstract boolean isIndexed(); + public boolean isIndexed(); /** * Returns the value of this property if the type is int * @return the value of this property. */ - public abstract int getIntValue(); + public int getIntValue(); /** * Returns the value of this property if the type is boolean * @return the value of this property. */ - public abstract boolean getBooleanValue(); + public boolean getBooleanValue(); /** * Returns the value of this property if the type is char * @return the value of this property. */ - public abstract char getCharValue(); + public char getCharValue(); /** * Returns the value of this property if the type is String * @return the value of this property. */ - public abstract String getStringValue(); + public String getStringValue(); /** * Returns the value of this property if the type is byte * @return the value of this property. */ - public abstract byte getByteValue(); + public byte getByteValue(); /** * Returns the value of this property if the type is Short * @return the value of this property. */ - public abstract short getShortValue(); + public short getShortValue(); /** * Returns the value of this property if the type is long * @return the value of this property. */ - public abstract long getLongValue(); + public long getLongValue(); /** * Returns the value of this property if the type is float * @return the value of this property. */ - public abstract float getFloatValue(); + public float getFloatValue(); /** * Returns the value of this property if the type is double * @return the value of this property. */ - public abstract double getDoubleValue(); + public double getDoubleValue(); } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -58,8 +58,9 @@ } public void setLayout(UIModelConstraintImpl constraint) { - // if (constraint == null) + // if (constraint == null) { // return new UIModelConstraintImpl(model, parent); + // } this.constraint = constraint; // return constraint; Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -74,8 +74,9 @@ * @return the value of this constraint. */ public String getStringValue() { - if (value instanceof String) + if (value instanceof String) { return (String) value; + } return null; } Modified: eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java 2009-04-26 20:40:15 UTC (rev 483) @@ -175,8 +175,9 @@ * @return a Collection containing all arguments for this object. */ public Collection<Object> getArguments() { - if (arguments != null) + if (arguments != null) { return arguments.getArguments(); + } return new ArrayList<Object>(); } @@ -195,8 +196,7 @@ * Returns the property defined on this object. * * @see UIModelProperty - * @param String - * the name of the property which must be returned + * @param name the name of the property which must be returned * @return a UIModelProperty for this object with the . */ public UIModelProperty getProperty(String name) { Modified: eugene/trunk/src/main/java/org/nuiton/eugene/package-info.java =================================================================== --- eugene/trunk/src/main/java/org/nuiton/eugene/package-info.java 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/main/java/org/nuiton/eugene/package-info.java 2009-04-26 20:40:15 UTC (rev 483) @@ -1,5 +1,5 @@ /** - * Lutin Generator. + * Eugene. */ package org.nuiton.eugene; Copied: eugene/trunk/src/site/en (from rev 481, eugene/trunk/src/site/rst/en) Deleted: eugene/trunk/src/site/en/LutinGenerator.rst =================================================================== --- eugene/trunk/src/site/rst/en/LutinGenerator.rst 2009-04-23 13:59:47 UTC (rev 481) +++ eugene/trunk/src/site/en/LutinGenerator.rst 2009-04-26 20:40:15 UTC (rev 483) @@ -1,57 +0,0 @@ -============== -Eugene -============== - -:Authors: Arnaud THIMEL -:Contact: thimel@codelutin.com -:Revision: $Revision$ -:Date: $Date$ - - -.. contents:: - - -Project origin -============== - -Eugene was born after a research of an easy-to-use code generator -oriented on "in memory" models. But the research ended by a failure. - -Analysed projects were : - -- Jostraca ; -- EMF ; -- ... - -Code Generation were chosen instead of Introspection because it allows to use -the compilation processes and therefore to validate the generated code. Even if -the initial need was to generate Java source code, Eugene is able to -generate any type of code. - - - -Technical part -============== - -Eugene allows using a set of generators. These generators are abstract -of any specificity enabling to adapt them to indicidual needs. - - -By default, Eugene has two implementations of these generators : - -- ObjectModelGenerator (generation from an object model) ; -- UIModelGenerator (generation from a graphic model). - -Each of these models has its own specificities due to its strucure and working -mode... - -Anyway, these generators are unuseful without generation templates. Templates -are files allowing to determinate what will be the generated content according -to the initial model. Thanks to LutinProcessor_, these templates are written -with a syntax close to the JSP syntax mixing Java and generated code. The goal -of LutinProcessor is to tranform the templates by replacing JSP code by the -matching Java code. Obtained Java classes can be compiled and so become -independants. - - -.. _LutinProcessor: http://lutinprocessor.labs.libre-entreprise.org/ Copied: eugene/trunk/src/site/en/rst/LutinGenerator.rst (from rev 481, eugene/trunk/src/site/rst/en/LutinGenerator.rst) =================================================================== --- eugene/trunk/src/site/en/rst/LutinGenerator.rst (rev 0) +++ eugene/trunk/src/site/en/rst/LutinGenerator.rst 2009-04-26 20:40:15 UTC (rev 483) @@ -0,0 +1,57 @@ +====== +Eugene +====== + +:Authors: Arnaud THIMEL +:Contact: thimel@codelutin.com +:Revision: $Revision$ +:Date: $Date$ + + +.. contents:: + + +Project origin +============== + +Eugene was born after a research of an easy-to-use code generator +oriented on "in memory" models. But the research ended by a failure. + +Analysed projects were : + +- Jostraca ; +- EMF ; +- ... + +Code Generation were chosen instead of Introspection because it allows to use +the compilation processes and therefore to validate the generated code. Even if +the initial need was to generate Java source code, Eugene is able to +generate any type of code. + + + +Technical part +============== + +Eugene allows using a set of generators. These generators are abstract +of any specificity enabling to adapt them to indicidual needs. + + +By default, Eugene has two implementations of these generators : + +- ObjectModelGenerator (generation from an object model) ; +- UIModelGenerator (generation from a graphic model). + +Each of these models has its own specificities due to its strucure and working +mode... + +Anyway, these generators are unuseful without generation templates. Templates +are files allowing to determinate what will be the generated content according +to the initial model. Thanks to LutinProcessor_, these templates are written +with a syntax close to the JSP syntax mixing Java and generated code. The goal +of LutinProcessor is to tranform the templates by replacing JSP code by the +matching Java code. Obtained Java classes can be compiled and so become +independants. + + +.. _LutinProcessor: http://lutinprocessor.labs.libre-entreprise.org/ Copied: eugene/trunk/src/site/resources/images (from rev 481, eugene/trunk/src/site/rst/images) Modified: eugene/trunk/src/site/rst/generatorHelp.txt =================================================================== --- eugene/trunk/src/site/rst/generatorHelp.txt 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/site/rst/generatorHelp.txt 2009-04-26 20:40:15 UTC (rev 483) @@ -1,6 +1,6 @@ How to create a UML model for use with Eugene ------------------------------------------------------ +--------------------------------------------- In Poseidon, - Create an empty project Modified: eugene/trunk/src/site/rst/index.rst =================================================================== (Binary files differ) Modified: eugene/trunk/src/site/site.xml =================================================================== --- eugene/trunk/src/site/site.xml 2009-04-24 11:57:27 UTC (rev 482) +++ eugene/trunk/src/site/site.xml 2009-04-26 20:40:15 UTC (rev 483) @@ -10,18 +10,18 @@ </skin> <bannerLeft> - <name>${project.name}</name> - </bannerLeft> + <name>${project.name}</name> + </bannerLeft> - <bannerRight> - <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> - <href>${project.organization.url}</href> - </bannerRight> + <bannerRight> + <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> + <href>${project.organization.url}</href> + </bannerRight> <poweredBy> <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/> - <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/> - <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/> + <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/> + <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/> </poweredBy> <body> @@ -33,18 +33,18 @@ <menu name="Utilisateur"> <item href="index.html" name="Accueil"/> - <!--item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutingenerator..." name="Téléchargement"/--> </menu> <menu name="Téléchargement"> - <item href="${labs.builder.url}/org/codelutin/${project.artifactId}/${project.version}" + <item href="${labs.builder.url}/org/nuiton/${project.artifactId}/${project.version}" name="Télécharger la dernière version"/> - <item href="${labs.builder.url}/org/codelutin/${project.artifactId}" + <item href="${labs.builder.url}/org/nuiton/${project.artifactId}" name="Voir toutes les versions"/> </menu> <menu name="Developpeur"> <item name="ObjectModel" href="ObjectModel.html"/> + <item name="StateModel" href="StateModel.html"/> <item name="UIModel" href="DevUIDoc.html"/> <item name="Todo" href="Todo.html"/> </menu> Added: eugene/trunk/src/test/java/org/nuiton/eugene/GeneratorTaskTest.java =================================================================== --- eugene/trunk/src/test/java/org/nuiton/eugene/GeneratorTaskTest.java (rev 0) +++ eugene/trunk/src/test/java/org/nuiton/eugene/GeneratorTaskTest.java 2009-04-26 20:40:15 UTC (rev 483) @@ -0,0 +1,163 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.nuiton.eugene; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tools.ant.BuildLogger; +import org.apache.tools.ant.NoBannerLogger; +import org.apache.tools.ant.Project; +import org.codelutin.util.FileUtil; +import org.junit.Test; + +/** + * Test class for Generator Ant task. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 18 févr. 2009 $ + * By : $Author: chatellier $ + */ +public class GeneratorTaskTest { + + /** Logger */ + private static Log log = LogFactory.getLog(GeneratorTaskTest.class); + + /** + * All test common task instanciation. + * + * @return task + */ + protected GeneratorTask getGeneratorTask() { + Project antProject = new Project(); + + BuildLogger logger = new NoBannerLogger(); + logger.setMessageOutputLevel(Project.MSG_DEBUG); + logger.setOutputPrintStream(System.out); + logger.setErrorPrintStream(System.err); + antProject.addBuildListener(logger); + + GeneratorTask generatorTask = new GeneratorTask(); + generatorTask.setProject(antProject); + generatorTask.setTaskName("Eugene"); + + return generatorTask; + } + + /** + * Test generation with ant task. + * @throws IOException + */ + @Test + public void testGenerateXMI12() throws IOException { + + GeneratorTask generatorTask = getGeneratorTask(); + + /* Configuration */ + generatorTask.setOverwrite(true); + generatorTask.setBuilddirectory("target/anttest"); + generatorTask.setTemplates(ObjectModelGenerator.class.getName()); + generatorTask.setSrcdir(new File("src/test/resources/xmi/1.2")); + generatorTask.setEncoding("UTF-8"); + + File destDirGen = FileUtil.createTempDirectory("1.2-", "", new File("target", "ant")); + destDirGen.mkdirs(); + generatorTask.setDestdir(destDirGen); + generatorTask.setBuilddirectory(destDirGen.getAbsolutePath()); + + generatorTask.setProperties("defaultPackage=org.nuiton"); + + generatorTask.setIncludes("**/*.xmi"); + + generatorTask.execute(); + + //Assert.assertTrue(condition); + + // remove created temp dir + //FileUtil.deleteRecursively(destDirGen); + } + + /** + * Test generation with ant task. + * @throws IOException + */ + @Test + public void testGenerateXMI21() throws IOException { + + GeneratorTask generatorTask = getGeneratorTask(); + + /* Configuration */ + generatorTask.setOverwrite(true); + generatorTask.setTemplates(ObjectModelGenerator.class.getName()); + generatorTask.setSrcdir(new File("src/test/resources/xmi/2.1")); + generatorTask.setEncoding("UTF-8"); + + File destDirGen = FileUtil.createTempDirectory("2.1-", "", new File("target", "ant")); + destDirGen.mkdirs(); + generatorTask.setDestdir(destDirGen); + generatorTask.setBuilddirectory(destDirGen.getAbsolutePath()); + + generatorTask.setProperties("defaultPackage=org.nuiton"); + + generatorTask.setIncludes("**/*.uml"); + + generatorTask.execute(); + + //Assert.assertTrue(condition); + + // remove created temp dir + //FileUtil.deleteRecursively(destDirGen); + } + + /** + * Test generation with ant task. + * @throws IOException + */ + @Test + public void testGenerateXMIObjectModel() throws IOException { + + GeneratorTask generatorTask = getGeneratorTask(); + + /* Configuration */ + generatorTask.setOverwrite(true); + generatorTask.setTemplates(ObjectModelGenerator.class.getName()); + generatorTask.setSrcdir(new File("src/test/resources/models/")); + generatorTask.setEncoding("UTF-8"); + + File destDirGen = FileUtil.createTempDirectory("objectmodel-", "", new File("target", "ant")); + destDirGen.mkdirs(); + generatorTask.setDestdir(destDirGen); + generatorTask.setBuilddirectory(destDirGen.getAbsolutePath()); + + generatorTask.setProperties("defaultPackage=org.nuiton"); + + generatorTask.setIncludes("**/*.objectmodel"); + + generatorTask.execute(); + + //Assert.assertTrue(condition); + + // remove created temp dir + //FileUtil.deleteRecursively(destDirGen); + } +} Modified: maven-eugene-plugin/trunk/changelog.txt =================================================================== --- maven-eugene-plugin/trunk/changelog.txt 2009-04-24 11:57:27 UTC (rev 482) +++ maven-eugene-plugin/trunk/changelog.txt 2009-04-26 20:40:15 UTC (rev 483) @@ -1,3 +1,8 @@ +1.0.0 xxx xxx + * Recode EugenePlugin without ant + * Move to org.nuiton groupid + * Rename project to Eugene + 0.64 chemit 20090218 * 20090211 [chatellier] add testPhase property in mojo to specify when using it in test phase * 20090210 [chatellier] add info and debug maven log messages Modified: maven-eugene-plugin/trunk/pom.xml =================================================================== --- maven-eugene-plugin/trunk/pom.xml 2009-04-24 11:57:27 UTC (rev 482) +++ maven-eugene-plugin/trunk/pom.xml 2009-04-26 20:40:15 UTC (rev 483) @@ -9,7 +9,7 @@ <parent> <groupId>org.codelutin</groupId> <artifactId>lutinproject</artifactId> - <version>3.4</version> + <version>3.5</version> </parent> <groupId>org.nuiton</groupId> Copied: maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java (from rev 481, maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/GeneratorPlugin.java) =================================================================== --- maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java (rev 0) +++ maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2009-04-26 20:40:15 UTC (rev 483) @@ -0,0 +1,349 @@ +/* *##% Plugin maven Generator + * Copyright (C) 2006 - 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ + +package org.nuiton.eugene.plugin; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.Map.Entry; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.model.Resource; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.codelutin.util.FileUtil; +import org.nuiton.eugene.Generator; + +/** + * Effectue toutes les générations et copie les fichiers générés + * dans le répertoire de compilation + * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + * + * @goal generate + * @projectRequired true + */ +public class EugenePlugin extends AbstractMojo { + + /** + * Maven project. + * + * @description Dépendance du projet. + * @parameter default-value="${project}" + * @readonly + * @since 0.50 + */ + protected MavenProject project; + + /** + * Répertoire source. + * + * @parameter expression="${eugene.srcGenDest}" alias="srcGenDest" default-value="target/generated-sources/models" + * @since 0.50 + */ + protected File srcDirGen; + + /** + * Répertoire cible + * + * @parameter expression="${eugene.destDirGen}" default-value="target/generated-sources/java" + * @since 0.50 + */ + protected File destDirGen; + + /** + * Templates à utiliser, séparés par des virgules. + * + * @parameter expression="${eugene.templates}" + * @required + * @since 0.50 + */ + protected String templates; + + /** + * Templates à ne pas utiliser. + * + * @parameter expression="${eugene.excludeTemplates}" + * @since 0.63 + */ + protected String[] excludeTemplates; + + /** + * Fichier à inclure. + * + * @parameter expression="${eugene.includes}" default-value="*.*model" + * @since 0.50 + */ + protected String includes; + + /** + * Nom par défaut du paquetage généré. + * + * @parameter expression="${eugene.defaultPackage}" default-value="${project.groupId}.${project.artifactId}" + * @since 0.50 + */ + protected String defaultPackage; + + /** + * Ecrase les fichiers générés + * + * @parameter expression="${eugene.overwrite}" default-value="false" + * @since 0.50 + */ + private boolean overwrite = false; + + /** + * An extra directory to be added to the classpath. + * + * @parameter expression="${eugene.extraClassPathDirectory}" + * @since 0.63 + */ + protected File extraClassPathDirectory; + + /** + * Encoding to be used for generation of files. + * + * @parameter expression="${eugene.encoding}" default-value="${project.build.sourceEncoding}" + * @since 0.60 + */ + protected String encoding; + + /** + * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots. + * + * @parameter expression="${eugene.testPhase}" default-value="false" + * @since 0.64 + */ + protected boolean testPhase; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + + getLog().info("Generating model using : "); + getLog().info(" using template : " + templates); + getLog().info(" using defaultPackage : " + defaultPackage); + getLog().info(" generating from : " + srcDirGen + File.separator + includes); + getLog().info(" generating to : " + destDirGen); + + // init generators + Properties generatorProperties = new Properties(); + generatorProperties.setProperty("defaultPackage", defaultPackage); + + List<Generator> generators = new ArrayList<Generator>(); + String[] templatesNames = templates.split(","); + ClassLoader fixedClassLoader = fixClassLoader(); + for (String templateName : templatesNames) { + + // remove trailing spaces + templateName = templateName.trim(); + + try { + Generator generator = (Generator) Class.forName(templateName, + true, fixedClassLoader).newInstance(); + + // configuration + generator.setExcludeTemplates(Arrays.asList(excludeTemplates)); + generator.setProperties(generatorProperties); + generator.setOverwrite(overwrite); + generator.setEncoding(encoding); + + generators.add(generator); + } catch (InstantiationException e) { + throw new MojoFailureException("Can't instantiate generator : " + + templateName, e); + } catch (IllegalAccessException e) { + throw new MojoFailureException("Can't access generator : " + + templateName, e); + } catch (ClassNotFoundException e) { + throw new MojoFailureException("Can't found generator : " + + templateName, e); + } + } + + generate(generators); + + fixCompileSourceRoots(); + } + + /** + * Execute generators on source directory. + * + * @param generators generators + */ + protected void generate(List<Generator> generators) { + + // get file to generate + // TODO improve this loop + // TODO too strange code + List<File> modelFiles = new ArrayList<File>(); + String[] includePatterns = includes.split(","); + for (String includePattern : includePatterns) { + includePattern = includePattern.trim(); + boolean recursive = false; + if (includePattern.startsWith("**/")) { + recursive = true; + includePattern = includePattern.substring(3); + } + + // transform pattern in java regex + includePattern = includePattern.replaceAll("\\.", "\\\\."); + includePattern = includePattern.replaceAll("\\*", ".*"); + + // log java regex + getLog().debug("Search for " + includePattern + " in " + + srcDirGen.getAbsolutePath()); + + List<File> currentFiles = FileUtil.find(srcDirGen, includePattern, + recursive); + modelFiles.addAll(currentFiles); + } + + generateModels(generators, modelFiles); + } + + /** + * Apply generators on models files. + * + * @param generators generators + * @param modelFiles + */ + protected void generateModels(List<Generator> generators, + List<File> modelFiles) { + + for (Generator generator : generators) { + getLog().info("Apply " + generator.getClass().getSimpleName() + + " generator"); + + for (File modelFile : modelFiles) { + getLog().debug(" on " + modelFile.getAbsolutePath()); + + // generation + generator.generate(modelFile, destDirGen); + } + } + + } + + /** + * permet d'ajout le répertoire de génération des fichiers java dans les répertoires + * de compilation du projet Maven. + */ + protected void fixCompileSourceRoots() { + + if (project == null) { + // no project defined, can not fix anything + // this case could appears if we wanted to do some tests of the plugin + return; + } + + if (testPhase) { + if (!project.getTestCompileSourceRoots().contains( + destDirGen.getPath())) { + getLog().info("Add test compile source root : " + destDirGen); + project.addTestCompileSourceRoot(destDirGen.getPath()); + Resource resources = new Resource(); + resources.setDirectory(destDirGen.getAbsolutePath()); + resources.setExcludes(Arrays.asList("**/*.java")); + getLog().info("Add test resource root :" + resources); + project.addTestResource(resources); + } + } else { + if (!project.getCompileSourceRoots().contains(destDirGen.getPath())) { + getLog().info("Add compile source root : " + destDirGen); + project.addCompileSourceRoot(destDirGen.getPath()); + Resource resources = new Resource(); + resources.setDirectory(destDirGen.getAbsolutePath()); + resources.setExcludes(Arrays.asList("**/*.java")); + getLog().info("Add resource root :" + resources); + project.addResource(resources); + } + } + } + + /** + * Prepare le classLoader a utiliser dans le generateur. + * <p/> + * Si un {@link #extraClassPathDirectory} a été renseigné, il est rajouté. + * <p/> + * Si des références à des sibling modules, ils seront rajoutés aussi. + * + * @return le class loader modifie + * @throws MojoExecutionException if any pb + */ + protected ClassLoader fixClassLoader() throws MojoExecutionException { + try { + List<URL> urls = new ArrayList<URL>(); + ClassLoader loader = null; + if (extraClassPathDirectory != null) { + getLog().info( + "Add extra directory in generator's classLoader : " + + extraClassPathDirectory); + urls.add(extraClassPathDirectory.toURI().toURL()); + } + if (project.getProjectReferences() != null) { + // this case is for multi-module when calling from a parent module + for (Object o : project.getProjectReferences().entrySet()) { + Entry entry = (Entry) o; + MavenProject relatedProject = (MavenProject) entry + .getValue(); + getLog().info( + "Add project reference in generator's classLoader : '" + + relatedProject.getArtifact() + "'"); + //TODO il faudrait peut-etre aussi ajouter les dependances ? + urls.add(relatedProject.getArtifact().getFile().toURI() + .toURL()); + } + } + if (!project.getArtifacts().isEmpty()) { + // this is a special case when artifacts were resolved (for example in site phase) + getLog().info("Use resolved artifacts to build class-path"); + for (Object o : project.getArtifacts()) { + Artifact a = (Artifact) o; + if (!a.getScope().equals("provided")) { + urls.add(a.getFile().toURI().toURL()); + } + } + // using the strict class loader with only resolved artifacts + //loader = new URLClassLoader(urls.toArray(new URL[urls.size()])); + } + //if (loader == null) { + // we ask to add the directory in classloader + loader = getClass().getClassLoader(); + if (!urls.isEmpty()) { + loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), + loader); + } + //} + return loader; + } catch (MalformedURLException e) { + throw new MojoExecutionException(e.getMessage()); + } + + } +} Deleted: maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/GeneratorPlugin.java =================================================================== --- maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/GeneratorPlugin.java 2009-04-24 11:57:27 UTC (rev 482) +++ maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/GeneratorPlugin.java 2009-04-26 20:40:15 UTC (rev 483) @@ -1,286 +0,0 @@ -/* *##% Plugin maven Generator - * Copyright (C) 2006 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.plugin; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map.Entry; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.apache.tools.ant.BuildLogger; -import org.apache.tools.ant.NoBannerLogger; -import org.apache.tools.ant.Project; -import org.nuiton.eugene.GeneratorTask; - -/** - * Effectue toutes les générations et copie les fichiers générés - * dans le répertoire de compilation - * - * @author ruchaud - * @version $Revision$ - * <p/> - * Last update: $Date$ - * by : $Author$ - * @goal generate - * @projectRequired true - */ -public class GeneratorPlugin extends AbstractMojo { - - /** - * @description Dépendance du projet. - * @parameter default-value="${project}" - * @readonly - * @since 0.50 - */ - protected MavenProject project; - - /** - * Répertoire source - * - * @parameter expression="${generator.srcGenDest}" alias="srcGenDest" default-value="target/generated-sources/models" - * @since 0.50 - */ - protected File srcDirGen; - - /** - * Répertoire cible - * - * @parameter expression="${generator.destDirGen}" default-value="target/generated-sources/java" - * @since 0.50 - */ - protected File destDirGen; - - /** - * Templates à utiliser, séparés par des virgules. - * - * @parameter expression="${generator.templates}" - * @required - * @since 0.50 - */ - protected String templates; - - /** - * Templates à ne pas utiliser. - * - * @parameter expression="${generator.excludeTemplates}" - * @since 0.63 - */ - protected String[] excludeTemplates; - - /** - * Fichier à inclure. - * - * @parameter expression="${generator.includes}" default-value="*.*model" - * @since 0.50 - */ - protected String includes; - - /** - * Nom par défaut du paquetage généré. - * - * @parameter expression="${generator.defaultPackage}" default-value="${project.groupId}.${project.artifactId}" - * @since 0.50 - */ - protected String defaultPackage; - - /** - * Ecrase les fichiers générés - * - * @parameter expression="${generator.overwrite}" default-value="false" - * @since 0.50 - */ - private boolean overwrite = false; - - /** - * An extra directory to be added to the classpath. - * - * @parameter expression="${generator.extraClassPathDirectory}" - * @since 0.63 - */ - protected File extraClassPathDirectory; - - /** - * Encoding to be used for generation of files. - * - * @parameter expression="${generator.encoding}" default-value="${project.build.sourceEncoding}" - * @since 0.60 - */ - protected String encoding; - - /** - * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots. - * - * @parameter expression="${generator.testPhase}" default-value="false" - * @since 0.64 - */ - protected boolean testPhase; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - - getLog().info("Generating model using : "); - getLog().info(" using template : " + templates); - getLog().info(" using defaultPackage : " + defaultPackage); - getLog().info(" generating from : " + srcDirGen + File.separator + includes); - getLog().info(" generating to : " + destDirGen); - - /* Création d'un projet ant */ - Project project = new Project(); - - BuildLogger logger = new NoBannerLogger(); - logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO); - logger.setOutputPrintStream(System.out); - logger.setErrorPrintStream(System.err); - - project.init(); - project.getBaseDir(); - project.addBuildListener(logger); - - /* Création de la tâche ant */ - GeneratorTask generator = new GeneratorTask(); - generator.setProject(project); - generator.setTaskName("Generator"); - - /* Configuration */ - generator.setOverwrite(overwrite); - generator.setTemplates(templates); - generator.setSrcdir(srcDirGen); - generator.setEncoding(encoding); - - destDirGen.mkdirs(); - generator.setDestdir(destDirGen); - - fixCompileSourceRoots(); - - generator.setProperties("defaultPackage=" + defaultPackage); - - generator.setIncludes(includes); - generator.setExcludeTemplates(excludeTemplates == null - || excludeTemplates.length == 0 ? java.util.Collections - .<String>emptyList() : java.util.Arrays - .asList(excludeTemplates)); - - //ClassLoader loader = fixClassLoader(); - //generator.setLoader(loader); - /* Execution */ - generator.execute(); - } - - /** - * permet d'ajout le répertoire de génération des fichiers java dans les répertoires - * de compilation du projet Maven. - */ - protected void fixCompileSourceRoots() { - if (project==null) { - // no project defined, can not fix anything - // this case could appears if we wanted to do some tests of the plugin - return; - } - - if (testPhase) { - if (!project.getTestCompileSourceRoots().contains(destDirGen.getPath())) { - getLog().info("Add test compile source root : " + destDirGen); - project.addTestCompileSourceRoot(destDirGen.getPath()); - Resource resources = new Resource(); - resources.setDirectory(destDirGen.getAbsolutePath()); - resources.setExcludes(Arrays.asList("**/*.java")); - getLog().info("Add test resource root :" + resources); - project.addTestResource(resources); - } - } else { - if (!project.getCompileSourceRoots().contains(destDirGen.getPath())) { - getLog().info("Add compile source root : " + destDirGen); - project.addCompileSourceRoot(destDirGen.getPath()); - Resource resources = new Resource(); - resources.setDirectory(destDirGen.getAbsolutePath()); - resources.setExcludes(Arrays.asList("**/*.java")); - getLog().info("Add resource root :" + resources); - project.addResource(resources); - } - } - } - - /** - * Prepare le classLoader a utiliser dans le generateur. - * <p/> - * Si un {@link #extraClassPathDirectory} a été renseigné, il est rajouté. - * <p/> - * Si des références à des sibling modules, ils seront rajoutés aussi. - * - * @return le class loader modifie - * @throws MojoExecutionException if any pb - */ - protected ClassLoader fixClassLoader() throws MojoExecutionException { - try { - List<URL> urls = new ArrayList<URL>(); - ClassLoader loader = null; - if (extraClassPathDirectory != null) { - getLog().info("Add extra directory in generator's classLoader : " - + extraClassPathDirectory); - urls.add(extraClassPathDirectory.toURI().toURL()); - } - if (project.getProjectReferences() != null) { - // this case is for multi-module when calling from a parent module - for (Object o : project.getProjectReferences().entrySet()) { - Entry entry = (Entry) o; - MavenProject relatedProject = (MavenProject) entry - .getValue(); - getLog().info("Add project reference in generator's classLoader : '" - + relatedProject.getArtifact() + "'"); - //TODO il faudrait peut-etre aussi ajouter les dependances ? - urls.add(relatedProject.getArtifact().getFile().toURI() - .toURL()); - } - } - if (!project.getArtifacts().isEmpty()) { - // this is a special case when artifacts were resolved (for example in site phase) - getLog().info("Use resolved artifacts to build class-path"); - for (Object o : project.getArtifacts()) { - Artifact a = (Artifact) o; - if (!a.getScope().equals("provided")) { - urls.add(a.getFile().toURI().toURL()); - } - } - // using the strict class loader with only resolved artifacts - //loader = new URLClassLoader(urls.toArray(new URL[urls.size()])); - } - //if (loader == null) { - // we ask to add the directory in classloader - loader = getClass().getClassLoader(); - if (!urls.isEmpty()) { - loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), - loader); - } - //} - return loader; - } catch (MalformedURLException e) { - throw new MojoExecutionException(e.getMessage()); - } - - } -} Modified: maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/helper/ResourceResolver.java =================================================================== --- maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/helper/ResourceResolver.java 2009-04-24 11:57:27 UTC (rev 482) +++ maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/helper/ResourceResolver.java 2009-04-26 20:40:15 UTC (rev 483) @@ -48,10 +48,10 @@ * {@link javax.xml.transform.TransformerFactory}. <br/> * * @author chorlet - * @version $Revision: 1.0 $ + * @version $Revision$ * - * Last update : $Date: 18 févr. 2009 $ - * By : $Author: chatellier $ + * Last update : $Date$ + * By : $Author$ */ public class ResourceResolver implements URIResolver { Property changes on: maven-eugene-plugin/trunk/src/main/java/org/nuiton/eugene/plugin/helper/ResourceResolver.java ___________________________________________________________________ Name: svn:keywords + DAte Author Revision