Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uaaltools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
universAAL
uaaltools
Commits
afbad828
Commit
afbad828
authored
13 years ago
by
Erlend Stav
Browse files
Options
Downloads
Patches
Plain Diff
Initial support for restrictions added to transformation script
parent
59e54438
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
transformations/org.universaal.tools.transformationcommand/ontUML2Java.m2t
+82
-35
82 additions, 35 deletions
...rg.universaal.tools.transformationcommand/ontUML2Java.m2t
with
82 additions
and
35 deletions
transformations/org.universaal.tools.transformationcommand/ontUML2Java.m2t
+
82
−
35
View file @
afbad828
...
...
@@ -310,54 +310,101 @@ public interface ' ontologyName 'Namespace {
}\n'
}
uml.Class::genGetClassRestrictionsOnProperty() {
'
public static Restriction getClassRestrictionsOnProperty(String propURI) {
'
'
unprotect {
' //Add any maunual modifications within this block
'
}
'
// TODO: Restrictions are currently not supported by the transformation scripts
// Code entered in this section will not be overwritten by the transformations if
// the code is generated again
if (propURI == null)
return null;
// Typical code to include is something like:
// if (PROP_BEAMING_DIRECTION.equals(propURI))
// return Restriction.getAllValuesRestrictionWithCardinality(propURI,Location.MY_URI, 1, 0);
if (propURI == null) {
return null;
}
'
if (self.superClass.isEmpty()) {
' return null;\n'
}
else {
' return ' self.superClass.first().name '.getClassRestrictionsOnProperty(propURI);\n'
}
self.ownedMember->forEach(prop : uml.Property) {
' else if (PROP_' prop.toUpperFormat() '.equals(propURI)) {\n'
' return Restriction.getAllValuesRestrictionWithCardinality(propURI, \n'
' 'self.getURIExpressionForType(prop.type.name.trim())', ' prop.upper ', ' prop.lower ');\n'
' }\n'
}
self.getAssociations()->forEach (ass : uml.Association | ass.endType.first().name.trim().equals(self.name.trim()) ) {
' else if (PROP_' ass.memberEnd.last().toUpperFormat() '.equals(propURI)) {\n'
' return Restriction.getAllValuesRestrictionWithCardinality(propURI, \n'
' 'self.getURIExpressionForType(ass.endType.last().name.trim())', ' ass.memberEnd.last().upper ', ' ass.memberEnd.last().lower ');\n'
' }\n'
}
if (self.superClass.isEmpty()) {
' return null;\n'
}
else {
' return ' self.superClass.first().name '.getClassRestrictionsOnProperty(propURI);\n'
}
' }\n\n'
}
uml.Class::getURIExpressionForType(typeName : String):String {
if (typeName == null) {
typeName = "String"
}
if ((typeName == "Boolean") || (typeName == "Integer") || (typeName == "String")) {
return "TypeMapper.getDatatypeURI(" + typeName + ".class)"
}
else if (typeName == "UnlimitedNatural") {
return "TypeMapper.getDatatypeURI(Long.class)"
}
return typeName+".MY_URI"
}
uml.Class::genGetStandardPropertyURIs() {
// First, check if there is any property URIs to add. If not, do not generate this method
// First, find the number of properties URIs to add
var numberOfProperties:Integer = self.getAssociations().size()
var props:List = self.ownedMember->select(prop : uml.Property)
numberOfProperties = numberOfProperties + props.size()
if (numberOfProperties == 0) {
// Do not generate method if there are no properties to add
return
}
// Generate method
'
public static String[] getStandardPropertyURIs() {
//TODO: Code generation for this will be added soon...
'
// String[] inherited = Device.getStandardPropertyURIs();
// String[] toReturn = new String[inherited.length + 1];
// int i = 0;
// while (i < inherited.length) {
// toReturn[i] = inherited[i];
// i++;
// }
// toReturn[i] = PROP_MEASURED_VALUE;
// return toReturn;
' return null;
}\n'
'\n public static String[] getStandardPropertyURIs() {\n'
if (self.superClass.isEmpty()) {
' // First, create an array large enough to hold all my properties \n'
' String[] toReturn = new String['numberOfProperties'];\n\n'
' // Next, copy each of my property URIs into the array \n'
' int index = 0;\n'
}
else {
' // First, retrieve inherited properties and copy into an array large enough to hold inherited + own \n'
' String[] inherited = 'self.superClass.first().name'.getStandardPropertyURIs();\n'
' String[] toReturn = new String[inherited.length + 'numberOfProperties'];\n'
' System.arraycopy(inherited, 0, toReturn, 0, inherited.length);\n\n'
' // Next, copy each of my own property URIs into the array \n'
' int index = inherited.length;\n'
}
props->forEach(prop : uml.Property) {
' toReturn[index++] = PROP_' prop.toUpperFormat() ';\n'
}
self.getAssociations()->forEach (ass : uml.Association | ass.endType.first().name.trim().equals(self.name.trim()) ) {
' PROP_' ass.memberEnd.last().toUpperFormat() ';\n'
}
' return toReturn;\n'
' }\n'
}
uml.Class::genPropertiesForAssociations() {
...
...
@@ -396,7 +443,7 @@ public interface ' ontologyName 'Namespace {
self.genGetRDFSCommentDefault()
}
else {
' return "' self.ownedComment.first().body '";\n'
' return "' self.ownedComment.first().body
.trim()
'";\n'
}
' }'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment