r1278 - in trunk: eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml eugene-plantuml-templates/src eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml eugene-plantuml-templates/src/site eugene-plantuml-templates/src/site/fr eugene-plantuml-templates/src/site/fr/rst eugene-plantuml-templates/src/site/resources eugene-plantuml-templates/src/site/rst eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml
Author: agiraudet Date: 2013-06-14 16:23:53 +0200 (Fri, 14 Jun 2013) New Revision: 1278 Url: http://nuiton.org/projects/eugene/repository/revisions/1278 Log: refs #2708: ajout d'une documentation sur le template PlantUML Added: trunk/eugene-plantuml-templates/src/site/ trunk/eugene-plantuml-templates/src/site/fr/ trunk/eugene-plantuml-templates/src/site/fr/rst/ trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst trunk/eugene-plantuml-templates/src/site/resources/ trunk/eugene-plantuml-templates/src/site/resources/Pollen.png trunk/eugene-plantuml-templates/src/site/resources/legend1.png trunk/eugene-plantuml-templates/src/site/resources/legend2.png trunk/eugene-plantuml-templates/src/site/resources/legend3.png trunk/eugene-plantuml-templates/src/site/rst/ trunk/eugene-plantuml-templates/src/site/rst/index.rst trunk/eugene-plantuml-templates/src/site/site_en.xml trunk/eugene-plantuml-templates/src/site/site_fr.xml Modified: trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -17,20 +17,17 @@ public class DefaultValues implements KeyWords { Yaml yaml; - public DefaultValues() - { + public DefaultValues() { yaml = new Yaml(); } - public static Map<String,String> getDefaultValues(String version) - { - Map<String,String> values = new LinkedHashMap<String, String>(); + public static Map<String, String> getDefaultValues(String version) { + Map<String, String> values = new LinkedHashMap<String, String>(); - if(version.equals("0")) - { - values.put(ATTRIBUTE+SEPARATOR+MIN_MULTIPLICITY,"1"); - values.put(ATTRIBUTE+SEPARATOR+MAX_MULTIPLICITY,"1"); - values.put(ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY,"1"); + if (version.equals("0")) { + values.put(ATTRIBUTE + SEPARATOR + MIN_MULTIPLICITY, "1"); + values.put(ATTRIBUTE + SEPARATOR + MAX_MULTIPLICITY, "1"); + values.put(ATTRIBUTE + SEPARATOR + REVERSE_MAX_MULTIPLICITY, "1"); } /*else if(version.equals("")) { @@ -41,19 +38,16 @@ } //retourne les valeurs par defaut du fichier YAML passe an parametre - public Map<String,String> getDefaultValues(File file) throws IOException { + public Map<String, String> getDefaultValues(File file) throws IOException { InputStream inputModel = new FileInputStream(file); Object valuesYAML = yaml.load(inputModel); inputModel.close(); - Map<String,String> values = new LinkedHashMap<String, String>(); - if(valuesYAML instanceof Map) - { - for(Object entry : ((Map) valuesYAML).entrySet()) - { - if(entry instanceof Map.Entry) - { - values.put(String.valueOf(((Map.Entry) entry).getKey()),String.valueOf(((Map.Entry) entry).getValue())); + Map<String, String> values = new LinkedHashMap<String, String>(); + if (valuesYAML instanceof Map) { + for (Object entry : ((Map) valuesYAML).entrySet()) { + if (entry instanceof Map.Entry) { + values.put(String.valueOf(((Map.Entry) entry).getKey()), String.valueOf(((Map.Entry) entry).getValue())); } } } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -14,15 +14,15 @@ protected String packageL; protected YamlObject modelYAMLO; protected ObjectModelImpl modelOM; - protected Map<String,String> defaultValues; + protected Map<String, String> defaultValues; - public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM, Map<String,String> defaultValues) { + public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM, Map<String, String> defaultValues) { this.packageL = "default"; this.modelOM = modelOM; this.modelYAMLO = modelYAMLO; this.defaultValues = defaultValues; //log - //Log.initLog(modelYAMLO.toString(),"/tmp/log.LoadObjectModel.txt"); + Log.initLog(modelYAMLO.toString(), "/tmp/log.LoadObjectModel.txt"); //log } @@ -30,21 +30,19 @@ String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE); if (packageYAMLO == null) { String key = PACKAGE; - if(defaultValues.containsKey(key)) - { + if (defaultValues.containsKey(key)) { packageL = defaultValues.get(key); } } else { packageL = packageYAMLO; } //permet d'afficher le package dans le diagramme plantuml - modelOM.addTagValue(PACKAGE,packageL); + modelOM.addTagValue(PACKAGE, packageL); String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME); if (nameYAMLO == null) { String key = NAME; - if(defaultValues.containsKey(key)) - { + if (defaultValues.containsKey(key)) { modelOM.setName(defaultValues.get(key)); } } else { @@ -54,8 +52,7 @@ String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION); if (versionYAMLO == null) { String key = VERSION; - if(defaultValues.containsKey(key)) - { + if (defaultValues.containsKey(key)) { modelOM.setVersion(defaultValues.get(key)); } } else { @@ -103,9 +100,8 @@ public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) { String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME); if (nameYAMLO == null) { - String key = ELEMENT+SEPARATOR+NAME; - if(defaultValues.containsKey(key)) - { + String key = ELEMENT + SEPARATOR + NAME; + if (defaultValues.containsKey(key)) { elementOM.setName(defaultValues.get(key)); } } else { @@ -114,9 +110,8 @@ String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC); if (staticYAMLO == null) { - String key = ELEMENT+SEPARATOR+STATIC; - if(defaultValues.containsKey(key)) - { + String key = ELEMENT + SEPARATOR + STATIC; + if (defaultValues.containsKey(key)) { elementOM.setStatic(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -125,9 +120,8 @@ String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION); if (documentationYAMLO == null) { - String key = ELEMENT+SEPARATOR+DOCUMENTATION; - if(defaultValues.containsKey(key)) - { + String key = ELEMENT + SEPARATOR + DOCUMENTATION; + if (defaultValues.containsKey(key)) { elementOM.setDocumentation(defaultValues.get(key)); } } else { @@ -172,9 +166,8 @@ String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN); if (externYAMLO == null) { - String key = CLASSIFIER+SEPARATOR+EXTERN; - if(defaultValues.containsKey(key)) - { + String key = CLASSIFIER + SEPARATOR + EXTERN; + if (defaultValues.containsKey(key)) { classifierOM.setExtern(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -184,9 +177,8 @@ String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER); if (innerYAMLO == null) { - String key = CLASSIFIER+SEPARATOR+INNER; - if(defaultValues.containsKey(key)) - { + String key = CLASSIFIER + SEPARATOR + INNER; + if (defaultValues.containsKey(key)) { classifierOM.setInner(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -195,9 +187,8 @@ String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE); if (typeYAMLO == null) { - String key = CLASSIFIER+SEPARATOR+TYPE; - if(defaultValues.containsKey(key)) - { + String key = CLASSIFIER + SEPARATOR + TYPE; + if (defaultValues.containsKey(key)) { classifierOM.setType(defaultValues.get(key)); } } else { @@ -229,9 +220,8 @@ String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT); if (abstractYAMLO == null) { - String key = CLASS+SEPARATOR+ABSTRACT; - if(defaultValues.containsKey(key)) - { + String key = CLASS + SEPARATOR + ABSTRACT; + if (defaultValues.containsKey(key)) { classOM.setAbstract(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -261,9 +251,8 @@ String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME); if (nameYAMLO == null) { - String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+NAME; - if(defaultValues.containsKey(key)) - { + String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + NAME; + if (defaultValues.containsKey(key)) { participantOM.setName(defaultValues.get(key)); } } else { @@ -272,9 +261,8 @@ String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE); if (attributeYAMLO == null) { - String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+ATTRIBUTE; - if(defaultValues.containsKey(key)) - { + String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + ATTRIBUTE; + if (defaultValues.containsKey(key)) { participantOM.setAttribute(defaultValues.get(key)); } } else { @@ -309,9 +297,8 @@ String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING); if (orderingYAMLO == null) { - String key = PARAMETER+SEPARATOR+ORDERING; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + ORDERING; + if (defaultValues.containsKey(key)) { parameterOM.setOrdering(defaultValues.get(key)); } } else { @@ -320,9 +307,8 @@ String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE); if (typeYAMLO == null) { - String key = PARAMETER+SEPARATOR+TYPE; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + TYPE; + if (defaultValues.containsKey(key)) { parameterOM.setType(defaultValues.get(key)); } } else { @@ -331,9 +317,8 @@ String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE); if (defaultValueYAMLO == null) { - String key = PARAMETER+SEPARATOR+DEFAULT_VALUE; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + DEFAULT_VALUE; + if (defaultValues.containsKey(key)) { parameterOM.setDefaultValue(defaultValues.get(key)); } } else { @@ -342,9 +327,8 @@ String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY); if (minMultiplicityYAMLO == null) { - String key = PARAMETER+SEPARATOR+MIN_MULTIPLICITY; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + MIN_MULTIPLICITY; + if (defaultValues.containsKey(key)) { parameterOM.setMinMultiplicity(Integer.valueOf(defaultValues.get(key))); } } else { @@ -353,9 +337,8 @@ String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY); if (maxMultiplicityYAMLO == null) { - String key = PARAMETER+SEPARATOR+MAX_MULTIPLICITY; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + MAX_MULTIPLICITY; + if (defaultValues.containsKey(key)) { parameterOM.setMaxMultiplicity(Integer.valueOf(defaultValues.get(key))); } } else { @@ -365,9 +348,8 @@ String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED); if (orderedYAMLO == null) { - String key = PARAMETER+SEPARATOR+ORDERED; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + ORDERED; + if (defaultValues.containsKey(key)) { parameterOM.setOrdered(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -376,9 +358,8 @@ String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE); if (uniqueYAMLO == null) { - String key = PARAMETER+SEPARATOR+UNIQUE; - if(defaultValues.containsKey(key)) - { + String key = PARAMETER + SEPARATOR + UNIQUE; + if (defaultValues.containsKey(key)) { parameterOM.setUnique(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -391,9 +372,8 @@ String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE); if (navigableYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+NAVIGABLE; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + NAVIGABLE; + if (defaultValues.containsKey(key)) { attributeOM.setNavigable(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -402,9 +382,8 @@ String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE); if (associationTypeYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_TYPE; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_TYPE; + if (defaultValues.containsKey(key)) { attributeOM.setAssociationType(defaultValues.get(key)); } } else { @@ -413,9 +392,8 @@ String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL); if (finalYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+FINAL; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + FINAL; + if (defaultValues.containsKey(key)) { attributeOM.setFinal(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -424,9 +402,8 @@ String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC); if (staticYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+STATIC; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + STATIC; + if (defaultValues.containsKey(key)) { attributeOM.setStatic(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -435,9 +412,8 @@ String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME); if (associationClassNameYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_CLASS_NAME; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_CLASS_NAME; + if (defaultValues.containsKey(key)) { attributeOM.setAssociationClassName(defaultValues.get(key)); } } else { @@ -446,9 +422,8 @@ String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME); if (reverseAttributeNameYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+REVERSE_ATTRIBUTE_NAME; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + REVERSE_ATTRIBUTE_NAME; + if (defaultValues.containsKey(key)) { attributeOM.setReverseAttributeName(defaultValues.get(key)); } } else { @@ -457,9 +432,8 @@ String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY); if (reverseMaxMultiplicityYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + REVERSE_MAX_MULTIPLICITY; + if (defaultValues.containsKey(key)) { attributeOM.setReverseMaxMultiplicity(Integer.valueOf(defaultValues.get(key))); } } else { @@ -468,9 +442,8 @@ String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT); if (transientYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+TRANSIENT; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + TRANSIENT; + if (defaultValues.containsKey(key)) { attributeOM.setTransient(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -479,9 +452,8 @@ String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY); if (visibilityYAMLO == null) { - String key = ATTRIBUTE+SEPARATOR+VISIBILITY; - if(defaultValues.containsKey(key)) - { + String key = ATTRIBUTE + SEPARATOR + VISIBILITY; + if (defaultValues.containsKey(key)) { attributeOM.setVisibility(defaultValues.get(key)); } } else { @@ -494,9 +466,8 @@ String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT); if (abstractYAMLO == null) { - String key = OPERATION+SEPARATOR+ABSTRACT; - if(defaultValues.containsKey(key)) - { + String key = OPERATION + SEPARATOR + ABSTRACT; + if (defaultValues.containsKey(key)) { operationOM.setAbstract(Boolean.valueOf(defaultValues.get(key))); } } else { @@ -505,9 +476,8 @@ String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY); if (visibilityYAMLO == null) { - String key = OPERATION+SEPARATOR+VISIBILITY; - if(defaultValues.containsKey(key)) - { + String key = OPERATION + SEPARATOR + VISIBILITY; + if (defaultValues.containsKey(key)) { operationOM.setVisibility(defaultValues.get(key)); } } else { @@ -528,9 +498,8 @@ String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE); if (bodyCodeYAMLO == null) { - String key = OPERATION+SEPARATOR+BODY_CODE; - if(defaultValues.containsKey(key)) - { + String key = OPERATION + SEPARATOR + BODY_CODE; + if (defaultValues.containsKey(key)) { operationOM.setBodyCode(defaultValues.get(key)); } } else { Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -403,7 +403,21 @@ enumerationYAMLO.addStringToMap(NAME, name); importsI.put(name, packageM + "." + name); } - //TODO: parser literals + + if (value instanceof Map) { + //TODO: utiliser variable locales pour plus de clartee + if (((Map) value).containsKey(LITERAL)) { + if (((Map) value).get(LITERAL) instanceof Map) { + for (Object entry : ((Map) ((Map) value).get(LITERAL)).entrySet()) { + if (entry instanceof Map.Entry) { + enumerationYAMLO.addStringToMap(LITERAL, String.valueOf(((Map.Entry) entry).getKey())); + } + } + } + ((Map) value).remove(LITERAL); + } + } + } //TODO: factoriser code @@ -414,6 +428,13 @@ public void parseAttribute(String key, Object value, YamlObject attributeYAMLO) { List<String> attributePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>'); + if (attributePARSE.contains(COMPOSITE)) { + attributeYAMLO.addStringToMap(ASSOCIATION_TYPE, COMPOSITE); + attributePARSE.remove(attributePARSE.indexOf(COMPOSITE)); + } else if (attributePARSE.contains(AGGREGATE)) { + attributeYAMLO.addStringToMap(ASSOCIATION_TYPE, AGGREGATE); + attributePARSE.remove(attributePARSE.indexOf(AGGREGATE)); + } if (attributePARSE.contains(STATIC)) { attributeYAMLO.addStringToMap(STATIC, String.valueOf(true)); attributePARSE.remove(attributePARSE.indexOf(STATIC)); @@ -486,12 +507,12 @@ if (attributePARSE.size() > 1) { attributeYAMLO.addStringToMap(NAME, attributePARSE.get(1)); } - if(value != null) - { + if (value != null) { //idée1: defaultValue //attributeYAMLO.addStringToMap(DEFAULT_VALUE,String.valueOf(value)); //idée2: reverseMultiplicity & reverseOrdering (pour lien unidirectionnel) - List<String> valuePARSE = YamlUtil.charParse(String.valueOf(value),' '); + //idée3: defaultValue après '=' + List<String> valuePARSE = YamlUtil.charParse(String.valueOf(value), ' '); if (valuePARSE.contains(ORDERED)) { attributeYAMLO.addStringToMap(REVERSE_ORDERING, ORDERED); attributePARSE.remove(valuePARSE.indexOf(ORDERED)); @@ -577,7 +598,7 @@ returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value)); operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);*/ //idée2: bodyCode - operationYAMLO.addStringToMap(BODY_CODE,String.valueOf(value)); + operationYAMLO.addStringToMap(BODY_CODE, String.valueOf(value)); } } @@ -650,7 +671,8 @@ if (imports.containsKey(ninja)) { res.append(imports.get(ninja)); } else { - res.append(tmp); + //res.append(tmp); + res.append(ninja); } res.append("<"); res.append(browseType(YamlUtil.extract('<', '>', tmp))); @@ -720,8 +742,7 @@ if (attribute.containsKeyMapStringListString(REVERSE_MAX_MULTIPLICITY)) { reverseAttribute.addStringToMap(MAX_MULTIPLICITY, attribute.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY)); } - if(attribute.containsKeyMapStringListString(REVERSE_ORDERING)) - { + if (attribute.containsKeyMapStringListString(REVERSE_ORDERING)) { reverseAttribute.addStringToMap(ORDERING, attribute.getFirstMapStringListString(REVERSE_ORDERING)); } //else set opposit ordering 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-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -34,6 +34,8 @@ } if (input.getTagValue(PACKAGE) != null) { packageM = input.getTagValue(PACKAGE) + " "; + } else { + packageM = findPackage(input) + " "; } output.write("note \"" + nameM + " " + versionM + "\" as N1\n\n"); output.write("package " + packageM + "{\n\n"); @@ -166,29 +168,50 @@ return stereotype.toString(); } - //TODO: parser type public void generateFromAttributes(Writer output, Collection<ObjectModelAttribute> input, String indent) throws IOException { for (ObjectModelAttribute attribute : input) { if (!attribute.referenceClassifier()) { + String visibility = ""; + if (attribute.getVisibility() != null) { + if (attribute.getVisibility().equals(PUBLIC)) { + visibility = "+ "; + } else if (attribute.getVisibility().equals(PROTECTED)) { + visibility = "# "; + } else if (attribute.getVisibility().equals(PRIVATE)) { + visibility = "- "; + } + } String type = "", name = ""; if (attribute.getType() != null) { - type = attribute.getType() + " "; + type = reduceType(attribute.getType()) + " "; } if (attribute.getName() != null) { name = attribute.getName(); } - output.write(indent + type + name + "\n"); + output.write(indent + visibility + type + name + "\n"); } } } - //TODO: parser parameters public void generateFromOperations(Writer output, Collection<ObjectModelOperation> input, String indent) throws IOException { for (ObjectModelOperation operation : input) { - String isAbstract = "", parameters = "", name = "", returnParameter = ""; + String isAbstract = "", isStatic = "", parameters = "", name = "", returnParameter = ""; if (operation.isAbstract()) { isAbstract = "{abstract} "; } + if (operation.isStatic()) { + isAbstract = "{static} "; + } + String visibility = ""; + if (operation.getVisibility() != null) { + if (operation.getVisibility().equals(PUBLIC)) { + visibility = "+ "; + } else if (operation.getVisibility().equals(PROTECTED)) { + visibility = "# "; + } else if (operation.getVisibility().equals(PRIVATE)) { + visibility = "- "; + } + } if (operation.getParameters() != null) { StringBuilder tmp = new StringBuilder(""); boolean first = true; @@ -199,7 +222,7 @@ tmp.append(", "); } if (parameter.getType() != null) { - tmp.append(parameter.getType()).append(" "); + tmp.append(reduceType(parameter.getType())).append(" "); } if (parameter.getName() != null) { tmp.append(parameter.getName()); @@ -209,13 +232,13 @@ } if (operation.getReturnParameter() != null) { if (operation.getReturnParameter().getType() != null) { - returnParameter = operation.getReturnParameter().getType() + " "; + returnParameter = reduceType(operation.getReturnParameter().getType()) + " "; } } if (operation.getName() != null) { name = operation.getName(); } - output.write(indent + isAbstract + returnParameter + name + "(" + parameters + ")\n"); + output.write(indent + isAbstract + isStatic + visibility + returnParameter + name + "(" + parameters + ")\n"); } } @@ -239,13 +262,11 @@ } } - //TODO: factoriser public void generateFromLinks(Writer output, ObjectModel input, String indent) throws IOException { Map<ObjectModelAttribute, ObjectModelClassifier> attributesM = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>(); List<ObjectModelAttribute> bin = new LinkedList<ObjectModelAttribute>();//bin au sens poubelle - for (ObjectModelClassifier classifier : input.getClassifiers())//TODO+enum? - { + for (ObjectModelClassifier classifier : input.getClassifiers()) { if (classifier.getAttributes() != null) { for (ObjectModelAttribute attribute : classifier.getAttributes()) { if (attribute.referenceClassifier()) { @@ -263,6 +284,12 @@ if (attribute.getName() != null) { attributeName = attribute.getName(); } + String associationType = ""; + if (attribute.isComposite()) { + associationType = "*"; + } else if (attribute.isAggregate()) { + associationType = "o"; + } String minMultiplicity = (attribute.getMinMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMinMultiplicity()); String maxMultiplicity = (attribute.getMaxMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMaxMultiplicity()); String multiplicity = (minMultiplicity.equals(maxMultiplicity)) ? minMultiplicity : minMultiplicity + ".." + maxMultiplicity; @@ -280,6 +307,7 @@ String reverseType = YamlUtil.afterChar(reverseAttribute.getType(), '.'); if (reverseAttribute.isNavigable())//lien bi-directionnel { + //tenir compte du type d'association ? output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" -- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n"); if (attribute.getAssociationClass() != null && reverseAttribute.getAssociationClass() != null && attribute.getAssociationClass().equals(reverseAttribute.getAssociationClass())) { String associationClassName = ""; @@ -291,21 +319,75 @@ bin.add(reverseAttribute); } else//lien uni-directionnel { - if (multiplicity.equals("0..*") && reverseMultiplicity.equals("1")) { + /*if (multiplicity.equals("0..*") && reverseMultiplicity.equals("1")) { output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <--* \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n"); } else { output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <-- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n"); - } + }*/ + output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <--" + associationType + " \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n"); + } } else { String reverseType = ""; if (attributesM.get(attribute).getName() != null) { reverseType = attributesM.get(attribute).getName(); } - output.write(type + " \"" + multiplicity + " " + attributeName + "\" <-- " + reverseType + "\n"); + output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <-- " + reverseType + "\n"); } } } } } + + public static String browseType(String type) { + StringBuilder res = new StringBuilder(); + boolean first = true; + for (String tmp : YamlUtil.charParseIgnore(type, ',', '<', '>')) { + if (first) { + first = false; + } else { + res.append(","); + } + if (tmp.contains("<") && tmp.contains(">")) { + String ninja = YamlUtil.beforeChar(tmp, '<'); + res.append(YamlUtil.afterChar(ninja, '.')); + res.append("<"); + res.append(browseType(YamlUtil.extract('<', '>', tmp))); + res.append(">"); + } else { + res.append(YamlUtil.afterChar(tmp, '.')); + } + } + return res.toString(); + } + + public static String reduceType(String type) { + List<Character> ignore = new LinkedList<Character>(); + ignore.add(' '); + String typePARSE = YamlUtil.removeMultiChar(type, ignore); + return browseType(typePARSE); + } + + public String findPackage(ObjectModel input) { + Map<String, Integer> packages = new LinkedHashMap<String, Integer>(); + for (ObjectModelClassifier classifier : input.getClassifiers()) { + String packageTMP = classifier.getPackageName(); + if (packageTMP != null) { + if (packages.containsKey(packageTMP)) { + packages.put(packageTMP, packages.get(packageTMP) + 1); + } else { + packages.put(packageTMP, 1); + } + } + } + String packageL = ""; + int count = 0; + for (Map.Entry<String, Integer> entry : packages.entrySet()) { + if (entry.getValue() > count) { + count = entry.getValue(); + packageL = entry.getKey(); + } + } + return packageL; + } } Added: trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst =================================================================== --- trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst (rev 0) +++ trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst 2013-06-14 14:23:53 UTC (rev 1278) @@ -0,0 +1,84 @@ +.. - +.. * #%L +.. * EUGene :: PlantUML templates +.. * +.. * $Id: index.rst 1174 2012-08-17 08:44:36Z tchemit $ +.. * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/fr... $ +.. * %% +.. * Copyright (C) 2012 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% +.. - + +========================= +EUGene PlantUML templates +========================= + +.. contents:: + +Présentation +------------ +Le plugin *eugene-plantuml-templates* est un template permettant de générer un diagramme de classes `PlantUML` à partir d'un `ObjectModel` au moment de l'installation d'un projet. +`PlantUML` utilise Graphviz lors de la génération d'images, si vous ne pouvez pas installer `Graphviz`, le `PlantUML Server` permet de générer des diagrammes en ligne. + +Démonstration +----------------------------- +Voici un exemple d'utilisation du plugin *eugene-plantuml-templates* avec le projet `Pollen`. + + +Ajouter le template dans le pom.xml +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Après avoir récupéré les sources du projet `Pollen`, on ajoute le template PlantUML au fichier pollen-persistence/pom.xml (sans oublier la virgule pour séparer les templates):: + + <templates> + org.nuiton.topia.generator.TopiaMetaTransformer, + org.nuiton.topia.generator.BinderHelperTransformer, + org.nuiton.eugene.plantuml.PlantumlTemplatesGenerator + </templates> + +Installation du projet +~~~~~~~~~~~~~~~~~~~~~~ +On lance ensuite l'installation avec la commande:: + pollen$ mvn install +La ligne suivante devrait apparaitre lors de l'installation:: + [INFO] Apply generator PlantumlTemplatesGenerator" + +Résultat +~~~~~~~~ +Le diagramme de classe se trouve dans le répertoire pollen-persistence/target/classes (ou pollen-persistence/target/generated-sources/java): +Pollen.plantuml est la représentation textuelle du modèle en `PlantUML` +Pollen.png est l'image générée par `PlantUML` à partir du fichier Pollen.plantuml +Pour générer le diagramme à partir du `PlantUML Server`, il suffit de copier le contenu du fichier Pollen.plantuml dans le formulaire du site et d'envoyer. + +Voici à quoi devrait ressembler le diagramme: +.. image:: ../images/Pollen.png + +Légende +~~~~~~~ +Visibilité: +.. image:: ../images/legend1.png + +Abstract & Static: +.. image:: ../images/legend2.png + +Relations: +.. image:: ../images/legend3.png + +.. _PlantUML : http://plantuml.sourceforge.net/index.html +.. _ObjectModel : http://maven-site.nuiton.org/eugene/02-objectmodel.html +.. _Graphviz : http://www.graphviz.org/ +.. _PlantUML Server : http://plantuml.com/plantuml/ +.. _Pollen : http://maven-site.chorem.org/pollen/ Added: trunk/eugene-plantuml-templates/src/site/resources/Pollen.png =================================================================== (Binary files differ) Property changes on: trunk/eugene-plantuml-templates/src/site/resources/Pollen.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/eugene-plantuml-templates/src/site/resources/legend1.png =================================================================== (Binary files differ) Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend1.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/eugene-plantuml-templates/src/site/resources/legend2.png =================================================================== (Binary files differ) Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend2.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/eugene-plantuml-templates/src/site/resources/legend3.png =================================================================== (Binary files differ) Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend3.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/eugene-plantuml-templates/src/site/rst/index.rst =================================================================== --- trunk/eugene-plantuml-templates/src/site/rst/index.rst (rev 0) +++ trunk/eugene-plantuml-templates/src/site/rst/index.rst 2013-06-14 14:23:53 UTC (rev 1278) @@ -0,0 +1,36 @@ +.. - +.. * #%L +.. * EUGene :: PlantUML templates +.. * +.. * $Id: index.rst 1220 2012-12-10 07:55:48Z tchemit $ +.. * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/rs... $ +.. * %% +.. * Copyright (C) 2012 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% +.. - + +========================= +EUGene PlantUML templates +========================= + +.. contents:: + +Introduction +------------ + +Example +------- Added: trunk/eugene-plantuml-templates/src/site/site_en.xml =================================================================== --- trunk/eugene-plantuml-templates/src/site/site_en.xml (rev 0) +++ trunk/eugene-plantuml-templates/src/site/site_en.xml 2013-06-14 14:23:53 UTC (rev 1278) @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + EUGene :: Java templates + $Id: site_en.xml 1223 2012-12-10 08:17:42Z tchemit $ + $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/si... $ + %% + Copyright (C) 2012 CodeLutin, Tony Chemit + %% + 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% + --> + + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + </bannerLeft> + + <body> + + <head> + <script type="text/javascript" + src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> + </script> + </head> + + <breadcrumbs> + <item name="${project.name}" href="./index.html"/> + </breadcrumbs> + + <links> + <item name="[fr" href="fr/index.html"/> + <item name="en]" href="index.html"/> + </links> + + <menu ref="parent"/> + + <menu name="User"> + <item href="index.html" name="Home"/> + </menu> + + <menu ref="reports"/> + + <footer> + + <div id='projectMetas' locale='en' + projectversion='${project.version}' + platform='${project.platform}' + projectid='${project.projectId}' + scm='${project.scm.developerConnection}' + scmwebeditorenabled='${project.scmwebeditorEnabled}' + scmwebeditorurl='${project.scmwebeditorUrl}' + siteSourcesType='${project.siteSourcesType}' + piwikEnabled='${project.piwikEnabled}' + piwikId='${project.piwikId}'> + </div> + </footer> + + </body> +</project> Added: trunk/eugene-plantuml-templates/src/site/site_fr.xml =================================================================== --- trunk/eugene-plantuml-templates/src/site/site_fr.xml (rev 0) +++ trunk/eugene-plantuml-templates/src/site/site_fr.xml 2013-06-14 14:23:53 UTC (rev 1278) @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + EUGene :: Java templates + $Id: site_fr.xml 1223 2012-12-10 08:17:42Z tchemit $ + $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/si... $ + %% + Copyright (C) 2012 CodeLutin, Tony Chemit + %% + 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% + --> + + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + </bannerLeft> + + <body> + + <head> + <script type="text/javascript" + src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> + </script> + </head> + + <breadcrumbs> + <item name="${project.name}" href="./index.html"/> + </breadcrumbs> + + <links> + <item name="[fr" href="index.html"/> + <item name="en]" href="../index.html"/> + </links> + + <!-- TC-20100117 : ne fonctionne pas sur une langue non principale --> + <!--<menu ref="parent"/>--> + <menu name="Parent Projet"> + <item name="Eugene" href="../../fr/index.html"/> + </menu> + + <menu name="Utilisateur"> + <item href="index.html" name="Accueil"/> + </menu> + + <menu ref="reports"/> + + <footer> + + <div id='projectMetas' locale='fr' + projectversion='${project.version}' + platform='${project.platform}' + projectid='${project.projectId}' + scm='${project.scm.developerConnection}' + scmwebeditorenabled='${project.scmwebeditorEnabled}' + scmwebeditorurl='${project.scmwebeditorUrl}' + siteSourcesType='${project.siteSourcesType}' + piwikEnabled='${project.piwikEnabled}' + piwikId='${project.piwikId}'> + </div> + </footer> + + </body> +</project> Modified: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java =================================================================== --- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -20,178 +20,143 @@ @Override public void generateFromModel(Writer output, ObjectModel input) throws IOException { output.write("%YAML 1.1\n---\n- syntaxe: 1.0\n\n"); - if(input.getName() != null) - { - output.write("- "+NAME+": "+input.getName()+"\n"); + if (input.getName() != null) { + output.write("- " + NAME + ": " + input.getName() + "\n"); } - if(input.getVersion() != null) - { - output.write("- "+VERSION+": "+input.getVersion()+"\n"); + if (input.getVersion() != null) { + output.write("- " + VERSION + ": " + input.getVersion() + "\n"); } - if(input.getTagValues() != null && !input.getTagValues().isEmpty()) - { - output.write("- "+TAG_VALUES+":\n"); - for(Map.Entry<String,String> entry : input.getTagValues().entrySet()) - { - output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n"); + if (input.getTagValues() != null && !input.getTagValues().isEmpty()) { + output.write("- " + TAG_VALUES + ":\n"); + for (Map.Entry<String, String> entry : input.getTagValues().entrySet()) { + output.write(" - " + entry.getKey() + ": " + entry.getValue() + "\n"); } } output.write("\n"); //classifier - if(input.getClasses() != null && !input.getClasses().isEmpty()) - { - for(ObjectModelClass objectModelClass : input.getClasses()) - { + if (input.getClasses() != null && !input.getClasses().isEmpty()) { + for (ObjectModelClass objectModelClass : input.getClasses()) { //associationClass - if(objectModelClass instanceof ObjectModelAssociationClass) - { + if (objectModelClass instanceof ObjectModelAssociationClass) { generateFromAssociationClass(output, (ObjectModelAssociationClass) objectModelClass); } //class - else - { + else { generateFromClass(output, objectModelClass); } } } //interface - if(input.getInterfaces() != null && !input.getInterfaces().isEmpty()) - { - for(ObjectModelInterface objectModelInterface : input.getInterfaces()) - { + if (input.getInterfaces() != null && !input.getInterfaces().isEmpty()) { + for (ObjectModelInterface objectModelInterface : input.getInterfaces()) { generateFromInterface(output, objectModelInterface); } } //enumeration - if(input.getEnumerations() != null && !input.getEnumerations().isEmpty()) - { - for(ObjectModelEnumeration objectModelEnumeration : input.getEnumerations()) - { - generateFromEnumeration(output,objectModelEnumeration); + if (input.getEnumerations() != null && !input.getEnumerations().isEmpty()) { + for (ObjectModelEnumeration objectModelEnumeration : input.getEnumerations()) { + generateFromEnumeration(output, objectModelEnumeration); } } } @Override public String getFilenameForModel(ObjectModel model) { - return model.getName()+".yamlobjectmodel"; + return model.getName() + ".yamlobjectmodel"; } public void generateFromElement(Writer output, ObjectModelElement input, String indent) throws IOException { - if(input.getName() != null) - { - output.write(indent+"- "+NAME+": "+input.getName()+"\n"); + if (input.getName() != null) { + output.write(indent + "- " + NAME + ": " + input.getName() + "\n"); } - if(input.getStereotypes() != null && !input.getStereotypes().isEmpty()) - { - for(String stereotype : input.getStereotypes()) - { - output.write(indent+"- "+STEREOTYPES+": "+stereotype+"\n"); + if (input.getStereotypes() != null && !input.getStereotypes().isEmpty()) { + for (String stereotype : input.getStereotypes()) { + output.write(indent + "- " + STEREOTYPES + ": " + stereotype + "\n"); } } - if(input.getComments() != null && !input.getComments().isEmpty()) - { - for(String comment : input.getComments()) - { - output.write(indent+"- "+COMMENTS+": "+comment+"\n"); + if (input.getComments() != null && !input.getComments().isEmpty()) { + for (String comment : input.getComments()) { + output.write(indent + "- " + COMMENTS + ": " + comment + "\n"); } } /*if(input.getDescription() != null) { output.write(indent+"- "+DESCRIPTION+": "+input.getDescription()+"\n"); }*/ - if(input.getDocumentation() != null) - { - output.write(indent+"- "+DOCUMENTATION+": "+input.getDocumentation()+"\n"); + if (input.getDocumentation() != null) { + output.write(indent + "- " + DOCUMENTATION + ": " + input.getDocumentation() + "\n"); } - if(input.getTagValues() != null && !input.getTagValues().isEmpty()) - { - output.write("- "+TAG_VALUES+":\n"); - for(Map.Entry<String,String> entry : input.getTagValues().entrySet()) - { - output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n"); + if (input.getTagValues() != null && !input.getTagValues().isEmpty()) { + output.write("- " + TAG_VALUES + ":\n"); + for (Map.Entry<String, String> entry : input.getTagValues().entrySet()) { + output.write(" - " + entry.getKey() + ": " + entry.getValue() + "\n"); } } - output.write(indent+"- "+STATIC+": "+String.valueOf(input.isStatic())+"\n"); + output.write(indent + "- " + STATIC + ": " + String.valueOf(input.isStatic()) + "\n"); } public void generateFromClassifier(Writer output, ObjectModelClassifier input) throws IOException { - if(input.getInterfaces() != null && !input.getInterfaces().isEmpty()) - { - for(ObjectModelInterface objectModelInterface : input.getInterfaces()) - { + if (input.getInterfaces() != null && !input.getInterfaces().isEmpty()) { + for (ObjectModelInterface objectModelInterface : input.getInterfaces()) { //tester null - output.write(" - "+SUPER_INTERFACES+": "+objectModelInterface.getPackageName()+"."+objectModelInterface.getName()); + output.write(" - " + SUPER_INTERFACES + ": " + objectModelInterface.getPackageName() + "." + objectModelInterface.getName()); } } - generateFromElement(output,input," "); - output.write(" - "+INNER+": "+String.valueOf(input.isInner())+"\n"); - if(input.getPackageName() != null) - { - output.write(" - "+PACKAGE+": "+input.getPackageName()+"\n"); + generateFromElement(output, input, " "); + output.write(" - " + INNER + ": " + String.valueOf(input.isInner()) + "\n"); + if (input.getPackageName() != null) { + output.write(" - " + PACKAGE + ": " + input.getPackageName() + "\n"); } - if(input.getAttributes() != null && !input.getAttributes().isEmpty()) - { - for(ObjectModelAttribute attribute : input.getAttributes()) - { - generateFromAttribute(output,attribute); + if (input.getAttributes() != null && !input.getAttributes().isEmpty()) { + for (ObjectModelAttribute attribute : input.getAttributes()) { + generateFromAttribute(output, attribute); } } - if(input.getOperations() != null && !input.getOperations().isEmpty()) - { - for(ObjectModelOperation operation : input.getOperations()) - { - generateFromOperation(output,operation); + if (input.getOperations() != null && !input.getOperations().isEmpty()) { + for (ObjectModelOperation operation : input.getOperations()) { + generateFromOperation(output, operation); } } } public void generateFromClass(Writer output, ObjectModelClass input) throws IOException { output.write("- " + CLASS + ":\n"); - output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n"); - if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) - { - for(ObjectModelClass objectModelClass : input.getSuperclasses()) - { + output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n"); + if (input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) { + for (ObjectModelClass objectModelClass : input.getSuperclasses()) { //tester null - output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName()); + output.write(" - " + SUPER_CLASSES + ": " + objectModelClass.getPackageName() + "." + objectModelClass.getName()); } } - generateFromClassifier(output,input); + generateFromClassifier(output, input); output.write("\n"); } public void generateFromInterface(Writer output, ObjectModelInterface input) throws IOException { - output.write("- "+INTERFACE+":\n"); - generateFromClassifier(output,input); + output.write("- " + INTERFACE + ":\n"); + generateFromClassifier(output, input); output.write("\n"); } public void generateFromAssociationClass(Writer output, ObjectModelAssociationClass input) throws IOException { output.write("- " + ASSOCIATION_CLASS + ":\n"); - if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) - { - for(ObjectModelClass objectModelClass : input.getSuperclasses()) - { + if (input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) { + for (ObjectModelClass objectModelClass : input.getSuperclasses()) { //tester null - output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName()); + output.write(" - " + SUPER_CLASSES + ": " + objectModelClass.getPackageName() + "." + objectModelClass.getName()); } } - generateFromClassifier(output,input); + generateFromClassifier(output, input); output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n"); - if(input.getParticipantsAttributes() != null && !input.getParticipantsAttributes().isEmpty()) - { - for(ObjectModelAttribute attribute : input.getParticipantsAttributes()) - { - output.write(" - "+PARTICIPANT+":\n"); + if (input.getParticipantsAttributes() != null && !input.getParticipantsAttributes().isEmpty()) { + for (ObjectModelAttribute attribute : input.getParticipantsAttributes()) { + output.write(" - " + PARTICIPANT + ":\n"); //tester null - if(attribute.getType() != null) - { - output.write(" - "+NAME+": "+attribute.getType()+"\n"); + if (attribute.getType() != null) { + output.write(" - " + NAME + ": " + attribute.getType() + "\n"); } - if(attribute.getName() != null) - { - output.write(" - "+TYPE+": "+attribute.getName()+"\n"); + if (attribute.getName() != null) { + output.write(" - " + TYPE + ": " + attribute.getName() + "\n"); } } } @@ -199,80 +164,65 @@ } public void generateFromEnumeration(Writer output, ObjectModelEnumeration input) throws IOException { - output.write("- "+ENUMERATION+":\n"); - generateFromElement(output,input," "); + output.write("- " + ENUMERATION + ":\n"); + generateFromElement(output, input, " "); } public void generateFromParameter(Writer output, ObjectModelParameter input, String indent) throws IOException { - generateFromElement(output,input,indent); - if(input.isOrdered()) - { - output.write(indent+"- "+ORDERING+": "+ORDERED+"\n"); + generateFromElement(output, input, indent); + if (input.isOrdered()) { + output.write(indent + "- " + ORDERING + ": " + ORDERED + "\n"); + } else { + output.write(indent + "- " + ORDERING + ": " + UNORDERED + "\n"); } - else - { - output.write(indent+"- "+ORDERING+": "+UNORDERED+"\n"); + if (input.getType() != null) { + output.write(indent + "- " + TYPE + ": " + input.getType() + "\n"); } - if(input.getType() != null) - { - output.write(indent+"- "+TYPE+": "+input.getType()+"\n"); + if (input.getDefaultValue() != null) { + output.write(indent + "- " + DEFAULT_VALUE + ": " + input.getDefaultValue() + "\n"); } - if(input.getDefaultValue() != null) - { - output.write(indent+"- "+DEFAULT_VALUE+": "+input.getDefaultValue()+"\n"); - } - output.write(indent+"- "+MIN_MULTIPLICITY+": "+String.valueOf(input.getMinMultiplicity())+"\n"); - output.write(indent+"- "+MAX_MULTIPLICITY+": "+String.valueOf(input.getMaxMultiplicity())+"\n"); - output.write(indent+"- "+UNIQUE+": "+String.valueOf(input.isUnique())+"\n"); + output.write(indent + "- " + MIN_MULTIPLICITY + ": " + String.valueOf(input.getMinMultiplicity()) + "\n"); + output.write(indent + "- " + MAX_MULTIPLICITY + ": " + String.valueOf(input.getMaxMultiplicity()) + "\n"); + output.write(indent + "- " + UNIQUE + ": " + String.valueOf(input.isUnique()) + "\n"); } public void generateFromAttribute(Writer output, ObjectModelAttribute input) throws IOException { - output.write(" - "+ATTRIBUTE+":\n"); + output.write(" - " + ATTRIBUTE + ":\n"); generateFromParameter(output, input, " "); - output.write(" - "+NAVIGABLE+": "+String.valueOf(input.isNavigable())+"\n"); - output.write(" - "+TRANSIENT+": "+String.valueOf(input.isTransient())+"\n"); - output.write(" - "+FINAL+": "+String.valueOf(input.isFinal())+"\n"); - output.write(" - "+REVERSE_MAX_MULTIPLICITY+": "+String.valueOf(input.getReverseMaxMultiplicity())+"\n"); - if(input.getVisibility() != null) - { - output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n"); + output.write(" - " + NAVIGABLE + ": " + String.valueOf(input.isNavigable()) + "\n"); + output.write(" - " + TRANSIENT + ": " + String.valueOf(input.isTransient()) + "\n"); + output.write(" - " + FINAL + ": " + String.valueOf(input.isFinal()) + "\n"); + output.write(" - " + REVERSE_MAX_MULTIPLICITY + ": " + String.valueOf(input.getReverseMaxMultiplicity()) + "\n"); + if (input.getVisibility() != null) { + output.write(" - " + VISIBILITY + ": " + input.getVisibility() + "\n"); } - if(input.isComposite()) - { - output.write(" - "+ASSOCIATION_TYPE+": "+COMPOSITE+"\n"); + if (input.isComposite()) { + output.write(" - " + ASSOCIATION_TYPE + ": " + COMPOSITE + "\n"); + } else if (input.isAggregate()) { + output.write(" - " + ASSOCIATION_TYPE + ": " + AGGREGATE + "\n"); } - else if(input.isAggregate()) - { - output.write(" - "+ASSOCIATION_TYPE+": "+AGGREGATE+"\n"); + if (input.getAssociationClass() != null) { + output.write(" - " + ASSOCIATION_CLASS_NAME + ": " + input.getAssociationClass().getPackageName() + "." + input.getAssociationClass().getName() + "\n"); } - if(input.getAssociationClass() != null) - { - output.write(" - "+ASSOCIATION_CLASS_NAME+": "+input.getAssociationClass().getPackageName()+"."+input.getAssociationClass().getName()+"\n"); - } } public void generateFromOperation(Writer output, ObjectModelOperation input) throws IOException { output.write(" - " + ATTRIBUTE + ":\n"); generateFromElement(output, input, " "); - output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n"); - if(input.getVisibility() != null) - { - output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n"); + output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n"); + if (input.getVisibility() != null) { + output.write(" - " + VISIBILITY + ": " + input.getVisibility() + "\n"); } - if(input.getBodyCode() != null) - { - output.write(" - "+BODY_CODE+": "+input.getBodyCode()+"\n"); + if (input.getBodyCode() != null) { + output.write(" - " + BODY_CODE + ": " + input.getBodyCode() + "\n"); } - if(input.getReturnParameter() != null) - { - output.write(" - "+RETURN_PARAMETER+":\n"); + if (input.getReturnParameter() != null) { + output.write(" - " + RETURN_PARAMETER + ":\n"); generateFromParameter(output, input.getReturnParameter(), " "); } - if(input.getParameters() != null && !input.getParameters().isEmpty()) - { - for(ObjectModelParameter objectModelParameter : input.getParameters()) - { - output.write(" - "+PARAMETER+":\n"); + if (input.getParameters() != null && !input.getParameters().isEmpty()) { + for (ObjectModelParameter objectModelParameter : input.getParameters()) { + output.write(" - " + PARAMETER + ":\n"); generateFromParameter(output, objectModelParameter, " "); } } Modified: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java =================================================================== --- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277) +++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278) @@ -21,6 +21,6 @@ @Override public String getFilenameForModel(ObjectModel model) { - return model.getName()+".yamlobjectmodel"; + return model.getName() + ".yamlobjectmodel"; } }
participants (1)
-
agiraudet@users.nuiton.org