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
See <http://ci.nuiton.org/jenkins/job/eugene/1151/changes>
Changes:
[agiraudet] Refonte complète du template PlantUML et mise à jour de la version de la dépendance vers PlantUML
------------------------------------------
[...truncated 128 lines...]
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.tagvalue.string] : this tagvalue 'string' is unkown.
INFO [main] (ObjectModelReader.java:286) loadModelProperties - 5 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/test-classes…>
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:310) loadModelTagValue - Invalid model tag value [model.tagvalue.lejoliemodel] : the tagvalue 'lejoliemodel' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.Role.class.stereotype] : this stereotype 'Permission' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.Role.class.tagvalue.role] : this tagvalue 'role' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.stereotype] : this stereotype 'pk' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.tagvalue.string] : this tagvalue 'string' is unkown.
INFO [main] (ObjectModelReader.java:286) loadModelProperties - 5 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/test-classes…>
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:310) loadModelTagValue - Invalid model tag value [model.tagvalue.lejoliemodel] : the tagvalue 'lejoliemodel' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.Role.class.stereotype] : this stereotype 'Permission' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.Role.class.tagvalue.role] : this tagvalue 'role' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.stereotype] : this stereotype 'pk' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.tagvalue.string] : this tagvalue 'string' is unkown.
INFO [main] (ObjectModelReader.java:286) loadModelProperties - 5 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/test-classes…>
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:310) loadModelTagValue - Invalid model tag value [model.tagvalue.lejoliemodel] : the tagvalue 'lejoliemodel' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.Role.class.stereotype] : this stereotype 'Permission' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.Role.class.tagvalue.role] : this tagvalue 'role' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.stereotype] : this stereotype 'pk' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.tagvalue.string] : this tagvalue 'string' is unkown.
INFO [main] (ObjectModelReader.java:286) loadModelProperties - 5 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/test-classes…>
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.stereotype] : this stereotype 'pk' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.attribute.topiaId.tagvalue.string] : this tagvalue 'string' is unkown.
WARN [main] (ObjectModelReader.java:371) loadStereotype - Invalid stereotype [org.codelutin.topia.security.entities.RolePermission.class.stereotype] : this stereotype 'Permission' is unkown.
WARN [main] (ObjectModelReader.java:475) loadTagValue - Invalid tag value [org.codelutin.topia.security.entities.RolePermission.class.tagvalue.role] : this tagvalue 'role' is unkown.
INFO [main] (ObjectModelReader.java:286) loadModelProperties - 4 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/test-classes…>
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.559 sec
Running org.nuiton.eugene.models.object.xml.ExternalCacheExtensionTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Running org.nuiton.eugene.models.object.xml.ObjectModelImplTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec
Running org.nuiton.eugene.models.object.xml.ObjectModelBuilderTest
Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec
Running org.nuiton.eugene.models.object.XMI21ToObjectModelTest
INFO [main] (TestHelper.java:58) getTestWorkdir - basedir for test <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/surefire-wor…>
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
Recoverable error on line 877
FODC0002: java.io.FileNotFoundException:
<http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/conception-helper.u…> (No such
file or directory)
Recoverable error on line 877
FODC0002: java.io.FileNotFoundException:
<http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/conception-helper.u…> (No such
file or directory)
Recoverable error on line 877
FODC0002: java.io.FileNotFoundException:
<http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/conception-helper.u…> (No such
file or directory)
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
Recoverable error on line 877
FODC0002: java.io.FileNotFoundException:
/var/local/jenkins/data/jobs/vpod-api/src/main/uml/conception.uml (No such file or directory)
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.937 sec
Running org.nuiton.eugene.models.object.XMI12ToObjectModelTest
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
WARN [main] (ObjectModelReader.java:140) read - No properties provider filled, will instanciate a new default one
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.113 sec
Running org.nuiton.eugene.models.object.ObjectModelGeneratorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running org.nuiton.eugene.GeneratorUtilTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.036 sec
Running org.nuiton.eugene.java.JavaBuilderTest
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec
Running org.nuiton.eugene.java.extension.ImportsManagerExtensionTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running org.nuiton.eugene.java.extension.ImportsManagerTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
Running org.nuiton.eugene.java.JavaGeneratorUtilTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Results :
Tests run: 80, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ eugene ---
[INFO] Building jar: <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/eugene-2.6.4…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ eugene ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ eugene ---
[INFO] Installing <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/eugene-2.6.4…> to /var/local/maven/data/repository/org/nuiton/eugene/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT.jar
[INFO] Installing <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/pom.xml> to /var/local/maven/data/repository/org/nuiton/eugene/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EUGene :: Java templates 2.6.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ eugene-java-templates ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ eugene-java-templates ---
[INFO]
[INFO] --- processor-maven-plugin:1.3:process (default) @ eugene-java-templates ---
[INFO] Processing 10 files(s).
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ eugene-java-templates ---
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ eugene-java-templates ---
[INFO] Compiling 10 source files to <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
[INFO]
[INFO] --- plexus-component-metadata:1.5.5:generate-metadata (default) @ eugene-java-templates ---
[INFO] Discovered 5 component descriptors(s)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ eugene-java-templates ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ eugene-java-templates ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ eugene-java-templates ---
[INFO] Compiling 1 source file to <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ eugene-java-templates ---
[INFO] Surefire report directory: <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.nuiton.eugene.java.JavaTemplatesModelPropertiesProviderTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.204 sec
Results :
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ eugene-java-templates ---
[INFO] Building jar: <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ eugene-java-templates ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ eugene-java-templates ---
[INFO] Installing <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…> to /var/local/maven/data/repository/org/nuiton/eugene/eugene-java-templates/2.6.4-SNAPSHOT/eugene-java-templates-2.6.4-SNAPSHOT.jar
[INFO] Installing <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/pom.…> to /var/local/maven/data/repository/org/nuiton/eugene/eugene-java-templates/2.6.4-SNAPSHOT/eugene-java-templates-2.6.4-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EUGene :: PlantUML templates 2.6.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/net/sourceforge/plantum…
[WARNING] The POM for net.sourceforge.plantuml:plantuml:jar:7968 is missing, no dependency information available
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/net/sourceforge/plantum…
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] EUGene ............................................ SUCCESS [7.583s]
[INFO] EUGene :: EUGene .................................. SUCCESS [27.770s]
[INFO] EUGene :: Java templates .......................... SUCCESS [2.736s]
[INFO] EUGene :: PlantUML templates ...................... FAILURE [0.472s]
[INFO] EUGene :: YAML templates .......................... SKIPPED
[INFO] EUGene :: Maven plugin ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.190s
[INFO] Finished at: Fri Jun 14 11:41:15 CEST 2013
[INFO] Final Memory: 28M/187M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/pom.xml> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton$eugene/builds/2013-06-14_11-40-30/archive/org.nuiton/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/target/eugene-2.6.4-SNAPSH…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton$eugene/builds/2013-06-14_11-40-30/archive/org.nuiton/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT-site_en.xml
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/target/eugene-2.6.4-SNAPSH…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton$eugene/builds/2013-06-14_11-40-30/archive/org.nuiton/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT-site_fr.xml
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-plantuml-templates/…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene-plantuml-templates/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene-plantuml-templates/2.6.4-SNAPSHOT/eugene-plantuml-templates-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-yaml-templates/pom.…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene-yaml-templates/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene-yaml-templates/2.6.4-SNAPSHOT/eugene-yaml-templates-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-maven-plugin/pom.xml> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene-maven-plugin/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene-maven-plugin/2.6.4-SNAPSHOT/eugene-maven-plugin-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/pom.xml> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene/target/eugene-2.6.4…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene/2.6.4-SNAPSHOT/eugene-2.6.4-SNAPSHOT.jar
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/pom.…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene-java-templates/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene-java-templates/2.6.4-SNAPSHOT/eugene-java-templates-2.6.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/eugene/ws/trunk/eugene-java-templates/targ…> to /var/local/jenkins/data/jobs/eugene/modules/org.nuiton.eugene$eugene-java-templates/builds/2013-06-14_11-40-30/archive/org.nuiton.eugene/eugene-java-templates/2.6.4-SNAPSHOT/eugene-java-templates-2.6.4-SNAPSHOT.jar
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal on project eugene-plantuml-templates: Could not resolve dependencies for project org.nuiton.eugene:eugene-plantuml-templates:jar:2.6.4-SNAPSHOT: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
cause : Could not resolve dependencies for project org.nuiton.eugene:eugene-plantuml-templates:jar:2.6.4-SNAPSHOT: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project eugene-plantuml-templates: Could not resolve dependencies for project org.nuiton.eugene:eugene-plantuml-templates:jar:2.6.4-SNAPSHOT: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:210)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:117)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
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:329)
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: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.nuiton.eugene:eugene-plantuml-templates:jar:2.6.4-SNAPSHOT: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:189)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:185)
... 30 more
Caused by: org.sonatype.aether.resolution.DependencyResolutionException: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:375)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:183)
... 31 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:358)
... 32 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact net.sourceforge.plantuml:plantuml:jar:7968 in central (http://nexus.nuiton.org/nexus/content/groups/public)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
... 3 more
Failed to send e-mail to agiraudet because no e-mail address is known, and no default e-mail domain is configured
Sending e-mails to: eugene-commits(a)list.nuiton.org
channel stopped
Failed to send e-mail to agiraudet because no e-mail address is known, and no default e-mail domain is configured
1
1
Build failed in Jenkins: eugene » EUGene :: PlantUML templates #1151
by admin+hudson@codelutin.com 17 Jun '13
by admin+hudson@codelutin.com 17 Jun '13
17 Jun '13
See <http://ci.nuiton.org/jenkins/job/eugene/org.nuiton.eugene$eugene-plantuml-t…>
Changes:
[agiraudet] Refonte complète du template PlantUML et mise à jour de la version de la dépendance vers PlantUML
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EUGene :: PlantUML templates 2.6.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/net/sourceforge/plantum…
[WARNING] The POM for net.sourceforge.plantuml:plantuml:jar:7968 is missing, no dependency information available
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/net/sourceforge/plantum…
1
1
r1280 - in trunk: eugene-plantuml-templates/src eugene-plantuml-templates/src/site eugene-plantuml-templates/src/site/resources eugene-plantuml-templates/src/site/resources/images src/site/fr/rst src/site/rst
by agiraudet@users.nuiton.org 14 Jun '13
by agiraudet@users.nuiton.org 14 Jun '13
14 Jun '13
Author: agiraudet
Date: 2013-06-14 18:24:07 +0200 (Fri, 14 Jun 2013)
New Revision: 1280
Url: http://nuiton.org/projects/eugene/repository/revisions/1280
Log:
fixes #2708: documentation template plantuml ok (correction probl?\195?\168me arborescence et lien index de eugene)
Added:
trunk/eugene-plantuml-templates/src/site/resources/
trunk/eugene-plantuml-templates/src/site/resources/images/
trunk/eugene-plantuml-templates/src/site/resources/images/Pollen.png
trunk/eugene-plantuml-templates/src/site/resources/images/legend1.png
trunk/eugene-plantuml-templates/src/site/resources/images/legend2.png
trunk/eugene-plantuml-templates/src/site/resources/images/legend3.png
Removed:
trunk/eugene-plantuml-templates/src/resources/
Modified:
trunk/src/site/fr/rst/index.rst
trunk/src/site/rst/index.rst
Added: trunk/eugene-plantuml-templates/src/site/resources/images/Pollen.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/images/Pollen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/images/legend1.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/images/legend1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/images/legend2.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/images/legend2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/images/legend3.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/images/legend3.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/site/fr/rst/index.rst
===================================================================
--- trunk/src/site/fr/rst/index.rst 2013-06-14 15:43:32 UTC (rev 1279)
+++ trunk/src/site/fr/rst/index.rst 2013-06-14 16:24:07 UTC (rev 1280)
@@ -55,11 +55,13 @@
* `eugene-api`_ (Api de base d'EUGene)
* `eugene-java-templates`_ (Templates pour générer des classes java)
+ * `eugene-plantuml-templates`_ (depuis la version 2.7) (Templates pour générer des diagrammes plantumlclasses java)
* `eugene-maven-plugin`_ (Plugin maven pour lancer des générations)
.. _eugene-api: ../eugene/fr/index.html
.. _eugene-java-templates: ../eugene-java-templates/fr/index.html
.. _eugene-maven-plugin: ../eugene-maven-plugin/fr/index.html
+.. _eugene-plantuml-templates: ../eugene-plantuml-templates/fr/index.html
Plus d'infos sur le projet sur la `forge nuiton`_ .
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2013-06-14 15:43:32 UTC (rev 1279)
+++ trunk/src/site/rst/index.rst 2013-06-14 16:24:07 UTC (rev 1280)
@@ -61,6 +61,7 @@
.. _eugene-api: eugene/index.html
.. _eugene-java-templates: ../eugene-java-templates/fr/index.html
.. _eugene-maven-plugin: eugene-maven-plugin/index.html
+.. _eugene-plantuml-templates: ../eugene-plantuml-templates/index.html
More info on the project on `nuiton's forge`_ .
1
0
14 Jun '13
Author: agiraudet
Date: 2013-06-14 17:43:32 +0200 (Fri, 14 Jun 2013)
New Revision: 1279
Url: http://nuiton.org/projects/eugene/repository/revisions/1279
Log:
refs #2708: correction des liens et des images
relecture du code (commentaires, corrections...)
Added:
trunk/eugene-plantuml-templates/src/resources/
trunk/eugene-plantuml-templates/src/resources/images/
trunk/eugene-plantuml-templates/src/resources/images/Pollen.png
trunk/eugene-plantuml-templates/src/resources/images/legend1.png
trunk/eugene-plantuml-templates/src/resources/images/legend2.png
trunk/eugene-plantuml-templates/src/resources/images/legend3.png
Removed:
trunk/eugene-plantuml-templates/src/site/resources/
Modified:
trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
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/DefaultValues.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/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
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/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/YamlObjectModelReader.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/YamlObjectModelReader.java 2013-06-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/YamlObjectModelReader.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -45,8 +45,7 @@
public class YamlObjectModelReader extends AbstractObjectModelReader {
private static final Log log = LogFactory.getLog(YamlObjectModelReader.class);
- //protected YamlToObjectModel yamlToObjectModel;
- protected LoadYamlFile test;
+ protected LoadYamlFile loaderYAML;
@Override
public String getInputType() {
@@ -56,15 +55,13 @@
@Override
protected void beforeReadFile(File... files) {
super.beforeReadFile(files);
- //yamlToObjectModel = new YamlToObjectModel();
- test = new LoadYamlFile();
+ loaderYAML = new LoadYamlFile();
}
@Override
protected void readFileToModel(File file, ObjectModel model) throws IOException {
try {
- //yamlToObjectModel.loadFile(file,model);
- test.loadFile(file,model);
+ loaderYAML.loadFile(file, model);
} catch (YAMLException e) {
throw new IOException("Unable to parse ObjectModel input file : " + file, e);
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -24,6 +24,7 @@
public static Map<String, String> getDefaultValues(String version) {
Map<String, String> values = new LinkedHashMap<String, String>();
+ //retourne les valeurs par defaut en fonction de la version dans une Map
if (version.equals("0")) {
values.put(ATTRIBUTE + SEPARATOR + MIN_MULTIPLICITY, "1");
values.put(ATTRIBUTE + SEPARATOR + MAX_MULTIPLICITY, "1");
@@ -37,7 +38,7 @@
return values;
}
- //retourne les valeurs par defaut du fichier YAML passe an parametre
+ //retourne les valeurs par defaut du fichier YAML passé en parametre
public Map<String, String> getDefaultValues(File file) throws IOException {
InputStream inputModel = new FileInputStream(file);
Object valuesYAML = yaml.load(inputModel);
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -29,7 +29,7 @@
String INNER = "inner";
String INTERFACE = "interface";
String LABEL = "label";
- String LITERAL = "literal";
+ String LITERALS = "literals";
String MAX_MULTIPLICITY = "maxmultiplicity";
String MIN_MULTIPLICITY = "minmultiplicity";
String NAME = "name";
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -22,7 +22,7 @@
this.modelYAMLO = modelYAMLO;
this.defaultValues = defaultValues;
//log
- Log.initLog(modelYAMLO.toString(), "/tmp/log.LoadObjectModel.txt");
+ //Log.initLog(modelYAMLO.toString(), "/tmp/log.LoadObjectModel.txt");
//log
}
@@ -49,6 +49,7 @@
modelOM.setName(nameYAMLO);
}
+ //version
String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
if (versionYAMLO == null) {
String key = VERSION;
@@ -59,8 +60,7 @@
modelOM.setVersion(versionYAMLO);
}
- //tageValues
- //TODO: tester
+ //tagValues
YamlObject tagValues = modelYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
if (tagValues != null) {
for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
@@ -98,6 +98,7 @@
}
public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) {
+ //name
String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
String key = ELEMENT + SEPARATOR + NAME;
@@ -108,6 +109,7 @@
elementOM.setName(nameYAMLO);
}
+ //static
String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
String key = ELEMENT + SEPARATOR + STATIC;
@@ -118,6 +120,7 @@
elementOM.setStatic(Boolean.valueOf(staticYAMLO));
}
+ //documentation
String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
if (documentationYAMLO == null) {
String key = ELEMENT + SEPARATOR + DOCUMENTATION;
@@ -128,7 +131,7 @@
elementOM.setDocumentation(documentationYAMLO);
}
- //TODO: tester
+ //tagValues
YamlObject tagValues = elementYAMLO.getFirstMapStringListYamlObject(TAG_VALUES);
if (tagValues != null) {
for (Map.Entry<String, List<String>> tagValue : tagValues.getMapStringListString().entrySet()) {
@@ -139,12 +142,13 @@
}
}
+ //comments
List<String> comments = elementYAMLO.getMapStringListString(COMMENTS);
for (String comment : comments) {
elementOM.addComment(comment);
}
- //TODO: ajouter setereotype par defaut
+ //stereotypes
List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
for (String stereotype : stereotypes) {
ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
@@ -156,6 +160,7 @@
public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM) {
loadElement(classifierYAMLO, classifierOM);
+ //package
String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
if (packageYAMLO == null) {
classifierOM.setPackage(packageL);
@@ -163,7 +168,7 @@
classifierOM.setPackage(packageYAMLO);
}
-
+ //extern
String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
if (externYAMLO == null) {
String key = CLASSIFIER + SEPARATOR + EXTERN;
@@ -175,6 +180,7 @@
}
+ //inner
String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
if (innerYAMLO == null) {
String key = CLASSIFIER + SEPARATOR + INNER;
@@ -185,6 +191,7 @@
classifierOM.setInner(Boolean.valueOf(innerYAMLO));
}
+ //type
String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
String key = CLASSIFIER + SEPARATOR + TYPE;
@@ -195,18 +202,21 @@
classifierOM.setType(typeYAMLO);
}
+ //attributes
for (YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
loadAttribute(attributeYAMLO, attributeOM);
classifierOM.addAttribute(attributeOM);
}
+ //operations
for (YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION)) {
ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
loadOperation(operationYAMLO, operationOM);
classifierOM.addOperation(operationOM);
}
+ //superInterfaces
List<String> superInterfacesYAMLO = classifierYAMLO.getMapStringListString(SUPER_INTERFACES);
for (String superInterfaceYAMLO : superInterfacesYAMLO) {
ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
@@ -218,6 +228,7 @@
public void loadClass(YamlObject classYAMLO, ObjectModelClassImpl classOM) {
loadClassifier(classYAMLO, classOM);
+ //abstract
String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
String key = CLASS + SEPARATOR + ABSTRACT;
@@ -228,6 +239,7 @@
classOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
+ //superClasses
List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
for (String superClassYAMLO : superClassesYAMLO) {
ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
@@ -245,10 +257,11 @@
//TODO: remplacer name par type et attribute par name ? -> confusion
//TODO: remplacer PARTICIPANT par PARTICIPANTS (List)
+ //participants
for (YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT)) {
ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
participantOM.setAssociationClass(associationClassOM);
-
+ //name
String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + NAME;
@@ -258,7 +271,7 @@
} else {
participantOM.setName(nameYAMLO);
}
-
+ //attribute
String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
if (attributeYAMLO == null) {
String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + ATTRIBUTE;
@@ -277,13 +290,15 @@
loadElement(enumerationYAMLO, enumerationOM);
//TODO: remplacer LITERAL par LITERALS (List)
- List<String> literalsYAMLO = enumerationYAMLO.getMapStringListString(LITERAL);
+ //lierals
+ List<String> literalsYAMLO = enumerationYAMLO.getMapStringListString(LITERALS);
for (String literalYAMLO : literalsYAMLO) {
ObjectModelImplRef literalOM = new ObjectModelImplRef();
literalOM.setName(literalYAMLO);
enumerationOM.addLiteral(literalOM);
}
+ //package
String packageYAMLO = enumerationYAMLO.getFirstMapStringListString(PACKAGE);
if (packageYAMLO == null) {
enumerationOM.setPackage(packageL);
@@ -295,6 +310,7 @@
public void loadParameter(YamlObject parameterYAMLO, ObjectModelParameterImpl parameterOM) {
loadElement(parameterYAMLO, parameterOM);
+ //ordering
String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
if (orderingYAMLO == null) {
String key = PARAMETER + SEPARATOR + ORDERING;
@@ -305,6 +321,7 @@
parameterOM.setOrdering(orderingYAMLO);
}
+ //type
String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
String key = PARAMETER + SEPARATOR + TYPE;
@@ -315,6 +332,7 @@
parameterOM.setType(typeYAMLO);
}
+ //defaultValues
String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
if (defaultValueYAMLO == null) {
String key = PARAMETER + SEPARATOR + DEFAULT_VALUE;
@@ -325,6 +343,7 @@
parameterOM.setDefaultValue(defaultValueYAMLO);
}
+ //minMultiplicity
String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
if (minMultiplicityYAMLO == null) {
String key = PARAMETER + SEPARATOR + MIN_MULTIPLICITY;
@@ -335,6 +354,7 @@
parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
}
+ //maxMultiplicity
String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
if (maxMultiplicityYAMLO == null) {
String key = PARAMETER + SEPARATOR + MAX_MULTIPLICITY;
@@ -346,6 +366,7 @@
}
+ //ordered
String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
if (orderedYAMLO == null) {
String key = PARAMETER + SEPARATOR + ORDERED;
@@ -356,6 +377,7 @@
parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
}
+ //unique
String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
if (uniqueYAMLO == null) {
String key = PARAMETER + SEPARATOR + UNIQUE;
@@ -370,6 +392,7 @@
public void loadAttribute(YamlObject attributeYAMLO, ObjectModelAttributeImpl attributeOM) {
loadParameter(attributeYAMLO, attributeOM);
+ //navigable
String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
if (navigableYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + NAVIGABLE;
@@ -380,6 +403,7 @@
attributeOM.setNavigable(Boolean.valueOf(navigableYAMLO));
}
+ //associationType
String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
if (associationTypeYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_TYPE;
@@ -390,6 +414,7 @@
attributeOM.setAssociationType(associationTypeYAMLO);
}
+ //final
String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
if (finalYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + FINAL;
@@ -400,6 +425,7 @@
attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
}
+ //static
String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + STATIC;
@@ -410,6 +436,7 @@
attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
}
+ //associationClassName
String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
if (associationClassNameYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_CLASS_NAME;
@@ -420,6 +447,7 @@
attributeOM.setAssociationClassName(associationClassNameYAMLO);
}
+ //reverseAttributeName
String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
if (reverseAttributeNameYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + REVERSE_ATTRIBUTE_NAME;
@@ -430,6 +458,7 @@
attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
}
+ //reverseMaxMultiplicity
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
if (reverseMaxMultiplicityYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + REVERSE_MAX_MULTIPLICITY;
@@ -440,6 +469,7 @@
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
}
+ //transient
String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
if (transientYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + TRANSIENT;
@@ -450,6 +480,7 @@
attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
}
+ //visibility
String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
String key = ATTRIBUTE + SEPARATOR + VISIBILITY;
@@ -464,6 +495,7 @@
public void loadOperation(YamlObject operationYAMLO, ObjectModelOperationImpl operationOM) {
loadElement(operationYAMLO, operationOM);
+ //abstract
String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
String key = OPERATION + SEPARATOR + ABSTRACT;
@@ -474,6 +506,7 @@
operationOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
+ //visibility
String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
String key = OPERATION + SEPARATOR + VISIBILITY;
@@ -484,18 +517,21 @@
operationOM.setVisibility(visibilityYAMLO);
}
+ //returnParameter
for (YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
ObjectModelParameterImpl returnParameterOM = new ObjectModelAttributeImpl();
loadParameter(returnParameterYAMLO, returnParameterOM);
operationOM.setReturnParameter(returnParameterOM);
}
+ //parameter
for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
loadParameter(parameterYAMLO, parameterOM);
operationOM.addParameter(parameterOM);
}
+ //bodyCode
String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
if (bodyCodeYAMLO == null) {
String key = OPERATION + SEPARATOR + BODY_CODE;
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -24,6 +24,7 @@
}
public void loadFile(File file, ObjectModel model) throws IOException {
+ //parse le fichier YAML
InputStream inputModel = new FileInputStream(file);
Object modelYAML = yaml.load(inputModel);
inputModel.close();
@@ -31,6 +32,7 @@
ObjectModelImpl modelOM = (ObjectModelImpl) model;
YamlObject modelYAMLO = new YamlObject();
+ //recherche la version
Object version = null;
String syntaxeVersion = "0";
String defaultVersion = "0";
@@ -50,6 +52,7 @@
defaultVersion = YamlUtil.afterChar(String.valueOf(version), '.');
}
+ //charge le modele en fonction de la version
if (syntaxeVersion.equals("1")) {
SyntaxePureYaml.loadYamlObject(modelYAML, modelYAMLO);
} else if (syntaxeVersion.equals("2")) {
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserPureYaml.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -10,6 +10,7 @@
*/
public class ParserPureYaml {
+ //charge recursivement le modelYAML dans le modelYAMLO
public static void parseModel(Object modelYAML, YamlObject modelYAMLO) {
if (modelYAML instanceof List) {
for (Object tmp1 : (List) modelYAML) {
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -49,7 +49,6 @@
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));
}
}
@@ -166,7 +165,6 @@
}
}
- //TODO: factoriser le code (classifier)
public void parseInterface(String key, Object value, YamlObject interfaceYAMLO) {
List<String> interfacePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
if (interfacePARSE.contains(INTERFACE)) {
@@ -310,7 +308,7 @@
}
if (value instanceof Map) {
- //TODO: utiliser variable locales pour plus de clartee
+ //TODO: utiliser variable locales
if (((Map) value).containsKey(PARTICIPANT)) {
if (((Map) value).get(PARTICIPANT) instanceof Map) {
for (Object entry : ((Map) ((Map) value).get(PARTICIPANT)).entrySet()) {
@@ -405,16 +403,16 @@
}
if (value instanceof Map) {
- //TODO: utiliser variable locales pour plus de clartee
- if (((Map) value).containsKey(LITERAL)) {
- if (((Map) value).get(LITERAL) instanceof Map) {
- for (Object entry : ((Map) ((Map) value).get(LITERAL)).entrySet()) {
+ //TODO: utiliser variable locales
+ if (((Map) value).containsKey(LITERALS)) {
+ if (((Map) value).get(LITERALS) instanceof Map) {
+ for (Object entry : ((Map) ((Map) value).get(LITERALS)).entrySet()) {
if (entry instanceof Map.Entry) {
- enumerationYAMLO.addStringToMap(LITERAL, String.valueOf(((Map.Entry) entry).getKey()));
+ enumerationYAMLO.addStringToMap(LITERALS, String.valueOf(((Map.Entry) entry).getKey()));
}
}
}
- ((Map) value).remove(LITERAL);
+ ((Map) value).remove(LITERALS);
}
}
@@ -687,7 +685,7 @@
}
return res.toString();
}
-
+ // String -> java.lang.String
public String resolveType(String type) {
List<Character> ignore = new LinkedList<Character>();
ignore.add(' ');
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/SyntaxePureYaml.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -5,6 +5,7 @@
* Date: 30/05/13
* Time: 11:23
*/
+//TODO: interface Syntaxe pour futures syntaxes
public class SyntaxePureYaml {
public static void loadYamlObject(Object modelYAML, YamlObject modelYAMLO) {
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-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlObject.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -9,11 +9,15 @@
* User: agiraudet
* Date: 28/05/13
* Time: 16:41
+ *
+ * le YamlObject est un objet intermédiaire et très laxiste, pouvant s'adapter à d'éventuelles évolutions
+ * (en cas d'évolutions de la syntaxe YAML ou de l'ObjectModel, les modifications permettant de conserver les interactions seront légères)
+ *
*/
public class YamlObject {
protected Map<String, List<String>> mapStringListString;
protected Map<String, List<YamlObject>> mapStringListYamlObject;
- //TODO: améliorer nom méthodes
+ //TODO: améliorer noms méthodes
public YamlObject() {
mapStringListString = new LinkedHashMap<String, List<String>>();
@@ -80,7 +84,7 @@
return mapStringListYamlObject.get(key);
}
}
- //return null;
+ //return null;//permet parcours
return new LinkedList<YamlObject>();
}
@@ -90,7 +94,7 @@
return mapStringListString.get(key);
}
}
- //return null;
+ //return null;//permet parcours
return new LinkedList<String>();
}
@@ -189,11 +193,9 @@
}
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");
}
- //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-06-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -96,6 +96,7 @@
}
}
+ //decoupe une chaine par le caractere passe en parametre
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
@@ -140,6 +141,7 @@
return res;
}
+ //permet de parser une chaine en ignorant les parentheses par exemple
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
@@ -208,6 +210,7 @@
return res.toString();
}
+ //extrait une chaine delimitee par les caracteres en parametres
public static String extract(Character start, Character end, String str) {
StringBuilder tmp = new StringBuilder(str.length() + 1);
boolean start_end = false;
Added: trunk/eugene-plantuml-templates/src/resources/images/Pollen.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/resources/images/Pollen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/resources/images/legend1.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/resources/images/legend1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/resources/images/legend2.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/resources/images/legend2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/resources/images/legend3.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/resources/images/legend3.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst
===================================================================
--- trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst 2013-06-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst 2013-06-14 15:43:32 UTC (rev 1279)
@@ -31,17 +31,17 @@
Présentation
------------
-Le plugin *eugene-plantuml-templates* est un template permettant de générer un diagramme de classes `PlantUML` à partir d'un `ObjectModel` au moment de l'installation d'un projet.
-`PlantUML` utilise Graphviz lors de la génération d'images, si vous ne pouvez pas installer `Graphviz`, le `PlantUML Server` permet de générer des diagrammes en ligne.
+Le plugin *eugene-plantuml-templates* est un template permettant de générer un diagramme de classes `PlantUML`_ à partir d'un `ObjectModel`_ au moment de l'installation d'un projet.
+`PlantUML`_ utilise Graphviz lors de la génération d'images, si vous ne pouvez pas installer `Graphviz`_, le `PlantUML Server`_ permet de générer des diagrammes en ligne.
Démonstration
-----------------------------
-Voici un exemple d'utilisation du plugin *eugene-plantuml-templates* avec le projet `Pollen`.
+Voici un exemple d'utilisation du plugin *eugene-plantuml-templates* avec le projet `Pollen`_.
Ajouter le template dans le pom.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Après avoir récupéré les sources du projet `Pollen`, on ajoute le template PlantUML au fichier pollen-persistence/pom.xml (sans oublier la virgule pour séparer les templates)::
+Après avoir récupéré les sources du projet `Pollen`_, on ajoute le template PlantUML au fichier pollen-persistence/pom.xml (sans oublier la virgule pour séparer les templates)::
<templates>
org.nuiton.topia.generator.TopiaMetaTransformer,
@@ -52,29 +52,36 @@
Installation du projet
~~~~~~~~~~~~~~~~~~~~~~
On lance ensuite l'installation avec la commande::
+
pollen$ mvn install
+
La ligne suivante devrait apparaitre lors de l'installation::
+
[INFO] Apply generator PlantumlTemplatesGenerator"
Résultat
~~~~~~~~
Le diagramme de classe se trouve dans le répertoire pollen-persistence/target/classes (ou pollen-persistence/target/generated-sources/java):
-Pollen.plantuml est la représentation textuelle du modèle en `PlantUML`
-Pollen.png est l'image générée par `PlantUML` à partir du fichier Pollen.plantuml
-Pour générer le diagramme à partir du `PlantUML Server`, il suffit de copier le contenu du fichier Pollen.plantuml dans le formulaire du site et d'envoyer.
+Pollen.plantuml est la représentation textuelle du modèle en `PlantUML`_
+Pollen.png est l'image générée par `PlantUML`_ à partir du fichier Pollen.plantuml
+Pour générer le diagramme à partir du `PlantUML Server`_, il suffit de copier le contenu du fichier Pollen.plantuml dans le formulaire du site et d'envoyer.
Voici à quoi devrait ressembler le diagramme:
+
.. image:: ../images/Pollen.png
Légende
~~~~~~~
Visibilité:
+
.. image:: ../images/legend1.png
Abstract & Static:
+
.. image:: ../images/legend2.png
Relations:
+
.. image:: ../images/legend3.png
.. _PlantUML : http://plantuml.sourceforge.net/index.html
Modified: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
===================================================================
--- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278)
+++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-14 15:43:32 UTC (rev 1279)
@@ -16,7 +16,7 @@
@Override
public void generateFromModel(Writer output, ObjectModel input) throws IOException {
- ;//TODO:
+ ;//TODO
}
@Override
1
0
14 Jun '13
Author: agiraudet
Date: 2013-06-14 16:23:53 +0200 (Fri, 14 Jun 2013)
New Revision: 1278
Url: http://nuiton.org/projects/eugene/repository/revisions/1278
Log:
refs #2708: ajout d'une documentation sur le template PlantUML
Added:
trunk/eugene-plantuml-templates/src/site/
trunk/eugene-plantuml-templates/src/site/fr/
trunk/eugene-plantuml-templates/src/site/fr/rst/
trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst
trunk/eugene-plantuml-templates/src/site/resources/
trunk/eugene-plantuml-templates/src/site/resources/Pollen.png
trunk/eugene-plantuml-templates/src/site/resources/legend1.png
trunk/eugene-plantuml-templates/src/site/resources/legend2.png
trunk/eugene-plantuml-templates/src/site/resources/legend3.png
trunk/eugene-plantuml-templates/src/site/rst/
trunk/eugene-plantuml-templates/src/site/rst/index.rst
trunk/eugene-plantuml-templates/src/site/site_en.xml
trunk/eugene-plantuml-templates/src/site/site_fr.xml
Modified:
trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -17,20 +17,17 @@
public class DefaultValues implements KeyWords {
Yaml yaml;
- public DefaultValues()
- {
+ public DefaultValues() {
yaml = new Yaml();
}
- public static Map<String,String> getDefaultValues(String version)
- {
- Map<String,String> values = new LinkedHashMap<String, String>();
+ public static Map<String, String> getDefaultValues(String version) {
+ Map<String, String> values = new LinkedHashMap<String, String>();
- if(version.equals("0"))
- {
- values.put(ATTRIBUTE+SEPARATOR+MIN_MULTIPLICITY,"1");
- values.put(ATTRIBUTE+SEPARATOR+MAX_MULTIPLICITY,"1");
- values.put(ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY,"1");
+ if (version.equals("0")) {
+ values.put(ATTRIBUTE + SEPARATOR + MIN_MULTIPLICITY, "1");
+ values.put(ATTRIBUTE + SEPARATOR + MAX_MULTIPLICITY, "1");
+ values.put(ATTRIBUTE + SEPARATOR + REVERSE_MAX_MULTIPLICITY, "1");
}
/*else if(version.equals(""))
{
@@ -41,19 +38,16 @@
}
//retourne les valeurs par defaut du fichier YAML passe an parametre
- public Map<String,String> getDefaultValues(File file) throws IOException {
+ public Map<String, String> getDefaultValues(File file) throws IOException {
InputStream inputModel = new FileInputStream(file);
Object valuesYAML = yaml.load(inputModel);
inputModel.close();
- Map<String,String> values = new LinkedHashMap<String, String>();
- if(valuesYAML instanceof Map)
- {
- for(Object entry : ((Map) valuesYAML).entrySet())
- {
- if(entry instanceof Map.Entry)
- {
- values.put(String.valueOf(((Map.Entry) entry).getKey()),String.valueOf(((Map.Entry) entry).getValue()));
+ Map<String, String> values = new LinkedHashMap<String, String>();
+ if (valuesYAML instanceof Map) {
+ for (Object entry : ((Map) valuesYAML).entrySet()) {
+ if (entry instanceof Map.Entry) {
+ values.put(String.valueOf(((Map.Entry) entry).getKey()), String.valueOf(((Map.Entry) entry).getValue()));
}
}
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -14,15 +14,15 @@
protected String packageL;
protected YamlObject modelYAMLO;
protected ObjectModelImpl modelOM;
- protected Map<String,String> defaultValues;
+ protected Map<String, String> defaultValues;
- public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM, Map<String,String> defaultValues) {
+ public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM, Map<String, String> defaultValues) {
this.packageL = "default";
this.modelOM = modelOM;
this.modelYAMLO = modelYAMLO;
this.defaultValues = defaultValues;
//log
- //Log.initLog(modelYAMLO.toString(),"/tmp/log.LoadObjectModel.txt");
+ Log.initLog(modelYAMLO.toString(), "/tmp/log.LoadObjectModel.txt");
//log
}
@@ -30,21 +30,19 @@
String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
if (packageYAMLO == null) {
String key = PACKAGE;
- if(defaultValues.containsKey(key))
- {
+ if (defaultValues.containsKey(key)) {
packageL = defaultValues.get(key);
}
} else {
packageL = packageYAMLO;
}
//permet d'afficher le package dans le diagramme plantuml
- modelOM.addTagValue(PACKAGE,packageL);
+ modelOM.addTagValue(PACKAGE, packageL);
String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
String key = NAME;
- if(defaultValues.containsKey(key))
- {
+ if (defaultValues.containsKey(key)) {
modelOM.setName(defaultValues.get(key));
}
} else {
@@ -54,8 +52,7 @@
String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
if (versionYAMLO == null) {
String key = VERSION;
- if(defaultValues.containsKey(key))
- {
+ if (defaultValues.containsKey(key)) {
modelOM.setVersion(defaultValues.get(key));
}
} else {
@@ -103,9 +100,8 @@
public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) {
String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
- String key = ELEMENT+SEPARATOR+NAME;
- if(defaultValues.containsKey(key))
- {
+ String key = ELEMENT + SEPARATOR + NAME;
+ if (defaultValues.containsKey(key)) {
elementOM.setName(defaultValues.get(key));
}
} else {
@@ -114,9 +110,8 @@
String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
- String key = ELEMENT+SEPARATOR+STATIC;
- if(defaultValues.containsKey(key))
- {
+ String key = ELEMENT + SEPARATOR + STATIC;
+ if (defaultValues.containsKey(key)) {
elementOM.setStatic(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -125,9 +120,8 @@
String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
if (documentationYAMLO == null) {
- String key = ELEMENT+SEPARATOR+DOCUMENTATION;
- if(defaultValues.containsKey(key))
- {
+ String key = ELEMENT + SEPARATOR + DOCUMENTATION;
+ if (defaultValues.containsKey(key)) {
elementOM.setDocumentation(defaultValues.get(key));
}
} else {
@@ -172,9 +166,8 @@
String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
if (externYAMLO == null) {
- String key = CLASSIFIER+SEPARATOR+EXTERN;
- if(defaultValues.containsKey(key))
- {
+ String key = CLASSIFIER + SEPARATOR + EXTERN;
+ if (defaultValues.containsKey(key)) {
classifierOM.setExtern(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -184,9 +177,8 @@
String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
if (innerYAMLO == null) {
- String key = CLASSIFIER+SEPARATOR+INNER;
- if(defaultValues.containsKey(key))
- {
+ String key = CLASSIFIER + SEPARATOR + INNER;
+ if (defaultValues.containsKey(key)) {
classifierOM.setInner(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -195,9 +187,8 @@
String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
- String key = CLASSIFIER+SEPARATOR+TYPE;
- if(defaultValues.containsKey(key))
- {
+ String key = CLASSIFIER + SEPARATOR + TYPE;
+ if (defaultValues.containsKey(key)) {
classifierOM.setType(defaultValues.get(key));
}
} else {
@@ -229,9 +220,8 @@
String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
- String key = CLASS+SEPARATOR+ABSTRACT;
- if(defaultValues.containsKey(key))
- {
+ String key = CLASS + SEPARATOR + ABSTRACT;
+ if (defaultValues.containsKey(key)) {
classOM.setAbstract(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -261,9 +251,8 @@
String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
- String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+NAME;
- if(defaultValues.containsKey(key))
- {
+ String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + NAME;
+ if (defaultValues.containsKey(key)) {
participantOM.setName(defaultValues.get(key));
}
} else {
@@ -272,9 +261,8 @@
String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
if (attributeYAMLO == null) {
- String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+ATTRIBUTE;
- if(defaultValues.containsKey(key))
- {
+ String key = ASSOCIATION_CLASS + SEPARATOR + PARTICIPANT + SEPARATOR + ATTRIBUTE;
+ if (defaultValues.containsKey(key)) {
participantOM.setAttribute(defaultValues.get(key));
}
} else {
@@ -309,9 +297,8 @@
String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
if (orderingYAMLO == null) {
- String key = PARAMETER+SEPARATOR+ORDERING;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + ORDERING;
+ if (defaultValues.containsKey(key)) {
parameterOM.setOrdering(defaultValues.get(key));
}
} else {
@@ -320,9 +307,8 @@
String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
- String key = PARAMETER+SEPARATOR+TYPE;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + TYPE;
+ if (defaultValues.containsKey(key)) {
parameterOM.setType(defaultValues.get(key));
}
} else {
@@ -331,9 +317,8 @@
String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
if (defaultValueYAMLO == null) {
- String key = PARAMETER+SEPARATOR+DEFAULT_VALUE;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + DEFAULT_VALUE;
+ if (defaultValues.containsKey(key)) {
parameterOM.setDefaultValue(defaultValues.get(key));
}
} else {
@@ -342,9 +327,8 @@
String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
if (minMultiplicityYAMLO == null) {
- String key = PARAMETER+SEPARATOR+MIN_MULTIPLICITY;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + MIN_MULTIPLICITY;
+ if (defaultValues.containsKey(key)) {
parameterOM.setMinMultiplicity(Integer.valueOf(defaultValues.get(key)));
}
} else {
@@ -353,9 +337,8 @@
String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
if (maxMultiplicityYAMLO == null) {
- String key = PARAMETER+SEPARATOR+MAX_MULTIPLICITY;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + MAX_MULTIPLICITY;
+ if (defaultValues.containsKey(key)) {
parameterOM.setMaxMultiplicity(Integer.valueOf(defaultValues.get(key)));
}
} else {
@@ -365,9 +348,8 @@
String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
if (orderedYAMLO == null) {
- String key = PARAMETER+SEPARATOR+ORDERED;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + ORDERED;
+ if (defaultValues.containsKey(key)) {
parameterOM.setOrdered(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -376,9 +358,8 @@
String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
if (uniqueYAMLO == null) {
- String key = PARAMETER+SEPARATOR+UNIQUE;
- if(defaultValues.containsKey(key))
- {
+ String key = PARAMETER + SEPARATOR + UNIQUE;
+ if (defaultValues.containsKey(key)) {
parameterOM.setUnique(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -391,9 +372,8 @@
String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
if (navigableYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+NAVIGABLE;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + NAVIGABLE;
+ if (defaultValues.containsKey(key)) {
attributeOM.setNavigable(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -402,9 +382,8 @@
String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
if (associationTypeYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_TYPE;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_TYPE;
+ if (defaultValues.containsKey(key)) {
attributeOM.setAssociationType(defaultValues.get(key));
}
} else {
@@ -413,9 +392,8 @@
String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
if (finalYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+FINAL;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + FINAL;
+ if (defaultValues.containsKey(key)) {
attributeOM.setFinal(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -424,9 +402,8 @@
String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+STATIC;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + STATIC;
+ if (defaultValues.containsKey(key)) {
attributeOM.setStatic(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -435,9 +412,8 @@
String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
if (associationClassNameYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_CLASS_NAME;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + ASSOCIATION_CLASS_NAME;
+ if (defaultValues.containsKey(key)) {
attributeOM.setAssociationClassName(defaultValues.get(key));
}
} else {
@@ -446,9 +422,8 @@
String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
if (reverseAttributeNameYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+REVERSE_ATTRIBUTE_NAME;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + REVERSE_ATTRIBUTE_NAME;
+ if (defaultValues.containsKey(key)) {
attributeOM.setReverseAttributeName(defaultValues.get(key));
}
} else {
@@ -457,9 +432,8 @@
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
if (reverseMaxMultiplicityYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + REVERSE_MAX_MULTIPLICITY;
+ if (defaultValues.containsKey(key)) {
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(defaultValues.get(key)));
}
} else {
@@ -468,9 +442,8 @@
String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
if (transientYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+TRANSIENT;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + TRANSIENT;
+ if (defaultValues.containsKey(key)) {
attributeOM.setTransient(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -479,9 +452,8 @@
String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
- String key = ATTRIBUTE+SEPARATOR+VISIBILITY;
- if(defaultValues.containsKey(key))
- {
+ String key = ATTRIBUTE + SEPARATOR + VISIBILITY;
+ if (defaultValues.containsKey(key)) {
attributeOM.setVisibility(defaultValues.get(key));
}
} else {
@@ -494,9 +466,8 @@
String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
- String key = OPERATION+SEPARATOR+ABSTRACT;
- if(defaultValues.containsKey(key))
- {
+ String key = OPERATION + SEPARATOR + ABSTRACT;
+ if (defaultValues.containsKey(key)) {
operationOM.setAbstract(Boolean.valueOf(defaultValues.get(key)));
}
} else {
@@ -505,9 +476,8 @@
String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
- String key = OPERATION+SEPARATOR+VISIBILITY;
- if(defaultValues.containsKey(key))
- {
+ String key = OPERATION + SEPARATOR + VISIBILITY;
+ if (defaultValues.containsKey(key)) {
operationOM.setVisibility(defaultValues.get(key));
}
} else {
@@ -528,9 +498,8 @@
String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
if (bodyCodeYAMLO == null) {
- String key = OPERATION+SEPARATOR+BODY_CODE;
- if(defaultValues.containsKey(key))
- {
+ String key = OPERATION + SEPARATOR + BODY_CODE;
+ if (defaultValues.containsKey(key)) {
operationOM.setBodyCode(defaultValues.get(key));
}
} else {
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -403,7 +403,21 @@
enumerationYAMLO.addStringToMap(NAME, name);
importsI.put(name, packageM + "." + name);
}
- //TODO: parser literals
+
+ if (value instanceof Map) {
+ //TODO: utiliser variable locales pour plus de clartee
+ if (((Map) value).containsKey(LITERAL)) {
+ if (((Map) value).get(LITERAL) instanceof Map) {
+ for (Object entry : ((Map) ((Map) value).get(LITERAL)).entrySet()) {
+ if (entry instanceof Map.Entry) {
+ enumerationYAMLO.addStringToMap(LITERAL, String.valueOf(((Map.Entry) entry).getKey()));
+ }
+ }
+ }
+ ((Map) value).remove(LITERAL);
+ }
+ }
+
}
//TODO: factoriser code
@@ -414,6 +428,13 @@
public void parseAttribute(String key, Object value, YamlObject attributeYAMLO) {
List<String> attributePARSE = YamlUtil.charParseIgnore(key, ' ', '<', '>');
+ if (attributePARSE.contains(COMPOSITE)) {
+ attributeYAMLO.addStringToMap(ASSOCIATION_TYPE, COMPOSITE);
+ attributePARSE.remove(attributePARSE.indexOf(COMPOSITE));
+ } else if (attributePARSE.contains(AGGREGATE)) {
+ attributeYAMLO.addStringToMap(ASSOCIATION_TYPE, AGGREGATE);
+ attributePARSE.remove(attributePARSE.indexOf(AGGREGATE));
+ }
if (attributePARSE.contains(STATIC)) {
attributeYAMLO.addStringToMap(STATIC, String.valueOf(true));
attributePARSE.remove(attributePARSE.indexOf(STATIC));
@@ -486,12 +507,12 @@
if (attributePARSE.size() > 1) {
attributeYAMLO.addStringToMap(NAME, attributePARSE.get(1));
}
- if(value != null)
- {
+ if (value != null) {
//idée1: defaultValue
//attributeYAMLO.addStringToMap(DEFAULT_VALUE,String.valueOf(value));
//idée2: reverseMultiplicity & reverseOrdering (pour lien unidirectionnel)
- List<String> valuePARSE = YamlUtil.charParse(String.valueOf(value),' ');
+ //idée3: defaultValue après '='
+ List<String> valuePARSE = YamlUtil.charParse(String.valueOf(value), ' ');
if (valuePARSE.contains(ORDERED)) {
attributeYAMLO.addStringToMap(REVERSE_ORDERING, ORDERED);
attributePARSE.remove(valuePARSE.indexOf(ORDERED));
@@ -577,7 +598,7 @@
returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value));
operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);*/
//idée2: bodyCode
- operationYAMLO.addStringToMap(BODY_CODE,String.valueOf(value));
+ operationYAMLO.addStringToMap(BODY_CODE, String.valueOf(value));
}
}
@@ -650,7 +671,8 @@
if (imports.containsKey(ninja)) {
res.append(imports.get(ninja));
} else {
- res.append(tmp);
+ //res.append(tmp);
+ res.append(ninja);
}
res.append("<");
res.append(browseType(YamlUtil.extract('<', '>', tmp)));
@@ -720,8 +742,7 @@
if (attribute.containsKeyMapStringListString(REVERSE_MAX_MULTIPLICITY)) {
reverseAttribute.addStringToMap(MAX_MULTIPLICITY, attribute.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY));
}
- if(attribute.containsKeyMapStringListString(REVERSE_ORDERING))
- {
+ if (attribute.containsKeyMapStringListString(REVERSE_ORDERING)) {
reverseAttribute.addStringToMap(ORDERING, attribute.getFirstMapStringListString(REVERSE_ORDERING));
}
//else set opposit ordering
Modified: trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java
===================================================================
--- trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -34,6 +34,8 @@
}
if (input.getTagValue(PACKAGE) != null) {
packageM = input.getTagValue(PACKAGE) + " ";
+ } else {
+ packageM = findPackage(input) + " ";
}
output.write("note \"" + nameM + " " + versionM + "\" as N1\n\n");
output.write("package " + packageM + "{\n\n");
@@ -166,29 +168,50 @@
return stereotype.toString();
}
- //TODO: parser type
public void generateFromAttributes(Writer output, Collection<ObjectModelAttribute> input, String indent) throws IOException {
for (ObjectModelAttribute attribute : input) {
if (!attribute.referenceClassifier()) {
+ String visibility = "";
+ if (attribute.getVisibility() != null) {
+ if (attribute.getVisibility().equals(PUBLIC)) {
+ visibility = "+ ";
+ } else if (attribute.getVisibility().equals(PROTECTED)) {
+ visibility = "# ";
+ } else if (attribute.getVisibility().equals(PRIVATE)) {
+ visibility = "- ";
+ }
+ }
String type = "", name = "";
if (attribute.getType() != null) {
- type = attribute.getType() + " ";
+ type = reduceType(attribute.getType()) + " ";
}
if (attribute.getName() != null) {
name = attribute.getName();
}
- output.write(indent + type + name + "\n");
+ output.write(indent + visibility + type + name + "\n");
}
}
}
- //TODO: parser parameters
public void generateFromOperations(Writer output, Collection<ObjectModelOperation> input, String indent) throws IOException {
for (ObjectModelOperation operation : input) {
- String isAbstract = "", parameters = "", name = "", returnParameter = "";
+ String isAbstract = "", isStatic = "", parameters = "", name = "", returnParameter = "";
if (operation.isAbstract()) {
isAbstract = "{abstract} ";
}
+ if (operation.isStatic()) {
+ isAbstract = "{static} ";
+ }
+ String visibility = "";
+ if (operation.getVisibility() != null) {
+ if (operation.getVisibility().equals(PUBLIC)) {
+ visibility = "+ ";
+ } else if (operation.getVisibility().equals(PROTECTED)) {
+ visibility = "# ";
+ } else if (operation.getVisibility().equals(PRIVATE)) {
+ visibility = "- ";
+ }
+ }
if (operation.getParameters() != null) {
StringBuilder tmp = new StringBuilder("");
boolean first = true;
@@ -199,7 +222,7 @@
tmp.append(", ");
}
if (parameter.getType() != null) {
- tmp.append(parameter.getType()).append(" ");
+ tmp.append(reduceType(parameter.getType())).append(" ");
}
if (parameter.getName() != null) {
tmp.append(parameter.getName());
@@ -209,13 +232,13 @@
}
if (operation.getReturnParameter() != null) {
if (operation.getReturnParameter().getType() != null) {
- returnParameter = operation.getReturnParameter().getType() + " ";
+ returnParameter = reduceType(operation.getReturnParameter().getType()) + " ";
}
}
if (operation.getName() != null) {
name = operation.getName();
}
- output.write(indent + isAbstract + returnParameter + name + "(" + parameters + ")\n");
+ output.write(indent + isAbstract + isStatic + visibility + returnParameter + name + "(" + parameters + ")\n");
}
}
@@ -239,13 +262,11 @@
}
}
- //TODO: factoriser
public void generateFromLinks(Writer output, ObjectModel input, String indent) throws IOException {
Map<ObjectModelAttribute, ObjectModelClassifier> attributesM = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>();
List<ObjectModelAttribute> bin = new LinkedList<ObjectModelAttribute>();//bin au sens poubelle
- for (ObjectModelClassifier classifier : input.getClassifiers())//TODO+enum?
- {
+ for (ObjectModelClassifier classifier : input.getClassifiers()) {
if (classifier.getAttributes() != null) {
for (ObjectModelAttribute attribute : classifier.getAttributes()) {
if (attribute.referenceClassifier()) {
@@ -263,6 +284,12 @@
if (attribute.getName() != null) {
attributeName = attribute.getName();
}
+ String associationType = "";
+ if (attribute.isComposite()) {
+ associationType = "*";
+ } else if (attribute.isAggregate()) {
+ associationType = "o";
+ }
String minMultiplicity = (attribute.getMinMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMinMultiplicity());
String maxMultiplicity = (attribute.getMaxMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMaxMultiplicity());
String multiplicity = (minMultiplicity.equals(maxMultiplicity)) ? minMultiplicity : minMultiplicity + ".." + maxMultiplicity;
@@ -280,6 +307,7 @@
String reverseType = YamlUtil.afterChar(reverseAttribute.getType(), '.');
if (reverseAttribute.isNavigable())//lien bi-directionnel
{
+ //tenir compte du type d'association ?
output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" -- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
if (attribute.getAssociationClass() != null && reverseAttribute.getAssociationClass() != null && attribute.getAssociationClass().equals(reverseAttribute.getAssociationClass())) {
String associationClassName = "";
@@ -291,21 +319,75 @@
bin.add(reverseAttribute);
} else//lien uni-directionnel
{
- if (multiplicity.equals("0..*") && reverseMultiplicity.equals("1")) {
+ /*if (multiplicity.equals("0..*") && reverseMultiplicity.equals("1")) {
output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <--* \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
} else {
output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <-- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
- }
+ }*/
+ output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <--" + associationType + " \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
+
}
} else {
String reverseType = "";
if (attributesM.get(attribute).getName() != null) {
reverseType = attributesM.get(attribute).getName();
}
- output.write(type + " \"" + multiplicity + " " + attributeName + "\" <-- " + reverseType + "\n");
+ output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <-- " + reverseType + "\n");
}
}
}
}
}
+
+ public static String browseType(String type) {
+ StringBuilder res = new StringBuilder();
+ boolean first = true;
+ for (String tmp : YamlUtil.charParseIgnore(type, ',', '<', '>')) {
+ if (first) {
+ first = false;
+ } else {
+ res.append(",");
+ }
+ if (tmp.contains("<") && tmp.contains(">")) {
+ String ninja = YamlUtil.beforeChar(tmp, '<');
+ res.append(YamlUtil.afterChar(ninja, '.'));
+ res.append("<");
+ res.append(browseType(YamlUtil.extract('<', '>', tmp)));
+ res.append(">");
+ } else {
+ res.append(YamlUtil.afterChar(tmp, '.'));
+ }
+ }
+ return res.toString();
+ }
+
+ public static String reduceType(String type) {
+ List<Character> ignore = new LinkedList<Character>();
+ ignore.add(' ');
+ String typePARSE = YamlUtil.removeMultiChar(type, ignore);
+ return browseType(typePARSE);
+ }
+
+ public String findPackage(ObjectModel input) {
+ Map<String, Integer> packages = new LinkedHashMap<String, Integer>();
+ for (ObjectModelClassifier classifier : input.getClassifiers()) {
+ String packageTMP = classifier.getPackageName();
+ if (packageTMP != null) {
+ if (packages.containsKey(packageTMP)) {
+ packages.put(packageTMP, packages.get(packageTMP) + 1);
+ } else {
+ packages.put(packageTMP, 1);
+ }
+ }
+ }
+ String packageL = "";
+ int count = 0;
+ for (Map.Entry<String, Integer> entry : packages.entrySet()) {
+ if (entry.getValue() > count) {
+ count = entry.getValue();
+ packageL = entry.getKey();
+ }
+ }
+ return packageL;
+ }
}
Added: trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst
===================================================================
--- trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst (rev 0)
+++ trunk/eugene-plantuml-templates/src/site/fr/rst/index.rst 2013-06-14 14:23:53 UTC (rev 1278)
@@ -0,0 +1,84 @@
+.. -
+.. * #%L
+.. * EUGene :: PlantUML templates
+.. *
+.. * $Id: index.rst 1174 2012-08-17 08:44:36Z tchemit $
+.. * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/f… $
+.. * %%
+.. * Copyright (C) 2012 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+
+=========================
+EUGene PlantUML templates
+=========================
+
+.. contents::
+
+Présentation
+------------
+Le plugin *eugene-plantuml-templates* est un template permettant de générer un diagramme de classes `PlantUML` à partir d'un `ObjectModel` au moment de l'installation d'un projet.
+`PlantUML` utilise Graphviz lors de la génération d'images, si vous ne pouvez pas installer `Graphviz`, le `PlantUML Server` permet de générer des diagrammes en ligne.
+
+Démonstration
+-----------------------------
+Voici un exemple d'utilisation du plugin *eugene-plantuml-templates* avec le projet `Pollen`.
+
+
+Ajouter le template dans le pom.xml
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Après avoir récupéré les sources du projet `Pollen`, on ajoute le template PlantUML au fichier pollen-persistence/pom.xml (sans oublier la virgule pour séparer les templates)::
+
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer,
+ org.nuiton.topia.generator.BinderHelperTransformer,
+ org.nuiton.eugene.plantuml.PlantumlTemplatesGenerator
+ </templates>
+
+Installation du projet
+~~~~~~~~~~~~~~~~~~~~~~
+On lance ensuite l'installation avec la commande::
+ pollen$ mvn install
+La ligne suivante devrait apparaitre lors de l'installation::
+ [INFO] Apply generator PlantumlTemplatesGenerator"
+
+Résultat
+~~~~~~~~
+Le diagramme de classe se trouve dans le répertoire pollen-persistence/target/classes (ou pollen-persistence/target/generated-sources/java):
+Pollen.plantuml est la représentation textuelle du modèle en `PlantUML`
+Pollen.png est l'image générée par `PlantUML` à partir du fichier Pollen.plantuml
+Pour générer le diagramme à partir du `PlantUML Server`, il suffit de copier le contenu du fichier Pollen.plantuml dans le formulaire du site et d'envoyer.
+
+Voici à quoi devrait ressembler le diagramme:
+.. image:: ../images/Pollen.png
+
+Légende
+~~~~~~~
+Visibilité:
+.. image:: ../images/legend1.png
+
+Abstract & Static:
+.. image:: ../images/legend2.png
+
+Relations:
+.. image:: ../images/legend3.png
+
+.. _PlantUML : http://plantuml.sourceforge.net/index.html
+.. _ObjectModel : http://maven-site.nuiton.org/eugene/02-objectmodel.html
+.. _Graphviz : http://www.graphviz.org/
+.. _PlantUML Server : http://plantuml.com/plantuml/
+.. _Pollen : http://maven-site.chorem.org/pollen/
Added: trunk/eugene-plantuml-templates/src/site/resources/Pollen.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/Pollen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/legend1.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/legend2.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/resources/legend3.png
===================================================================
(Binary files differ)
Property changes on: trunk/eugene-plantuml-templates/src/site/resources/legend3.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/eugene-plantuml-templates/src/site/rst/index.rst
===================================================================
--- trunk/eugene-plantuml-templates/src/site/rst/index.rst (rev 0)
+++ trunk/eugene-plantuml-templates/src/site/rst/index.rst 2013-06-14 14:23:53 UTC (rev 1278)
@@ -0,0 +1,36 @@
+.. -
+.. * #%L
+.. * EUGene :: PlantUML templates
+.. *
+.. * $Id: index.rst 1220 2012-12-10 07:55:48Z tchemit $
+.. * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/r… $
+.. * %%
+.. * Copyright (C) 2012 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+
+=========================
+EUGene PlantUML templates
+=========================
+
+.. contents::
+
+Introduction
+------------
+
+Example
+-------
Added: trunk/eugene-plantuml-templates/src/site/site_en.xml
===================================================================
--- trunk/eugene-plantuml-templates/src/site/site_en.xml (rev 0)
+++ trunk/eugene-plantuml-templates/src/site/site_en.xml 2013-06-14 14:23:53 UTC (rev 1278)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: Java templates
+ $Id: site_en.xml 1223 2012-12-10 08:17:42Z tchemit $
+ $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/s… $
+ %%
+ Copyright (C) 2012 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+
+ <head>
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+ </head>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="./index.html"/>
+ </breadcrumbs>
+
+ <links>
+ <item name="[fr" href="fr/index.html"/>
+ <item name="en]" href="index.html"/>
+ </links>
+
+ <menu ref="parent"/>
+
+ <menu name="User">
+ <item href="index.html" name="Home"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ <footer>
+
+ <div id='projectMetas' locale='en'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.developerConnection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
+ </body>
+</project>
Added: trunk/eugene-plantuml-templates/src/site/site_fr.xml
===================================================================
--- trunk/eugene-plantuml-templates/src/site/site_fr.xml (rev 0)
+++ trunk/eugene-plantuml-templates/src/site/site_fr.xml 2013-06-14 14:23:53 UTC (rev 1278)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: Java templates
+ $Id: site_fr.xml 1223 2012-12-10 08:17:42Z tchemit $
+ $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-plantuml-templates/src/site/s… $
+ %%
+ Copyright (C) 2012 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+
+ <head>
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+ </head>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="./index.html"/>
+ </breadcrumbs>
+
+ <links>
+ <item name="[fr" href="index.html"/>
+ <item name="en]" href="../index.html"/>
+ </links>
+
+ <!-- TC-20100117 : ne fonctionne pas sur une langue non principale -->
+ <!--<menu ref="parent"/>-->
+ <menu name="Parent Projet">
+ <item name="Eugene" href="../../fr/index.html"/>
+ </menu>
+
+ <menu name="Utilisateur">
+ <item href="index.html" name="Accueil"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ <footer>
+
+ <div id='projectMetas' locale='fr'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.developerConnection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
+ </body>
+</project>
Modified: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java
===================================================================
--- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -20,178 +20,143 @@
@Override
public void generateFromModel(Writer output, ObjectModel input) throws IOException {
output.write("%YAML 1.1\n---\n- syntaxe: 1.0\n\n");
- if(input.getName() != null)
- {
- output.write("- "+NAME+": "+input.getName()+"\n");
+ if (input.getName() != null) {
+ output.write("- " + NAME + ": " + input.getName() + "\n");
}
- if(input.getVersion() != null)
- {
- output.write("- "+VERSION+": "+input.getVersion()+"\n");
+ if (input.getVersion() != null) {
+ output.write("- " + VERSION + ": " + input.getVersion() + "\n");
}
- if(input.getTagValues() != null && !input.getTagValues().isEmpty())
- {
- output.write("- "+TAG_VALUES+":\n");
- for(Map.Entry<String,String> entry : input.getTagValues().entrySet())
- {
- output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n");
+ if (input.getTagValues() != null && !input.getTagValues().isEmpty()) {
+ output.write("- " + TAG_VALUES + ":\n");
+ for (Map.Entry<String, String> entry : input.getTagValues().entrySet()) {
+ output.write(" - " + entry.getKey() + ": " + entry.getValue() + "\n");
}
}
output.write("\n");
//classifier
- if(input.getClasses() != null && !input.getClasses().isEmpty())
- {
- for(ObjectModelClass objectModelClass : input.getClasses())
- {
+ if (input.getClasses() != null && !input.getClasses().isEmpty()) {
+ for (ObjectModelClass objectModelClass : input.getClasses()) {
//associationClass
- if(objectModelClass instanceof ObjectModelAssociationClass)
- {
+ if (objectModelClass instanceof ObjectModelAssociationClass) {
generateFromAssociationClass(output, (ObjectModelAssociationClass) objectModelClass);
}
//class
- else
- {
+ else {
generateFromClass(output, objectModelClass);
}
}
}
//interface
- if(input.getInterfaces() != null && !input.getInterfaces().isEmpty())
- {
- for(ObjectModelInterface objectModelInterface : input.getInterfaces())
- {
+ if (input.getInterfaces() != null && !input.getInterfaces().isEmpty()) {
+ for (ObjectModelInterface objectModelInterface : input.getInterfaces()) {
generateFromInterface(output, objectModelInterface);
}
}
//enumeration
- if(input.getEnumerations() != null && !input.getEnumerations().isEmpty())
- {
- for(ObjectModelEnumeration objectModelEnumeration : input.getEnumerations())
- {
- generateFromEnumeration(output,objectModelEnumeration);
+ if (input.getEnumerations() != null && !input.getEnumerations().isEmpty()) {
+ for (ObjectModelEnumeration objectModelEnumeration : input.getEnumerations()) {
+ generateFromEnumeration(output, objectModelEnumeration);
}
}
}
@Override
public String getFilenameForModel(ObjectModel model) {
- return model.getName()+".yamlobjectmodel";
+ return model.getName() + ".yamlobjectmodel";
}
public void generateFromElement(Writer output, ObjectModelElement input, String indent) throws IOException {
- if(input.getName() != null)
- {
- output.write(indent+"- "+NAME+": "+input.getName()+"\n");
+ if (input.getName() != null) {
+ output.write(indent + "- " + NAME + ": " + input.getName() + "\n");
}
- if(input.getStereotypes() != null && !input.getStereotypes().isEmpty())
- {
- for(String stereotype : input.getStereotypes())
- {
- output.write(indent+"- "+STEREOTYPES+": "+stereotype+"\n");
+ if (input.getStereotypes() != null && !input.getStereotypes().isEmpty()) {
+ for (String stereotype : input.getStereotypes()) {
+ output.write(indent + "- " + STEREOTYPES + ": " + stereotype + "\n");
}
}
- if(input.getComments() != null && !input.getComments().isEmpty())
- {
- for(String comment : input.getComments())
- {
- output.write(indent+"- "+COMMENTS+": "+comment+"\n");
+ if (input.getComments() != null && !input.getComments().isEmpty()) {
+ for (String comment : input.getComments()) {
+ output.write(indent + "- " + COMMENTS + ": " + comment + "\n");
}
}
/*if(input.getDescription() != null)
{
output.write(indent+"- "+DESCRIPTION+": "+input.getDescription()+"\n");
}*/
- if(input.getDocumentation() != null)
- {
- output.write(indent+"- "+DOCUMENTATION+": "+input.getDocumentation()+"\n");
+ if (input.getDocumentation() != null) {
+ output.write(indent + "- " + DOCUMENTATION + ": " + input.getDocumentation() + "\n");
}
- if(input.getTagValues() != null && !input.getTagValues().isEmpty())
- {
- output.write("- "+TAG_VALUES+":\n");
- for(Map.Entry<String,String> entry : input.getTagValues().entrySet())
- {
- output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n");
+ if (input.getTagValues() != null && !input.getTagValues().isEmpty()) {
+ output.write("- " + TAG_VALUES + ":\n");
+ for (Map.Entry<String, String> entry : input.getTagValues().entrySet()) {
+ output.write(" - " + entry.getKey() + ": " + entry.getValue() + "\n");
}
}
- output.write(indent+"- "+STATIC+": "+String.valueOf(input.isStatic())+"\n");
+ output.write(indent + "- " + STATIC + ": " + String.valueOf(input.isStatic()) + "\n");
}
public void generateFromClassifier(Writer output, ObjectModelClassifier input) throws IOException {
- if(input.getInterfaces() != null && !input.getInterfaces().isEmpty())
- {
- for(ObjectModelInterface objectModelInterface : input.getInterfaces())
- {
+ if (input.getInterfaces() != null && !input.getInterfaces().isEmpty()) {
+ for (ObjectModelInterface objectModelInterface : input.getInterfaces()) {
//tester null
- output.write(" - "+SUPER_INTERFACES+": "+objectModelInterface.getPackageName()+"."+objectModelInterface.getName());
+ output.write(" - " + SUPER_INTERFACES + ": " + objectModelInterface.getPackageName() + "." + objectModelInterface.getName());
}
}
- generateFromElement(output,input," ");
- output.write(" - "+INNER+": "+String.valueOf(input.isInner())+"\n");
- if(input.getPackageName() != null)
- {
- output.write(" - "+PACKAGE+": "+input.getPackageName()+"\n");
+ generateFromElement(output, input, " ");
+ output.write(" - " + INNER + ": " + String.valueOf(input.isInner()) + "\n");
+ if (input.getPackageName() != null) {
+ output.write(" - " + PACKAGE + ": " + input.getPackageName() + "\n");
}
- if(input.getAttributes() != null && !input.getAttributes().isEmpty())
- {
- for(ObjectModelAttribute attribute : input.getAttributes())
- {
- generateFromAttribute(output,attribute);
+ if (input.getAttributes() != null && !input.getAttributes().isEmpty()) {
+ for (ObjectModelAttribute attribute : input.getAttributes()) {
+ generateFromAttribute(output, attribute);
}
}
- if(input.getOperations() != null && !input.getOperations().isEmpty())
- {
- for(ObjectModelOperation operation : input.getOperations())
- {
- generateFromOperation(output,operation);
+ if (input.getOperations() != null && !input.getOperations().isEmpty()) {
+ for (ObjectModelOperation operation : input.getOperations()) {
+ generateFromOperation(output, operation);
}
}
}
public void generateFromClass(Writer output, ObjectModelClass input) throws IOException {
output.write("- " + CLASS + ":\n");
- output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n");
- if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty())
- {
- for(ObjectModelClass objectModelClass : input.getSuperclasses())
- {
+ output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n");
+ if (input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) {
+ for (ObjectModelClass objectModelClass : input.getSuperclasses()) {
//tester null
- output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName());
+ output.write(" - " + SUPER_CLASSES + ": " + objectModelClass.getPackageName() + "." + objectModelClass.getName());
}
}
- generateFromClassifier(output,input);
+ generateFromClassifier(output, input);
output.write("\n");
}
public void generateFromInterface(Writer output, ObjectModelInterface input) throws IOException {
- output.write("- "+INTERFACE+":\n");
- generateFromClassifier(output,input);
+ output.write("- " + INTERFACE + ":\n");
+ generateFromClassifier(output, input);
output.write("\n");
}
public void generateFromAssociationClass(Writer output, ObjectModelAssociationClass input) throws IOException {
output.write("- " + ASSOCIATION_CLASS + ":\n");
- if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty())
- {
- for(ObjectModelClass objectModelClass : input.getSuperclasses())
- {
+ if (input.getSuperclasses() != null && !input.getSuperclasses().isEmpty()) {
+ for (ObjectModelClass objectModelClass : input.getSuperclasses()) {
//tester null
- output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName());
+ output.write(" - " + SUPER_CLASSES + ": " + objectModelClass.getPackageName() + "." + objectModelClass.getName());
}
}
- generateFromClassifier(output,input);
+ generateFromClassifier(output, input);
output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n");
- if(input.getParticipantsAttributes() != null && !input.getParticipantsAttributes().isEmpty())
- {
- for(ObjectModelAttribute attribute : input.getParticipantsAttributes())
- {
- output.write(" - "+PARTICIPANT+":\n");
+ if (input.getParticipantsAttributes() != null && !input.getParticipantsAttributes().isEmpty()) {
+ for (ObjectModelAttribute attribute : input.getParticipantsAttributes()) {
+ output.write(" - " + PARTICIPANT + ":\n");
//tester null
- if(attribute.getType() != null)
- {
- output.write(" - "+NAME+": "+attribute.getType()+"\n");
+ if (attribute.getType() != null) {
+ output.write(" - " + NAME + ": " + attribute.getType() + "\n");
}
- if(attribute.getName() != null)
- {
- output.write(" - "+TYPE+": "+attribute.getName()+"\n");
+ if (attribute.getName() != null) {
+ output.write(" - " + TYPE + ": " + attribute.getName() + "\n");
}
}
}
@@ -199,80 +164,65 @@
}
public void generateFromEnumeration(Writer output, ObjectModelEnumeration input) throws IOException {
- output.write("- "+ENUMERATION+":\n");
- generateFromElement(output,input," ");
+ output.write("- " + ENUMERATION + ":\n");
+ generateFromElement(output, input, " ");
}
public void generateFromParameter(Writer output, ObjectModelParameter input, String indent) throws IOException {
- generateFromElement(output,input,indent);
- if(input.isOrdered())
- {
- output.write(indent+"- "+ORDERING+": "+ORDERED+"\n");
+ generateFromElement(output, input, indent);
+ if (input.isOrdered()) {
+ output.write(indent + "- " + ORDERING + ": " + ORDERED + "\n");
+ } else {
+ output.write(indent + "- " + ORDERING + ": " + UNORDERED + "\n");
}
- else
- {
- output.write(indent+"- "+ORDERING+": "+UNORDERED+"\n");
+ if (input.getType() != null) {
+ output.write(indent + "- " + TYPE + ": " + input.getType() + "\n");
}
- if(input.getType() != null)
- {
- output.write(indent+"- "+TYPE+": "+input.getType()+"\n");
+ if (input.getDefaultValue() != null) {
+ output.write(indent + "- " + DEFAULT_VALUE + ": " + input.getDefaultValue() + "\n");
}
- if(input.getDefaultValue() != null)
- {
- output.write(indent+"- "+DEFAULT_VALUE+": "+input.getDefaultValue()+"\n");
- }
- output.write(indent+"- "+MIN_MULTIPLICITY+": "+String.valueOf(input.getMinMultiplicity())+"\n");
- output.write(indent+"- "+MAX_MULTIPLICITY+": "+String.valueOf(input.getMaxMultiplicity())+"\n");
- output.write(indent+"- "+UNIQUE+": "+String.valueOf(input.isUnique())+"\n");
+ output.write(indent + "- " + MIN_MULTIPLICITY + ": " + String.valueOf(input.getMinMultiplicity()) + "\n");
+ output.write(indent + "- " + MAX_MULTIPLICITY + ": " + String.valueOf(input.getMaxMultiplicity()) + "\n");
+ output.write(indent + "- " + UNIQUE + ": " + String.valueOf(input.isUnique()) + "\n");
}
public void generateFromAttribute(Writer output, ObjectModelAttribute input) throws IOException {
- output.write(" - "+ATTRIBUTE+":\n");
+ output.write(" - " + ATTRIBUTE + ":\n");
generateFromParameter(output, input, " ");
- output.write(" - "+NAVIGABLE+": "+String.valueOf(input.isNavigable())+"\n");
- output.write(" - "+TRANSIENT+": "+String.valueOf(input.isTransient())+"\n");
- output.write(" - "+FINAL+": "+String.valueOf(input.isFinal())+"\n");
- output.write(" - "+REVERSE_MAX_MULTIPLICITY+": "+String.valueOf(input.getReverseMaxMultiplicity())+"\n");
- if(input.getVisibility() != null)
- {
- output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n");
+ output.write(" - " + NAVIGABLE + ": " + String.valueOf(input.isNavigable()) + "\n");
+ output.write(" - " + TRANSIENT + ": " + String.valueOf(input.isTransient()) + "\n");
+ output.write(" - " + FINAL + ": " + String.valueOf(input.isFinal()) + "\n");
+ output.write(" - " + REVERSE_MAX_MULTIPLICITY + ": " + String.valueOf(input.getReverseMaxMultiplicity()) + "\n");
+ if (input.getVisibility() != null) {
+ output.write(" - " + VISIBILITY + ": " + input.getVisibility() + "\n");
}
- if(input.isComposite())
- {
- output.write(" - "+ASSOCIATION_TYPE+": "+COMPOSITE+"\n");
+ if (input.isComposite()) {
+ output.write(" - " + ASSOCIATION_TYPE + ": " + COMPOSITE + "\n");
+ } else if (input.isAggregate()) {
+ output.write(" - " + ASSOCIATION_TYPE + ": " + AGGREGATE + "\n");
}
- else if(input.isAggregate())
- {
- output.write(" - "+ASSOCIATION_TYPE+": "+AGGREGATE+"\n");
+ if (input.getAssociationClass() != null) {
+ output.write(" - " + ASSOCIATION_CLASS_NAME + ": " + input.getAssociationClass().getPackageName() + "." + input.getAssociationClass().getName() + "\n");
}
- if(input.getAssociationClass() != null)
- {
- output.write(" - "+ASSOCIATION_CLASS_NAME+": "+input.getAssociationClass().getPackageName()+"."+input.getAssociationClass().getName()+"\n");
- }
}
public void generateFromOperation(Writer output, ObjectModelOperation input) throws IOException {
output.write(" - " + ATTRIBUTE + ":\n");
generateFromElement(output, input, " ");
- output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n");
- if(input.getVisibility() != null)
- {
- output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n");
+ output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n");
+ if (input.getVisibility() != null) {
+ output.write(" - " + VISIBILITY + ": " + input.getVisibility() + "\n");
}
- if(input.getBodyCode() != null)
- {
- output.write(" - "+BODY_CODE+": "+input.getBodyCode()+"\n");
+ if (input.getBodyCode() != null) {
+ output.write(" - " + BODY_CODE + ": " + input.getBodyCode() + "\n");
}
- if(input.getReturnParameter() != null)
- {
- output.write(" - "+RETURN_PARAMETER+":\n");
+ if (input.getReturnParameter() != null) {
+ output.write(" - " + RETURN_PARAMETER + ":\n");
generateFromParameter(output, input.getReturnParameter(), " ");
}
- if(input.getParameters() != null && !input.getParameters().isEmpty())
- {
- for(ObjectModelParameter objectModelParameter : input.getParameters())
- {
- output.write(" - "+PARAMETER+":\n");
+ if (input.getParameters() != null && !input.getParameters().isEmpty()) {
+ for (ObjectModelParameter objectModelParameter : input.getParameters()) {
+ output.write(" - " + PARAMETER + ":\n");
generateFromParameter(output, objectModelParameter, " ");
}
}
Modified: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
===================================================================
--- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277)
+++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-14 14:23:53 UTC (rev 1278)
@@ -21,6 +21,6 @@
@Override
public String getFilenameForModel(ObjectModel model) {
- return model.getName()+".yamlobjectmodel";
+ return model.getName() + ".yamlobjectmodel";
}
}
1
0
r1277 - in trunk: eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml eugene-plantuml-templates eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml
by agiraudet@users.nuiton.org 13 Jun '13
by agiraudet@users.nuiton.org 13 Jun '13
13 Jun '13
Author: agiraudet
Date: 2013-06-13 18:07:14 +0200 (Thu, 13 Jun 2013)
New Revision: 1277
Url: http://nuiton.org/projects/eugene/repository/revisions/1277
Log:
Refonte compl?\195?\168te du template PlantUML et mise ?\195?\160 jour de la version de la d?\195?\169pendance vers PlantUML
Modified:
trunk/eugene-plantuml-templates/pom.xml
trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.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-12 15:46:10 UTC (rev 1276)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-13 16:07:14 UTC (rev 1277)
@@ -37,6 +37,8 @@
} else {
packageL = packageYAMLO;
}
+ //permet d'afficher le package dans le diagramme plantuml
+ modelOM.addTagValue(PACKAGE,packageL);
String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
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-12 15:46:10 UTC (rev 1276)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlUtil.java 2013-06-13 16:07:14 UTC (rev 1277)
@@ -14,7 +14,7 @@
//TODO: faire classes dédiée au parser ?
public class YamlUtil {
- //TODO: caster proprement
+ @Deprecated
public static void keySetToLowerCase(Map<Object, Object> map) {
List<Object> keys = new ArrayList<Object>(map.keySet());
for (Object obj : keys) {
@@ -25,6 +25,7 @@
}
}
+ @Deprecated
public static void browseKeySetToLowerCase(Object obj, List<String> ignore) {
if (obj instanceof Map) {
keySetToLowerCase((Map<Object, Object>) obj);
@@ -95,7 +96,6 @@
}
}
- // 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
@@ -118,7 +118,6 @@
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
@@ -248,25 +247,7 @@
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('<', '>', "<<<>>>"));
- }
+ /*public static void main(String[] args) {
+ ;
+ }*/
}
Modified: trunk/eugene-plantuml-templates/pom.xml
===================================================================
--- trunk/eugene-plantuml-templates/pom.xml 2013-06-12 15:46:10 UTC (rev 1276)
+++ trunk/eugene-plantuml-templates/pom.xml 2013-06-13 16:07:14 UTC (rev 1277)
@@ -46,7 +46,7 @@
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
- <version>7965</version>
+ <version>7968</version>
</dependency>
</dependencies>
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-12 15:46:10 UTC (rev 1276)
+++ trunk/eugene-plantuml-templates/src/main/java/org/nuiton/eugene/plantuml/PlantumlTemplatesGenerator.java 2013-06-13 16:07:14 UTC (rev 1277)
@@ -3,317 +3,309 @@
import net.sourceforge.plantuml.GeneratedImage;
import net.sourceforge.plantuml.SourceFileReader;
import org.nuiton.eugene.models.object.*;
-import org.nuiton.eugene.models.object.xml.ObjectModelAssociationClassImpl;
-import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl;
+import org.nuiton.eugene.models.object.reader.yaml.KeyWords;
+import org.nuiton.eugene.models.object.reader.yaml.YamlUtil;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
import java.util.*;
-// http://maven-site.nuiton.org/eugene/objectmodel/ObjectModel_Interfaces.png
-//TODO : Plexus ?
+/**
+ * @author agiraudet <giraudet(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.plantuml.PlantumlTemplatesGenerator"
+ * @since 2.6.4
+ */
-public class PlantumlTemplatesGenerator extends ObjectModelGenerator {
+//TODO: utiliser systeme de template
- private boolean _loginit = true;
- private void log(String str) {
- try {
- FileWriter log;
- String path = "/tmp/log.plantuml.txt";
+public class PlantumlTemplatesGenerator extends ObjectModelGenerator implements KeyWords {
- 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) {;}
+ @Override
+ public void generateFromModel(Writer output, ObjectModel input) throws IOException {
+ output.write("@startuml\n\n");
+
+ String nameM = "", versionM = "", packageM = "";
+ if (input.getName() != null) {
+ nameM = input.getName();
+ }
+ if (input.getVersion() != null) {
+ versionM = input.getVersion();
+ }
+ if (input.getTagValue(PACKAGE) != null) {
+ packageM = input.getTagValue(PACKAGE) + " ";
+ }
+ output.write("note \"" + nameM + " " + versionM + "\" as N1\n\n");
+ output.write("package " + packageM + "{\n\n");
+ String indent = " ";
+ for (ObjectModelClass objectModelClass : input.getClasses()) {
+ generateFromClass(output, objectModelClass, indent);
+ }
+ for (ObjectModelInterface objectModelInterface : input.getInterfaces()) {
+ generateFromInterface(output, objectModelInterface, indent);
+ }
+ for (ObjectModelEnumeration objectModelEnumeration : input.getEnumerations()) {
+ generateFromEnumeration(output, objectModelEnumeration, indent);
+ }
+ generateFromLinks(output, input, indent);
+ output.write("\n");
+ output.write("}\n");
+ output.write("@enduml");
}
@Override
- public void generateFromModel(Writer output, ObjectModel input) throws IOException {
- //log
- //log
+ public void applyTemplate(ObjectModel model, File destDir) throws IOException {
+ super.applyTemplate(model, destDir);
+ try {
+ 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");
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
- // utiliser le systeme de templates a l'avenir
+ @Override
+ public String getFilenameForModel(ObjectModel model) {
+ return model.getName() + ".plantuml";
+ }
- Map<ObjectModelAttribute,ObjectModelClassifier> linksOME = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>();
+ public void generateFromClass(Writer output, ObjectModelClass input, String indent) throws IOException {
+ String name = "", stereotype = "", isAbstract = "";
+ if (input.getName() != null) {
+ name = input.getName() + " ";
+ }
+ if (input.getStereotypes() != null) {
+ stereotype = getFromStereotypes(input.getStereotypes()) + " ";
+ }
+ if (input.isAbstract()) {
+ isAbstract = "abstract ";
+ }
+ output.write(indent + isAbstract + "class " + name + stereotype + "{\n");
+ if (input.getAttributes() != null && !input.getAttributes().isEmpty()) {
+ generateFromAttributes(output, input.getAttributes(), indent + " ");
+ }
+ output.write(indent + " ..\n");
+ if (input.getOperations() != null) {
+ generateFromOperations(output, input.getOperations(), indent + " ");
+ }
+ output.write(indent + "}\n");
- // debut du fichier
- output.write("@startuml\n\n");
- // parcours des classes
- for(ObjectModelClass class_tmp : input.getClasses())
- {
- String classStereotype = "";
- if(class_tmp.getStereotypes().size()>0)
- {
- classStereotype = "<<";
- boolean first = true;
- for(String str : class_tmp.getStereotypes())
- {
- if(first)
- {
- classStereotype = classStereotype+str;
- first = false;
- }
- else
- {
- classStereotype = classStereotype+" ,"+str;
- }
- }
- classStereotype = classStereotype+">>";
- }
- String className = class_tmp.getName();
- // ajout de la classe
- output.write("class "+className+classStereotype+" {\n");
- // parcours des attributs de la classe
- 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())
- {
- // ajout du lien
- linksOME.put(attribute_tmp,class_tmp);
- }
- else
- {
- // ajout de l'attribut
- output.write(" -"+attributeName+" : "+attributeType+"\n");
- }
- }
- // parcours des operations
- 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+"(");
- // parcours des parametres
- boolean first = true;
- for(ObjectModelParameter param : operation_tmp.getParameters())
- {
- String parameterName = param.getName();
- //String parameterType = afterLastPoint(param.getType());
- String parameterType = param.getType();
- if(first)
- {
- first = false;
- }
- else
- {
- output.write(", ");
- }
- // ajout du parametre
- output.write(parameterName+" : "+parameterType);
- }
- // ajout du type de retour
- output.write(") : "+operationReturnType+"\n");// attention aux listes !
- }
- output.write("}\n\n");
+ if (input.getSuperclasses() != null) {
+ generateFromSuperClasses(output, input.getSuperclasses(), name, indent);
+ }
+ if (input.getInterfaces() != null) {
+ generateFromSuperInterfaces(output, input.getInterfaces(), name, indent);
+ }
+ output.write("\n");
+ }
+ public void generateFromInterface(Writer output, ObjectModelInterface input, String indent) throws IOException {
+ String name = "", stereotype = "";
+ if (input.getName() != null) {
+ name = input.getName() + " ";
}
+ if (input.getStereotypes() != null) {
+ stereotype = getFromStereotypes(input.getStereotypes()) + " ";
+ }
+ output.write(indent + "class " + name + stereotype + "{\n");
+ if (input.getAttributes() != null && !input.getAttributes().isEmpty()) {
+ generateFromAttributes(output, input.getAttributes(), indent + " ");
+ }
+ output.write(indent + " ..\n");
+ if (input.getOperations() != null) {
+ generateFromOperations(output, input.getOperations(), indent + " ");
+ }
+ output.write(indent + "}\n");
- // parcours des enumerations
- for(ObjectModelEnumeration enumeration_tmp : input.getEnumerations())
- {
- String enumerationName = enumeration_tmp.getName();
- String enumerationStereotype = "";
- 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+">>";
+ if (input.getInterfaces() != null) {
+ generateFromSuperInterfaces(output, input.getInterfaces(), name, indent);
+ }
+ output.write("\n");
+ }
+
+ public void generateFromEnumeration(Writer output, ObjectModelEnumeration input, String indent) throws IOException {
+ String name = "", stereotype = "";
+ if (input.getName() != null) {
+ name = input.getName() + " ";
+ }
+ if (input.getStereotypes() != null) {
+ stereotype = getFromStereotypes(input.getStereotypes()) + " ";
+ }
+ output.write(indent + "enum " + name + stereotype + "{\n");
+ if (input.getLiterals() != null && !input.getAttributes().isEmpty()) {
+ for (String literal : input.getLiterals()) {
+ output.write(indent + " " + literal.toUpperCase() + "\n");
}
- // ajout de l'enumeration
- output.write("enum "+enumerationName+enumerationStereotype+" {\n");
- for(String literalOM : enumeration_tmp.getLiterals())
- {
- output.write(" "+literalOM.toUpperCase()+"\n");
- }
- output.write("}\n\n");
}
+ output.write(indent + " ..\n");
+ if (input.getOperations() != null) {
+ generateFromOperations(output, input.getOperations(), indent + " ");
+ }
+ output.write(indent + "}\n");
- // parcours des interfaces
- for(ObjectModelInterface interface_tmp : input.getInterfaces())
- {
- String interfaceName = interface_tmp.getName();
- String interfaceStereotype = "";
- 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;
- }
+ output.write("\n");
+ }
+
+ public String getFromStereotypes(Collection<String> stereotypes) {
+ StringBuilder stereotype = new StringBuilder("");
+ if (stereotypes.size() > 0) {
+ stereotype.append("<< ");
+ boolean first = true;
+ for (String str : stereotypes) {
+ if (first) {
+ first = false;
+ } else {
+ stereotype.append(", ");
}
- interfaceStereotype = interfaceStereotype+">>";
+ stereotype.append(str);
}
- // ajout de l'interface
- output.write("interface "+interfaceName+interfaceStereotype+" {\n");
- // ajout des methodes
- output.write("}\n\n");
+ stereotype.append(" >>");
}
+ return stereotype.toString();
+ }
- //liaisons
- for(ObjectModelAttribute attribute_tmp : linksOME.keySet())
- {
- //if(attribute_tmp.isNavigable())
- {
- if(attribute_tmp.isComposite() && attribute_tmp.referenceClassifier())
- {
- output.write(linksOME.get(attribute_tmp).getName()+" *-- "+attribute_tmp.getClassifier().getName()+"\n");
+ //TODO: parser type
+ public void generateFromAttributes(Writer output, Collection<ObjectModelAttribute> input, String indent) throws IOException {
+ for (ObjectModelAttribute attribute : input) {
+ if (!attribute.referenceClassifier()) {
+ String type = "", name = "";
+ if (attribute.getType() != null) {
+ type = attribute.getType() + " ";
}
- else if(attribute_tmp.isAggregate() && attribute_tmp.referenceClassifier())//else if
- {
- output.write(linksOME.get(attribute_tmp).getName()+" o-- "+attribute_tmp.getClassifier().getName()+"\n");
+ if (attribute.getName() != null) {
+ name = attribute.getName();
}
- 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");
- }
+ output.write(indent + type + name + "\n");
}
}
+ }
- /*//test
- for(ObjectModelClassifier class_tmp : input.getClassifiers())
- {
- log("name="+class_tmp.getName());
- for(ObjectModelDependency dependency : class_tmp.getDependencies())
- {
- log("dependency="+dependency.getName()+" client="+ dependency.getClient().getName()+" supplier="+dependency.getSupplier().getName());
+ //TODO: parser parameters
+ public void generateFromOperations(Writer output, Collection<ObjectModelOperation> input, String indent) throws IOException {
+ for (ObjectModelOperation operation : input) {
+ String isAbstract = "", parameters = "", name = "", returnParameter = "";
+ if (operation.isAbstract()) {
+ isAbstract = "{abstract} ";
}
- 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())
- {
- String key = attribute.getAssociationClass().getName();
- String value = classifier.getName();
- if(associationClass.containsKey(key))
- {
- associationClass.get(key).add(value);
+ if (operation.getParameters() != null) {
+ StringBuilder tmp = new StringBuilder("");
+ boolean first = true;
+ for (ObjectModelParameter parameter : operation.getParameters()) {
+ if (first) {
+ first = false;
+ } else {
+ tmp.append(", ");
}
- else
- {
- associationClass.put(key,new LinkedList<String>());
- associationClass.get(key).add(value);
+ if (parameter.getType() != null) {
+ tmp.append(parameter.getType()).append(" ");
}
+ if (parameter.getName() != null) {
+ tmp.append(parameter.getName());
+ }
}
+ parameters = tmp.toString();
}
- }
- for(Map.Entry<String,LinkedList<String>> entry : associationClass.entrySet())
- {
- boolean first = true;
- output.write("(");
- for(String value : entry.getValue())
- {
- if(first)
- {
- output.write(value);
- first = false;
- }else
- {
- output.write(", "+value);
+ if (operation.getReturnParameter() != null) {
+ if (operation.getReturnParameter().getType() != null) {
+ returnParameter = operation.getReturnParameter().getType() + " ";
}
}
- output.write(") .. "+entry.getKey()+"\n");
+ if (operation.getName() != null) {
+ name = operation.getName();
+ }
+ output.write(indent + isAbstract + returnParameter + name + "(" + parameters + ")\n");
}
+ }
- //extensions/generalisations (heritage)
- for(ObjectModelClass classOM : input.getClasses())
- {
- for(ObjectModelClass superClassOM : classOM.getSuperclasses())
- {
- output.write(superClassOM.getName()+" <|-- "+classOM.getName()+"\n");
+ public void generateFromSuperClasses(Writer output, Collection<ObjectModelClass> input, String name, String indent) throws IOException {
+ for (ObjectModelClass superClass : input) {
+ String superClassName = "";
+ if (superClass.getName() != null) {
+ superClassName = superClass.getName();
}
+ output.write(indent + superClassName + " <|-- " + name + "\n");
}
+ }
- //realisations
- for(ObjectModelClass classOM : input.getClasses())
- {
- for(ObjectModelInterface superInterfaceOM : classOM.getInterfaces())
- {
- output.write(superInterfaceOM.getName()+" <|.. "+classOM.getName()+"\n");
+ public void generateFromSuperInterfaces(Writer output, Collection<ObjectModelInterface> input, String name, String indent) throws IOException {
+ for (ObjectModelInterface superInterface : input) {
+ String superInterfaceName = "";
+ if (superInterface.getName() != null) {
+ superInterfaceName = superInterface.getName();
}
+ output.write(indent + superInterfaceName + " <|.. " + name + "\n");
}
-
- // fin du fichier
- output.write("\n@enduml");
}
- // exemple : afterLastPoint("org.nuiton.testeugene.generator") return "generator"
- public static String afterLastPoint(String input)
- {
- String str = new StringBuffer(input).reverse().toString();
- String res = "";
- for(Character car : str.toCharArray())
+ //TODO: factoriser
+ public void generateFromLinks(Writer output, ObjectModel input, String indent) throws IOException {
+ Map<ObjectModelAttribute, ObjectModelClassifier> attributesM = new LinkedHashMap<ObjectModelAttribute, ObjectModelClassifier>();
+ List<ObjectModelAttribute> bin = new LinkedList<ObjectModelAttribute>();//bin au sens poubelle
+
+ for (ObjectModelClassifier classifier : input.getClassifiers())//TODO+enum?
{
- if(car.equals('.'))
- {
- return res;
+ if (classifier.getAttributes() != null) {
+ for (ObjectModelAttribute attribute : classifier.getAttributes()) {
+ if (attribute.referenceClassifier()) {
+ attributesM.put(attribute, classifier);
+ }
+ }
}
- else
- {
- res = car.toString()+res;
- }
}
- return res;
- }
- @Override
- public void applyTemplate(ObjectModel model, File destDir) throws IOException {
- super.applyTemplate(model, destDir);
- try {
- 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");
- } catch (InterruptedException e) {
- e.printStackTrace();
+ for (Map.Entry<ObjectModelAttribute, ObjectModelClassifier> entry : attributesM.entrySet()) {
+ ObjectModelAttribute attribute = entry.getKey();
+ ObjectModelClassifier classifier = entry.getValue();
+ if (attribute.isNavigable()) {
+ String attributeName = "";
+ if (attribute.getName() != null) {
+ attributeName = attribute.getName();
+ }
+ String minMultiplicity = (attribute.getMinMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMinMultiplicity());
+ String maxMultiplicity = (attribute.getMaxMultiplicity() == -1) ? "*" : String.valueOf(attribute.getMaxMultiplicity());
+ String multiplicity = (minMultiplicity.equals(maxMultiplicity)) ? minMultiplicity : minMultiplicity + ".." + maxMultiplicity;
+ String type = YamlUtil.afterChar(attribute.getType(), '.');
+ if (!bin.contains(attribute)) {
+ if (attribute.getReverseAttribute() != null) {
+ ObjectModelAttribute reverseAttribute = attribute.getReverseAttribute();
+ String reverseAttributeName = "";
+ if (reverseAttribute.getName() != null) {
+ reverseAttributeName = reverseAttribute.getName();
+ }
+ String reverseMinMultiplicity = (reverseAttribute.getMinMultiplicity() == -1) ? "*" : String.valueOf(reverseAttribute.getMinMultiplicity());
+ String reverseMaxMultiplicity = (reverseAttribute.getMaxMultiplicity() == -1) ? "*" : String.valueOf(reverseAttribute.getMaxMultiplicity());
+ String reverseMultiplicity = (reverseMinMultiplicity.equals(reverseMaxMultiplicity)) ? reverseMinMultiplicity : reverseMinMultiplicity + ".." + reverseMaxMultiplicity;
+ String reverseType = YamlUtil.afterChar(reverseAttribute.getType(), '.');
+ if (reverseAttribute.isNavigable())//lien bi-directionnel
+ {
+ output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" -- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
+ if (attribute.getAssociationClass() != null && reverseAttribute.getAssociationClass() != null && attribute.getAssociationClass().equals(reverseAttribute.getAssociationClass())) {
+ String associationClassName = "";
+ if (attribute.getAssociationClass().getName() != null) {
+ associationClassName = attribute.getAssociationClass().getName();
+ }
+ output.write(indent + "(" + type + ", " + reverseType + ") . " + associationClassName + "\n");
+ }
+ bin.add(reverseAttribute);
+ } else//lien uni-directionnel
+ {
+ if (multiplicity.equals("0..*") && reverseMultiplicity.equals("1")) {
+ output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <--* \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
+ } else {
+ output.write(indent + type + " \"" + multiplicity + " " + attributeName + "\" <-- \"" + reverseMultiplicity + " " + reverseAttributeName + "\" " + reverseType + "\n");
+ }
+ }
+ } else {
+ String reverseType = "";
+ if (attributesM.get(attribute).getName() != null) {
+ reverseType = attributesM.get(attribute).getName();
+ }
+ output.write(type + " \"" + multiplicity + " " + attributeName + "\" <-- " + reverseType + "\n");
+ }
+ }
+ }
}
}
-
- @Override
- public String getFilenameForModel(ObjectModel model) {
- return model.getName()+".plantuml";
- }
}
1
0
12 Jun '13
Author: agiraudet
Date: 2013-06-12 17:46:10 +0200 (Wed, 12 Jun 2013)
New Revision: 1276
Url: http://nuiton.org/projects/eugene/repository/revisions/1276
Log:
syntaxe user friendly : param?\195?\168tre de retour des op?\195?\169rations d?\195?\169sormais devant l'op?\195?\169ration et non apr?\195?\168s (remplac?\195?\169 par bodyCode)
syntaxe user firendly : remplacement de la valeur par d?\195?\169faut des attributs par la reverse min/max multiplicit?\195?\169 et reverse ordering pour les liens unidirectionnels (test)
ajout d'un template de g?\195?\169n?\195?\169ration de syntaxe pure yaml ?\195?\160 partir d'un ObjectModel (template pour la syntaxe user friendly ?\195?\160 venir)
Added:
trunk/eugene-yaml-templates/
trunk/eugene-yaml-templates/LICENSE.txt
trunk/eugene-yaml-templates/README.txt
trunk/eugene-yaml-templates/changelog.txt
trunk/eugene-yaml-templates/pom.xml
trunk/eugene-yaml-templates/src/
trunk/eugene-yaml-templates/src/main/
trunk/eugene-yaml-templates/src/main/java/
trunk/eugene-yaml-templates/src/main/java/org/
trunk/eugene-yaml-templates/src/main/java/org/nuiton/
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java
trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
trunk/eugene-yaml-templates/src/main/resources/
trunk/eugene-yaml-templates/src/test/
trunk/eugene-yaml-templates/src/test/java/
Modified:
trunk/eugene-maven-plugin/pom.xml
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/ParserUserFriendly.java
trunk/pom.xml
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-11 14:52:53 UTC (rev 1275)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-12 15:46:10 UTC (rev 1276)
@@ -9,6 +9,7 @@
String SEPARATOR = ".";
String ABSTRACT = "abstract";
+ String AGGREGATE = "aggregate";
String ASSOCIATION_CLASS = "associationclass";
String ASSOCIATION_CLASS_NAME = "associationclassname";
String ASSOCIATION_TYPE = "associationtype";
@@ -17,7 +18,9 @@
String CLASS = "class";
String CLASSIFIER = "classifier";
String COMMENTS = "comments";
+ String COMPOSITE = "composite";
String DEFAULT_VALUE = "defaultvalue";
+ String DESCRIPTION = "description";
String DOCUMENTATION = "documentation";
String ENUMERATION = "enumeration";
String EXTERN = "extern";
@@ -43,6 +46,8 @@
String RETURN_PARAMETER = "returnparameter";
String REVERSE_ATTRIBUTE_NAME = "reverseattributename";
String REVERSE_MAX_MULTIPLICITY = "reversemaxmultiplicity";
+ String REVERSE_MIN_MULTIPLICITY = "reverseminmultiplicity";
+ String REVERSE_ORDERING = "reverseordering";
String STATIC = "static";
String STEREOTYPES = "stereotypes";
String SUPER_CLASSES = "superclasses";
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 14:52:53 UTC (rev 1275)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-12 15:46:10 UTC (rev 1276)
@@ -486,6 +486,40 @@
if (attributePARSE.size() > 1) {
attributeYAMLO.addStringToMap(NAME, attributePARSE.get(1));
}
+ if(value != null)
+ {
+ //idée1: defaultValue
+ //attributeYAMLO.addStringToMap(DEFAULT_VALUE,String.valueOf(value));
+ //idée2: reverseMultiplicity & reverseOrdering (pour lien unidirectionnel)
+ List<String> valuePARSE = YamlUtil.charParse(String.valueOf(value),' ');
+ if (valuePARSE.contains(ORDERED)) {
+ attributeYAMLO.addStringToMap(REVERSE_ORDERING, ORDERED);
+ attributePARSE.remove(valuePARSE.indexOf(ORDERED));
+ } else if (valuePARSE.contains(UNORDERED)) {
+ attributeYAMLO.addStringToMap(REVERSE_ORDERING, UNORDERED);
+ attributePARSE.remove(valuePARSE.indexOf(UNORDERED));
+ }
+
+ if (valuePARSE.contains("[" + YamlUtil.extract('[', ']', String.valueOf(value)) + "]")) {
+ String multiplicity = YamlUtil.extract('[', ']', String.valueOf(value));
+ if (multiplicity.equals("*")) {
+ attributeYAMLO.addStringToMap(REVERSE_MIN_MULTIPLICITY, "0");
+ attributeYAMLO.addStringToMap(REVERSE_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(REVERSE_MIN_MULTIPLICITY, min);
+ attributeYAMLO.addStringToMap(REVERSE_MAX_MULTIPLICITY, max);
+ }
+ valuePARSE.remove("[" + YamlUtil.extract('[', ']', String.valueOf(value)) + "]");
+ }
+ }
}
public void parseOperation(String key, Object value, YamlObject operationYAMLO) {
@@ -531,11 +565,20 @@
}
}
- if (value != null) {
+ if (operationPARSE.size() > 1) {
YamlObject returnParameterYAMLO = new YamlObject();
- returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value));
+ returnParameterYAMLO.addStringToMap(TYPE, operationPARSE.get(0));
operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);
}
+
+ if (value != null) {
+ //idée1: returnParameter
+ /*YamlObject returnParameterYAMLO = new YamlObject();
+ returnParameterYAMLO.addStringToMap(TYPE, String.valueOf(value));
+ operationYAMLO.addYamlObjectToMap(RETURN_PARAMETER, returnParameterYAMLO);*/
+ //idée2: bodyCode
+ operationYAMLO.addStringToMap(BODY_CODE,String.valueOf(value));
+ }
}
public void resolveImports() {
@@ -662,6 +705,7 @@
YamlObject reverseObject = getReverseObject(YamlUtil.afterChar(type, '.'));
if (reverseObject != null) {
YamlObject reverseAttribute = new YamlObject();
+ attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
reverseAttribute.addStringToMap(NAVIGABLE, String.valueOf(false));
reverseAttribute.addStringToMap(TYPE, imports.get(labelisable.getFirstMapStringListString(NAME)));
if (attribute.containsKeyMapStringListString(MAX_MULTIPLICITY)) {
@@ -670,7 +714,18 @@
if (attribute.containsKeyMapStringListString(NAME)) {
reverseAttribute.addStringToMap(REVERSE_ATTRIBUTE_NAME, attribute.getFirstMapStringListString(NAME));
}
- if (attribute.containsKeyMapStringListString(ORDERING)) {
+ if (attribute.containsKeyMapStringListString(REVERSE_MIN_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(MIN_MULTIPLICITY, attribute.getFirstMapStringListString(REVERSE_MIN_MULTIPLICITY));
+ }
+ if (attribute.containsKeyMapStringListString(REVERSE_MAX_MULTIPLICITY)) {
+ reverseAttribute.addStringToMap(MAX_MULTIPLICITY, attribute.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY));
+ }
+ if(attribute.containsKeyMapStringListString(REVERSE_ORDERING))
+ {
+ reverseAttribute.addStringToMap(ORDERING, attribute.getFirstMapStringListString(REVERSE_ORDERING));
+ }
+ //else set opposit ordering
+ else if (attribute.containsKeyMapStringListString(ORDERING)) {
if (attribute.getFirstMapStringListString(ORDERING).equals(ORDERED)) {
reverseAttribute.addStringToMap(ORDERING, UNORDERED);
} else if (attribute.getFirstMapStringListString(ORDERING).equals(UNORDERED)) {
@@ -678,8 +733,6 @@
}
}
reverseObject.addYamlObjectToMap(ATTRIBUTE, reverseAttribute);
-
- attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
}
}
}
Modified: trunk/eugene-maven-plugin/pom.xml
===================================================================
--- trunk/eugene-maven-plugin/pom.xml 2013-06-11 14:52:53 UTC (rev 1275)
+++ trunk/eugene-maven-plugin/pom.xml 2013-06-12 15:46:10 UTC (rev 1276)
@@ -64,6 +64,13 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>eugene-yaml-templates</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
Property changes on: trunk/eugene-yaml-templates
___________________________________________________________________
Added: svn:ignore
+ target
.idea
*.ipr
*.iml
*.iws
Added: trunk/eugene-yaml-templates/LICENSE.txt
===================================================================
Added: trunk/eugene-yaml-templates/README.txt
===================================================================
Added: trunk/eugene-yaml-templates/changelog.txt
===================================================================
Added: trunk/eugene-yaml-templates/pom.xml
===================================================================
--- trunk/eugene-yaml-templates/pom.xml (rev 0)
+++ trunk/eugene-yaml-templates/pom.xml 2013-06-12 15:46:10 UTC (rev 1276)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: EUGene
+
+ $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-yaml-templates/pom.xml $
+ %%
+ Copyright (C) 2004 - 2010 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%
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>eugene</artifactId>
+ <version>2.6.4-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-yaml-templates</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>eugene</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <name>EUGene :: YAML templates</name>
+
+ <inceptionYear>2013</inceptionYear>
+
+ <build>
+ <plugins>
+ <!-- expose new plexus components -->
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
+
+
Added: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java
===================================================================
--- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java (rev 0)
+++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/PureYamlTemplatesGenerator.java 2013-06-12 15:46:10 UTC (rev 1276)
@@ -0,0 +1,281 @@
+package org.nuiton.eugene.yaml;
+
+import org.nuiton.eugene.models.object.*;
+import org.nuiton.eugene.models.object.reader.yaml.KeyWords;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * @author agiraudet <giraudet(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.yaml.PureYamlTemplatesGenerator"
+ * @since 2.6.4
+ */
+
+public class PureYamlTemplatesGenerator extends ObjectModelGenerator implements KeyWords {
+
+ //TODO: tenir compte des valeurs par defaut : afficher seulement les valeurs différentes des valeurs par défaut
+
+ @Override
+ public void generateFromModel(Writer output, ObjectModel input) throws IOException {
+ output.write("%YAML 1.1\n---\n- syntaxe: 1.0\n\n");
+ if(input.getName() != null)
+ {
+ output.write("- "+NAME+": "+input.getName()+"\n");
+ }
+ if(input.getVersion() != null)
+ {
+ output.write("- "+VERSION+": "+input.getVersion()+"\n");
+ }
+ if(input.getTagValues() != null && !input.getTagValues().isEmpty())
+ {
+ output.write("- "+TAG_VALUES+":\n");
+ for(Map.Entry<String,String> entry : input.getTagValues().entrySet())
+ {
+ output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n");
+ }
+ }
+ output.write("\n");
+ //classifier
+ if(input.getClasses() != null && !input.getClasses().isEmpty())
+ {
+ for(ObjectModelClass objectModelClass : input.getClasses())
+ {
+ //associationClass
+ if(objectModelClass instanceof ObjectModelAssociationClass)
+ {
+ generateFromAssociationClass(output, (ObjectModelAssociationClass) objectModelClass);
+ }
+ //class
+ else
+ {
+ generateFromClass(output, objectModelClass);
+ }
+ }
+ }
+ //interface
+ if(input.getInterfaces() != null && !input.getInterfaces().isEmpty())
+ {
+ for(ObjectModelInterface objectModelInterface : input.getInterfaces())
+ {
+ generateFromInterface(output, objectModelInterface);
+ }
+ }
+ //enumeration
+ if(input.getEnumerations() != null && !input.getEnumerations().isEmpty())
+ {
+ for(ObjectModelEnumeration objectModelEnumeration : input.getEnumerations())
+ {
+ generateFromEnumeration(output,objectModelEnumeration);
+ }
+ }
+ }
+
+ @Override
+ public String getFilenameForModel(ObjectModel model) {
+ return model.getName()+".yamlobjectmodel";
+ }
+
+ public void generateFromElement(Writer output, ObjectModelElement input, String indent) throws IOException {
+ if(input.getName() != null)
+ {
+ output.write(indent+"- "+NAME+": "+input.getName()+"\n");
+ }
+ if(input.getStereotypes() != null && !input.getStereotypes().isEmpty())
+ {
+ for(String stereotype : input.getStereotypes())
+ {
+ output.write(indent+"- "+STEREOTYPES+": "+stereotype+"\n");
+ }
+ }
+ if(input.getComments() != null && !input.getComments().isEmpty())
+ {
+ for(String comment : input.getComments())
+ {
+ output.write(indent+"- "+COMMENTS+": "+comment+"\n");
+ }
+ }
+ /*if(input.getDescription() != null)
+ {
+ output.write(indent+"- "+DESCRIPTION+": "+input.getDescription()+"\n");
+ }*/
+ if(input.getDocumentation() != null)
+ {
+ output.write(indent+"- "+DOCUMENTATION+": "+input.getDocumentation()+"\n");
+ }
+ if(input.getTagValues() != null && !input.getTagValues().isEmpty())
+ {
+ output.write("- "+TAG_VALUES+":\n");
+ for(Map.Entry<String,String> entry : input.getTagValues().entrySet())
+ {
+ output.write(" - "+entry.getKey()+": "+entry.getValue()+"\n");
+ }
+ }
+ output.write(indent+"- "+STATIC+": "+String.valueOf(input.isStatic())+"\n");
+ }
+
+ public void generateFromClassifier(Writer output, ObjectModelClassifier input) throws IOException {
+ if(input.getInterfaces() != null && !input.getInterfaces().isEmpty())
+ {
+ for(ObjectModelInterface objectModelInterface : input.getInterfaces())
+ {
+ //tester null
+ output.write(" - "+SUPER_INTERFACES+": "+objectModelInterface.getPackageName()+"."+objectModelInterface.getName());
+ }
+ }
+ generateFromElement(output,input," ");
+ output.write(" - "+INNER+": "+String.valueOf(input.isInner())+"\n");
+ if(input.getPackageName() != null)
+ {
+ output.write(" - "+PACKAGE+": "+input.getPackageName()+"\n");
+ }
+ if(input.getAttributes() != null && !input.getAttributes().isEmpty())
+ {
+ for(ObjectModelAttribute attribute : input.getAttributes())
+ {
+ generateFromAttribute(output,attribute);
+ }
+ }
+ if(input.getOperations() != null && !input.getOperations().isEmpty())
+ {
+ for(ObjectModelOperation operation : input.getOperations())
+ {
+ generateFromOperation(output,operation);
+ }
+ }
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass input) throws IOException {
+ output.write("- " + CLASS + ":\n");
+ output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n");
+ if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty())
+ {
+ for(ObjectModelClass objectModelClass : input.getSuperclasses())
+ {
+ //tester null
+ output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName());
+ }
+ }
+ generateFromClassifier(output,input);
+ output.write("\n");
+ }
+
+ public void generateFromInterface(Writer output, ObjectModelInterface input) throws IOException {
+ output.write("- "+INTERFACE+":\n");
+ generateFromClassifier(output,input);
+ output.write("\n");
+ }
+
+ public void generateFromAssociationClass(Writer output, ObjectModelAssociationClass input) throws IOException {
+ output.write("- " + ASSOCIATION_CLASS + ":\n");
+ if(input.getSuperclasses() != null && !input.getSuperclasses().isEmpty())
+ {
+ for(ObjectModelClass objectModelClass : input.getSuperclasses())
+ {
+ //tester null
+ output.write(" - "+SUPER_CLASSES+": "+objectModelClass.getPackageName()+"."+objectModelClass.getName());
+ }
+ }
+ generateFromClassifier(output,input);
+ output.write(" - " + ABSTRACT + ": " + String.valueOf(input.isAbstract()) + "\n");
+ if(input.getParticipantsAttributes() != null && !input.getParticipantsAttributes().isEmpty())
+ {
+ for(ObjectModelAttribute attribute : input.getParticipantsAttributes())
+ {
+ output.write(" - "+PARTICIPANT+":\n");
+ //tester null
+ if(attribute.getType() != null)
+ {
+ output.write(" - "+NAME+": "+attribute.getType()+"\n");
+ }
+ if(attribute.getName() != null)
+ {
+ output.write(" - "+TYPE+": "+attribute.getName()+"\n");
+ }
+ }
+ }
+ output.write("\n");
+ }
+
+ public void generateFromEnumeration(Writer output, ObjectModelEnumeration input) throws IOException {
+ output.write("- "+ENUMERATION+":\n");
+ generateFromElement(output,input," ");
+ }
+
+ public void generateFromParameter(Writer output, ObjectModelParameter input, String indent) throws IOException {
+ generateFromElement(output,input,indent);
+ if(input.isOrdered())
+ {
+ output.write(indent+"- "+ORDERING+": "+ORDERED+"\n");
+ }
+ else
+ {
+ output.write(indent+"- "+ORDERING+": "+UNORDERED+"\n");
+ }
+ if(input.getType() != null)
+ {
+ output.write(indent+"- "+TYPE+": "+input.getType()+"\n");
+ }
+ if(input.getDefaultValue() != null)
+ {
+ output.write(indent+"- "+DEFAULT_VALUE+": "+input.getDefaultValue()+"\n");
+ }
+ output.write(indent+"- "+MIN_MULTIPLICITY+": "+String.valueOf(input.getMinMultiplicity())+"\n");
+ output.write(indent+"- "+MAX_MULTIPLICITY+": "+String.valueOf(input.getMaxMultiplicity())+"\n");
+ output.write(indent+"- "+UNIQUE+": "+String.valueOf(input.isUnique())+"\n");
+ }
+
+ public void generateFromAttribute(Writer output, ObjectModelAttribute input) throws IOException {
+ output.write(" - "+ATTRIBUTE+":\n");
+ generateFromParameter(output, input, " ");
+ output.write(" - "+NAVIGABLE+": "+String.valueOf(input.isNavigable())+"\n");
+ output.write(" - "+TRANSIENT+": "+String.valueOf(input.isTransient())+"\n");
+ output.write(" - "+FINAL+": "+String.valueOf(input.isFinal())+"\n");
+ output.write(" - "+REVERSE_MAX_MULTIPLICITY+": "+String.valueOf(input.getReverseMaxMultiplicity())+"\n");
+ if(input.getVisibility() != null)
+ {
+ output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n");
+ }
+ if(input.isComposite())
+ {
+ output.write(" - "+ASSOCIATION_TYPE+": "+COMPOSITE+"\n");
+ }
+ else if(input.isAggregate())
+ {
+ output.write(" - "+ASSOCIATION_TYPE+": "+AGGREGATE+"\n");
+ }
+ if(input.getAssociationClass() != null)
+ {
+ output.write(" - "+ASSOCIATION_CLASS_NAME+": "+input.getAssociationClass().getPackageName()+"."+input.getAssociationClass().getName()+"\n");
+ }
+ }
+
+ public void generateFromOperation(Writer output, ObjectModelOperation input) throws IOException {
+ output.write(" - " + ATTRIBUTE + ":\n");
+ generateFromElement(output, input, " ");
+ output.write(" - "+ABSTRACT+": "+String.valueOf(input.isAbstract())+"\n");
+ if(input.getVisibility() != null)
+ {
+ output.write(" - "+VISIBILITY+": "+input.getVisibility()+"\n");
+ }
+ if(input.getBodyCode() != null)
+ {
+ output.write(" - "+BODY_CODE+": "+input.getBodyCode()+"\n");
+ }
+ if(input.getReturnParameter() != null)
+ {
+ output.write(" - "+RETURN_PARAMETER+":\n");
+ generateFromParameter(output, input.getReturnParameter(), " ");
+ }
+ if(input.getParameters() != null && !input.getParameters().isEmpty())
+ {
+ for(ObjectModelParameter objectModelParameter : input.getParameters())
+ {
+ output.write(" - "+PARAMETER+":\n");
+ generateFromParameter(output, objectModelParameter, " ");
+ }
+ }
+
+ }
+}
Added: trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java
===================================================================
--- trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java (rev 0)
+++ trunk/eugene-yaml-templates/src/main/java/org/nuiton/eugene/yaml/UserFriendlyTemplatesGenerator.java 2013-06-12 15:46:10 UTC (rev 1276)
@@ -0,0 +1,26 @@
+package org.nuiton.eugene.yaml;
+
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.reader.yaml.KeyWords;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author agiraudet <giraudet(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.yaml.UserFriendlyTemplatesGenerator"
+ * @since 2.6.4
+ */
+public class UserFriendlyTemplatesGenerator extends ObjectModelGenerator implements KeyWords {
+
+ @Override
+ public void generateFromModel(Writer output, ObjectModel input) throws IOException {
+ ;//TODO:
+ }
+
+ @Override
+ public String getFilenameForModel(ObjectModel model) {
+ return model.getName()+".yamlobjectmodel";
+ }
+}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-06-11 14:52:53 UTC (rev 1275)
+++ trunk/pom.xml 2013-06-12 15:46:10 UTC (rev 1276)
@@ -43,6 +43,7 @@
<module>eugene-java-templates</module>
<module>eugene-plantuml-templates</module>
<module>eugene-maven-plugin</module>
+ <module>eugene-yaml-templates</module>
</modules>
<dependencyManagement>
1
0
r1275 - 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 16:52:53 +0200 (Tue, 11 Jun 2013)
New Revision: 1275
Url: http://nuiton.org/projects/eugene/repository/revisions/1275
Log:
remplac class KeyWords par interface : org.nuiton.eugene.models.object.reader.yaml.KeyWords
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-11 14:22:32 UTC (rev 1274)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-11 14:52:53 UTC (rev 1275)
@@ -14,7 +14,7 @@
* Date: 11/06/13
* Time: 14:51
*/
-public class DefaultValues extends KeyWords {
+public class DefaultValues implements KeyWords {
Yaml yaml;
public DefaultValues()
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-11 14:22:32 UTC (rev 1274)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-11 14:52:53 UTC (rev 1275)
@@ -5,55 +5,55 @@
* Date: 30/05/13
* Time: 10:10
*/
-public class KeyWords {
- public static final String SEPARATOR = ".";
+public interface KeyWords {
+ String SEPARATOR = ".";
- public static final String ABSTRACT = "abstract";
- public static final String ASSOCIATION_CLASS = "associationclass";
- public static final String ASSOCIATION_CLASS_NAME = "associationclassname";
- public static final String ASSOCIATION_TYPE = "associationtype";
- public static final String ATTRIBUTE = "attribute";
- public static final String BODY_CODE = "bodeycode";
- public static final String CLASS = "class";
- public static final String CLASSIFIER = "classifier";
- public static final String COMMENTS = "comments";
- public static final String DEFAULT_VALUE = "defaultvalue";
- public static final String DOCUMENTATION = "documentation";
- public static final String ENUMERATION = "enumeration";
- public static final String EXTERN = "extern";
- public static final String FINAL = "final";
- 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";
- public static final String NAME = "name";
- public static final String NAVIGABLE = "navigable";
- public static final String OPERATION = "operation";
- public static final String ORDERED = "ordered";
- public static final String ORDERING = "ordering";
- 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";
- public static final String STATIC = "static";
- public static final String STEREOTYPES = "stereotypes";
- public static final String SUPER_CLASSES = "superclasses";
- public static final String SUPER_INTERFACES = "superinterfaces";
- public static final String SYNTAXE = "syntaxe";
- public static final String TAG_VALUES = "tagvalues";
- 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";
+ String ABSTRACT = "abstract";
+ String ASSOCIATION_CLASS = "associationclass";
+ String ASSOCIATION_CLASS_NAME = "associationclassname";
+ String ASSOCIATION_TYPE = "associationtype";
+ String ATTRIBUTE = "attribute";
+ String BODY_CODE = "bodeycode";
+ String CLASS = "class";
+ String CLASSIFIER = "classifier";
+ String COMMENTS = "comments";
+ String DEFAULT_VALUE = "defaultvalue";
+ String DOCUMENTATION = "documentation";
+ String ENUMERATION = "enumeration";
+ String EXTERN = "extern";
+ String FINAL = "final";
+ String IMPORTS = "imports";
+ String INNER = "inner";
+ String INTERFACE = "interface";
+ String LABEL = "label";
+ String LITERAL = "literal";
+ String MAX_MULTIPLICITY = "maxmultiplicity";
+ String MIN_MULTIPLICITY = "minmultiplicity";
+ String NAME = "name";
+ String NAVIGABLE = "navigable";
+ String OPERATION = "operation";
+ String ORDERED = "ordered";
+ String ORDERING = "ordering";
+ String PACKAGE = "package";
+ String PARAMETER = "parameter";
+ String PARTICIPANT = "participant";
+ String PRIVATE = "private";
+ String PROTECTED = "protected";
+ String PUBLIC = "public";
+ String RETURN_PARAMETER = "returnparameter";
+ String REVERSE_ATTRIBUTE_NAME = "reverseattributename";
+ String REVERSE_MAX_MULTIPLICITY = "reversemaxmultiplicity";
+ String STATIC = "static";
+ String STEREOTYPES = "stereotypes";
+ String SUPER_CLASSES = "superclasses";
+ String SUPER_INTERFACES = "superinterfaces";
+ String SYNTAXE = "syntaxe";
+ String TAG_VALUES = "tagvalues";
+ String TRANSIENT = "transient";
+ String TYPE = "type";
+ String UNIQUE = "unique";
+ String UNORDERED = "unordered";
+ String VERSION = "version";
+ String VISIBILITY = "visibility";
+ String ELEMENT = "element";
}
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 14:22:32 UTC (rev 1274)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-11 14:52:53 UTC (rev 1275)
@@ -10,7 +10,7 @@
* Date: 11/06/13
* Time: 10:37
*/
-public class LoadObjectModel extends KeyWords {
+public class LoadObjectModel implements KeyWords {
protected String packageL;
protected YamlObject modelYAMLO;
protected ObjectModelImpl modelOM;
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 14:22:32 UTC (rev 1274)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-11 14:52:53 UTC (rev 1275)
@@ -16,7 +16,7 @@
* Date: 10/06/13
* Time: 16:11
*/
-public class LoadYamlFile extends KeyWords {
+public class LoadYamlFile implements KeyWords {
Yaml yaml;
public LoadYamlFile() {
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 14:22:32 UTC (rev 1274)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/ParserUserFriendly.java 2013-06-11 14:52:53 UTC (rev 1275)
@@ -10,7 +10,7 @@
* Date: 10/06/13
* Time: 16:48
*/
-public class ParserUserFriendly extends KeyWords {
+public class ParserUserFriendly implements KeyWords {
protected Map<String, String> imports;
protected Map<String, String> importsI;
protected Map<String, String> importsE;
1
0
r1274 - 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 16:22:32 +0200 (Tue, 11 Jun 2013)
New Revision: 1274
Url: http://nuiton.org/projects/eugene/repository/revisions/1274
Log:
ajout de la gestion des valeurs par defaut : org.nuiton.eugene.models.object.reader.yaml.DefaultValues
Added:
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.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/LoadObjectModel.java
trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java
Added: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java (rev 0)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/DefaultValues.java 2013-06-11 14:22:32 UTC (rev 1274)
@@ -0,0 +1,63 @@
+package org.nuiton.eugene.models.object.reader.yaml;
+
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * User: agiraudet
+ * Date: 11/06/13
+ * Time: 14:51
+ */
+public class DefaultValues extends KeyWords {
+ Yaml yaml;
+
+ public DefaultValues()
+ {
+ yaml = new Yaml();
+ }
+
+ public static Map<String,String> getDefaultValues(String version)
+ {
+ Map<String,String> values = new LinkedHashMap<String, String>();
+
+ if(version.equals("0"))
+ {
+ values.put(ATTRIBUTE+SEPARATOR+MIN_MULTIPLICITY,"1");
+ values.put(ATTRIBUTE+SEPARATOR+MAX_MULTIPLICITY,"1");
+ values.put(ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY,"1");
+ }
+ /*else if(version.equals(""))
+ {
+ ;
+ }*/
+
+ return values;
+ }
+
+ //retourne les valeurs par defaut du fichier YAML passe an parametre
+ public Map<String,String> getDefaultValues(File file) throws IOException {
+ InputStream inputModel = new FileInputStream(file);
+ Object valuesYAML = yaml.load(inputModel);
+ inputModel.close();
+
+ Map<String,String> values = new LinkedHashMap<String, String>();
+ if(valuesYAML instanceof Map)
+ {
+ for(Object entry : ((Map) valuesYAML).entrySet())
+ {
+ if(entry instanceof Map.Entry)
+ {
+ values.put(String.valueOf(((Map.Entry) entry).getKey()),String.valueOf(((Map.Entry) entry).getValue()));
+ }
+ }
+ }
+
+ return values;
+ }
+}
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-11 12:25:25 UTC (rev 1273)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/KeyWords.java 2013-06-11 14:22:32 UTC (rev 1274)
@@ -6,6 +6,8 @@
* Time: 10:10
*/
public class KeyWords {
+ public static final String SEPARATOR = ".";
+
public static final String ABSTRACT = "abstract";
public static final String ASSOCIATION_CLASS = "associationclass";
public static final String ASSOCIATION_CLASS_NAME = "associationclassname";
@@ -13,6 +15,7 @@
public static final String ATTRIBUTE = "attribute";
public static final String BODY_CODE = "bodeycode";
public static final String CLASS = "class";
+ public static final String CLASSIFIER = "classifier";
public static final String COMMENTS = "comments";
public static final String DEFAULT_VALUE = "defaultvalue";
public static final String DOCUMENTATION = "documentation";
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 12:25:25 UTC (rev 1273)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadObjectModel.java 2013-06-11 14:22:32 UTC (rev 1274)
@@ -14,11 +14,13 @@
protected String packageL;
protected YamlObject modelYAMLO;
protected ObjectModelImpl modelOM;
+ protected Map<String,String> defaultValues;
- public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM) {
+ public LoadObjectModel(YamlObject modelYAMLO, ObjectModelImpl modelOM, Map<String,String> defaultValues) {
this.packageL = "default";
this.modelOM = modelOM;
this.modelYAMLO = modelYAMLO;
+ this.defaultValues = defaultValues;
//log
//Log.initLog(modelYAMLO.toString(),"/tmp/log.LoadObjectModel.txt");
//log
@@ -27,21 +29,33 @@
public void loadModel() {
String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
if (packageYAMLO == null) {
- //valeur par defaut
+ String key = PACKAGE;
+ if(defaultValues.containsKey(key))
+ {
+ packageL = defaultValues.get(key);
+ }
} else {
packageL = packageYAMLO;
}
String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
- ;//valeur par defaut
+ String key = NAME;
+ if(defaultValues.containsKey(key))
+ {
+ modelOM.setName(defaultValues.get(key));
+ }
} else {
modelOM.setName(nameYAMLO);
}
String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
if (versionYAMLO == null) {
- ;//valeur par defaut
+ String key = VERSION;
+ if(defaultValues.containsKey(key))
+ {
+ modelOM.setVersion(defaultValues.get(key));
+ }
} else {
modelOM.setVersion(versionYAMLO);
}
@@ -87,21 +101,33 @@
public void loadElement(YamlObject elementYAMLO, ObjectModelElementImpl elementOM) {
String nameYAMLO = elementYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
- ;//valeur par defaut
+ String key = ELEMENT+SEPARATOR+NAME;
+ if(defaultValues.containsKey(key))
+ {
+ elementOM.setName(defaultValues.get(key));
+ }
} else {
elementOM.setName(nameYAMLO);
}
String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
- ;//valeur par defaut
+ String key = ELEMENT+SEPARATOR+STATIC;
+ if(defaultValues.containsKey(key))
+ {
+ elementOM.setStatic(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
elementOM.setStatic(Boolean.valueOf(staticYAMLO));
}
String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
if (documentationYAMLO == null) {
- ;//valeur par defaut
+ String key = ELEMENT+SEPARATOR+DOCUMENTATION;
+ if(defaultValues.containsKey(key))
+ {
+ elementOM.setDocumentation(defaultValues.get(key));
+ }
} else {
elementOM.setDocumentation(documentationYAMLO);
}
@@ -122,6 +148,7 @@
elementOM.addComment(comment);
}
+ //TODO: ajouter setereotype par defaut
List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
for (String stereotype : stereotypes) {
ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
@@ -143,7 +170,11 @@
String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
if (externYAMLO == null) {
- ;//valeur par defaut
+ String key = CLASSIFIER+SEPARATOR+EXTERN;
+ if(defaultValues.containsKey(key))
+ {
+ classifierOM.setExtern(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
classifierOM.setExtern(Boolean.valueOf(externYAMLO));
@@ -151,14 +182,22 @@
String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
if (innerYAMLO == null) {
- ;//valeur par defaut
+ String key = CLASSIFIER+SEPARATOR+INNER;
+ if(defaultValues.containsKey(key))
+ {
+ classifierOM.setInner(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
classifierOM.setInner(Boolean.valueOf(innerYAMLO));
}
String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
- ;//valeur par defaut
+ String key = CLASSIFIER+SEPARATOR+TYPE;
+ if(defaultValues.containsKey(key))
+ {
+ classifierOM.setType(defaultValues.get(key));
+ }
} else {
classifierOM.setType(typeYAMLO);
}
@@ -188,7 +227,11 @@
String abstractYAMLO = classYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
- ;//valeur par defaut
+ String key = CLASS+SEPARATOR+ABSTRACT;
+ if(defaultValues.containsKey(key))
+ {
+ classOM.setAbstract(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
classOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
@@ -208,21 +251,30 @@
public void loadAssociationClass(YamlObject associationClassYAML, ObjectModelAssociationClassImpl associationClassOM) {
loadClass(associationClassYAML, associationClassOM);
- //TODO: remplacer name par type et attribute par name ?
+ //TODO: remplacer name par type et attribute par name ? -> confusion
+ //TODO: remplacer PARTICIPANT par PARTICIPANTS (List)
for (YamlObject participantYAMLO : associationClassYAML.getMapStringListYamlObject(PARTICIPANT)) {
ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
participantOM.setAssociationClass(associationClassOM);
String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
if (nameYAMLO == null) {
- ;//valeur par defaut
+ String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+NAME;
+ if(defaultValues.containsKey(key))
+ {
+ participantOM.setName(defaultValues.get(key));
+ }
} else {
participantOM.setName(nameYAMLO);
}
String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
if (attributeYAMLO == null) {
- ;//valeur par defaut
+ String key = ASSOCIATION_CLASS+SEPARATOR+PARTICIPANT+SEPARATOR+ATTRIBUTE;
+ if(defaultValues.containsKey(key))
+ {
+ participantOM.setAttribute(defaultValues.get(key));
+ }
} else {
participantOM.setAttribute(attributeYAMLO);
}
@@ -255,35 +307,55 @@
String orderingYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERING);
if (orderingYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+ORDERING;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setOrdering(defaultValues.get(key));
+ }
} else {
parameterOM.setOrdering(orderingYAMLO);
}
String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
if (typeYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+TYPE;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setType(defaultValues.get(key));
+ }
} else {
parameterOM.setType(typeYAMLO);
}
String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
if (defaultValueYAMLO == null) {
- ;//default
+ String key = PARAMETER+SEPARATOR+DEFAULT_VALUE;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setDefaultValue(defaultValues.get(key));
+ }
} else {
parameterOM.setDefaultValue(defaultValueYAMLO);
}
String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
if (minMultiplicityYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+MIN_MULTIPLICITY;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setMinMultiplicity(Integer.valueOf(defaultValues.get(key)));
+ }
} else {
parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
}
String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
if (maxMultiplicityYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+MAX_MULTIPLICITY;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setMaxMultiplicity(Integer.valueOf(defaultValues.get(key)));
+ }
} else {
parameterOM.setMaxMultiplicity(Integer.valueOf(maxMultiplicityYAMLO));
@@ -291,14 +363,22 @@
String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
if (orderedYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+ORDERED;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setOrdered(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
}
String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
if (uniqueYAMLO == null) {
- ;//valeur par defaut
+ String key = PARAMETER+SEPARATOR+UNIQUE;
+ if(defaultValues.containsKey(key))
+ {
+ parameterOM.setUnique(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
parameterOM.setUnique(Boolean.valueOf(uniqueYAMLO));
}
@@ -309,65 +389,99 @@
String navigableYAMLO = attributeYAMLO.getFirstMapStringListString(NAVIGABLE);
if (navigableYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+NAVIGABLE;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setNavigable(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
attributeOM.setNavigable(Boolean.valueOf(navigableYAMLO));
}
String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
if (associationTypeYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_TYPE;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setAssociationType(defaultValues.get(key));
+ }
} else {
attributeOM.setAssociationType(associationTypeYAMLO);
}
String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
if (finalYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+FINAL;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setFinal(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
}
String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
if (staticYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+STATIC;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setStatic(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
}
String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
if (associationClassNameYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+ASSOCIATION_CLASS_NAME;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setAssociationClassName(defaultValues.get(key));
+ }
} else {
attributeOM.setAssociationClassName(associationClassNameYAMLO);
}
String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
if (reverseAttributeNameYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+REVERSE_ATTRIBUTE_NAME;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setReverseAttributeName(defaultValues.get(key));
+ }
} else {
attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
}
String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
if (reverseMaxMultiplicityYAMLO == null) {
- //test
- attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
- //test
+ String key = ATTRIBUTE+SEPARATOR+REVERSE_MAX_MULTIPLICITY;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setReverseMaxMultiplicity(Integer.valueOf(defaultValues.get(key)));
+ }
} else {
attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
}
String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
if (transientYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+TRANSIENT;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setTransient(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
}
String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
- ;//valeur par defaut
+ String key = ATTRIBUTE+SEPARATOR+VISIBILITY;
+ if(defaultValues.containsKey(key))
+ {
+ attributeOM.setVisibility(defaultValues.get(key));
+ }
} else {
attributeOM.setVisibility(visibilityYAMLO);
}
@@ -378,14 +492,22 @@
String abstractYAMLO = operationYAMLO.getFirstMapStringListString(ABSTRACT);
if (abstractYAMLO == null) {
- ;//valeur par defaut
+ String key = OPERATION+SEPARATOR+ABSTRACT;
+ if(defaultValues.containsKey(key))
+ {
+ operationOM.setAbstract(Boolean.valueOf(defaultValues.get(key)));
+ }
} else {
operationOM.setAbstract(Boolean.valueOf(abstractYAMLO));
}
String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
if (visibilityYAMLO == null) {
- ;//valeur par defaut
+ String key = OPERATION+SEPARATOR+VISIBILITY;
+ if(defaultValues.containsKey(key))
+ {
+ operationOM.setVisibility(defaultValues.get(key));
+ }
} else {
operationOM.setVisibility(visibilityYAMLO);
}
@@ -404,7 +526,11 @@
String bodyCodeYAMLO = operationYAMLO.getFirstMapStringListString(BODY_CODE);
if (bodyCodeYAMLO == null) {
- ;//valeur par defaut
+ String key = OPERATION+SEPARATOR+BODY_CODE;
+ if(defaultValues.containsKey(key))
+ {
+ operationOM.setBodyCode(defaultValues.get(key));
+ }
} 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 12:25:25 UTC (rev 1273)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/LoadYamlFile.java 2013-06-11 14:22:32 UTC (rev 1274)
@@ -58,7 +58,7 @@
;//impossible de charger le modele
}
- LoadObjectModel loader = new LoadObjectModel(modelYAMLO, modelOM);//+defaultVersion
+ LoadObjectModel loader = new LoadObjectModel(modelYAMLO, modelOM, DefaultValues.getDefaultValues(defaultVersion));//sortir getDefaultValues ?
loader.loadModel();
}
}
1
0
r1273 - 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:25:25 +0200 (Tue, 11 Jun 2013)
New Revision: 1273
Url: http://nuiton.org/projects/eugene/repository/revisions/1273
Log:
suppression des classes Deprecated de org.nuiton.eugene.models.object.reader.yaml.*
Removed:
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
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
Deleted: 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 12:16:35 UTC (rev 1272)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/Parser.java 2013-06-11 12:25:25 UTC (rev 1273)
@@ -1,1010 +0,0 @@
-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
- * <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)
- */
-@Deprecated
-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 ?
- {
- //
-
- /*
- 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));
- }
-
- //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) {
- 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 !
- */
- }
-
- 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(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));
- }
-
- 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
- {
- 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);
- }
- }*/
- //name: type ?
- 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)//defaultValue
- {
- //attributeYAMLO.addStringToMap(DEFAULT_VALUE,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) ? name: 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));
- }
-
- 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);
- }
- }
- //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) {
- //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.containsKeyYamlMapStringListYamlObject(PARTICIPANT)) {
- 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));
- }
- }
- }
- }
- }
- }
-
- //OK
- 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<>
- {
- 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 variable global
- 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));
- }
- }
- } 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)));
- 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));
- }
- //test
- 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);
- }
- }
- //test
- reverseObject.addYamlObjectToMap(ATTRIBUTE, reverseAttribute);
-
- attribute.addStringToMap(NAVIGABLE, String.valueOf(true));
- }
- }
- }
- } else//simple attribut
- {
- ;//ou gerer par valeurs par defaut ?
- //associationType="composite"//default eugene
- //minMultiplicity="1"//default eugene
- //maxMultiplicity="1"//default eugene
- }
- }
- }
- }
- 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");
- //tester package
- reverseAttribute.addStringToMap(ASSOCIATION_CLASS_NAME, modelYAMLO.getFirstMapStringListString(PACKAGE) + "." + labelisable.getFirstMapStringListString(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)) {
- 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);
- }*/
- }
-}
Deleted: 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 12:16:35 UTC (rev 1272)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadObjectModel.java 2013-06-11 12:25:25 UTC (rev 1273)
@@ -1,485 +0,0 @@
-package org.nuiton.eugene.models.object.reader.yaml;
-
-import org.nuiton.eugene.models.object.xml.*;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-/**
- * User: agiraudet
- * Date: 30/05/13
- * Time: 11:58
- */
-@Deprecated
-public class TestLoadObjectModel extends KeyWords {
- List<String> imports;
- String packageL;//package local
-
- private boolean _loginit = true;
-
- private void log(String str) {
- try {
- FileWriter log;
- String path = "/tmp/log.yamlobject.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) {
- ;
- }
- }
-
- //precondition: labels et imports resolus
- //TODO: valeurs par defaut
- public TestLoadObjectModel(/*YamlObject modelYAMLO, ObjectModelImpl modelOM*/) {
- ;//loadModel(modelYAMLO,modelOM);
- }
-
- public void loadModel(YamlObject modelYAMLO, ObjectModelImpl modelOM) {
-
- //log
- log(modelYAMLO.toString());
- log(" MODEL");
- //log
-
- String packageYAMLO = modelYAMLO.getFirstMapStringListString(PACKAGE);
- if (packageYAMLO == null) {
- packageL = "";
- } else {
- packageL = packageYAMLO;
- }
- log("package=" + packageL);
-
- String nameYAMLO = modelYAMLO.getFirstMapStringListString(NAME);
- if (nameYAMLO == null) {
- ;//valeur par defaut
- } else {
- modelOM.setName(nameYAMLO);
- log("name=" + modelOM.getName());
- }
-
- String versionYAMLO = modelYAMLO.getFirstMapStringListString(VERSION);
- if (versionYAMLO == null) {
- ;//valeur par defaut
- } else {
- modelOM.setVersion(versionYAMLO);
- 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
- {
- modelOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
- }
- }
- log("tagValues=" + modelOM.getTagValues());
- }
-
- //classes
- for (YamlObject classYAMLO : modelYAMLO.getMapStringListYamlObject(CLASS)) {
- log(" CLASS");
- ObjectModelClassImpl classOM = new ObjectModelClassImpl();
- loadClass(classYAMLO, classOM);
- modelOM.addClass(classOM);
- }
- //interfaces
- for (YamlObject interfaceYAMLO : modelYAMLO.getMapStringListYamlObject(INTERFACE)) {
- log(" INTERFACE");
- ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
- loadInterface(interfaceYAMLO, interfaceOM);
- modelOM.addInterface(interfaceOM);
- }
- //classes d'association
- for (YamlObject associationClassYAMLO : modelYAMLO.getMapStringListYamlObject(ASSOCIATION_CLASS)) {
- log(" ASSOCIATION_CLASS");
- ObjectModelAssociationClassImpl associationClassOM = new ObjectModelAssociationClassImpl();
- loadAssociationClass(associationClassYAMLO, associationClassOM);
- modelOM.addAssociationClass(associationClassOM);
- }
- //enumerations
- for (YamlObject enumerationYAMLO : modelYAMLO.getMapStringListYamlObject(ENUMERATION)) {
- log(" 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);
- log("name=" + elementOM.getName());
- }
-
- String staticYAMLO = elementYAMLO.getFirstMapStringListString(STATIC);
- if (staticYAMLO == null) {
- ;//valeur par defaut
- } else {
- elementOM.setStatic(Boolean.valueOf(staticYAMLO));
- log("static=" + elementOM.isStatic());
- }
-
- String documentationYAMLO = elementYAMLO.getFirstMapStringListString(DOCUMENTATION);
- if (documentationYAMLO == null) {
- ;//valeur par defaut
- } else {
- elementOM.setDocumentation(documentationYAMLO);
- 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
- {
- elementOM.addTagValue(tagValue.getKey(), tagValue.getValue().get(0));
- }
- }
- log("tagValues=" + elementOM.getTagValues());
- }
-
- List<String> comments = elementYAMLO.getMapStringListString(COMMENTS);
- for (String comment : comments) {
- elementOM.addComment(comment);
- log("comments=" + elementOM.getComments());
- }
-
- List<String> stereotypes = elementYAMLO.getMapStringListString(STEREOTYPES);
- for (String stereotype : stereotypes) {
- ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
- stereotypeOM.setName(stereotype);
- elementOM.addStereotype(stereotypeOM);
- log("stereotype=" + elementOM.getStereotypes());
- }
- }
-
- public void loadClassifier(YamlObject classifierYAMLO, ObjectModelClassifierImpl classifierOM) {
- loadElement(classifierYAMLO, classifierOM);
-
- String packageYAMLO = classifierYAMLO.getFirstMapStringListString(PACKAGE);
- if (packageYAMLO == null) {
- //TODO: tester packageL == null
- classifierOM.setPackage(packageL);
- } else {
- classifierOM.setPackage(packageYAMLO);
- }
- log("package=" + classifierOM.getPackageName());
-
-
- String externYAMLO = classifierYAMLO.getFirstMapStringListString(EXTERN);
- if (externYAMLO == null) {
- ;//valeur par defaut
- } else {
- classifierOM.setExtern(Boolean.valueOf(externYAMLO));
- log("extern=" + classifierOM.isExtern());
-
- }
-
- String innerYAMLO = classifierYAMLO.getFirstMapStringListString(INNER);
- if (innerYAMLO == null) {
- ;//valeur par defaut
- } else {
- classifierOM.setInner(Boolean.valueOf(innerYAMLO));
- log("inner=" + classifierOM.isInner());
- }
-
- String typeYAMLO = classifierYAMLO.getFirstMapStringListString(TYPE);
- if (typeYAMLO == null) {
- ;//valeur par defaut
- } else {
- classifierOM.setType(typeYAMLO);
- log("type=" + typeYAMLO);//getType ?
- }
-
- for (YamlObject attributeYAMLO : classifierYAMLO.getMapStringListYamlObject(ATTRIBUTE)) {
- log(" ATTRIBUTE");
- ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
- loadAttribute(attributeYAMLO, attributeOM);
- classifierOM.addAttribute(attributeOM);
- }
-
- for (YamlObject operationYAMLO : classifierYAMLO.getMapStringListYamlObject(OPERATION)) {
- log(" 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);
- log("superInterface=" + superInterfaceYAMLO);
- }
- }
-
- 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));
- log("abstract=" + classOM.isAbstract());
- }
-
- List<String> superClassesYAMLO = classYAMLO.getMapStringListString(SUPER_CLASSES);
- for (String superClassYAMLO : superClassesYAMLO) {
- ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
- superClassOM.setName(superClassYAMLO);
- classOM.addSuperclass(superClassOM);
- log("superClasses=" + superClassYAMLO);
- }
- }
-
- 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)) {
- log(" PARTICIPANT");
- ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
- participantOM.setAssociationClass(associationClassOM);
-
- String nameYAMLO = participantYAMLO.getFirstMapStringListString(NAME);
- if (nameYAMLO == null) {
- ;//valeur par defaut
- } else {
- participantOM.setName(nameYAMLO);
- log("name=" + participantOM.getName());
- }
-
- String attributeYAMLO = participantYAMLO.getFirstMapStringListString(ATTRIBUTE);
- if (attributeYAMLO == null) {
- ;//valeur par defaut
- } else {
- participantOM.setAttribute(attributeYAMLO);
- log("attribute=" + participantOM.getAttributeName());
- }
-
- 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);
- log("literals=" + enumerationOM.getLiterals());
- }
-
- String packageYAMLO = enumerationYAMLO.getFirstMapStringListString(PACKAGE);
- if (packageYAMLO == null) {
- enumerationOM.setPackage(packageL);
- } else {
- enumerationOM.setPackage(packageYAMLO);
- }
- log("package=" + enumerationOM.getPackageName());
- }
-
- 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);
- log("ordering=" + orderingYAMLO);//getOrdering ?
- }
-
- String typeYAMLO = parameterYAMLO.getFirstMapStringListString(TYPE);
- if (typeYAMLO == null) {
- ;//valeur par defaut
- } else {
- parameterOM.setType(typeYAMLO);
- log("type=" + parameterOM.getType());
- }
-
- String defaultValueYAMLO = parameterYAMLO.getFirstMapStringListString(DEFAULT_VALUE);
- if (defaultValueYAMLO == null) {
- ;//default
- } else {
- parameterOM.setDefaultValue(defaultValueYAMLO);
- log("defaultValue=" + parameterOM.getDefaultValue());
- }
-
- String minMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MIN_MULTIPLICITY);
- if (minMultiplicityYAMLO == null) {
- ;//valeur par defaut
- } else {
- parameterOM.setMinMultiplicity(Integer.valueOf(minMultiplicityYAMLO));
- log("minMultiplicity=" + parameterOM.getMinMultiplicity());
- }
-
- String maxMultiplicityYAMLO = parameterYAMLO.getFirstMapStringListString(MAX_MULTIPLICITY);
- if (maxMultiplicityYAMLO == null) {
- ;//valeur par defaut
- } else {
- parameterOM.setMaxMultiplicity(Integer.valueOf(maxMultiplicityYAMLO));
- log("maxMultiplicity=" + parameterOM.getMaxMultiplicity());
-
- }
-
- String orderedYAMLO = parameterYAMLO.getFirstMapStringListString(ORDERED);
- if (orderedYAMLO == null) {
- ;//valeur par defaut
- } else {
- parameterOM.setOrdered(Boolean.valueOf(orderedYAMLO));
- log("ordered=" + parameterOM.isOrdered());
- }
-
- String uniqueYAMLO = parameterYAMLO.getFirstMapStringListString(UNIQUE);
- if (uniqueYAMLO == null) {
- ;//valeur par defaut
- } else {
- parameterOM.setUnique(Boolean.valueOf(uniqueYAMLO));
- log("unique=" + parameterOM.isUnique());
- }
- }
-
- 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));
- log("navigable=" + attributeOM.isNavigable());
- }
-
- String associationTypeYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_TYPE);
- if (associationTypeYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setAssociationType(associationTypeYAMLO);
- log("associationType=" + associationTypeYAMLO);//getAssociationType ?
- }
-
- String finalYAMLO = attributeYAMLO.getFirstMapStringListString(FINAL);
- if (finalYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setFinal(Boolean.valueOf(finalYAMLO));
- log("final=" + attributeOM.isFinal());
- }
-
- String staticYAMLO = attributeYAMLO.getFirstMapStringListString(STATIC);
- if (staticYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setStatic(Boolean.valueOf(staticYAMLO));
- log("static=" + attributeOM.isStatic());
- }
-
- String associationClassNameYAMLO = attributeYAMLO.getFirstMapStringListString(ASSOCIATION_CLASS_NAME);
- if (associationClassNameYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setAssociationClassName(associationClassNameYAMLO);
- log("associationClassName=" + associationClassNameYAMLO);
- }
-
- String reverseAttributeNameYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_ATTRIBUTE_NAME);
- if (reverseAttributeNameYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setReverseAttributeName(reverseAttributeNameYAMLO);
- log("reverseAttributeName=" + attributeOM.getReverseAttributeName());
- }
-
- String reverseMaxMultiplicityYAMLO = attributeYAMLO.getFirstMapStringListString(REVERSE_MAX_MULTIPLICITY);
- if (reverseMaxMultiplicityYAMLO == null) {
- //test
- attributeOM.setReverseMaxMultiplicity(1);//valeur par defaut
- //test
- } else {
- attributeOM.setReverseMaxMultiplicity(Integer.valueOf(reverseMaxMultiplicityYAMLO));
- log("reverseMaxMultiplicity=" + attributeOM.getReverseMaxMultiplicity());
- }
-
- String transientYAMLO = attributeYAMLO.getFirstMapStringListString(TRANSIENT);
- if (transientYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setTransient(Boolean.valueOf(transientYAMLO));
- log("transient=" + attributeOM.isTransient());
- }
-
- String visibilityYAMLO = attributeYAMLO.getFirstMapStringListString(VISIBILITY);
- if (visibilityYAMLO == null) {
- ;//valeur par defaut
- } else {
- attributeOM.setVisibility(visibilityYAMLO);
- log("visibility=" + attributeOM.getVisibility());
- }
- }
-
- 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));
- log("abstract=" + operationOM.isAbstract());
- }
-
- String visibilityYAMLO = operationYAMLO.getFirstMapStringListString(VISIBILITY);
- if (visibilityYAMLO == null) {
- ;//valeur par defaut
- } else {
- operationOM.setVisibility(visibilityYAMLO);
- log("visibility=" + operationOM.getVisibility());
- }
-
- for (YamlObject returnParameterYAMLO : operationYAMLO.getMapStringListYamlObject(RETURN_PARAMETER)) {
- log(" RETURN_PARAMETER");
- ObjectModelParameterImpl returnParameterOM = new ObjectModelAttributeImpl();
- loadParameter(returnParameterYAMLO, returnParameterOM);
- operationOM.setReturnParameter(returnParameterOM);
- }
-
- for (YamlObject parameterYAMLO : operationYAMLO.getMapStringListYamlObject(PARAMETER)) {
- log(" 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);
- log("bodyCode=" + operationOM.getBodyCode());
- }
- }
-}
Deleted: 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 12:16:35 UTC (rev 1272)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/TestLoadYamlFile.java 2013-06-11 12:25:25 UTC (rev 1273)
@@ -1,105 +0,0 @@
-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.*;
-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
- */
-@Deprecated
-public class TestLoadYamlFile extends KeyWords {
- Yaml yaml;
- ObjectModelImpl modelOM;
- YamlObject modelYAMLO;
- Object modelYAML;
- 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();
- }
-
- public void LoadYamlFile(File fileYAML, ObjectModel model) throws IOException {
- modelOM = (ObjectModelImpl) model;
- modelYAMLO = new YamlObject();
- InputStream inputModel = new FileInputStream(fileYAML);
- modelYAML = yaml.load(inputModel);
- inputModel.close();
-
- //chercher version et charger en conséquent
- Object version = null;
- if (modelYAML instanceof List) {
- 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.loadYamlObject(modelYAML, modelYAMLO);
- log("load SyntaxePureYaml");
- } 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 {
- ;//syntaxe par defaut, si version syntaxe non reconnue
- 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)
- }
-}
Deleted: 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 12:16:35 UTC (rev 1272)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/reader/yaml/YamlToObjectModel.java 2013-06-11 12:25:25 UTC (rev 1273)
@@ -1,670 +0,0 @@
-package org.nuiton.eugene.models.object.reader.yaml;
-
-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.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;
-
-/**
- * User: agiraudet
- * Date: 15/05/13
- * Time: 11:15
- */
-@Deprecated
-public class YamlToObjectModel {
- protected Yaml yaml;
- protected String packageOM;
- protected Map<String, String> imports;
- protected Map<String, String> defaultValues;
-
- //mots clefs
- public static final String ABSTRACT = "abstract";
- public static final String ASSOCIATION_CLASS_NAME = "associationclassname";
- public static final String ASSOCIATION_TYPE = "associationtype";
- public static final String ATTRIBUTE = "attribute";
- public static final String BODY_CODE = "bodeycode";
- public static final String CLASS = "class";
- public static final String CLASS_ASSOCIATION = "associationclass";
- public static final String COMMENTS = "comments";
- public static final String DEFAULT_VALUE = "defaultvalue";
- public static final String DOCUMENTATION = "documentation";
- public static final String ENUMERATION = "enumeration";
- public static final String EXTERN = "extern";
- public static final String FINAL = "final";
- public static final String IMPORTS = "imports";
- public static final String INNER = "inner";
- public static final String INTERFACE = "interface";
- public static final String LITERAL = "literal";
- public static final String MAX_MULTIPLICITY = "maxmultiplicity";
- public static final String MIN_MULTIPLICITY = "minmultiplicity";
- public static final String NAME = "name";
- public static final String NAVIGABLE = "navigable";
- public static final String OPERATION = "operation";
- public static final String ORDERED = "ordered";
- public static final String ORDERING = "ordering";
- public static final String PACKAGE = "package";
- public static final String PARAMETER = "parameter";
- public static final String PARTICIPANT = "participant";
- public static final String RETURN_PARAMETER = "returnparameter";
- public static final String REVERSE_ATTRIBUTE_NAME = "reverseattributename";
- public static final String REVERSE_MAX_MULTIPLICITY = "reversemaxmultiplicity";
- public static final String STATIC = "static";
- public static final String STEREOTYPES = "stereotypes";
- public static final String SUPER_CLASSES = "superclasses";
- public static final String SUPER_INTERFACES = "superinterfaces";
- public static final String TAG_VALUES = "tagvalues";
- public static final String TRANSIENT = "transient";
- public static final String TYPE = "type";
- public static final String UNIQUE = "unique";
- public static final String VERSION = "version";
- public static final String VISIBILITY = "visibility";
- public static final String ELEMENT = "element";
-
- private boolean _loginit = true;
-
- private void log(String str) {
- try {
- FileWriter log;
- String path = "/tmp/log.yaml.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 YamlToObjectModel() {
- yaml = new Yaml();
- }
-
- //TODO: gestion des labels ? -> non pas pour le moment (plutot pour la syntaxe "user friendly")
- //TODO: retourner boolean sur reussite chargement ? ou lever excpetions ? -> aucun des deux pour le moment
- //TODO: charger valeurs par defaut en fonction de la version de la syntaxe yaml (syntaxe: version), charger les valeurs à partir d'un fichier ou d'une classe ? -> a partir d'un fichier YAML
- //TODO: mettre les valeurs par défaut en dur dans le code
- //TODOK: gérer les imports sous forme de List et récuperer le type
- //TODO: pre-charger les noms et paquetages des classes pour les imports
- //TODO: 1/ instancier les objets et les attributs de niveau 1 (name, package...) (et charger les imports vers les classes du modele) 2/ charger les objets de niveau 2 (attributes, operations...)
- /*
- * nouvelle implémentation : contraintes : labels, valeurs par défaut, parser des chaines (imports internes/externes)
- *
- */
- //http://demo.codelutin.com/pollen/poll/summary/23f361a09411482eb6be219ddf4ab5dc:bf4068a19c27436c844980c2f095e079
- public void loadFile(File file, ObjectModel model) throws IOException {
- //TODO: valeurs par defaut, faire interface ? ou simple map ? + mots clefs ?
- defaultValues = new LinkedHashMap<String, String>();
-
- ObjectModelImpl modelOM = (ObjectModelImpl) model;
- InputStream inputModel = new FileInputStream(file);
- Object modelYAML = yaml.load(inputModel);
- inputModel.close();
-
- List<String> ignore = new LinkedList<String>();
- ignore.add(TAG_VALUES);
- browseKeySetToLowerCase(modelYAML, ignore);
-
- loadModel(modelYAML, modelOM);
- }
-
- public Object collectElement(List data, Object key) {
- for (Object obj : data) {
- if (obj instanceof Map) {
- if (((Map) obj).containsKey(key)) {
- return ((Map) obj).get(key);
- }
- }
- }
- return null;
- }
-
- public List<Object> collectAllElements(List data, Object key) {
- List<Object> res = new LinkedList<Object>();
- for (Object obj : data) {
- if (obj instanceof Map) {
- if (((Map) obj).containsKey(key)) {
- res.add(((Map) obj).get(key));
- }
- }
- }
- return res;
- }
-
- public void loadModel(Object modelYAML, ObjectModelImpl modelOM) {
- if (modelYAML instanceof List) {
- //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));
- }
- }
-
- //load package
- Object packageYAML = collectElement((List) modelYAML, PACKAGE);
- if (packageYAML == null) {
- packageOM = "";
- } else {
- packageOM = String.valueOf(packageYAML);
- }
- log("package=" + packageOM);
-
- Object nameYAML = collectElement((List) modelYAML, NAME);
- if (nameYAML == null) {
- ;
- } else {
- modelOM.setName(String.valueOf(nameYAML));
- log("name=" + String.valueOf(nameYAML));
- }
-
- Object versionYAML = collectElement((List) modelYAML, VERSION);
- if (versionYAML == null) {
- ;
- } else {
- modelOM.setVersion(String.valueOf(versionYAML));
- log("version=" + String.valueOf(versionYAML));
- }
-
- Object tagValuesYAML = collectElement((List) modelYAML, TAG_VALUES);
- if (tagValuesYAML instanceof Map) {
- 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()) + "]");
- }
- }
- }
-
- /*//test imports objets modele
- /*List<Object> objectsYAML = collectAllElements((List) modelYAML, CLASS);
- objectsYAML.addAll(collectAllElements((List) modelYAML, INTERFACE));
- objectsYAML.addAll(collectAllElements((List) modelYAML, CLASS_ASSOCIATION));
- objectsYAML.addAll(collectAllElements((List) modelYAML, ENUMERATION));
- for(Object objectYAML : objectsYAML)
- {
- if(objectYAML instanceof List)
- {
- Object importNameYAML = collectElement((List) objectYAML, NAME);
- //Object importPackageYAML = collectElement((List) objectYAML, PACKAGE);
- imports.put(String.valueOf(importNameYAML),packageOM+"."+String.valueOf(importNameYAML));
- log("import="+imports.get(String.valueOf(importNameYAML)));
- log(imports.toString());
- }
- }
- *///test imports objets modele
-
- List classesYAML = collectAllElements((List) modelYAML, CLASS);
- for (Object classYAML : classesYAML) {
- ObjectModelClassImpl classOM = new ObjectModelClassImpl();
- loadClass(classYAML, classOM);
- modelOM.addClass(classOM);
- log("class=" + classOM.getName() + " loaded");
- }
-
- List interfacesYAML = collectAllElements((List) modelYAML, INTERFACE);
- for (Object interfaceYAML : interfacesYAML) {
- ObjectModelInterfaceImpl interfaceOM = new ObjectModelInterfaceImpl();
- loadInterface(interfaceYAML, interfaceOM);
- modelOM.addInterface(interfaceOM);
- log("interface=" + interfaceOM.getName() + " loaded");
- }
-
- List classesAssociationYAML = collectAllElements((List) modelYAML, CLASS_ASSOCIATION);
- for (Object classAssociationYAML : classesAssociationYAML) {
- ObjectModelAssociationClassImpl classAssociationOM = new ObjectModelAssociationClassImpl();
- loadAssociationClass(classAssociationYAML, classAssociationOM);
- modelOM.addAssociationClass(classAssociationOM);
- log("classAssociation=" + classAssociationOM.getName() + " loaded");
- }
-
- List enumerationsYAML = collectAllElements((List) modelYAML, ENUMERATION);
- for (Object enumerationYAML : enumerationsYAML) {
- ObjectModelEnumerationImpl enumerationOM = new ObjectModelEnumerationImpl();
- loadEnumeration(enumerationYAML, enumerationOM);
- modelOM.addEnumeration(enumerationOM);
- log("enumeration=" + enumerationOM.getName() + " loaded");
- }
- }
- }
-
- public void loadElement(Object elementYAML, ObjectModelElementImpl elementOM) {
- if (elementYAML instanceof List) {
- //TODO: setDeclaringElement
- //TODO: setObjectModelImpl
- //TODO: addModifier
-
- Object nameYAML = collectElement((List) elementYAML, NAME);
- if (nameYAML == null) {
- ;
- } else {
- elementOM.setName(String.valueOf(nameYAML));
- log("name=" + String.valueOf(nameYAML));
- }
-
- Object staticYAML = collectElement((List) elementYAML, STATIC);
- if (staticYAML == null) {
- ;
- } else {
- elementOM.setStatic(Boolean.valueOf(String.valueOf(staticYAML)));
- log("static=" + (Boolean.valueOf(String.valueOf(staticYAML))));
- }
-
- Object documentationYAML = collectElement((List) elementYAML, DOCUMENTATION);
- if (documentationYAML == null) {
- ;
- } else {
- elementOM.setDocumentation(String.valueOf(documentationYAML));
- log("documentation=" + String.valueOf(documentationYAML));
- }
-
- Object tagValuesYAML = collectElement((List) elementYAML, TAG_VALUES);
- if (tagValuesYAML instanceof Map) {
- 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()) + "]");
- }
- }
- }
-
- Object commentsYAML = collectElement((List) elementYAML, COMMENTS);
- if (commentsYAML instanceof List) {
- for (Object comment : (List) commentsYAML) {
- elementOM.addComment(String.valueOf(comment));
- log("comment=" + String.valueOf(comment));
- }
- }
-
- Object stereotypesYAML = collectElement((List) elementYAML, STEREOTYPES);
- {
- if (stereotypesYAML instanceof List) {
- for (Object stereotype : (List) stereotypesYAML) {
- ObjectModelImplRef stereotypeOM = new ObjectModelImplRef();
- stereotypeOM.setName(String.valueOf(stereotype));
- elementOM.addStereotype(stereotypeOM);
- log("stereotype=" + String.valueOf(stereotype));
- }
- }
- }
- }
- }
-
- public void loadClassifier(Object classifierYAML, ObjectModelClassifierImpl classifierOM) {
- if (classifierYAML instanceof List) {
- //TODO: addDependency
-
- loadElement(classifierYAML, classifierOM);
-
- Object packageYAML = collectElement((List) classifierYAML, PACKAGE);
- if (packageYAML == null) {
- classifierOM.setPackage(packageOM);
- } else {
- classifierOM.setPackage(String.valueOf(packageYAML));
- log("package=" + String.valueOf(packageYAML));
- }
-
- Object externYAML = collectElement((List) classifierYAML, EXTERN);
- if (externYAML == null) {
- ;
- } else {
- classifierOM.setExtern(Boolean.valueOf(String.valueOf(externYAML)));
- log("extern=" + String.valueOf(externYAML));
- }
-
- Object innerYAML = collectElement((List) classifierYAML, INNER);
- if (innerYAML == null) {
- ;
- } else {
- classifierOM.setInner(Boolean.valueOf(String.valueOf(innerYAML)));
- log("inner=" + String.valueOf(innerYAML));
- }
-
- Object typeYAML = collectElement((List) classifierYAML, TYPE);
- if (typeYAML == null) {
- ;
- } else {
- classifierOM.setType(String.valueOf(typeYAML));
- log("type=" + String.valueOf(typeYAML));
- }
-
- List attributesYAML = collectAllElements((List) classifierYAML, ATTRIBUTE);
- for (Object attributeYAML : attributesYAML) {
- ObjectModelAttributeImpl attributeOM = new ObjectModelAttributeImpl();
- loadAttribute(attributeYAML, attributeOM);
- classifierOM.addAttribute(attributeOM);
- log("attribute=" + attributeOM.getType() + " loaded");
- }
-
- List operationsYAML = collectAllElements((List) classifierYAML, OPERATION);
- for (Object operationYAML : operationsYAML) {
- ObjectModelOperationImpl operationOM = new ObjectModelOperationImpl();
- loadOperation(operationYAML, operationOM);
- classifierOM.addOperation(operationOM);
- log("operation=" + operationOM.getName() + " loaded");
- }
-
- Object superInterfacesYAML = collectElement((List) classifierYAML, SUPER_INTERFACES);
- if (superInterfacesYAML instanceof List) {
- for (Object superInterface : (List) superInterfacesYAML) {
- ObjectModelImplRef superInterfaceOM = new ObjectModelImplRef();
- superInterfaceOM.setName(String.valueOf(superInterface));
- classifierOM.addInterface(superInterfaceOM);
- log("superInterface=" + String.valueOf(superInterface));
- }
- }
- }
- }
-
- public void loadClass(Object classYAML, ObjectModelClassImpl classOM) {
- if (classYAML instanceof List) {
- //TODO: addInnerClassifier
-
- loadClassifier(classYAML, classOM);
-
- Object abstractYAML = collectElement((List) classYAML, ABSTRACT);
- if (abstractYAML == null) {
- ;
- } else {
- classOM.setAbstract(Boolean.valueOf(String.valueOf(abstractYAML)));
- log("abstract=" + String.valueOf(abstractYAML));
- }
-
- Object superClassesYAML = collectElement((List) classYAML, SUPER_CLASSES);
- if (superClassesYAML instanceof List) {
- for (Object superClass : (List) superClassesYAML) {
- ObjectModelImplSuperClassRef superClassOM = new ObjectModelImplSuperClassRef();
- //ObjectModelImplRef superClassOM = new ObjectModelImplRef();
- superClassOM.setName(String.valueOf(superClass));
- classOM.addSuperclass(superClassOM);
- log("superClass=" + String.valueOf(superClass));
- }
- }
- }
- }
-
- public void loadInterface(Object interfaceYAML, ObjectModelInterfaceImpl interfaceOM) {
- if (interfaceYAML instanceof List) {
- loadClassifier(interfaceYAML, interfaceOM);
- }
- }
-
- //TODO: gerer participants sous forme de liste -ou pas ? "attribute" utile ?-
- public void loadAssociationClass(Object associationClassYAML, ObjectModelAssociationClassImpl associationClassOM) {
- if (associationClassYAML instanceof List) {
- loadClass(associationClassYAML, associationClassOM);
-
- List participantsYAML = collectAllElements((List) associationClassYAML, PARTICIPANT);
- for (Object participantYAML : participantsYAML) {
- if (participantYAML instanceof List) {
-
- ObjectModeImplAssociationClassParticipant participantOM = new ObjectModeImplAssociationClassParticipant();
- participantOM.setAssociationClass(associationClassOM);
-
- //le nom de la classe sans oublier la package devant
- Object nameYAML = collectElement((List) participantYAML, NAME);
- if (nameYAML == null) {
- ;
- } else {
- String name = String.valueOf(nameYAML);
- if (imports.containsKey(name)) {
- participantOM.setName(imports.get(name));
- } else {
- participantOM.setName(name);
- }
- log("name=" + name);
- }
-
- Object attributeYAML = collectElement((List) participantYAML, ATTRIBUTE);
- if (attributeYAML == null) {
- ;
- } else {
- participantOM.setAttribute(String.valueOf(attributeYAML));
- log("attribute=" + String.valueOf(attributeYAML));
- }
- log("participant=" + String.valueOf(nameYAML) + " loaded");
- associationClassOM.addParticipant(participantOM);
- }
- }
- }
- }
-
- public void loadEnumeration(Object enumerationYAML, ObjectModelEnumerationImpl enumerationOM) {
- if (enumerationYAML instanceof List) {
- loadElement(enumerationYAML, enumerationOM);
-
- Object literalsYAML = collectElement((List) enumerationYAML, LITERAL);
- if (literalsYAML instanceof List) {
- for (Object literalYAML : (List) literalsYAML) {
- ObjectModelImplRef literalOM = new ObjectModelImplRef();
- literalOM.setName(String.valueOf(literalYAML));
- enumerationOM.addLiteral(literalOM);
- log("literal=" + String.valueOf(literalsYAML));
- }
- }
-
- Object packageYAML = collectElement((List) enumerationYAML, PACKAGE);
- if (packageYAML == null) {
- enumerationOM.setPackage(packageOM);
- } else {
- enumerationOM.setPackage(String.valueOf(packageYAML));
- log("package=" + String.valueOf(packageYAML));
- }
- }
- }
-
- public void loadParameter(Object parameterYAML, ObjectModelParameterImpl parameterOM) {
- if (parameterYAML instanceof List) {
- loadElement(parameterYAML, parameterOM);
-
- Object orderingYAML = collectElement((List) parameterYAML, ORDERING);
- if (orderingYAML == null) {
- ;
- } else {
- parameterOM.setOrdering(String.valueOf(orderingYAML));
- log("ordering=" + String.valueOf(orderingYAML));
- }
-
- Object typeYAML = collectElement((List) parameterYAML, TYPE);
- if (typeYAML == null) {
- ;//lever exception
- } else {
- String type = String.valueOf(typeYAML);
- if (imports.containsKey(type)) {
- parameterOM.setType(imports.get(type));
- } else {
- parameterOM.setType(type);
- }
- log("type=" + parameterOM.getType());
- }
-
- Object defaultValueYAML = collectElement((List) parameterYAML, DEFAULT_VALUE);
- if (defaultValueYAML == null) {
- ;
- } else {
- parameterOM.setDefaultValue(String.valueOf(defaultValueYAML));
- log("defaultValue=" + String.valueOf(defaultValueYAML));
- }
-
- Object minMultiplicityYAML = collectElement((List) parameterYAML, MIN_MULTIPLICITY);
- if (minMultiplicityYAML == null) {
- ;//deja instancié à 1
- } else {
- parameterOM.setMinMultiplicity(Integer.valueOf(String.valueOf(minMultiplicityYAML)));
- log("minMultiplicity=" + Integer.valueOf(String.valueOf(minMultiplicityYAML)));
- }
-
- Object maxMultiplicityYAML = collectElement((List) parameterYAML, MAX_MULTIPLICITY);
- if (maxMultiplicityYAML == null) {
- ;
- } else {
- parameterOM.setMaxMultiplicity(Integer.valueOf(String.valueOf(maxMultiplicityYAML)));
- log("maxMultiplicity=" + String.valueOf(maxMultiplicityYAML));
- }
-
- Object orderedYAML = collectElement((List) parameterYAML, ORDERED);
- if (orderedYAML == null) {
- ;
- } else {
- parameterOM.setOrdered(Boolean.valueOf(String.valueOf(orderedYAML)));
- log("ordered=" + Boolean.valueOf(String.valueOf(orderedYAML)));
- }
-
- Object uniqueYAML = collectElement((List) parameterYAML, UNIQUE);
- if (uniqueYAML == null) {
- ;
- } else {
- parameterOM.setUnique(Boolean.valueOf(String.valueOf(uniqueYAML)));
- log("unique=" + Boolean.valueOf(String.valueOf(uniqueYAML)));
- }
- }
- }
-
- public void loadAttribute(Object attributeYAML, ObjectModelAttributeImpl attributeOM) {
- if (attributeYAML instanceof List) {
- loadParameter(attributeYAML, attributeOM);
-
- Object navigableYAML = collectElement((List) attributeYAML, NAVIGABLE);
- if (navigableYAML == null) {
- ;
- } else {
- attributeOM.setNavigable(Boolean.valueOf(String.valueOf(navigableYAML)));
- log("navigable=" + Boolean.valueOf(String.valueOf(navigableYAML)));
- }
-
- Object associationTypeYAML = collectElement((List) attributeYAML, ASSOCIATION_TYPE);
- if (associationTypeYAML == null) {
- ;//attributeOM.setAssociationType(ObjectModelAttributeImpl.ATTRIBUTE_TYPE_COMPOSITE);
- } else {
- attributeOM.setAssociationType(String.valueOf(associationTypeYAML));
- log("associationType=" + String.valueOf(associationTypeYAML));
- }
-
- Object finalYAML = collectElement((List) attributeYAML, FINAL);
- if (finalYAML == null) {
- ;
- } else {
- attributeOM.setFinal(Boolean.valueOf(String.valueOf(finalYAML)));
- log("final=" + Boolean.valueOf(String.valueOf(finalYAML)));
- }
-
- Object staticYAML = collectElement((List) attributeYAML, STATIC);
- if (staticYAML == null) {
- ;
- } else {
- attributeOM.setStatic(Boolean.valueOf(String.valueOf(staticYAML)));
- log("static=" + Boolean.valueOf(String.valueOf(staticYAML)));
- }
-
- Object associationClassNameYAML = collectElement((List) attributeYAML, ASSOCIATION_CLASS_NAME);
- if (associationClassNameYAML == null) {
- ;
- } else {
- String associationClassName = String.valueOf(associationClassNameYAML);
- if (imports.containsKey(associationClassName)) {
- attributeOM.setAssociationClassName(imports.get(associationClassName));
- } else {
- attributeOM.setAssociationClassName(associationClassName);
- }
- log("associationClassName=" + associationClassName);
- }
-
- Object reverseAttributeNameYAML = collectElement((List) attributeYAML, REVERSE_ATTRIBUTE_NAME);
- if (reverseAttributeNameYAML == null) {
- ;// attributeOM.setReverseAttributeName("");//test
- } else {
- attributeOM.setReverseAttributeName(String.valueOf(reverseAttributeNameYAML));
- log("reverseAttributeName=" + String.valueOf(reverseAttributeNameYAML));
- }
-
- Object reverseMaxMultiplicityYAML = collectElement((List) attributeYAML, REVERSE_MAX_MULTIPLICITY);
- if (reverseMaxMultiplicityYAML == null) {
- ;//instancié à -1
- } else {
- attributeOM.setReverseMaxMultiplicity(Integer.valueOf(String.valueOf(reverseMaxMultiplicityYAML)));
- log("reverseMaxMultiplicity=" + Integer.valueOf(String.valueOf(reverseMaxMultiplicityYAML)));
- }
-
-
- Object transientYAML = collectElement((List) attributeYAML, TRANSIENT);
- if (transientYAML == null) {
- ;
- } else {
- attributeOM.setTransient(Boolean.valueOf(String.valueOf(transientYAML)));
- log("transient=" + Boolean.valueOf(String.valueOf(transientYAML)));
- }
-
- Object visibilityYAML = collectElement((List) attributeYAML, VISIBILITY);
- if (visibilityYAML == null) {
- ;
- } else {
- attributeOM.setVisibility(String.valueOf(visibilityYAML));
- log("visibility=" + String.valueOf(visibilityYAML));
- }
- }
- }
-
- public void loadOperation(Object operationYAML, ObjectModelOperationImpl operationOM) {
- if (operationYAML instanceof List) {
- //TODO: addExceptionParameter
-
- loadElement(operationYAML, operationOM);
-
- Object abstractYAML = collectElement((List) operationYAML, ABSTRACT);
- if (abstractYAML == null) {
- ;
- } else {
- operationOM.setAbstract(Boolean.valueOf(String.valueOf(abstractYAML)));
- log("abstract=" + Boolean.valueOf(String.valueOf(abstractYAML)));
- }
-
- Object visibilityYAML = collectElement((List) operationYAML, VISIBILITY);
- if (visibilityYAML == null) {
- ;
- } else {
- operationOM.setVisibility(String.valueOf(visibilityYAML));
- log("visibility=" + String.valueOf(visibilityYAML));
- }
-
- Object returnParameterYAML = collectElement((List) operationYAML, RETURN_PARAMETER);
- if (returnParameterYAML == null) {
- ;
- } else {
- ObjectModelParameterImpl parameterOM = new ObjectModelParameterImpl();
- loadParameter(returnParameterYAML, parameterOM);
- operationOM.setReturnParameter(parameterOM);
- log("returnParameter=" + parameterOM.getType() + " loaded");
- }
-
- Object bodyCodeYAML = collectElement((List) operationYAML, BODY_CODE);
- if (bodyCodeYAML == null) {
- ;
- } else {
- operationOM.setBodyCode(String.valueOf(bodyCodeYAML));
- log("bodyCode=" + String.valueOf(bodyCodeYAML));
- }
-
- List parametersYAML = collectAllElements((List) operationYAML, PARAMETER);
- for (Object parameterYAML : parametersYAML) {
- ObjectModelParameterImpl parameterOM = new ObjectModelAttributeImpl();
- loadParameter(parameterYAML, parameterOM);
- operationOM.addParameter(parameterOM);
- log("parameter=" + parameterOM.getType() + " loaded");
- }
- }
- }
-}
1
0