ontomde-java 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,28 @@
|
|
1
|
+
|
2
|
+
class Crdfs_Class
|
3
|
+
|
4
|
+
# UML metaclass to java class mapping.
|
5
|
+
#
|
6
|
+
#Example:
|
7
|
+
# An UML metaclass class maps to a java.lang.Class java class.
|
8
|
+
#Note:
|
9
|
+
# feature introduced for opencrx.
|
10
|
+
JAVA_METACLASS_MAPPING={
|
11
|
+
"uml_Class" => "java.lang.Class"
|
12
|
+
}
|
13
|
+
|
14
|
+
# returns the java class name for this meta-class.
|
15
|
+
#
|
16
|
+
#Example:
|
17
|
+
#
|
18
|
+
#Note:
|
19
|
+
# added for openmdx which uses attributes of type "metaclass-class".
|
20
|
+
def java_qualifiedName
|
21
|
+
qn=JAVA_METACLASS_MAPPING[rdf_uri]
|
22
|
+
return qn unless qn.nil?
|
23
|
+
msg="unknown java_qualifiedName for meta-class #{rdf_uri}"
|
24
|
+
return "int /*TODO: #{msg} */"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#
|
2
|
+
# This file is about generating forms associated to business method.
|
3
|
+
# For example, if a class C has a method doThis with parameter p1 and p2,
|
4
|
+
# a class doThisMPC would be generated with properties p1 and p2.
|
5
|
+
# This class could then be used for creating a form that would contain
|
6
|
+
# data for calling doThis method.
|
7
|
+
|
8
|
+
|
9
|
+
module Muml_Classifier
|
10
|
+
# name of property which stores the object whose business method will be invoked.
|
11
|
+
STRUTS_APPLY_TO_PARAM="applyTo"
|
12
|
+
# name of bean property which stores the object whose business method will be invoked.
|
13
|
+
STRUTS_APPLY_TO_PROP="ApplyTo"
|
14
|
+
end
|
15
|
+
|
16
|
+
module Muml_Operation
|
17
|
+
# link to a form generated from this operation parameters.
|
18
|
+
rdf_safe_attr_reader_many :struts_bizOperationReverse
|
19
|
+
end
|
20
|
+
|
21
|
+
module Muml_Parameter
|
22
|
+
# the method parameter
|
23
|
+
rdf_safe_attr_reader_many :struts_sourceParameter
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
module Mrdf_Repository
|
28
|
+
# generates for every business operation in repository.
|
29
|
+
def struts_addAllOperationAggregateParameterClass!
|
30
|
+
return unless context[:withGenerateMethodForm]
|
31
|
+
|
32
|
+
uml_Class_all.each {|c|
|
33
|
+
#exclude classes explicitely set to false
|
34
|
+
next if (!c.umlx_businessMethod.empty?) && (!c.umlx_businessMethod?)
|
35
|
+
c.uml_ownedOperation.each {|biz|
|
36
|
+
#next if c.java_isATestFile?
|
37
|
+
next unless biz.kind_of?(Muml_Operation)
|
38
|
+
next unless biz.umlx_businessMethod?
|
39
|
+
next if biz.umlx_isConstructor?
|
40
|
+
next if biz.uml_visibility_one.isPrivate?
|
41
|
+
next if biz.uml_visibility_one.isProtected?
|
42
|
+
next if biz.uml_visibility_one.isPackage?
|
43
|
+
next if biz.uml_isStatic?
|
44
|
+
#c=biz.umlx_owner_one
|
45
|
+
|
46
|
+
p=c.umlx_package
|
47
|
+
if p.nil?
|
48
|
+
log.error{"Model modification required !!! class #{c} is in root model element. Classes should be in a package."}
|
49
|
+
next
|
50
|
+
end
|
51
|
+
next unless c.kind_of?(Muml_Class)
|
52
|
+
|
53
|
+
p=p.umlx_getOrCreatePackage(context[:classMethodSubDir,"methods"],p)
|
54
|
+
#BUG:biz_uri ne suffisait pas car si 2 classes immplémnetaient 2 fois une méthode d'une classe abstraite
|
55
|
+
#la classe crée avait les 2 mêmes uri et donc était zappé par la suite(notamment le java_transform
|
56
|
+
mpc=p.umlx_createAndAddClass(c.rdf_uri+biz.rdf_uri+"_mpc2");
|
57
|
+
mpc.umlx_businessMethod=RDF_TRUE
|
58
|
+
mpc.struts_addAllOperationAggregateParameterClass!(biz)
|
59
|
+
mpc.db_isTransient=RDF_TRUE
|
60
|
+
mpc.java_addTenantField!
|
61
|
+
|
62
|
+
m=mpc.umlx_createAndAddOperation(mpc.rdf_uri+"merge","merge");
|
63
|
+
#TODO merge referenced items
|
64
|
+
m.java_code="return this; "
|
65
|
+
p=m.umlx_createAndAddReturnParameter(m.rdf_uri+'_ret',"return")
|
66
|
+
p.uml_type=mpc
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
}}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
module Muml_Classifier
|
74
|
+
# source business operation from which this class was generated.
|
75
|
+
rdf_safe_attr_reader_many :struts_bizOperation
|
76
|
+
|
77
|
+
|
78
|
+
STRUTS_RESULT_PARAM_NAME="_result"
|
79
|
+
# Creates a class for every business method holding every parameters
|
80
|
+
def struts_addAllOperationAggregateParameterClass!(biz)
|
81
|
+
mpc=self
|
82
|
+
mpc.struts_bizOperation=biz
|
83
|
+
biz.struts_bizOperationReverse_add(mpc)
|
84
|
+
#biz.struts_bizForm=mpc
|
85
|
+
mpc.uml_name="#{biz.umlx_owner_one.java_Name}#{biz.java_Name}MPC"
|
86
|
+
(biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
|
87
|
+
#next if param.uml_direction_one.isReturn?
|
88
|
+
mpcp=mpc.umlx_createAndAddProperty(mpc.rdf_uri+"_mpc3")
|
89
|
+
param.umlx_copyToAttributeProperty(mpcp)
|
90
|
+
mpcp.uml_name= param.uml_direction_one.isReturn? ? STRUTS_RESULT_PARAM_NAME : param.uml_name
|
91
|
+
}
|
92
|
+
mpc.struts_addApplyToParameter!(biz)
|
93
|
+
mpc.struts_addProceed!(biz)
|
94
|
+
#mpc.apaCom_addLogger!
|
95
|
+
end
|
96
|
+
|
97
|
+
# generates an apply to parameter
|
98
|
+
def struts_addApplyToParameter!(biz)
|
99
|
+
mpc=self
|
100
|
+
m,m1,m2=mpc.umlx_createAndAddAssociation(mpc.rdf_uri+"_apply",biz.umlx_owner_one)
|
101
|
+
m1.uml_name=STRUTS_APPLY_TO_PARAM
|
102
|
+
m2.uml_name="#{STRUTS_APPLY_TO_PARAM}_inv"
|
103
|
+
end
|
104
|
+
|
105
|
+
# generates a proceed operation.
|
106
|
+
def struts_addProceed!(biz)
|
107
|
+
mpc=self
|
108
|
+
cpt=mpc.umlx_createAndAddOperation(mpc.rdf_uri+"_proceed","proceed")
|
109
|
+
params=""; sep=""
|
110
|
+
hasRP=false
|
111
|
+
(biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
|
112
|
+
if param.uml_direction_one.isReturn?
|
113
|
+
hasRP=true
|
114
|
+
next
|
115
|
+
end
|
116
|
+
params="#{params}#{sep}#{param.java_Name}"
|
117
|
+
sep=","
|
118
|
+
}
|
119
|
+
if(biz.uml_raisedException.empty?)
|
120
|
+
cpt.java_code=%{
|
121
|
+
#{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
|
122
|
+
}
|
123
|
+
else
|
124
|
+
cpt.java_code=%{
|
125
|
+
try {
|
126
|
+
//log.error("before biz method");
|
127
|
+
//log.error("applyTo="+#{STRUTS_APPLY_TO_PARAM});
|
128
|
+
#{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
|
129
|
+
//log.error("after biz method");
|
130
|
+
//log.error("result="+#{hasRP ? STRUTS_RESULT_PARAM_NAME : %{"-none-"}});
|
131
|
+
} catch(Exception e) {
|
132
|
+
//TODO: implement proper exception handling
|
133
|
+
throw new java.lang.RuntimeException(e);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
@@ -0,0 +1,260 @@
|
|
1
|
+
# Authentification and security model enhancements.
|
2
|
+
# Used in acegi integration.
|
3
|
+
#
|
4
|
+
|
5
|
+
module Muml_Property
|
6
|
+
# returns true if element is marked as secured.
|
7
|
+
def umlx_isSecured?
|
8
|
+
return umlx_hasStereotype?("Secured")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
module Muml_Operation
|
12
|
+
# returns true if element is marked as secured.
|
13
|
+
def umlx_isSecured?
|
14
|
+
return umlx_hasStereotype?("Secured")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Mrdf_Repository
|
19
|
+
|
20
|
+
# Retrieve an enumeration that will contain a list of secured methods
|
21
|
+
def umlx_getSecuredMethodEnumeration
|
22
|
+
return umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.SecuredMethodInventory",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
|
23
|
+
end
|
24
|
+
|
25
|
+
# populate secured method inventory (which is stored as a java enum.)
|
26
|
+
def umlx_populateSecuredMethodEnumeration
|
27
|
+
umlx_generateStaticSecurityRoleEnum
|
28
|
+
e=umlx_getSecuredMethodEnumeration
|
29
|
+
|
30
|
+
#populate inventory
|
31
|
+
uml_Class_all.each {|c|
|
32
|
+
next unless c.umlx_businessMethod?
|
33
|
+
next if c.kind_of?(Muml_Interface)
|
34
|
+
cn="#{c.java_qualifiedName}.class"
|
35
|
+
c.uml_ownedOperation.each {|op|
|
36
|
+
next unless op.umlx_businessMethod?
|
37
|
+
next unless op.umlx_isSecured?
|
38
|
+
#operation was generated from an interface
|
39
|
+
next if (!op.umlx_redefinesMethod.empty?) && (!op.umlx_redefinesMethod_one.umlx_owner_one.kind_of?(Muml_Interface))
|
40
|
+
lit=e.umlx_createAndAddLiteral("#{op.umlx_owner_one.java_qualifiedName}_#{op.java_Name}")
|
41
|
+
lit.java_initParameterValue_add(cn)
|
42
|
+
lit.java_initParameterValue_add(%{"#{op.java_Name}"})
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
cc=umlx_reserved_model.umlx_getOrCreateClass("java.lang.Classxx")
|
47
|
+
cc.uml_name="Class<?>"
|
48
|
+
cc.java_isGeneric=RDF_TRUE
|
49
|
+
|
50
|
+
str=e.umlx_owner_one.umlx_dataType_string
|
51
|
+
# add constructor
|
52
|
+
c=e.umlx_createAndAddOperation("#{c}.constructor","constructor")
|
53
|
+
c.uml_appliedStereotype_add(e.umlx_getOrCreateStereotype("Create"))
|
54
|
+
c.uml_visibility=::Cuml_VisibilityKind::Private
|
55
|
+
p1=c.umlx_createAndAddParameter("#{c.uri}_p1","_ownerClass")
|
56
|
+
p1.uml_type=cc
|
57
|
+
p2=c.umlx_createAndAddParameter("#{c.uri}_p2","_operationName")
|
58
|
+
p2.uml_type=str
|
59
|
+
c.java_code="ownerClass=_ownerClass;\noperationName=_operationName;"
|
60
|
+
|
61
|
+
#add attributes
|
62
|
+
a1=e.umlx_createAndAddProperty("#{e}_a1","ownerClass")
|
63
|
+
a1.uml_type=cc
|
64
|
+
a2=e.umlx_createAndAddProperty("#{e}_a2","operationName")
|
65
|
+
a2.uml_type=str
|
66
|
+
|
67
|
+
#add finder
|
68
|
+
f=e.umlx_createAndAddOperation("#{e.uri}_find","find")
|
69
|
+
f.uml_isStatic=RDF_TRUE
|
70
|
+
a1=f.umlx_createAndAddParameter("#{e}_a1","ownerClass")
|
71
|
+
a1.uml_type=cc
|
72
|
+
a2=f.umlx_createAndAddParameter("#{e}_a2","operationName")
|
73
|
+
a2.uml_type=str
|
74
|
+
a3=f.umlx_createAndAddReturnParameter("#{e}_ret","enum")
|
75
|
+
a3.uml_type=e
|
76
|
+
f.java_code=<<END
|
77
|
+
//TODO !!!!!!!!!!!
|
78
|
+
return null ; //#{e.java_Name}
|
79
|
+
END
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# JAVA_GLOBAL_ACCESS_CONTROL_ENUM="xmda .security.StaticSecurityRole"
|
84
|
+
# Enumerated containing the list of all access control criteria
|
85
|
+
JAVA_GLOBAL_ACCESS_CONTROL_ENUM="xmda.security.GlobalComputedAccessControlCriteria"
|
86
|
+
JAVA_GLOBAL_ACCESS_CONTROL_ENUM_COMMENT=<<ENDHELP
|
87
|
+
This enum contains a list of all computed access control criteria.
|
88
|
+
|
89
|
+
Generic examples of access control:
|
90
|
+
* userIsManagerForThisObject
|
91
|
+
* userOwnsThisObject
|
92
|
+
* userIsOnDuty
|
93
|
+
|
94
|
+
AccessControl criteria are computed in the context of one class instance of the model and one user. (ex: User Martin accessing contract number 3003).
|
95
|
+
|
96
|
+
Some criteria migth not need to know what object is beeing accessed (example: userIsOnDuty). Some other will need to know what object is access (Is martin a manager for contract 42000 ?, Does Martin owns product number 13239 ?)
|
97
|
+
|
98
|
+
This list is defined at design time because these rules criteria are implemented usign an algorithm (model query, date computation, ...) that require some coding and optimisation at developpement time. It is however possible to add RESERVED elements for future extension (RESERVED1, RESERVED2, ...).
|
99
|
+
ENDHELP
|
100
|
+
|
101
|
+
|
102
|
+
# Model may contain several enumeration of roles stereotypes staticSecurityRole
|
103
|
+
# For implementation use, an enumeration containing every roles is generated.
|
104
|
+
# Role container name could be appended to role name but it is not because it
|
105
|
+
# would make code refactoring more complex.
|
106
|
+
# As a consequence, role name should be unique application wide.
|
107
|
+
def umlx_generateStaticSecurityRoleEnum
|
108
|
+
e=umlx_reserved_model.umlx_getOrCreateEnumeration(JAVA_GLOBAL_ACCESS_CONTROL_ENUM,Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
|
109
|
+
e.umlx_createAndAddComment("#{e.rdf_uri}_comment",JAVA_GLOBAL_ACCESS_CONTROL_ENUM_COMMENT) if e.uml_ownedComment.empty?
|
110
|
+
|
111
|
+
self.each_value { |v|
|
112
|
+
next unless v.kind_of?(Muml_Enumeration)
|
113
|
+
#next unless v.umlx_hasStereotype?("staticSecurityRole")
|
114
|
+
next unless v.umlx_hasStereotype?("ComputedAccessControlCriteria")
|
115
|
+
v.uml_ownedLiteral.each {|c|
|
116
|
+
#role name should be unique
|
117
|
+
e.umlx_createAndAddLiteral(c.to_s)
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
# Retrieve an enumeration that will contain a list of secured property
|
123
|
+
def umlx_getSecuredPropertyEnumeration
|
124
|
+
return umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.SecuredPropertyInventory",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Populate secured property inventory (which is stored as a java enum)
|
128
|
+
def umlx_populateSecuredPropertyEnumeration
|
129
|
+
#umlx_generateStaticSecurityRoleEnum
|
130
|
+
e=umlx_getSecuredPropertyEnumeration
|
131
|
+
|
132
|
+
#populate inventory
|
133
|
+
uml_Class_all.each {|c|
|
134
|
+
next unless c.umlx_businessMethod?
|
135
|
+
|
136
|
+
#Hack: transient operation
|
137
|
+
#next if c.db_isTransient?
|
138
|
+
|
139
|
+
|
140
|
+
next if c.kind_of?(Muml_Interface)
|
141
|
+
cn="#{c.java_qualifiedName}.class"
|
142
|
+
c.uml_ownedAttribute.each {|op|
|
143
|
+
#next unless op.umlx_businessMethod?
|
144
|
+
#operation was generated from an interface
|
145
|
+
#next if (!op.umlx_redefinesProperty.empty?) && (!op.umlx_redefinesProperty_one.umlx_owner_one.kind_of?(Muml_Interface))
|
146
|
+
lit=e.umlx_createAndAddLiteral("#{op.umlx_owner_one.java_qualifiedName}_#{op.java_Name}")
|
147
|
+
lit.java_initParameterValue_add(cn)
|
148
|
+
lit.java_initParameterValue_add(%{"#{op.java_Name}"})
|
149
|
+
lit.java_initParameterValue_add(op.umlx_isSecured?)
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
#Classxx is on purpose
|
155
|
+
cc=umlx_reserved_model.umlx_getOrCreateClass("java.lang.Classxx")
|
156
|
+
cc.uml_name="Class<?>"
|
157
|
+
cc.java_isGeneric=RDF_TRUE
|
158
|
+
|
159
|
+
str=e.umlx_owner_one.umlx_dataType_string
|
160
|
+
bol=e.umlx_owner_one.umlx_dataType_boolean
|
161
|
+
# add constructor
|
162
|
+
c=e.umlx_createAndAddOperation("#{c}.constructor","constructor")
|
163
|
+
c.uml_appliedStereotype_add(e.umlx_getOrCreateStereotype("Create"))
|
164
|
+
c.uml_visibility=::Cuml_VisibilityKind::Private
|
165
|
+
p1=c.umlx_createAndAddParameter("#{c.uri}_p1","_ownerClass")
|
166
|
+
p1.uml_type=cc
|
167
|
+
p2=c.umlx_createAndAddParameter("#{c.uri}_p2","_propertyName")
|
168
|
+
p2.uml_type=str
|
169
|
+
p3=c.umlx_createAndAddParameter("#{c.uri}_p3","_isSecured")
|
170
|
+
p3.uml_type=bol
|
171
|
+
c.java_code="ownerClass=_ownerClass;\npropertyName=_propertyName;\nisSecured=_isSecured;"
|
172
|
+
|
173
|
+
#add attributes
|
174
|
+
a1=e.umlx_createAndAddProperty("#{e}_a1","ownerClass")
|
175
|
+
a1.uml_type=cc
|
176
|
+
a2=e.umlx_createAndAddProperty("#{e}_a2","propertyName")
|
177
|
+
a2.uml_type=str
|
178
|
+
a3=e.umlx_createAndAddProperty("#{e}_a2","isSecured")
|
179
|
+
a3.uml_type=bol
|
180
|
+
|
181
|
+
|
182
|
+
#add finder
|
183
|
+
f=e.umlx_createAndAddOperation("#{e.uri}_find","find")
|
184
|
+
f.uml_isStatic=RDF_TRUE
|
185
|
+
a1=f.umlx_createAndAddParameter("#{e}_a1","ownerClass")
|
186
|
+
a1.uml_type=cc
|
187
|
+
a2=f.umlx_createAndAddParameter("#{e}_a2","propertyName")
|
188
|
+
a2.uml_type=str
|
189
|
+
a3=f.umlx_createAndAddReturnParameter("#{e}_ret","enum")
|
190
|
+
a3.uml_type=e
|
191
|
+
f.java_code=<<END
|
192
|
+
//TODO !!!!!!!!!!!
|
193
|
+
return null ; //#{e.java_Name}
|
194
|
+
END
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
#Java annotation used to mark a Secured method or field.
|
199
|
+
JAVA_SECURE_ANNOTATION="@xmda.security.Secure"
|
200
|
+
|
201
|
+
# process element marked as secured
|
202
|
+
def umlx_processSecuredElements
|
203
|
+
e=umlx_reserved_model.umlx_getOrCreateInterface("org.springframework.security.userdetails.UserDetails")
|
204
|
+
|
205
|
+
uml_Class_all.each {|c|
|
206
|
+
#sec=false
|
207
|
+
next if c.kind_of?(Muml_Interface) || c.kind_of?(Muml_Enumeration)
|
208
|
+
c.uml_ownedOperation.each {|o|
|
209
|
+
next unless o.umlx_isSecured?
|
210
|
+
o.java_annotation_add(JAVA_SECURE_ANNOTATION)
|
211
|
+
#sec=true
|
212
|
+
}
|
213
|
+
c.uml_ownedAttribute.each { |a|
|
214
|
+
next unless a.umlx_isSecured?
|
215
|
+
a.java_annotation_add(JAVA_SECURE_ANNOTATION)
|
216
|
+
#sec=true
|
217
|
+
}
|
218
|
+
c.umlx_addGetStaticRoleOperation! #if sec
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
module Muml_Class
|
224
|
+
|
225
|
+
# method comment that will be generated as javadoc
|
226
|
+
JAVA_GETSTATIC_ROLE_COMMENT=<<ENDHELP
|
227
|
+
This method returns a set of "static roles" that *may* *be* granted to the user based on database informations.
|
228
|
+
|
229
|
+
When a "security role" (defined at runtime) is bounded(linked) to a "static role" (defined at compile time),
|
230
|
+
users must
|
231
|
+
- be granted the security role
|
232
|
+
- and the bounded "static role" must be included in the set of role returned by this method.
|
233
|
+
ENDHELP
|
234
|
+
|
235
|
+
#method default implementation
|
236
|
+
JAVA_GETSTATIC_ROLE_CODE=<<ENDROLECODE
|
237
|
+
//return empty list (every static role are denied)
|
238
|
+
return new java.util.HashSet<#{Mrdf_Repository::JAVA_GLOBAL_ACCESS_CONTROL_ENUM}>();
|
239
|
+
ENDROLECODE
|
240
|
+
|
241
|
+
# Adds methods which returns computed grants to user.
|
242
|
+
# This methods returns an list of granted rights (which are stored as java enums)
|
243
|
+
#
|
244
|
+
# Example:
|
245
|
+
# * public List<SecurityRole> getComputedAccessControlGrant(org.acegi.security.UserDetails userName
|
246
|
+
def umlx_addGetStaticRoleOperation!
|
247
|
+
m=self.umlx_createAndAddOperation("#{rdf_uri}_getComputedAccessControlGrant","getComputedAccessControlGrant")
|
248
|
+
|
249
|
+
r=m.umlx_createAndAddReturnParameter("#{m.rdf_uri}_return")
|
250
|
+
r.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration(Mrdf_Repository::JAVA_GLOBAL_ACCESS_CONTROL_ENUM,Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
|
251
|
+
r.uml_upperValue=umlx_literal(-1)
|
252
|
+
r.umlx_createAndAddComment("#{r.rdf_uri}_c1",JAVA_GETSTATIC_ROLE_COMMENT)
|
253
|
+
|
254
|
+
p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","user")
|
255
|
+
p.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration("org.springframework.security.userdetails.UserDetails",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
|
256
|
+
|
257
|
+
m.java_code=JAVA_GETSTATIC_ROLE_CODE
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
@@ -0,0 +1,415 @@
|
|
1
|
+
#
|
2
|
+
# This application reads a uml2 state machine
|
3
|
+
# and generates a graphviz graph from it.
|
4
|
+
#
|
5
|
+
# This is a basic generator for State Machine Generator
|
6
|
+
# cf: http://smc.sourceforge.net/SmcManSec2.htm
|
7
|
+
#
|
8
|
+
|
9
|
+
|
10
|
+
require 'ontomde-uml2'
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
module Mrdf_Repository
|
15
|
+
def java_getClassWithQualifiedName(qname)
|
16
|
+
uml_Class_all.each { |f|
|
17
|
+
return f if f.java_qualifiedName.to_s.casecmp(qname)==0
|
18
|
+
}
|
19
|
+
puts "not found #{qname}"
|
20
|
+
#exit 1
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Muml_Operation
|
26
|
+
#Indique si c'est une m�thode g�r�e par la machine � �tat
|
27
|
+
attr_accessor :java_isFsmOperation
|
28
|
+
end
|
29
|
+
|
30
|
+
module Muml_Classifier
|
31
|
+
|
32
|
+
#FSMContext of the StateMachine
|
33
|
+
rdf_safe_attr_reader_many :java_FSMContext
|
34
|
+
#State of the StateMachine
|
35
|
+
rdf_safe_attr_reader_many :java_FSMState
|
36
|
+
|
37
|
+
def java_addStateManagement
|
38
|
+
|
39
|
+
fsmState = self.java_FSMState_one
|
40
|
+
fsmContext = self.java_FSMContext_one
|
41
|
+
|
42
|
+
#TODO Corriger le bug avec JPA qui emp�che de rajouter cette interface
|
43
|
+
# typecomp=umlx_getOrCreateInterface("xmda.fsm.FsmComponent<#{fsmContext.java_qualifiedName}>")
|
44
|
+
# typecomp.java_isGeneric=RDF_TRUE
|
45
|
+
# umlx_createAndAddImplementation(typecomp)
|
46
|
+
|
47
|
+
fsm=umlx_createAndAddProperty(rdf_uri+"_fsm", "fsmCtx")
|
48
|
+
fsm.uml_type=java_FSMContext_one
|
49
|
+
fsm.db_isTransient=RDF_TRUE
|
50
|
+
fsm.uml_visibility=::Cuml_VisibilityKind::Private
|
51
|
+
fsm.java_annotation_add("@javax.persistence.Transient")
|
52
|
+
get=java_addGlobalGetter!(fsm)
|
53
|
+
get.java_code=<<CODE
|
54
|
+
if (fsmCtx==null || getPersistedState().compareToIgnoreCase(fsmCtx.getState().getName()) != 0) {
|
55
|
+
saasAdministration.fsm.MDAaasApplicationInstanceState currentState = saasAdministration.fsm.MDAaasApplicationInstanceState.findStateByName(getPersistedState());
|
56
|
+
fsmCtx = new saasAdministration.fsm.MDAaasApplicationInstanceFSMContext(this, currentState);
|
57
|
+
}
|
58
|
+
return fsmCtx;
|
59
|
+
|
60
|
+
CODE
|
61
|
+
|
62
|
+
persState=umlx_createAndAddProperty(rdf_uri+"_state", "persistedState")
|
63
|
+
persState.uml_type=umlx_dataType_string
|
64
|
+
persState.uml_visibility=::Cuml_VisibilityKind::Private
|
65
|
+
java_addGlobalSetter!(persState)
|
66
|
+
getState=java_addGlobalGetter!(persState)
|
67
|
+
getState.java_code=<<CODE
|
68
|
+
if (persistedState==null || persistedState.length()<=0) {
|
69
|
+
fsmCtx = new saasAdministration.fsm.MDAaasApplicationInstanceFSMContext(this);
|
70
|
+
setPersistedState(fsmCtx.getState().getName());
|
71
|
+
}
|
72
|
+
return persistedState;
|
73
|
+
CODE
|
74
|
+
|
75
|
+
|
76
|
+
# Gestion de la synchronisation du champ persistedState et fsmCtx transient
|
77
|
+
ent=umlx_getOrCreateInterface("java.beans.PropertyChangeListener")
|
78
|
+
umlx_createAndAddImplementation(ent)
|
79
|
+
m=umlx_createAndAddOperation(rdf_uri+"_prop","propertyChange")
|
80
|
+
m.uml_visibility=Cuml_VisibilityKind::Public
|
81
|
+
arg1=m.umlx_createAndAddParameter(m.rdf_uri+"_evt","evt")
|
82
|
+
arg1.uml_direction=Cuml_ParameterDirectionKind::In
|
83
|
+
arg1.uml_upperValue=umlx_literal(1)
|
84
|
+
arg1.uml_lowerValue=umlx_literal(1)
|
85
|
+
arg1.uml_type=umlx_getOrCreateInterface("java.beans.PropertyChangeEvent")
|
86
|
+
m.java_code=<<CODE
|
87
|
+
#{fsmState.java_qualifiedName} newState = (#{fsmState.java_qualifiedName}) evt.getNewValue();
|
88
|
+
setPersistedState(newState.getName());
|
89
|
+
CODE
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def findOperationByName(methodName)
|
94
|
+
uml_ownedOperation.each { |o|
|
95
|
+
return o if methodName == "#{o.java_Name}"
|
96
|
+
}
|
97
|
+
return nil
|
98
|
+
end
|
99
|
+
#t transition
|
100
|
+
def java_getOrCreateOperationForTransition(t)
|
101
|
+
opForT = findOperationByName("#{t.uml_name}")
|
102
|
+
if opForT.nil?
|
103
|
+
opForT=umlx_createAndAddOperation(rdf_uri+"_#{t.uml_name}","#{t.uml_name}")
|
104
|
+
opForT.uml_visibility=Cuml_VisibilityKind::Public
|
105
|
+
opForT.umlx_businessMethod=RDF_TRUE
|
106
|
+
end
|
107
|
+
opForT.java_annotation_add("@xmda.fsm.StateMachineTransition")
|
108
|
+
opForT.java_isFsmOperation=true
|
109
|
+
opForT.java_code=<<CODE
|
110
|
+
getFsmCtx().#{opForT.java_Name}();
|
111
|
+
CODE
|
112
|
+
end
|
113
|
+
end
|
114
|
+
module Muml_FinalState
|
115
|
+
def fsm_name
|
116
|
+
n=uml_name_one0
|
117
|
+
return n.nil? ? "Final" : n
|
118
|
+
end
|
119
|
+
end
|
120
|
+
module Muml_Pseudostate
|
121
|
+
#myClazz = classe qui est caract�ris� par la machine � �tat
|
122
|
+
def processVertex(myClazz)
|
123
|
+
# Calculer l'�tat initial et rajouter le constructeur de la classe contexte qui initialise � cet �tat
|
124
|
+
if self.uml_kind_one == ::Cuml_PseudostateKind::Initial
|
125
|
+
self.uml_outgoing.each { |t|
|
126
|
+
fsmState = myClazz.java_FSMState_one
|
127
|
+
fsmContext = myClazz.java_FSMContext_one
|
128
|
+
construct=fsmContext.umlx_createAndAddOperation(fsmState.rdf_uri+"_constructor","constructor")
|
129
|
+
construct.uml_appliedStereotype_add(fsmContext.umlx_getOrCreateStereotype("Create"))
|
130
|
+
construct.uml_visibility=Cuml_VisibilityKind::Public
|
131
|
+
arg1=construct.umlx_createAndAddParameter(construct.rdf_uri+"_owner","owner")
|
132
|
+
arg1.uml_direction=Cuml_ParameterDirectionKind::In
|
133
|
+
arg1.uml_upperValue=fsmState.umlx_literal(1)
|
134
|
+
arg1.uml_lowerValue=fsmState.umlx_literal(1)
|
135
|
+
arg1.uml_type=myClazz
|
136
|
+
construct.java_code=<<CODE
|
137
|
+
this.owner = owner;
|
138
|
+
this.addStateChangeListener(owner);
|
139
|
+
setState(#{fsmState.java_qualifiedName}.#{t.uml_target_one.java_Name.downcase}state);
|
140
|
+
#{fsmState.java_qualifiedName}.#{t.uml_target_one.java_Name.downcase}state.Entry(this);
|
141
|
+
CODE
|
142
|
+
|
143
|
+
construct2=fsmContext.umlx_createAndAddOperation(fsmState.rdf_uri+"_constructor2","constructor2")
|
144
|
+
construct2.uml_appliedStereotype_add(fsmContext.umlx_getOrCreateStereotype("Create"))
|
145
|
+
construct2.uml_visibility=Cuml_VisibilityKind::Public
|
146
|
+
arg3=construct2.umlx_createAndAddParameter(construct2.rdf_uri+"_owner","owner")
|
147
|
+
arg3.uml_direction=Cuml_ParameterDirectionKind::In
|
148
|
+
arg3.uml_upperValue=fsmState.umlx_literal(1)
|
149
|
+
arg3.uml_lowerValue=fsmState.umlx_literal(1)
|
150
|
+
arg3.uml_type=myClazz
|
151
|
+
arg2=construct2.umlx_createAndAddParameter(construct2.rdf_uri+"_initState","initState")
|
152
|
+
arg2.uml_direction=Cuml_ParameterDirectionKind::In
|
153
|
+
arg2.uml_upperValue=fsmState.umlx_literal(1)
|
154
|
+
arg2.uml_lowerValue=fsmState.umlx_literal(1)
|
155
|
+
arg2.uml_type=fsmState
|
156
|
+
construct2.java_code=<<CODE
|
157
|
+
this.owner = owner;
|
158
|
+
this.addStateChangeListener(owner);
|
159
|
+
setState(initState);
|
160
|
+
CODE
|
161
|
+
|
162
|
+
}
|
163
|
+
else
|
164
|
+
raise Warning.new,"PseudState not managed except ::Cuml_PseudostateKind::Initial"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def fsm_name
|
169
|
+
n=uml_name_one0
|
170
|
+
return n.nil? ? rdf_uri : n
|
171
|
+
end
|
172
|
+
end
|
173
|
+
module Muml_PseudostateKind
|
174
|
+
end
|
175
|
+
module Muml_Region
|
176
|
+
end
|
177
|
+
module Muml_Signal
|
178
|
+
end
|
179
|
+
module Muml_SignalTrigger
|
180
|
+
end
|
181
|
+
module Muml_State
|
182
|
+
def processVertex(myClazz)
|
183
|
+
# Generate the class for this state
|
184
|
+
p=myClazz.umlx_package
|
185
|
+
p=p.umlx_getOrCreatePackage("fsm",p)
|
186
|
+
|
187
|
+
fsmState = myClazz.java_FSMState_one
|
188
|
+
fsmContext = myClazz.java_FSMContext_one
|
189
|
+
|
190
|
+
state=p.umlx_createAndAddClass(self.rdf_uri+"_State")
|
191
|
+
state.uml_name="#{self.java_Name}State"
|
192
|
+
state.db_isTransient=RDF_TRUE
|
193
|
+
state.umlx_createAndAddGeneralization(fsmState)
|
194
|
+
construct=state.umlx_createAndAddOperation(state.rdf_uri+"_constructor","constructor")
|
195
|
+
construct.uml_appliedStereotype_add(state.umlx_getOrCreateStereotype("Create"))
|
196
|
+
construct.uml_visibility=Cuml_VisibilityKind::Public
|
197
|
+
construct.java_code=<<CODE
|
198
|
+
super("#{state.java_qualifiedName}");
|
199
|
+
CODE
|
200
|
+
|
201
|
+
pconst=fsmState.umlx_createAndAddProperty(state.rdf_uri+"_Const", "#{state.java_Name.downcase}")
|
202
|
+
pconst.java_noAccessors="true"
|
203
|
+
pconst.uml_type=state
|
204
|
+
pconst.uml_visibility=Cuml_VisibilityKind::Public
|
205
|
+
pconst.uml_isStatic=RDF_TRUE
|
206
|
+
pconst.java_isFinal="true"
|
207
|
+
pconst.java_code=<<CODE
|
208
|
+
new #{state.java_qualifiedName}();
|
209
|
+
CODE
|
210
|
+
|
211
|
+
# Ajouter les m�thodes � la super classe State et au State concern�
|
212
|
+
# Ajouter ou retrouver la m�thode de la classe m�re
|
213
|
+
self.uml_outgoing.each { |t|
|
214
|
+
m = fsmState.findOperationByName("#{t.uml_name}")
|
215
|
+
# Faire une seule fois (cas ou on a plusieurs transitions de m�me nom)
|
216
|
+
if m.nil?
|
217
|
+
m=fsmState.umlx_createAndAddOperation(fsmState.rdf_uri+"_#{t.uml_name}","#{t.uml_name}")
|
218
|
+
m.uml_visibility=Cuml_VisibilityKind::Public
|
219
|
+
em=m.umlx_createAndAddParameter(m.rdf_uri+"_ctx","ctx")
|
220
|
+
em.uml_type=fsmContext
|
221
|
+
em.uml_direction=Cuml_ParameterDirectionKind::In
|
222
|
+
em.uml_upperValue=fsmState.umlx_literal(1)
|
223
|
+
em.uml_lowerValue=fsmState.umlx_literal(1)
|
224
|
+
m.java_code=<<CODE
|
225
|
+
defaultBehavior(ctx);
|
226
|
+
CODE
|
227
|
+
|
228
|
+
m3=fsmContext.umlx_createAndAddOperation(fsmContext.rdf_uri+"_#{t.uml_name}","#{t.uml_name}")
|
229
|
+
m3.uml_visibility=Cuml_VisibilityKind::Public
|
230
|
+
m3.java_code=<<CODE
|
231
|
+
_transition = "#{t.uml_name}";
|
232
|
+
getState().#{t.uml_name}(this);
|
233
|
+
_transition = null;
|
234
|
+
CODE
|
235
|
+
|
236
|
+
myClazz.java_getOrCreateOperationForTransition(t)
|
237
|
+
|
238
|
+
end
|
239
|
+
m2=state.umlx_createAndAddOperation(state.rdf_uri+"_#{t.uml_name}","#{t.uml_name}")
|
240
|
+
m2.uml_visibility=Cuml_VisibilityKind::Public
|
241
|
+
em2=m2.umlx_createAndAddParameter(m2.rdf_uri+"_ctx","ctx")
|
242
|
+
em2.uml_type=fsmContext
|
243
|
+
em2.uml_direction=Cuml_ParameterDirectionKind::In
|
244
|
+
em2.uml_upperValue=state.umlx_literal(1)
|
245
|
+
em2.uml_lowerValue=state.umlx_literal(1)
|
246
|
+
m2.java_code=<<CODE
|
247
|
+
(ctx.getState()).Exit(ctx);
|
248
|
+
ctx.setState(#{fsmState.java_Name}.#{t.uml_target_one.java_Name.downcase}state);
|
249
|
+
(ctx.getState()).Entry(ctx);
|
250
|
+
CODE
|
251
|
+
|
252
|
+
}
|
253
|
+
|
254
|
+
end
|
255
|
+
def fsm_name
|
256
|
+
n=uml_name_one0
|
257
|
+
return n.nil? ? rdf_uri : n
|
258
|
+
end
|
259
|
+
end
|
260
|
+
module Muml_StateMachine
|
261
|
+
def processStateMachine
|
262
|
+
puts "Processing StateMachine #{self.java_qualifiedName}"
|
263
|
+
|
264
|
+
mrdf=context[:umlModel,self.rdf_Repository]
|
265
|
+
muml=mrdf.umlx_reserved_model
|
266
|
+
myClazz=mrdf.java_getClassWithQualifiedName("#{self.java_qualifiedName}")
|
267
|
+
raise Warning.new,"No Class with the same bame as ths StateMachine #{self.java_qualifiedName} !!!!" if myClazz.nil?
|
268
|
+
p=myClazz.umlx_package
|
269
|
+
p=p.umlx_getOrCreatePackage("fsm",p)
|
270
|
+
|
271
|
+
fsmCtx=umlx_getOrCreateClass("xmda.fsm.FSMContext")
|
272
|
+
fsmCtx.umlx_external="true"
|
273
|
+
fsmState=umlx_getOrCreateClass("xmda.fsm.State")
|
274
|
+
fsmState.umlx_external="true"
|
275
|
+
|
276
|
+
appFsmState=p.umlx_createAndAddClass(myClazz.rdf_uri+"_FSMState")
|
277
|
+
appFsmState.uml_name="#{myClazz.java_Name}State"
|
278
|
+
appFsmState.db_isTransient=RDF_TRUE
|
279
|
+
appFsmState.umlx_createAndAddGeneralization(fsmState)
|
280
|
+
myClazz.java_FSMState = appFsmState
|
281
|
+
construct=appFsmState.umlx_createAndAddOperation(fsmCtx.rdf_uri+"_constructor","constructor")
|
282
|
+
construct.uml_appliedStereotype_add(appFsmState.umlx_getOrCreateStereotype("Create"))
|
283
|
+
arg1=construct.umlx_createAndAddParameter(construct.rdf_uri+"_name","name")
|
284
|
+
arg1.uml_direction=Cuml_ParameterDirectionKind::In
|
285
|
+
arg1.uml_upperValue=umlx_literal(1)
|
286
|
+
arg1.uml_lowerValue=umlx_literal(1)
|
287
|
+
arg1.uml_type=umlx_dataType_string
|
288
|
+
construct.uml_visibility=Cuml_VisibilityKind::Public
|
289
|
+
construct.java_code=<<CODE
|
290
|
+
super(name);
|
291
|
+
allStates.put(getName(), this);
|
292
|
+
CODE
|
293
|
+
pconst=appFsmState.umlx_createAndAddProperty(appFsmState.rdf_uri+"_AllConst", "allStates")
|
294
|
+
pconst.java_noAccessors="true"
|
295
|
+
typeconst=appFsmState.umlx_getOrCreateInterface("java.util.HashMap<String, #{appFsmState.java_qualifiedName}>")
|
296
|
+
typeconst.java_isGeneric=RDF_TRUE
|
297
|
+
pconst.uml_type=typeconst
|
298
|
+
pconst.uml_visibility=Cuml_VisibilityKind::Private
|
299
|
+
pconst.uml_isStatic=RDF_TRUE
|
300
|
+
pconst.java_isFinal="true"
|
301
|
+
pconst.java_code=<<CODE
|
302
|
+
new #{typeconst.java_qualifiedName}();
|
303
|
+
CODE
|
304
|
+
mfind=appFsmState.umlx_createAndAddOperation(appFsmState.rdf_uri+"_find","findStateByName")
|
305
|
+
mfind.uml_visibility=Cuml_VisibilityKind::Public
|
306
|
+
mfind.uml_isStatic=RDF_TRUE
|
307
|
+
argfind=mfind.umlx_createAndAddParameter(mfind.rdf_uri+"_name","name")
|
308
|
+
argfind.uml_direction=Cuml_ParameterDirectionKind::In
|
309
|
+
argfind.uml_upperValue=umlx_literal(1)
|
310
|
+
argfind.uml_lowerValue=umlx_literal(1)
|
311
|
+
argfind.uml_type=umlx_dataType_string
|
312
|
+
rp=mfind.umlx_createAndAddParameter(mfind.rdf_uri+"_ret_param","return")
|
313
|
+
rp.uml_direction=Cuml_ParameterDirectionKind::Return
|
314
|
+
rp.uml_upperValue=umlx_literal(1)
|
315
|
+
rp.uml_lowerValue=umlx_literal(1)
|
316
|
+
rp.uml_type=appFsmState
|
317
|
+
mfind.java_code=<<CODE
|
318
|
+
return allStates.get(name);
|
319
|
+
CODE
|
320
|
+
|
321
|
+
|
322
|
+
appFsmCtx=p.umlx_createAndAddClass(myClazz.rdf_uri+"_FSMContext")
|
323
|
+
appFsmCtx.uml_name="#{myClazz.java_Name}FSMContext"
|
324
|
+
appFsmCtx.db_isTransient=RDF_TRUE
|
325
|
+
appFsmCtx.umlx_createAndAddGeneralization(fsmCtx)
|
326
|
+
myClazz.java_FSMContext = appFsmCtx
|
327
|
+
m=appFsmCtx.umlx_createAndAddOperation(fsmCtx.rdf_uri+"_ret","getState")
|
328
|
+
m.uml_visibility=Cuml_VisibilityKind::Public
|
329
|
+
rp=m.umlx_createAndAddParameter(m.rdf_uri+"_ret_param","return")
|
330
|
+
rp.uml_direction=Cuml_ParameterDirectionKind::Return
|
331
|
+
rp.uml_upperValue=umlx_literal(1)
|
332
|
+
rp.uml_lowerValue=umlx_literal(1)
|
333
|
+
rp.uml_type=appFsmState
|
334
|
+
m.java_code=<<CODE
|
335
|
+
return (#{appFsmState.java_qualifiedName})_state;
|
336
|
+
CODE
|
337
|
+
p2=appFsmCtx.umlx_createAndAddProperty(fsmState.rdf_uri+"_prop_owner", "owner")
|
338
|
+
p2.uml_type=myClazz
|
339
|
+
p2.uml_visibility=::Cuml_VisibilityKind::Private
|
340
|
+
appFsmCtx.java_addGlobalGetter!(p2)
|
341
|
+
appFsmCtx.java_addGlobalSetter!(p2)
|
342
|
+
|
343
|
+
uml_region.each { |reg|
|
344
|
+
reg.uml_subvertex.each { |v|
|
345
|
+
v.processVertex(myClazz)
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
# Rajouter le contexte dans la classe
|
350
|
+
myClazz.java_addStateManagement
|
351
|
+
#Chercher ou la g�n�rer pour chaque transition
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
# self.mtk_writeSession("output/sm_#{self}.fsm") {
|
357
|
+
# write <<END
|
358
|
+
#%{
|
359
|
+
#// This file is a State Machine Compiler class
|
360
|
+
#// http://smc.sourceforge.net
|
361
|
+
#//
|
362
|
+
#%}
|
363
|
+
#// This FSM works for the Task class only and only the Task
|
364
|
+
#// class may instantiate it.
|
365
|
+
#%class
|
366
|
+
#Task
|
367
|
+
#%package TODOcom.acme.supercron
|
368
|
+
#%access package
|
369
|
+
#%start xxxxx
|
370
|
+
#%map yyyy
|
371
|
+
#%%
|
372
|
+
#END
|
373
|
+
# uml_region.each { |reg|
|
374
|
+
# reg.uml_subvertex.each { |v|
|
375
|
+
# write("//state type=#{v.class.name} name=#{v.uml_name} \n")
|
376
|
+
# write("#{v.fsm_name}\n")
|
377
|
+
# write("{\n")
|
378
|
+
# v.uml_outgoing.each { |tr|
|
379
|
+
# write(" "*2+"#{tr.uml_name}() //Transition\n")
|
380
|
+
# tr.uml_guard.each {|guard|
|
381
|
+
# write(" "*4+"[#{guard.uml_specification_one.uml_body}] // Guard condition\n")
|
382
|
+
# }
|
383
|
+
# write(" "*4+"#{tr.uml_target_one==tr.uml_source_one ? "nil" : tr.uml_target_one.fsm_name} //End State\n")
|
384
|
+
# write(" "*4+"{\n")
|
385
|
+
# write(" "*6+"//Action code goes here\n")
|
386
|
+
# tr.uml_trigger.each {|trig|
|
387
|
+
# write(" "*8+"#{trig.uml_name}; // call #{trig.class.name}\n")
|
388
|
+
# }
|
389
|
+
# write(" "*4+"}\n")
|
390
|
+
# }
|
391
|
+
# write("}\n")
|
392
|
+
# write("\n")
|
393
|
+
#
|
394
|
+
# }
|
395
|
+
# }
|
396
|
+
# write("}\n")
|
397
|
+
# }
|
398
|
+
end
|
399
|
+
end
|
400
|
+
module Muml_Stereotype
|
401
|
+
end
|
402
|
+
module Muml_Transition
|
403
|
+
end
|
404
|
+
module Muml_TransitionKind
|
405
|
+
end
|
406
|
+
module Muml_VisibilityKind
|
407
|
+
end
|
408
|
+
module Mrdf_Repository
|
409
|
+
def java_addStateMachine!()
|
410
|
+
each_value { |sm|
|
411
|
+
next unless sm.kind_of?(Muml_StateMachine)
|
412
|
+
sm.processStateMachine
|
413
|
+
}
|
414
|
+
end
|
415
|
+
end
|