Eugene-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
June 2013
- 2 participants
- 17 discussions
r1272 - trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml
by agiraudet@users.nuiton.org 11 Jun '13
by agiraudet@users.nuiton.org 11 Jun '13
11 Jun '13
Author: agiraudet
Date: 2013-06-11 14:16:35 +0200 (Tue, 11 Jun 2013)
New Revision: 1272
Url: http://nuiton.org/projects/eugene/repository/revisions/1272
Log:
formatage du code org.nuiton.eugene.models.object.reader.yaml.*
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/LoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java
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/SyntaxePureYaml.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.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
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-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -15,8 +15,7 @@
protected YamlObject modelYAMLO;
protected ObjectModelImpl modelOM;
- public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM)
- {
+ public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM) {
this.packageL = "default";
this.modelOM = modelOM;
this.modelYAMLO = modelYAMLO;
@@ -27,263 +26,204 @@
public void loadModel() {
String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ if (packageYAMLO == null) {
//valeur par defaut
- }
- else
- {
+ } else {
packageL = packageYAMLO;
}
String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
modelOM.setName(nameYAMLO);
}
String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
- if(versionYAMLO == null)
- {
+ if (versionYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
modelOM.setVersion(versionYAMLO);
}
//tageValues
//TODO: tester
YamlObject tagValues = modelYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
- if(tagValues != null)
- {
- for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
- {
- if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ if (tagValues != null) {
+ for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
+ if (!tagValue.getValue().isEmpty())//taille strictement = 1
{
- modelOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ modelOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
}
}
}
//classes
- for(YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS))
- {
+ for (YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS)) {
ObjectModelClassImpl classOM = new ObjectModelClassImpl();
- loadClass(classYAMLO,classOM);
+ loadClass(classYAMLO, classOM);
modelOM.addClass(classOM);
}
//interfaces
- for(YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE))
- {
+ for (YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE)) {
ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
- loadInterface(interfaceYAMLO,interfaceOM);
+ loadInterface(interfaceYAMLO, interfaceOM);
modelOM.addInterface(interfaceOM);
}
//classes d'association
- for(YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS))
- {
+ for (YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS)) {
ObjectModelAssociationClassImpl associationClassOM = new ObjectModelAssociationClassImpl();
- loadAssociationClass(associationClassYAMLO,associationClassOM);
+ loadAssociationClass(associationClassYAMLO, associationClassOM);
modelOM.addAssociationClass(associationClassOM);
}
//enumerations
- for(YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION))
- {
+ for (YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION)) {
ObjectModelEnumerationImpl enumerationOM = new ObjectModelEnumerationImpl();
- loadEnumeration(enumerationYAMLO,enumerationOM);
+ loadEnumeration(enumerationYAMLO, enumerationOM);
modelOM.addEnumeration(enumerationOM);
}
}
- public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM)
- {
+ public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) {
String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setName(nameYAMLO);
}
String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
- if(staticYAMLO == null)
- {
+ if (staticYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setStatic(Boolean.valueOf(staticYAMLO));
}
String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
- if(documentationYAMLO == null)
- {
+ if (documentationYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setDocumentation(documentationYAMLO);
}
//TODO: tester
YamlObject tagValues = elementYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
- if(tagValues != null)
- {
- for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
- {
- if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ if (tagValues != null) {
+ for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
+ if (!tagValue.getValue().isEmpty())//taille strictement = 1
{
- elementOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ elementOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
}
}
}
List<String> comments = elementYAMLO.getMapStringListString(COMMENTS);
- for(String comment : comments)
- {
+ for (String comment : comments) {
elementOM.addComment(comment);
}
List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
- for(String stereotype : stereotypes)
- {
+ for (String stereotype : stereotypes) {
ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
stereotypeOM.setName(stereotype);
elementOM.addStereotype(stereotypeOM);
}
}
- public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM)
- {
+ public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM) {
loadElement(classifierYAMLO, classifierOM);
- String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
+ if (packageYAMLO == null) {
classifierOM.setPackage(packageL);
- }
- else
- {
+ } else {
classifierOM.setPackage(packageYAMLO);
}
String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
- if(externYAMLO == null)
- {
+ if (externYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setExtern(Boolean.valueOf(externYAMLO));
}
String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
- if(innerYAMLO == null)
- {
+ if (innerYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setInner(Boolean.valueOf(innerYAMLO));
}
String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
- if(typeYAMLO == null)
- {
+ if (typeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setType(typeYAMLO);
}
- for(YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE))
- {
+ for (YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
- loadAttribute(attributeYAMLO,attributeOM);
+ loadAttribute(attributeYAMLO, attributeOM);
classifierOM.addAttribute(attributeOM);
}
- for(YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION))
- {
+ for (YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION)) {
ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
- loadOperation(operationYAMLO,operationOM);
+ loadOperation(operationYAMLO, operationOM);
classifierOM.addOperation(operationOM);
}
List<String> superInterfacesYAMLO = classifierYAMLO.getMapStringListString(SUPER_INTERFACES);
- for(String superInterfaceYAMLO : superInterfacesYAMLO)
- {
+ for (String superInterfaceYAMLO : superInterfacesYAMLO) {
ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
superInterfaceOM.setName(superInterfaceYAMLO);
classifierOM.addInterface(superInterfaceOM);
}
}
- public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM)
- {
+ public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM) {
loadClassifier(classYAMLO, classOM);
String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
- if(abstractYAMLO == null)
- {
+ if (abstractYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
- for(String superClassYAMLO : superClassesYAMLO)
- {
+ for (String superClassYAMLO : superClassesYAMLO) {
ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
superClassOM.setName(superClassYAMLO);
classOM.addSuperclass(superClassOM);
}
}
- public void loadInterface(YamlObject interfaceYAMLO, ObjectModelInterfaceImpl interfaceOM)
- {
- loadClassifier(interfaceYAMLO,interfaceOM);
+ public void loadInterface(YamlObject interfaceYAMLO, ObjectModelInterfaceImpl interfaceOM) {
+ loadClassifier(interfaceYAMLO, interfaceOM);
}
- public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM)
- {
+ public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM) {
loadClass(associationClassYAML, associationClassOM);
//TODO: remplacer name par type et attribute par name ?
- for(YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT))
- {
+ for (YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT)) {
ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
participantOM.setAssociationClass(associationClassOM);
String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
participantOM.setName(nameYAMLO);
}
String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
- if(attributeYAMLO == null)
- {
+ if (attributeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
participantOM.setAttribute(attributeYAMLO);
}
@@ -291,248 +231,181 @@
}
}
- public void loadEnumeration(YamlObject enumerationYAMLO, ObjectModelEnumerationImpl enumerationOM)
- {
+ public void loadEnumeration(YamlObject enumerationYAMLO, ObjectModelEnumerationImpl enumerationOM) {
loadElement(enumerationYAMLO, enumerationOM);
//TODO: remplacer LITERAL par LITERALS (List)
List<String> literalsYAMLO = enumerationYAMLO.getMapStringListString(LITERAL);
- for(String literalYAMLO : literalsYAMLO)
- {
+ for (String literalYAMLO : literalsYAMLO) {
ObjectModelImplRef literalOM = new ObjectModelImplRef();
literalOM.setName(literalYAMLO);
enumerationOM.addLiteral(literalOM);
}
String packageYAMLO = enumerationYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ if (packageYAMLO == null) {
enumerationOM.setPackage(packageL);
- }
- else
- {
+ } else {
enumerationOM.setPackage(packageYAMLO);
}
}
- public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM)
- {
- loadElement(parameterYAMLO,parameterOM);
+ public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM) {
+ loadElement(parameterYAMLO, parameterOM);
String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
- if(orderingYAMLO == null)
- {
+ if (orderingYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setOrdering(orderingYAMLO);
}
String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
- if(typeYAMLO == null)
- {
+ if (typeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setType(typeYAMLO);
}
String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
- if(defaultValueYAMLO == null)
- {
+ if (defaultValueYAMLO == null) {
;//default
- }
- else
- {
+ } else {
parameterOM.setDefaultValue(defaultValueYAMLO);
}
String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
- if(minMultiplicityYAMLO == null)
- {
+ if (minMultiplicityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
}
String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
- if(maxMultiplicityYAMLO == null)
- {
+ if (maxMultiplicityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setMaxMultiplicity(Integer.valueOf(maxMultiplicityYAMLO));
}
String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
- if(orderedYAMLO == null)
- {
+ if (orderedYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
}
String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
- if(uniqueYAMLO == null)
- {
+ if (uniqueYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setUnique(Boolean.valueOf(uniqueYAMLO));
}
}
- public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM)
- {
- loadParameter(attributeYAMLO,attributeOM);
+ public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM) {
+ loadParameter(attributeYAMLO, attributeOM);
String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
- if(navigableYAMLO == null)
- {
+ if (navigableYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setNavigable(Boolean.valueOf(navigableYAMLO));
}
String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
- if(associationTypeYAMLO == null)
- {
+ if (associationTypeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setAssociationType(associationTypeYAMLO);
}
String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
- if(finalYAMLO == null)
- {
+ if (finalYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
}
String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
- if(staticYAMLO == null)
- {
+ if (staticYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
}
String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
- if(associationClassNameYAMLO == null)
- {
+ if (associationClassNameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setAssociationClassName(associationClassNameYAMLO);
}
String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
- if(reverseAttributeNameYAMLO == null)
- {
+ if (reverseAttributeNameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
}
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
- if(reverseMaxMultiplicityYAMLO == null)
- {
+ if (reverseMaxMultiplicityYAMLO == null) {
//test
attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
//test
- }
- else
- {
+ } else {
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
}
String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
- if(transientYAMLO == null)
- {
+ if (transientYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
}
String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
- if(visibilityYAMLO == null)
- {
+ if (visibilityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setVisibility(visibilityYAMLO);
}
}
- public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM)
- {
- loadElement(operationYAMLO,operationOM);
+ public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM) {
+ loadElement(operationYAMLO, operationOM);
String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
- if(abstractYAMLO == null)
- {
+ if (abstractYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
- if(visibilityYAMLO == null)
- {
+ if (visibilityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setVisibility(visibilityYAMLO);
}
- for(YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
- {
+ for (YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
ObjectModelParameterImpl returnParameterOM = new ObjectModelAttributeImpl();
- loadParameter(returnParameterYAMLO,returnParameterOM);
+ loadParameter(returnParameterYAMLO, returnParameterOM);
operationOM.setReturnParameter(returnParameterOM);
}
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
- {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
- loadParameter(parameterYAMLO,parameterOM);
+ loadParameter(parameterYAMLO, parameterOM);
operationOM.addParameter(parameterOM);
}
String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
- if(bodyCodeYAMLO == null)
- {
+ if (bodyCodeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setBodyCode(bodyCodeYAMLO);
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -19,13 +19,11 @@
public class LoadYamlFile extends KeyWords {
Yaml yaml;
- public LoadYamlFile()
- {
+ public LoadYamlFile() {
yaml = new Yaml();
}
- public void loadFile(File file, ObjectModel model) throws IOException
- {
+ public void loadFile(File file, ObjectModel model) throws IOException {
InputStream inputModel = new FileInputStream(file);
Object modelYAML = yaml.load(inputModel);
inputModel.close();
@@ -37,39 +35,30 @@
String syntaxeVersion = "0";
String defaultVersion = "0";
- if(modelYAML instanceof List)
- {
+ if (modelYAML instanceof List) {
version = YamlUtil.collectElementList((List) modelYAML, SYNTAXE);
syntaxeVersion = "1";
defaultVersion = "0";
- }
- else if(modelYAML instanceof Map)
- {
+ } else if (modelYAML instanceof Map) {
version = YamlUtil.collectElementMap((Map) modelYAML, SYNTAXE);
syntaxeVersion = "2";
defaultVersion = "0";
}
- if(version != null)
- {
- syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version),'.');
- defaultVersion = YamlUtil.afterChar(String.valueOf(version),'.');
+ if (version != null) {
+ syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version), '.');
+ defaultVersion = YamlUtil.afterChar(String.valueOf(version), '.');
}
- if(syntaxeVersion.equals("1"))
- {
- SyntaxePureYaml.loadYamlObject(modelYAML,modelYAMLO);
- }
- else if(syntaxeVersion.equals("2"))
- {
- SyntaxeUserFriendly.loadYamlObject(modelYAML,modelYAMLO);
- }
- else
- {
+ if (syntaxeVersion.equals("1")) {
+ SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
+ } else if (syntaxeVersion.equals("2")) {
+ SyntaxeUserFriendly.loadYamlObject(modelYAML, modelYAMLO);
+ } else {
;//impossible de charger le modele
}
- LoadObjectModel loader = new LoadObjectModel(modelYAMLO,modelOM);//+defaultVersion
+ LoadObjectModel loader = new LoadObjectModel(modelYAMLO, modelOM);//+defaultVersion
loader.loadModel();
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -15,7 +15,7 @@
/**
* principe : recuperer Object, retourner YamlObject et resoudre YamlObject
- *
+ * <p/>
* methode1 : syntaxe stricte, recuperer element en fonction de leur emplacement dans la liste et avec des contains ex: get(indexOf(truc)) ?
* methode2 : syntaxe moins restrictive, supprimer les élément et en déduir les restant
* methode3 : la methode3 (ninja hybride)
@@ -24,6 +24,7 @@
public class Parser extends KeyWords {
private static boolean _loginit = true;
+
private static void log(String str) {
try {
FileWriter log;
@@ -37,11 +38,12 @@
log = new FileWriter(path, true);
log.write("[LOG] " + str + "\n");
log.close();
- } catch (IOException e) {;}
+ } catch (IOException e) {
+ ;
+ }
}
- public Parser()
- {
+ public Parser() {
;
}
@@ -51,66 +53,50 @@
//retourner YAMLO ou modifier YAMLO ?
//charger class, interface, associationClass ou enumeration
//it work !
- public YamlObject parseModel(Object modelYAML, YamlObject modelYAMLO)
- {
- if(modelYAML instanceof Map)
- {
- for(Object entry : ((Map) modelYAML).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ public YamlObject parseModel(Object modelYAML, YamlObject modelYAMLO) {
+ if (modelYAML instanceof Map) {
+ for (Object entry : ((Map) modelYAML).entrySet()) {
+ if (entry instanceof Map.Entry) {
String key = String.valueOf(((Map.Entry) entry).getKey());
Object value = ((Map.Entry) entry).getValue();
//TODO: 1/ containsKey + remove & for() sur le reste
- if(key.equals(PACKAGE))
- {
- modelYAMLO.addStringToMap(PACKAGE,String.valueOf(value));
+ if (key.equals(PACKAGE)) {
+ modelYAMLO.addStringToMap(PACKAGE, String.valueOf(value));
}
- if(key.equals(NAME))
- {
- modelYAMLO.addStringToMap(NAME,String.valueOf(value));
+ if (key.equals(NAME)) {
+ modelYAMLO.addStringToMap(NAME, String.valueOf(value));
}
- if(key.equals(VERSION))
- {
- modelYAMLO.addStringToMap(VERSION,String.valueOf(value));
+ if (key.equals(VERSION)) {
+ modelYAMLO.addStringToMap(VERSION, String.valueOf(value));
}
- if(key.equals(IMPORTS))
- {
- if(value instanceof List)
- {
- for(Object imp : (List) value)
- {
- modelYAMLO.addStringToMap(IMPORTS,String.valueOf(imp));
+ if (key.equals(IMPORTS)) {
+ if (value instanceof List) {
+ for (Object imp : (List) value) {
+ modelYAMLO.addStringToMap(IMPORTS, String.valueOf(imp));
}
}
}
- List<String> tmp = YamlUtil.charParseIgnore(key,' ','<','>');
- if(tmp.contains(CLASS))
- { YamlObject classYAMLO = new YamlObject();
- parseClass(key,value,classYAMLO);
- modelYAMLO.addYamlObjectToMap(CLASS,classYAMLO);
- }
- else if(tmp.contains(INTERFACE))
- {
+ List<String> tmp = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (tmp.contains(CLASS)) {
+ YamlObject classYAMLO = new YamlObject();
+ parseClass(key, value, classYAMLO);
+ modelYAMLO.addYamlObjectToMap(CLASS, classYAMLO);
+ } else if (tmp.contains(INTERFACE)) {
YamlObject interfaceYAMLO = new YamlObject();
- parseInterface(key,value,interfaceYAMLO);
- modelYAMLO.addYamlObjectToMap(INTERFACE,interfaceYAMLO);
- }
- else if(tmp.contains(ASSOCIATION_CLASS))
- {
+ parseInterface(key, value, interfaceYAMLO);
+ modelYAMLO.addYamlObjectToMap(INTERFACE, interfaceYAMLO);
+ } else if (tmp.contains(ASSOCIATION_CLASS)) {
YamlObject associationClassYAMLO = new YamlObject();
- parseAssociationClass(key,value,associationClassYAMLO);
- modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS,associationClassYAMLO);
- }
- else if(tmp.contains(ENUMERATION))
- {
+ parseAssociationClass(key, value, associationClassYAMLO);
+ modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS, associationClassYAMLO);
+ } else if (tmp.contains(ENUMERATION)) {
YamlObject enumerationYAMLO = new YamlObject();
- parseEnumeration(key,value,enumerationYAMLO);
- modelYAMLO.addYamlObjectToMap(ENUMERATION,enumerationYAMLO);
+ parseEnumeration(key, value, enumerationYAMLO);
+ modelYAMLO.addYamlObjectToMap(ENUMERATION, enumerationYAMLO);
}
}
}
@@ -121,51 +107,39 @@
//name, abstract, static, stereotypes, extern inner, atribute, operation et super classes et super interfaces
public void parseClass(String key, Object value, YamlObject classYAMLO)//classYAMLO
{
- List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(classPARSE.contains(CLASS))
- {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (classPARSE.contains(CLASS)) {
classPARSE.remove(classPARSE.indexOf(CLASS));
}
- if(classPARSE.contains(ABSTRACT))
- {
- classYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ if (classPARSE.contains(ABSTRACT)) {
+ classYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(ABSTRACT));
}
- if(classPARSE.contains(STATIC))
- {
- classYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (classPARSE.contains(STATIC)) {
+ classYAMLO.addStringToMap(STATIC, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(STATIC));
}
- if(classPARSE.contains(EXTERN))
- {
- classYAMLO.addStringToMap(EXTERN,String.valueOf(true));
+ if (classPARSE.contains(EXTERN)) {
+ classYAMLO.addStringToMap(EXTERN, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(EXTERN));
}
- if(classPARSE.contains(INNER))
- {
- classYAMLO.addStringToMap(INNER,String.valueOf(true));
+ if (classPARSE.contains(INNER)) {
+ classYAMLO.addStringToMap(INNER, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(INNER));
}
- if(classPARSE.contains(PUBLIC))
- {
- classYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (classPARSE.contains(PUBLIC)) {
+ classYAMLO.addStringToMap(VISIBILITY, PUBLIC);
classPARSE.remove(classPARSE.indexOf(PUBLIC));
- }
- else if(classPARSE.contains(PRIVATE))
- {
- classYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (classPARSE.contains(PRIVATE)) {
+ classYAMLO.addStringToMap(VISIBILITY, PRIVATE);
classPARSE.remove(classPARSE.indexOf(PRIVATE));
- }
- else if(classPARSE.contains(PROTECTED))
- {
- classYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (classPARSE.contains(PROTECTED)) {
+ classYAMLO.addStringToMap(VISIBILITY, PROTECTED);
classPARSE.remove(classPARSE.indexOf(PROTECTED));
}
- for(String tmp1 : classPARSE)
- {
- if(tmp1.contains("<<") && tmp1.contains(">>"))
- {
+ for (String tmp1 : classPARSE) {
+ if (tmp1.contains("<<") && tmp1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -174,63 +148,47 @@
targets.add(' ');
targets.add(',');
List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
- for(String tmp4 : tmp3)
- {
- classYAMLO.addStringToMap(STEREOTYPES,tmp4);
- log("stereotype="+tmp4);
+ for (String tmp4 : tmp3) {
+ classYAMLO.addStringToMap(STEREOTYPES, tmp4);
+ log("stereotype=" + tmp4);
}
}
}
- if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ if (classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
{
- classYAMLO.addStringToMap(NAME,classPARSE.get(0));
- log("name="+classPARSE.get(0));
+ classYAMLO.addStringToMap(NAME, classPARSE.get(0));
+ log("name=" + classPARSE.get(0));
}
- if(value instanceof Map)
- {
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
//TODO: superClasses sur une ligne
- classYAMLO.addStringToMap(SUPER_CLASSES,String.valueOf(superClass));
+ classYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
//TODO: superInterfaces sur une ligne
- classYAMLO.addStringToMap(SUPER_INTERFACES,String.valueOf(superInterface));
+ classYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
- classYAMLO.addYamlObjectToMap(OPERATION,operationYAMLO);
- }
- else
- {
+ parseOperation(keyP, valueP, operationYAMLO);
+ classYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
- classYAMLO.addYamlObjectToMap(ATTRIBUTE,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
+ classYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
}
@@ -240,51 +198,39 @@
public void parseInterface(String key, Object value, YamlObject interfaceYAMLO)//enlever superflu
{
- List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(classPARSE.contains(INTERFACE))
- {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (classPARSE.contains(INTERFACE)) {
classPARSE.remove(classPARSE.indexOf(INTERFACE));
}
- if(classPARSE.contains(ABSTRACT))
- {
+ if (classPARSE.contains(ABSTRACT)) {
interfaceYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(ABSTRACT));
}
- if(classPARSE.contains(STATIC))
- {
+ if (classPARSE.contains(STATIC)) {
interfaceYAMLO.addStringToMap(STATIC, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(STATIC));
}
- if(classPARSE.contains(EXTERN))
- {
+ if (classPARSE.contains(EXTERN)) {
interfaceYAMLO.addStringToMap(EXTERN, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(EXTERN));
}
- if(classPARSE.contains(INNER))
- {
+ if (classPARSE.contains(INNER)) {
interfaceYAMLO.addStringToMap(INNER, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(INNER));
}
- if(classPARSE.contains(PUBLIC))
- {
+ if (classPARSE.contains(PUBLIC)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PUBLIC);
classPARSE.remove(classPARSE.indexOf(PUBLIC));
- }
- else if(classPARSE.contains(PRIVATE))
- {
+ } else if (classPARSE.contains(PRIVATE)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PRIVATE);
classPARSE.remove(classPARSE.indexOf(PRIVATE));
- }
- else if(classPARSE.contains(PROTECTED))
- {
+ } else if (classPARSE.contains(PROTECTED)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PROTECTED);
classPARSE.remove(classPARSE.indexOf(PROTECTED));
}
- for(String tmp1 : classPARSE)
- {
- if(tmp1.contains("<<") && tmp1.contains(">>"))
- {
+ for (String tmp1 : classPARSE) {
+ if (tmp1.contains("<<") && tmp1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -293,62 +239,46 @@
targets.add(' ');
targets.add(',');
List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
- for(String tmp4 : tmp3)
- {
+ for (String tmp4 : tmp3) {
interfaceYAMLO.addStringToMap(STEREOTYPES, tmp4);
- log("stereotype="+tmp4);
+ log("stereotype=" + tmp4);
}
}
}
- if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ if (classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
{
interfaceYAMLO.addStringToMap(NAME, classPARSE.get(0));
- log("name="+classPARSE.get(0));
+ log("name=" + classPARSE.get(0));
}
- if(value instanceof Map)
- {
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
//TODO: superClasses sur une ligne
interfaceYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
//TODO: superInterfaces sur une ligne
interfaceYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
+ parseOperation(keyP, valueP, operationYAMLO);
interfaceYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
- }
- else
- {
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
interfaceYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
@@ -365,51 +295,39 @@
/*
FACTORISER LE CODE !
*/
- List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(classPARSE.contains(ASSOCIATION_CLASS))
- {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (classPARSE.contains(ASSOCIATION_CLASS)) {
classPARSE.remove(classPARSE.indexOf(ASSOCIATION_CLASS));
}
- if(classPARSE.contains(ABSTRACT))
- {
+ if (classPARSE.contains(ABSTRACT)) {
associationClassYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(ABSTRACT));
}
- if(classPARSE.contains(STATIC))
- {
+ if (classPARSE.contains(STATIC)) {
associationClassYAMLO.addStringToMap(STATIC, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(STATIC));
}
- if(classPARSE.contains(EXTERN))
- {
+ if (classPARSE.contains(EXTERN)) {
associationClassYAMLO.addStringToMap(EXTERN, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(EXTERN));
}
- if(classPARSE.contains(INNER))
- {
+ if (classPARSE.contains(INNER)) {
associationClassYAMLO.addStringToMap(INNER, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(INNER));
}
- if(classPARSE.contains(PUBLIC))
- {
+ if (classPARSE.contains(PUBLIC)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PUBLIC);
classPARSE.remove(classPARSE.indexOf(PUBLIC));
- }
- else if(classPARSE.contains(PRIVATE))
- {
+ } else if (classPARSE.contains(PRIVATE)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PRIVATE);
classPARSE.remove(classPARSE.indexOf(PRIVATE));
- }
- else if(classPARSE.contains(PROTECTED))
- {
+ } else if (classPARSE.contains(PROTECTED)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PROTECTED);
classPARSE.remove(classPARSE.indexOf(PROTECTED));
}
- for(String tmp1 : classPARSE)
- {
- if(tmp1.contains("<<") && tmp1.contains(">>"))
- {
+ for (String tmp1 : classPARSE) {
+ if (tmp1.contains("<<") && tmp1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -418,52 +336,45 @@
targets.add(' ');
targets.add(',');
List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
- for(String tmp4 : tmp3)
- {
+ for (String tmp4 : tmp3) {
associationClassYAMLO.addStringToMap(STEREOTYPES, tmp4);
- log("stereotype="+tmp4);
+ log("stereotype=" + tmp4);
}
}
}
- if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ if (classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
{
associationClassYAMLO.addStringToMap(NAME, classPARSE.get(0));
- log("name="+classPARSE.get(0));
+ log("name=" + classPARSE.get(0));
}
//participant
- if(value instanceof Map)
- {
- if(((Map) value).containsKey(PARTICIPANT))
- {
- if(((Map) value).get(PARTICIPANT) instanceof Map)
- {
- for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ if (((Map) value).containsKey(PARTICIPANT)) {
+ if (((Map) value).get(PARTICIPANT) instanceof Map) {
+ for (Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet()) {
+ if (entry instanceof Map.Entry) {
//name attribute "value":
- List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
+ List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()), ' ');
YamlObject participantYAMLO = new YamlObject();
- if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
- {
- String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
+ if (participantPARSE.contains("\"" + YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey())) + "\"")) {
+ String label = YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey()));
- participantYAMLO.addStringToMap(LABEL,label);
+ participantYAMLO.addStringToMap(LABEL, label);
- participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
+ participantPARSE.remove("\"" + YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey())) + "\"");
}
- if(participantPARSE.size() > 0)//ajout type
+ if (participantPARSE.size() > 0)//ajout type
{
- participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
+ participantYAMLO.addStringToMap(NAME, participantPARSE.get(0));
}
- if(participantPARSE.size() > 1)//ajout name
+ if (participantPARSE.size() > 1)//ajout name
{
- participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
+ participantYAMLO.addStringToMap(ATTRIBUTE, participantPARSE.get(1));
}
- associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT, participantYAMLO);
/*YamlObject participantYAMLO = new YamlObject();
participantYAMLO.addStringToMap(NAME, String.valueOf(((Map.Entry) entry).getKey()));
@@ -480,49 +391,34 @@
}
//participant
- if(value instanceof Map)
- {
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
//TODO: superClasses sur une ligne
associationClassYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
//TODO: superInterfaces sur une ligne
associationClassYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
+ parseOperation(keyP, valueP, operationYAMLO);
associationClassYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
- }
- else
- {
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
associationClassYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
@@ -534,23 +430,18 @@
*/
}
- public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO)
- {
- List<String> enumerationPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(enumerationPARSE.contains(ENUMERATION))
- {
+ public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO) {
+ List<String> enumerationPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (enumerationPARSE.contains(ENUMERATION)) {
enumerationPARSE.remove(enumerationPARSE.indexOf(ENUMERATION));
}
- if(enumerationPARSE.contains(STATIC))
- {
- enumerationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (enumerationPARSE.contains(STATIC)) {
+ enumerationYAMLO.addStringToMap(STATIC, String.valueOf(true));
enumerationPARSE.remove(enumerationPARSE.indexOf(STATIC));
}
- for(String tmp1 : enumerationPARSE)
- {
- if(tmp1.contains("<<") && tmp1.contains(">>"))
- {
+ for (String tmp1 : enumerationPARSE) {
+ if (tmp1.contains("<<") && tmp1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -559,16 +450,15 @@
targets.add(' ');
targets.add(',');
List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
- for(String tmp4 : tmp3)
- {
- enumerationYAMLO.addStringToMap(STEREOTYPES,tmp4);
- log("stereotype="+tmp4);
+ for (String tmp4 : tmp3) {
+ enumerationYAMLO.addStringToMap(STEREOTYPES, tmp4);
+ log("stereotype=" + tmp4);
}
}
}
- if(enumerationPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ if (enumerationPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
{
- enumerationYAMLO.addStringToMap(NAME,enumerationPARSE.get(0));
+ enumerationYAMLO.addStringToMap(NAME, enumerationPARSE.get(0));
log("name=" + enumerationPARSE.get(0));
}
@@ -577,95 +467,74 @@
}
//~ok, fonctionnel
- public void parseAttribute(String key, Object value, YamlObject attributeYAMLO)
- {
+ public void parseAttribute(String key, Object value, YamlObject attributeYAMLO) {
//TODO: defaultValue, multiplicity, associationType, reverse(multiplicity & attributeName)
- List<String> attributePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- log("key="+key);
- log("keyPARSE="+attributePARSE);
- if(attributePARSE.contains(STATIC))
- {
- attributeYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ List<String> attributePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ log("key=" + key);
+ log("keyPARSE=" + attributePARSE);
+ if (attributePARSE.contains(STATIC)) {
+ attributeYAMLO.addStringToMap(STATIC, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(STATIC));
}
- if(attributePARSE.contains(FINAL))
- {
- attributeYAMLO.addStringToMap(FINAL,String.valueOf(true));
+ if (attributePARSE.contains(FINAL)) {
+ attributeYAMLO.addStringToMap(FINAL, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(FINAL));
}
- if(attributePARSE.contains(UNIQUE))
- {
- attributeYAMLO.addStringToMap(UNIQUE,String.valueOf(true));
+ if (attributePARSE.contains(UNIQUE)) {
+ attributeYAMLO.addStringToMap(UNIQUE, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(UNIQUE));
}
- if(attributePARSE.contains(NAVIGABLE))
- {
- attributeYAMLO.addStringToMap(NAVIGABLE,String.valueOf(true));
+ if (attributePARSE.contains(NAVIGABLE)) {
+ attributeYAMLO.addStringToMap(NAVIGABLE, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(NAVIGABLE));
}
- if(attributePARSE.contains(TRANSIENT))
- {
- attributeYAMLO.addStringToMap(TRANSIENT,String.valueOf(true));
+ if (attributePARSE.contains(TRANSIENT)) {
+ attributeYAMLO.addStringToMap(TRANSIENT, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(TRANSIENT));
}
- if(attributePARSE.contains(PUBLIC))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (attributePARSE.contains(PUBLIC)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PUBLIC);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
- }
- else if(attributePARSE.contains(PROTECTED))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (attributePARSE.contains(PROTECTED)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PROTECTED);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
- }
- else if(attributePARSE.contains(PRIVATE))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (attributePARSE.contains(PRIVATE)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PRIVATE);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
}
- if(attributePARSE.contains(ORDERED))
- {
- attributeYAMLO.addStringToMap(ORDERING,ORDERED);
+ if (attributePARSE.contains(ORDERED)) {
+ attributeYAMLO.addStringToMap(ORDERING, ORDERED);
attributePARSE.remove(attributePARSE.indexOf(ORDERED));
- }
- else if(attributePARSE.contains(UNORDERED))
- {
- attributeYAMLO.addStringToMap(ORDERING,UNORDERED);
+ } else if (attributePARSE.contains(UNORDERED)) {
+ attributeYAMLO.addStringToMap(ORDERING, UNORDERED);
attributePARSE.remove(attributePARSE.indexOf(UNORDERED));
}
- if(attributePARSE.contains("\""+YamlUtil.extract('"',key)+"\""))
- {
- String label = YamlUtil.extract('"',key);
- attributeYAMLO.addStringToMap(LABEL,label);
- attributePARSE.remove("\""+YamlUtil.extract('"',key)+"\"");
+ if (attributePARSE.contains("\"" + YamlUtil.extract('"', key) + "\"")) {
+ String label = YamlUtil.extract('"', key);
+ attributeYAMLO.addStringToMap(LABEL, label);
+ attributePARSE.remove("\"" + YamlUtil.extract('"', key) + "\"");
}
- if(attributePARSE.contains("["+YamlUtil.extract('[',']',key)+"]"))
- {
- String multiplicity = YamlUtil.extract('[',']',key);
- if(multiplicity.equals("*"))
- {
- attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,"0");
- attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,"-1");
- }
- else if(multiplicity.contains(".."))
- {
- String min = YamlUtil.beforeChar(multiplicity,'.');
+ if (attributePARSE.contains("[" + YamlUtil.extract('[', ']', key) + "]")) {
+ String multiplicity = YamlUtil.extract('[', ']', key);
+ if (multiplicity.equals("*")) {
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY, "0");
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY, "-1");
+ } else if (multiplicity.contains("..")) {
+ String min = YamlUtil.beforeChar(multiplicity, '.');
String max = YamlUtil.afterChar(multiplicity, '.');
- if(min.equals("*"))
- {
+ if (min.equals("*")) {
min = "-1";
}
- if(max.equals("*"))
- {
+ if (max.equals("*")) {
max = "-1";
}
- attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,min);
- attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,max);
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY, min);
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY, max);
}
- attributePARSE.remove("["+YamlUtil.extract('[',']',key)+"]");
+ attributePARSE.remove("[" + YamlUtil.extract('[', ']', key) + "]");
}
//extraire directement car pas de suppression
@@ -706,13 +575,13 @@
}
}*/
//name: type ?
- if(attributePARSE.size() > 0)//ajout type
+ if (attributePARSE.size() > 0)//ajout type
{
- attributeYAMLO.addStringToMap(TYPE,attributePARSE.get(0));
+ attributeYAMLO.addStringToMap(TYPE, attributePARSE.get(0));
}
- if(attributePARSE.size() > 1)//ajout name
+ if (attributePARSE.size() > 1)//ajout name
{
- attributeYAMLO.addStringToMap(NAME,attributePARSE.get(1));
+ attributeYAMLO.addStringToMap(NAME, attributePARSE.get(1));
}
/*if(value != null)//defaultValue
@@ -727,8 +596,7 @@
//OK, fonctionnel : yeah ninja flex
//TODO: return Parameter après les : (value) ? name: value
- public void parseOperation(String key, Object value, YamlObject operationYAMLO)
- {
+ public void parseOperation(String key, Object value, YamlObject operationYAMLO) {
log("operation=" + key);
List<Character> ignoreStart = new LinkedList<Character>();
ignoreStart.add('(');
@@ -736,44 +604,33 @@
List<Character> ignoreEnd = new LinkedList<Character>();
ignoreEnd.add(')');
ignoreEnd.add('>');
- List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key,' ',ignoreStart,ignoreEnd);
+ List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key, ' ', ignoreStart, ignoreEnd);
- if(operationPARSE.contains(STATIC))
- {
- operationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (operationPARSE.contains(STATIC)) {
+ operationYAMLO.addStringToMap(STATIC, String.valueOf(true));
operationPARSE.remove(operationPARSE.indexOf(STATIC));
}
- if(operationPARSE.contains(ABSTRACT))
- {
- operationYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ if (operationPARSE.contains(ABSTRACT)) {
+ operationYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
operationPARSE.remove(operationPARSE.indexOf(ABSTRACT));
}
- if(operationPARSE.contains(PUBLIC))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (operationPARSE.contains(PUBLIC)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PUBLIC);
operationPARSE.remove(operationPARSE.indexOf(PUBLIC));
- }
- else if(operationPARSE.contains(PROTECTED))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (operationPARSE.contains(PROTECTED)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PROTECTED);
operationPARSE.remove(operationPARSE.indexOf(PROTECTED));
- }
- else if(operationPARSE.contains(PRIVATE))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (operationPARSE.contains(PRIVATE)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PRIVATE);
operationPARSE.remove(operationPARSE.indexOf(PRIVATE));
}
- for(String tmp : operationPARSE)
- {
- if(tmp.contains("(") && tmp.contains(")"))
- {
- operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(tmp,'('));
- for(String tmp1 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', tmp), ',', '<', '>'))
- {
- List<String> tmp2 = YamlUtil.charParse(tmp1,' ');
- if(tmp2.size() == 2)
- {
+ for (String tmp : operationPARSE) {
+ if (tmp.contains("(") && tmp.contains(")")) {
+ operationYAMLO.addStringToMap(NAME, YamlUtil.beforeChar(tmp, '('));
+ for (String tmp1 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', tmp), ',', '<', '>')) {
+ List<String> tmp2 = YamlUtil.charParse(tmp1, ' ');
+ if (tmp2.size() == 2) {
YamlObject parameterYAMLO = new YamlObject();
parameterYAMLO.addStringToMap(TYPE, tmp2.get(0));
parameterYAMLO.addStringToMap(NAME, tmp2.get(1));
@@ -791,129 +648,98 @@
operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
}*/
- if(value != null)
- {
+ if (value != null) {
YamlObject returnParameterYAMLO = new YamlObject();
- returnParameterYAMLO.addStringToMap(TYPE,String.valueOf(value));
- operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+ returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);
}
}
- public static void resolveImports(YamlObject modelYAMLO)
- {
+ public static void resolveImports(YamlObject modelYAMLO) {
//List<String> imports = new LinkedList<String>();
- Map<String,String> imports = new LinkedHashMap<String, String>();
- if(modelYAMLO.containsKeyMapStringListString(IMPORTS))
- {
- for(String imp : modelYAMLO.getMapStringListString(IMPORTS))
- {
- imports.put(YamlUtil.afterChar(imp,'.'),imp);
+ Map<String, String> imports = new LinkedHashMap<String, String>();
+ if (modelYAMLO.containsKeyMapStringListString(IMPORTS)) {
+ for (String imp : modelYAMLO.getMapStringListString(IMPORTS)) {
+ imports.put(YamlUtil.afterChar(imp, '.'), imp);
}
}
//Objects importés: Attribute.Type SuperClasses SuperInterfaces AssociationClass.Participant.Name Parameter.Type(Operation(Class, AssociationClass(Classifier))
//recursivité pour Parameter et attribute ? Yeah
String packageM = null;
- if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
- {
+ if (modelYAMLO.containsKeyMapStringListString(PACKAGE)) {
packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
}
- for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
- {
- for(YamlObject importable : entry.getValue())
- {
- if(importable.containsKeyMapStringListString(NAME))
- {
+ for (Map.Entry<String, List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet()) {
+ for (YamlObject importable : entry.getValue()) {
+ if (importable.containsKeyMapStringListString(NAME)) {
String name = importable.getFirstMapStringListString(NAME);
- if(importable.containsKeyMapStringListString(PACKAGE))
- {
- imports.put(name,importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ if (importable.containsKeyMapStringListString(PACKAGE)) {
+ imports.put(name, importable.getFirstMapStringListString(PACKAGE) + "." + name);
+ } else if (packageM != null) {
+ imports.put(name, packageM + "." + name);
}
- else if(packageM != null)
- {
- imports.put(name,packageM+"."+name);
- }
}
}
}
- for(Map.Entry<String,String> imp : imports.entrySet())
- {
- log("import="+imp.getKey()+":"+imp.getValue());
+ for (Map.Entry<String, String> imp : imports.entrySet()) {
+ log("import=" + imp.getKey() + ":" + imp.getValue());
}
//remplacer types par imports complets
- for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
- {
- for(YamlObject importable : entry.getValue())
- {
- if(importable.containsKeyMapStringListString(SUPER_CLASSES))
- {
- for(String value : importable.getMapStringListString(SUPER_CLASSES))
- {
- if(imports.containsKey(value))
- {
- importable.setMapStringListString(SUPER_CLASSES,value,imports.get(value));
- log("imported="+value+":"+imports.get(value));
+ for (Map.Entry<String, List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet()) {
+ for (YamlObject importable : entry.getValue()) {
+ if (importable.containsKeyMapStringListString(SUPER_CLASSES)) {
+ for (String value : importable.getMapStringListString(SUPER_CLASSES)) {
+ if (imports.containsKey(value)) {
+ importable.setMapStringListString(SUPER_CLASSES, value, imports.get(value));
+ log("imported=" + value + ":" + imports.get(value));
}
}
}
- if(importable.containsKeyMapStringListString(SUPER_INTERFACES))
- {
- for(String value : importable.getMapStringListString(SUPER_INTERFACES))
- {
- if(imports.containsKey(value))
- {
- importable.setMapStringListString(SUPER_INTERFACES,value,imports.get(value));
- log("imported="+value+":"+imports.get(value));
+ if (importable.containsKeyMapStringListString(SUPER_INTERFACES)) {
+ for (String value : importable.getMapStringListString(SUPER_INTERFACES)) {
+ if (imports.containsKey(value)) {
+ importable.setMapStringListString(SUPER_INTERFACES, value, imports.get(value));
+ log("imported=" + value + ":" + imports.get(value));
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
+ if (importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
log(" contains attributes");
- for(YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE))
- {
+ for (YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE)) {
log(" browse attributes");
- if(attributeYAMLO.containsKeyMapStringListString(TYPE))
- {
+ if (attributeYAMLO.containsKeyMapStringListString(TYPE)) {
log(" contains type");
//if(imports.containsKey(attributeYAMLO.getFirstMapStringListString(TYPE)))
{
//attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(attributeYAMLO.getFirstMapStringListString(TYPE)),imports));
- attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(attributeYAMLO.getFirstMapStringListString(TYPE),imports));
+ attributeYAMLO.setMapStringListString(TYPE, attributeYAMLO.getFirstMapStringListString(TYPE), resolveType(attributeYAMLO.getFirstMapStringListString(TYPE), imports));
log("imported=" + attributeYAMLO.getFirstMapStringListString(TYPE) + ":" + imports.get(attributeYAMLO.getFirstMapStringListString(TYPE)));//retourne null car la clef vient juste d'etre modifiee
}
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(OPERATION))
- {
- for(YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION))
- {
- if(operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER))
- {
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
- {
- if(parameterYAMLO.containsKeyMapStringListString(TYPE))
- {
+ if (importable.containsKeyYamlMapStringListYamlObject(OPERATION)) {
+ for (YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION)) {
+ if (operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER)) {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
+ if (parameterYAMLO.containsKeyMapStringListString(TYPE)) {
//if(imports.containsKey(parameterYAMLO.getFirstMapStringListString(TYPE)))
{
//parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(parameterYAMLO.getFirstMapStringListString(TYPE)),imports));
- parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE),imports));
+ parameterYAMLO.setMapStringListString(TYPE, parameterYAMLO.getFirstMapStringListString(TYPE), resolveType(parameterYAMLO.getFirstMapStringListString(TYPE), imports));
}
}
}
}
- if(operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER))
- {
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
- {
- if(parameterYAMLO.containsKeyMapStringListString(TYPE))
- {
+ if (operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER)) {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
+ if (parameterYAMLO.containsKeyMapStringListString(TYPE)) {
//if(imports.containsKey(parameterYAMLO.getFirstMapStringListString(TYPE)))
{
//parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(parameterYAMLO.getFirstMapStringListString(TYPE)),imports));
- parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE),imports));
+ parameterYAMLO.setMapStringListString(TYPE, parameterYAMLO.getFirstMapStringListString(TYPE), resolveType(parameterYAMLO.getFirstMapStringListString(TYPE), imports));
}
}
@@ -921,16 +747,13 @@
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
- {
+ if (importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT)) {
log("0");
- for(YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT))
- {
+ for (YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT)) {
log("1");
- if(participantYAMLO.containsKeyMapStringListString(NAME))
- {
+ if (participantYAMLO.containsKeyMapStringListString(NAME)) {
log("2");
- participantYAMLO.setMapStringListString(NAME,participantYAMLO.getFirstMapStringListString(NAME),resolveType(participantYAMLO.getFirstMapStringListString(NAME),imports));
+ participantYAMLO.setMapStringListString(NAME, participantYAMLO.getFirstMapStringListString(NAME), resolveType(participantYAMLO.getFirstMapStringListString(NAME), imports));
}
}
}
@@ -939,86 +762,66 @@
}
//OK
- public static String browseType(String type, Map<String,String> imports)
- {
- StringBuilder res = new StringBuilder();
- boolean first = true;
- for(String tmp : YamlUtil.charParseIgnore(type,',','<','>'))
+ public static String browseType(String type, Map<String, String> imports) {
+ StringBuilder res = new StringBuilder();
+ boolean first = true;
+ for (String tmp : YamlUtil.charParseIgnore(type, ',', '<', '>')) {
+ if (first)//String || List<>
{
- if(first)//String || List<>
- {
- first = false;
+ first = false;
+ } else {
+ res.append(",");
+ }
+ if (tmp.contains("<") && tmp.contains(">")) {
+ String ninja = YamlUtil.beforeChar(tmp, '<');
+ if (imports.containsKey(ninja)) {
+ res.append(imports.get(ninja));
+ } else {
+ res.append(tmp);
}
- else
- {
- res.append(",");
+ res.append("<");
+ res.append(browseType(YamlUtil.extract('<', '>', tmp), imports));
+ res.append(">");
+ } else {
+ if (imports.containsKey(tmp)) {
+ res.append(imports.get(tmp));
+ } else {
+ res.append(tmp);
}
- if(tmp.contains("<") && tmp.contains(">"))
- {
- String ninja = YamlUtil.beforeChar(tmp,'<');
- if(imports.containsKey(ninja))
- {
- res.append(imports.get(ninja));
- }
- else
- {
- res.append(tmp);
- }
- res.append("<");
- res.append(browseType(YamlUtil.extract('<','>',tmp),imports));
- res.append(">");
- }
- else
- {
- if(imports.containsKey(tmp))
- {
- res.append(imports.get(tmp));
- }
- else
- {
- res.append(tmp);
- }
- }
}
- return res.toString();
+ }
+ return res.toString();
/*String ninja = YamlUtil.beforeChar(type,'<');
String flex = browseType(YamlUtil.extract('<','>',type),imports);
return ninja+flex;//gerer ',' multi parse fuck yeah*/
}
+
//OK
- public static String resolveType(String type, Map<String,String> imports)
- {
+ public static String resolveType(String type, Map<String, String> imports) {
List<Character> ignore = new LinkedList<Character>();
ignore.add(' ');
- String typePARSE = YamlUtil.removeMultiChar(type,ignore);
- return browseType(typePARSE,imports);
+ String typePARSE = YamlUtil.removeMultiChar(type, ignore);
+ return browseType(typePARSE, imports);
}
//recuperer toyus les attributs dans une seule liste au lieu d'aller les chercher a chaque fois
public static void resolveLabels(YamlObject modelYAMLO)//reverseAttribute + Labels
{
//test variable global
- Map<String,String> imports = new LinkedHashMap<String, String>();
+ Map<String, String> imports = new LinkedHashMap<String, String>();
String packageM = null;
- if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
- {
+ if (modelYAMLO.containsKeyMapStringListString(PACKAGE)) {
packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
}
- for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
- {
- for(YamlObject importable : entry.getValue())
- {
- if(importable.containsKeyMapStringListString(NAME))
- {
+ for (Map.Entry<String, List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet()) {
+ for (YamlObject importable : entry.getValue()) {
+ if (importable.containsKeyMapStringListString(NAME)) {
String name = importable.getFirstMapStringListString(NAME);
- if(importable.containsKeyMapStringListString(PACKAGE))
- {
- imports.put(name,importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ if (importable.containsKeyMapStringListString(PACKAGE)) {
+ imports.put(name, importable.getFirstMapStringListString(PACKAGE) + "." + name);
+ } else if (packageM != null) {
+ imports.put(name, packageM + "." + name);
}
- else if(packageM != null)
- {
- imports.put(name,packageM+"."+name);
- }
}
}
}
@@ -1027,25 +830,18 @@
List<String> importsI = new LinkedList<String>();
//String packageM = null;
- if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
- {
+ if (modelYAMLO.containsKeyMapStringListString(PACKAGE)) {
packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
}
- for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
- {
- for(YamlObject importable : entry.getValue())
- {
- if(importable.containsKeyMapStringListString(NAME))
- {
+ for (Map.Entry<String, List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet()) {
+ for (YamlObject importable : entry.getValue()) {
+ if (importable.containsKeyMapStringListString(NAME)) {
String name = importable.getFirstMapStringListString(NAME);
- if(importable.containsKeyMapStringListString(PACKAGE))
- {
- importsI.add(importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ if (importable.containsKeyMapStringListString(PACKAGE)) {
+ importsI.add(importable.getFirstMapStringListString(PACKAGE) + "." + name);
+ } else if (packageM != null) {
+ importsI.add(packageM + "." + name);
}
- else if(packageM != null)
- {
- importsI.add(packageM+"."+name);
- }
}
}
}
@@ -1055,89 +851,69 @@
//if label -> chercher reverse attribute
//else ajouter attribut navigable=false
//+ bricoler nom
- for(List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values())
- {
- for(YamlObject labelisable : objectYAMLO)
- {
- if(labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
- for(YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE))
- {
- if(attribute.containsKeyMapStringListString(TYPE))
- {
+ for (List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values()) {
+ for (YamlObject labelisable : objectYAMLO) {
+ if (labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
+ for (YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE)) {
+ if (attribute.containsKeyMapStringListString(TYPE)) {
String type = attribute.getFirstMapStringListString(TYPE);
- log("type="+type);
- if(importsI.contains(type))//refClassifier
+ log("type=" + type);
+ if (importsI.contains(type))//refClassifier
{
//pas encore passé par la//osef composite
- if(!attribute.containsKeyMapStringListString(NAVIGABLE))
- {
- if(attribute.containsKeyMapStringListString(LABEL))//bidirectionnel, recup reverse maxMultiplicity, reverseAttributeName et setNavigable(true)
+ if (!attribute.containsKeyMapStringListString(NAVIGABLE)) {
+ if (attribute.containsKeyMapStringListString(LABEL))//bidirectionnel, recup reverse maxMultiplicity, reverseAttributeName et setNavigable(true)
{
String label = attribute.getFirstMapStringListString(LABEL);
- log("label="+label);
- YamlObject reverseAttribute = getReverseAttribute(modelYAMLO,YamlUtil.afterChar(type,'.'),label);
- if(reverseAttribute != null)
- {
- attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
- reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(true));
- if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ log("label=" + label);
+ YamlObject reverseAttribute = getReverseAttribute(modelYAMLO, YamlUtil.afterChar(type, '.'), label);
+ if (reverseAttribute != null) {
+ attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
+ reverseAttribute.addStringToMap(NAVIGABLE, String.valueOf(true));
+ if (attribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ if (reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(attribute.containsKeyMapStringListString(NAME))
- {
- reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ if (attribute.containsKeyMapStringListString(NAME)) {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, attribute.getFirstMapStringListString(NAME));
}
- if(reverseAttribute.containsKeyMapStringListString(NAME))
- {
- attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,reverseAttribute.getFirstMapStringListString(NAME));
+ if (reverseAttribute.containsKeyMapStringListString(NAME)) {
+ attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, reverseAttribute.getFirstMapStringListString(NAME));
}
}
- }
- else//unidirectionnel
+ } else//unidirectionnel
{
log("unidirectionnel");
- YamlObject reverseObject = getReverseObject(modelYAMLO,YamlUtil.afterChar(type,'.'));
- if(reverseObject != null)
- {
+ YamlObject reverseObject = getReverseObject(modelYAMLO, YamlUtil.afterChar(type, '.'));
+ if (reverseObject != null) {
log("reverseObject != null");
YamlObject reverseAttribute = new YamlObject();
- reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(false));
- reverseAttribute.addStringToMap(TYPE,imports.get(labelisable.getFirstMapStringListString(NAME)));
- if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ reverseAttribute.addStringToMap(NAVIGABLE, String.valueOf(false));
+ reverseAttribute.addStringToMap(TYPE, imports.get(labelisable.getFirstMapStringListString(NAME)));
+ if (attribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(attribute.containsKeyMapStringListString(NAME))
- {
- reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ if (attribute.containsKeyMapStringListString(NAME)) {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, attribute.getFirstMapStringListString(NAME));
}
//test
- if(attribute.containsKeyMapStringListString(ORDERING))
- {
- if(attribute.getFirstMapStringListString(ORDERING).equals(ORDERED))
- {
- reverseAttribute.addStringToMap(ORDERING,UNORDERED);
+ if (attribute.containsKeyMapStringListString(ORDERING)) {
+ if (attribute.getFirstMapStringListString(ORDERING).equals(ORDERED)) {
+ reverseAttribute.addStringToMap(ORDERING, UNORDERED);
+ } else if (attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED)) {
+ reverseAttribute.addStringToMap(ORDERING, ORDERED);
}
- else if(attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED))
- {
- reverseAttribute.addStringToMap(ORDERING,ORDERED);
- }
}
//test
- reverseObject.addYamlObjectToMap(ATTRIBUTE,reverseAttribute);
+ reverseObject.addYamlObjectToMap(ATTRIBUTE, reverseAttribute);
- attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
}
}
}
- }
- else//simple attribut
+ } else//simple attribut
{
;//ou gerer par valeurs par defaut ?
//associationType="composite"//default eugene
@@ -1147,31 +923,25 @@
}
}
}
- if(labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
- {
+ if (labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT)) {
log("0");
- for(YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT))
- {
- if(participant.containsKeyMapStringListString(NAME))
- {
+ for (YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT)) {
+ if (participant.containsKeyMapStringListString(NAME)) {
log("1");
String name = participant.getFirstMapStringListString(NAME);
- if(importsI.contains(name))//refClassifier
+ if (importsI.contains(name))//refClassifier
{
log("2");
- if(participant.containsKeyMapStringListString(LABEL))
- {
+ if (participant.containsKeyMapStringListString(LABEL)) {
log("3");
String label = participant.getFirstMapStringListString(LABEL);
- YamlObject reverseAttribute = getReverseAttribute(modelYAMLO,YamlUtil.afterChar(name,'.'),label);
- if(reverseAttribute != null)
- {
+ YamlObject reverseAttribute = getReverseAttribute(modelYAMLO, YamlUtil.afterChar(name, '.'), label);
+ if (reverseAttribute != null) {
log("4");
- if(labelisable.containsKeyMapStringListString(NAME))
- {
+ if (labelisable.containsKeyMapStringListString(NAME)) {
log("5");
//tester package
- reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,modelYAMLO.getFirstMapStringListString(PACKAGE)+"."+labelisable.getFirstMapStringListString(NAME));
+ reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME, modelYAMLO.getFirstMapStringListString(PACKAGE) + "." + labelisable.getFirstMapStringListString(NAME));
}
}
}
@@ -1183,26 +953,17 @@
}
}
- public static YamlObject getReverseAttribute(YamlObject model, String type, String label)
- {
- for(List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values())
- {
- for(YamlObject objectYAMLO : objectsYAMLO)
- {
- if(objectYAMLO.containsKeyMapStringListString(NAME))
- {
+ public static YamlObject getReverseAttribute(YamlObject model, String type, String label) {
+ for (List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values()) {
+ for (YamlObject objectYAMLO : objectsYAMLO) {
+ if (objectYAMLO.containsKeyMapStringListString(NAME)) {
String name = objectYAMLO.getFirstMapStringListString(NAME);
- if(name.equals(type))
- {
- if(objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
- for(YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE))
- {
- if(attributeYAMLO.containsKeyMapStringListString(LABEL))
- {
+ if (name.equals(type)) {
+ if (objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
+ for (YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
+ if (attributeYAMLO.containsKeyMapStringListString(LABEL)) {
String reverseLabel = attributeYAMLO.getFirstMapStringListString(LABEL);
- if(reverseLabel.equals(label))
- {
+ if (reverseLabel.equals(label)) {
return attributeYAMLO;
}
}
@@ -1215,17 +976,12 @@
return null;
}
- public static YamlObject getReverseObject(YamlObject model, String type)
- {
- for(List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values())
- {
- for(YamlObject objectYAMLO : objectsYAMLO)
- {
- if(objectYAMLO.containsKeyMapStringListString(NAME))
- {
+ public static YamlObject getReverseObject(YamlObject model, String type) {
+ for (List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values()) {
+ for (YamlObject objectYAMLO : objectsYAMLO) {
+ if (objectYAMLO.containsKeyMapStringListString(NAME)) {
String name = objectYAMLO.getFirstMapStringListString(NAME);
- if(name.equals(type))
- {
+ if (name.equals(type)) {
return objectYAMLO;
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -10,27 +10,18 @@
*/
public class ParserPureYaml {
- public static void parseModel(Object modelYAML, YamlObject modelYAMLO)
- {
- if(modelYAML instanceof List)
- {
- for(Object tmp1 : (List) modelYAML)
- {
+ public static void parseModel(Object modelYAML, YamlObject modelYAMLO) {
+ if (modelYAML instanceof List) {
+ for (Object tmp1 : (List) modelYAML) {
parseModel(tmp1, modelYAMLO);
}
- }
- else if(modelYAML instanceof Map)
- {
- for(Object tmp1 : ((Map) modelYAML).entrySet())
- {
- if(((Map.Entry) tmp1).getValue() instanceof List || ((Map.Entry) tmp1).getValue() instanceof Map)
- {
+ } else if (modelYAML instanceof Map) {
+ for (Object tmp1 : ((Map) modelYAML).entrySet()) {
+ if (((Map.Entry) tmp1).getValue() instanceof List || ((Map.Entry) tmp1).getValue() instanceof Map) {
YamlObject tmp2 = new YamlObject();
- parseModel(((Map.Entry) tmp1).getValue(),tmp2);
+ parseModel(((Map.Entry) tmp1).getValue(), tmp2);
modelYAMLO.addYamlObjectToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(), tmp2);
- }
- else
- {
+ } else {
modelYAMLO.addStringToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(), String.valueOf(((Map.Entry) tmp1).getValue()));
}
}
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-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -11,15 +11,14 @@
* Time: 16:48
*/
public class ParserUserFriendly extends KeyWords {
- protected Map<String,String> imports;
- protected Map<String,String> importsI;
- protected Map<String,String> importsE;
+ protected Map<String, String> imports;
+ protected Map<String, String> importsI;
+ protected Map<String, String> importsE;
protected String packageM;
protected Object modelYAML;
protected YamlObject modelYAMLO;
- public ParserUserFriendly(Object modelYAML, YamlObject modelYAMLO)
- {
+ public ParserUserFriendly(Object modelYAML, YamlObject modelYAMLO) {
this.imports = new LinkedHashMap<String, String>();
this.importsI = new LinkedHashMap<String, String>();
this.importsE = new LinkedHashMap<String, String>();
@@ -28,120 +27,91 @@
this.modelYAMLO = modelYAMLO;
}
- public void parseModel()
- {
- if(modelYAML instanceof Map)
- {
- for(Object entry : ((Map) modelYAML).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ public void parseModel() {
+ if (modelYAML instanceof Map) {
+ for (Object entry : ((Map) modelYAML).entrySet()) {
+ if (entry instanceof Map.Entry) {
String key = String.valueOf(((Map.Entry) entry).getKey());
Object value = ((Map.Entry) entry).getValue();
- if(key.equals(PACKAGE))
- {
- modelYAMLO.addStringToMap(PACKAGE,String.valueOf(value));
- packageM = String.valueOf(value);
+ if (key.equals(PACKAGE)) {
+ modelYAMLO.addStringToMap(PACKAGE, String.valueOf(value));
+ packageM = String.valueOf(value);
}
- if(key.equals(NAME))
- {
- modelYAMLO.addStringToMap(NAME,String.valueOf(value));
+ if (key.equals(NAME)) {
+ modelYAMLO.addStringToMap(NAME, String.valueOf(value));
}
- if(key.equals(VERSION))
- {
- modelYAMLO.addStringToMap(VERSION,String.valueOf(value));
+ if (key.equals(VERSION)) {
+ modelYAMLO.addStringToMap(VERSION, String.valueOf(value));
}
- if(key.equals(IMPORTS))
- {
- if(value instanceof List)
- {
- for(Object imp : (List) value)
- {
+ if (key.equals(IMPORTS)) {
+ if (value instanceof List) {
+ for (Object imp : (List) value) {
//modelYAMLO.addStringToMap(IMPORTS,String.valueOf(imp));
- importsE.put(YamlUtil.afterChar(String.valueOf(imp),'.'),String.valueOf(imp));
+ importsE.put(YamlUtil.afterChar(String.valueOf(imp), '.'), String.valueOf(imp));
}
}
}
- List<String> tmp = YamlUtil.charParseIgnore(key,' ','<','>');
- if(tmp.contains(CLASS))
- { YamlObject classYAMLO = new YamlObject();
- parseClass(key,value,classYAMLO);
- modelYAMLO.addYamlObjectToMap(CLASS,classYAMLO);
- }
- else if(tmp.contains(INTERFACE))
- {
+ List<String> tmp = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (tmp.contains(CLASS)) {
+ YamlObject classYAMLO = new YamlObject();
+ parseClass(key, value, classYAMLO);
+ modelYAMLO.addYamlObjectToMap(CLASS, classYAMLO);
+ } else if (tmp.contains(INTERFACE)) {
YamlObject interfaceYAMLO = new YamlObject();
- parseInterface(key,value,interfaceYAMLO);
- modelYAMLO.addYamlObjectToMap(INTERFACE,interfaceYAMLO);
- }
- else if(tmp.contains(ASSOCIATION_CLASS))
- {
+ parseInterface(key, value, interfaceYAMLO);
+ modelYAMLO.addYamlObjectToMap(INTERFACE, interfaceYAMLO);
+ } else if (tmp.contains(ASSOCIATION_CLASS)) {
YamlObject associationClassYAMLO = new YamlObject();
- parseAssociationClass(key,value,associationClassYAMLO);
- modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS,associationClassYAMLO);
- }
- else if(tmp.contains(ENUMERATION))
- {
+ parseAssociationClass(key, value, associationClassYAMLO);
+ modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS, associationClassYAMLO);
+ } else if (tmp.contains(ENUMERATION)) {
YamlObject enumerationYAMLO = new YamlObject();
- parseEnumeration(key,value,enumerationYAMLO);
- modelYAMLO.addYamlObjectToMap(ENUMERATION,enumerationYAMLO);
+ parseEnumeration(key, value, enumerationYAMLO);
+ modelYAMLO.addYamlObjectToMap(ENUMERATION, enumerationYAMLO);
}
}
}
}
}
- public void parseClass(String key, Object value, YamlObject classYAMLO)
- {
- List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(classPARSE.contains(CLASS))
- {
+ public void parseClass(String key, Object value, YamlObject classYAMLO) {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (classPARSE.contains(CLASS)) {
classPARSE.remove(classPARSE.indexOf(CLASS));
}
- if(classPARSE.contains(ABSTRACT))
- {
- classYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ if (classPARSE.contains(ABSTRACT)) {
+ classYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(ABSTRACT));
}
- if(classPARSE.contains(STATIC))
- {
- classYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (classPARSE.contains(STATIC)) {
+ classYAMLO.addStringToMap(STATIC, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(STATIC));
}
- if(classPARSE.contains(EXTERN))
- {
- classYAMLO.addStringToMap(EXTERN,String.valueOf(true));
+ if (classPARSE.contains(EXTERN)) {
+ classYAMLO.addStringToMap(EXTERN, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(EXTERN));
}
- if(classPARSE.contains(INNER))
- {
- classYAMLO.addStringToMap(INNER,String.valueOf(true));
+ if (classPARSE.contains(INNER)) {
+ classYAMLO.addStringToMap(INNER, String.valueOf(true));
classPARSE.remove(classPARSE.indexOf(INNER));
}
- if(classPARSE.contains(PUBLIC))
- {
- classYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (classPARSE.contains(PUBLIC)) {
+ classYAMLO.addStringToMap(VISIBILITY, PUBLIC);
classPARSE.remove(classPARSE.indexOf(PUBLIC));
- }
- else if(classPARSE.contains(PRIVATE))
- {
- classYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (classPARSE.contains(PRIVATE)) {
+ classYAMLO.addStringToMap(VISIBILITY, PRIVATE);
classPARSE.remove(classPARSE.indexOf(PRIVATE));
- }
- else if(classPARSE.contains(PROTECTED))
- {
- classYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (classPARSE.contains(PROTECTED)) {
+ classYAMLO.addStringToMap(VISIBILITY, PROTECTED);
classPARSE.remove(classPARSE.indexOf(PROTECTED));
}
- for(String str1 : classPARSE)
- {
- if(str1.contains("<<") && str1.contains(">>"))
- {
+ for (String str1 : classPARSE) {
+ if (str1.contains("<<") && str1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -150,62 +120,45 @@
targets.add(' ');
targets.add(',');
List<String> list = YamlUtil.multiCharParse(str2, targets);
- for(String str3 : list)
- {
+ for (String str3 : list) {
classYAMLO.addStringToMap(STEREOTYPES, str3);
}
}
}
- if(classPARSE.size() > 0)
- {
+ if (classPARSE.size() > 0) {
String name = classPARSE.get(0);
classYAMLO.addStringToMap(NAME, name);
- importsI.put(name,packageM+"."+name);
+ importsI.put(name, packageM + "." + name);
}
- if(value instanceof Map)
- {
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
- classYAMLO.addStringToMap(SUPER_CLASSES,String.valueOf(superClass));
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
+ classYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
- classYAMLO.addStringToMap(SUPER_INTERFACES,String.valueOf(superInterface));
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
+ classYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
- classYAMLO.addYamlObjectToMap(OPERATION,operationYAMLO);
- }
- else
- {
+ parseOperation(keyP, valueP, operationYAMLO);
+ classYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
- classYAMLO.addYamlObjectToMap(ATTRIBUTE,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
+ classYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
}
@@ -214,53 +167,40 @@
}
//TODO: factoriser le code (classifier)
- public void parseInterface(String key, Object value, YamlObject interfaceYAMLO)
- {
- List<String> interfacePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(interfacePARSE.contains(INTERFACE))
- {
+ public void parseInterface(String key, Object value, YamlObject interfaceYAMLO) {
+ List<String> interfacePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (interfacePARSE.contains(INTERFACE)) {
interfacePARSE.remove(interfacePARSE.indexOf(INTERFACE));
}
- if(interfacePARSE.contains(ABSTRACT))
- {
+ if (interfacePARSE.contains(ABSTRACT)) {
interfaceYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
interfacePARSE.remove(interfacePARSE.indexOf(ABSTRACT));
}
- if(interfacePARSE.contains(STATIC))
- {
+ if (interfacePARSE.contains(STATIC)) {
interfaceYAMLO.addStringToMap(STATIC, String.valueOf(true));
interfacePARSE.remove(interfacePARSE.indexOf(STATIC));
}
- if(interfacePARSE.contains(EXTERN))
- {
+ if (interfacePARSE.contains(EXTERN)) {
interfaceYAMLO.addStringToMap(EXTERN, String.valueOf(true));
interfacePARSE.remove(interfacePARSE.indexOf(EXTERN));
}
- if(interfacePARSE.contains(INNER))
- {
+ if (interfacePARSE.contains(INNER)) {
interfaceYAMLO.addStringToMap(INNER, String.valueOf(true));
interfacePARSE.remove(interfacePARSE.indexOf(INNER));
}
- if(interfacePARSE.contains(PUBLIC))
- {
+ if (interfacePARSE.contains(PUBLIC)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PUBLIC);
interfacePARSE.remove(interfacePARSE.indexOf(PUBLIC));
- }
- else if(interfacePARSE.contains(PRIVATE))
- {
+ } else if (interfacePARSE.contains(PRIVATE)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PRIVATE);
interfacePARSE.remove(interfacePARSE.indexOf(PRIVATE));
- }
- else if(interfacePARSE.contains(PROTECTED))
- {
+ } else if (interfacePARSE.contains(PROTECTED)) {
interfaceYAMLO.addStringToMap(VISIBILITY, PROTECTED);
interfacePARSE.remove(interfacePARSE.indexOf(PROTECTED));
}
- for(String str1 : interfacePARSE)
- {
- if(str1.contains("<<") && str1.contains(">>"))
- {
+ for (String str1 : interfacePARSE) {
+ if (str1.contains("<<") && str1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -269,61 +209,44 @@
targets.add(' ');
targets.add(',');
List<String> list = YamlUtil.multiCharParse(str2, targets);
- for(String str3 : list)
- {
+ for (String str3 : list) {
interfaceYAMLO.addStringToMap(STEREOTYPES, str3);
}
}
}
- if(interfacePARSE.size() > 0)
- {
+ if (interfacePARSE.size() > 0) {
String name = interfacePARSE.get(0);
interfaceYAMLO.addStringToMap(NAME, name);
- importsI.put(name,packageM+"."+name);
+ importsI.put(name, packageM + "." + name);
}
- if(value instanceof Map)
- {
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ if (value instanceof Map) {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
interfaceYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
interfaceYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
+ parseOperation(keyP, valueP, operationYAMLO);
interfaceYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
- }
- else
- {
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
interfaceYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
@@ -332,53 +255,40 @@
}
}
- public void parseAssociationClass(String key, Object value, YamlObject associationClassYAMLO)
- {
- List<String> associationClassPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(associationClassPARSE.contains(ASSOCIATION_CLASS))
- {
+ public void parseAssociationClass(String key, Object value, YamlObject associationClassYAMLO) {
+ List<String> associationClassPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (associationClassPARSE.contains(ASSOCIATION_CLASS)) {
associationClassPARSE.remove(associationClassPARSE.indexOf(ASSOCIATION_CLASS));
}
- if(associationClassPARSE.contains(ABSTRACT))
- {
+ if (associationClassPARSE.contains(ABSTRACT)) {
associationClassYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
associationClassPARSE.remove(associationClassPARSE.indexOf(ABSTRACT));
}
- if(associationClassPARSE.contains(STATIC))
- {
+ if (associationClassPARSE.contains(STATIC)) {
associationClassYAMLO.addStringToMap(STATIC, String.valueOf(true));
associationClassPARSE.remove(associationClassPARSE.indexOf(STATIC));
}
- if(associationClassPARSE.contains(EXTERN))
- {
+ if (associationClassPARSE.contains(EXTERN)) {
associationClassYAMLO.addStringToMap(EXTERN, String.valueOf(true));
associationClassPARSE.remove(associationClassPARSE.indexOf(EXTERN));
}
- if(associationClassPARSE.contains(INNER))
- {
+ if (associationClassPARSE.contains(INNER)) {
associationClassYAMLO.addStringToMap(INNER, String.valueOf(true));
associationClassPARSE.remove(associationClassPARSE.indexOf(INNER));
}
- if(associationClassPARSE.contains(PUBLIC))
- {
+ if (associationClassPARSE.contains(PUBLIC)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PUBLIC);
associationClassPARSE.remove(associationClassPARSE.indexOf(PUBLIC));
- }
- else if(associationClassPARSE.contains(PRIVATE))
- {
+ } else if (associationClassPARSE.contains(PRIVATE)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PRIVATE);
associationClassPARSE.remove(associationClassPARSE.indexOf(PRIVATE));
- }
- else if(associationClassPARSE.contains(PROTECTED))
- {
+ } else if (associationClassPARSE.contains(PROTECTED)) {
associationClassYAMLO.addStringToMap(VISIBILITY, PROTECTED);
associationClassPARSE.remove(associationClassPARSE.indexOf(PROTECTED));
}
- for(String str1 : associationClassPARSE)
- {
- if(str1.contains("<<") && str1.contains(">>"))
- {
+ for (String str1 : associationClassPARSE) {
+ if (str1.contains("<<") && str1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -387,96 +297,74 @@
targets.add(' ');
targets.add(',');
List<String> list = YamlUtil.multiCharParse(str2, targets);
- for(String str3 : list)
- {
+ for (String str3 : list) {
associationClassYAMLO.addStringToMap(STEREOTYPES, str3);
}
}
}
- if(associationClassPARSE.size() > 0)
- {
+ if (associationClassPARSE.size() > 0) {
String name = associationClassPARSE.get(0);
associationClassYAMLO.addStringToMap(NAME, name);
- importsI.put(name,packageM+"."+name);
+ importsI.put(name, packageM + "." + name);
}
- if(value instanceof Map)
- {
+ if (value instanceof Map) {
//TODO: utiliser variable locales pour plus de clartee
- if(((Map) value).containsKey(PARTICIPANT))
- {
- if(((Map) value).get(PARTICIPANT) instanceof Map)
- {
- for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
- List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
+ if (((Map) value).containsKey(PARTICIPANT)) {
+ if (((Map) value).get(PARTICIPANT) instanceof Map) {
+ for (Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet()) {
+ if (entry instanceof Map.Entry) {
+ List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()), ' ');
YamlObject participantYAMLO = new YamlObject();
- if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
- {
- String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
+ if (participantPARSE.contains("\"" + YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey())) + "\"")) {
+ String label = YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey()));
- participantYAMLO.addStringToMap(LABEL,label);
+ participantYAMLO.addStringToMap(LABEL, label);
- participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
+ participantPARSE.remove("\"" + YamlUtil.extract('"', String.valueOf(((Map.Entry) entry).getKey())) + "\"");
}
- if(participantPARSE.size() > 0)//ajout type
+ if (participantPARSE.size() > 0)//ajout type
{
- participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
+ participantYAMLO.addStringToMap(NAME, participantPARSE.get(0));
}
- if(participantPARSE.size() > 1)//ajout name
+ if (participantPARSE.size() > 1)//ajout name
{
- participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
+ participantYAMLO.addStringToMap(ATTRIBUTE, participantPARSE.get(1));
}
- associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT, participantYAMLO);
}
}
}
((Map) value).remove(PARTICIPANT);
}
- for(Object entry : ((Map) value).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
+ for (Object entry : ((Map) value).entrySet()) {
+ if (entry instanceof Map.Entry) {
String keyP = String.valueOf(((Map.Entry) entry).getKey());
Object valueP = ((Map.Entry) entry).getValue();
- if(keyP.equals(SUPER_CLASSES))
- {
- if(valueP instanceof List)
- {
- for(Object superClass : (List) valueP)
- {
+ if (keyP.equals(SUPER_CLASSES)) {
+ if (valueP instanceof List) {
+ for (Object superClass : (List) valueP) {
associationClassYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
}
}
- }
- else if(keyP.equals(SUPER_INTERFACES))
- {
- if(valueP instanceof List)
- {
- for(Object superInterface : (List) valueP)
- {
+ } else if (keyP.equals(SUPER_INTERFACES)) {
+ if (valueP instanceof List) {
+ for (Object superInterface : (List) valueP) {
associationClassYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
}
}
- }
- else
- {
- if(keyP.contains("(") && keyP.contains(")"))
- {
+ } else {
+ if (keyP.contains("(") && keyP.contains(")")) {
YamlObject operationYAMLO = new YamlObject();
- parseOperation(keyP,valueP,operationYAMLO);
+ parseOperation(keyP, valueP, operationYAMLO);
associationClassYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
- }
- else
- {
+ } else {
YamlObject attributeYAMLO = new YamlObject();
- parseAttribute(keyP,valueP,attributeYAMLO);
+ parseAttribute(keyP, valueP, attributeYAMLO);
associationClassYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
}
}
@@ -485,23 +373,18 @@
}
}
- public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO)
- {
- List<String> enumerationPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(enumerationPARSE.contains(ENUMERATION))
- {
+ public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO) {
+ List<String> enumerationPARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (enumerationPARSE.contains(ENUMERATION)) {
enumerationPARSE.remove(enumerationPARSE.indexOf(ENUMERATION));
}
- if(enumerationPARSE.contains(STATIC))
- {
- enumerationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (enumerationPARSE.contains(STATIC)) {
+ enumerationYAMLO.addStringToMap(STATIC, String.valueOf(true));
enumerationPARSE.remove(enumerationPARSE.indexOf(STATIC));
}
- for(String str1 : enumerationPARSE)
- {
- if(str1.contains("<<") && str1.contains(">>"))
- {
+ for (String str1 : enumerationPARSE) {
+ if (str1.contains("<<") && str1.contains(">>")) {
List<Character> targets = new LinkedList<Character>();
targets.add('<');
targets.add('>');
@@ -510,17 +393,15 @@
targets.add(' ');
targets.add(',');
List<String> list = YamlUtil.multiCharParse(str2, targets);
- for(String str3 : list)
- {
+ for (String str3 : list) {
enumerationYAMLO.addStringToMap(STEREOTYPES, str3);
}
}
}
- if(enumerationPARSE.size() > 0)
- {
+ if (enumerationPARSE.size() > 0) {
String name = enumerationPARSE.get(0);
enumerationYAMLO.addStringToMap(NAME, name);
- importsI.put(name,packageM+"."+name);
+ importsI.put(name, packageM + "." + name);
}
//TODO: parser literals
}
@@ -531,151 +412,116 @@
;
}*/
- public void parseAttribute(String key, Object value, YamlObject attributeYAMLO)
- {
- List<String> attributePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
- if(attributePARSE.contains(STATIC))
- {
- attributeYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ public void parseAttribute(String key, Object value, YamlObject attributeYAMLO) {
+ List<String> attributePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (attributePARSE.contains(STATIC)) {
+ attributeYAMLO.addStringToMap(STATIC, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(STATIC));
}
- if(attributePARSE.contains(FINAL))
- {
- attributeYAMLO.addStringToMap(FINAL,String.valueOf(true));
+ if (attributePARSE.contains(FINAL)) {
+ attributeYAMLO.addStringToMap(FINAL, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(FINAL));
}
- if(attributePARSE.contains(UNIQUE))
- {
- attributeYAMLO.addStringToMap(UNIQUE,String.valueOf(true));
+ if (attributePARSE.contains(UNIQUE)) {
+ attributeYAMLO.addStringToMap(UNIQUE, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(UNIQUE));
}
- if(attributePARSE.contains(NAVIGABLE))
- {
- attributeYAMLO.addStringToMap(NAVIGABLE,String.valueOf(true));
+ if (attributePARSE.contains(NAVIGABLE)) {
+ attributeYAMLO.addStringToMap(NAVIGABLE, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(NAVIGABLE));
}
- if(attributePARSE.contains(TRANSIENT))
- {
- attributeYAMLO.addStringToMap(TRANSIENT,String.valueOf(true));
+ if (attributePARSE.contains(TRANSIENT)) {
+ attributeYAMLO.addStringToMap(TRANSIENT, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(TRANSIENT));
}
- if(attributePARSE.contains(PUBLIC))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (attributePARSE.contains(PUBLIC)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PUBLIC);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
- }
- else if(attributePARSE.contains(PROTECTED))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (attributePARSE.contains(PROTECTED)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PROTECTED);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
- }
- else if(attributePARSE.contains(PRIVATE))
- {
- attributeYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (attributePARSE.contains(PRIVATE)) {
+ attributeYAMLO.addStringToMap(VISIBILITY, PRIVATE);
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
}
- if(attributePARSE.contains(ORDERED))
- {
- attributeYAMLO.addStringToMap(ORDERING,ORDERED);
+ if (attributePARSE.contains(ORDERED)) {
+ attributeYAMLO.addStringToMap(ORDERING, ORDERED);
attributePARSE.remove(attributePARSE.indexOf(ORDERED));
- }
- else if(attributePARSE.contains(UNORDERED))
- {
- attributeYAMLO.addStringToMap(ORDERING,UNORDERED);
+ } else if (attributePARSE.contains(UNORDERED)) {
+ attributeYAMLO.addStringToMap(ORDERING, UNORDERED);
attributePARSE.remove(attributePARSE.indexOf(UNORDERED));
}
//TODO: utiliser variables locales
- if(attributePARSE.contains("\""+YamlUtil.extract('"',key)+"\""))
- {
- String label = YamlUtil.extract('"',key);
- attributeYAMLO.addStringToMap(LABEL,label);
- attributePARSE.remove("\""+YamlUtil.extract('"',key)+"\"");
+ if (attributePARSE.contains("\"" + YamlUtil.extract('"', key) + "\"")) {
+ String label = YamlUtil.extract('"', key);
+ attributeYAMLO.addStringToMap(LABEL, label);
+ attributePARSE.remove("\"" + YamlUtil.extract('"', key) + "\"");
}
- if(attributePARSE.contains("["+YamlUtil.extract('[',']',key)+"]"))
- {
- String multiplicity = YamlUtil.extract('[',']',key);
- if(multiplicity.equals("*"))
- {
- attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,"0");
- attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,"-1");
- }
- else if(multiplicity.contains(".."))
- {
- String min = YamlUtil.beforeChar(multiplicity,'.');
+ if (attributePARSE.contains("[" + YamlUtil.extract('[', ']', key) + "]")) {
+ String multiplicity = YamlUtil.extract('[', ']', key);
+ if (multiplicity.equals("*")) {
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY, "0");
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY, "-1");
+ } else if (multiplicity.contains("..")) {
+ String min = YamlUtil.beforeChar(multiplicity, '.');
String max = YamlUtil.afterChar(multiplicity, '.');
- if(min.equals("*"))
- {
+ if (min.equals("*")) {
min = "-1";
}
- if(max.equals("*"))
- {
+ if (max.equals("*")) {
max = "-1";
}
- attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,min);
- attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,max);
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY, min);
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY, max);
}
- attributePARSE.remove("["+YamlUtil.extract('[',']',key)+"]");
+ attributePARSE.remove("[" + YamlUtil.extract('[', ']', key) + "]");
}
- if(attributePARSE.size() > 0)
- {
- attributeYAMLO.addStringToMap(TYPE,attributePARSE.get(0));
+ if (attributePARSE.size() > 0) {
+ attributeYAMLO.addStringToMap(TYPE, attributePARSE.get(0));
}
- if(attributePARSE.size() > 1)
- {
- attributeYAMLO.addStringToMap(NAME,attributePARSE.get(1));
+ if (attributePARSE.size() > 1) {
+ attributeYAMLO.addStringToMap(NAME, attributePARSE.get(1));
}
}
- public void parseOperation(String key, Object value, YamlObject operationYAMLO)
- {
+ public void parseOperation(String key, Object value, YamlObject operationYAMLO) {
List<Character> ignoreStart = new LinkedList<Character>();
ignoreStart.add('(');
ignoreStart.add('<');
List<Character> ignoreEnd = new LinkedList<Character>();
ignoreEnd.add(')');
ignoreEnd.add('>');
- List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key,' ',ignoreStart,ignoreEnd);
+ List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key, ' ', ignoreStart, ignoreEnd);
- if(operationPARSE.contains(STATIC))
- {
- operationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ if (operationPARSE.contains(STATIC)) {
+ operationYAMLO.addStringToMap(STATIC, String.valueOf(true));
operationPARSE.remove(operationPARSE.indexOf(STATIC));
}
- if(operationPARSE.contains(ABSTRACT))
- {
- operationYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ if (operationPARSE.contains(ABSTRACT)) {
+ operationYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
operationPARSE.remove(operationPARSE.indexOf(ABSTRACT));
}
- if(operationPARSE.contains(PUBLIC))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ if (operationPARSE.contains(PUBLIC)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PUBLIC);
operationPARSE.remove(operationPARSE.indexOf(PUBLIC));
- }
- else if(operationPARSE.contains(PROTECTED))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ } else if (operationPARSE.contains(PROTECTED)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PROTECTED);
operationPARSE.remove(operationPARSE.indexOf(PROTECTED));
- }
- else if(operationPARSE.contains(PRIVATE))
- {
- operationYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ } else if (operationPARSE.contains(PRIVATE)) {
+ operationYAMLO.addStringToMap(VISIBILITY, PRIVATE);
operationPARSE.remove(operationPARSE.indexOf(PRIVATE));
}
- for(String str1 : operationPARSE)
- {
- if(str1.contains("(") && str1.contains(")"))
- {
- operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(str1,'('));
- for(String str2 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', str1), ',', '<', '>'))
- {
- List<String> list = YamlUtil.charParse(str2,' ');
- if(list.size() == 2)
- {
+ for (String str1 : operationPARSE) {
+ if (str1.contains("(") && str1.contains(")")) {
+ operationYAMLO.addStringToMap(NAME, YamlUtil.beforeChar(str1, '('));
+ for (String str2 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', str1), ',', '<', '>')) {
+ List<String> list = YamlUtil.charParse(str2, ' ');
+ if (list.size() == 2) {
YamlObject parameterYAMLO = new YamlObject();
parameterYAMLO.addStringToMap(TYPE, list.get(0));
parameterYAMLO.addStringToMap(NAME, list.get(1));
@@ -685,85 +531,61 @@
}
}
- if(value != null)
- {
+ if (value != null) {
YamlObject returnParameterYAMLO = new YamlObject();
- returnParameterYAMLO.addStringToMap(TYPE,String.valueOf(value));
- operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+ returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);
}
}
- public void resolveImports()
- {
+ public void resolveImports() {
imports.putAll(importsE);
imports.putAll(importsI);
- for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
- {
- for(YamlObject importable : entry.getValue())
- {
- if(importable.containsKeyMapStringListString(SUPER_CLASSES))
- {
- for(String value : importable.getMapStringListString(SUPER_CLASSES))
- {
- if(imports.containsKey(value))
- {
- importable.setMapStringListString(SUPER_CLASSES,value,imports.get(value));
+ for (Map.Entry<String, List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet()) {
+ for (YamlObject importable : entry.getValue()) {
+ if (importable.containsKeyMapStringListString(SUPER_CLASSES)) {
+ for (String value : importable.getMapStringListString(SUPER_CLASSES)) {
+ if (imports.containsKey(value)) {
+ importable.setMapStringListString(SUPER_CLASSES, value, imports.get(value));
}
}
}
- if(importable.containsKeyMapStringListString(SUPER_INTERFACES))
- {
- for(String value : importable.getMapStringListString(SUPER_INTERFACES))
- {
- if(imports.containsKey(value))
- {
- importable.setMapStringListString(SUPER_INTERFACES,value,imports.get(value));
+ if (importable.containsKeyMapStringListString(SUPER_INTERFACES)) {
+ for (String value : importable.getMapStringListString(SUPER_INTERFACES)) {
+ if (imports.containsKey(value)) {
+ importable.setMapStringListString(SUPER_INTERFACES, value, imports.get(value));
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
- for(YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE))
- {
- if(attributeYAMLO.containsKeyMapStringListString(TYPE))
- {
- attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(attributeYAMLO.getFirstMapStringListString(TYPE)));
+ if (importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
+ for (YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE)) {
+ if (attributeYAMLO.containsKeyMapStringListString(TYPE)) {
+ attributeYAMLO.setMapStringListString(TYPE, attributeYAMLO.getFirstMapStringListString(TYPE), resolveType(attributeYAMLO.getFirstMapStringListString(TYPE)));
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(OPERATION))
- {
- for(YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION))
- {
- if(operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER))
- {
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
- {
- if(parameterYAMLO.containsKeyMapStringListString(TYPE))
- {
- parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
+ if (importable.containsKeyYamlMapStringListYamlObject(OPERATION)) {
+ for (YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION)) {
+ if (operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER)) {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
+ if (parameterYAMLO.containsKeyMapStringListString(TYPE)) {
+ parameterYAMLO.setMapStringListString(TYPE, parameterYAMLO.getFirstMapStringListString(TYPE), resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
}
}
}
- if(operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER))
- {
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
- {
- if(parameterYAMLO.containsKeyMapStringListString(TYPE))
- {
- parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
+ if (operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER)) {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
+ if (parameterYAMLO.containsKeyMapStringListString(TYPE)) {
+ parameterYAMLO.setMapStringListString(TYPE, parameterYAMLO.getFirstMapStringListString(TYPE), resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
}
}
}
}
}
- if(importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
- {
- for(YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT))
- {
- if(participantYAMLO.containsKeyMapStringListString(NAME))
- {
- participantYAMLO.setMapStringListString(NAME,participantYAMLO.getFirstMapStringListString(NAME),resolveType(participantYAMLO.getFirstMapStringListString(NAME)));
+ if (importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT)) {
+ for (YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT)) {
+ if (participantYAMLO.containsKeyMapStringListString(NAME)) {
+ participantYAMLO.setMapStringListString(NAME, participantYAMLO.getFirstMapStringListString(NAME), resolveType(participantYAMLO.getFirstMapStringListString(NAME)));
}
}
}
@@ -771,43 +593,29 @@
}
}
- public String browseType(String type)
- {
- StringBuilder res = new StringBuilder();
+ public String browseType(String type) {
+ StringBuilder res = new StringBuilder();
boolean first = true;
- for(String tmp : YamlUtil.charParseIgnore(type,',','<','>'))
- {
- if(first)
- {
+ for (String tmp : YamlUtil.charParseIgnore(type, ',', '<', '>')) {
+ if (first) {
first = false;
- }
- else
- {
+ } else {
res.append(",");
}
- if(tmp.contains("<") && tmp.contains(">"))
- {
- String ninja = YamlUtil.beforeChar(tmp,'<');
- if(imports.containsKey(ninja))
- {
+ if (tmp.contains("<") && tmp.contains(">")) {
+ String ninja = YamlUtil.beforeChar(tmp, '<');
+ if (imports.containsKey(ninja)) {
res.append(imports.get(ninja));
- }
- else
- {
+ } else {
res.append(tmp);
}
res.append("<");
- res.append(browseType(YamlUtil.extract('<','>',tmp)));
+ res.append(browseType(YamlUtil.extract('<', '>', tmp)));
res.append(">");
- }
- else
- {
- if(imports.containsKey(tmp))
- {
+ } else {
+ if (imports.containsKey(tmp)) {
res.append(imports.get(tmp));
- }
- else
- {
+ } else {
res.append(tmp);
}
}
@@ -815,87 +623,63 @@
return res.toString();
}
- public String resolveType(String type)
- {
+ public String resolveType(String type) {
List<Character> ignore = new LinkedList<Character>();
ignore.add(' ');
- String typePARSE = YamlUtil.removeMultiChar(type,ignore);
+ String typePARSE = YamlUtil.removeMultiChar(type, ignore);
return browseType(typePARSE);
}
- public void resolveLabels()
- {
- for(List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values())
- {
- for(YamlObject labelisable : objectYAMLO)
- {
- if(labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
- for(YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE))
- {
- if(attribute.containsKeyMapStringListString(TYPE))
- {
+ public void resolveLabels() {
+ for (List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values()) {
+ for (YamlObject labelisable : objectYAMLO) {
+ if (labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
+ for (YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE)) {
+ if (attribute.containsKeyMapStringListString(TYPE)) {
String type = attribute.getFirstMapStringListString(TYPE);
- if(importsI.containsValue(type))
- {
- if(!attribute.containsKeyMapStringListString(NAVIGABLE))
- {
- if(attribute.containsKeyMapStringListString(LABEL))
- {
+ if (importsI.containsValue(type)) {
+ if (!attribute.containsKeyMapStringListString(NAVIGABLE)) {
+ if (attribute.containsKeyMapStringListString(LABEL)) {
String label = attribute.getFirstMapStringListString(LABEL);
- YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(type,'.'),label);
- if(reverseAttribute != null)
- {
- attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
- reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(true));
- if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(type, '.'), label);
+ if (reverseAttribute != null) {
+ attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
+ reverseAttribute.addStringToMap(NAVIGABLE, String.valueOf(true));
+ if (attribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ if (reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(attribute.containsKeyMapStringListString(NAME))
- {
- reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ if (attribute.containsKeyMapStringListString(NAME)) {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, attribute.getFirstMapStringListString(NAME));
}
- if(reverseAttribute.containsKeyMapStringListString(NAME))
- {
- attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,reverseAttribute.getFirstMapStringListString(NAME));
+ if (reverseAttribute.containsKeyMapStringListString(NAME)) {
+ attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, reverseAttribute.getFirstMapStringListString(NAME));
}
}
- }
- else
- {
- YamlObject reverseObject = getReverseObject(YamlUtil.afterChar(type,'.'));
- if(reverseObject != null)
- {
+ } else {
+ YamlObject reverseObject = getReverseObject(YamlUtil.afterChar(type, '.'));
+ if (reverseObject != null) {
YamlObject reverseAttribute = new YamlObject();
- reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(false));
- reverseAttribute.addStringToMap(TYPE,imports.get(labelisable.getFirstMapStringListString(NAME)));
- if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
- {
- reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ reverseAttribute.addStringToMap(NAVIGABLE, String.valueOf(false));
+ reverseAttribute.addStringToMap(TYPE, imports.get(labelisable.getFirstMapStringListString(NAME)));
+ if (attribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY, attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
}
- if(attribute.containsKeyMapStringListString(NAME))
- {
- reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ if (attribute.containsKeyMapStringListString(NAME)) {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, attribute.getFirstMapStringListString(NAME));
}
- if(attribute.containsKeyMapStringListString(ORDERING))
- {
- if(attribute.getFirstMapStringListString(ORDERING).equals(ORDERED))
- {
- reverseAttribute.addStringToMap(ORDERING,UNORDERED);
+ if (attribute.containsKeyMapStringListString(ORDERING)) {
+ if (attribute.getFirstMapStringListString(ORDERING).equals(ORDERED)) {
+ reverseAttribute.addStringToMap(ORDERING, UNORDERED);
+ } else if (attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED)) {
+ reverseAttribute.addStringToMap(ORDERING, ORDERED);
}
- else if(attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED))
- {
- reverseAttribute.addStringToMap(ORDERING,ORDERED);
- }
}
- reverseObject.addYamlObjectToMap(ATTRIBUTE,reverseAttribute);
+ reverseObject.addYamlObjectToMap(ATTRIBUTE, reverseAttribute);
- attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
}
}
}
@@ -907,24 +691,18 @@
}
}
}
- if(labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
- {
- for(YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT))
- {
- if(participant.containsKeyMapStringListString(NAME))
- {
+ if (labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT)) {
+ for (YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT)) {
+ if (participant.containsKeyMapStringListString(NAME)) {
String name = participant.getFirstMapStringListString(NAME);
- if(importsI.containsValue(name))//refClassifier
+ if (importsI.containsValue(name))//refClassifier
{
- if(participant.containsKeyMapStringListString(LABEL))
- {
+ if (participant.containsKeyMapStringListString(LABEL)) {
String label = participant.getFirstMapStringListString(LABEL);
- YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(name,'.'),label);
- if(reverseAttribute != null)
- {
- if(labelisable.containsKeyMapStringListString(NAME))
- {
- reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,packageM+"."+labelisable.getFirstMapStringListString(NAME));
+ YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(name, '.'), label);
+ if (reverseAttribute != null) {
+ if (labelisable.containsKeyMapStringListString(NAME)) {
+ reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME, packageM + "." + labelisable.getFirstMapStringListString(NAME));
}
}
}
@@ -936,26 +714,17 @@
}
}
- public YamlObject getReverseAttribute(String type, String label)
- {
- for(List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values())
- {
- for(YamlObject objectYAMLO : objectsYAMLO)
- {
- if(objectYAMLO.containsKeyMapStringListString(NAME))
- {
+ public YamlObject getReverseAttribute(String type, String label) {
+ for (List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values()) {
+ for (YamlObject objectYAMLO : objectsYAMLO) {
+ if (objectYAMLO.containsKeyMapStringListString(NAME)) {
String name = objectYAMLO.getFirstMapStringListString(NAME);
- if(name.equals(type))
- {
- if(objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
- {
- for(YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE))
- {
- if(attributeYAMLO.containsKeyMapStringListString(LABEL))
- {
+ if (name.equals(type)) {
+ if (objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE)) {
+ for (YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
+ if (attributeYAMLO.containsKeyMapStringListString(LABEL)) {
String reverseLabel = attributeYAMLO.getFirstMapStringListString(LABEL);
- if(reverseLabel.equals(label))
- {
+ if (reverseLabel.equals(label)) {
return attributeYAMLO;
}
}
@@ -968,17 +737,12 @@
return null;
}
- public YamlObject getReverseObject(String type)
- {
- for(List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values())
- {
- for(YamlObject objectYAMLO : objectsYAMLO)
- {
- if(objectYAMLO.containsKeyMapStringListString(NAME))
- {
+ public YamlObject getReverseObject(String type) {
+ for (List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values()) {
+ for (YamlObject objectYAMLO : objectsYAMLO) {
+ if (objectYAMLO.containsKeyMapStringListString(NAME)) {
String name = objectYAMLO.getFirstMapStringListString(NAME);
- if(name.equals(type))
- {
+ if (name.equals(type)) {
return objectYAMLO;
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -7,8 +7,7 @@
*/
public class SyntaxePureYaml {
- public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO)
- {
- ParserPureYaml.parseModel(modelYAML,modelYAMLO);
+ public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO) {
+ ParserPureYaml.parseModel(modelYAML, modelYAMLO);
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -8,9 +8,8 @@
//TODO: interface Syntaxe pour futures syntaxes
public class SyntaxeUserFriendly {
- public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO)
- {
- ParserUserFriendly parser = new ParserUserFriendly(modelYAML,modelYAMLO);
+ public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO) {
+ ParserUserFriendly parser = new ParserUserFriendly(modelYAML, modelYAMLO);
parser.parseModel();
parser.resolveImports();
parser.resolveLabels();
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -1,11 +1,11 @@
package org.nuiton.eugene.models.object.reader.yaml;
-import org.nuiton.eugene.models.object.*;
import org.nuiton.eugene.models.object.xml.*;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
/**
* User: agiraudet
@@ -18,6 +18,7 @@
String packageL;//package local
private boolean _loginit = true;
+
private void log(String str) {
try {
FileWriter log;
@@ -31,13 +32,14 @@
log = new FileWriter(path, true);
log.write("[LOG] " + str + "\n");
log.close();
- } catch (IOException e) {;}
+ } catch (IOException e) {
+ ;
+ }
}
//precondition: labels et imports resolus
//TODO: valeurs par defaut
- public TestLoadObjectModel(/*YamlObject modelYAMLO, ObjectModelImpl modelOM*/)
- {
+ public TestLoadObjectModel(/*YamlObject modelYAMLO, ObjectModelImpl modelOM*/) {
;//loadModel(modelYAMLO,modelOM);
}
@@ -49,561 +51,435 @@
//log
String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ if (packageYAMLO == null) {
packageL = "";
- }
- else
- {
+ } else {
packageL = packageYAMLO;
}
- log("package="+packageL);
+ log("package=" + packageL);
String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
modelOM.setName(nameYAMLO);
- log("name="+modelOM.getName());
+ log("name=" + modelOM.getName());
}
String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
- if(versionYAMLO == null)
- {
+ if (versionYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
modelOM.setVersion(versionYAMLO);
- log("version="+modelOM.getVersion());
+ log("version=" + modelOM.getVersion());
}
//tagvalues
YamlObject tagValues = modelYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
- if(tagValues != null)
- {
- for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
- {
- if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ if (tagValues != null) {
+ for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
+ if (!tagValue.getValue().isEmpty())//taille strictement = 1
{
- modelOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ modelOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
}
}
- log("tagValues="+modelOM.getTagValues());
+ log("tagValues=" + modelOM.getTagValues());
}
//classes
- for(YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS))
- {
+ for (YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS)) {
log(" CLASS");
ObjectModelClassImpl classOM = new ObjectModelClassImpl();
- loadClass(classYAMLO,classOM);
+ loadClass(classYAMLO, classOM);
modelOM.addClass(classOM);
}
//interfaces
- for(YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE))
- {
+ for (YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE)) {
log(" INTERFACE");
ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
- loadInterface(interfaceYAMLO,interfaceOM);
+ loadInterface(interfaceYAMLO, interfaceOM);
modelOM.addInterface(interfaceOM);
}
//classes d'association
- for(YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS))
- {
+ for (YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS)) {
log(" ASSOCIATION_CLASS");
ObjectModelAssociationClassImpl associationClassOM = new ObjectModelAssociationClassImpl();
- loadAssociationClass(associationClassYAMLO,associationClassOM);
+ loadAssociationClass(associationClassYAMLO, associationClassOM);
modelOM.addAssociationClass(associationClassOM);
}
//enumerations
- for(YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION))
- {
+ for (YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION)) {
log(" ENUMERATION");
ObjectModelEnumerationImpl enumerationOM = new ObjectModelEnumerationImpl();
- loadEnumeration(enumerationYAMLO,enumerationOM);
+ loadEnumeration(enumerationYAMLO, enumerationOM);
modelOM.addEnumeration(enumerationOM);
}
}
- public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM)
- {
+ public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) {
String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setName(nameYAMLO);
- log("name="+elementOM.getName());
+ log("name=" + elementOM.getName());
}
String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
- if(staticYAMLO == null)
- {
+ if (staticYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setStatic(Boolean.valueOf(staticYAMLO));
- log("static="+elementOM.isStatic());
+ log("static=" + elementOM.isStatic());
}
String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
- if(documentationYAMLO == null)
- {
+ if (documentationYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
elementOM.setDocumentation(documentationYAMLO);
- log("documentation="+elementOM.getDocumentation());
+ log("documentation=" + elementOM.getDocumentation());
}
YamlObject tagValues = elementYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
- if(tagValues != null)
- {
- for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
- {
- if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ if (tagValues != null) {
+ for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
+ if (!tagValue.getValue().isEmpty())//taille strictement = 1
{
- elementOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ elementOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
}
}
- log("tagValues="+elementOM.getTagValues());
+ log("tagValues=" + elementOM.getTagValues());
}
List<String> comments = elementYAMLO.getMapStringListString(COMMENTS);
- for(String comment : comments)
- {
+ for (String comment : comments) {
elementOM.addComment(comment);
- log("comments="+elementOM.getComments());
+ log("comments=" + elementOM.getComments());
}
List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
- for(String stereotype : stereotypes)
- {
+ for (String stereotype : stereotypes) {
ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
stereotypeOM.setName(stereotype);
elementOM.addStereotype(stereotypeOM);
- log("stereotype="+elementOM.getStereotypes());
+ log("stereotype=" + elementOM.getStereotypes());
}
}
- public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM)
- {
+ public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM) {
loadElement(classifierYAMLO, classifierOM);
- String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
+ if (packageYAMLO == null) {
//TODO: tester packageL == null
classifierOM.setPackage(packageL);
- }
- else
- {
+ } else {
classifierOM.setPackage(packageYAMLO);
}
- log("package="+classifierOM.getPackageName());
+ log("package=" + classifierOM.getPackageName());
String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
- if(externYAMLO == null)
- {
+ if (externYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setExtern(Boolean.valueOf(externYAMLO));
- log("extern="+classifierOM.isExtern());
+ log("extern=" + classifierOM.isExtern());
}
String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
- if(innerYAMLO == null)
- {
+ if (innerYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setInner(Boolean.valueOf(innerYAMLO));
- log("inner="+classifierOM.isInner());
+ log("inner=" + classifierOM.isInner());
}
String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
- if(typeYAMLO == null)
- {
+ if (typeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classifierOM.setType(typeYAMLO);
- log("type="+typeYAMLO);//getType ?
+ log("type=" + typeYAMLO);//getType ?
}
- for(YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE))
- {
+ for (YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
log(" ATTRIBUTE");
ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
- loadAttribute(attributeYAMLO,attributeOM);
+ loadAttribute(attributeYAMLO, attributeOM);
classifierOM.addAttribute(attributeOM);
}
- for(YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION))
- {
+ for (YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION)) {
log(" OPERATION");
ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
- loadOperation(operationYAMLO,operationOM);
+ loadOperation(operationYAMLO, operationOM);
classifierOM.addOperation(operationOM);
}
List<String> superInterfacesYAMLO = classifierYAMLO.getMapStringListString(SUPER_INTERFACES);
- for(String superInterfaceYAMLO : superInterfacesYAMLO)
- {
+ for (String superInterfaceYAMLO : superInterfacesYAMLO) {
ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
superInterfaceOM.setName(superInterfaceYAMLO);
classifierOM.addInterface(superInterfaceOM);
- log("superInterface="+superInterfaceYAMLO);
+ log("superInterface=" + superInterfaceYAMLO);
}
}
- public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM)
- {
+ public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM) {
loadClassifier(classYAMLO, classOM);
String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
- if(abstractYAMLO == null)
- {
+ if (abstractYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
classOM.setAbstract(Boolean.valueOf(abstractYAMLO));
- log("abstract="+classOM.isAbstract());
+ log("abstract=" + classOM.isAbstract());
}
List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
- for(String superClassYAMLO : superClassesYAMLO)
- {
+ for (String superClassYAMLO : superClassesYAMLO) {
ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
superClassOM.setName(superClassYAMLO);
classOM.addSuperclass(superClassOM);
- log("superClasses="+superClassYAMLO);
+ log("superClasses=" + superClassYAMLO);
}
}
- public void loadInterface(YamlObject interfaceYAMLO, ObjectModelInterfaceImpl interfaceOM)
- {
- loadClassifier(interfaceYAMLO,interfaceOM);
+ public void loadInterface(YamlObject interfaceYAMLO, ObjectModelInterfaceImpl interfaceOM) {
+ loadClassifier(interfaceYAMLO, interfaceOM);
}
- public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM)
- {
+ public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM) {
loadClass(associationClassYAML, associationClassOM);
//TODO: remplacer name par type et attribute par name ?
- for(YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT))
- {
+ for (YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT)) {
log(" PARTICIPANT");
ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
participantOM.setAssociationClass(associationClassOM);
String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
- if(nameYAMLO == null)
- {
+ if (nameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
participantOM.setName(nameYAMLO);
- log("name="+participantOM.getName());
+ log("name=" + participantOM.getName());
}
String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
- if(attributeYAMLO == null)
- {
+ if (attributeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
participantOM.setAttribute(attributeYAMLO);
- log("attribute="+participantOM.getAttributeName());
+ log("attribute=" + participantOM.getAttributeName());
}
associationClassOM.addParticipant(participantOM);
}
}
- public void loadEnumeration(YamlObject enumerationYAMLO, ObjectModelEnumerationImpl enumerationOM)
- {
+ public void loadEnumeration(YamlObject enumerationYAMLO, ObjectModelEnumerationImpl enumerationOM) {
loadElement(enumerationYAMLO, enumerationOM);
//TODO: remplacer LITERAL par LITERALS (List)
List<String> literalsYAMLO = enumerationYAMLO.getMapStringListString(LITERAL);
- for(String literalYAMLO : literalsYAMLO)
- {
+ for (String literalYAMLO : literalsYAMLO) {
ObjectModelImplRef literalOM = new ObjectModelImplRef();
literalOM.setName(literalYAMLO);
enumerationOM.addLiteral(literalOM);
- log("literals="+enumerationOM.getLiterals());
+ log("literals=" + enumerationOM.getLiterals());
}
String packageYAMLO = enumerationYAMLO.getFirstMapStringListString(PACKAGE);
- if(packageYAMLO == null)
- {
+ if (packageYAMLO == null) {
enumerationOM.setPackage(packageL);
- }
- else
- {
+ } else {
enumerationOM.setPackage(packageYAMLO);
}
- log("package="+enumerationOM.getPackageName());
+ log("package=" + enumerationOM.getPackageName());
}
- public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM)
- {
- loadElement(parameterYAMLO,parameterOM);
+ public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM) {
+ loadElement(parameterYAMLO, parameterOM);
String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
- if(orderingYAMLO == null)
- {
+ if (orderingYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setOrdering(orderingYAMLO);
- log("ordering="+orderingYAMLO);//getOrdering ?
+ log("ordering=" + orderingYAMLO);//getOrdering ?
}
String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
- if(typeYAMLO == null)
- {
+ if (typeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setType(typeYAMLO);
- log("type="+parameterOM.getType());
+ log("type=" + parameterOM.getType());
}
String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
- if(defaultValueYAMLO == null)
- {
+ if (defaultValueYAMLO == null) {
;//default
- }
- else
- {
+ } else {
parameterOM.setDefaultValue(defaultValueYAMLO);
- log("defaultValue="+parameterOM.getDefaultValue());
+ log("defaultValue=" + parameterOM.getDefaultValue());
}
String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
- if(minMultiplicityYAMLO == null)
- {
+ if (minMultiplicityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
- log("minMultiplicity="+parameterOM.getMinMultiplicity());
+ log("minMultiplicity=" + parameterOM.getMinMultiplicity());
}
String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
- if(maxMultiplicityYAMLO == null)
- {
+ if (maxMultiplicityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setMaxMultiplicity(Integer.valueOf(maxMultiplicityYAMLO));
- log("maxMultiplicity="+parameterOM.getMaxMultiplicity());
+ log("maxMultiplicity=" + parameterOM.getMaxMultiplicity());
}
String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
- if(orderedYAMLO == null)
- {
+ if (orderedYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
- log("ordered="+parameterOM.isOrdered());
+ log("ordered=" + parameterOM.isOrdered());
}
String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
- if(uniqueYAMLO == null)
- {
+ if (uniqueYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
parameterOM.setUnique(Boolean.valueOf(uniqueYAMLO));
- log("unique="+parameterOM.isUnique());
+ log("unique=" + parameterOM.isUnique());
}
}
- public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM)
- {
- loadParameter(attributeYAMLO,attributeOM);
+ public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM) {
+ loadParameter(attributeYAMLO, attributeOM);
String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
- if(navigableYAMLO == null)
- {
+ if (navigableYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setNavigable(Boolean.valueOf(navigableYAMLO));
- log("navigable="+attributeOM.isNavigable());
+ log("navigable=" + attributeOM.isNavigable());
}
String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
- if(associationTypeYAMLO == null)
- {
+ if (associationTypeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setAssociationType(associationTypeYAMLO);
- log("associationType="+associationTypeYAMLO);//getAssociationType ?
+ log("associationType=" + associationTypeYAMLO);//getAssociationType ?
}
String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
- if(finalYAMLO == null)
- {
+ if (finalYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
- log("final="+attributeOM.isFinal());
+ log("final=" + attributeOM.isFinal());
}
String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
- if(staticYAMLO == null)
- {
+ if (staticYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
- log("static="+attributeOM.isStatic());
+ log("static=" + attributeOM.isStatic());
}
String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
- if(associationClassNameYAMLO == null)
- {
+ if (associationClassNameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setAssociationClassName(associationClassNameYAMLO);
- log("associationClassName="+associationClassNameYAMLO);
+ log("associationClassName=" + associationClassNameYAMLO);
}
String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
- if(reverseAttributeNameYAMLO == null)
- {
+ if (reverseAttributeNameYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
- log("reverseAttributeName="+attributeOM.getReverseAttributeName());
+ log("reverseAttributeName=" + attributeOM.getReverseAttributeName());
}
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
- if(reverseMaxMultiplicityYAMLO == null)
- {
+ if (reverseMaxMultiplicityYAMLO == null) {
//test
attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
//test
- }
- else
- {
+ } else {
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
- log("reverseMaxMultiplicity="+attributeOM.getReverseMaxMultiplicity());
+ log("reverseMaxMultiplicity=" + attributeOM.getReverseMaxMultiplicity());
}
String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
- if(transientYAMLO == null)
- {
+ if (transientYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
- log("transient="+attributeOM.isTransient());
+ log("transient=" + attributeOM.isTransient());
}
String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
- if(visibilityYAMLO == null)
- {
+ if (visibilityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
attributeOM.setVisibility(visibilityYAMLO);
- log("visibility="+attributeOM.getVisibility());
+ log("visibility=" + attributeOM.getVisibility());
}
}
- public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM)
- {
- loadElement(operationYAMLO,operationOM);
+ public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM) {
+ loadElement(operationYAMLO, operationOM);
String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
- if(abstractYAMLO == null)
- {
+ if (abstractYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setAbstract(Boolean.valueOf(abstractYAMLO));
- log("abstract="+operationOM.isAbstract());
+ log("abstract=" + operationOM.isAbstract());
}
String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
- if(visibilityYAMLO == null)
- {
+ if (visibilityYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setVisibility(visibilityYAMLO);
- log("visibility="+operationOM.getVisibility());
+ log("visibility=" + operationOM.getVisibility());
}
- for(YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
- {
+ for (YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
log(" RETURN_PARAMETER");
ObjectModelParameterImpl returnParameterOM = new ObjectModelAttributeImpl();
- loadParameter(returnParameterYAMLO,returnParameterOM);
+ loadParameter(returnParameterYAMLO, returnParameterOM);
operationOM.setReturnParameter(returnParameterOM);
}
- for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
- {
+ for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
log(" PARAMETER");
ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
- loadParameter(parameterYAMLO,parameterOM);
+ loadParameter(parameterYAMLO, parameterOM);
operationOM.addParameter(parameterOM);
}
String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
- if(bodyCodeYAMLO == null)
- {
+ if (bodyCodeYAMLO == null) {
;//valeur par defaut
- }
- else
- {
+ } else {
operationOM.setBodyCode(bodyCodeYAMLO);
- log("bodyCode="+operationOM.getBodyCode());
+ log("bodyCode=" + operationOM.getBodyCode());
}
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -5,17 +5,18 @@
import org.yaml.snakeyaml.Yaml;
import java.io.*;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
/**
* User: agiraudet
* Date: 28/05/13
* Time: 16:35
- *
+ * <p/>
* Rôle: parser le fichier YAML et le transformer en YAMLobject
- *
+ * <p/>
* parser si besoin et charger le YAMLobject
- * parse en fonction de la version
+ * parse en fonction de la version
*/
@Deprecated
public class TestLoadYamlFile extends KeyWords {
@@ -27,6 +28,7 @@
String defaultVersion;//version des valeurs par defaut
private boolean _loginit = true;
+
private void log(String str) {
try {
FileWriter log;
@@ -40,11 +42,12 @@
log = new FileWriter(path, true);
log.write("[LOG] " + str + "\n");
log.close();
- } catch (IOException e) {;}
+ } catch (IOException e) {
+ ;
+ }
}
- public TestLoadYamlFile()
- {
+ public TestLoadYamlFile() {
yaml = new Yaml();
}
@@ -57,55 +60,45 @@
//chercher version et charger en conséquent
Object version = null;
- if(modelYAML instanceof List)
- {
+ if (modelYAML instanceof List) {
version = YamlUtil.collectElementList((List) modelYAML, SYNTAXE);
syntaxeVersion = "1";
defaultVersion = "0";
log("modelYAML instanceof List");
}
- if(modelYAML instanceof Map)
- {
+ if (modelYAML instanceof Map) {
version = YamlUtil.collectElementMap((Map) modelYAML, SYNTAXE);
syntaxeVersion = "2";
defaultVersion = "0";
log("modelYAML instanceof Map");
- }
- else
- {
+ } else {
syntaxeVersion = "0";
defaultVersion = "0";
log("modelYAML instanceof unknow");
}
- if(version != null)
- {
- syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version),'.');
- defaultVersion = YamlUtil.afterChar(String.valueOf(version),'.');
- log("version="+syntaxeVersion+"."+defaultVersion);
+ if (version != null) {
+ syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version), '.');
+ defaultVersion = YamlUtil.afterChar(String.valueOf(version), '.');
+ log("version=" + syntaxeVersion + "." + defaultVersion);
}
- if(syntaxeVersion.equals("1"))
- {
+ if (syntaxeVersion.equals("1")) {
SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
log("load SyntaxePureYaml");
- }
- else if(syntaxeVersion.equals("2"))
- {
+ } else if (syntaxeVersion.equals("2")) {
//syntaxe user firendly : coming soon
Parser test = new Parser();
test.parseModel(modelYAML, modelYAMLO);
Parser.resolveImports(modelYAMLO);
Parser.resolveLabels(modelYAMLO);
log("load SyntaxeUserFriendly");
- }
- else
- {
+ } else {
;//syntaxe par defaut, si version syntaxe non reconnue
SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
}
TestLoadObjectModel test = new TestLoadObjectModel();
- test.loadModel(modelYAMLO,modelOM);
+ test.loadModel(modelYAMLO, modelOM);
log("END");
//TODO: charger ObjectModel avec les valeurs par defaut en fonction de la version (ajouter parametre à loadModel)
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java 2013-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -11,93 +11,72 @@
* Time: 16:41
*/
public class YamlObject {
- protected Map<String,List<String>> mapStringListString;
+ protected Map<String, List<String>> mapStringListString;
protected Map<String, List<YamlObject>> mapStringListYamlObject;
//TODO: améliorer nom méthodes
- public YamlObject()
- {
+ public YamlObject() {
mapStringListString = new LinkedHashMap<String, List<String>>();
mapStringListYamlObject = new LinkedHashMap<String, List<YamlObject>>();
}
- public void addYamlObjectToMap(String key, YamlObject value)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
+ public void addYamlObjectToMap(String key, YamlObject value) {
+ if (mapStringListYamlObject.containsKey(key)) {
mapStringListYamlObject.get(key).add(value);
- }
- else
- {
+ } else {
List<YamlObject> tmp = new LinkedList<YamlObject>();
tmp.add(value);
- mapStringListYamlObject.put(key,tmp);
+ mapStringListYamlObject.put(key, tmp);
}
}
- public void addStringToMap(String key, String value)
- {
- if(mapStringListString.containsKey(key))
- {
+ public void addStringToMap(String key, String value) {
+ if (mapStringListString.containsKey(key)) {
mapStringListString.get(key).add(value);
- }
- else
- {
+ } else {
List<String> tmp = new LinkedList<String>();
tmp.add(value);
- mapStringListString.put(key,tmp);
+ mapStringListString.put(key, tmp);
}
}
- public YamlObject getFirstMapStringListYamlObject(String key)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
- if(!mapStringListYamlObject.isEmpty())
- {
+ public YamlObject getFirstMapStringListYamlObject(String key) {
+ if (mapStringListYamlObject.containsKey(key)) {
+ if (!mapStringListYamlObject.isEmpty()) {
return mapStringListYamlObject.get(key).get(0);
}
}
- return null; }
+ return null;
+ }
- public String getFirstMapStringListString(String key)
- {
- if( mapStringListString.containsKey(key))
- {
- if(! mapStringListString.isEmpty())
- {
- return mapStringListString.get(key).get(0);
+ public String getFirstMapStringListString(String key) {
+ if (mapStringListString.containsKey(key)) {
+ if (!mapStringListString.isEmpty()) {
+ return mapStringListString.get(key).get(0);
}
}
return null;
}
- public boolean isUniqueMapStringListYamlObject(String key)
- {
+ public boolean isUniqueMapStringListYamlObject(String key) {
return (sizeOfMapStringListYamlObject(key) == 1);
}
- public boolean isUniqueMapStringListString(String key)
- {
+ public boolean isUniqueMapStringListString(String key) {
return (sizeOfMapStringListString(key) == 1);
}
- public boolean containsKeyYamlMapStringListYamlObject(String key)
- {
+ public boolean containsKeyYamlMapStringListYamlObject(String key) {
return mapStringListYamlObject.containsKey(key);
}
- public boolean containsKeyMapStringListString(String key)
- {
+ public boolean containsKeyMapStringListString(String key) {
return mapStringListString.containsKey(key);
}
- public List<YamlObject> getMapStringListYamlObject(String key)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
- if(!mapStringListYamlObject.isEmpty())
- {
+ public List<YamlObject> getMapStringListYamlObject(String key) {
+ if (mapStringListYamlObject.containsKey(key)) {
+ if (!mapStringListYamlObject.isEmpty()) {
return mapStringListYamlObject.get(key);
}
}
@@ -105,12 +84,9 @@
return new LinkedList<YamlObject>();
}
- public List<String> getMapStringListString(String key)
- {
- if(mapStringListString.containsKey(key))
- {
- if(!mapStringListString.isEmpty())
- {
+ public List<String> getMapStringListString(String key) {
+ if (mapStringListString.containsKey(key)) {
+ if (!mapStringListString.isEmpty()) {
return mapStringListString.get(key);
}
}
@@ -118,92 +94,72 @@
return new LinkedList<String>();
}
- public int sizeOfMapStringListYamlObject(String key)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
+ public int sizeOfMapStringListYamlObject(String key) {
+ if (mapStringListYamlObject.containsKey(key)) {
return mapStringListYamlObject.get(key).size();
}
return 0;//-1
}
- public int sizeOfMapStringListString(String key)
- {
- if(mapStringListString.containsKey(key))
- {
+ public int sizeOfMapStringListString(String key) {
+ if (mapStringListString.containsKey(key)) {
return mapStringListString.get(key).size();
}
return 0;//-1
}
- public Map<String, List<YamlObject>> getMapStringListYamlObject()
- {
+ public Map<String, List<YamlObject>> getMapStringListYamlObject() {
return mapStringListYamlObject;
}
- public Map<String, List<String>> getMapStringListString()
- {
+ public Map<String, List<String>> getMapStringListString() {
return mapStringListString;
}
- public boolean setMapStringListString(String key, String value, String element)
- {
- if(mapStringListString.containsKey(key))
- {
- if(mapStringListString.get(key).contains(value))
- {
- mapStringListString.get(key).set(mapStringListString.get(key).indexOf(value),element);
+ public boolean setMapStringListString(String key, String value, String element) {
+ if (mapStringListString.containsKey(key)) {
+ if (mapStringListString.get(key).contains(value)) {
+ mapStringListString.get(key).set(mapStringListString.get(key).indexOf(value), element);
return true;
}
}
return false;
}
- public boolean setMapStringListYamlObject(String key, YamlObject value, YamlObject element)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
- if(mapStringListYamlObject.get(key).contains(value))
- {
- mapStringListYamlObject.get(key).set(mapStringListYamlObject.get(key).indexOf(value),element);
+ public boolean setMapStringListYamlObject(String key, YamlObject value, YamlObject element) {
+ if (mapStringListYamlObject.containsKey(key)) {
+ if (mapStringListYamlObject.get(key).contains(value)) {
+ mapStringListYamlObject.get(key).set(mapStringListYamlObject.get(key).indexOf(value), element);
return true;
}
}
return false;
}
- public boolean removeMapStringListString(String key, String value)
- {
- if(mapStringListString.containsKey(key))
- {
+ public boolean removeMapStringListString(String key, String value) {
+ if (mapStringListString.containsKey(key)) {
return mapStringListString.get(key).remove(value);
}
return false;
}
- public boolean removeMapStringString(String key)
- {
- if(mapStringListString.containsKey(key))
- {
+ public boolean removeMapStringString(String key) {
+ if (mapStringListString.containsKey(key)) {
mapStringListString.remove(key);
return true;
}
return false;
}
- public boolean removeMapStringListYamlObject(String key, YamlObject value)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
+ public boolean removeMapStringListYamlObject(String key, YamlObject value) {
+ if (mapStringListYamlObject.containsKey(key)) {
return mapStringListYamlObject.get(key).remove(value);
}
return false;
}
- public boolean removeMapStringListYamlObject(String key)
- {
- if(mapStringListYamlObject.containsKey(key))
- {
+ public boolean removeMapStringListYamlObject(String key) {
+ if (mapStringListYamlObject.containsKey(key)) {
mapStringListYamlObject.remove(key);
return true;
}
@@ -212,38 +168,30 @@
@Override
public boolean equals(Object o) {
- if(o instanceof YamlObject)
- {
+ if (o instanceof YamlObject) {
return (mapStringListYamlObject.equals(((YamlObject) o).getMapStringListYamlObject()) && mapStringListString.equals(((YamlObject) o).getMapStringListString()));
}
return false;
}
@Override
- public String toString()
- {
+ public String toString() {
return toString("- ");
}
- public String toString(String indentation)
- {
+ public String toString(String indentation) {
StringBuilder res = new StringBuilder();
- for(Map.Entry<String,List<String>> entry : mapStringListString.entrySet())
- {
- for(String str : entry.getValue())
- {
+ for (Map.Entry<String, List<String>> entry : mapStringListString.entrySet()) {
+ for (String str : entry.getValue()) {
res.append(indentation).append(entry.getKey()).append(": ").append(str).append("\n");
}
}
- for(Map.Entry<String,List<YamlObject>> entry : mapStringListYamlObject.entrySet())
- {
- for(YamlObject yobj : entry.getValue())
- {
+ for (Map.Entry<String, List<YamlObject>> entry : mapStringListYamlObject.entrySet()) {
+ for (YamlObject yobj : entry.getValue()) {
//test temporaire
- if(yobj != null)
- {
- res.append(indentation).append(entry.getKey()).append(":\n").append(yobj.toString( " "+indentation)).append("\n");
+ if (yobj != null) {
+ res.append(indentation).append(entry.getKey()).append(":\n").append(yobj.toString(" " + indentation)).append("\n");
}
//test
}
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-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -1,11 +1,14 @@
package org.nuiton.eugene.models.object.reader.yaml;
-import org.nuiton.eugene.models.object.*;
+import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.xml.*;
import org.yaml.snakeyaml.Yaml;
import java.io.*;
-import java.util.*;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import static org.nuiton.eugene.models.object.reader.yaml.YamlUtil.afterChar;
import static org.nuiton.eugene.models.object.reader.yaml.YamlUtil.browseKeySetToLowerCase;
@@ -15,7 +18,7 @@
* Date: 15/05/13
* Time: 11:15
*/
- @Deprecated
+@Deprecated
public class YamlToObjectModel {
protected Yaml yaml;
protected String packageOM;
@@ -66,6 +69,7 @@
public static final String ELEMENT = "element";
private boolean _loginit = true;
+
private void log(String str) {
try {
FileWriter log;
@@ -79,7 +83,9 @@
log = new FileWriter(path, true);
log.write("[LOG] " + str + "\n");
log.close();
- } catch (IOException e) {;}
+ } catch (IOException e) {
+ ;
+ }
}
public YamlToObjectModel() {
@@ -142,12 +148,10 @@
//load imports
imports = new LinkedHashMap<String, String>();
Object importsYAML = collectElement((List) modelYAML, IMPORTS);
- if(importsYAML instanceof List)
- {
- for(Object importYAML : (List) importsYAML)
- {
- imports.put(afterChar(String.valueOf(importYAML),'.'),String.valueOf(importYAML));
- log("import="+String.valueOf(importYAML));
+ if (importsYAML instanceof List) {
+ for (Object importYAML : (List) importsYAML) {
+ imports.put(afterChar(String.valueOf(importYAML), '.'), String.valueOf(importYAML));
+ log("import=" + String.valueOf(importYAML));
}
}
@@ -158,14 +162,14 @@
} else {
packageOM = String.valueOf(packageYAML);
}
- log("package="+packageOM);
+ log("package=" + packageOM);
Object nameYAML = collectElement((List) modelYAML, NAME);
if (nameYAML == null) {
;
} else {
modelOM.setName(String.valueOf(nameYAML));
- log("name="+String.valueOf(nameYAML));
+ log("name=" + String.valueOf(nameYAML));
}
Object versionYAML = collectElement((List) modelYAML, VERSION);
@@ -173,7 +177,7 @@
;
} else {
modelOM.setVersion(String.valueOf(versionYAML));
- log("version="+String.valueOf(versionYAML));
+ log("version=" + String.valueOf(versionYAML));
}
Object tagValuesYAML = collectElement((List) modelYAML, TAG_VALUES);
@@ -181,7 +185,7 @@
for (Object entry : ((Map) tagValuesYAML).entrySet()) {
if (entry instanceof Map.Entry) {
modelOM.addTagValue(String.valueOf(((Map.Entry) entry).getKey()), String.valueOf(((Map.Entry) entry).getValue()));
- log("tagValue=[key="+String.valueOf(((Map.Entry) entry).getKey())+" value="+String.valueOf(((Map.Entry) entry).getValue())+"]");
+ log("tagValue=[key=" + String.valueOf(((Map.Entry) entry).getKey()) + " value=" + String.valueOf(((Map.Entry) entry).getValue()) + "]");
}
}
}
@@ -209,7 +213,7 @@
ObjectModelClassImpl classOM = new ObjectModelClassImpl();
loadClass(classYAML, classOM);
modelOM.addClass(classOM);
- log("class="+classOM.getName()+" loaded");
+ log("class=" + classOM.getName() + " loaded");
}
List interfacesYAML = collectAllElements((List) modelYAML, INTERFACE);
@@ -217,7 +221,7 @@
ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
loadInterface(interfaceYAML, interfaceOM);
modelOM.addInterface(interfaceOM);
- log("interface="+interfaceOM.getName()+" loaded");
+ log("interface=" + interfaceOM.getName() + " loaded");
}
List classesAssociationYAML = collectAllElements((List) modelYAML, CLASS_ASSOCIATION);
@@ -225,7 +229,7 @@
ObjectModelAssociationClassImpl classAssociationOM = new ObjectModelAssociationClassImpl();
loadAssociationClass(classAssociationYAML, classAssociationOM);
modelOM.addAssociationClass(classAssociationOM);
- log("classAssociation="+classAssociationOM.getName()+" loaded");
+ log("classAssociation=" + classAssociationOM.getName() + " loaded");
}
List enumerationsYAML = collectAllElements((List) modelYAML, ENUMERATION);
@@ -233,7 +237,7 @@
ObjectModelEnumerationImpl enumerationOM = new ObjectModelEnumerationImpl();
loadEnumeration(enumerationYAML, enumerationOM);
modelOM.addEnumeration(enumerationOM);
- log("enumeration="+enumerationOM.getName()+" loaded");
+ log("enumeration=" + enumerationOM.getName() + " loaded");
}
}
}
@@ -249,7 +253,7 @@
;
} else {
elementOM.setName(String.valueOf(nameYAML));
- log("name="+String.valueOf(nameYAML));
+ log("name=" + String.valueOf(nameYAML));
}
Object staticYAML = collectElement((List) elementYAML, STATIC);
@@ -257,7 +261,7 @@
;
} else {
elementOM.setStatic(Boolean.valueOf(String.valueOf(staticYAML)));
- log("static="+(Boolean.valueOf(String.valueOf(staticYAML))));
+ log("static=" + (Boolean.valueOf(String.valueOf(staticYAML))));
}
Object documentationYAML = collectElement((List) elementYAML, DOCUMENTATION);
@@ -265,7 +269,7 @@
;
} else {
elementOM.setDocumentation(String.valueOf(documentationYAML));
- log("documentation="+String.valueOf(documentationYAML));
+ log("documentation=" + String.valueOf(documentationYAML));
}
Object tagValuesYAML = collectElement((List) elementYAML, TAG_VALUES);
@@ -273,7 +277,7 @@
for (Object entry : ((Map) tagValuesYAML).entrySet()) {
if (entry instanceof Map.Entry) {
elementOM.addTagValue(String.valueOf(((Map.Entry) entry).getKey()), String.valueOf(((Map.Entry) entry).getValue()));
- log("tagValue=[key="+String.valueOf(((Map.Entry) entry).getKey())+" value="+String.valueOf(((Map.Entry) entry).getValue())+"]");
+ log("tagValue=[key=" + String.valueOf(((Map.Entry) entry).getKey()) + " value=" + String.valueOf(((Map.Entry) entry).getValue()) + "]");
}
}
}
@@ -282,7 +286,7 @@
if (commentsYAML instanceof List) {
for (Object comment : (List) commentsYAML) {
elementOM.addComment(String.valueOf(comment));
- log("comment="+String.valueOf(comment));
+ log("comment=" + String.valueOf(comment));
}
}
@@ -293,7 +297,7 @@
ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
stereotypeOM.setName(String.valueOf(stereotype));
elementOM.addStereotype(stereotypeOM);
- log("stereotype="+String.valueOf(stereotype));
+ log("stereotype=" + String.valueOf(stereotype));
}
}
}
@@ -311,7 +315,7 @@
classifierOM.setPackage(packageOM);
} else {
classifierOM.setPackage(String.valueOf(packageYAML));
- log("package="+String.valueOf(packageYAML));
+ log("package=" + String.valueOf(packageYAML));
}
Object externYAML = collectElement((List) classifierYAML, EXTERN);
@@ -319,7 +323,7 @@
;
} else {
classifierOM.setExtern(Boolean.valueOf(String.valueOf(externYAML)));
- log("extern="+String.valueOf(externYAML));
+ log("extern=" + String.valueOf(externYAML));
}
Object innerYAML = collectElement((List) classifierYAML, INNER);
@@ -327,7 +331,7 @@
;
} else {
classifierOM.setInner(Boolean.valueOf(String.valueOf(innerYAML)));
- log("inner="+String.valueOf(innerYAML));
+ log("inner=" + String.valueOf(innerYAML));
}
Object typeYAML = collectElement((List) classifierYAML, TYPE);
@@ -335,7 +339,7 @@
;
} else {
classifierOM.setType(String.valueOf(typeYAML));
- log("type="+String.valueOf(typeYAML));
+ log("type=" + String.valueOf(typeYAML));
}
List attributesYAML = collectAllElements((List) classifierYAML, ATTRIBUTE);
@@ -343,7 +347,7 @@
ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
loadAttribute(attributeYAML, attributeOM);
classifierOM.addAttribute(attributeOM);
- log("attribute="+attributeOM.getType()+" loaded");
+ log("attribute=" + attributeOM.getType() + " loaded");
}
List operationsYAML = collectAllElements((List) classifierYAML, OPERATION);
@@ -351,7 +355,7 @@
ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
loadOperation(operationYAML, operationOM);
classifierOM.addOperation(operationOM);
- log("operation="+operationOM.getName()+" loaded");
+ log("operation=" + operationOM.getName() + " loaded");
}
Object superInterfacesYAML = collectElement((List) classifierYAML, SUPER_INTERFACES);
@@ -360,7 +364,7 @@
ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
superInterfaceOM.setName(String.valueOf(superInterface));
classifierOM.addInterface(superInterfaceOM);
- log("superInterface="+String.valueOf(superInterface));
+ log("superInterface=" + String.valueOf(superInterface));
}
}
}
@@ -377,7 +381,7 @@
;
} else {
classOM.setAbstract(Boolean.valueOf(String.valueOf(abstractYAML)));
- log("abstract="+String.valueOf(abstractYAML));
+ log("abstract=" + String.valueOf(abstractYAML));
}
Object superClassesYAML = collectElement((List) classYAML, SUPER_CLASSES);
@@ -387,7 +391,7 @@
//ObjectModelImplRef superClassOM = new ObjectModelImplRef();
superClassOM.setName(String.valueOf(superClass));
classOM.addSuperclass(superClassOM);
- log("superClass="+String.valueOf(superClass));
+ log("superClass=" + String.valueOf(superClass));
}
}
}
@@ -422,7 +426,7 @@
} else {
participantOM.setName(name);
}
- log("name="+name);
+ log("name=" + name);
}
Object attributeYAML = collectElement((List) participantYAML, ATTRIBUTE);
@@ -430,9 +434,9 @@
;
} else {
participantOM.setAttribute(String.valueOf(attributeYAML));
- log("attribute="+String.valueOf(attributeYAML));
+ log("attribute=" + String.valueOf(attributeYAML));
}
- log("participant="+String.valueOf(nameYAML)+" loaded");
+ log("participant=" + String.valueOf(nameYAML) + " loaded");
associationClassOM.addParticipant(participantOM);
}
}
@@ -449,7 +453,7 @@
ObjectModelImplRef literalOM = new ObjectModelImplRef();
literalOM.setName(String.valueOf(literalYAML));
enumerationOM.addLiteral(literalOM);
- log("literal="+String.valueOf(literalsYAML));
+ log("literal=" + String.valueOf(literalsYAML));
}
}
@@ -458,7 +462,7 @@
enumerationOM.setPackage(packageOM);
} else {
enumerationOM.setPackage(String.valueOf(packageYAML));
- log("package="+String.valueOf(packageYAML));
+ log("package=" + String.valueOf(packageYAML));
}
}
}
@@ -472,7 +476,7 @@
;
} else {
parameterOM.setOrdering(String.valueOf(orderingYAML));
- log("ordering="+String.valueOf(orderingYAML));
+ log("ordering=" + String.valueOf(orderingYAML));
}
Object typeYAML = collectElement((List) parameterYAML, TYPE);
@@ -485,7 +489,7 @@
} else {
parameterOM.setType(type);
}
- log("type="+parameterOM.getType());
+ log("type=" + parameterOM.getType());
}
Object defaultValueYAML = collectElement((List) parameterYAML, DEFAULT_VALUE);
@@ -493,7 +497,7 @@
;
} else {
parameterOM.setDefaultValue(String.valueOf(defaultValueYAML));
- log("defaultValue="+String.valueOf(defaultValueYAML));
+ log("defaultValue=" + String.valueOf(defaultValueYAML));
}
Object minMultiplicityYAML = collectElement((List) parameterYAML, MIN_MULTIPLICITY);
@@ -501,7 +505,7 @@
;//deja instancié à 1
} else {
parameterOM.setMinMultiplicity(Integer.valueOf(String.valueOf(minMultiplicityYAML)));
- log("minMultiplicity="+Integer.valueOf(String.valueOf(minMultiplicityYAML)));
+ log("minMultiplicity=" + Integer.valueOf(String.valueOf(minMultiplicityYAML)));
}
Object maxMultiplicityYAML = collectElement((List) parameterYAML, MAX_MULTIPLICITY);
@@ -509,7 +513,7 @@
;
} else {
parameterOM.setMaxMultiplicity(Integer.valueOf(String.valueOf(maxMultiplicityYAML)));
- log("maxMultiplicity="+String.valueOf(maxMultiplicityYAML));
+ log("maxMultiplicity=" + String.valueOf(maxMultiplicityYAML));
}
Object orderedYAML = collectElement((List) parameterYAML, ORDERED);
@@ -517,7 +521,7 @@
;
} else {
parameterOM.setOrdered(Boolean.valueOf(String.valueOf(orderedYAML)));
- log("ordered="+Boolean.valueOf(String.valueOf(orderedYAML)));
+ log("ordered=" + Boolean.valueOf(String.valueOf(orderedYAML)));
}
Object uniqueYAML = collectElement((List) parameterYAML, UNIQUE);
@@ -525,7 +529,7 @@
;
} else {
parameterOM.setUnique(Boolean.valueOf(String.valueOf(uniqueYAML)));
- log("unique="+Boolean.valueOf(String.valueOf(uniqueYAML)));
+ log("unique=" + Boolean.valueOf(String.valueOf(uniqueYAML)));
}
}
}
@@ -539,7 +543,7 @@
;
} else {
attributeOM.setNavigable(Boolean.valueOf(String.valueOf(navigableYAML)));
- log("navigable="+Boolean.valueOf(String.valueOf(navigableYAML)));
+ log("navigable=" + Boolean.valueOf(String.valueOf(navigableYAML)));
}
Object associationTypeYAML = collectElement((List) attributeYAML, ASSOCIATION_TYPE);
@@ -547,7 +551,7 @@
;//attributeOM.setAssociationType(ObjectModelAttributeImpl.ATTRIBUTE_TYPE_COMPOSITE);
} else {
attributeOM.setAssociationType(String.valueOf(associationTypeYAML));
- log("associationType="+String.valueOf(associationTypeYAML));
+ log("associationType=" + String.valueOf(associationTypeYAML));
}
Object finalYAML = collectElement((List) attributeYAML, FINAL);
@@ -555,7 +559,7 @@
;
} else {
attributeOM.setFinal(Boolean.valueOf(String.valueOf(finalYAML)));
- log("final="+Boolean.valueOf(String.valueOf(finalYAML)));
+ log("final=" + Boolean.valueOf(String.valueOf(finalYAML)));
}
Object staticYAML = collectElement((List) attributeYAML, STATIC);
@@ -563,7 +567,7 @@
;
} else {
attributeOM.setStatic(Boolean.valueOf(String.valueOf(staticYAML)));
- log("static="+Boolean.valueOf(String.valueOf(staticYAML)));
+ log("static=" + Boolean.valueOf(String.valueOf(staticYAML)));
}
Object associationClassNameYAML = collectElement((List) attributeYAML, ASSOCIATION_CLASS_NAME);
@@ -576,7 +580,7 @@
} else {
attributeOM.setAssociationClassName(associationClassName);
}
- log("associationClassName="+associationClassName);
+ log("associationClassName=" + associationClassName);
}
Object reverseAttributeNameYAML = collectElement((List) attributeYAML, REVERSE_ATTRIBUTE_NAME);
@@ -584,7 +588,7 @@
;// attributeOM.setReverseAttributeName("");//test
} else {
attributeOM.setReverseAttributeName(String.valueOf(reverseAttributeNameYAML));
- log("reverseAttributeName="+String.valueOf(reverseAttributeNameYAML));
+ log("reverseAttributeName=" + String.valueOf(reverseAttributeNameYAML));
}
Object reverseMaxMultiplicityYAML = collectElement((List) attributeYAML, REVERSE_MAX_MULTIPLICITY);
@@ -592,7 +596,7 @@
;//instancié à -1
} else {
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(String.valueOf(reverseMaxMultiplicityYAML)));
- log("reverseMaxMultiplicity="+Integer.valueOf(String.valueOf(reverseMaxMultiplicityYAML)));
+ log("reverseMaxMultiplicity=" + Integer.valueOf(String.valueOf(reverseMaxMultiplicityYAML)));
}
@@ -601,7 +605,7 @@
;
} else {
attributeOM.setTransient(Boolean.valueOf(String.valueOf(transientYAML)));
- log("transient="+Boolean.valueOf(String.valueOf(transientYAML)));
+ log("transient=" + Boolean.valueOf(String.valueOf(transientYAML)));
}
Object visibilityYAML = collectElement((List) attributeYAML, VISIBILITY);
@@ -609,7 +613,7 @@
;
} else {
attributeOM.setVisibility(String.valueOf(visibilityYAML));
- log("visibility="+String.valueOf(visibilityYAML));
+ log("visibility=" + String.valueOf(visibilityYAML));
}
}
}
@@ -625,7 +629,7 @@
;
} else {
operationOM.setAbstract(Boolean.valueOf(String.valueOf(abstractYAML)));
- log("abstract="+Boolean.valueOf(String.valueOf(abstractYAML)));
+ log("abstract=" + Boolean.valueOf(String.valueOf(abstractYAML)));
}
Object visibilityYAML = collectElement((List) operationYAML, VISIBILITY);
@@ -633,7 +637,7 @@
;
} else {
operationOM.setVisibility(String.valueOf(visibilityYAML));
- log("visibility="+String.valueOf(visibilityYAML));
+ log("visibility=" + String.valueOf(visibilityYAML));
}
Object returnParameterYAML = collectElement((List) operationYAML, RETURN_PARAMETER);
@@ -643,7 +647,7 @@
ObjectModelParameterImpl parameterOM = new ObjectModelParameterImpl();
loadParameter(returnParameterYAML, parameterOM);
operationOM.setReturnParameter(parameterOM);
- log("returnParameter="+parameterOM.getType()+" loaded");
+ log("returnParameter=" + parameterOM.getType() + " loaded");
}
Object bodyCodeYAML = collectElement((List) operationYAML, BODY_CODE);
@@ -651,7 +655,7 @@
;
} else {
operationOM.setBodyCode(String.valueOf(bodyCodeYAML));
- log("bodyCode="+String.valueOf(bodyCodeYAML));
+ log("bodyCode=" + String.valueOf(bodyCodeYAML));
}
List parametersYAML = collectAllElements((List) operationYAML, PARAMETER);
@@ -659,7 +663,7 @@
ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
loadParameter(parameterYAML, parameterOM);
operationOM.addParameter(parameterOM);
- log("parameter="+parameterOM.getType()+" loaded");
+ log("parameter=" + parameterOM.getType() + " loaded");
}
}
}
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-06-11 10:11:42 UTC (rev 1271)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-06-11 12:16:35 UTC (rev 1272)
@@ -1,6 +1,9 @@
package org.nuiton.eugene.models.object.reader.yaml;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
/**
* User: agiraudet
@@ -84,223 +87,161 @@
return res;
}
- public static Object collectElementMap(Map data, Object key)
- {
- if(data.containsKey(key))
- {
+ public static Object collectElementMap(Map data, Object key) {
+ if (data.containsKey(key)) {
return data.get(key);
- }
- else
- {
+ } else {
return null;
}
}
// fonctionnel/robuste/optimise
- public static List<String> charParse(String str, Character target)
- {
+ public static List<String> charParse(String str, Character target) {
LinkedList<String> res = new LinkedList<String>();
- StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ StringBuilder tmp = new StringBuilder(str.length() + 1);//+1 utile en Java ? != C
boolean pre = false;
- for(Character c : str.toCharArray())
- {
- if(c.equals(target))
- {
- if(pre)
- {
+ for (Character c : str.toCharArray()) {
+ if (c.equals(target)) {
+ if (pre) {
res.add(tmp.toString());
}
- tmp.delete(0,tmp.length());
+ tmp.delete(0, tmp.length());
pre = false;
- }
- else
- {
+ } else {
tmp.append(c);
pre = true;
}
}
- if(pre)
- {
+ if (pre) {
res.add(tmp.toString());
}
return res;
}
// fonctionnel/robuste/optimise
- public static List<String> multiCharParse(String str, List<Character> targets)
- {
+ public static List<String> multiCharParse(String str, List<Character> targets) {
LinkedList<String> res = new LinkedList<String>();
- StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ StringBuilder tmp = new StringBuilder(str.length() + 1);//+1 utile en Java ? != C
boolean pre = false;
- for(Character c : str.toCharArray())
- {
- if(targets.contains(c))
- {
- if(pre)
- {
+ for (Character c : str.toCharArray()) {
+ if (targets.contains(c)) {
+ if (pre) {
res.add(tmp.toString());
}
- tmp.delete(0,tmp.length());
+ tmp.delete(0, tmp.length());
pre = false;
- }
- else
- {
+ } else {
tmp.append(c);
pre = true;
}
}
- if(pre)
- {
+ if (pre) {
res.add(tmp.toString());
}
return res;
}
- public static List<String> charParseIgnore(String str, Character target, Character ignoreStart, Character ignoreEnd)
- {
+ public static List<String> charParseIgnore(String str, Character target, Character ignoreStart, Character ignoreEnd) {
LinkedList<String> res = new LinkedList<String>();
- StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ StringBuilder tmp = new StringBuilder(str.length() + 1);//+1 utile en Java ? != C
boolean pre = false;
int ign = 0;//parentheses ouvertes
- for(Character c : str.toCharArray())
- {
- if(c.equals(ignoreStart))
- {
+ for (Character c : str.toCharArray()) {
+ if (c.equals(ignoreStart)) {
ign++;
tmp.append(c);
- }
- else if(c.equals(ignoreEnd))
- {
+ } else if (c.equals(ignoreEnd)) {
ign--;
tmp.append(c);
- }
- else if(c.equals(target) && ign < 1)
- {
- if(pre)
- {
+ } else if (c.equals(target) && ign < 1) {
+ if (pre) {
res.add(tmp.toString());
}
- tmp.delete(0,tmp.length());
+ tmp.delete(0, tmp.length());
pre = false;
- }
- else
- {
+ } else {
tmp.append(c);
pre = true;
}
}
- if(pre)
- {
+ if (pre) {
res.add(tmp.toString());
}
return res;
}
- public static List<String> charParseMultiIgnore(String str, Character target, List<Character> ignoreStart, List<Character> ignoreEnd)
- {
+ public static List<String> charParseMultiIgnore(String str, Character target, List<Character> ignoreStart, List<Character> ignoreEnd) {
LinkedList<String> res = new LinkedList<String>();
- StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ StringBuilder tmp = new StringBuilder(str.length() + 1);//+1 utile en Java ? != C
boolean pre = false;
int ign = 0;//parentheses ouvertes
- for(Character c : str.toCharArray())
- {
- if(ignoreStart.contains(c))
- {
+ for (Character c : str.toCharArray()) {
+ if (ignoreStart.contains(c)) {
ign++;
tmp.append(c);
- }
- else if(ignoreEnd.contains(c))
- {
+ } else if (ignoreEnd.contains(c)) {
ign--;
tmp.append(c);
- }
- else if(c.equals(target) && ign < 1)
- {
- if(pre)
- {
+ } else if (c.equals(target) && ign < 1) {
+ if (pre) {
res.add(tmp.toString());
}
- tmp.delete(0,tmp.length());
+ tmp.delete(0, tmp.length());
pre = false;
- }
- else
- {
+ } else {
tmp.append(c);
pre = true;
}
}
- if(pre)
- {
+ if (pre) {
res.add(tmp.toString());
}
return res;
}
- public static String removeMultiChar(String str, List<Character> targets)
- {
- StringBuilder res = new StringBuilder(str.length()+1);
- for(Character c : str.toCharArray())
- {
- if(!targets.contains(c))
- {
+ public static String removeMultiChar(String str, List<Character> targets) {
+ StringBuilder res = new StringBuilder(str.length() + 1);
+ for (Character c : str.toCharArray()) {
+ if (!targets.contains(c)) {
res.append(c);
}
}
return res.toString();
}
- public static String extract(Character start, Character end, String str)
- {
- StringBuilder tmp = new StringBuilder(str.length()+1);
+ public static String extract(Character start, Character end, String str) {
+ StringBuilder tmp = new StringBuilder(str.length() + 1);
boolean start_end = false;
int count = 0;
- for(Character c : str.toCharArray())
- {
- if(!start_end && c.equals(start))
- {
+ for (Character c : str.toCharArray()) {
+ if (!start_end && c.equals(start)) {
start_end = true;
- }
- else if(start_end && c.equals(start))
- {
+ } else if (start_end && c.equals(start)) {
count++;
tmp.append(c);
- }
- else if(start_end && c.equals(end))
- {
- if(count>0)
- {
+ } else if (start_end && c.equals(end)) {
+ if (count > 0) {
count--;
tmp.append(c);
- }
- else
- {
+ } else {
return tmp.toString();
}
- }
- else if(start_end)
- {
+ } else if (start_end) {
tmp.append(c);
}
}
return null;
}
- public static String extract(Character startend, String str)
- {
- StringBuilder tmp = new StringBuilder(str.length()+1);
+ public static String extract(Character startend, String str) {
+ StringBuilder tmp = new StringBuilder(str.length() + 1);
boolean start_end = false;
- for(Character c : str.toCharArray())
- {
- if(!start_end && c.equals(startend))
- {
+ for (Character c : str.toCharArray()) {
+ if (!start_end && c.equals(startend)) {
start_end = true;
- }
- else if(start_end && c.equals(startend))
- {
+ } else if (start_end && c.equals(startend)) {
return tmp.toString();
- }
- else if(start_end)
- {
+ } else if (start_end) {
tmp.append(c);
}
}
@@ -322,11 +263,10 @@
//System.out.println(beforeChar("11..**",'.'));
//System.out.println(afterChar("11..**",'.'));
//System.out.println(afterChar("java.lang.String",'.'));
- List<String> test = charParseIgnore("Map<String,String,String>",',','<','>');
- for(String str : test)
- {
+ List<String> test = charParseIgnore("Map<String,String,String>", ',', '<', '>');
+ for (String str : test) {
System.out.println(str);
}
- System.out.println(extract('<','>',"<<<>>>"));
+ System.out.println(extract('<', '>', "<<<>>>"));
}
}
1
0
r1271 - in trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader: . yaml
by agiraudet@users.nuiton.org 11 Jun '13
by agiraudet@users.nuiton.org 11 Jun '13
11 Jun '13
Author: agiraudet
Date: 2013-06-11 12:11:42 +0200 (Tue, 11 Jun 2013)
New Revision: 1271
Url: http://nuiton.org/projects/eugene/repository/revisions/1271
Log:
r?\195?\169?\195?\169criture du parser yaml (optimisation, plus propre)
Added:
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/LoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.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/YamlObjectModelReader.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/YamlObjectModelReader.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/YamlObjectModelReader.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/YamlObjectModelReader.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -29,8 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.ModelHelper;
import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.reader.yaml.TestLoadYamlFile;
-import org.nuiton.eugene.models.object.reader.yaml.YamlToObjectModel;
+import org.nuiton.eugene.models.object.reader.yaml.LoadYamlFile;
import org.yaml.snakeyaml.error.YAMLException;
import java.io.File;
@@ -47,7 +46,7 @@
private static final Log log = LogFactory.getLog(YamlObjectModelReader.class);
//protected YamlToObjectModel yamlToObjectModel;
- protected TestLoadYamlFile test;
+ protected LoadYamlFile test;
@Override
public String getInputType() {
@@ -58,14 +57,14 @@
protected void beforeReadFile(File... files) {
super.beforeReadFile(files);
//yamlToObjectModel = new YamlToObjectModel();
- test = new TestLoadYamlFile();
+ test = new LoadYamlFile();
}
@Override
protected void readFileToModel(File file, ObjectModel model) throws IOException {
try {
//yamlToObjectModel.loadFile(file,model);
- test.LoadYamlFile(file,model);
+ test.loadFile(file,model);
} catch (YAMLException e) {
throw new IOException("Unable to parse ObjectModel input file : " + file, e);
}
Added: 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 (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -0,0 +1,539 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import org.nuiton.eugene.models.object.xml.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 11/06/13
+ * Time: 10:37
+ */
+public class LoadObjectModel extends KeyWords {
+ protected String packageL;
+ protected YamlObject modelYAMLO;
+ protected ObjectModelImpl modelOM;
+
+ public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM)
+ {
+ this.packageL = "default";
+ this.modelOM = modelOM;
+ this.modelYAMLO = modelYAMLO;
+ //log
+ //Log.initLog(modelYAMLO.toString(),"/tmp/log.LoadObjectModel.txt");
+ //log
+ }
+
+ public void loadModel() {
+ String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
+ if(packageYAMLO == null)
+ {
+ //valeur par defaut
+ }
+ else
+ {
+ packageL = packageYAMLO;
+ }
+
+ String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
+ if(nameYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ modelOM.setName(nameYAMLO);
+ }
+
+ String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
+ if(versionYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ modelOM.setVersion(versionYAMLO);
+ }
+
+ //tageValues
+ //TODO: tester
+ YamlObject tagValues = modelYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
+ if(tagValues != null)
+ {
+ for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
+ {
+ if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ {
+ modelOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ }
+ }
+ }
+
+ //classes
+ for(YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS))
+ {
+ ObjectModelClassImpl classOM = new ObjectModelClassImpl();
+ loadClass(classYAMLO,classOM);
+ modelOM.addClass(classOM);
+ }
+ //interfaces
+ for(YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE))
+ {
+ ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
+ loadInterface(interfaceYAMLO,interfaceOM);
+ modelOM.addInterface(interfaceOM);
+ }
+ //classes d'association
+ for(YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS))
+ {
+ ObjectModelAssociationClassImpl associationClassOM = new ObjectModelAssociationClassImpl();
+ loadAssociationClass(associationClassYAMLO,associationClassOM);
+ modelOM.addAssociationClass(associationClassOM);
+ }
+ //enumerations
+ for(YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION))
+ {
+ ObjectModelEnumerationImpl enumerationOM = new ObjectModelEnumerationImpl();
+ loadEnumeration(enumerationYAMLO,enumerationOM);
+ modelOM.addEnumeration(enumerationOM);
+ }
+ }
+
+ public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM)
+ {
+ String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
+ if(nameYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ elementOM.setName(nameYAMLO);
+ }
+
+ String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
+ if(staticYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ elementOM.setStatic(Boolean.valueOf(staticYAMLO));
+ }
+
+ String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
+ if(documentationYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ elementOM.setDocumentation(documentationYAMLO);
+ }
+
+ //TODO: tester
+ YamlObject tagValues = elementYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
+ if(tagValues != null)
+ {
+ for(Map.Entry<String,List<String>> tagValue :tagValues.getMapStringListString().entrySet())
+ {
+ if(!tagValue.getValue().isEmpty())//taille strictement = 1
+ {
+ elementOM.addTagValue(tagValue.getKey(),tagValue.getValue().get(0));
+ }
+ }
+ }
+
+ List<String> comments = elementYAMLO.getMapStringListString(COMMENTS);
+ for(String comment : comments)
+ {
+ elementOM.addComment(comment);
+ }
+
+ List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
+ for(String stereotype : stereotypes)
+ {
+ ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
+ stereotypeOM.setName(stereotype);
+ elementOM.addStereotype(stereotypeOM);
+ }
+ }
+
+ public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM)
+ {
+ loadElement(classifierYAMLO, classifierOM);
+
+ String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
+ if(packageYAMLO == null)
+ {
+ classifierOM.setPackage(packageL);
+ }
+ else
+ {
+ classifierOM.setPackage(packageYAMLO);
+ }
+
+
+ String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
+ if(externYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ classifierOM.setExtern(Boolean.valueOf(externYAMLO));
+
+ }
+
+ String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
+ if(innerYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ classifierOM.setInner(Boolean.valueOf(innerYAMLO));
+ }
+
+ String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
+ if(typeYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ classifierOM.setType(typeYAMLO);
+ }
+
+ for(YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
+ loadAttribute(attributeYAMLO,attributeOM);
+ classifierOM.addAttribute(attributeOM);
+ }
+
+ for(YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION))
+ {
+ ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
+ loadOperation(operationYAMLO,operationOM);
+ classifierOM.addOperation(operationOM);
+ }
+
+ List<String> superInterfacesYAMLO = classifierYAMLO.getMapStringListString(SUPER_INTERFACES);
+ for(String superInterfaceYAMLO : superInterfacesYAMLO)
+ {
+ ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
+ superInterfaceOM.setName(superInterfaceYAMLO);
+ classifierOM.addInterface(superInterfaceOM);
+ }
+ }
+
+ public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM)
+ {
+ loadClassifier(classYAMLO, classOM);
+
+ String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
+ if(abstractYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ classOM.setAbstract(Boolean.valueOf(abstractYAMLO));
+ }
+
+ List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
+ for(String superClassYAMLO : superClassesYAMLO)
+ {
+ ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
+ superClassOM.setName(superClassYAMLO);
+ classOM.addSuperclass(superClassOM);
+ }
+ }
+
+ public void loadInterface(YamlObject interfaceYAMLO, ObjectModelInterfaceImpl interfaceOM)
+ {
+ loadClassifier(interfaceYAMLO,interfaceOM);
+ }
+
+ public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM)
+ {
+ loadClass(associationClassYAML, associationClassOM);
+
+ //TODO: remplacer name par type et attribute par name ?
+ for(YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT))
+ {
+ ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
+ participantOM.setAssociationClass(associationClassOM);
+
+ String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
+ if(nameYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ participantOM.setName(nameYAMLO);
+ }
+
+ String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
+ if(attributeYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ participantOM.setAttribute(attributeYAMLO);
+ }
+
+ associationClassOM.addParticipant(participantOM);
+ }
+ }
+
+ public void loadEnumeration(YamlObject enumerationYAMLO, ObjectModelEnumerationImpl enumerationOM)
+ {
+ loadElement(enumerationYAMLO, enumerationOM);
+
+ //TODO: remplacer LITERAL par LITERALS (List)
+ List<String> literalsYAMLO = enumerationYAMLO.getMapStringListString(LITERAL);
+ for(String literalYAMLO : literalsYAMLO)
+ {
+ ObjectModelImplRef literalOM = new ObjectModelImplRef();
+ literalOM.setName(literalYAMLO);
+ enumerationOM.addLiteral(literalOM);
+ }
+
+ String packageYAMLO = enumerationYAMLO.getFirstMapStringListString(PACKAGE);
+ if(packageYAMLO == null)
+ {
+ enumerationOM.setPackage(packageL);
+ }
+ else
+ {
+ enumerationOM.setPackage(packageYAMLO);
+ }
+ }
+
+ public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM)
+ {
+ loadElement(parameterYAMLO,parameterOM);
+
+ String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
+ if(orderingYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setOrdering(orderingYAMLO);
+ }
+
+ String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
+ if(typeYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setType(typeYAMLO);
+ }
+
+ String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
+ if(defaultValueYAMLO == null)
+ {
+ ;//default
+ }
+ else
+ {
+ parameterOM.setDefaultValue(defaultValueYAMLO);
+ }
+
+ String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
+ if(minMultiplicityYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
+ }
+
+ String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
+ if(maxMultiplicityYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setMaxMultiplicity(Integer.valueOf(maxMultiplicityYAMLO));
+
+ }
+
+ String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
+ if(orderedYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
+ }
+
+ String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
+ if(uniqueYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ parameterOM.setUnique(Boolean.valueOf(uniqueYAMLO));
+ }
+ }
+
+ public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM)
+ {
+ loadParameter(attributeYAMLO,attributeOM);
+
+ String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
+ if(navigableYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setNavigable(Boolean.valueOf(navigableYAMLO));
+ }
+
+ String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
+ if(associationTypeYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setAssociationType(associationTypeYAMLO);
+ }
+
+ String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
+ if(finalYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
+ }
+
+ String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
+ if(staticYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
+ }
+
+ String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
+ if(associationClassNameYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setAssociationClassName(associationClassNameYAMLO);
+ }
+
+ String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
+ if(reverseAttributeNameYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
+ }
+
+ String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
+ if(reverseMaxMultiplicityYAMLO == null)
+ {
+ //test
+ attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
+ //test
+ }
+ else
+ {
+ attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
+ }
+
+ String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
+ if(transientYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
+ }
+
+ String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
+ if(visibilityYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ attributeOM.setVisibility(visibilityYAMLO);
+ }
+ }
+
+ public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM)
+ {
+ loadElement(operationYAMLO,operationOM);
+
+ String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
+ if(abstractYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ operationOM.setAbstract(Boolean.valueOf(abstractYAMLO));
+ }
+
+ String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
+ if(visibilityYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ operationOM.setVisibility(visibilityYAMLO);
+ }
+
+ for(YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
+ {
+ ObjectModelParameterImpl returnParameterOM = new ObjectModelAttributeImpl();
+ loadParameter(returnParameterYAMLO,returnParameterOM);
+ operationOM.setReturnParameter(returnParameterOM);
+ }
+
+ for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
+ {
+ ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
+ loadParameter(parameterYAMLO,parameterOM);
+ operationOM.addParameter(parameterOM);
+ }
+
+ String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
+ if(bodyCodeYAMLO == null)
+ {
+ ;//valeur par defaut
+ }
+ else
+ {
+ operationOM.setBodyCode(bodyCodeYAMLO);
+ }
+ }
+}
Added: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -0,0 +1,75 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.xml.ObjectModelImpl;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 10/06/13
+ * Time: 16:11
+ */
+public class LoadYamlFile extends KeyWords {
+ Yaml yaml;
+
+ public LoadYamlFile()
+ {
+ yaml = new Yaml();
+ }
+
+ public void loadFile(File file, ObjectModel model) throws IOException
+ {
+ InputStream inputModel = new FileInputStream(file);
+ Object modelYAML = yaml.load(inputModel);
+ inputModel.close();
+
+ ObjectModelImpl modelOM = (ObjectModelImpl) model;
+ YamlObject modelYAMLO = new YamlObject();
+
+ Object version = null;
+ String syntaxeVersion = "0";
+ String defaultVersion = "0";
+
+ if(modelYAML instanceof List)
+ {
+ version = YamlUtil.collectElementList((List) modelYAML, SYNTAXE);
+ syntaxeVersion = "1";
+ defaultVersion = "0";
+ }
+ else if(modelYAML instanceof Map)
+ {
+ version = YamlUtil.collectElementMap((Map) modelYAML, SYNTAXE);
+ syntaxeVersion = "2";
+ defaultVersion = "0";
+ }
+
+ if(version != null)
+ {
+ syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version),'.');
+ defaultVersion = YamlUtil.afterChar(String.valueOf(version),'.');
+ }
+
+ if(syntaxeVersion.equals("1"))
+ {
+ SyntaxePureYaml.loadYamlObject(modelYAML,modelYAMLO);
+ }
+ else if(syntaxeVersion.equals("2"))
+ {
+ SyntaxeUserFriendly.loadYamlObject(modelYAML,modelYAMLO);
+ }
+ else
+ {
+ ;//impossible de charger le modele
+ }
+
+ LoadObjectModel loader = new LoadObjectModel(modelYAMLO,modelOM);//+defaultVersion
+ loader.loadModel();
+ }
+}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -20,6 +20,7 @@
* methode2 : syntaxe moins restrictive, supprimer les élément et en déduir les restant
* methode3 : la methode3 (ninja hybride)
*/
+@Deprecated
public class Parser extends KeyWords {
private static boolean _loginit = true;
Added: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -0,0 +1,39 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 11/06/13
+ * Time: 10:25
+ */
+public class ParserPureYaml {
+
+ public static void parseModel(Object modelYAML, YamlObject modelYAMLO)
+ {
+ if(modelYAML instanceof List)
+ {
+ for(Object tmp1 : (List) modelYAML)
+ {
+ parseModel(tmp1, modelYAMLO);
+ }
+ }
+ else if(modelYAML instanceof Map)
+ {
+ for(Object tmp1 : ((Map) modelYAML).entrySet())
+ {
+ if(((Map.Entry) tmp1).getValue() instanceof List || ((Map.Entry) tmp1).getValue() instanceof Map)
+ {
+ YamlObject tmp2 = new YamlObject();
+ parseModel(((Map.Entry) tmp1).getValue(),tmp2);
+ modelYAMLO.addYamlObjectToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(), tmp2);
+ }
+ else
+ {
+ modelYAMLO.addStringToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(), String.valueOf(((Map.Entry) tmp1).getValue()));
+ }
+ }
+ }
+ }
+}
Added: 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 (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -0,0 +1,990 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 10/06/13
+ * Time: 16:48
+ */
+public class ParserUserFriendly extends KeyWords {
+ protected Map<String,String> imports;
+ protected Map<String,String> importsI;
+ protected Map<String,String> importsE;
+ protected String packageM;
+ protected Object modelYAML;
+ protected YamlObject modelYAMLO;
+
+ public ParserUserFriendly(Object modelYAML, YamlObject modelYAMLO)
+ {
+ this.imports = new LinkedHashMap<String, String>();
+ this.importsI = new LinkedHashMap<String, String>();
+ this.importsE = new LinkedHashMap<String, String>();
+ this.packageM = "default";
+ this.modelYAML = modelYAML;
+ this.modelYAMLO = modelYAMLO;
+ }
+
+ public void parseModel()
+ {
+ if(modelYAML instanceof Map)
+ {
+ for(Object entry : ((Map) modelYAML).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String key = String.valueOf(((Map.Entry) entry).getKey());
+ Object value = ((Map.Entry) entry).getValue();
+ if(key.equals(PACKAGE))
+ {
+ modelYAMLO.addStringToMap(PACKAGE,String.valueOf(value));
+ packageM = String.valueOf(value);
+ }
+
+ if(key.equals(NAME))
+ {
+ modelYAMLO.addStringToMap(NAME,String.valueOf(value));
+ }
+
+ if(key.equals(VERSION))
+ {
+ modelYAMLO.addStringToMap(VERSION,String.valueOf(value));
+ }
+
+ if(key.equals(IMPORTS))
+ {
+ if(value instanceof List)
+ {
+ for(Object imp : (List) value)
+ {
+ //modelYAMLO.addStringToMap(IMPORTS,String.valueOf(imp));
+ importsE.put(YamlUtil.afterChar(String.valueOf(imp),'.'),String.valueOf(imp));
+ }
+ }
+ }
+
+ List<String> tmp = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(tmp.contains(CLASS))
+ { YamlObject classYAMLO = new YamlObject();
+ parseClass(key,value,classYAMLO);
+ modelYAMLO.addYamlObjectToMap(CLASS,classYAMLO);
+ }
+ else if(tmp.contains(INTERFACE))
+ {
+ YamlObject interfaceYAMLO = new YamlObject();
+ parseInterface(key,value,interfaceYAMLO);
+ modelYAMLO.addYamlObjectToMap(INTERFACE,interfaceYAMLO);
+ }
+ else if(tmp.contains(ASSOCIATION_CLASS))
+ {
+ YamlObject associationClassYAMLO = new YamlObject();
+ parseAssociationClass(key,value,associationClassYAMLO);
+ modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS,associationClassYAMLO);
+ }
+ else if(tmp.contains(ENUMERATION))
+ {
+ YamlObject enumerationYAMLO = new YamlObject();
+ parseEnumeration(key,value,enumerationYAMLO);
+ modelYAMLO.addYamlObjectToMap(ENUMERATION,enumerationYAMLO);
+ }
+ }
+ }
+ }
+ }
+
+ public void parseClass(String key, Object value, YamlObject classYAMLO)
+ {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(classPARSE.contains(CLASS))
+ {
+ classPARSE.remove(classPARSE.indexOf(CLASS));
+ }
+ if(classPARSE.contains(ABSTRACT))
+ {
+ classYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(ABSTRACT));
+ }
+ if(classPARSE.contains(STATIC))
+ {
+ classYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(STATIC));
+ }
+ if(classPARSE.contains(EXTERN))
+ {
+ classYAMLO.addStringToMap(EXTERN,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(EXTERN));
+ }
+ if(classPARSE.contains(INNER))
+ {
+ classYAMLO.addStringToMap(INNER,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(INNER));
+ }
+ if(classPARSE.contains(PUBLIC))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ classPARSE.remove(classPARSE.indexOf(PUBLIC));
+ }
+ else if(classPARSE.contains(PRIVATE))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ classPARSE.remove(classPARSE.indexOf(PRIVATE));
+ }
+ else if(classPARSE.contains(PROTECTED))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ classPARSE.remove(classPARSE.indexOf(PROTECTED));
+ }
+
+ for(String str1 : classPARSE)
+ {
+ if(str1.contains("<<") && str1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String str2 = YamlUtil.removeMultiChar(str1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> list = YamlUtil.multiCharParse(str2, targets);
+ for(String str3 : list)
+ {
+ classYAMLO.addStringToMap(STEREOTYPES, str3);
+ }
+ }
+ }
+
+ if(classPARSE.size() > 0)
+ {
+ String name = classPARSE.get(0);
+ classYAMLO.addStringToMap(NAME, name);
+ importsI.put(name,packageM+"."+name);
+ }
+
+ if(value instanceof Map)
+ {
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ classYAMLO.addStringToMap(SUPER_CLASSES,String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ classYAMLO.addStringToMap(SUPER_INTERFACES,String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ classYAMLO.addYamlObjectToMap(OPERATION,operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ classYAMLO.addYamlObjectToMap(ATTRIBUTE,attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //TODO: factoriser le code (classifier)
+ public void parseInterface(String key, Object value, YamlObject interfaceYAMLO)
+ {
+ List<String> interfacePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(interfacePARSE.contains(INTERFACE))
+ {
+ interfacePARSE.remove(interfacePARSE.indexOf(INTERFACE));
+ }
+ if(interfacePARSE.contains(ABSTRACT))
+ {
+ interfaceYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
+ interfacePARSE.remove(interfacePARSE.indexOf(ABSTRACT));
+ }
+ if(interfacePARSE.contains(STATIC))
+ {
+ interfaceYAMLO.addStringToMap(STATIC, String.valueOf(true));
+ interfacePARSE.remove(interfacePARSE.indexOf(STATIC));
+ }
+ if(interfacePARSE.contains(EXTERN))
+ {
+ interfaceYAMLO.addStringToMap(EXTERN, String.valueOf(true));
+ interfacePARSE.remove(interfacePARSE.indexOf(EXTERN));
+ }
+ if(interfacePARSE.contains(INNER))
+ {
+ interfaceYAMLO.addStringToMap(INNER, String.valueOf(true));
+ interfacePARSE.remove(interfacePARSE.indexOf(INNER));
+ }
+ if(interfacePARSE.contains(PUBLIC))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PUBLIC);
+ interfacePARSE.remove(interfacePARSE.indexOf(PUBLIC));
+ }
+ else if(interfacePARSE.contains(PRIVATE))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PRIVATE);
+ interfacePARSE.remove(interfacePARSE.indexOf(PRIVATE));
+ }
+ else if(interfacePARSE.contains(PROTECTED))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PROTECTED);
+ interfacePARSE.remove(interfacePARSE.indexOf(PROTECTED));
+ }
+
+ for(String str1 : interfacePARSE)
+ {
+ if(str1.contains("<<") && str1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String str2 = YamlUtil.removeMultiChar(str1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> list = YamlUtil.multiCharParse(str2, targets);
+ for(String str3 : list)
+ {
+ interfaceYAMLO.addStringToMap(STEREOTYPES, str3);
+ }
+ }
+ }
+
+ if(interfacePARSE.size() > 0)
+ {
+ String name = interfacePARSE.get(0);
+ interfaceYAMLO.addStringToMap(NAME, name);
+ importsI.put(name,packageM+"."+name);
+ }
+
+ if(value instanceof Map)
+ {
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ interfaceYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ interfaceYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ interfaceYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ interfaceYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void parseAssociationClass(String key, Object value, YamlObject associationClassYAMLO)
+ {
+ List<String> associationClassPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(associationClassPARSE.contains(ASSOCIATION_CLASS))
+ {
+ associationClassPARSE.remove(associationClassPARSE.indexOf(ASSOCIATION_CLASS));
+ }
+ if(associationClassPARSE.contains(ABSTRACT))
+ {
+ associationClassYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
+ associationClassPARSE.remove(associationClassPARSE.indexOf(ABSTRACT));
+ }
+ if(associationClassPARSE.contains(STATIC))
+ {
+ associationClassYAMLO.addStringToMap(STATIC, String.valueOf(true));
+ associationClassPARSE.remove(associationClassPARSE.indexOf(STATIC));
+ }
+ if(associationClassPARSE.contains(EXTERN))
+ {
+ associationClassYAMLO.addStringToMap(EXTERN, String.valueOf(true));
+ associationClassPARSE.remove(associationClassPARSE.indexOf(EXTERN));
+ }
+ if(associationClassPARSE.contains(INNER))
+ {
+ associationClassYAMLO.addStringToMap(INNER, String.valueOf(true));
+ associationClassPARSE.remove(associationClassPARSE.indexOf(INNER));
+ }
+ if(associationClassPARSE.contains(PUBLIC))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PUBLIC);
+ associationClassPARSE.remove(associationClassPARSE.indexOf(PUBLIC));
+ }
+ else if(associationClassPARSE.contains(PRIVATE))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PRIVATE);
+ associationClassPARSE.remove(associationClassPARSE.indexOf(PRIVATE));
+ }
+ else if(associationClassPARSE.contains(PROTECTED))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PROTECTED);
+ associationClassPARSE.remove(associationClassPARSE.indexOf(PROTECTED));
+ }
+
+ for(String str1 : associationClassPARSE)
+ {
+ if(str1.contains("<<") && str1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String str2 = YamlUtil.removeMultiChar(str1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> list = YamlUtil.multiCharParse(str2, targets);
+ for(String str3 : list)
+ {
+ associationClassYAMLO.addStringToMap(STEREOTYPES, str3);
+ }
+ }
+ }
+
+ if(associationClassPARSE.size() > 0)
+ {
+ String name = associationClassPARSE.get(0);
+ associationClassYAMLO.addStringToMap(NAME, name);
+ importsI.put(name,packageM+"."+name);
+ }
+
+ if(value instanceof Map)
+ {
+ //TODO: utiliser variable locales pour plus de clartee
+ if(((Map) value).containsKey(PARTICIPANT))
+ {
+ if(((Map) value).get(PARTICIPANT) instanceof Map)
+ {
+ for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
+ YamlObject participantYAMLO = new YamlObject();
+ if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
+ {
+ String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
+
+ participantYAMLO.addStringToMap(LABEL,label);
+
+ participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
+ }
+
+ if(participantPARSE.size() > 0)//ajout type
+ {
+ participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
+ }
+ if(participantPARSE.size() > 1)//ajout name
+ {
+ participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
+ }
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+ }
+ }
+ }
+ ((Map) value).remove(PARTICIPANT);
+ }
+
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ associationClassYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ associationClassYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO)
+ {
+ List<String> enumerationPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(enumerationPARSE.contains(ENUMERATION))
+ {
+ enumerationPARSE.remove(enumerationPARSE.indexOf(ENUMERATION));
+ }
+ if(enumerationPARSE.contains(STATIC))
+ {
+ enumerationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ enumerationPARSE.remove(enumerationPARSE.indexOf(STATIC));
+ }
+
+ for(String str1 : enumerationPARSE)
+ {
+ if(str1.contains("<<") && str1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String str2 = YamlUtil.removeMultiChar(str1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> list = YamlUtil.multiCharParse(str2, targets);
+ for(String str3 : list)
+ {
+ enumerationYAMLO.addStringToMap(STEREOTYPES, str3);
+ }
+ }
+ }
+ if(enumerationPARSE.size() > 0)
+ {
+ String name = enumerationPARSE.get(0);
+ enumerationYAMLO.addStringToMap(NAME, name);
+ importsI.put(name,packageM+"."+name);
+ }
+ //TODO: parser literals
+ }
+
+ //TODO: factoriser code
+ /*public void parseClassifier(String type, String key, Object value, YamlObject classYAMLO)
+ {
+ ;
+ }*/
+
+ public void parseAttribute(String key, Object value, YamlObject attributeYAMLO)
+ {
+ List<String> attributePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(attributePARSE.contains(STATIC))
+ {
+ attributeYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(STATIC));
+ }
+ if(attributePARSE.contains(FINAL))
+ {
+ attributeYAMLO.addStringToMap(FINAL,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(FINAL));
+ }
+ if(attributePARSE.contains(UNIQUE))
+ {
+ attributeYAMLO.addStringToMap(UNIQUE,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(UNIQUE));
+ }
+ if(attributePARSE.contains(NAVIGABLE))
+ {
+ attributeYAMLO.addStringToMap(NAVIGABLE,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(NAVIGABLE));
+ }
+ if(attributePARSE.contains(TRANSIENT))
+ {
+ attributeYAMLO.addStringToMap(TRANSIENT,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(TRANSIENT));
+ }
+ if(attributePARSE.contains(PUBLIC))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+ else if(attributePARSE.contains(PROTECTED))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+ else if(attributePARSE.contains(PRIVATE))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+
+ if(attributePARSE.contains(ORDERED))
+ {
+ attributeYAMLO.addStringToMap(ORDERING,ORDERED);
+ attributePARSE.remove(attributePARSE.indexOf(ORDERED));
+ }
+ else if(attributePARSE.contains(UNORDERED))
+ {
+ attributeYAMLO.addStringToMap(ORDERING,UNORDERED);
+ attributePARSE.remove(attributePARSE.indexOf(UNORDERED));
+ }
+
+ //TODO: utiliser variables locales
+ if(attributePARSE.contains("\""+YamlUtil.extract('"',key)+"\""))
+ {
+ String label = YamlUtil.extract('"',key);
+ attributeYAMLO.addStringToMap(LABEL,label);
+ attributePARSE.remove("\""+YamlUtil.extract('"',key)+"\"");
+ }
+
+ if(attributePARSE.contains("["+YamlUtil.extract('[',']',key)+"]"))
+ {
+ String multiplicity = YamlUtil.extract('[',']',key);
+ if(multiplicity.equals("*"))
+ {
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,"0");
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,"-1");
+ }
+ else if(multiplicity.contains(".."))
+ {
+ String min = YamlUtil.beforeChar(multiplicity,'.');
+ String max = YamlUtil.afterChar(multiplicity, '.');
+ if(min.equals("*"))
+ {
+ min = "-1";
+ }
+ if(max.equals("*"))
+ {
+ max = "-1";
+ }
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,min);
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,max);
+ }
+ attributePARSE.remove("["+YamlUtil.extract('[',']',key)+"]");
+ }
+
+ if(attributePARSE.size() > 0)
+ {
+ attributeYAMLO.addStringToMap(TYPE,attributePARSE.get(0));
+ }
+ if(attributePARSE.size() > 1)
+ {
+ attributeYAMLO.addStringToMap(NAME,attributePARSE.get(1));
+ }
+ }
+
+ public void parseOperation(String key, Object value, YamlObject operationYAMLO)
+ {
+ List<Character> ignoreStart = new LinkedList<Character>();
+ ignoreStart.add('(');
+ ignoreStart.add('<');
+ List<Character> ignoreEnd = new LinkedList<Character>();
+ ignoreEnd.add(')');
+ ignoreEnd.add('>');
+ List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key,' ',ignoreStart,ignoreEnd);
+
+ if(operationPARSE.contains(STATIC))
+ {
+ operationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ operationPARSE.remove(operationPARSE.indexOf(STATIC));
+ }
+ if(operationPARSE.contains(ABSTRACT))
+ {
+ operationYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ operationPARSE.remove(operationPARSE.indexOf(ABSTRACT));
+ }
+ if(operationPARSE.contains(PUBLIC))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ operationPARSE.remove(operationPARSE.indexOf(PUBLIC));
+ }
+ else if(operationPARSE.contains(PROTECTED))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ operationPARSE.remove(operationPARSE.indexOf(PROTECTED));
+ }
+ else if(operationPARSE.contains(PRIVATE))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ operationPARSE.remove(operationPARSE.indexOf(PRIVATE));
+ }
+
+ for(String str1 : operationPARSE)
+ {
+ if(str1.contains("(") && str1.contains(")"))
+ {
+ operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(str1,'('));
+ for(String str2 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', str1), ',', '<', '>'))
+ {
+ List<String> list = YamlUtil.charParse(str2,' ');
+ if(list.size() == 2)
+ {
+ YamlObject parameterYAMLO = new YamlObject();
+ parameterYAMLO.addStringToMap(TYPE, list.get(0));
+ parameterYAMLO.addStringToMap(NAME, list.get(1));
+ operationYAMLO.addYamlObjectToMap(PARAMETER, parameterYAMLO);
+ }
+ }
+ }
+ }
+
+ if(value != null)
+ {
+ YamlObject returnParameterYAMLO = new YamlObject();
+ returnParameterYAMLO.addStringToMap(TYPE,String.valueOf(value));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+ }
+ }
+
+ public void resolveImports()
+ {
+ imports.putAll(importsE);
+ imports.putAll(importsI);
+ for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
+ {
+ for(YamlObject importable : entry.getValue())
+ {
+ if(importable.containsKeyMapStringListString(SUPER_CLASSES))
+ {
+ for(String value : importable.getMapStringListString(SUPER_CLASSES))
+ {
+ if(imports.containsKey(value))
+ {
+ importable.setMapStringListString(SUPER_CLASSES,value,imports.get(value));
+ }
+ }
+ }
+ if(importable.containsKeyMapStringListString(SUPER_INTERFACES))
+ {
+ for(String value : importable.getMapStringListString(SUPER_INTERFACES))
+ {
+ if(imports.containsKey(value))
+ {
+ importable.setMapStringListString(SUPER_INTERFACES,value,imports.get(value));
+ }
+ }
+ }
+ if(importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ for(YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ if(attributeYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(attributeYAMLO.getFirstMapStringListString(TYPE)));
+ }
+ }
+ }
+ if(importable.containsKeyYamlMapStringListYamlObject(OPERATION))
+ {
+ for(YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION))
+ {
+ if(operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER))
+ {
+ for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
+ {
+ if(parameterYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
+ }
+ }
+ }
+ if(operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER))
+ {
+ for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
+ {
+ if(parameterYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE)));
+ }
+ }
+ }
+ }
+ }
+ if(importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
+ {
+ for(YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT))
+ {
+ if(participantYAMLO.containsKeyMapStringListString(NAME))
+ {
+ participantYAMLO.setMapStringListString(NAME,participantYAMLO.getFirstMapStringListString(NAME),resolveType(participantYAMLO.getFirstMapStringListString(NAME)));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public 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,'<');
+ if(imports.containsKey(ninja))
+ {
+ res.append(imports.get(ninja));
+ }
+ else
+ {
+ res.append(tmp);
+ }
+ res.append("<");
+ res.append(browseType(YamlUtil.extract('<','>',tmp)));
+ res.append(">");
+ }
+ else
+ {
+ if(imports.containsKey(tmp))
+ {
+ res.append(imports.get(tmp));
+ }
+ else
+ {
+ res.append(tmp);
+ }
+ }
+ }
+ return res.toString();
+ }
+
+ public String resolveType(String type)
+ {
+ List<Character> ignore = new LinkedList<Character>();
+ ignore.add(' ');
+ String typePARSE = YamlUtil.removeMultiChar(type,ignore);
+ return browseType(typePARSE);
+ }
+
+ public void resolveLabels()
+ {
+ for(List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values())
+ {
+ for(YamlObject labelisable : objectYAMLO)
+ {
+ if(labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ for(YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ if(attribute.containsKeyMapStringListString(TYPE))
+ {
+ String type = attribute.getFirstMapStringListString(TYPE);
+ if(importsI.containsValue(type))
+ {
+ if(!attribute.containsKeyMapStringListString(NAVIGABLE))
+ {
+ if(attribute.containsKeyMapStringListString(LABEL))
+ {
+ String label = attribute.getFirstMapStringListString(LABEL);
+ YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(type,'.'),label);
+ if(reverseAttribute != null)
+ {
+ attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(attribute.containsKeyMapStringListString(NAME))
+ {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ }
+ if(reverseAttribute.containsKeyMapStringListString(NAME))
+ {
+ attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,reverseAttribute.getFirstMapStringListString(NAME));
+ }
+ }
+ }
+ else
+ {
+ YamlObject reverseObject = getReverseObject(YamlUtil.afterChar(type,'.'));
+ if(reverseObject != null)
+ {
+ YamlObject reverseAttribute = new YamlObject();
+ reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(false));
+ reverseAttribute.addStringToMap(TYPE,imports.get(labelisable.getFirstMapStringListString(NAME)));
+ if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(attribute.containsKeyMapStringListString(NAME))
+ {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ }
+ if(attribute.containsKeyMapStringListString(ORDERING))
+ {
+ if(attribute.getFirstMapStringListString(ORDERING).equals(ORDERED))
+ {
+ reverseAttribute.addStringToMap(ORDERING,UNORDERED);
+ }
+ else if(attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED))
+ {
+ reverseAttribute.addStringToMap(ORDERING,ORDERED);
+ }
+ }
+ reverseObject.addYamlObjectToMap(ATTRIBUTE,reverseAttribute);
+
+ attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ }
+ }
+ }
+ }
+ /*else//simple attribut
+ {
+ ;
+ }*/
+ }
+ }
+ }
+ if(labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
+ {
+ for(YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT))
+ {
+ if(participant.containsKeyMapStringListString(NAME))
+ {
+ String name = participant.getFirstMapStringListString(NAME);
+ if(importsI.containsValue(name))//refClassifier
+ {
+ if(participant.containsKeyMapStringListString(LABEL))
+ {
+ String label = participant.getFirstMapStringListString(LABEL);
+ YamlObject reverseAttribute = getReverseAttribute(YamlUtil.afterChar(name,'.'),label);
+ if(reverseAttribute != null)
+ {
+ if(labelisable.containsKeyMapStringListString(NAME))
+ {
+ reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,packageM+"."+labelisable.getFirstMapStringListString(NAME));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public YamlObject getReverseAttribute(String type, String label)
+ {
+ for(List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values())
+ {
+ for(YamlObject objectYAMLO : objectsYAMLO)
+ {
+ if(objectYAMLO.containsKeyMapStringListString(NAME))
+ {
+ String name = objectYAMLO.getFirstMapStringListString(NAME);
+ if(name.equals(type))
+ {
+ if(objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ for(YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ if(attributeYAMLO.containsKeyMapStringListString(LABEL))
+ {
+ String reverseLabel = attributeYAMLO.getFirstMapStringListString(LABEL);
+ if(reverseLabel.equals(label))
+ {
+ return attributeYAMLO;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public YamlObject getReverseObject(String type)
+ {
+ for(List<YamlObject> objectsYAMLO : modelYAMLO.getMapStringListYamlObject().values())
+ {
+ for(YamlObject objectYAMLO : objectsYAMLO)
+ {
+ if(objectYAMLO.containsKeyMapStringListString(NAME))
+ {
+ String name = objectYAMLO.getFirstMapStringListString(NAME);
+ if(name.equals(type))
+ {
+ return objectYAMLO;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -1,52 +1,14 @@
package org.nuiton.eugene.models.object.reader.yaml;
-import org.nuiton.eugene.models.object.ObjectModel;
-
-import java.util.List;
-import java.util.Map;
-
/**
* User: agiraudet
* Date: 30/05/13
* Time: 11:23
*/
-//TODO: interface Syntaxe ou classe abstraite (appel l'operation suivante : charger l'ObjectModel)
-//key.toLowerCase() ?
public class SyntaxePureYaml {
- /*
- public static void loadModelYaml(Object modelYAML, YamlObject modelYAMLO)
+
+ public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO)
{
- loadYamlObject(modelYAML, modelYAMLO);
+ ParserPureYaml.parseModel(modelYAML,modelYAMLO);
}
- */
- public static void loadYamlObject(Object objectYaml, YamlObject modelYaml)
- {
- if(objectYaml instanceof List)
- {
- for(Object tmp1 : (List) objectYaml)
- {
- loadYamlObject(tmp1, modelYaml);
- }
- }
- else if(objectYaml instanceof Map)
- {
- for(Object tmp1 : ((Map) objectYaml).entrySet())
- {
- if(((Map.Entry) tmp1).getValue() instanceof List || ((Map.Entry) tmp1).getValue() instanceof Map)
- {
- YamlObject tmp2 = new YamlObject();
- loadYamlObject(((Map.Entry) tmp1).getValue(),tmp2);
- modelYaml.addYamlObjectToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(),tmp2);
- }
- else
- {
- modelYaml.addStringToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(),String.valueOf(((Map.Entry) tmp1).getValue()));
- }
- }
- }
- /*else
- {
- modelYaml.addStringToMap(previous,String.valueOf(objectYaml));
- }*/
- }
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxeUserFriendly.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -7,4 +7,12 @@
*/
//TODO: interface Syntaxe pour futures syntaxes
public class SyntaxeUserFriendly {
+
+ public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO)
+ {
+ ParserUserFriendly parser = new ParserUserFriendly(modelYAML,modelYAMLO);
+ parser.parseModel();
+ parser.resolveImports();
+ parser.resolveLabels();
+ }
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -12,6 +12,7 @@
* Date: 30/05/13
* Time: 11:58
*/
+@Deprecated
public class TestLoadObjectModel extends KeyWords {
List<String> imports;
String packageL;//package local
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -17,6 +17,7 @@
* parser si besoin et charger le YAMLobject
* parse en fonction de la version
*/
+@Deprecated
public class TestLoadYamlFile extends KeyWords {
Yaml yaml;
ObjectModelImpl modelOM;
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-06-10 14:09:12 UTC (rev 1270)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java 2013-06-11 10:11:42 UTC (rev 1271)
@@ -15,7 +15,7 @@
* Date: 15/05/13
* Time: 11:15
*/
-
+ @Deprecated
public class YamlToObjectModel {
protected Yaml yaml;
protected String packageOM;
1
0
r1270 - trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml
by agiraudet@users.nuiton.org 10 Jun '13
by agiraudet@users.nuiton.org 10 Jun '13
10 Jun '13
Author: agiraudet
Date: 2013-06-10 16:09:12 +0200 (Mon, 10 Jun 2013)
New Revision: 1270
Url: http://nuiton.org/projects/eugene/repository/revisions/1270
Log:
corrections de quelques bogues : syntaxe yaml user friendly fonctionnelle
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-09 22:07:36 UTC (rev 1269)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-10 14:09:12 UTC (rev 1270)
@@ -592,11 +592,6 @@
attributeYAMLO.addStringToMap(FINAL,String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(FINAL));
}
- if(attributePARSE.contains(ORDERED))
- {
- attributeYAMLO.addStringToMap(ORDERED,String.valueOf(true));
- attributePARSE.remove(attributePARSE.indexOf(ORDERED));
- }
if(attributePARSE.contains(UNIQUE))
{
attributeYAMLO.addStringToMap(UNIQUE,String.valueOf(true));
@@ -1121,10 +1116,19 @@
{
reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
}
+ //test
if(attribute.containsKeyMapStringListString(ORDERING))
{
- reverseAttribute.addStringToMap(ORDERING,attribute.getFirstMapStringListString(ORDERING));
+ if(attribute.getFirstMapStringListString(ORDERING).equals(ORDERED))
+ {
+ reverseAttribute.addStringToMap(ORDERING,UNORDERED);
+ }
+ else if(attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED))
+ {
+ reverseAttribute.addStringToMap(ORDERING,ORDERED);
+ }
}
+ //test
reverseObject.addYamlObjectToMap(ATTRIBUTE,reverseAttribute);
attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-09 22:07:36 UTC (rev 1269)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-10 14:09:12 UTC (rev 1270)
@@ -519,7 +519,9 @@
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
if(reverseMaxMultiplicityYAMLO == null)
{
- ;//valeur par defaut
+ //test
+ attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
+ //test
}
else
{
1
0
See <http://ci.nuiton.org/jenkins/job/eugene/1146/changes>
Changes:
[agiraudet] correction d'un problème de parsage et d'import des participants des classes d'association
------------------------------------------
Started by an SCM change
Building on master in workspace <http://ci.nuiton.org/jenkins/job/eugene/ws/>
Updating http://svn.nuiton.org/svn/eugene/trunk at revision '2013-06-10T11:41:00.323 +0200'
U eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
At revision 1269
Parsing POMs
Modules changed, recalculating dependency graph
[trunk] $ /opt/jdk/bin/java -XX:MaxPermSize=256m -Xmx448m -Dhudson.DNSMultiCast.disabled=true -Djava.awt.headless=true -XX:-UseGCOverheadLimit -cp /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/opt/maven3/boot/plexus-classworlds-2.4.2.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/maven3 /opt/repository/apache-tomcat-7.0.40/webapps/jenkins/WEB-INF/lib/remoting-2.22.jar /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 34388
<===[JENKINS REMOTING CAPACITY]===> channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/pom.xml> -e clean install
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
... 19 more
channel stopped
ERROR: Failed to parse POMs
hudson.util.IOException2: java.lang.reflect.InvocationTargetException
at hudson.maven.Maven3Builder.call(Maven3Builder.java:162)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.Exception: java.lang.reflect.InvocationTargetException
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:161)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
... 10 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
... 11 more
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
... 19 more
Failed to send e-mail to agiraudet because no e-mail address is known, and no default e-mail domain is configured
1
1
r1269 - trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml
by agiraudet@users.nuiton.org 09 Jun '13
by agiraudet@users.nuiton.org 09 Jun '13
09 Jun '13
Author: agiraudet
Date: 2013-06-10 00:07:36 +0200 (Mon, 10 Jun 2013)
New Revision: 1269
Url: http://nuiton.org/projects/eugene/repository/revisions/1269
Log:
correction d'un probl?\195?\168me de parsage et d'import des participants des classes d'association
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-07 15:58:50 UTC (rev 1268)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-09 22:07:36 UTC (rev 1269)
@@ -430,8 +430,57 @@
log("name="+classPARSE.get(0));
}
+ //participant
if(value instanceof Map)
{
+ if(((Map) value).containsKey(PARTICIPANT))
+ {
+ if(((Map) value).get(PARTICIPANT) instanceof Map)
+ {
+ for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ //name attribute "value":
+
+ List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
+ YamlObject participantYAMLO = new YamlObject();
+ if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
+ {
+ String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
+
+ participantYAMLO.addStringToMap(LABEL,label);
+
+ participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
+ }
+
+ if(participantPARSE.size() > 0)//ajout type
+ {
+ participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
+ }
+ if(participantPARSE.size() > 1)//ajout name
+ {
+ participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
+ }
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+
+ /*YamlObject participantYAMLO = new YamlObject();
+ participantYAMLO.addStringToMap(NAME, String.valueOf(((Map.Entry) entry).getKey()));
+ if(((Map.Entry) entry).getValue() != null)
+ {
+ participantYAMLO.addStringToMap(ATTRIBUTE,String.valueOf(((Map.Entry) entry).getValue()));
+ }
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);*/
+ }
+ }
+ }
+ ((Map) value).remove(PARTICIPANT);
+ }
+ }
+ //participant
+
+ if(value instanceof Map)
+ {
for(Object entry : ((Map) value).entrySet())
{
if(entry instanceof Map.Entry)
@@ -482,51 +531,6 @@
/*
FACTORISER LE CODE !
*/
- if(value instanceof Map)
- {
- if(((Map) value).containsKey(PARTICIPANT))
- {
- if(((Map) value).get(PARTICIPANT) instanceof Map)
- {
- for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
- //name attribute "value":
-
- List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
- YamlObject participantYAMLO = new YamlObject();
- if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
- {
- String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
-
- participantYAMLO.addStringToMap(LABEL,label);
-
- participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
- }
-
- if(participantPARSE.size() > 0)//ajout type
- {
- participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
- }
- if(participantPARSE.size() > 1)//ajout name
- {
- participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
- }
- associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
-
- /*YamlObject participantYAMLO = new YamlObject();
- participantYAMLO.addStringToMap(NAME, String.valueOf(((Map.Entry) entry).getKey()));
- if(((Map.Entry) entry).getValue() != null)
- {
- participantYAMLO.addStringToMap(ATTRIBUTE,String.valueOf(((Map.Entry) entry).getValue()));
- }
- associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);*/
- }
- }
- }
- }
- }
}
public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO)
@@ -1161,7 +1165,8 @@
if(labelisable.containsKeyMapStringListString(NAME))
{
log("5");
- reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,labelisable.getFirstMapStringListString(NAME));
+ //tester package
+ reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,modelYAMLO.getFirstMapStringListString(PACKAGE)+"."+labelisable.getFirstMapStringListString(NAME));
}
}
}
1
0
r1268 - in trunk: eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml
by agiraudet@users.nuiton.org 07 Jun '13
by agiraudet@users.nuiton.org 07 Jun '13
07 Jun '13
Author: agiraudet
Date: 2013-06-07 17:58:50 +0200 (Fri, 07 Jun 2013)
New Revision: 1268
Url: http://nuiton.org/projects/eugene/repository/revisions/1268
Log:
am?\195?\169lioration du parser de la syntaxe "user friendly" ()
am?\195?\169lioration du template PlantUML
Modified:
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/KeyWords.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-07 09:30:56 UTC (rev 1267)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-07 15:58:50 UTC (rev 1268)
@@ -49,6 +49,7 @@
public static final String TRANSIENT = "transient";
public static final String TYPE = "type";
public static final String UNIQUE = "unique";
+ public static final String UNORDERED = "unordered";
public static final String VERSION = "version";
public static final String VISIBILITY = "visibility";
public static final String ELEMENT = "element";
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-07 09:30:56 UTC (rev 1267)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-07 15:58:50 UTC (rev 1268)
@@ -359,11 +359,131 @@
//
public void parseAssociationClass(String key, Object value, YamlObject associationClassYAMLO)//declarer participant attribut ?
{
- parseClass(key,value,associationClassYAMLO);//non fonctionnel (remplacer CLASS par ASSOCIATION_CLASS)
+ //
- //degolass'
+ /*
+ FACTORISER LE CODE !
+ */
+ List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(classPARSE.contains(ASSOCIATION_CLASS))
+ {
+ classPARSE.remove(classPARSE.indexOf(ASSOCIATION_CLASS));
+ }
+ if(classPARSE.contains(ABSTRACT))
+ {
+ associationClassYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(ABSTRACT));
+ }
+ if(classPARSE.contains(STATIC))
+ {
+ associationClassYAMLO.addStringToMap(STATIC, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(STATIC));
+ }
+ if(classPARSE.contains(EXTERN))
+ {
+ associationClassYAMLO.addStringToMap(EXTERN, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(EXTERN));
+ }
+ if(classPARSE.contains(INNER))
+ {
+ associationClassYAMLO.addStringToMap(INNER, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(INNER));
+ }
+ if(classPARSE.contains(PUBLIC))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PUBLIC);
+ classPARSE.remove(classPARSE.indexOf(PUBLIC));
+ }
+ else if(classPARSE.contains(PRIVATE))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PRIVATE);
+ classPARSE.remove(classPARSE.indexOf(PRIVATE));
+ }
+ else if(classPARSE.contains(PROTECTED))
+ {
+ associationClassYAMLO.addStringToMap(VISIBILITY, PROTECTED);
+ classPARSE.remove(classPARSE.indexOf(PROTECTED));
+ }
+
+ for(String tmp1 : classPARSE)
+ {
+ if(tmp1.contains("<<") && tmp1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String tmp2 = YamlUtil.removeMultiChar(tmp1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
+ for(String tmp4 : tmp3)
+ {
+ associationClassYAMLO.addStringToMap(STEREOTYPES, tmp4);
+ log("stereotype="+tmp4);
+ }
+ }
+ }
+ if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ {
+ associationClassYAMLO.addStringToMap(NAME, classPARSE.get(0));
+ log("name="+classPARSE.get(0));
+ }
+
if(value instanceof Map)
{
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ //TODO: superClasses sur une ligne
+ associationClassYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ //TODO: superInterfaces sur une ligne
+ associationClassYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ /*
+ FACTORISER LE CODE !
+ */
+ if(value instanceof Map)
+ {
if(((Map) value).containsKey(PARTICIPANT))
{
if(((Map) value).get(PARTICIPANT) instanceof Map)
@@ -372,14 +492,36 @@
{
if(entry instanceof Map.Entry)
{
- //name: attribute
+ //name attribute "value":
+
+ List<String> participantPARSE = YamlUtil.charParse(String.valueOf(((Map.Entry) entry).getKey()),' ');
YamlObject participantYAMLO = new YamlObject();
+ if(participantPARSE.contains("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\""))
+ {
+ String label = YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()));
+
+ participantYAMLO.addStringToMap(LABEL,label);
+
+ participantPARSE.remove("\""+YamlUtil.extract('"',String.valueOf(((Map.Entry) entry).getKey()))+"\"");
+ }
+
+ if(participantPARSE.size() > 0)//ajout type
+ {
+ participantYAMLO.addStringToMap(NAME,participantPARSE.get(0));
+ }
+ if(participantPARSE.size() > 1)//ajout name
+ {
+ participantYAMLO.addStringToMap(ATTRIBUTE,participantPARSE.get(1));
+ }
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+
+ /*YamlObject participantYAMLO = new YamlObject();
participantYAMLO.addStringToMap(NAME, String.valueOf(((Map.Entry) entry).getKey()));
if(((Map.Entry) entry).getValue() != null)
{
participantYAMLO.addStringToMap(ATTRIBUTE,String.valueOf(((Map.Entry) entry).getValue()));
}
- associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);*/
}
}
}
@@ -482,8 +624,53 @@
attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
}
- for(String tmp1 : attributePARSE)
+ if(attributePARSE.contains(ORDERED))
{
+ attributeYAMLO.addStringToMap(ORDERING,ORDERED);
+ attributePARSE.remove(attributePARSE.indexOf(ORDERED));
+ }
+ else if(attributePARSE.contains(UNORDERED))
+ {
+ attributeYAMLO.addStringToMap(ORDERING,UNORDERED);
+ attributePARSE.remove(attributePARSE.indexOf(UNORDERED));
+ }
+
+ if(attributePARSE.contains("\""+YamlUtil.extract('"',key)+"\""))
+ {
+ String label = YamlUtil.extract('"',key);
+ attributeYAMLO.addStringToMap(LABEL,label);
+ attributePARSE.remove("\""+YamlUtil.extract('"',key)+"\"");
+ }
+
+ if(attributePARSE.contains("["+YamlUtil.extract('[',']',key)+"]"))
+ {
+ String multiplicity = YamlUtil.extract('[',']',key);
+ if(multiplicity.equals("*"))
+ {
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,"0");
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,"-1");
+ }
+ else if(multiplicity.contains(".."))
+ {
+ String min = YamlUtil.beforeChar(multiplicity,'.');
+ String max = YamlUtil.afterChar(multiplicity, '.');
+ if(min.equals("*"))
+ {
+ min = "-1";
+ }
+ if(max.equals("*"))
+ {
+ max = "-1";
+ }
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,min);
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,max);
+ }
+ attributePARSE.remove("["+YamlUtil.extract('[',']',key)+"]");
+ }
+
+ //extraire directement car pas de suppression
+ /*for(String tmp1 : attributePARSE)
+ {
log("tmp1="+tmp1);
if(tmp1.contains("\""))//tester deux occurrences ?//remplacer label par reverseMultiplicity si lien unidirectionnel
{
@@ -517,29 +704,29 @@
}
//attributePARSE.remove(tmp1);
}
- }
-
+ }*/
+ //name: type ?
if(attributePARSE.size() > 0)//ajout type
{
attributeYAMLO.addStringToMap(TYPE,attributePARSE.get(0));
}
- /*if(attributePARSE.size() > 1)//ajout name
+ if(attributePARSE.size() > 1)//ajout name
{
attributeYAMLO.addStringToMap(NAME,attributePARSE.get(1));
- }*/
+ }
- if(value != null)
+ /*if(value != null)//defaultValue
{
//attributeYAMLO.addStringToMap(DEFAULT_VALUE,String.valueOf(value));
- attributeYAMLO.addStringToMap(NAME,String.valueOf(value));
- }
+ attributeYAMLO.addStringToMap(TYPE,String.valueOf(value));
+ }*/
//on parcours le reste on recherche les [] (multiplicity) et les "" (label)
}
//OK, fonctionnel : yeah ninja flex
- //TODO: return Parameter après les : (value) ?
+ //TODO: return Parameter après les : (value) ? name: value
public void parseOperation(String key, Object value, YamlObject operationYAMLO)
{
log("operation=" + key);
@@ -576,31 +763,40 @@
operationYAMLO.addStringToMap(VISIBILITY,PRIVATE);
operationPARSE.remove(operationPARSE.indexOf(PRIVATE));
}
- if(operationPARSE.size() > 1)
+
+ for(String tmp : operationPARSE)
{
- YamlObject returnParameterYAMLO = new YamlObject();
- returnParameterYAMLO.addStringToMap(TYPE,operationPARSE.get(0));
- operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
-
- for(String tmp : operationPARSE)
+ if(tmp.contains("(") && tmp.contains(")"))
{
- if(tmp.contains("(") && tmp.contains(")"))
+ operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(tmp,'('));
+ for(String tmp1 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', tmp), ',', '<', '>'))
{
- operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(tmp,'('));
- for(String tmp1 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', tmp), ',', '<', '>'))
+ List<String> tmp2 = YamlUtil.charParse(tmp1,' ');
+ if(tmp2.size() == 2)
{
- List<String> tmp2 = YamlUtil.charParse(tmp1,' ');
- if(tmp2.size() == 2)
- {
- YamlObject parameterYAMLO = new YamlObject();
- parameterYAMLO.addStringToMap(TYPE, tmp2.get(0));
- parameterYAMLO.addStringToMap(NAME, tmp2.get(1));
- operationYAMLO.addYamlObjectToMap(PARAMETER, parameterYAMLO);
- }
+ YamlObject parameterYAMLO = new YamlObject();
+ parameterYAMLO.addStringToMap(TYPE, tmp2.get(0));
+ parameterYAMLO.addStringToMap(NAME, tmp2.get(1));
+ operationYAMLO.addYamlObjectToMap(PARAMETER, parameterYAMLO);
}
}
+ //operationPARSE.remove(tmp);
}
}
+
+ /*if(operationPARSE.size() > 1)
+ {
+ YamlObject returnParameterYAMLO = new YamlObject();
+ returnParameterYAMLO.addStringToMap(TYPE,operationPARSE.get(0));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+ }*/
+
+ if(value != null)
+ {
+ YamlObject returnParameterYAMLO = new YamlObject();
+ returnParameterYAMLO.addStringToMap(TYPE,String.valueOf(value));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+ }
}
public static void resolveImports(YamlObject modelYAMLO)
@@ -725,9 +921,18 @@
}
}
}
- if(importable.containsKeyMapStringListString(PARTICIPANT))
+ if(importable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
{
- ;//TODO
+ log("0");
+ for(YamlObject participantYAMLO : importable.getMapStringListYamlObject(PARTICIPANT))
+ {
+ log("1");
+ if(participantYAMLO.containsKeyMapStringListString(NAME))
+ {
+ log("2");
+ participantYAMLO.setMapStringListString(NAME,participantYAMLO.getFirstMapStringListString(NAME),resolveType(participantYAMLO.getFirstMapStringListString(NAME),imports));
+ }
+ }
}
}
}
@@ -736,7 +941,6 @@
//OK
public static String browseType(String type, Map<String,String> imports)
{
- //List<Map<String,List<Integer>>>
StringBuilder res = new StringBuilder();
boolean first = true;
for(String tmp : YamlUtil.charParseIgnore(type,',','<','>'))
@@ -793,7 +997,7 @@
//recuperer toyus les attributs dans une seule liste au lieu d'aller les chercher a chaque fois
public static void resolveLabels(YamlObject modelYAMLO)//reverseAttribute + Labels
{
- //test
+ //test variable global
Map<String,String> imports = new LinkedHashMap<String, String>();
String packageM = null;
if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
@@ -894,17 +1098,14 @@
attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,reverseAttribute.getFirstMapStringListString(NAME));
}
}
- //methode getReverseAttribute(mode,type,label)
- //recuperer le reverse attribute
- //TODO
- //modelYAMLO.getFirstMapStringListYamlObject(YamlUtil.afterChar(type,'.')).get
- //for()
}
else//unidirectionnel
{
+ log("unidirectionnel");
YamlObject reverseObject = getReverseObject(modelYAMLO,YamlUtil.afterChar(type,'.'));
if(reverseObject != null)
{
+ log("reverseObject != null");
YamlObject reverseAttribute = new YamlObject();
reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(false));
reverseAttribute.addStringToMap(TYPE,imports.get(labelisable.getFirstMapStringListString(NAME)));
@@ -916,6 +1117,13 @@
{
reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
}
+ if(attribute.containsKeyMapStringListString(ORDERING))
+ {
+ reverseAttribute.addStringToMap(ORDERING,attribute.getFirstMapStringListString(ORDERING));
+ }
+ reverseObject.addYamlObjectToMap(ATTRIBUTE,reverseAttribute);
+
+ attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
}
}
}
@@ -930,6 +1138,37 @@
}
}
}
+ if(labelisable.containsKeyYamlMapStringListYamlObject(PARTICIPANT))
+ {
+ log("0");
+ for(YamlObject participant : labelisable.getMapStringListYamlObject(PARTICIPANT))
+ {
+ if(participant.containsKeyMapStringListString(NAME))
+ {
+ log("1");
+ String name = participant.getFirstMapStringListString(NAME);
+ if(importsI.contains(name))//refClassifier
+ {
+ log("2");
+ if(participant.containsKeyMapStringListString(LABEL))
+ {
+ log("3");
+ String label = participant.getFirstMapStringListString(LABEL);
+ YamlObject reverseAttribute = getReverseAttribute(modelYAMLO,YamlUtil.afterChar(name,'.'),label);
+ if(reverseAttribute != null)
+ {
+ log("4");
+ if(labelisable.containsKeyMapStringListString(NAME))
+ {
+ log("5");
+ reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME,labelisable.getFirstMapStringListString(NAME));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -992,7 +1231,7 @@
imports.put("Map","java.util.Map");
String type = "Map<List<String>,List<String>>";
System.out.println(resolveType(type,imports));*/
- List<String> test = new LinkedList<String>();
+ /*List<String> test = new LinkedList<String>();
test.add("test1");
test.add("test2");
test.add("\"test3\"");
@@ -1000,6 +1239,6 @@
for(String str : test)
{
System.out.println(str);
- }
+ }*/
}
}
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-07 09:30:56 UTC (rev 1267)
+++ trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-06-07 15:58:50 UTC (rev 1268)
@@ -1,65 +1,24 @@
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.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 org.nuiton.eugene.models.object.*;
+import org.nuiton.eugene.models.object.xml.ObjectModelAssociationClassImpl;
+import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl;
-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;
+import java.io.*;
+import java.util.*;
-/**
- * TODO
- *
- * @author agiraudet
- * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.plantuml.PlantumlTemplatesGenerator"
- * @since 2.6.3
- */
+// http://maven-site.nuiton.org/eugene/objectmodel/ObjectModel_Interfaces.png
+//TODO : Plexus ?
+
public class PlantumlTemplatesGenerator extends ObjectModelGenerator {
private boolean _loginit = true;
-
private void log(String str) {
try {
FileWriter log;
- String path = "/tmp/log.yaml.txt";
+ String path = "/tmp/log.plantuml.txt";
if (_loginit) {
log = new FileWriter(path, false);
@@ -69,9 +28,7 @@
log = new FileWriter(path, true);
log.write("[LOG] " + str + "\n");
log.close();
- } catch (IOException e) {
- ;
- }
+ } catch (IOException e) {;}
}
@Override
@@ -81,167 +38,263 @@
// 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()) {
- // sale
+ for(ObjectModelClass class_tmp : input.getClasses())
+ {
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"))
- {
- classStereotype = " <<entity>>";
- }*/
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")) {
- enumerationStereotype = " <<entity>>";
+ if(enumeration_tmp.getStereotypes().size()>0)
+ {
+ enumerationStereotype = "<<";
+ boolean first = true;
+ for(String str : enumeration_tmp.getStereotypes())
+ {
+ if(first)
+ {
+ enumerationStereotype = enumerationStereotype+str;
+ first = false;
+ }
+ else
+ {
+ enumerationStereotype = enumerationStereotype+" ,"+str;
+ }
+ }
+ enumerationStereotype = enumerationStereotype+">>";
}
// ajout de l'enumeration
- output.write("enum " + enumerationName + enumerationStereotype + " {\n");
+ output.write("enum "+enumerationName+enumerationStereotype+" {\n");
+ for(String literalOM : enumeration_tmp.getLiterals())
+ {
+ output.write(" "+literalOM.toUpperCase()+"\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")) {
- interfaceStereotype = " <<entity>>";
+ if(interface_tmp.getStereotypes().size()>0)
+ {
+ interfaceStereotype = "<<";
+ boolean first = true;
+ for(String str : interface_tmp.getStereotypes())
+ {
+ if(first)
+ {
+ interfaceStereotype = interfaceStereotype+str;
+ first = false;
+ }
+ else
+ {
+ interfaceStereotype = interfaceStereotype+" ,"+str;
+ }
+ }
+ interfaceStereotype = interfaceStereotype+">>";
}
// 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()) {
- output.write(linksOME.get(attribute_tmp).getName() + " *-- " + attribute_tmp.getClassifier().getName() + "\n");
- } else if (attribute_tmp.isAggregate() && attribute_tmp.referenceClassifier())//else if
+ for(ObjectModelAttribute attribute_tmp : linksOME.keySet())
+ {
+ //if(attribute_tmp.isNavigable())
{
- 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
+ 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()+" o-- "+attribute_tmp.getClassifier().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");
+ }
+ }
+ }
+
+ /*//test
+ for(ObjectModelClassifier class_tmp : input.getClassifiers())
+ {
+ log("name="+class_tmp.getName());
+ for(ObjectModelDependency dependency : class_tmp.getDependencies())
{
- 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");
+ log("dependency="+dependency.getName()+" client="+ dependency.getClient().getName()+" supplier="+dependency.getSupplier().getName());
}
+ if(class_tmp.getDeclaringElement() != null)
+ {
+ log("declaringElement="+class_tmp.getDeclaringElement().getName());
+ }
}
+ *///test
//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()+"\n");
}
}
+ //realisations
+ for(ObjectModelClass classOM : input.getClasses())
+ {
+ for(ObjectModelInterface superInterfaceOM : classOM.getInterfaces())
+ {
+ output.write(superInterfaceOM.getName()+" <|.. "+classOM.getName()+"\n");
+ }
+ }
+
// fin du fichier
output.write("\n@enduml");
}
// 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;
}
@@ -250,10 +303,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();
}
@@ -261,6 +314,6 @@
@Override
public String getFilenameForModel(ObjectModel model) {
- return model.getName() + ".plantuml";
+ return model.getName()+".plantuml";
}
}
1
0
r1267 - trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml
by agiraudet@users.nuiton.org 07 Jun '13
by agiraudet@users.nuiton.org 07 Jun '13
07 Jun '13
Author: agiraudet
Date: 2013-06-07 11:30:56 +0200 (Fri, 07 Jun 2013)
New Revision: 1267
Url: http://nuiton.org/projects/eugene/repository/revisions/1267
Log:
impl?\195?\169mentation de la syntaxe YAML user friendly (test)
Added:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-05-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -22,6 +22,7 @@
public static final String IMPORTS = "imports";
public static final String INNER = "inner";
public static final String INTERFACE = "interface";
+ public static final String LABEL = "label";
public static final String LITERAL = "literal";
public static final String MAX_MULTIPLICITY = "maxmultiplicity";
public static final String MIN_MULTIPLICITY = "minmultiplicity";
@@ -33,6 +34,9 @@
public static final String PACKAGE = "package";
public static final String PARAMETER = "parameter";
public static final String PARTICIPANT = "participant";
+ public static final String PRIVATE = "private";
+ public static final String PROTECTED = "protected";
+ public static final String PUBLIC = "public";
public static final String RETURN_PARAMETER = "returnparameter";
public static final String REVERSE_ATTRIBUTE_NAME = "reverseattributename";
public static final String REVERSE_MAX_MULTIPLICITY = "reversemaxmultiplicity";
Added: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -0,0 +1,1005 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 03/06/13
+ * Time: 09:56
+ */
+
+/**
+ * principe : recuperer Object, retourner YamlObject et resoudre YamlObject
+ *
+ * methode1 : syntaxe stricte, recuperer element en fonction de leur emplacement dans la liste et avec des contains ex: get(indexOf(truc)) ?
+ * methode2 : syntaxe moins restrictive, supprimer les élément et en déduir les restant
+ * methode3 : la methode3 (ninja hybride)
+ */
+public class Parser extends KeyWords {
+
+ private static boolean _loginit = true;
+ private static void log(String str) {
+ try {
+ FileWriter log;
+ String path = "/tmp/log.parser.txt";
+
+ if (_loginit) {
+ log = new FileWriter(path, false);
+ log.close();
+ _loginit = false;
+ }
+ log = new FileWriter(path, true);
+ log.write("[LOG] " + str + "\n");
+ log.close();
+ } catch (IOException e) {;}
+ }
+
+ public Parser()
+ {
+ ;
+ }
+
+ //TODO: ajouter le nom des Objects aux imports ! lors du parsage (imports internes)
+ //TODO: ajouter "imports" Map.Entity<Strign,List<String>>
+ //TODO: resoudre labels avant imports
+ //retourner YAMLO ou modifier YAMLO ?
+ //charger class, interface, associationClass ou enumeration
+ //it work !
+ public YamlObject parseModel(Object modelYAML, YamlObject modelYAMLO)
+ {
+ if(modelYAML instanceof Map)
+ {
+ for(Object entry : ((Map) modelYAML).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String key = String.valueOf(((Map.Entry) entry).getKey());
+ Object value = ((Map.Entry) entry).getValue();
+ //TODO: 1/ containsKey + remove & for() sur le reste
+ if(key.equals(PACKAGE))
+ {
+ modelYAMLO.addStringToMap(PACKAGE,String.valueOf(value));
+ }
+
+ if(key.equals(NAME))
+ {
+ modelYAMLO.addStringToMap(NAME,String.valueOf(value));
+ }
+
+ if(key.equals(VERSION))
+ {
+ modelYAMLO.addStringToMap(VERSION,String.valueOf(value));
+ }
+
+ if(key.equals(IMPORTS))
+ {
+ if(value instanceof List)
+ {
+ for(Object imp : (List) value)
+ {
+ modelYAMLO.addStringToMap(IMPORTS,String.valueOf(imp));
+ }
+ }
+ }
+
+ List<String> tmp = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(tmp.contains(CLASS))
+ { YamlObject classYAMLO = new YamlObject();
+ parseClass(key,value,classYAMLO);
+ modelYAMLO.addYamlObjectToMap(CLASS,classYAMLO);
+ }
+ else if(tmp.contains(INTERFACE))
+ {
+ YamlObject interfaceYAMLO = new YamlObject();
+ parseInterface(key,value,interfaceYAMLO);
+ modelYAMLO.addYamlObjectToMap(INTERFACE,interfaceYAMLO);
+ }
+ else if(tmp.contains(ASSOCIATION_CLASS))
+ {
+ YamlObject associationClassYAMLO = new YamlObject();
+ parseAssociationClass(key,value,associationClassYAMLO);
+ modelYAMLO.addYamlObjectToMap(ASSOCIATION_CLASS,associationClassYAMLO);
+ }
+ else if(tmp.contains(ENUMERATION))
+ {
+ YamlObject enumerationYAMLO = new YamlObject();
+ parseEnumeration(key,value,enumerationYAMLO);
+ modelYAMLO.addYamlObjectToMap(ENUMERATION,enumerationYAMLO);
+ }
+ }
+ }
+ }
+ return modelYAMLO;
+ }
+
+ //name, abstract, static, stereotypes, extern inner, atribute, operation et super classes et super interfaces
+ public void parseClass(String key, Object value, YamlObject classYAMLO)//classYAMLO
+ {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(classPARSE.contains(CLASS))
+ {
+ classPARSE.remove(classPARSE.indexOf(CLASS));
+ }
+ if(classPARSE.contains(ABSTRACT))
+ {
+ classYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(ABSTRACT));
+ }
+ if(classPARSE.contains(STATIC))
+ {
+ classYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(STATIC));
+ }
+ if(classPARSE.contains(EXTERN))
+ {
+ classYAMLO.addStringToMap(EXTERN,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(EXTERN));
+ }
+ if(classPARSE.contains(INNER))
+ {
+ classYAMLO.addStringToMap(INNER,String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(INNER));
+ }
+ if(classPARSE.contains(PUBLIC))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ classPARSE.remove(classPARSE.indexOf(PUBLIC));
+ }
+ else if(classPARSE.contains(PRIVATE))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ classPARSE.remove(classPARSE.indexOf(PRIVATE));
+ }
+ else if(classPARSE.contains(PROTECTED))
+ {
+ classYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ classPARSE.remove(classPARSE.indexOf(PROTECTED));
+ }
+
+ for(String tmp1 : classPARSE)
+ {
+ if(tmp1.contains("<<") && tmp1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String tmp2 = YamlUtil.removeMultiChar(tmp1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
+ for(String tmp4 : tmp3)
+ {
+ classYAMLO.addStringToMap(STEREOTYPES,tmp4);
+ log("stereotype="+tmp4);
+ }
+ }
+ }
+ if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ {
+ classYAMLO.addStringToMap(NAME,classPARSE.get(0));
+ log("name="+classPARSE.get(0));
+ }
+
+ if(value instanceof Map)
+ {
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ //TODO: superClasses sur une ligne
+ classYAMLO.addStringToMap(SUPER_CLASSES,String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ //TODO: superInterfaces sur une ligne
+ classYAMLO.addStringToMap(SUPER_INTERFACES,String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ classYAMLO.addYamlObjectToMap(OPERATION,operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ classYAMLO.addYamlObjectToMap(ATTRIBUTE,attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void parseInterface(String key, Object value, YamlObject interfaceYAMLO)//enlever superflu
+ {
+ List<String> classPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(classPARSE.contains(INTERFACE))
+ {
+ classPARSE.remove(classPARSE.indexOf(INTERFACE));
+ }
+ if(classPARSE.contains(ABSTRACT))
+ {
+ interfaceYAMLO.addStringToMap(ABSTRACT, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(ABSTRACT));
+ }
+ if(classPARSE.contains(STATIC))
+ {
+ interfaceYAMLO.addStringToMap(STATIC, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(STATIC));
+ }
+ if(classPARSE.contains(EXTERN))
+ {
+ interfaceYAMLO.addStringToMap(EXTERN, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(EXTERN));
+ }
+ if(classPARSE.contains(INNER))
+ {
+ interfaceYAMLO.addStringToMap(INNER, String.valueOf(true));
+ classPARSE.remove(classPARSE.indexOf(INNER));
+ }
+ if(classPARSE.contains(PUBLIC))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PUBLIC);
+ classPARSE.remove(classPARSE.indexOf(PUBLIC));
+ }
+ else if(classPARSE.contains(PRIVATE))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PRIVATE);
+ classPARSE.remove(classPARSE.indexOf(PRIVATE));
+ }
+ else if(classPARSE.contains(PROTECTED))
+ {
+ interfaceYAMLO.addStringToMap(VISIBILITY, PROTECTED);
+ classPARSE.remove(classPARSE.indexOf(PROTECTED));
+ }
+
+ for(String tmp1 : classPARSE)
+ {
+ if(tmp1.contains("<<") && tmp1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String tmp2 = YamlUtil.removeMultiChar(tmp1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
+ for(String tmp4 : tmp3)
+ {
+ interfaceYAMLO.addStringToMap(STEREOTYPES, tmp4);
+ log("stereotype="+tmp4);
+ }
+ }
+ }
+ if(classPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ {
+ interfaceYAMLO.addStringToMap(NAME, classPARSE.get(0));
+ log("name="+classPARSE.get(0));
+ }
+
+ if(value instanceof Map)
+ {
+ for(Object entry : ((Map) value).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ String keyP = String.valueOf(((Map.Entry) entry).getKey());
+ Object valueP = ((Map.Entry) entry).getValue();
+
+ if(keyP.equals(SUPER_CLASSES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superClass : (List) valueP)
+ {
+ //TODO: superClasses sur une ligne
+ interfaceYAMLO.addStringToMap(SUPER_CLASSES, String.valueOf(superClass));
+ }
+ }
+ }
+ else if(keyP.equals(SUPER_INTERFACES))
+ {
+ if(valueP instanceof List)
+ {
+ for(Object superInterface : (List) valueP)
+ {
+ //TODO: superInterfaces sur une ligne
+ interfaceYAMLO.addStringToMap(SUPER_INTERFACES, String.valueOf(superInterface));
+ }
+ }
+ }
+ else
+ {
+ if(keyP.contains("(") && keyP.contains(")"))
+ {
+ YamlObject operationYAMLO = new YamlObject();
+ parseOperation(keyP,valueP,operationYAMLO);
+ interfaceYAMLO.addYamlObjectToMap(OPERATION, operationYAMLO);
+ }
+ else
+ {
+ YamlObject attributeYAMLO = new YamlObject();
+ parseAttribute(keyP,valueP,attributeYAMLO);
+ interfaceYAMLO.addYamlObjectToMap(ATTRIBUTE, attributeYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //
+ public void parseAssociationClass(String key, Object value, YamlObject associationClassYAMLO)//declarer participant attribut ?
+ {
+ parseClass(key,value,associationClassYAMLO);//non fonctionnel (remplacer CLASS par ASSOCIATION_CLASS)
+
+ //degolass'
+ if(value instanceof Map)
+ {
+ if(((Map) value).containsKey(PARTICIPANT))
+ {
+ if(((Map) value).get(PARTICIPANT) instanceof Map)
+ {
+ for(Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ //name: attribute
+ YamlObject participantYAMLO = new YamlObject();
+ participantYAMLO.addStringToMap(NAME, String.valueOf(((Map.Entry) entry).getKey()));
+ if(((Map.Entry) entry).getValue() != null)
+ {
+ participantYAMLO.addStringToMap(ATTRIBUTE,String.valueOf(((Map.Entry) entry).getValue()));
+ }
+ associationClassYAMLO.addYamlObjectToMap(PARTICIPANT,participantYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void parseEnumeration(String key, Object value, YamlObject enumerationYAMLO)
+ {
+ List<String> enumerationPARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ if(enumerationPARSE.contains(ENUMERATION))
+ {
+ enumerationPARSE.remove(enumerationPARSE.indexOf(ENUMERATION));
+ }
+ if(enumerationPARSE.contains(STATIC))
+ {
+ enumerationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ enumerationPARSE.remove(enumerationPARSE.indexOf(STATIC));
+ }
+
+ for(String tmp1 : enumerationPARSE)
+ {
+ if(tmp1.contains("<<") && tmp1.contains(">>"))
+ {
+ List<Character> targets = new LinkedList<Character>();
+ targets.add('<');
+ targets.add('>');
+ String tmp2 = YamlUtil.removeMultiChar(tmp1, targets);
+ targets = new LinkedList<Character>();
+ targets.add(' ');
+ targets.add(',');
+ List<String> tmp3 = YamlUtil.multiCharParse(tmp2, targets);
+ for(String tmp4 : tmp3)
+ {
+ enumerationYAMLO.addStringToMap(STEREOTYPES,tmp4);
+ log("stereotype="+tmp4);
+ }
+ }
+ }
+ if(enumerationPARSE.size() > 0)//prend compte de l'ordre : nom avant stereotypes
+ {
+ enumerationYAMLO.addStringToMap(NAME,enumerationPARSE.get(0));
+ log("name=" + enumerationPARSE.get(0));
+ }
+
+
+ ;//literal
+ }
+
+ //~ok, fonctionnel
+ public void parseAttribute(String key, Object value, YamlObject attributeYAMLO)
+ {
+ //TODO: defaultValue, multiplicity, associationType, reverse(multiplicity & attributeName)
+ List<String> attributePARSE = YamlUtil.charParseIgnore(key,' ','<','>');
+ log("key="+key);
+ log("keyPARSE="+attributePARSE);
+ if(attributePARSE.contains(STATIC))
+ {
+ attributeYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(STATIC));
+ }
+ if(attributePARSE.contains(FINAL))
+ {
+ attributeYAMLO.addStringToMap(FINAL,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(FINAL));
+ }
+ if(attributePARSE.contains(ORDERED))
+ {
+ attributeYAMLO.addStringToMap(ORDERED,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(ORDERED));
+ }
+ if(attributePARSE.contains(UNIQUE))
+ {
+ attributeYAMLO.addStringToMap(UNIQUE,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(UNIQUE));
+ }
+ if(attributePARSE.contains(NAVIGABLE))
+ {
+ attributeYAMLO.addStringToMap(NAVIGABLE,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(NAVIGABLE));
+ }
+ if(attributePARSE.contains(TRANSIENT))
+ {
+ attributeYAMLO.addStringToMap(TRANSIENT,String.valueOf(true));
+ attributePARSE.remove(attributePARSE.indexOf(TRANSIENT));
+ }
+ if(attributePARSE.contains(PUBLIC))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+ else if(attributePARSE.contains(PROTECTED))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+ else if(attributePARSE.contains(PRIVATE))
+ {
+ attributeYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ attributePARSE.remove(attributePARSE.indexOf(PUBLIC));
+ }
+
+ for(String tmp1 : attributePARSE)
+ {
+ log("tmp1="+tmp1);
+ if(tmp1.contains("\""))//tester deux occurrences ?//remplacer label par reverseMultiplicity si lien unidirectionnel
+ {
+ String label = YamlUtil.extract('"',tmp1);
+ attributeYAMLO.addStringToMap(LABEL,label);
+ //attributePARSE.remove(tmp1);
+ log("label="+label);
+ }
+ else if(tmp1.contains("[") && tmp1.contains("]"))
+ {
+ String multiplicity = YamlUtil.extract('[',']',tmp1);
+ if(multiplicity.equals("*"))
+ {
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,"0");
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,"-1");
+ }
+ else if(multiplicity.contains(".."))
+ {
+ String min = YamlUtil.beforeChar(multiplicity,'.');
+ String max = YamlUtil.afterChar(multiplicity, '.');
+ if(min.equals("*"))
+ {
+ min = "-1";
+ }
+ if(max.equals("*"))
+ {
+ max = "-1";
+ }
+ attributeYAMLO.addStringToMap(MIN_MULTIPLICITY,min);
+ attributeYAMLO.addStringToMap(MAX_MULTIPLICITY,max);
+ }
+ //attributePARSE.remove(tmp1);
+ }
+ }
+
+ if(attributePARSE.size() > 0)//ajout type
+ {
+ attributeYAMLO.addStringToMap(TYPE,attributePARSE.get(0));
+ }
+ /*if(attributePARSE.size() > 1)//ajout name
+ {
+ attributeYAMLO.addStringToMap(NAME,attributePARSE.get(1));
+ }*/
+
+ if(value != null)
+ {
+ //attributeYAMLO.addStringToMap(DEFAULT_VALUE,String.valueOf(value));
+ attributeYAMLO.addStringToMap(NAME,String.valueOf(value));
+ }
+
+ //on parcours le reste on recherche les [] (multiplicity) et les "" (label)
+
+ }
+
+ //OK, fonctionnel : yeah ninja flex
+ //TODO: return Parameter après les : (value) ?
+ public void parseOperation(String key, Object value, YamlObject operationYAMLO)
+ {
+ log("operation=" + key);
+ List<Character> ignoreStart = new LinkedList<Character>();
+ ignoreStart.add('(');
+ ignoreStart.add('<');
+ List<Character> ignoreEnd = new LinkedList<Character>();
+ ignoreEnd.add(')');
+ ignoreEnd.add('>');
+ List<String> operationPARSE = YamlUtil.charParseMultiIgnore(key,' ',ignoreStart,ignoreEnd);
+
+ if(operationPARSE.contains(STATIC))
+ {
+ operationYAMLO.addStringToMap(STATIC,String.valueOf(true));
+ operationPARSE.remove(operationPARSE.indexOf(STATIC));
+ }
+ if(operationPARSE.contains(ABSTRACT))
+ {
+ operationYAMLO.addStringToMap(ABSTRACT,String.valueOf(true));
+ operationPARSE.remove(operationPARSE.indexOf(ABSTRACT));
+ }
+ if(operationPARSE.contains(PUBLIC))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PUBLIC);
+ operationPARSE.remove(operationPARSE.indexOf(PUBLIC));
+ }
+ else if(operationPARSE.contains(PROTECTED))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PROTECTED);
+ operationPARSE.remove(operationPARSE.indexOf(PROTECTED));
+ }
+ else if(operationPARSE.contains(PRIVATE))
+ {
+ operationYAMLO.addStringToMap(VISIBILITY,PRIVATE);
+ operationPARSE.remove(operationPARSE.indexOf(PRIVATE));
+ }
+ if(operationPARSE.size() > 1)
+ {
+ YamlObject returnParameterYAMLO = new YamlObject();
+ returnParameterYAMLO.addStringToMap(TYPE,operationPARSE.get(0));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER,returnParameterYAMLO);
+
+ for(String tmp : operationPARSE)
+ {
+ if(tmp.contains("(") && tmp.contains(")"))
+ {
+ operationYAMLO.addStringToMap(NAME,YamlUtil.beforeChar(tmp,'('));
+ for(String tmp1 : YamlUtil.charParseIgnore(YamlUtil.extract('(', ')', tmp), ',', '<', '>'))
+ {
+ List<String> tmp2 = YamlUtil.charParse(tmp1,' ');
+ if(tmp2.size() == 2)
+ {
+ YamlObject parameterYAMLO = new YamlObject();
+ parameterYAMLO.addStringToMap(TYPE, tmp2.get(0));
+ parameterYAMLO.addStringToMap(NAME, tmp2.get(1));
+ operationYAMLO.addYamlObjectToMap(PARAMETER, parameterYAMLO);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void resolveImports(YamlObject modelYAMLO)
+ {
+ //List<String> imports = new LinkedList<String>();
+ Map<String,String> imports = new LinkedHashMap<String, String>();
+ if(modelYAMLO.containsKeyMapStringListString(IMPORTS))
+ {
+ for(String imp : modelYAMLO.getMapStringListString(IMPORTS))
+ {
+ imports.put(YamlUtil.afterChar(imp,'.'),imp);
+ }
+ }
+ //Objects importés: Attribute.Type SuperClasses SuperInterfaces AssociationClass.Participant.Name Parameter.Type(Operation(Class, AssociationClass(Classifier))
+ //recursivité pour Parameter et attribute ? Yeah
+ String packageM = null;
+ if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
+ {
+ packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
+ }
+ for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
+ {
+ for(YamlObject importable : entry.getValue())
+ {
+ if(importable.containsKeyMapStringListString(NAME))
+ {
+ String name = importable.getFirstMapStringListString(NAME);
+ if(importable.containsKeyMapStringListString(PACKAGE))
+ {
+ imports.put(name,importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ }
+ else if(packageM != null)
+ {
+ imports.put(name,packageM+"."+name);
+ }
+ }
+ }
+ }
+ for(Map.Entry<String,String> imp : imports.entrySet())
+ {
+ log("import="+imp.getKey()+":"+imp.getValue());
+ }
+
+ //remplacer types par imports complets
+ for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
+ {
+ for(YamlObject importable : entry.getValue())
+ {
+ if(importable.containsKeyMapStringListString(SUPER_CLASSES))
+ {
+ for(String value : importable.getMapStringListString(SUPER_CLASSES))
+ {
+ if(imports.containsKey(value))
+ {
+ importable.setMapStringListString(SUPER_CLASSES,value,imports.get(value));
+ log("imported="+value+":"+imports.get(value));
+ }
+ }
+ }
+ if(importable.containsKeyMapStringListString(SUPER_INTERFACES))
+ {
+ for(String value : importable.getMapStringListString(SUPER_INTERFACES))
+ {
+ if(imports.containsKey(value))
+ {
+ importable.setMapStringListString(SUPER_INTERFACES,value,imports.get(value));
+ log("imported="+value+":"+imports.get(value));
+ }
+ }
+ }
+ if(importable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ log(" contains attributes");
+ for(YamlObject attributeYAMLO : importable.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ log(" browse attributes");
+ if(attributeYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ log(" contains type");
+ //if(imports.containsKey(attributeYAMLO.getFirstMapStringListString(TYPE)))
+ {
+ //attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(attributeYAMLO.getFirstMapStringListString(TYPE)),imports));
+ attributeYAMLO.setMapStringListString(TYPE,attributeYAMLO.getFirstMapStringListString(TYPE),resolveType(attributeYAMLO.getFirstMapStringListString(TYPE),imports));
+ log("imported=" + attributeYAMLO.getFirstMapStringListString(TYPE) + ":" + imports.get(attributeYAMLO.getFirstMapStringListString(TYPE)));//retourne null car la clef vient juste d'etre modifiee
+ }
+ }
+ }
+ }
+ if(importable.containsKeyYamlMapStringListYamlObject(OPERATION))
+ {
+ for(YamlObject operationYAMLO : importable.getMapStringListYamlObject(OPERATION))
+ {
+ if(operationYAMLO.containsKeyYamlMapStringListYamlObject(PARAMETER))
+ {
+ for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER))
+ {
+ if(parameterYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ //if(imports.containsKey(parameterYAMLO.getFirstMapStringListString(TYPE)))
+ {
+ //parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(parameterYAMLO.getFirstMapStringListString(TYPE)),imports));
+ parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE),imports));
+
+ }
+ }
+ }
+ }
+ if(operationYAMLO.containsKeyYamlMapStringListYamlObject(RETURN_PARAMETER))
+ {
+ for(YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER))
+ {
+ if(parameterYAMLO.containsKeyMapStringListString(TYPE))
+ {
+ //if(imports.containsKey(parameterYAMLO.getFirstMapStringListString(TYPE)))
+ {
+ //parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(imports.get(parameterYAMLO.getFirstMapStringListString(TYPE)),imports));
+ parameterYAMLO.setMapStringListString(TYPE,parameterYAMLO.getFirstMapStringListString(TYPE),resolveType(parameterYAMLO.getFirstMapStringListString(TYPE),imports));
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if(importable.containsKeyMapStringListString(PARTICIPANT))
+ {
+ ;//TODO
+ }
+ }
+ }
+ }
+
+ //OK
+ public static String browseType(String type, Map<String,String> imports)
+ {
+ //List<Map<String,List<Integer>>>
+ StringBuilder res = new StringBuilder();
+ boolean first = true;
+ for(String tmp : YamlUtil.charParseIgnore(type,',','<','>'))
+ {
+ if(first)//String || List<>
+ {
+ first = false;
+ }
+ else
+ {
+ res.append(",");
+ }
+ if(tmp.contains("<") && tmp.contains(">"))
+ {
+ String ninja = YamlUtil.beforeChar(tmp,'<');
+ if(imports.containsKey(ninja))
+ {
+ res.append(imports.get(ninja));
+ }
+ else
+ {
+ res.append(tmp);
+ }
+ res.append("<");
+ res.append(browseType(YamlUtil.extract('<','>',tmp),imports));
+ res.append(">");
+ }
+ else
+ {
+ if(imports.containsKey(tmp))
+ {
+ res.append(imports.get(tmp));
+ }
+ else
+ {
+ res.append(tmp);
+ }
+ }
+ }
+ return res.toString();
+ /*String ninja = YamlUtil.beforeChar(type,'<');
+ String flex = browseType(YamlUtil.extract('<','>',type),imports);
+ return ninja+flex;//gerer ',' multi parse fuck yeah*/
+ }
+ //OK
+ public static String resolveType(String type, Map<String,String> imports)
+ {
+ List<Character> ignore = new LinkedList<Character>();
+ ignore.add(' ');
+ String typePARSE = YamlUtil.removeMultiChar(type,ignore);
+ return browseType(typePARSE,imports);
+ }
+
+ //recuperer toyus les attributs dans une seule liste au lieu d'aller les chercher a chaque fois
+ public static void resolveLabels(YamlObject modelYAMLO)//reverseAttribute + Labels
+ {
+ //test
+ Map<String,String> imports = new LinkedHashMap<String, String>();
+ String packageM = null;
+ if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
+ {
+ packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
+ }
+ for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
+ {
+ for(YamlObject importable : entry.getValue())
+ {
+ if(importable.containsKeyMapStringListString(NAME))
+ {
+ String name = importable.getFirstMapStringListString(NAME);
+ if(importable.containsKeyMapStringListString(PACKAGE))
+ {
+ imports.put(name,importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ }
+ else if(packageM != null)
+ {
+ imports.put(name,packageM+"."+name);
+ }
+ }
+ }
+ }
+ //test
+
+
+ List<String> importsI = new LinkedList<String>();
+ //String packageM = null;
+ if(modelYAMLO.containsKeyMapStringListString(PACKAGE))
+ {
+ packageM = modelYAMLO.getFirstMapStringListString(PACKAGE);
+ }
+ for(Map.Entry<String,List<YamlObject>> entry : modelYAMLO.getMapStringListYamlObject().entrySet())
+ {
+ for(YamlObject importable : entry.getValue())
+ {
+ if(importable.containsKeyMapStringListString(NAME))
+ {
+ String name = importable.getFirstMapStringListString(NAME);
+ if(importable.containsKeyMapStringListString(PACKAGE))
+ {
+ importsI.add(importable.getFirstMapStringListString(PACKAGE)+"."+name);
+ }
+ else if(packageM != null)
+ {
+ importsI.add(packageM+"."+name);
+ }
+ }
+ }
+ }
+
+ //recuperer imports internes
+ //if reference class interne et navigable (ou ! navigable=false)
+ //if label -> chercher reverse attribute
+ //else ajouter attribut navigable=false
+ //+ bricoler nom
+ for(List<YamlObject> objectYAMLO : modelYAMLO.getMapStringListYamlObject().values())
+ {
+ for(YamlObject labelisable : objectYAMLO)
+ {
+ if(labelisable.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ for(YamlObject attribute : labelisable.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ if(attribute.containsKeyMapStringListString(TYPE))
+ {
+ String type = attribute.getFirstMapStringListString(TYPE);
+ log("type="+type);
+ if(importsI.contains(type))//refClassifier
+ {
+ //pas encore passé par la//osef composite
+ if(!attribute.containsKeyMapStringListString(NAVIGABLE))
+ {
+ if(attribute.containsKeyMapStringListString(LABEL))//bidirectionnel, recup reverse maxMultiplicity, reverseAttributeName et setNavigable(true)
+ {
+ String label = attribute.getFirstMapStringListString(LABEL);
+ log("label="+label);
+ YamlObject reverseAttribute = getReverseAttribute(modelYAMLO,YamlUtil.afterChar(type,'.'),label);
+ if(reverseAttribute != null)
+ {
+ attribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(true));
+ if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(reverseAttribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ attribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,reverseAttribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(attribute.containsKeyMapStringListString(NAME))
+ {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ }
+ if(reverseAttribute.containsKeyMapStringListString(NAME))
+ {
+ attribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,reverseAttribute.getFirstMapStringListString(NAME));
+ }
+ }
+ //methode getReverseAttribute(mode,type,label)
+ //recuperer le reverse attribute
+ //TODO
+ //modelYAMLO.getFirstMapStringListYamlObject(YamlUtil.afterChar(type,'.')).get
+ //for()
+ }
+ else//unidirectionnel
+ {
+ YamlObject reverseObject = getReverseObject(modelYAMLO,YamlUtil.afterChar(type,'.'));
+ if(reverseObject != null)
+ {
+ YamlObject reverseAttribute = new YamlObject();
+ reverseAttribute.addStringToMap(NAVIGABLE,String.valueOf(false));
+ reverseAttribute.addStringToMap(TYPE,imports.get(labelisable.getFirstMapStringListString(NAME)));
+ if(attribute.containsKeyMapStringListString(MAX_MULTIPLICITY))
+ {
+ reverseAttribute.addStringToMap(REVERSE_MAX_MULTIPLICITY,attribute.getFirstMapStringListString(MAX_MULTIPLICITY));
+ }
+ if(attribute.containsKeyMapStringListString(NAME))
+ {
+ reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME,attribute.getFirstMapStringListString(NAME));
+ }
+ }
+ }
+ }
+ }
+ else//simple attribut
+ {
+ ;//ou gerer par valeurs par defaut ?
+ //associationType="composite"//default eugene
+ //minMultiplicity="1"//default eugene
+ //maxMultiplicity="1"//default eugene
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static YamlObject getReverseAttribute(YamlObject model, String type, String label)
+ {
+ for(List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values())
+ {
+ for(YamlObject objectYAMLO : objectsYAMLO)
+ {
+ if(objectYAMLO.containsKeyMapStringListString(NAME))
+ {
+ String name = objectYAMLO.getFirstMapStringListString(NAME);
+ if(name.equals(type))
+ {
+ if(objectYAMLO.containsKeyYamlMapStringListYamlObject(ATTRIBUTE))
+ {
+ for(YamlObject attributeYAMLO : objectYAMLO.getMapStringListYamlObject(ATTRIBUTE))
+ {
+ if(attributeYAMLO.containsKeyMapStringListString(LABEL))
+ {
+ String reverseLabel = attributeYAMLO.getFirstMapStringListString(LABEL);
+ if(reverseLabel.equals(label))
+ {
+ return attributeYAMLO;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static YamlObject getReverseObject(YamlObject model, String type)
+ {
+ for(List<YamlObject> objectsYAMLO : model.getMapStringListYamlObject().values())
+ {
+ for(YamlObject objectYAMLO : objectsYAMLO)
+ {
+ if(objectYAMLO.containsKeyMapStringListString(NAME))
+ {
+ String name = objectYAMLO.getFirstMapStringListString(NAME);
+ if(name.equals(type))
+ {
+ return objectYAMLO;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ /*Map<String,String> imports = new LinkedHashMap<String, String>();
+ imports.put("String","java.lang.String");
+ imports.put("List","java.util.List");
+ imports.put("Map","java.util.Map");
+ String type = "Map<List<String>,List<String>>";
+ System.out.println(resolveType(type,imports));*/
+ List<String> test = new LinkedList<String>();
+ test.add("test1");
+ test.add("test2");
+ test.add("\"test3\"");
+ test.remove(test.indexOf("test2"));
+ for(String str : test)
+ {
+ System.out.println(str);
+ }
+ }
+}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-05-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -13,19 +13,19 @@
//TODO: interface Syntaxe ou classe abstraite (appel l'operation suivante : charger l'ObjectModel)
//key.toLowerCase() ?
public class SyntaxePureYaml {
-
+ /*
public static void loadModelYaml(Object modelYAML, YamlObject modelYAMLO)
{
- loadYamlObject(modelYAML, modelYAMLO, "model");
+ loadYamlObject(modelYAML, modelYAMLO);
}
-
- public static void loadYamlObject(Object objectYaml, YamlObject modelYaml, String previous)
+ */
+ public static void loadYamlObject(Object objectYaml, YamlObject modelYaml)
{
if(objectYaml instanceof List)
{
for(Object tmp1 : (List) objectYaml)
{
- loadYamlObject(tmp1, modelYaml, previous);
+ loadYamlObject(tmp1, modelYaml);
}
}
else if(objectYaml instanceof Map)
@@ -35,7 +35,7 @@
if(((Map.Entry) tmp1).getValue() instanceof List || ((Map.Entry) tmp1).getValue() instanceof Map)
{
YamlObject tmp2 = new YamlObject();
- loadYamlObject(((Map.Entry) tmp1).getValue(),tmp2,String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase());
+ loadYamlObject(((Map.Entry) tmp1).getValue(),tmp2);
modelYaml.addYamlObjectToMap(String.valueOf(((Map.Entry) tmp1).getKey()).toLowerCase(),tmp2);
}
else
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-05-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -263,10 +263,10 @@
List<String> superInterfacesYAMLO = classifierYAMLO.getMapStringListString(SUPER_INTERFACES);
for(String superInterfaceYAMLO : superInterfacesYAMLO)
{
- log(" SUPER_INTERFACE");
ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
superInterfaceOM.setName(superInterfaceYAMLO);
classifierOM.addInterface(superInterfaceOM);
+ log("superInterface="+superInterfaceYAMLO);
}
}
@@ -288,10 +288,10 @@
List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
for(String superClassYAMLO : superClassesYAMLO)
{
- ObjectModelImplRef superClassOM = new ObjectModelImplRef();
+ ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
superClassOM.setName(superClassYAMLO);
- classOM.addInterface(superClassOM);
- log("superClasses="+classOM.getSuperclasses());
+ classOM.addSuperclass(superClassOM);
+ log("superClasses="+superClassYAMLO);
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-05-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -25,6 +25,23 @@
String syntaxeVersion;//version de la synatxe
String defaultVersion;//version des valeurs par defaut
+ private boolean _loginit = true;
+ private void log(String str) {
+ try {
+ FileWriter log;
+ String path = "/tmp/log.loadfile.txt";
+
+ if (_loginit) {
+ log = new FileWriter(path, false);
+ log.close();
+ _loginit = false;
+ }
+ log = new FileWriter(path, true);
+ log.write("[LOG] " + str + "\n");
+ log.close();
+ } catch (IOException e) {;}
+ }
+
public TestLoadYamlFile()
{
yaml = new Yaml();
@@ -38,33 +55,57 @@
inputModel.close();
//chercher version et charger en conséquent
- syntaxeVersion="1";
- defaultVersion="0";
+ Object version = null;
if(modelYAML instanceof List)
{
- Object version = YamlUtil.collectElement((List) modelYAML, SYNTAXE);
- if(version != null)
- {
- syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version),'.');
- defaultVersion = YamlUtil.afterChar(String.valueOf(version),'.');
- }
+ version = YamlUtil.collectElementList((List) modelYAML, SYNTAXE);
+ syntaxeVersion = "1";
+ defaultVersion = "0";
+ log("modelYAML instanceof List");
}
+ if(modelYAML instanceof Map)
+ {
+ version = YamlUtil.collectElementMap((Map) modelYAML, SYNTAXE);
+ syntaxeVersion = "2";
+ defaultVersion = "0";
+ log("modelYAML instanceof Map");
+ }
+ else
+ {
+ syntaxeVersion = "0";
+ defaultVersion = "0";
+ log("modelYAML instanceof unknow");
+ }
+ if(version != null)
+ {
+ syntaxeVersion = YamlUtil.beforeChar(String.valueOf(version),'.');
+ defaultVersion = YamlUtil.afterChar(String.valueOf(version),'.');
+ log("version="+syntaxeVersion+"."+defaultVersion);
+ }
+
if(syntaxeVersion.equals("1"))
{
- SyntaxePureYaml.loadModelYaml(modelYAML, modelYAMLO);
+ SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
+ log("load SyntaxePureYaml");
}
else if(syntaxeVersion.equals("2"))
{
- ;//syntaxe user firendly : coming soon
+ //syntaxe user firendly : coming soon
+ Parser test = new Parser();
+ test.parseModel(modelYAML, modelYAMLO);
+ Parser.resolveImports(modelYAMLO);
+ Parser.resolveLabels(modelYAMLO);
+ log("load SyntaxeUserFriendly");
}
else
{
;//syntaxe par defaut, si version syntaxe non reconnue
- SyntaxePureYaml.loadModelYaml(modelYAML, modelYAMLO);
+ SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
}
TestLoadObjectModel test = new TestLoadObjectModel();
test.loadModel(modelYAMLO,modelOM);
+ log("END");
//TODO: charger ObjectModel avec les valeurs par defaut en fonction de la version (ajouter parametre à loadModel)
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java 2013-05-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -146,6 +146,32 @@
return mapStringListString;
}
+ public boolean setMapStringListString(String key, String value, String element)
+ {
+ if(mapStringListString.containsKey(key))
+ {
+ if(mapStringListString.get(key).contains(value))
+ {
+ mapStringListString.get(key).set(mapStringListString.get(key).indexOf(value),element);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean setMapStringListYamlObject(String key, YamlObject value, YamlObject element)
+ {
+ if(mapStringListYamlObject.containsKey(key))
+ {
+ if(mapStringListYamlObject.get(key).contains(value))
+ {
+ mapStringListYamlObject.get(key).set(mapStringListYamlObject.get(key).indexOf(value),element);
+ return true;
+ }
+ }
+ return false;
+ }
+
public boolean removeMapStringListString(String key, String value)
{
if(mapStringListString.containsKey(key))
@@ -214,7 +240,12 @@
{
for(YamlObject yobj : entry.getValue())
{
- res.append(indentation).append(entry.getKey()).append(":\n").append(yobj.toString( " "+indentation)).append("\n");
+ //test temporaire
+ if(yobj != null)
+ {
+ res.append(indentation).append(entry.getKey()).append(":\n").append(yobj.toString( " "+indentation)).append("\n");
+ }
+ //test
}
}
return res.toString();
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-31 15:50:13 UTC (rev 1266)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-06-07 09:30:56 UTC (rev 1267)
@@ -61,7 +61,7 @@
return out.reverse().toString();
}
- public static Object collectElement(List data, Object key) {
+ public static Object collectElementList(List data, Object key) {
for (Object obj : data) {
if (obj instanceof Map) {
if (((Map) obj).containsKey(key)) {
@@ -72,7 +72,7 @@
return null;
}
- public static List<Object> collectAllElements(List data, Object key) {
+ public static List<Object> collectAllElementsList(List data, Object key) {
List<Object> res = new LinkedList<Object>();
for (Object obj : data) {
if (obj instanceof Map) {
@@ -83,4 +83,250 @@
}
return res;
}
+
+ public static Object collectElementMap(Map data, Object key)
+ {
+ if(data.containsKey(key))
+ {
+ return data.get(key);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ // fonctionnel/robuste/optimise
+ public static List<String> charParse(String str, Character target)
+ {
+ LinkedList<String> res = new LinkedList<String>();
+ StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ boolean pre = false;
+ for(Character c : str.toCharArray())
+ {
+ if(c.equals(target))
+ {
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ tmp.delete(0,tmp.length());
+ pre = false;
+ }
+ else
+ {
+ tmp.append(c);
+ pre = true;
+ }
+ }
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ return res;
+ }
+
+ // fonctionnel/robuste/optimise
+ public static List<String> multiCharParse(String str, List<Character> targets)
+ {
+ LinkedList<String> res = new LinkedList<String>();
+ StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ boolean pre = false;
+ for(Character c : str.toCharArray())
+ {
+ if(targets.contains(c))
+ {
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ tmp.delete(0,tmp.length());
+ pre = false;
+ }
+ else
+ {
+ tmp.append(c);
+ pre = true;
+ }
+ }
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ return res;
+ }
+
+ public static List<String> charParseIgnore(String str, Character target, Character ignoreStart, Character ignoreEnd)
+ {
+ LinkedList<String> res = new LinkedList<String>();
+ StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ boolean pre = false;
+ int ign = 0;//parentheses ouvertes
+ for(Character c : str.toCharArray())
+ {
+ if(c.equals(ignoreStart))
+ {
+ ign++;
+ tmp.append(c);
+ }
+ else if(c.equals(ignoreEnd))
+ {
+ ign--;
+ tmp.append(c);
+ }
+ else if(c.equals(target) && ign < 1)
+ {
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ tmp.delete(0,tmp.length());
+ pre = false;
+ }
+ else
+ {
+ tmp.append(c);
+ pre = true;
+ }
+ }
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ return res;
+ }
+
+ public static List<String> charParseMultiIgnore(String str, Character target, List<Character> ignoreStart, List<Character> ignoreEnd)
+ {
+ LinkedList<String> res = new LinkedList<String>();
+ StringBuilder tmp = new StringBuilder(str.length()+1);//+1 utile en Java ? != C
+ boolean pre = false;
+ int ign = 0;//parentheses ouvertes
+ for(Character c : str.toCharArray())
+ {
+ if(ignoreStart.contains(c))
+ {
+ ign++;
+ tmp.append(c);
+ }
+ else if(ignoreEnd.contains(c))
+ {
+ ign--;
+ tmp.append(c);
+ }
+ else if(c.equals(target) && ign < 1)
+ {
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ tmp.delete(0,tmp.length());
+ pre = false;
+ }
+ else
+ {
+ tmp.append(c);
+ pre = true;
+ }
+ }
+ if(pre)
+ {
+ res.add(tmp.toString());
+ }
+ return res;
+ }
+
+ public static String removeMultiChar(String str, List<Character> targets)
+ {
+ StringBuilder res = new StringBuilder(str.length()+1);
+ for(Character c : str.toCharArray())
+ {
+ if(!targets.contains(c))
+ {
+ res.append(c);
+ }
+ }
+ return res.toString();
+ }
+
+ public static String extract(Character start, Character end, String str)
+ {
+ StringBuilder tmp = new StringBuilder(str.length()+1);
+ boolean start_end = false;
+ int count = 0;
+ for(Character c : str.toCharArray())
+ {
+ if(!start_end && c.equals(start))
+ {
+ start_end = true;
+ }
+ else if(start_end && c.equals(start))
+ {
+ count++;
+ tmp.append(c);
+ }
+ else if(start_end && c.equals(end))
+ {
+ if(count>0)
+ {
+ count--;
+ tmp.append(c);
+ }
+ else
+ {
+ return tmp.toString();
+ }
+ }
+ else if(start_end)
+ {
+ tmp.append(c);
+ }
+ }
+ return null;
+ }
+
+ public static String extract(Character startend, String str)
+ {
+ StringBuilder tmp = new StringBuilder(str.length()+1);
+ boolean start_end = false;
+ for(Character c : str.toCharArray())
+ {
+ if(!start_end && c.equals(startend))
+ {
+ start_end = true;
+ }
+ else if(start_end && c.equals(startend))
+ {
+ return tmp.toString();
+ }
+ else if(start_end)
+ {
+ tmp.append(c);
+ }
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ /*List<Character> ignoreStart = new LinkedList<Character>();
+ ignoreStart.add('(');
+ ignoreStart.add('<');
+ List<Character> ignoreEnd = new LinkedList<Character>();
+ ignoreEnd.add(')');
+ ignoreEnd.add('>');
+ List<String> tmp = charParseMultiIgnore("public Map<Integer, String> Somme(List<String> bonjour, int y)",' ',ignoreStart,ignoreEnd);
+ for(String str : tmp)
+ {
+ System.out.println(str);
+ }*/
+ //System.out.println(beforeChar("11..**",'.'));
+ //System.out.println(afterChar("11..**",'.'));
+ //System.out.println(afterChar("java.lang.String",'.'));
+ List<String> test = charParseIgnore("Map<String,String,String>",',','<','>');
+ for(String str : test)
+ {
+ System.out.println(str);
+ }
+ System.out.println(extract('<','>',"<<<>>>"));
+ }
}
1
0