ontomde-java 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -0
- data/Manifest.txt +156 -0
- data/README.txt +98 -0
- data/Rakefile +21 -0
- data/bin/ontomde-java +5 -0
- data/generateRdocFile.sh +16 -0
- data/lib/ontomde-java.rb +45 -0
- data/lib/ontomde-java/crank.rb +13 -0
- data/lib/ontomde-java/crank/context.rb +384 -0
- data/lib/ontomde-java/crank/crankJpa.rb +103 -0
- data/lib/ontomde-java/crank/equals.rb +83 -0
- data/lib/ontomde-java/crank/facelets.rb +243 -0
- data/lib/ontomde-java/crank/facesconfig.rb +113 -0
- data/lib/ontomde-java/crank/helper.rb +46 -0
- data/lib/ontomde-java/crank/main.rb +51 -0
- data/lib/ontomde-java/crank/menu.rb +39 -0
- data/lib/ontomde-java/crank/menu2.rb +78 -0
- data/lib/ontomde-java/crank/validation.rb +34 -0
- data/lib/ontomde-java/ejb2.rb +3 -0
- data/lib/ontomde-java/ejb2/main-ejb2.rb +194 -0
- data/lib/ontomde-java/flex.rb +7 -0
- data/lib/ontomde-java/flex/Editor.mxml.as.rb +184 -0
- data/lib/ontomde-java/flex/Editor.mxml.rb +701 -0
- data/lib/ontomde-java/flex/ImportationAS.rb +40 -0
- data/lib/ontomde-java/flex/ValueObjectAS.rb +338 -0
- data/lib/ontomde-java/flex/fileTypes.rb +19 -0
- data/lib/ontomde-java/flex/main.rb +347 -0
- data/lib/ontomde-java/frontend/command.rb +324 -0
- data/lib/ontomde-java/frontend/command.rdoc +583 -0
- data/lib/ontomde-java/frontend/defaultOptions.rb +124 -0
- data/lib/ontomde-java/frontend/options.rb +555 -0
- data/lib/ontomde-java/frontend/steps.rb +287 -0
- data/lib/ontomde-java/java/accessorCode.rb +528 -0
- data/lib/ontomde-java/java/accessorSignature.rb +347 -0
- data/lib/ontomde-java/java/annotationOntoMDE.rb +88 -0
- data/lib/ontomde-java/java/apache.rb +34 -0
- data/lib/ontomde-java/java/build.rb +80 -0
- data/lib/ontomde-java/java/collectionMapping.rb +112 -0
- data/lib/ontomde-java/java/component.rb +446 -0
- data/lib/ontomde-java/java/contextualize.rb +43 -0
- data/lib/ontomde-java/java/enumAssignable.rb +75 -0
- data/lib/ontomde-java/java/enumCompatibilityLayer.rb +195 -0
- data/lib/ontomde-java/java/equals.rb +91 -0
- data/lib/ontomde-java/java/groovy.rb +95 -0
- data/lib/ontomde-java/java/java.rb +1329 -0
- data/lib/ontomde-java/java/java.rdoc +78 -0
- data/lib/ontomde-java/java/javaDatatypeMapping.rb +156 -0
- data/lib/ontomde-java/java/javaHelper.rb +25 -0
- data/lib/ontomde-java/java/java_todo.rdoc +3 -0
- data/lib/ontomde-java/java/javadoc.rb +254 -0
- data/lib/ontomde-java/java/meta.rb +28 -0
- data/lib/ontomde-java/java/operationAsClass.rb +144 -0
- data/lib/ontomde-java/java/security.rb +260 -0
- data/lib/ontomde-java/java/stateMachine.rb +415 -0
- data/lib/ontomde-java/java/tenant.rb +65 -0
- data/lib/ontomde-java/java/xsd.rb +1363 -0
- data/lib/ontomde-java/java/xsdCollectionMapping.rb +112 -0
- data/lib/ontomde-java/java/xsdDatatypeMapping.rb +103 -0
- data/lib/ontomde-java/jpa.rb +17 -0
- data/lib/ontomde-java/jpa/configuration.rb +176 -0
- data/lib/ontomde-java/jpa/finder.rb +102 -0
- data/lib/ontomde-java/jpa/jpa.rb +531 -0
- data/lib/ontomde-java/jpa/jpa.rdoc +20 -0
- data/lib/ontomde-java/jpa/locking.rb +18 -0
- data/lib/ontomde-java/jpa/mapping.rb +314 -0
- data/lib/ontomde-java/jpa/redefined.rb +77 -0
- data/lib/ontomde-java/jpa/simulationAutoImplement.rb +54 -0
- data/lib/ontomde-java/jpdl.rb +9 -0
- data/lib/ontomde-java/jpdl/bpm.pprj +1745 -0
- data/lib/ontomde-java/jpdl/bpm.rdf +140 -0
- data/lib/ontomde-java/jpdl/bpm.rdfs +231 -0
- data/lib/ontomde-java/jpdl/constant.rb +5 -0
- data/lib/ontomde-java/jpdl/graphic.rb +52 -0
- data/lib/ontomde-java/jpdl/jpdl.rb +281 -0
- data/lib/ontomde-java/jpdl/jpdl_deploy.rb +114 -0
- data/lib/ontomde-java/jpdl/main.rb +348 -0
- data/lib/ontomde-java/jpdl/main.rdoc +2 -0
- data/lib/ontomde-java/jpdl/processOperationToClass.rb +316 -0
- data/lib/ontomde-java/kbjava.rb +6 -0
- data/lib/ontomde-java/kbjava/rdfToJava.rb +407 -0
- data/lib/ontomde-java/struts.rb +27 -0
- data/lib/ontomde-java/struts/MessageResources.rb +359 -0
- data/lib/ontomde-java/struts/action.rb +883 -0
- data/lib/ontomde-java/struts/blob.rb +11 -0
- data/lib/ontomde-java/struts/exceptionHandling.rb +167 -0
- data/lib/ontomde-java/struts/footer.rb +128 -0
- data/lib/ontomde-java/struts/form.rb +450 -0
- data/lib/ontomde-java/struts/header.rb +37 -0
- data/lib/ontomde-java/struts/header_link.rb +39 -0
- data/lib/ontomde-java/struts/jsp_edit.rb +870 -0
- data/lib/ontomde-java/struts/jsp_edit_field.rb +1 -0
- data/lib/ontomde-java/struts/jsp_edit_js.rb +124 -0
- data/lib/ontomde-java/struts/jsp_index.rb +136 -0
- data/lib/ontomde-java/struts/localeAction.rb +641 -0
- data/lib/ontomde-java/struts/main.rb +41 -0
- data/lib/ontomde-java/struts/mappingForBean.rb +132 -0
- data/lib/ontomde-java/struts/mappingForJsp.rb +272 -0
- data/lib/ontomde-java/struts/mappingToJavaHierarchy.rb +87 -0
- data/lib/ontomde-java/struts/reloadAction.rb +33 -0
- data/lib/ontomde-java/struts/spring.rb +89 -0
- data/lib/ontomde-java/struts/struts-config.rb +232 -0
- data/lib/ontomde-java/struts/validation.rb +116 -0
- data/lib/ontomde-java/struts/validator.rb +341 -0
- data/lib/ontomde-java/struts/webXml.rb +195 -0
- data/lib/ontomde-java/struts/xmlForm.rb +308 -0
- data/lib/ontomde-java/version.rb +5 -0
- data/profiling.xls +0 -0
- data/test/.classpath +14 -0
- data/test/.project +17 -0
- data/test/.settings/org.eclipse.jdt.core.prefs +23 -0
- data/test/Rakefile +71 -0
- data/test/build.xml +34 -0
- data/test/classpath.rb +15 -0
- data/test/lib/junit-4.1.jar +0 -0
- data/test/load1.rb +3 -0
- data/test/load2.rb +3 -0
- data/test/log4j.properties +46 -0
- data/test/model/.project +11 -0
- data/test/model/BigProject.mdzip +0 -0
- data/test/model/BigProject.mdzip.nt +102866 -0
- data/test/model/ClassDiagram.EntArch.gif +0 -0
- data/test/model/ClassDiagram.emx.gif +0 -0
- data/test/model/ClassDiagram.mdzip.gif +0 -0
- data/test/model/model_ea71.bis.ea.xmi +149 -0
- data/test/model/model_ea71.ea.xmi +4470 -0
- data/test/model/model_ea71.eap +0 -0
- data/test/model/model_ea71_README.txt +8 -0
- data/test/model/multipleInheritance.emx +466 -0
- data/test/model/multipleInheritance.emx.nt +2428 -0
- data/test/model/simple1-530.ofp +0 -0
- data/test/model/simple1-includedAsReference.emx +169 -0
- data/test/model/simple1.emx +3729 -0
- data/test/model/simple1.emx.fragments.nt +81 -0
- data/test/model/simple1.emx.nt +5760 -0
- data/test/model/simple1.mdzip +0 -0
- data/test/model/simple1.mdzip.nt +11500 -0
- data/test/model/simple1.oe530.nt +1986 -0
- data/test/model/simple1.oe600.nt +1627 -0
- data/test/src/RuntimeTest.java +656 -0
- data/test/src/testsLevel1.java +174 -0
- data/test/src/testsLevel2.java +29 -0
- data/test/src/testsLevel3.java +40 -0
- data/test/test-ea7.sh +15 -0
- data/test/test-magicDraw.sh +10 -0
- data/test/test-mi.sh +9 -0
- data/test/test-oe530.sh +10 -0
- data/test/test-oe600.sh +11 -0
- data/test/test-rsm.sh +11 -0
- data/test/test_export_ea71.rb +5 -0
- data/test/test_export_oe530.rb +4 -0
- data/test/test_export_oe600.rb +4 -0
- data/test/test_export_rsm60.rb +4 -0
- data/test/trace +419 -0
- data/test/uml_test.rb +1434 -0
- data/test/uml_test.xls +0 -0
- data/test/unit_test.rb +6 -0
- metadata +224 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
|
2
|
+
# default generation workflow
|
3
|
+
# used by default implemetation of #getGenerationChain
|
4
|
+
#Default steps:
|
5
|
+
# #step_initComponent, #step_load, #step_addTenant, #step_generateKb, #step_generateCustomDTO, #step_bpm, #step_generate_tests , #step_transform10 ,
|
6
|
+
# #step_transform20, #step_transform30, #step_transform40, #step_generate_java, #step_generate_xsd,
|
7
|
+
# #step_generate_struts, #step_generate_crank, #step_generate_misc, #step_generate_flex, #step_clean
|
8
|
+
DEFAULT_GENERATION_CHAIN=[
|
9
|
+
[:load , :step_load],
|
10
|
+
[:tenant , :step_addTenant],
|
11
|
+
[:kb , :step_generateKb],
|
12
|
+
[:bpm , :step_bpm],
|
13
|
+
[:tests , :step_generate_tests],
|
14
|
+
[:mda1 , :step_transform10],
|
15
|
+
[:mda2 , :step_transform20],
|
16
|
+
[:initComponent, :step_initComponent],
|
17
|
+
[:dto , :step_generateCustomDTO ],
|
18
|
+
[:mda3 , :step_transform30],
|
19
|
+
[:mda4 , :step_transform40],
|
20
|
+
[:java , :step_generate_java],
|
21
|
+
[:xsd , :step_generate_xsd],
|
22
|
+
[:jsp , :step_generate_struts],
|
23
|
+
[:crank , :step_generate_crank],
|
24
|
+
[:misc , :step_generate_misc],
|
25
|
+
[:flex , :step_generate_flex],
|
26
|
+
[:clean, :step_clean]]
|
27
|
+
|
28
|
+
# returns generation workflow as an array of steps.
|
29
|
+
# a step is an array of a label and a method name.
|
30
|
+
#
|
31
|
+
#Example:
|
32
|
+
# [[:load,: #step_load ],[:java,: #step_generate_java ]]
|
33
|
+
def getGenerationChain
|
34
|
+
return DEFAULT_GENERATION_CHAIN
|
35
|
+
end
|
36
|
+
|
37
|
+
#calls a generation step name stepMethodName on model
|
38
|
+
|
39
|
+
#Examples of stepMethodName include #step_load, #step_bpm.
|
40
|
+
def callStep(model, stepMethodName)
|
41
|
+
cmd="#{stepMethodName}(model)"
|
42
|
+
eval(cmd)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# load meta-model(s) and model(s)
|
47
|
+
def step_load(model)
|
48
|
+
if model.context[:bpm]
|
49
|
+
say "loading bpm meta-model"
|
50
|
+
model.bpm_loadBPM
|
51
|
+
end
|
52
|
+
say "loading UML2 meta-model"
|
53
|
+
model.loadUml2
|
54
|
+
i=0
|
55
|
+
model.context[:nt].each { |f|
|
56
|
+
i=i+1
|
57
|
+
say "loading uml data from '#{f}'" if model.context[:verbose]
|
58
|
+
model.loadModelFromFile(f)
|
59
|
+
}
|
60
|
+
|
61
|
+
model.umlx_processUnrootedElements! # required for EA incremental loading
|
62
|
+
model.umlx_processShortcuts!
|
63
|
+
|
64
|
+
model.context[:jpdl].each { |f|
|
65
|
+
i=i+1
|
66
|
+
say "loading bpm data from'#{f}'" if model.context[:verbose]
|
67
|
+
model.bpm_loadJPDL(f)
|
68
|
+
}
|
69
|
+
say "# Loaded #{i} model(s)." if model.context[:verbose]
|
70
|
+
model.inspector_start_daemon(model.context[:startupFile]) if model.context[:inspectorAfterLoad]
|
71
|
+
end
|
72
|
+
|
73
|
+
#add tenant information to model
|
74
|
+
def step_addTenant(model)
|
75
|
+
return unless model.context[:multiTenant]
|
76
|
+
puts "adding tenants"
|
77
|
+
model.java_addTenantClass!
|
78
|
+
model.java_addTenantFields!
|
79
|
+
#tenant is added before generateKb to be available in kb.
|
80
|
+
end
|
81
|
+
|
82
|
+
# Generate protege 2000 knowlege base
|
83
|
+
def step_generateKb(model)
|
84
|
+
|
85
|
+
# Pre-generation
|
86
|
+
#model.umlx_autoImplementProperty! if model.context[:withAutoImplementProperty]
|
87
|
+
#model.umlx_autoImplementOperation! if model.context[:withAutoImplementOperation]
|
88
|
+
|
89
|
+
if model.context[:updateTestDataProject]
|
90
|
+
say "generating KB project and schema"
|
91
|
+
model.generateRDFS(model.context[:testDataProject])
|
92
|
+
end
|
93
|
+
|
94
|
+
if model.context[:enableTestData] || model.context[:webservice]
|
95
|
+
say "loading KB project data"
|
96
|
+
ignoreheader=true
|
97
|
+
data_model=Crdf_ProtegeDataModel.new
|
98
|
+
data_model.loadMetaModelFromFile(model.context[:testDataRDFS],ignoreheader)
|
99
|
+
data_model.loadModelFromFile(model.context[:testDataRDF],ignoreheader)
|
100
|
+
data_model.kbjava_umlSourceModel = model
|
101
|
+
model[:dataModel]=data_model
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Process bpm enhancement.
|
106
|
+
def step_bpm(model)
|
107
|
+
return unless model.context[:bpm]
|
108
|
+
say "processing bpm"
|
109
|
+
model.bpm_addPingNode!
|
110
|
+
model.bpm_handleProcessMethods!
|
111
|
+
model.bpm_transform!
|
112
|
+
#model.bpm_graphGen_dot
|
113
|
+
end
|
114
|
+
|
115
|
+
# generate custom DTO based on business objects
|
116
|
+
# and setup from protege.
|
117
|
+
def step_generateCustomDTO(model)
|
118
|
+
model.dto_generateCustomDTO()
|
119
|
+
end
|
120
|
+
|
121
|
+
# Enhance UML model
|
122
|
+
def step_transform10(model)
|
123
|
+
say "processing UML model structure"
|
124
|
+
model.umlx_tryToSalvageErrors!
|
125
|
+
model.struts_createDataTypeHelpers! if model.context[:struts]
|
126
|
+
|
127
|
+
model.java_addJavaEnumInterface!
|
128
|
+
model.umlx_makeCompositionNavigable!
|
129
|
+
model.java_contextualizeStaticProperties! if model.context[:contextualizeStaticProperties]
|
130
|
+
model.umlx_mapMultipleInheritanceToInterface! if model.context[:withMultipleInheritance]
|
131
|
+
|
132
|
+
model.umlx_checkAbstractAndInheritance
|
133
|
+
|
134
|
+
model.umlx_generateCompositonDotDiagram
|
135
|
+
if model.context[:ejb2]
|
136
|
+
model.ejb2_transform!
|
137
|
+
end
|
138
|
+
#Should be placed before autoImplementoperation: otherwise autoImplementedMethod are not considered as business method
|
139
|
+
model.umlx_MarkAllAsbusinessMethod!
|
140
|
+
|
141
|
+
model.java_addEnumAssignable! if model.context[:withEnumAssignable]
|
142
|
+
model.umlx_autoImplementProperty! if model.context[:withAutoImplementProperty]
|
143
|
+
model.umlx_autoImplementOperation! if model.context[:withAutoImplementOperation]
|
144
|
+
|
145
|
+
|
146
|
+
model.java_processComponents! if model.context[:webservice]
|
147
|
+
|
148
|
+
model.java_addGroovyImplementations! if model.context[:groovyExperimental]
|
149
|
+
model.java_addStateMachine! if model.context[:statemachine]
|
150
|
+
|
151
|
+
model.struts_addAllOperationAggregateParameterClass!
|
152
|
+
model.java_addEnumCompatibilityLayerProperties! if model.context[:withEnumAsString]
|
153
|
+
model.db_addDAO! if model.context[:db]
|
154
|
+
model.java_transform!
|
155
|
+
end
|
156
|
+
def step_transform20(model)
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
model.db_addPersistence! if model.context[:db]
|
161
|
+
|
162
|
+
model.struts_addActionLocaleForm! if model.context[:struts]
|
163
|
+
model.struts_addPerClassElement! if model.context[:struts]
|
164
|
+
|
165
|
+
model.db_addTestImplementations! if model.context[:simulateNotImplementedMethods]
|
166
|
+
# model.struts_installRessources if model.context[:installRessources ]
|
167
|
+
model.struts_getFunctionalException if model.context[:struts]
|
168
|
+
end
|
169
|
+
def step_transform30(model)
|
170
|
+
model.struts_getExceptionHandlerClass if model.context[:struts]
|
171
|
+
model.uml_addVersionSignature
|
172
|
+
|
173
|
+
if model.context[:crank]
|
174
|
+
model.crank_generate_context
|
175
|
+
model.crank_generate_validation
|
176
|
+
end
|
177
|
+
model.umlx_populateSecuredMethodEnumeration if model.context[:security]
|
178
|
+
model.umlx_populateScriptedMethodEnumeration if model.context[:script]
|
179
|
+
end
|
180
|
+
def step_transform40(model)
|
181
|
+
model.umlx_populateSecuredPropertyEnumeration if model.context[:security]
|
182
|
+
model.umlx_processSecuredElements if model.context[:security]
|
183
|
+
|
184
|
+
model.umlx_processScriptedElements if model.context[:script]
|
185
|
+
model.umlx_pruneEmptyEnums! if model.context[:pruneEmptyEnums]
|
186
|
+
end
|
187
|
+
|
188
|
+
#process tests loaded from protege/2000 and generate test artefacts.
|
189
|
+
def step_generate_tests(model)
|
190
|
+
if(model.context[:enableTestData])
|
191
|
+
say "processing tests"
|
192
|
+
data_model=model[:dataModel]
|
193
|
+
data_model.kbjava_generateJavaJunit!
|
194
|
+
data_model.mtk_context(:build=>%{#{model.context[:testRelativeDir]}}) {
|
195
|
+
data_model.kbjava_generate
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
#write java files to disk
|
201
|
+
def step_generate_java(model)
|
202
|
+
if model.context[:hasGlobalReverse]
|
203
|
+
say "Reversing java files"
|
204
|
+
model.java_addJavaAnnotationOntoMDE!
|
205
|
+
|
206
|
+
model.context[:reverseGlobalMap]={}
|
207
|
+
model.context[:reversedFiles]=[]
|
208
|
+
model.context[:requireReverseExtensions]=[]
|
209
|
+
if model.context[:readGlobalReverseFile]
|
210
|
+
if !(model.mtk_retrieveProtected(model.context[:globalReverseFile],FileTypeJava.instance))
|
211
|
+
raise Warning.new,"#{model.context[:globalReverseFile]} doesn't exist. Add --no-readGlobalReverseFile option if it's normal."
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
say "Generating/Updating java files"
|
216
|
+
model.java_generateRepository
|
217
|
+
end
|
218
|
+
#write java files to disk
|
219
|
+
def step_generate_xsd(model)
|
220
|
+
return unless model.context[:generateXSD]
|
221
|
+
say "processing xsd"
|
222
|
+
model.xsd_generateSchemaElements!
|
223
|
+
model.xsd_generate_all
|
224
|
+
end
|
225
|
+
|
226
|
+
#write struts files to disk
|
227
|
+
def step_generate_struts(model)
|
228
|
+
return if model.context[:excludeNonTestFiles]
|
229
|
+
if(model.context[:struts])
|
230
|
+
say "processing struts"
|
231
|
+
model.struts_generate_webxml
|
232
|
+
model.struts_struts_config_generate
|
233
|
+
model.struts_validator_generate
|
234
|
+
model.struts_validation_generate
|
235
|
+
model.struts_copyReloadDefinitionsActionClass
|
236
|
+
|
237
|
+
model.struts_index_generate
|
238
|
+
model.struts_edit_generate
|
239
|
+
model.struts_messageResources_generate
|
240
|
+
model.struts_generateSpringApplicationContext
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
#generate misc. artefacts
|
245
|
+
def step_generate_misc(model)
|
246
|
+
return if model.context[:excludeNonTestFiles]
|
247
|
+
say "processing misc."
|
248
|
+
model.db_saveDB_DISCRIMINATOR if model.context[:db]
|
249
|
+
model.db_generateConfiguration if model.context[:db]
|
250
|
+
model.java_generateAntBuildFile
|
251
|
+
model.java_generatePackageDoc
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
#generate flex artefacts
|
256
|
+
def step_generate_flex(model)
|
257
|
+
return unless model.context[:flex]
|
258
|
+
say "processing flex"
|
259
|
+
model.mtk_context(:javaDir => "#{model.context[:flexDir]}/src/", :javaFilePathRegexp => nil) {
|
260
|
+
model.flex_generateVO
|
261
|
+
model.flex_generateMXML
|
262
|
+
}
|
263
|
+
model.mtk_context(:javaDir => "#{model.context[:flexDir]}/script/", :javaFilePathRegexp => nil) {
|
264
|
+
model.flex_generateImportationAS
|
265
|
+
}
|
266
|
+
end
|
267
|
+
|
268
|
+
def step_generate_crank(model)
|
269
|
+
return if model.context[:excludeNonTestFiles]
|
270
|
+
if(model.context[:crank])
|
271
|
+
model.crank_generate_facesconfig
|
272
|
+
model.crank_generate_facelets
|
273
|
+
model.crank_generate_home
|
274
|
+
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def step_initComponent(model)
|
279
|
+
model.java_autoGenerateCrudComponents! if model.context[:webservice]
|
280
|
+
model.umlx_autoCreateImplicitComponent! if model.context[:withGenerateImplicitComponent]
|
281
|
+
end
|
282
|
+
|
283
|
+
# cleanup temporary files
|
284
|
+
def step_clean(model)
|
285
|
+
mtk_deleteTempFiles
|
286
|
+
end
|
287
|
+
|
@@ -0,0 +1,528 @@
|
|
1
|
+
module Muml_Classifier
|
2
|
+
|
3
|
+
# returns access method access to current element
|
4
|
+
# (empty if static context, this otherwise)
|
5
|
+
def java_this(oa)
|
6
|
+
return "" if oa.uml_isStatic?
|
7
|
+
return "this."
|
8
|
+
end
|
9
|
+
|
10
|
+
# returns default suggester body code.
|
11
|
+
# (this method is often overwritten, especially by persistence module).
|
12
|
+
def java_writeSuggesterBody(oa)
|
13
|
+
#TODO: recherche du composite commun
|
14
|
+
write("return null;\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Write code for a composition createAndAdd suggester
|
18
|
+
#see: #java_writeSuggesterBodyEnumWithType
|
19
|
+
def java_writeSuggesterTypeBodyEnum(oa,isCreateAndAdd=false)
|
20
|
+
java_writeSuggesterBodyEnumWithType(oa,oa.uml_type_one.java_enumAssignableDataType_one,isCreateAndAdd)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Write code for a suggester for a parameter enum
|
24
|
+
#see: #java_writeSuggesterBodyEnumWithType
|
25
|
+
def java_writeSuggesterBodyEnum(oa)
|
26
|
+
java_writeSuggesterBodyEnumWithType(oa,oa.uml_type_one)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Write code for a suggester returning enum given has parameter
|
30
|
+
#Note: if lowerValue is zero, null is also added (except if createAndAdd)
|
31
|
+
def java_writeSuggesterBodyEnumWithType(oa,enum,isCreateAndAddSuggester=false)
|
32
|
+
write <<END
|
33
|
+
java.util.ArrayList<#{enum.java_qualifiedName}> ret=new java.util.ArrayList<#{enum.java_qualifiedName}>();
|
34
|
+
#{ (oa.umlx_lowerValueIsZero? && (!isCreateAndAddSuggester)) ? %{ret.add(null);} : %{} }
|
35
|
+
for(int i=java.lang.reflect.Array.getLength(#{enum.java_qualifiedName}.values())-1; i>=0 ; i--){
|
36
|
+
ret.add(#{enum.java_qualifiedName}.values()[i]);
|
37
|
+
}
|
38
|
+
return ret;
|
39
|
+
END
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns an UML LiteralInteger initialized with val value.
|
43
|
+
#
|
44
|
+
#Example:
|
45
|
+
# * umlx_literal(45)
|
46
|
+
# * umlx_literal("45")
|
47
|
+
def umlx_literal(val)
|
48
|
+
r=Cuml_LiteralInteger.new(rdf_Repository,nil)
|
49
|
+
r.uml_value=val
|
50
|
+
return r
|
51
|
+
end
|
52
|
+
|
53
|
+
#Adds a remover for parameter oa using a model transformation.
|
54
|
+
#
|
55
|
+
#NOTE:
|
56
|
+
#* A new operation is added to the UML model. The operation then generated using standard operation generator.
|
57
|
+
#* Remover is only generated for multi-valued property
|
58
|
+
#* If property is part of a *bidirectional* association, code is generated to update automaticaly the other side of the association.
|
59
|
+
def java_addRemover!(oa)
|
60
|
+
return unless context[:java_addRemover,true]
|
61
|
+
return if oa.umlx_upperValueIsOne?
|
62
|
+
return if oa.java_isSuggester?
|
63
|
+
return if oa.uml_isReadOnly?
|
64
|
+
set=java_createAndAddMethodFromProperty(oa,"remove",true)
|
65
|
+
|
66
|
+
if oa.uml_qualifier.empty?
|
67
|
+
qualCall=""
|
68
|
+
qualInit=""
|
69
|
+
qualCheckRemove=""
|
70
|
+
else
|
71
|
+
qualCall=".get(#{oa.uml_qualifier_one.java_Name})"
|
72
|
+
qualInit="//#{java_this(oa)}#{oa.java_NameProperty}.put(#{oa.uml_qualifier_one.java_Name},new java.util.HashSet<#{oa.uml_qualifier_one.uml_type_one}>);"
|
73
|
+
qualCheckRemove="==null"
|
74
|
+
end
|
75
|
+
|
76
|
+
ip=Cuml_Parameter.new(rdf_Repository,set.rdf_uri+"_in")
|
77
|
+
ip.uml_name=getterParameterName(oa)
|
78
|
+
ip.uml_direction=Cuml_ParameterDirectionKind::In
|
79
|
+
ip.uml_upperValue=umlx_literal(1)
|
80
|
+
ip.uml_lowerValue=umlx_literal(1)
|
81
|
+
ip.uml_type=oa.uml_type
|
82
|
+
set.uml_ownedParameter_add(ip)
|
83
|
+
oe=oa.umlx_otherEnd
|
84
|
+
if oa.uml_isDerived?
|
85
|
+
#no code when derived
|
86
|
+
elsif oe.nil? || !oe.umlx_isNavigable?
|
87
|
+
set.java_code=<<END
|
88
|
+
#{java_this(oa)}#{oa.java_NameProperty}.remove(#{getterParameterName(oa)});
|
89
|
+
END
|
90
|
+
elsif oe.umlx_upperValueIsOne?
|
91
|
+
set.java_code=<<END
|
92
|
+
#{qualInit}
|
93
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}.remove(#{getterParameterName(oa)})#{qualCheckRemove}) {
|
94
|
+
#{getterParameterName(oa)}#{qualCall}.set#{oe.java_NameBean}(null);
|
95
|
+
}
|
96
|
+
END
|
97
|
+
else
|
98
|
+
set.java_code=<<END
|
99
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}.remove(#{getterParameterName(oa)})) {
|
100
|
+
#{getterParameterName(oa)}#{qualCall}.remove#{oe.java_NameBean}(this);
|
101
|
+
}
|
102
|
+
END
|
103
|
+
end
|
104
|
+
|
105
|
+
if set.java_use_Arrays?
|
106
|
+
set.java_code=nil # TODO: implement
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
#return a warning text to be included in java method if incorrect model is found.
|
112
|
+
def java_qualifierNavigabilityWarning(oa)
|
113
|
+
oe=oa.umlx_otherEnd
|
114
|
+
return "" if oe.nil?
|
115
|
+
return "" if oe.umlx_isNavigable?
|
116
|
+
return <<END
|
117
|
+
/*TODO: association other end is navigable (#{oe.uml_name}).
|
118
|
+
Because extrinsic qualifier key is not computable, there is no way a computer program can guess it.
|
119
|
+
Check your model !
|
120
|
+
If your key is intrisic, you should reconsider your model as it is a redundant functional qualifier.
|
121
|
+
You should take appropriate action or your data model could be corrupted
|
122
|
+
as association other end will not be updated.
|
123
|
+
*/
|
124
|
+
END
|
125
|
+
end
|
126
|
+
|
127
|
+
def java_addQualifiedRemover!(oa)
|
128
|
+
end
|
129
|
+
|
130
|
+
def java_addQualifiedAppender!(oa)
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
def java_writeQualifiedPutterBody(oa)
|
136
|
+
j=""
|
137
|
+
sep=""
|
138
|
+
oa.uml_qualifier.each { |key|
|
139
|
+
j=j+sep+key.java_Name
|
140
|
+
sep=","
|
141
|
+
}
|
142
|
+
write <<END
|
143
|
+
{
|
144
|
+
#{java_qualifierNavigabilityWarning(oa)}
|
145
|
+
if(#{getterParameterName(oa)}==null) {
|
146
|
+
#{java_this(oa)}#{oa.java_NameProperty}.remove(#{j});
|
147
|
+
} else {
|
148
|
+
#{java_this(oa)}#{oa.java_NameProperty}.put(#{j},#{getterParameterName(oa)});
|
149
|
+
}
|
150
|
+
}
|
151
|
+
END
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
def java_addAppenderQualifier!(oa)
|
157
|
+
return unless context[:java_addAppenderQualifier,true]
|
158
|
+
return if oa.umlx_upperValueIsOne?
|
159
|
+
return if oa.uml_qualifier.empty?
|
160
|
+
return if oa.umlx_isComposite?
|
161
|
+
return if oa.uml_isReadOnly?
|
162
|
+
add=java_createAndAddMethodFromProperty(oa,"add",true)
|
163
|
+
|
164
|
+
ip=Cuml_Parameter.new(rdf_Repository,add.rdf_uri+"_in")
|
165
|
+
ip.uml_name=getterParameterName(oa)
|
166
|
+
ip.uml_direction=Cuml_ParameterDirectionKind::In
|
167
|
+
ip.uml_upperValue=umlx_literal(1);
|
168
|
+
ip.uml_lowerValue=umlx_literal(1);
|
169
|
+
ip.uml_type=oa.uml_type
|
170
|
+
add.uml_ownedParameter_add(ip)
|
171
|
+
oe=oa.umlx_otherEnd
|
172
|
+
|
173
|
+
qualCall=".get(#{oa.uml_qualifier_one.java_Name})"
|
174
|
+
qualInit="//#{java_this(oa)}#{oa.java_NameProperty}.put(#{oa.uml_qualifier_one.java_Name},new java.util.HashSet<#{oa.uml_qualifier_one.uml_type_one}>);"
|
175
|
+
|
176
|
+
if oa.uml_isDerived?
|
177
|
+
# no code when derived
|
178
|
+
elsif true #TODO:remetre le test oe.nil? || !oe.umlx_isNavigable?
|
179
|
+
add.java_code=<<END
|
180
|
+
//TODO:
|
181
|
+
if(#{ip.java_Name}==null) { return; }
|
182
|
+
#{qualInit}
|
183
|
+
#{java_this(oa)}#{oa.java_NameProperty}#{qualCall}.add(#{ip.java_Name});
|
184
|
+
END
|
185
|
+
elsif oe.umlx_upperValueIsOne?
|
186
|
+
#*-1
|
187
|
+
add.java_code=<<END
|
188
|
+
if(#{ip.java_Name}==null) { return; }
|
189
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}#{qualCall}.add(#{ip.java_Name})){
|
190
|
+
#{ip.java_Name}.set#{oe.java_NameBean}(this);
|
191
|
+
}
|
192
|
+
END
|
193
|
+
else
|
194
|
+
#*-*
|
195
|
+
add.java_code=<<END
|
196
|
+
if(#{ip.java_Name}==null) { return; }
|
197
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}#{qualCall}.add(#{ip.java_Name})) {
|
198
|
+
#{ip.java_Name}.remove#{oe.java_NameBean}(this);
|
199
|
+
}
|
200
|
+
END
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
#Adds a creater for parameter oa using a model transformation.
|
205
|
+
#
|
206
|
+
#NOTE:
|
207
|
+
#* A new operation is added to the UML model. The operation then generated using standard operation generator.
|
208
|
+
#--
|
209
|
+
#TODO: implementer methodes
|
210
|
+
def java_addCreater!(oa)
|
211
|
+
return unless context[:java_addCreater,true]
|
212
|
+
return if oa.umlx_upperValueIsOne?
|
213
|
+
#return unless oa.uml_qualifier.empty?
|
214
|
+
return unless oa.umlx_isComposite?
|
215
|
+
get=java_createAndAddMethodFromProperty(oa,"create",false)
|
216
|
+
|
217
|
+
tenantClause=""
|
218
|
+
if context[:multiTenant]
|
219
|
+
#call constructor with tenant
|
220
|
+
tenantClause="(#{TENANT_FIELD_NAME})"
|
221
|
+
end
|
222
|
+
|
223
|
+
rp=Cuml_Parameter.new(rdf_Repository,get.rdf_uri+"_p1")
|
224
|
+
rp.uml_name="return"
|
225
|
+
rp.uml_direction=Cuml_ParameterDirectionKind::Return
|
226
|
+
rp.uml_upperValue=oa.uml_upperValue
|
227
|
+
rp.uml_lowerValue=oa.uml_lowerValue
|
228
|
+
rp.uml_type=oa.uml_type
|
229
|
+
rp.uml_qualifier=oa.uml_qualifier
|
230
|
+
get.uml_ownedParameter_add(rp)
|
231
|
+
if oa.umlx_upperValueIsOne? || !oa.uml_qualifier.empty?
|
232
|
+
j="{ new return #{oa.java_NameProperty}#{tenantClause}"
|
233
|
+
sep_next=".get("
|
234
|
+
sep_end=""
|
235
|
+
j=j+sep_end +";}"
|
236
|
+
#get.java_code=j
|
237
|
+
else
|
238
|
+
#on ne peut pas permetre la modification de la liste en direct
|
239
|
+
#get.java_code="{ return new java.util.HashSet<#{oa.uml_type_one.java_qualifiedName}>(#{oa.java_NameProperty}); }"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
#Adds a createAndAdd method for parameter oa using a model transformation.
|
244
|
+
#
|
245
|
+
#NOTE:
|
246
|
+
#* A new operation is added to the UML model. The operation then generated using standard operation generator.
|
247
|
+
#* operation is only generated for multi-valued property
|
248
|
+
#* operation is only generated for a composite association end.
|
249
|
+
def java_addCreateAndAppender!(oa)
|
250
|
+
#method cannot be generated if required enum assignable is not on.
|
251
|
+
return unless context[:withEnumAssignable]
|
252
|
+
return unless context[:java_addAppender,true]
|
253
|
+
#return if oa.umlx_upperValueIsOne?
|
254
|
+
return unless oa.uml_qualifier.empty?
|
255
|
+
return unless oa.umlx_isComposite?
|
256
|
+
return if oa.java_isSuggester?
|
257
|
+
|
258
|
+
add=umlx_createAndAddOperation(rdf_uri+"_createAndAdd#{oa.java_NameBean}","createAndAdd#{oa.java_NameBean}")
|
259
|
+
|
260
|
+
rp=add.umlx_createAndAddReturnParameter(add.rdf_uri+"_ret")
|
261
|
+
rp.uml_upperValue=umlx_literal(1);
|
262
|
+
rp.uml_lowerValue=umlx_literal(1);
|
263
|
+
rp.uml_type=oa.uml_type
|
264
|
+
|
265
|
+
#ip=add.umlx_createAndAddParameter(add.rdf_uri+"_type")
|
266
|
+
#ip.uml_name="type"
|
267
|
+
#ip.uml_upperValue=umlx_literal(1);
|
268
|
+
#ip.uml_lowerValue=umlx_literal(1);
|
269
|
+
#ip.uml_type=oa.uml_type
|
270
|
+
|
271
|
+
|
272
|
+
tp=add.umlx_createAndAddParameter(oa.rdf_uri+"_reqType","requestedType")
|
273
|
+
tp.uml_type=oa.uml_type_one.java_enumAssignableDataType_one
|
274
|
+
|
275
|
+
#if oa.uml_type_one.uml_isAbstract?
|
276
|
+
# ******************************
|
277
|
+
# TODO: implement type selector
|
278
|
+
# ******************************
|
279
|
+
# no java code generated
|
280
|
+
|
281
|
+
#TODO: factorize in helper class
|
282
|
+
add.java_code=%{
|
283
|
+
if (requestedType==null) {
|
284
|
+
return null;
|
285
|
+
}
|
286
|
+
String qname=requestedType.name().replaceAll("#{JAVA_MAGIC_DOT_STRING}",".");
|
287
|
+
try {
|
288
|
+
// c=#{java_this(oa)}getClass().getClassLoader().loadClass(requestedType.name());
|
289
|
+
Class<?> t = Class.forName(qname);
|
290
|
+
Class<?>[] p = new Class[0];
|
291
|
+
Object[]initArgs =new Object[0];
|
292
|
+
java.lang.reflect.Constructor<?> c=t.getConstructor(p);
|
293
|
+
#{oa.uml_type_one.java_qualifiedName} ret=(#{oa.uml_type_one.java_qualifiedName})c.newInstance(initArgs);
|
294
|
+
#{%{ret.setTenantOwner(getTenantOwner());} if context[:multiTenant]}
|
295
|
+
#{oa.umlx_upperValueIsOne? ? "set" : "add"}#{oa.java_NameBean}(ret);
|
296
|
+
return ret;
|
297
|
+
} catch (ClassNotFoundException e) {
|
298
|
+
e.printStackTrace();
|
299
|
+
throw new RuntimeException("Missing type "+qname,e);
|
300
|
+
} catch (NoSuchMethodException e) {
|
301
|
+
e.printStackTrace();
|
302
|
+
throw new RuntimeException("Missing default constructor for"+qname,e);
|
303
|
+
} catch (IllegalAccessException e) {
|
304
|
+
e.printStackTrace();
|
305
|
+
throw new RuntimeException("Illegal access Exception on "+qname,e);
|
306
|
+
} catch (InstantiationException e) {
|
307
|
+
e.printStackTrace();
|
308
|
+
throw new RuntimeException("Instantiation exception on "+qname,e);
|
309
|
+
} catch (java.lang.reflect.InvocationTargetException e) {
|
310
|
+
e.printStackTrace();
|
311
|
+
throw new RuntimeException("Invocation Target Exception on "+qname,e);
|
312
|
+
}}
|
313
|
+
end
|
314
|
+
|
315
|
+
# Adds an appender for parameter oa using a model transformation.
|
316
|
+
#
|
317
|
+
#NOTE:
|
318
|
+
# * A new operation is added to the UML model. The operation then generated using standard operation generator.
|
319
|
+
# * operation is only generated for multi-valued property
|
320
|
+
# * If property is part of a *bidirectional* association, code is generated to update automaticaly the other side of the association.
|
321
|
+
def java_addAppender!(oa)
|
322
|
+
return unless context[:java_addAppender,true]
|
323
|
+
return if oa.umlx_upperValueIsOne?
|
324
|
+
return unless oa.uml_qualifier.empty?
|
325
|
+
return if oa.java_isSuggester?
|
326
|
+
#return if oa.umlx_isComposite?
|
327
|
+
return if oa.uml_isReadOnly?
|
328
|
+
add=java_createAndAddMethodFromProperty(oa,"add",true)
|
329
|
+
|
330
|
+
ip=Cuml_Parameter.new(rdf_Repository,add.rdf_uri+"_in")
|
331
|
+
ip.uml_name=getterParameterName(oa)
|
332
|
+
ip.uml_direction=Cuml_ParameterDirectionKind::In
|
333
|
+
ip.uml_upperValue=umlx_literal(1);
|
334
|
+
ip.uml_lowerValue=umlx_literal(1);
|
335
|
+
ip.uml_type=oa.uml_type
|
336
|
+
add.uml_ownedParameter_add(ip)
|
337
|
+
oe=oa.umlx_otherEnd
|
338
|
+
|
339
|
+
if oa.uml_isDerived?
|
340
|
+
# no code generated
|
341
|
+
elsif (oe.nil? || !oe.umlx_isNavigable?) && !oa.java_use_Arrays?
|
342
|
+
add.java_code=<<END
|
343
|
+
if(#{getterParameterName(oa)}==null) { return; }
|
344
|
+
#{java_this(oa)}#{oa.java_NameProperty}.add(#{getterParameterName(oa)});
|
345
|
+
END
|
346
|
+
elsif (oe.nil? || !oe.umlx_isNavigable?) && oa.java_use_Arrays?
|
347
|
+
add.java_code=<<END
|
348
|
+
if(#{getterParameterName(oa)}==null) { return; }
|
349
|
+
#{oa.uml_type_one.java_qualifiedName}[] newArray=null;
|
350
|
+
if (#{java_this(oa)}#{oa.java_NameProperty}==null) {
|
351
|
+
newArray=new #{oa.uml_type_one.java_qualifiedName}[1];
|
352
|
+
newArray[0]=#{getterParameterName(oa)};
|
353
|
+
} else {
|
354
|
+
newArray=new #{oa.uml_type_one.java_qualifiedName}[1+#{java_this(oa)}#{oa.java_NameProperty}.length];
|
355
|
+
System.arraycopy(#{java_this(oa)}#{oa.java_NameProperty}, 0, newArray,0, #{java_this(oa)}#{oa.java_NameProperty}.length);
|
356
|
+
newArray[#{java_this(oa)}#{oa.java_NameProperty}.length]=#{getterParameterName(oa)};
|
357
|
+
}
|
358
|
+
#{java_this(oa)}#{oa.java_NameProperty}=newArray;
|
359
|
+
END
|
360
|
+
|
361
|
+
|
362
|
+
elsif oe.umlx_upperValueIsOne?
|
363
|
+
#*-1
|
364
|
+
add.java_code=<<END
|
365
|
+
if(#{getterParameterName(oa)}==null) { return; }
|
366
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}.add(#{getterParameterName(oa)})){
|
367
|
+
#{getterParameterName(oa)}.set#{oe.java_NameBean}(this);
|
368
|
+
}
|
369
|
+
END
|
370
|
+
else
|
371
|
+
#*-*
|
372
|
+
# second test avoids loop
|
373
|
+
add.java_code=<<END
|
374
|
+
if(#{getterParameterName(oa)}==null) { return; }
|
375
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}.add(#{getterParameterName(oa)})) {
|
376
|
+
#{getterParameterName(oa)}.add#{oe.java_NameBean}(this);
|
377
|
+
}
|
378
|
+
END
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
|
384
|
+
def java_addWithIndexAppenderBody(oa,oe,ip,ip2)
|
385
|
+
if oe.nil? || !oe.umlx_isNavigable?
|
386
|
+
write <<END
|
387
|
+
if(#{getterParameterName(oa)}==null) { return; }
|
388
|
+
#{oa.java_NameProperty}.add(#{ip2.java_Name}, #{ip.java_Name});
|
389
|
+
END
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
# writes to current output global getter body which return the variable directly (not a subset).
|
394
|
+
#
|
395
|
+
#Example:
|
396
|
+
# return myVariable;
|
397
|
+
#Reference:
|
398
|
+
# * #getterParameterName
|
399
|
+
# * #java_isEnumStringMapping
|
400
|
+
# * #java_writeEnumStringMappingGetterCode
|
401
|
+
# * #java_getCollectionMapping
|
402
|
+
def java_writeGlobalGetterBody(oa)
|
403
|
+
return if oa.uml_isDerived? && oa.umlx_stringMappingForEnum.empty?
|
404
|
+
|
405
|
+
if java_isEnumStringMapping?(oa)
|
406
|
+
java_writeEnumStringMappingGetterCode(oa)
|
407
|
+
|
408
|
+
elsif oa.umlx_upperValueIsOne? || !oa.uml_qualifier.empty?
|
409
|
+
j="return #{oa.java_NameProperty}"
|
410
|
+
sep_next=".get("
|
411
|
+
sep_end=""
|
412
|
+
#oa.uml_qualifier.each { |key|
|
413
|
+
# j=j+sep_next+key.uml_name_one
|
414
|
+
# sep_next=","
|
415
|
+
# sep_end=")"
|
416
|
+
#}
|
417
|
+
j=j+sep_end +";"
|
418
|
+
write j
|
419
|
+
else
|
420
|
+
#on ne peut pas permettre la modification de la liste en direct
|
421
|
+
write %{
|
422
|
+
if(#{oa.java_NameProperty}!=null){
|
423
|
+
return #{oa.java_NameProperty};
|
424
|
+
} else {
|
425
|
+
return #{oa.java_getCollectionMapping.addNew(oa.uml_type_one.java_qualifiedName)};
|
426
|
+
}}
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
# writes to current output global setter body which return the variable directly (not a subset).
|
431
|
+
#
|
432
|
+
#Example:
|
433
|
+
# return myVariable;
|
434
|
+
#Reference:
|
435
|
+
# * #getterParameterName
|
436
|
+
# * #java_isEnumStringMapping
|
437
|
+
# * #java_writeEnumStringMappingSetterCode
|
438
|
+
# * #java_getCollectionMapping
|
439
|
+
def java_writeGlobalSetterBody(oa)
|
440
|
+
return if oa.uml_isDerived? && oa.umlx_stringMappingForEnum.empty?
|
441
|
+
|
442
|
+
oe=oa.umlx_otherEnd
|
443
|
+
if java_isEnumStringMapping?(oa)
|
444
|
+
java_writeEnumStringMappingSetterCode(oa)
|
445
|
+
elsif !oa.uml_qualifier.empty? || (!oe.nil? && oe.umlx_isNavigable? && !oe.uml_qualifier.empty?)
|
446
|
+
#TODO: gerer bi-nav et qualifier
|
447
|
+
write "//TODO: bi-navigability\n #{oa.java_NameProperty}=#{getterParameterName(oa)};"
|
448
|
+
elsif (oe.nil?) || (!oe.umlx_isNavigable?)
|
449
|
+
# other end is non navigable.
|
450
|
+
#begin
|
451
|
+
#if oa.uml_qualifier.empty?
|
452
|
+
write "#{java_this(oa)}#{oa.java_NameProperty}=#{getterParameterName(oa)};"
|
453
|
+
#else
|
454
|
+
# j="{ #{oa.java_NameProperty}.put("
|
455
|
+
# sep=""
|
456
|
+
# oa.uml_qualifier.each { |qual|
|
457
|
+
# j=j+sep+qual.java_NameProperty
|
458
|
+
# sep=","
|
459
|
+
# }
|
460
|
+
# j=j+sep+"#{ip.uml_name});}"
|
461
|
+
# set.java_code=j
|
462
|
+
#end
|
463
|
+
#end
|
464
|
+
elsif oa.umlx_upperValueIsOne? && oe.umlx_upperValueIsOne?
|
465
|
+
# 1<->1
|
466
|
+
#Ne pas enlver le =null (bloque la recursion)
|
467
|
+
write <<END
|
468
|
+
if(#{java_this(oa)}#{oa.java_NameProperty}==#{getterParameterName(oa)}) { return ;}
|
469
|
+
#{oa.uml_type_one.java_qualifiedName} previous=#{java_this(oa)}#{oa.java_NameProperty};
|
470
|
+
|
471
|
+
#{java_this(oa)}#{oa.java_NameProperty}=null;
|
472
|
+
if(previous!=null) { previous.set#{oe.java_NameBean}(null); }
|
473
|
+
|
474
|
+
#{java_this(oa)}#{oa.java_NameProperty}=#{getterParameterName(oa)};
|
475
|
+
if(#{getterParameterName(oa)}!=null) { #{getterParameterName(oa)}.set#{oe.java_NameBean}(this); }
|
476
|
+
END
|
477
|
+
|
478
|
+
elsif oa.umlx_upperValueIsOne? && (!oe.umlx_upperValueIsOne?)
|
479
|
+
# 1<->*
|
480
|
+
write <<END
|
481
|
+
if(#{oa.java_NameProperty}!=null && #{oa.java_NameProperty}.equals(#{getterParameterName(oa)})) { return ;}
|
482
|
+
#{oa.uml_type_one.java_qualifiedName} previous=#{oa.java_NameProperty};
|
483
|
+
|
484
|
+
#{oa.java_NameProperty}=null;
|
485
|
+
if(previous!=null) { previous.remove#{oe.java_NameBean}(this); }
|
486
|
+
|
487
|
+
#{java_this(oa)}#{oa.java_NameProperty}=#{getterParameterName(oa)};
|
488
|
+
if(#{getterParameterName(oa)}!=null) { #{getterParameterName(oa)}.add#{oe.java_NameBean}(this); }
|
489
|
+
END
|
490
|
+
else # *<->1 and *<->*
|
491
|
+
write <<END
|
492
|
+
#{oa.java_propertyAssociationType} toBeRemoved=new #{oa.java_propertyAssociationConcreteType}();
|
493
|
+
for(#{oa.uml_type_one.java_qualifiedName} item:#{oa.java_NameProperty}) {
|
494
|
+
if(#{getterParameterName(oa)}!=null && #{getterParameterName(oa)}.contains(item)) { continue;}
|
495
|
+
toBeRemoved.add(item);
|
496
|
+
}
|
497
|
+
for(#{oa.uml_type_one.java_qualifiedName} item:toBeRemoved) {
|
498
|
+
#{java_this(oa)}remove#{oa.java_NameBean}(item);
|
499
|
+
}
|
500
|
+
if(#{getterParameterName(oa)}==null) { return ; }
|
501
|
+
for(#{oa.uml_type_one.java_qualifiedName} item:#{getterParameterName(oa)}) {
|
502
|
+
#{java_this(oa)}add#{oa.java_NameBean}(item);
|
503
|
+
}
|
504
|
+
END
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
# writes to current output getter body when a qualifier (~hashtable) is used.
|
509
|
+
# Qualifier parameters are used as parameter.
|
510
|
+
#
|
511
|
+
#Example:
|
512
|
+
# return myVariable;
|
513
|
+
#Reference:
|
514
|
+
# * #getterParameterName
|
515
|
+
# * #java_isEnumStringMapping
|
516
|
+
# * #java_writeEnumStringMappingSetterCode
|
517
|
+
# * #java_getCollectionMapping
|
518
|
+
def java_writeQualifiedGetterBody(oa)
|
519
|
+
write("return #{oa.java_NameProperty}.get(")
|
520
|
+
sep=""
|
521
|
+
oa.uml_qualifier.each { |key|
|
522
|
+
write(sep)
|
523
|
+
sep=","
|
524
|
+
write(key.java_Name)
|
525
|
+
}
|
526
|
+
write(");\n")
|
527
|
+
end
|
528
|
+
end
|