r1262 - in trunk: eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml eugene-plantuml-templates eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml src/site/rst
Author: tchemit Date: 2013-05-29 12:06:05 +0200 (Wed, 29 May 2013) New Revision: 1262 Url: http://nuiton.org/projects/eugene/repository/revisions/1262 Log: prepare release Modified: trunk/eugene-plantuml-templates/LICENSE.txt trunk/eugene-plantuml-templates/README.txt trunk/eugene-plantuml-templates/changelog.txt trunk/eugene-plantuml-templates/pom.xml trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java trunk/src/site/rst/index.rst Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java 2013-05-28 13:49:26 UTC (rev 1261) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java 2013-05-29 10:06:05 UTC (rev 1262) @@ -1,5 +1,29 @@ package org.nuiton.eugene.models.object.reader.yaml; +/* + * #%L + * EUGene :: EUGene + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2013 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>. + * #L% + */ + import org.nuiton.eugene.models.object.*; import org.nuiton.eugene.models.object.xml.*; import org.yaml.snakeyaml.Yaml; Property changes on: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-05-28 13:49:26 UTC (rev 1261) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-05-29 10:06:05 UTC (rev 1262) @@ -1,5 +1,29 @@ package org.nuiton.eugene.models.object.reader.yaml; +/* + * #%L + * EUGene :: EUGene + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2013 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>. + * #L% + */ + import java.util.*; /** Property changes on: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/eugene-plantuml-templates/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/eugene-plantuml-templates/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/eugene-plantuml-templates/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/eugene-plantuml-templates/pom.xml =================================================================== --- trunk/eugene-plantuml-templates/pom.xml 2013-05-28 13:49:26 UTC (rev 1261) +++ trunk/eugene-plantuml-templates/pom.xml 2013-05-29 10:06:05 UTC (rev 1262) @@ -3,7 +3,7 @@ #%L EUGene :: EUGene - $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-java-templates/pom.xml $ + $HeadURL$ %% Copyright (C) 2004 - 2010 CodeLutin %% Property changes on: trunk/eugene-plantuml-templates/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java =================================================================== --- trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-05-28 13:49:26 UTC (rev 1261) +++ trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-05-29 10:06:05 UTC (rev 1262) @@ -1,19 +1,61 @@ package org.nuiton.eugene.plantuml; +/* + * #%L + * EUGene :: PlantUML templates + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2013 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>. + * #L% + */ + import net.sourceforge.plantuml.GeneratedImage; import net.sourceforge.plantuml.SourceFileReader; -import org.nuiton.eugene.models.object.*; -import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl; +import org.nuiton.eugene.models.object.ObjectModel; +import org.nuiton.eugene.models.object.ObjectModelAttribute; +import org.nuiton.eugene.models.object.ObjectModelClass; +import org.nuiton.eugene.models.object.ObjectModelClassifier; +import org.nuiton.eugene.models.object.ObjectModelEnumeration; +import org.nuiton.eugene.models.object.ObjectModelGenerator; +import org.nuiton.eugene.models.object.ObjectModelInterface; +import org.nuiton.eugene.models.object.ObjectModelOperation; +import org.nuiton.eugene.models.object.ObjectModelParameter; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; -// http://maven-site.nuiton.org/eugene/objectmodel/ObjectModel_Interfaces.png -//TODO : Plexus ? - +/** + * TODO + * + * @author agiraudet + * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.plantuml.PlantumlTemplatesGenerator" + * @since 2.6.3 + */ public class PlantumlTemplatesGenerator extends ObjectModelGenerator { private boolean _loginit = true; + private void log(String str) { try { FileWriter log; @@ -27,7 +69,9 @@ log = new FileWriter(path, true); log.write("[LOG] " + str + "\n"); log.close(); - } catch (IOException e) {;} + } catch (IOException e) { + ; + } } @Override @@ -37,32 +81,26 @@ // utiliser le systeme de templates a l'avenir - Map<ObjectModelAttribute,ObjectModelClassifier> linksOME = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>(); + Map<ObjectModelAttribute, ObjectModelClassifier> linksOME = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>(); // debut du fichier output.write("@startuml\n\n"); // parcours des classes - for(ObjectModelClass class_tmp : input.getClasses()) - { + for (ObjectModelClass class_tmp : input.getClasses()) { // sale String classStereotype = ""; - if(class_tmp.getStereotypes().size()>0) - { + if (class_tmp.getStereotypes().size() > 0) { classStereotype = "<<"; boolean first = true; - for(String str : class_tmp.getStereotypes()) - { - if(first) - { - classStereotype = classStereotype+str; + for (String str : class_tmp.getStereotypes()) { + if (first) { + classStereotype = classStereotype + str; first = false; + } else { + classStereotype = classStereotype + " ," + str; } - else - { - classStereotype = classStereotype+" ,"+str; - } } - classStereotype = classStereotype+">>"; + classStereotype = classStereotype + ">>"; } /*if(class_tmp.getStereotypes().contains("entity")) { @@ -70,154 +108,123 @@ }*/ String className = class_tmp.getName(); // ajout de la classe - output.write("class "+className+classStereotype+" {\n"); + output.write("class " + className + classStereotype + " {\n"); // parcours des attributs de la classe - for(ObjectModelAttribute attribute_tmp : class_tmp.getAttributes()) - { + for (ObjectModelAttribute attribute_tmp : class_tmp.getAttributes()) { String attributeName = attribute_tmp.getName(); //String attributeType = afterLastPoint(attribute_tmp.getType()); String attributeType = attribute_tmp.getType(); // si l'attribut n'est lie a aucune classe - if(attribute_tmp.referenceClassifier()) - { + if (attribute_tmp.referenceClassifier()) { // ajout du lien - linksOME.put(attribute_tmp,class_tmp); - } - else - { + linksOME.put(attribute_tmp, class_tmp); + } else { // ajout de l'attribut - output.write(" -"+attributeName+" : "+attributeType+"\n"); + output.write(" -" + attributeName + " : " + attributeType + "\n"); } } // parcours des operations - for(ObjectModelOperation operation_tmp : class_tmp.getOperations()) - { + for (ObjectModelOperation operation_tmp : class_tmp.getOperations()) { String operationName = operation_tmp.getName(); //String operationReturnType = afterLastPoint(operation_tmp.getReturnType()); String operationReturnType = operation_tmp.getReturnType(); // ajout de l'operation - output.write(" +"+operationName+"("); + output.write(" +" + operationName + "("); // parcours des parametres boolean first = true; - for(ObjectModelParameter param : operation_tmp.getParameters()) - { + for (ObjectModelParameter param : operation_tmp.getParameters()) { String parameterName = param.getName(); //String parameterType = afterLastPoint(param.getType()); String parameterType = param.getType(); - if(first) - { + if (first) { first = false; - } - else - { + } else { output.write(", "); } // ajout du parametre - output.write(parameterName+" : "+parameterType); + output.write(parameterName + " : " + parameterType); } // ajout du type de retour - output.write(") : "+operationReturnType+"\n");// attention aux listes ! + output.write(") : " + operationReturnType + "\n");// attention aux listes ! } output.write("}\n\n"); } // parcours des enumerations - for(ObjectModelEnumeration enumeration_tmp : input.getEnumerations()) - { + for (ObjectModelEnumeration enumeration_tmp : input.getEnumerations()) { String enumerationName = enumeration_tmp.getName(); String enumerationStereotype = ""; - if(enumeration_tmp.getStereotypes().contains("entity")) - { + if (enumeration_tmp.getStereotypes().contains("entity")) { enumerationStereotype = " <<entity>>"; } // ajout de l'enumeration - output.write("enum "+enumerationName+enumerationStereotype+" {\n"); + output.write("enum " + enumerationName + enumerationStereotype + " {\n"); output.write("}\n\n"); } // parcours des interfaces - for(ObjectModelInterface interface_tmp : input.getInterfaces()) - { + for (ObjectModelInterface interface_tmp : input.getInterfaces()) { String interfaceName = interface_tmp.getName(); String interfaceStereotype = ""; - if(interface_tmp.getStereotypes().contains("entity")) - { + if (interface_tmp.getStereotypes().contains("entity")) { interfaceStereotype = " <<entity>>"; } // ajout de l'interface - output.write("interface "+interfaceName+interfaceStereotype+" {\n"); + output.write("interface " + interfaceName + interfaceStereotype + " {\n"); // ajout des methodes output.write("}\n\n"); } //liaisons - for(ObjectModelAttribute attribute_tmp : linksOME.keySet()) - { - if(attribute_tmp.isComposite() && attribute_tmp.referenceClassifier()) + for (ObjectModelAttribute attribute_tmp : linksOME.keySet()) { + if (attribute_tmp.isComposite() && attribute_tmp.referenceClassifier()) { + output.write(linksOME.get(attribute_tmp).getName() + " *-- " + attribute_tmp.getClassifier().getName() + "\n"); + } else if (attribute_tmp.isAggregate() && attribute_tmp.referenceClassifier())//else if { - output.write(linksOME.get(attribute_tmp).getName()+" *-- "+attribute_tmp.getClassifier().getName()+"\n"); - } - else if(attribute_tmp.isAggregate() && attribute_tmp.referenceClassifier())//else if + output.write(linksOME.get(attribute_tmp).getName() + " o-- " + attribute_tmp.getClassifier().getName() + "\n"); + } else if (!attribute_tmp.isNavigable() && attribute_tmp.referenceClassifier())//probleme avec les compositions et aggregations -> double lien { - output.write(linksOME.get(attribute_tmp).getName()+" o-- "+attribute_tmp.getClassifier().getName()+"\n"); + output.write(attribute_tmp.getClassifier().getName() + " --> " + linksOME.get(attribute_tmp).getName() + "\n"); + } else if (attribute_tmp.isNavigable() && attribute_tmp.referenceClassifier()) { + output.write(attribute_tmp.getClassifier().getName() + " -- " + linksOME.get(attribute_tmp).getName() + "\n"); } - else if(!attribute_tmp.isNavigable() && attribute_tmp.referenceClassifier())//probleme avec les compositions et aggregations -> double lien - { - output.write(attribute_tmp.getClassifier().getName()+" --> "+linksOME.get(attribute_tmp).getName()+"\n"); - } - else if(attribute_tmp.isNavigable() && attribute_tmp.referenceClassifier()) - { - output.write(attribute_tmp.getClassifier().getName()+" -- "+linksOME.get(attribute_tmp).getName()+"\n"); - } } //classes d'association - Map<String,LinkedList<String>> associationClass = new LinkedHashMap<String, LinkedList<String>>(); - for(ObjectModelClassifier classifier : input.getClassifiers()) - { - for(ObjectModelAttribute attribute : classifier.getAttributes()) - { - if(attribute.hasAssociationClass()) - { + Map<String, LinkedList<String>> associationClass = new LinkedHashMap<String, LinkedList<String>>(); + for (ObjectModelClassifier classifier : input.getClassifiers()) { + for (ObjectModelAttribute attribute : classifier.getAttributes()) { + if (attribute.hasAssociationClass()) { String key = attribute.getAssociationClass().getName(); String value = classifier.getName(); - if(associationClass.containsKey(key)) - { + if (associationClass.containsKey(key)) { associationClass.get(key).add(value); - } - else - { - associationClass.put(key,new LinkedList<String>()); + } else { + associationClass.put(key, new LinkedList<String>()); associationClass.get(key).add(value); } } } } - for(Map.Entry<String,LinkedList<String>> entry : associationClass.entrySet()) - { + for (Map.Entry<String, LinkedList<String>> entry : associationClass.entrySet()) { boolean first = true; output.write("("); - for(String value : entry.getValue()) - { - if(first) - { + for (String value : entry.getValue()) { + if (first) { output.write(value); first = false; - }else - { - output.write(", "+value); + } else { + output.write(", " + value); } } - output.write(") .. "+entry.getKey()+"\n"); + output.write(") .. " + entry.getKey() + "\n"); } //extensions/generalisations (heritage) - for(ObjectModelClass classOM : input.getClasses()) - { - for(ObjectModelClass superClassOM : classOM.getSuperclasses()) - { - output.write(superClassOM.getName()+" <|-- "+classOM.getName()); + for (ObjectModelClass classOM : input.getClasses()) { + for (ObjectModelClass superClassOM : classOM.getSuperclasses()) { + output.write(superClassOM.getName() + " <|-- " + classOM.getName()); } } @@ -226,20 +233,15 @@ } // exemple : afterLastPoint("org.nuiton.testeugene.generator") return "generator" - public static String afterLastPoint(String input) - { + public static String afterLastPoint(String input) { String str = new StringBuffer(input).reverse().toString(); String res = ""; - for(Character car : str.toCharArray()) - { - if(car.equals('.')) - { + for (Character car : str.toCharArray()) { + if (car.equals('.')) { return res; + } else { + res = car.toString() + res; } - else - { - res = car.toString()+res; - } } return res; } @@ -248,10 +250,10 @@ public void applyTemplate(ObjectModel model, File destDir) throws IOException { super.applyTemplate(model, destDir); try { - File plantuml = new File(destDir+File.separator+this.getFilenameForModel(model)); + File plantuml = new File(destDir + File.separator + this.getFilenameForModel(model)); SourceFileReader reader = new SourceFileReader(plantuml); List<GeneratedImage> lst = reader.getGeneratedImages(); - new File(lst.get(0).getPngFile(), destDir+File.separator+model.getName()+".png"); + new File(lst.get(0).getPngFile(), destDir + File.separator + model.getName() + ".png"); } catch (InterruptedException e) { e.printStackTrace(); } @@ -259,6 +261,6 @@ @Override public String getFilenameForModel(ObjectModel model) { - return model.getName()+".plantuml"; + return model.getName() + ".plantuml"; } } Property changes on: trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/site/rst/index.rst =================================================================== --- trunk/src/site/rst/index.rst 2013-05-28 13:49:26 UTC (rev 1261) +++ trunk/src/site/rst/index.rst 2013-05-29 10:06:05 UTC (rev 1262) @@ -51,10 +51,11 @@ .. _Generator: 07-glossaire.html .. _FAQ: 08-FAQ.html -EUGene is divided into 3 modules : +EUGene is divided into 4 modules : * `eugene-api`_ (EUGene Api) * `eugene-java-templates`_ (Templates pour générer des classes java) + * `eugene-plantuml-templates`_ (depuis la version 2.7) (Templates pour générer des diagrammes plantumlclasses java) * `eugene-maven-plugin`_ (Maven Plugin to generate stuff using EUGene) .. _eugene-api: eugene/index.html
participants (1)
-
tchemit@users.nuiton.org