From 6f911bf27ecf426e423ed15f17084e44eb2fa81a Mon Sep 17 00:00:00 2001 From: Maged Elaasar Date: Wed, 3 Apr 2024 03:14:46 -0700 Subject: [PATCH] Oml 2.6.0 (#118) * increment minor version to 2.6.0 * Contains various fixes and improvements: - Added Argument.getValue() - Fixed double parsing in DSL - Switched unsigned int to int instead of long - Switch antecedent and consequent params in OmlBuilder/OmlWrite.addRule - Added new API in OmlBuilder - Modified OmlConstant API to only retain Oml constants - Improved formatting PropertyValueAssertion in DSL --- io.opencaesar.oml.api.feature/feature.xml | 2 +- io.opencaesar.oml.api.feature/pom.xml | 2 +- io.opencaesar.oml.dsl.feature/feature.xml | 2 +- io.opencaesar.oml.dsl.feature/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.dsl.ide/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.dsl.ui.tests/pom.xml | 2 +- io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.dsl.ui/pom.xml | 2 +- io.opencaesar.oml.dsl/META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.dsl/pom.xml | 2 +- .../src/io/opencaesar/oml/dsl/Oml.xtext | 4 +- .../oml/dsl/formatting2/OmlFormatter.java | 3 + io.opencaesar.oml.edit/META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.edit/pom.xml | 2 +- .../ScalarEquivalenceAxiomItemProvider.java | 2 +- io.opencaesar.oml.editor/META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml.editor/pom.xml | 2 +- io.opencaesar.oml.repository/pom.xml | 2 +- io.opencaesar.oml.sdk.feature/feature.xml | 2 +- io.opencaesar.oml.sdk.feature/pom.xml | 2 +- io.opencaesar.oml.target/pom.xml | 2 +- io.opencaesar.oml/META-INF/MANIFEST.MF | 2 +- io.opencaesar.oml/pom.xml | 2 +- .../src-gen/io/opencaesar/oml/Argument.java | 11 + .../io/opencaesar/oml/DoubleLiteral.java | 2 +- .../src-gen/io/opencaesar/oml/OmlPackage.java | 80 ++++- .../PropertyCardinalityRestrictionAxiom.java | 6 +- .../oml/ScalarEquivalenceAxiom.java | 18 +- .../io/opencaesar/oml/impl/ArgumentImpl.java | 53 +++ .../oml/impl/BooleanLiteralImpl.java | 4 +- .../oml/impl/DecimalLiteralImpl.java | 4 +- .../oml/impl/DoubleLiteralImpl.java | 4 +- .../oml/impl/IntegerLiteralImpl.java | 4 +- .../opencaesar/oml/impl/OmlFactoryImpl.java | 39 ++- .../opencaesar/oml/impl/OmlPackageImpl.java | 42 ++- ...opertyCardinalityRestrictionAxiomImpl.java | 12 +- .../oml/impl/QuotedLiteralImpl.java | 4 +- .../oml/impl/ScalarEquivalenceAxiomImpl.java | 36 +- .../io/opencaesar/oml/util/OmlValidator.java | 35 +- .../src/io/opencaesar/oml/Oml.xcore | 35 +- .../io/opencaesar/oml/util/OmlBuilder.java | 327 +++++++++++------- .../io/opencaesar/oml/util/OmlConstants.java | 134 +++++-- .../src/io/opencaesar/oml/util/OmlRead.java | 36 +- .../src/io/opencaesar/oml/util/OmlWrite.java | 47 ++- pom.xml | 2 +- version.txt | 2 +- 48 files changed, 683 insertions(+), 307 deletions(-) diff --git a/io.opencaesar.oml.api.feature/feature.xml b/io.opencaesar.oml.api.feature/feature.xml index e52e6eaf..047c2703 100644 --- a/io.opencaesar.oml.api.feature/feature.xml +++ b/io.opencaesar.oml.api.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/io.opencaesar.oml.api.feature/pom.xml b/io.opencaesar.oml.api.feature/pom.xml index c3310265..ac456e39 100644 --- a/io.opencaesar.oml.api.feature/pom.xml +++ b/io.opencaesar.oml.api.feature/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.api.feature eclipse-feature diff --git a/io.opencaesar.oml.dsl.feature/feature.xml b/io.opencaesar.oml.dsl.feature/feature.xml index 233a2104..52dbf441 100644 --- a/io.opencaesar.oml.dsl.feature/feature.xml +++ b/io.opencaesar.oml.dsl.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/io.opencaesar.oml.dsl.feature/pom.xml b/io.opencaesar.oml.dsl.feature/pom.xml index da01fede..5bec9288 100644 --- a/io.opencaesar.oml.dsl.feature/pom.xml +++ b/io.opencaesar.oml.dsl.feature/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.dsl.feature eclipse-feature diff --git a/io.opencaesar.oml.dsl.ide/META-INF/MANIFEST.MF b/io.opencaesar.oml.dsl.ide/META-INF/MANIFEST.MF index cdbdafde..4444e47d 100644 --- a/io.opencaesar.oml.dsl.ide/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.dsl.ide/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ide Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-SymbolicName: io.opencaesar.oml.dsl.ide; singleton:=true Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/io.opencaesar.oml.dsl.ide/pom.xml b/io.opencaesar.oml.dsl.ide/pom.xml index 37268001..cfd3b945 100644 --- a/io.opencaesar.oml.dsl.ide/pom.xml +++ b/io.opencaesar.oml.dsl.ide/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.dsl.ide eclipse-plugin diff --git a/io.opencaesar.oml.dsl.ui.tests/META-INF/MANIFEST.MF b/io.opencaesar.oml.dsl.ui.tests/META-INF/MANIFEST.MF index e44e5828..28ca126a 100644 --- a/io.opencaesar.oml.dsl.ui.tests/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.dsl.ui.tests/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ui.tests Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-SymbolicName: io.opencaesar.oml.dsl.ui.tests; singleton:=true Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/io.opencaesar.oml.dsl.ui.tests/pom.xml b/io.opencaesar.oml.dsl.ui.tests/pom.xml index 07b738c1..bd7c992e 100644 --- a/io.opencaesar.oml.dsl.ui.tests/pom.xml +++ b/io.opencaesar.oml.dsl.ui.tests/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.dsl.ui.tests eclipse-test-plugin diff --git a/io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF b/io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF index 6102dd9c..d484fbf4 100644 --- a/io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.dsl.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl.ui Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-SymbolicName: io.opencaesar.oml.dsl.ui; singleton:=true Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/io.opencaesar.oml.dsl.ui/pom.xml b/io.opencaesar.oml.dsl.ui/pom.xml index e9d0d260..3258d9a8 100644 --- a/io.opencaesar.oml.dsl.ui/pom.xml +++ b/io.opencaesar.oml.dsl.ui/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.dsl.ui eclipse-plugin diff --git a/io.opencaesar.oml.dsl/META-INF/MANIFEST.MF b/io.opencaesar.oml.dsl/META-INF/MANIFEST.MF index fc20064e..e75b2d8f 100644 --- a/io.opencaesar.oml.dsl/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.dsl/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: io.opencaesar.oml.dsl Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-SymbolicName: io.opencaesar.oml.dsl; singleton:=true Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/io.opencaesar.oml.dsl/pom.xml b/io.opencaesar.oml.dsl/pom.xml index ed7f1976..323b17ce 100644 --- a/io.opencaesar.oml.dsl/pom.xml +++ b/io.opencaesar.oml.dsl/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.dsl eclipse-plugin diff --git a/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/Oml.xtext b/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/Oml.xtext index cbf93f9a..0f51c5b8 100644 --- a/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/Oml.xtext +++ b/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/Oml.xtext @@ -409,7 +409,7 @@ Integer returns ecore::EInt: UNSIGNED_INTEGER_STR | INTEGER_STR; Decimal returns Decimal: DECIMAL_STR; -Double returns ecore::EDouble: DOUBLE_STR; +Double returns Double: DOUBLE_STR; //---------------------------- @@ -421,7 +421,7 @@ terminal INTEGER_STR: ('+'|'-')? DIGIT+; terminal DECIMAL_STR: ('+'|'-')? (DIGIT+('.'DIGIT*)? | ('.'DIGIT+)); -terminal DOUBLE_STR: ('+'|'-')? (DIGIT+('.'DIGIT*)? | ('.'DIGIT+)) (('e'|'E') ('+'|'-')? DIGIT+)?; +terminal DOUBLE_STR: ('+'|'-')? (DIGIT+('.'DIGIT*)? | ('.'DIGIT+)) ('e'|'E') ('+'|'-')? DIGIT+; terminal STRING: ('"' (!('"'|'\\') | '\\'.)* '"') | ("'" (!("'"|'\\') | '\\'.)* "'") | ("'''" -> "'''") | '"""' -> '"""'; diff --git a/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/formatting2/OmlFormatter.java b/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/formatting2/OmlFormatter.java index b5013fc3..b10cca3e 100644 --- a/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/formatting2/OmlFormatter.java +++ b/io.opencaesar.oml.dsl/src/io/opencaesar/oml/dsl/formatting2/OmlFormatter.java @@ -472,6 +472,9 @@ protected void _format(LiteralEnumerationAxiom axiom, IFormattableDocument doc) protected void _format(PropertyValueAssertion assertion, IFormattableDocument doc) { doc.append(feature(assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY), oneSpace()); + if (assertion.getContainedValue() != null) { + doc.format(assertion.getContainedValue()); + } } protected void _format(TypePredicate predicate, IFormattableDocument doc) { diff --git a/io.opencaesar.oml.edit/META-INF/MANIFEST.MF b/io.opencaesar.oml.edit/META-INF/MANIFEST.MF index 21bf43ee..dda9f9d2 100644 --- a/io.opencaesar.oml.edit/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.edit/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: io.opencaesar.oml.edit;singleton:=true Automatic-Module-Name: io.opencaesar.oml.edit -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-ClassPath: . Bundle-Activator: io.opencaesar.oml.provider.OmlEditPlugin$Implementation Bundle-Vendor: %providerName diff --git a/io.opencaesar.oml.edit/pom.xml b/io.opencaesar.oml.edit/pom.xml index 9b64835a..506b55cb 100644 --- a/io.opencaesar.oml.edit/pom.xml +++ b/io.opencaesar.oml.edit/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.edit eclipse-plugin diff --git a/io.opencaesar.oml.edit/src-gen/io/opencaesar/oml/provider/ScalarEquivalenceAxiomItemProvider.java b/io.opencaesar.oml.edit/src-gen/io/opencaesar/oml/provider/ScalarEquivalenceAxiomItemProvider.java index 9a31e3f7..d5fd4f73 100644 --- a/io.opencaesar.oml.edit/src-gen/io/opencaesar/oml/provider/ScalarEquivalenceAxiomItemProvider.java +++ b/io.opencaesar.oml.edit/src-gen/io/opencaesar/oml/provider/ScalarEquivalenceAxiomItemProvider.java @@ -281,7 +281,7 @@ public Object getImage(Object object) { */ @Override public String getText(Object object) { - Long labelValue = ((ScalarEquivalenceAxiom)object).getLength(); + Integer labelValue = ((ScalarEquivalenceAxiom)object).getLength(); String label = labelValue == null ? null : labelValue.toString(); return label == null || label.length() == 0 ? getString("_UI_ScalarEquivalenceAxiom_type") : diff --git a/io.opencaesar.oml.editor/META-INF/MANIFEST.MF b/io.opencaesar.oml.editor/META-INF/MANIFEST.MF index 81f6e0e9..bdf4d6bf 100644 --- a/io.opencaesar.oml.editor/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml.editor/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: io.opencaesar.oml.editor;singleton:=true Automatic-Module-Name: io.opencaesar.oml.editor -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-ClassPath: . Bundle-Activator: io.opencaesar.oml.presentation.OmlEditorPlugin$Implementation Bundle-Vendor: %providerName diff --git a/io.opencaesar.oml.editor/pom.xml b/io.opencaesar.oml.editor/pom.xml index efd53725..0de770ea 100644 --- a/io.opencaesar.oml.editor/pom.xml +++ b/io.opencaesar.oml.editor/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.editor eclipse-plugin diff --git a/io.opencaesar.oml.repository/pom.xml b/io.opencaesar.oml.repository/pom.xml index 53f0f758..4fff0546 100644 --- a/io.opencaesar.oml.repository/pom.xml +++ b/io.opencaesar.oml.repository/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.repository eclipse-repository diff --git a/io.opencaesar.oml.sdk.feature/feature.xml b/io.opencaesar.oml.sdk.feature/feature.xml index d0c39e68..586f95b8 100644 --- a/io.opencaesar.oml.sdk.feature/feature.xml +++ b/io.opencaesar.oml.sdk.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/io.opencaesar.oml.sdk.feature/pom.xml b/io.opencaesar.oml.sdk.feature/pom.xml index f7d0c38f..08c6521a 100644 --- a/io.opencaesar.oml.sdk.feature/pom.xml +++ b/io.opencaesar.oml.sdk.feature/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.sdk.feature eclipse-feature diff --git a/io.opencaesar.oml.target/pom.xml b/io.opencaesar.oml.target/pom.xml index cab0e291..42423b4d 100644 --- a/io.opencaesar.oml.target/pom.xml +++ b/io.opencaesar.oml.target/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml.target eclipse-target-definition diff --git a/io.opencaesar.oml/META-INF/MANIFEST.MF b/io.opencaesar.oml/META-INF/MANIFEST.MF index 5870e78c..96259f8c 100644 --- a/io.opencaesar.oml/META-INF/MANIFEST.MF +++ b/io.opencaesar.oml/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: io.opencaesar.oml;singleton:=true Automatic-Module-Name: io.opencaesar.oml -Bundle-Version: 2.5.0 +Bundle-Version: 2.6.0 Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/io.opencaesar.oml/pom.xml b/io.opencaesar.oml/pom.xml index ce4b1609..a7cc6435 100644 --- a/io.opencaesar.oml/pom.xml +++ b/io.opencaesar.oml/pom.xml @@ -4,7 +4,7 @@ io.opencaesar.oml io.opencaesar.oml.parent - 2.5.0 + 2.6.0 io.opencaesar.oml eclipse-plugin diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/Argument.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/Argument.java index cfbb7141..bd450e09 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/Argument.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/Argument.java @@ -117,4 +117,15 @@ public interface Argument extends Element { */ void setInstance(NamedInstance value); + /** + * + * + * + * Gets the value of the annotation + * + * @model kind="operation" unique="false" + * @generated + */ + Object getValue(); + } // Argument diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/DoubleLiteral.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/DoubleLiteral.java index 810dcf6e..30e97226 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/DoubleLiteral.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/DoubleLiteral.java @@ -51,7 +51,7 @@ public interface DoubleLiteral extends Literal { * @return the value of the 'Value' attribute. * @see #setValue(Double) * @see io.opencaesar.oml.OmlPackage#getDoubleLiteral_Value() - * @model default="0.0" unique="false" + * @model default="0.0" unique="false" dataType="io.opencaesar.oml.Double" * @generated */ Double getValue(); diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/OmlPackage.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/OmlPackage.java index c39fa405..c646e968 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/OmlPackage.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/OmlPackage.java @@ -703,6 +703,15 @@ public interface OmlPackage extends EPackage { */ int ARGUMENT___EXTRA_VALIDATE__DIAGNOSTICCHAIN_MAP = ELEMENT___EXTRA_VALIDATE__DIAGNOSTICCHAIN_MAP; + /** + * The operation id for the 'Get Value' operation. + * + * + * @generated + * @ordered + */ + int ARGUMENT___GET_VALUE = ELEMENT_OPERATION_COUNT + 0; + /** * The number of operations of the 'Argument' class. * @@ -710,7 +719,7 @@ public interface OmlPackage extends EPackage { * @generated * @ordered */ - int ARGUMENT_OPERATION_COUNT = ELEMENT_OPERATION_COUNT + 0; + int ARGUMENT_OPERATION_COUNT = ELEMENT_OPERATION_COUNT + 1; /** * The meta object id for the '{@link io.opencaesar.oml.impl.LiteralImpl Literal}' class. @@ -9374,7 +9383,7 @@ public interface OmlPackage extends EPackage { * The meta object id for the 'Unsigned Integer' data type. * * - * @see java.lang.Long + * @see java.lang.Integer * @see io.opencaesar.oml.impl.OmlPackageImpl#getUnsignedInteger() * @generated */ @@ -9390,6 +9399,16 @@ public interface OmlPackage extends EPackage { */ int DECIMAL = 83; + /** + * The meta object id for the 'Double' data type. + * + * + * @see java.lang.Double + * @see io.opencaesar.oml.impl.OmlPackageImpl#getDouble() + * @generated + */ + int DOUBLE = 84; + /** * The meta object id for the 'ID' data type. * @@ -9398,7 +9417,7 @@ public interface OmlPackage extends EPackage { * @see io.opencaesar.oml.impl.OmlPackageImpl#getID() * @generated */ - int ID = 84; + int ID = 85; /** * The meta object id for the 'Namespace' data type. @@ -9408,7 +9427,7 @@ public interface OmlPackage extends EPackage { * @see io.opencaesar.oml.impl.OmlPackageImpl#getNamespace() * @generated */ - int NAMESPACE = 85; + int NAMESPACE = 86; /** @@ -9776,6 +9795,16 @@ public interface OmlPackage extends EPackage { */ EReference getArgument_Instance(); + /** + * Returns the meta object for the '{@link io.opencaesar.oml.Argument#getValue() Get Value}' operation. + * + * + * @return the meta object for the 'Get Value' operation. + * @see io.opencaesar.oml.Argument#getValue() + * @generated + */ + EOperation getArgument__GetValue(); + /** * Returns the meta object for class '{@link io.opencaesar.oml.Literal Literal}'. * @@ -12604,20 +12633,20 @@ public interface OmlPackage extends EPackage { * * * @return the meta object for data type 'Unsigned Int'. - * @model instanceClass="long" - * extendedMetaData="minInclusive='0' maxInclusive='4294967295'" + * @model instanceClass="int" + * extendedMetaData="minInclusive='0' maxInclusive='2147483647'" * @generated */ EDataType getUnsignedInt(); /** - * Returns the meta object for data type '{@link java.lang.Long Unsigned Integer}'. + * Returns the meta object for data type '{@link java.lang.Integer Unsigned Integer}'. * * * @return the meta object for data type 'Unsigned Integer'. - * @see java.lang.Long - * @model instanceClass="java.lang.Long" - * extendedMetaData="minInclusive='0' maxInclusive='4294967295'" + * @see java.lang.Integer + * @model instanceClass="java.lang.Integer" + * extendedMetaData="minInclusive='0' maxInclusive='2147483647'" * @generated */ EDataType getUnsignedInteger(); @@ -12634,6 +12663,17 @@ public interface OmlPackage extends EPackage { */ EDataType getDecimal(); + /** + * Returns the meta object for data type '{@link java.lang.Double Double}'. + * + * + * @return the meta object for data type 'Double'. + * @see java.lang.Double + * @model instanceClass="java.lang.Double" + * @generated + */ + EDataType getDouble(); + /** * Returns the meta object for data type '{@link java.lang.String ID}'. * @@ -12979,6 +13019,14 @@ interface Literals { */ EReference ARGUMENT__INSTANCE = eINSTANCE.getArgument_Instance(); + /** + * The meta object literal for the 'Get Value' operation. + * + * + * @generated + */ + EOperation ARGUMENT___GET_VALUE = eINSTANCE.getArgument__GetValue(); + /** * The meta object literal for the '{@link io.opencaesar.oml.impl.LiteralImpl Literal}' class. * @@ -15304,7 +15352,7 @@ interface Literals { * The meta object literal for the 'Unsigned Integer' data type. * * - * @see java.lang.Long + * @see java.lang.Integer * @see io.opencaesar.oml.impl.OmlPackageImpl#getUnsignedInteger() * @generated */ @@ -15320,6 +15368,16 @@ interface Literals { */ EDataType DECIMAL = eINSTANCE.getDecimal(); + /** + * The meta object literal for the 'Double' data type. + * + * + * @see java.lang.Double + * @see io.opencaesar.oml.impl.OmlPackageImpl#getDouble() + * @generated + */ + EDataType DOUBLE = eINSTANCE.getDouble(); + /** * The meta object literal for the 'ID' data type. * diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/PropertyCardinalityRestrictionAxiom.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/PropertyCardinalityRestrictionAxiom.java index 232356a3..6e8823d1 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/PropertyCardinalityRestrictionAxiom.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/PropertyCardinalityRestrictionAxiom.java @@ -82,12 +82,12 @@ public interface PropertyCardinalityRestrictionAxiom extends PropertyRestriction * The value of the cardinality specified by this axiom (default is 1) * * @return the value of the 'Cardinality' attribute. - * @see #setCardinality(long) + * @see #setCardinality(int) * @see io.opencaesar.oml.OmlPackage#getPropertyCardinalityRestrictionAxiom_Cardinality() * @model default="1" unique="false" dataType="io.opencaesar.oml.UnsignedInt" required="true" * @generated */ - long getCardinality(); + int getCardinality(); /** * Sets the value of the '{@link io.opencaesar.oml.PropertyCardinalityRestrictionAxiom#getCardinality Cardinality}' attribute. @@ -97,7 +97,7 @@ public interface PropertyCardinalityRestrictionAxiom extends PropertyRestriction * @see #getCardinality() * @generated */ - void setCardinality(long value); + void setCardinality(int value); /** * Returns the value of the 'Range' reference. diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/ScalarEquivalenceAxiom.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/ScalarEquivalenceAxiom.java index 46b13338..a0982c75 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/ScalarEquivalenceAxiom.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/ScalarEquivalenceAxiom.java @@ -123,12 +123,12 @@ public interface ScalarEquivalenceAxiom extends Axiom { * The exact length of the literals of this scalar * * @return the value of the 'Length' attribute. - * @see #setLength(Long) + * @see #setLength(Integer) * @see io.opencaesar.oml.OmlPackage#getScalarEquivalenceAxiom_Length() * @model unique="false" dataType="io.opencaesar.oml.UnsignedInteger" * @generated */ - Long getLength(); + Integer getLength(); /** * Sets the value of the '{@link io.opencaesar.oml.ScalarEquivalenceAxiom#getLength Length}' attribute. @@ -138,7 +138,7 @@ public interface ScalarEquivalenceAxiom extends Axiom { * @see #getLength() * @generated */ - void setLength(Long value); + void setLength(Integer value); /** * Returns the value of the 'Min Length' attribute. @@ -148,12 +148,12 @@ public interface ScalarEquivalenceAxiom extends Axiom { * The minimum length of the literals of this scalar * * @return the value of the 'Min Length' attribute. - * @see #setMinLength(Long) + * @see #setMinLength(Integer) * @see io.opencaesar.oml.OmlPackage#getScalarEquivalenceAxiom_MinLength() * @model unique="false" dataType="io.opencaesar.oml.UnsignedInteger" * @generated */ - Long getMinLength(); + Integer getMinLength(); /** * Sets the value of the '{@link io.opencaesar.oml.ScalarEquivalenceAxiom#getMinLength Min Length}' attribute. @@ -163,7 +163,7 @@ public interface ScalarEquivalenceAxiom extends Axiom { * @see #getMinLength() * @generated */ - void setMinLength(Long value); + void setMinLength(Integer value); /** * Returns the value of the 'Max Length' attribute. @@ -173,12 +173,12 @@ public interface ScalarEquivalenceAxiom extends Axiom { * The maximum length of the literals of this scalar * * @return the value of the 'Max Length' attribute. - * @see #setMaxLength(Long) + * @see #setMaxLength(Integer) * @see io.opencaesar.oml.OmlPackage#getScalarEquivalenceAxiom_MaxLength() * @model unique="false" dataType="io.opencaesar.oml.UnsignedInteger" * @generated */ - Long getMaxLength(); + Integer getMaxLength(); /** * Sets the value of the '{@link io.opencaesar.oml.ScalarEquivalenceAxiom#getMaxLength Max Length}' attribute. @@ -188,7 +188,7 @@ public interface ScalarEquivalenceAxiom extends Axiom { * @see #getMaxLength() * @generated */ - void setMaxLength(Long value); + void setMaxLength(Integer value); /** * Returns the value of the 'Pattern' attribute. diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ArgumentImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ArgumentImpl.java index 531f939a..2d71c082 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ArgumentImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ArgumentImpl.java @@ -19,13 +19,18 @@ package io.opencaesar.oml.impl; import io.opencaesar.oml.Argument; +import io.opencaesar.oml.Element; import io.opencaesar.oml.Literal; import io.opencaesar.oml.NamedInstance; import io.opencaesar.oml.OmlPackage; +import java.lang.reflect.InvocationTargetException; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; + import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; @@ -214,6 +219,40 @@ public void setInstance(NamedInstance newInstance) { eNotify(new ENotificationImpl(this, Notification.SET, OmlPackage.ARGUMENT__INSTANCE, oldInstance, instance)); } + /** + * + * + * @generated + */ + @Override + public Object getValue() { + Object _xifexpression = null; + String _variable = this.getVariable(); + boolean _tripleNotEquals = (_variable != null); + if (_tripleNotEquals) { + _xifexpression = this.getVariable(); + } + else { + Element _xifexpression_1 = null; + Literal _literal = this.getLiteral(); + boolean _tripleNotEquals_1 = (_literal != null); + if (_tripleNotEquals_1) { + _xifexpression_1 = this.getLiteral(); + } + else { + NamedInstance _xifexpression_2 = null; + NamedInstance _instance = this.getInstance(); + boolean _tripleNotEquals_2 = (_instance != null); + if (_tripleNotEquals_2) { + _xifexpression_2 = this.getInstance(); + } + _xifexpression_1 = _xifexpression_2; + } + _xifexpression = _xifexpression_1; + } + return _xifexpression; + } + /** * * @@ -307,6 +346,20 @@ public boolean eIsSet(int featureID) { return super.eIsSet(featureID); } + /** + * + * + * @generated + */ + @Override + public Object eInvoke(int operationID, EList arguments) throws InvocationTargetException { + switch (operationID) { + case OmlPackage.ARGUMENT___GET_VALUE: + return getValue(); + } + return super.eInvoke(operationID, arguments); + } + /** * * diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/BooleanLiteralImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/BooleanLiteralImpl.java index 4ebd4c58..45c01964 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/BooleanLiteralImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/BooleanLiteralImpl.java @@ -21,8 +21,6 @@ import io.opencaesar.oml.BooleanLiteral; import io.opencaesar.oml.OmlPackage; -import io.opencaesar.oml.util.OmlConstants; - import java.lang.reflect.InvocationTargetException; import org.eclipse.emf.common.notify.Notification; @@ -126,7 +124,7 @@ public boolean isValue() { */ @Override public String getTypeIri() { - return (OmlConstants.XSD_NS + "boolean"); + return "http://www.w3.org/2001/XMLSchema#boolean"; } /** diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DecimalLiteralImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DecimalLiteralImpl.java index c1d26c6b..3c9fc631 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DecimalLiteralImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DecimalLiteralImpl.java @@ -21,8 +21,6 @@ import io.opencaesar.oml.DecimalLiteral; import io.opencaesar.oml.OmlPackage; -import io.opencaesar.oml.util.OmlConstants; - import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; @@ -118,7 +116,7 @@ public void setValue(BigDecimal newValue) { */ @Override public String getTypeIri() { - return (OmlConstants.XSD_NS + "decimal"); + return "http://www.w3.org/2001/XMLSchema#decimal"; } /** diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DoubleLiteralImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DoubleLiteralImpl.java index 4d8e6b49..15952b37 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DoubleLiteralImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/DoubleLiteralImpl.java @@ -21,8 +21,6 @@ import io.opencaesar.oml.DoubleLiteral; import io.opencaesar.oml.OmlPackage; -import io.opencaesar.oml.util.OmlConstants; - import java.lang.reflect.InvocationTargetException; import org.eclipse.emf.common.notify.Notification; @@ -116,7 +114,7 @@ public void setValue(Double newValue) { */ @Override public String getTypeIri() { - return (OmlConstants.XSD_NS + "double"); + return "http://www.w3.org/2001/XMLSchema#double"; } /** diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/IntegerLiteralImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/IntegerLiteralImpl.java index a22039e2..8a6360d8 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/IntegerLiteralImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/IntegerLiteralImpl.java @@ -21,8 +21,6 @@ import io.opencaesar.oml.IntegerLiteral; import io.opencaesar.oml.OmlPackage; -import io.opencaesar.oml.util.OmlConstants; - import java.lang.reflect.InvocationTargetException; import org.eclipse.emf.common.notify.Notification; @@ -116,7 +114,7 @@ public void setValue(Integer newValue) { */ @Override public String getTypeIri() { - return (OmlConstants.XSD_NS + "integer"); + return "http://www.w3.org/2001/XMLSchema#integer"; } /** diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlFactoryImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlFactoryImpl.java index a173a657..c3dac57b 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlFactoryImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlFactoryImpl.java @@ -152,6 +152,8 @@ public Object createFromString(EDataType eDataType, String initialValue) { return createUnsignedIntegerFromString(eDataType, initialValue); case OmlPackage.DECIMAL: return createDecimalFromString(eDataType, initialValue); + case OmlPackage.DOUBLE: + return createDoubleFromString(eDataType, initialValue); case OmlPackage.ID: return createIDFromString(eDataType, initialValue); case OmlPackage.NAMESPACE: @@ -183,6 +185,8 @@ public String convertToString(EDataType eDataType, Object instanceValue) { return convertUnsignedIntegerToString(eDataType, instanceValue); case OmlPackage.DECIMAL: return convertDecimalToString(eDataType, instanceValue); + case OmlPackage.DOUBLE: + return convertDoubleToString(eDataType, instanceValue); case OmlPackage.ID: return convertIDToString(eDataType, instanceValue); case OmlPackage.NAMESPACE: @@ -794,8 +798,8 @@ public String convertImportKindToString(EDataType eDataType, Object instanceValu * * @generated */ - public Long createUnsignedIntFromString(EDataType eDataType, String initialValue) { - return (Long)super.createFromString(eDataType, initialValue); + public Integer createUnsignedIntFromString(EDataType eDataType, String initialValue) { + return (Integer)super.createFromString(eDataType, initialValue); } /** @@ -812,8 +816,8 @@ public String convertUnsignedIntToString(EDataType eDataType, Object instanceVal * * @generated */ - public Long createUnsignedIntegerFromString(EDataType eDataType, String initialValue) { - return (Long)super.createFromString(eDataType, initialValue); + public Integer createUnsignedIntegerFromString(EDataType eDataType, String initialValue) { + return (Integer)super.createFromString(eDataType, initialValue); } /** @@ -843,6 +847,33 @@ public String convertDecimalToString(EDataType eDataType, Object instanceValue) return XMLTypeFactory.eINSTANCE.convertToString(XMLTypePackage.Literals.DECIMAL, instanceValue); } + /** + * + * + * @generated + */ + public Double createDoubleFromString(EDataType eDataType, String initialValue) { + return (Double)super.createFromString(eDataType, initialValue); + } + + /** + * + * + * @generated + */ + public String convertDouble(Double it) { + return String.format("%.2E", it); + } + + /** + * + * + * @generated + */ + public String convertDoubleToString(EDataType eDataType, Object instanceValue) { + return convertDouble((Double)instanceValue); + } + /** * * diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlPackageImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlPackageImpl.java index 9d679a87..fd96d187 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlPackageImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/OmlPackageImpl.java @@ -714,6 +714,13 @@ public class OmlPackageImpl extends EPackageImpl implements OmlPackage { */ private EDataType decimalEDataType = null; + /** + * + * + * @generated + */ + private EDataType doubleEDataType = null; + /** * * @@ -1151,6 +1158,16 @@ public EReference getArgument_Instance() { return (EReference)argumentEClass.getEStructuralFeatures().get(2); } + /** + * + * + * @generated + */ + @Override + public EOperation getArgument__GetValue() { + return argumentEClass.getEOperations().get(0); + } + /** * * @@ -3891,6 +3908,16 @@ public EDataType getDecimal() { return decimalEDataType; } + /** + * + * + * @generated + */ + @Override + public EDataType getDouble() { + return doubleEDataType; + } + /** * * @@ -3983,6 +4010,7 @@ public void createPackageContents() { createEAttribute(argumentEClass, ARGUMENT__VARIABLE); createEReference(argumentEClass, ARGUMENT__LITERAL); createEReference(argumentEClass, ARGUMENT__INSTANCE); + createEOperation(argumentEClass, ARGUMENT___GET_VALUE); literalEClass = createEClass(LITERAL); createEOperation(literalEClass, LITERAL___GET_VALUE); @@ -4329,6 +4357,7 @@ public void createPackageContents() { unsignedIntEDataType = createEDataType(UNSIGNED_INT); unsignedIntegerEDataType = createEDataType(UNSIGNED_INTEGER); decimalEDataType = createEDataType(DECIMAL); + doubleEDataType = createEDataType(DOUBLE); idEDataType = createEDataType(ID); namespaceEDataType = createEDataType(NAMESPACE); } @@ -4515,6 +4544,8 @@ public void initializePackageContents() { initEReference(getArgument_Literal(), this.getLiteral(), null, "literal", null, 0, 1, Argument.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getArgument_Instance(), this.getNamedInstance(), null, "instance", null, 0, 1, Argument.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEOperation(getArgument__GetValue(), theEcorePackage.getEJavaObject(), "getValue", 0, 1, !IS_UNIQUE, IS_ORDERED); + initEClass(literalEClass, Literal.class, "Literal", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEOperation(getLiteral__GetValue(), theEcorePackage.getEJavaObject(), "getValue", 0, 1, !IS_UNIQUE, IS_ORDERED); @@ -4925,7 +4956,7 @@ public void initializePackageContents() { initEOperation(getDecimalLiteral__GetTypeIri(), theEcorePackage.getEString(), "getTypeIri", 0, 1, !IS_UNIQUE, IS_ORDERED); initEClass(doubleLiteralEClass, DoubleLiteral.class, "DoubleLiteral", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getDoubleLiteral_Value(), theEcorePackage.getEDoubleObject(), "value", "0.0", 0, 1, DoubleLiteral.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDoubleLiteral_Value(), this.getDouble(), "value", "0.0", 0, 1, DoubleLiteral.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEOperation(getDoubleLiteral__GetTypeIri(), theEcorePackage.getEString(), "getTypeIri", 0, 1, !IS_UNIQUE, IS_ORDERED); @@ -4956,9 +4987,10 @@ public void initializePackageContents() { addEEnumLiteral(importKindEEnum, ImportKind.INCLUSION); // Initialize data types - initEDataType(unsignedIntEDataType, long.class, "UnsignedInt", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(unsignedIntegerEDataType, Long.class, "UnsignedInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(unsignedIntEDataType, int.class, "UnsignedInt", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(unsignedIntegerEDataType, Integer.class, "UnsignedInteger", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); initEDataType(decimalEDataType, BigDecimal.class, "Decimal", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(doubleEDataType, Double.class, "Double", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); initEDataType(idEDataType, String.class, "ID", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); initEDataType(namespaceEDataType, String.class, "Namespace", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); @@ -5535,14 +5567,14 @@ protected void createExtendedMetaDataAnnotations() { source, new String[] { "minInclusive", "0", - "maxInclusive", "4294967295" + "maxInclusive", "2147483647" }); addAnnotation (unsignedIntegerEDataType, source, new String[] { "minInclusive", "0", - "maxInclusive", "4294967295" + "maxInclusive", "2147483647" }); addAnnotation (decimalEDataType, diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/PropertyCardinalityRestrictionAxiomImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/PropertyCardinalityRestrictionAxiomImpl.java index 66ccfa20..b41efb8d 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/PropertyCardinalityRestrictionAxiomImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/PropertyCardinalityRestrictionAxiomImpl.java @@ -74,7 +74,7 @@ public class PropertyCardinalityRestrictionAxiomImpl extends PropertyRestriction * @generated * @ordered */ - protected static final long CARDINALITY_EDEFAULT = 1L; + protected static final int CARDINALITY_EDEFAULT = 1; /** * The cached value of the '{@link #getCardinality() Cardinality}' attribute. @@ -84,7 +84,7 @@ public class PropertyCardinalityRestrictionAxiomImpl extends PropertyRestriction * @generated * @ordered */ - protected long cardinality = CARDINALITY_EDEFAULT; + protected int cardinality = CARDINALITY_EDEFAULT; /** * The cached value of the '{@link #getRange() Range}' reference. @@ -144,7 +144,7 @@ public void setKind(CardinalityRestrictionKind newKind) { * @generated */ @Override - public long getCardinality() { + public int getCardinality() { return cardinality; } @@ -154,8 +154,8 @@ public long getCardinality() { * @generated */ @Override - public void setCardinality(long newCardinality) { - long oldCardinality = cardinality; + public void setCardinality(int newCardinality) { + int oldCardinality = cardinality; cardinality = newCardinality; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, OmlPackage.PROPERTY_CARDINALITY_RESTRICTION_AXIOM__CARDINALITY, oldCardinality, cardinality)); @@ -232,7 +232,7 @@ public void eSet(int featureID, Object newValue) { setKind((CardinalityRestrictionKind)newValue); return; case OmlPackage.PROPERTY_CARDINALITY_RESTRICTION_AXIOM__CARDINALITY: - setCardinality((Long)newValue); + setCardinality((Integer)newValue); return; case OmlPackage.PROPERTY_CARDINALITY_RESTRICTION_AXIOM__RANGE: setRange((Type)newValue); diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/QuotedLiteralImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/QuotedLiteralImpl.java index bf1e1d37..d63bf407 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/QuotedLiteralImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/QuotedLiteralImpl.java @@ -23,8 +23,6 @@ import io.opencaesar.oml.QuotedLiteral; import io.opencaesar.oml.Scalar; -import io.opencaesar.oml.util.OmlConstants; - import java.lang.reflect.InvocationTargetException; import org.eclipse.emf.common.notify.Notification; @@ -254,7 +252,7 @@ public String getTypeIri() { _xifexpression = this.getType().getIri(); } else { - _xifexpression = (OmlConstants.XSD_NS + "string"); + _xifexpression = "http://www.w3.org/2001/XMLSchema#string"; } return _xifexpression; } diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ScalarEquivalenceAxiomImpl.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ScalarEquivalenceAxiomImpl.java index 390c7d22..7fa3b792 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ScalarEquivalenceAxiomImpl.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/impl/ScalarEquivalenceAxiomImpl.java @@ -80,7 +80,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected static final Long LENGTH_EDEFAULT = null; + protected static final Integer LENGTH_EDEFAULT = null; /** * The cached value of the '{@link #getLength() Length}' attribute. @@ -90,7 +90,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected Long length = LENGTH_EDEFAULT; + protected Integer length = LENGTH_EDEFAULT; /** * The default value of the '{@link #getMinLength() Min Length}' attribute. @@ -100,7 +100,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected static final Long MIN_LENGTH_EDEFAULT = null; + protected static final Integer MIN_LENGTH_EDEFAULT = null; /** * The cached value of the '{@link #getMinLength() Min Length}' attribute. @@ -110,7 +110,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected Long minLength = MIN_LENGTH_EDEFAULT; + protected Integer minLength = MIN_LENGTH_EDEFAULT; /** * The default value of the '{@link #getMaxLength() Max Length}' attribute. @@ -120,7 +120,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected static final Long MAX_LENGTH_EDEFAULT = null; + protected static final Integer MAX_LENGTH_EDEFAULT = null; /** * The cached value of the '{@link #getMaxLength() Max Length}' attribute. @@ -130,7 +130,7 @@ public class ScalarEquivalenceAxiomImpl extends AxiomImpl implements ScalarEquiv * @generated * @ordered */ - protected Long maxLength = MAX_LENGTH_EDEFAULT; + protected Integer maxLength = MAX_LENGTH_EDEFAULT; /** * The default value of the '{@link #getPattern() Pattern}' attribute. @@ -330,7 +330,7 @@ else if (eNotificationRequired()) * @generated */ @Override - public Long getLength() { + public Integer getLength() { return length; } @@ -340,8 +340,8 @@ public Long getLength() { * @generated */ @Override - public void setLength(Long newLength) { - Long oldLength = length; + public void setLength(Integer newLength) { + Integer oldLength = length; length = newLength; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, OmlPackage.SCALAR_EQUIVALENCE_AXIOM__LENGTH, oldLength, length)); @@ -353,7 +353,7 @@ public void setLength(Long newLength) { * @generated */ @Override - public Long getMinLength() { + public Integer getMinLength() { return minLength; } @@ -363,8 +363,8 @@ public Long getMinLength() { * @generated */ @Override - public void setMinLength(Long newMinLength) { - Long oldMinLength = minLength; + public void setMinLength(Integer newMinLength) { + Integer oldMinLength = minLength; minLength = newMinLength; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, OmlPackage.SCALAR_EQUIVALENCE_AXIOM__MIN_LENGTH, oldMinLength, minLength)); @@ -376,7 +376,7 @@ public void setMinLength(Long newMinLength) { * @generated */ @Override - public Long getMaxLength() { + public Integer getMaxLength() { return maxLength; } @@ -386,8 +386,8 @@ public Long getMaxLength() { * @generated */ @Override - public void setMaxLength(Long newMaxLength) { - Long oldMaxLength = maxLength; + public void setMaxLength(Integer newMaxLength) { + Integer oldMaxLength = maxLength; maxLength = newMaxLength; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, OmlPackage.SCALAR_EQUIVALENCE_AXIOM__MAX_LENGTH, oldMaxLength, maxLength)); @@ -743,13 +743,13 @@ public void eSet(int featureID, Object newValue) { setOwningScalar((Scalar)newValue); return; case OmlPackage.SCALAR_EQUIVALENCE_AXIOM__LENGTH: - setLength((Long)newValue); + setLength((Integer)newValue); return; case OmlPackage.SCALAR_EQUIVALENCE_AXIOM__MIN_LENGTH: - setMinLength((Long)newValue); + setMinLength((Integer)newValue); return; case OmlPackage.SCALAR_EQUIVALENCE_AXIOM__MAX_LENGTH: - setMaxLength((Long)newValue); + setMaxLength((Integer)newValue); return; case OmlPackage.SCALAR_EQUIVALENCE_AXIOM__PATTERN: setPattern((String)newValue); diff --git a/io.opencaesar.oml/src-gen/io/opencaesar/oml/util/OmlValidator.java b/io.opencaesar.oml/src-gen/io/opencaesar/oml/util/OmlValidator.java index d5878349..1cd9ad5b 100644 --- a/io.opencaesar.oml/src-gen/io/opencaesar/oml/util/OmlValidator.java +++ b/io.opencaesar.oml/src-gen/io/opencaesar/oml/util/OmlValidator.java @@ -286,11 +286,13 @@ protected boolean validate(int classifierID, Object value, DiagnosticChain diagn case OmlPackage.IMPORT_KIND: return validateImportKind((ImportKind)value, diagnostics, context); case OmlPackage.UNSIGNED_INT: - return validateUnsignedInt((Long)value, diagnostics, context); + return validateUnsignedInt((Integer)value, diagnostics, context); case OmlPackage.UNSIGNED_INTEGER: - return validateUnsignedInteger((Long)value, diagnostics, context); + return validateUnsignedInteger((Integer)value, diagnostics, context); case OmlPackage.DECIMAL: return validateDecimal((BigDecimal)value, diagnostics, context); + case OmlPackage.DOUBLE: + return validateDouble((Double)value, diagnostics, context); case OmlPackage.ID: return validateID((String)value, diagnostics, context); case OmlPackage.NAMESPACE: @@ -1814,7 +1816,7 @@ public boolean validateImportKind(ImportKind importKind, DiagnosticChain diagnos * * @generated */ - public boolean validateUnsignedInt(long unsignedInt, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInt(int unsignedInt, DiagnosticChain diagnostics, Map context) { boolean result = validateUnsignedInt_Min(unsignedInt, diagnostics, context); if (result || diagnostics != null) result &= validateUnsignedInt_Max(unsignedInt, diagnostics, context); return result; @@ -1826,7 +1828,7 @@ public boolean validateUnsignedInt(long unsignedInt, DiagnosticChain diagnostics * @generated * @see #validateUnsignedInt_Min */ - public static final long UNSIGNED_INT__MIN__VALUE = 0L; + public static final int UNSIGNED_INT__MIN__VALUE = 0; /** * Validates the Min constraint of 'Unsigned Int'. @@ -1834,7 +1836,7 @@ public boolean validateUnsignedInt(long unsignedInt, DiagnosticChain diagnostics * * @generated */ - public boolean validateUnsignedInt_Min(long unsignedInt, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInt_Min(int unsignedInt, DiagnosticChain diagnostics, Map context) { boolean result = unsignedInt >= UNSIGNED_INT__MIN__VALUE; if (!result && diagnostics != null) reportMinViolation(OmlPackage.Literals.UNSIGNED_INT, unsignedInt, UNSIGNED_INT__MIN__VALUE, true, diagnostics, context); @@ -1847,7 +1849,7 @@ public boolean validateUnsignedInt_Min(long unsignedInt, DiagnosticChain diagnos * @generated * @see #validateUnsignedInt_Max */ - public static final long UNSIGNED_INT__MAX__VALUE = 4294967295L; + public static final int UNSIGNED_INT__MAX__VALUE = 2147483647; /** * Validates the Max constraint of 'Unsigned Int'. @@ -1855,7 +1857,7 @@ public boolean validateUnsignedInt_Min(long unsignedInt, DiagnosticChain diagnos * * @generated */ - public boolean validateUnsignedInt_Max(long unsignedInt, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInt_Max(int unsignedInt, DiagnosticChain diagnostics, Map context) { boolean result = unsignedInt <= UNSIGNED_INT__MAX__VALUE; if (!result && diagnostics != null) reportMaxViolation(OmlPackage.Literals.UNSIGNED_INT, unsignedInt, UNSIGNED_INT__MAX__VALUE, true, diagnostics, context); @@ -1867,7 +1869,7 @@ public boolean validateUnsignedInt_Max(long unsignedInt, DiagnosticChain diagnos * * @generated */ - public boolean validateUnsignedInteger(Long unsignedInteger, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInteger(Integer unsignedInteger, DiagnosticChain diagnostics, Map context) { boolean result = validateUnsignedInteger_Min(unsignedInteger, diagnostics, context); if (result || diagnostics != null) result &= validateUnsignedInteger_Max(unsignedInteger, diagnostics, context); return result; @@ -1879,7 +1881,7 @@ public boolean validateUnsignedInteger(Long unsignedInteger, DiagnosticChain dia * @generated * @see #validateUnsignedInteger_Min */ - public static final Long UNSIGNED_INTEGER__MIN__VALUE = Long.valueOf(0L); + public static final Integer UNSIGNED_INTEGER__MIN__VALUE = Integer.valueOf(0); /** * Validates the Min constraint of 'Unsigned Integer'. @@ -1887,7 +1889,7 @@ public boolean validateUnsignedInteger(Long unsignedInteger, DiagnosticChain dia * * @generated */ - public boolean validateUnsignedInteger_Min(Long unsignedInteger, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInteger_Min(Integer unsignedInteger, DiagnosticChain diagnostics, Map context) { boolean result = unsignedInteger.compareTo(UNSIGNED_INTEGER__MIN__VALUE) >= 0; if (!result && diagnostics != null) reportMinViolation(OmlPackage.Literals.UNSIGNED_INTEGER, unsignedInteger, UNSIGNED_INTEGER__MIN__VALUE, true, diagnostics, context); @@ -1900,7 +1902,7 @@ public boolean validateUnsignedInteger_Min(Long unsignedInteger, DiagnosticChain * @generated * @see #validateUnsignedInteger_Max */ - public static final Long UNSIGNED_INTEGER__MAX__VALUE = Long.valueOf(4294967295L); + public static final Integer UNSIGNED_INTEGER__MAX__VALUE = Integer.valueOf(2147483647); /** * Validates the Max constraint of 'Unsigned Integer'. @@ -1908,7 +1910,7 @@ public boolean validateUnsignedInteger_Min(Long unsignedInteger, DiagnosticChain * * @generated */ - public boolean validateUnsignedInteger_Max(Long unsignedInteger, DiagnosticChain diagnostics, Map context) { + public boolean validateUnsignedInteger_Max(Integer unsignedInteger, DiagnosticChain diagnostics, Map context) { boolean result = unsignedInteger.compareTo(UNSIGNED_INTEGER__MAX__VALUE) <= 0; if (!result && diagnostics != null) reportMaxViolation(OmlPackage.Literals.UNSIGNED_INTEGER, unsignedInteger, UNSIGNED_INTEGER__MAX__VALUE, true, diagnostics, context); @@ -1924,6 +1926,15 @@ public boolean validateDecimal(BigDecimal decimal, DiagnosticChain diagnostics, return true; } + /** + * + * + * @generated + */ + public boolean validateDouble(Double double_, DiagnosticChain diagnostics, Map context) { + return true; + } + /** * * diff --git a/io.opencaesar.oml/src/io/opencaesar/oml/Oml.xcore b/io.opencaesar.oml/src/io/opencaesar/oml/Oml.xcore index 4558b750..8897d3f2 100644 --- a/io.opencaesar.oml/src/io/opencaesar/oml/Oml.xcore +++ b/io.opencaesar.oml/src/io/opencaesar/oml/Oml.xcore @@ -31,7 +31,6 @@ @Bikeshed(heading="Abstract-Syntax") package io.opencaesar.oml -import io.opencaesar.oml.util.OmlConstants import io.opencaesar.oml.util.OmlValidator2 import java.math.BigDecimal import org.eclipse.emf.ecore.EDiagnosticChain @@ -274,6 +273,17 @@ class Argument extends Element { * An optional instance specified by this argument */ refers NamedInstance[?] instance + /* + * Gets the value of the annotation + */ + op Object getValue() { + if (variable !== null) + variable + else if (literal !== null) + literal + else if (instance !== null) + instance + } } /* @@ -1757,7 +1767,7 @@ class QuotedLiteral extends Literal { return '"'+value+'"' + if (langTag !== null) "$"+langTag else if (^type !== null) "^^"+^type.abbreviatedIri else "" } op String getTypeIri() { - return if (^type !== null) ^type.iri else OmlConstants.XSD_NS+"string" + return if (^type !== null) ^type.iri else "http://www.w3.org/2001/XMLSchema#string" } } @@ -1772,7 +1782,7 @@ class IntegerLiteral extends Literal { Integer value = "0" op String getTypeIri() { - return OmlConstants.XSD_NS+"integer" + return "http://www.w3.org/2001/XMLSchema#integer" } } @@ -1787,7 +1797,7 @@ class DecimalLiteral extends Literal { Decimal[1] value = "0.0" op String getTypeIri() { - return OmlConstants.XSD_NS+"decimal" + return "http://www.w3.org/2001/XMLSchema#decimal" } } @@ -1802,7 +1812,7 @@ class DoubleLiteral extends Literal { Double value = "0.0" op String getTypeIri() { - return OmlConstants.XSD_NS+"double" + return "http://www.w3.org/2001/XMLSchema#double" } } @@ -1821,7 +1831,7 @@ class BooleanLiteral extends Literal { } op String getTypeIri() { - return OmlConstants.XSD_NS+"boolean" + return "http://www.w3.org/2001/XMLSchema#boolean" } } @@ -1895,15 +1905,20 @@ enum ImportKind { // Primitive Types //////////////////////////////////////// -@ExtendedMetaData(minInclusive="0", maxInclusive="4294967295") -type UnsignedInt wraps long +@ExtendedMetaData(minInclusive="0", maxInclusive="2147483647") +type UnsignedInt wraps int -@ExtendedMetaData(minInclusive="0", maxInclusive="4294967295") -type UnsignedInteger wraps Long +@ExtendedMetaData(minInclusive="0", maxInclusive="2147483647") +type UnsignedInteger wraps Integer @ExtendedMetaData(baseType="http://www.w3.org/2001/XMLSchema#decimal") type Decimal wraps BigDecimal +type Double wraps Double +convert { + String.format("%.2E", it) +} + @ExtendedMetaData(pattern="[a-zA-Z0-9_]([a-zA-Z0-9_\\-.$])*") type ID wraps String diff --git a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlBuilder.java b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlBuilder.java index c7f8df5c..f76922c9 100644 --- a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlBuilder.java +++ b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlBuilder.java @@ -25,7 +25,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import org.eclipse.emf.common.util.URI; @@ -45,6 +44,7 @@ import io.opencaesar.oml.BuiltIn; import io.opencaesar.oml.BuiltInPredicate; import io.opencaesar.oml.CardinalityRestrictionKind; +import io.opencaesar.oml.Classifier; import io.opencaesar.oml.ClassifierEquivalenceAxiom; import io.opencaesar.oml.Concept; import io.opencaesar.oml.ConceptInstance; @@ -54,6 +54,7 @@ import io.opencaesar.oml.DifferentFromPredicate; import io.opencaesar.oml.DoubleLiteral; import io.opencaesar.oml.Element; +import io.opencaesar.oml.Entity; import io.opencaesar.oml.ForwardRelation; import io.opencaesar.oml.IdentifiedElement; import io.opencaesar.oml.Import; @@ -87,7 +88,6 @@ import io.opencaesar.oml.Scalar; import io.opencaesar.oml.ScalarEquivalenceAxiom; import io.opencaesar.oml.ScalarProperty; -import io.opencaesar.oml.SpecializableTerm; import io.opencaesar.oml.SpecializationAxiom; import io.opencaesar.oml.Structure; import io.opencaesar.oml.StructureInstance; @@ -194,11 +194,14 @@ public void finish() { */ @SuppressWarnings("unchecked") protected void setCrossReference(Ontology ontology, Element subject, EReference eRef, String objectIri) { - final Class subjectClass = eRef.getEContainingClass().getInstanceClass(); + assert !eRef.isContainment() : eRef.getName()+" is a containment reference"; + final Class objectClass = (Class) eRef.getEType().getInstanceClass(); - assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); assert Member.class.isAssignableFrom(objectClass) : eRef.getName()+" is not typed by Member or one of its subclasses"; - assert !eRef.isContainment() : eRef.getName()+" is a containment reference"; + + final Class subjectClass = eRef.getEContainingClass().getInstanceClass(); + assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); + if (objectIri != null) { if (eRef.isMany()) { defer.add(() -> ((List)subject.eGet(eRef)).add(resolve(objectClass, ontology, objectIri))); @@ -219,13 +222,16 @@ protected void setCrossReference(Ontology ontology, Element subject, EReference * @param objectIris a list of iris of objects */ @SuppressWarnings("unchecked") - protected void setCrossReferences(Ontology ontology, Element subject, EReference eRef, List objectIris) { - final Class subjectClass = eRef.getEContainingClass().getInstanceClass(); - final Class objectClass = (Class) eRef.getEType().getInstanceClass(); - assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); - assert Member.class.isAssignableFrom(objectClass) : eRef.getName()+" is not typed by Member or one of its subclasses"; + protected void setCrossReferences(Ontology ontology, Element subject, EReference eRef, List objectIris) { assert !eRef.isContainment() : eRef.getName()+" is a containment reference"; assert eRef.isMany() : eRef.getName()+" is a singular reference"; + + final Class objectClass = (Class) eRef.getEType().getInstanceClass(); + assert Member.class.isAssignableFrom(objectClass) : eRef.getName()+" is not typed by Member or one of its subclasses"; + + final Class subjectClass = eRef.getEContainingClass().getInstanceClass(); + assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); + if (objectIris.iterator().hasNext()) { defer.add(() -> subject.eSet(eRef, objectIris.stream().map(objectIri -> resolve(objectClass, ontology, objectIri)).collect(Collectors.toList()))); } @@ -236,48 +242,31 @@ protected void setCrossReferences(Ontology ontology, Element subject, EReference * * @param ontology the given ontology * @param subjectIri the given iri of a member to be resolved as subject - * @param elementERef the containment eRef to use on subject if it belongs to the given ontology - * @param object the given object - */ - protected void setContainmentReference(Ontology ontology, String subjectIri, EReference elementERef, Element object) { - setContainmentReference(ontology, subjectIri, elementERef, object, e -> e); - } - - /** - * Sets the given object to be contained by the given subject that is resolved by iri in the context of the given ontology - * - * @param ontology the given ontology - * @param subjectIri the given iri of a member to be resolved as subject - * @param elementERef the containment eRef to use on subject if it belongs to the given ontology + * @param eRef the containment eRef to use on subject if it belongs to the given ontology * @param object the given object */ @SuppressWarnings("unchecked") - protected void setContainmentReference(Ontology ontology, String subjectIri, EReference elementERef, Element object, Function postResolve) { - final Class subjectClass = (Class) elementERef.getEContainingClass().getInstanceClass(); - final Class objectClass = (Class) elementERef.getEType().getInstanceClass(); + protected void setContainmentReference(Ontology ontology, String subjectIri, EReference eRef, Element object) { + assert eRef.isContainment() : eRef.getName()+" is not a containment reference"; + + final Class objectClass = (Class) eRef.getEType().getInstanceClass(); assert objectClass.isInstance(object) : object+" is not an instance of "+objectClass.getName(); - assert elementERef.isContainment() : elementERef.getName()+" is not a containment reference"; - if (subjectIri != null) { - defer.add(() -> { - Member subject = resolve(Member.class, ontology, subjectIri); - subject = postResolve.apply(subject); - assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); - if (subject.getOntology() == ontology) { - if (elementERef.isMany()) { - ((List)subject.eGet(elementERef)).add(object); - } else { - subject.eSet(elementERef, object); - } - } else { - Member ref = OmlWrite.getOrAddRef(ontology, subject); - if (elementERef.isMany()) { - ((List)ref.eGet(elementERef)).add(object); - } else { - ref.eSet(elementERef, object); - } - } - }); - } + + defer.add(() -> { + final Class subjectClass = (Class) eRef.getEContainingClass().getInstanceClass(); + Member subject = resolve(Member.class, ontology, subjectIri); + // second condition is to cover forward/reverse rel cannot own specialization axiom + if (subject.getOntology() != ontology || !subjectClass.isInstance(subject)) { + subject = OmlWrite.getOrAddRef(ontology, subject); + } + assert subjectClass.isInstance(subject) : subject+" is not an instance of "+subjectClass.getName(); + + if (eRef.isMany()) { + ((List)subject.eGet(eRef)).add(object); + } else { + subject.eSet(eRef, object); + } + }); } /** @@ -492,7 +481,7 @@ public Concept addConcept(Vocabulary vocabulary, String name) { * Creates a new relation entity and adds it to the given vocabulary * * @param vocabulary the context vocabulary - * @param name the name of the new concept + * @param name the name of the new relation entity * @param sourceIris the iris of the source entities * @param targetIris the iris of the target entities * @param functional whether the relation entity is functional @@ -507,10 +496,10 @@ public Concept addConcept(Vocabulary vocabulary, String name) { public RelationEntity addRelationEntity(Vocabulary vocabulary, String name, List sourceIris, List targetIris, boolean functional, boolean inverseFunctional, boolean symmetric, boolean asymmetric, boolean reflexive, boolean irreflexive, boolean transitive) { - final RelationEntity relation = OmlWrite.addRelationEntity(vocabulary, name, Collections.emptyList(), Collections.emptyList(), functional, inverseFunctional, symmetric, asymmetric, reflexive, irreflexive, transitive); - setCrossReferences(vocabulary, relation, OmlPackage.Literals.RELATION_BASE__SOURCES, sourceIris); - setCrossReferences(vocabulary, relation, OmlPackage.Literals.RELATION_BASE__TARGETS, targetIris); - return relation; + final RelationEntity relationEntity = OmlWrite.addRelationEntity(vocabulary, name, Collections.emptyList(), Collections.emptyList(), functional, inverseFunctional, symmetric, asymmetric, reflexive, irreflexive, transitive); + setCrossReferences(vocabulary, relationEntity, OmlPackage.Literals.RELATION_BASE__SOURCES, sourceIris); + setCrossReferences(vocabulary, relationEntity, OmlPackage.Literals.RELATION_BASE__TARGETS, targetIris); + return relationEntity; } // Structure @@ -561,6 +550,34 @@ public ScalarProperty addScalarProperty(Vocabulary vocabulary, String name, return property; } + /** + * Sets a scalar property details in the given vocabulary + * + * @param vocabulary the context vocabulary + * @param propertyIri the iri of the scalar property + * @param domainIri the iri of a domain classifier + * @param rangeIri the iri of a range scalar + * @param functional whether the scalar property is functional (can be null) + */ + public void setScalarProperty(Vocabulary vocabulary, String propertyIri, + String domainIri, String rangeIri, Boolean functional) { + defer.add(() -> { + ScalarProperty property = resolve(ScalarProperty.class, vocabulary, propertyIri); + if (property.getOntology() != vocabulary) { + property = (ScalarProperty) OmlWrite.getOrAddRef(vocabulary, property); + } + if (domainIri != null) { + property.getDomains().add(resolve(Classifier.class, vocabulary, domainIri)); + } + if (rangeIri != null) { + property.getRanges().add(resolve(Scalar.class, vocabulary, rangeIri)); + } + if (functional != null) { + property.setFunctional(functional); + } + }); + } + // StructuredProperty /** @@ -581,6 +598,34 @@ public StructuredProperty addStructuredProperty(Vocabulary vocabulary, String na return property; } + /** + * Sets structured property details in the given vocabulary + * + * @param vocabulary the context vocabulary + * @param propertyIri the iri of the structured property + * @param domainIri the iri of a domain classifiers + * @param rangeIri the iri of a range structures + * @param functional whether the structured property is functional + */ + public void setStructuredProperty(Vocabulary vocabulary, String propertyIri, + String domainIri, String rangeIri, Boolean functional) { + defer.add(() -> { + StructuredProperty property = resolve(StructuredProperty.class, vocabulary, propertyIri); + if (property.getOntology() != vocabulary) { + property = (StructuredProperty) OmlWrite.getOrAddRef(vocabulary, property); + } + if (domainIri != null) { + property.getDomains().add(resolve(Classifier.class, vocabulary, domainIri)); + } + if (rangeIri != null) { + property.getRanges().add(resolve(Structure.class, vocabulary, rangeIri)); + } + if (functional != null) { + property.setFunctional(functional); + } + }); + } + // Scalar /** @@ -629,7 +674,7 @@ public ReverseRelation addReverseRelation(RelationBase base, String name) { * Creates a new unreified relation and adds it to the given vocabulary * * @param vocabulary the context vocabulary - * @param name the name of the new concept + * @param name the name of the new relation * @param sourceIris the iri of the source entity * @param targetIris the iri of the target entity * @param functional whether the relation entity is functional @@ -650,6 +695,59 @@ public UnreifiedRelation addUnreifiedRelation(Vocabulary vocabulary, String name return relation; } + /** + * Sets relation base details in the given vocabulary + * + * @param vocabulary the context vocabulary + * @param relationIri the iri of the relation + * @param sourceIri the iri of a source entity + * @param targetIri the iri of a target entity + * @param functional whether the relation entity is functional + * @param inverseFunctional whether the relation entity is inverse functional + * @param symmetric whether the relation entity is symmetric + * @param asymmetric whether the relation entity is asymmetric + * @param reflexive whether the relation entity is reflexive + * @param irreflexive whether the relation entity is irreflexive + * @param transitive whether the relation entity is transitive + */ + public void setRelationBase(Vocabulary vocabulary, String relationIri, String sourceIri, String targetIri, + Boolean functional, Boolean inverseFunctional, Boolean symmetric, + Boolean asymmetric, Boolean reflexive, Boolean irreflexive, Boolean transitive) { + defer.add(() -> { + RelationBase relation = resolve(RelationBase.class, vocabulary, relationIri); + if (relation.getOntology() != vocabulary) { + relation = (RelationBase) OmlWrite.getOrAddRef(vocabulary, relation); + } + if (sourceIri != null) { + relation.getSources().add(resolve(Entity.class, vocabulary, sourceIri)); + } + if (targetIri != null) { + relation.getTargets().add(resolve(Entity.class, vocabulary, targetIri)); + } + if (functional != null) { + relation.setFunctional(functional); + } + if (inverseFunctional != null) { + relation.setInverseFunctional(inverseFunctional); + } + if (symmetric != null) { + relation.setSymmetric(symmetric); + } + if (asymmetric != null) { + relation.setAsymmetric(asymmetric); + } + if (reflexive != null) { + relation.setReflexive(reflexive); + } + if (irreflexive != null) { + relation.setIrreflexive(irreflexive); + } + if (transitive != null) { + relation.setTransitive(transitive); + } + }); + } + // Rule /** @@ -657,12 +755,12 @@ public UnreifiedRelation addUnreifiedRelation(Vocabulary vocabulary, String name * * @param vocabulary the context vocabulary * @param name the name of the new rule - * @param consequent a list of consequent predicates of the rule * @param antecedent a list of antecedent predicates of the rule + * @param consequent a list of consequent predicates of the rule * @return a rule that is added to the given vocabulary */ - public Rule addRule(Vocabulary vocabulary, String name, Predicate[] consequent, Predicate[] antecedent) { - final Rule rule = OmlWrite.addRule(vocabulary, name, consequent, antecedent); + public Rule addRule(Vocabulary vocabulary, String name, Predicate[] antecedent, Predicate[] consequent) { + final Rule rule = OmlWrite.addRule(vocabulary, name, antecedent, consequent); return rule; } @@ -727,6 +825,29 @@ public RelationInstance addRelationInstance(Description description, String name return instance; } + /** + * Sets a relation instance details in the given description + * + * @param description the context description + * @param relationInstanceIri the iri of a relation instance + * @param sourceIri the iri of a source instance + * @param targetIri the iri of a target instance + */ + public void setRelationInstance(Description description, String relationInstanceIri, String sourceIri, String targetIri) { + defer.add(() -> { + RelationInstance relationInstance = resolve(RelationInstance.class, description, relationInstanceIri); + if (relationInstance.getOntology() != description) { + relationInstance = (RelationInstance) OmlWrite.getOrAddRef(description, relationInstance); + } + if (sourceIri != null) { + relationInstance.getSources().add(resolve(NamedInstance.class, description, sourceIri)); + } + if (targetIri != null) { + relationInstance.getTargets().add(resolve(NamedInstance.class, description, targetIri)); + } + }); + } + // Import /** @@ -756,14 +877,7 @@ public Import addImport(Ontology ontology, ImportKind kind, String namespace, St public SpecializationAxiom addSpecializationAxiom(Vocabulary vocabulary, String subTermIri, String superTermIri) { final SpecializationAxiom axiom = OmlWrite.addSpecializationAxiom(vocabulary, null, null); setCrossReference(vocabulary, axiom, OmlPackage.Literals.SPECIALIZATION_AXIOM__SUPER_TERM, superTermIri); - setContainmentReference(vocabulary, subTermIri, OmlPackage.Literals.SPECIALIZABLE_TERM__OWNED_SPECIALIZATIONS, axiom, subTerm -> { - if (!(subTerm instanceof SpecializableTerm)) { - // e.g., forward relation or reverse relation - return OmlWrite.getOrAddRef(vocabulary, subTerm); - } else { - return subTerm; - } - }); + setContainmentReference(vocabulary, subTermIri, OmlPackage.Literals.SPECIALIZABLE_TERM__OWNED_SPECIALIZATIONS, axiom); return axiom; } @@ -803,7 +917,7 @@ public ClassifierEquivalenceAxiom addClassifierEquivalenceAxiom(Vocabulary vocab * @param maxExclusive the max exclusive facet * @return a scalar equivalence axiom that is added to the vocabulary */ - public ScalarEquivalenceAxiom addScalarEquivalenceAxiom(Vocabulary vocabulary, String subScalarIri, String superScalarIri, Long length, Long minLength, Long maxLength, String pattern, + public ScalarEquivalenceAxiom addScalarEquivalenceAxiom(Vocabulary vocabulary, String subScalarIri, String superScalarIri, Integer length, Integer minLength, Integer maxLength, String pattern, String language, Literal minInclusive, Literal minExclusive, Literal maxInclusive, Literal maxExclusive) { final ScalarEquivalenceAxiom axiom = OmlWrite.addScalarEquivalenceAxiom(vocabulary, null, null, length, minLength, maxLength, pattern, language, minInclusive, minExclusive, maxInclusive, maxExclusive); setCrossReference(vocabulary, axiom, OmlPackage.Literals.SCALAR_EQUIVALENCE_AXIOM__SUPER_SCALAR, superScalarIri); @@ -865,7 +979,7 @@ public PropertyRangeRestrictionAxiom addPropertyRangeRestrictionAxiom(Vocabulary * @param restrictionKind the kind of the restriction * @return a property cardinality restriction axiom that is added to the given vocabulary */ - public PropertyCardinalityRestrictionAxiom addPropertyCardinalityRestrictionAxiom(Vocabulary vocabulary, Object owner, String propertyIri, CardinalityRestrictionKind restrictionKind, long cardinality, String rangeIri) { + public PropertyCardinalityRestrictionAxiom addPropertyCardinalityRestrictionAxiom(Vocabulary vocabulary, Object owner, String propertyIri, CardinalityRestrictionKind restrictionKind, int cardinality, String rangeIri) { final PropertyCardinalityRestrictionAxiom axiom = OmlWrite.addPropertyCardinalityRestrictionAxiom(vocabulary, null, null, restrictionKind, cardinality, null); setCrossReference(vocabulary, axiom, OmlPackage.Literals.PROPERTY_RESTRICTION_AXIOM__PROPERTY, propertyIri); setCrossReference(vocabulary, axiom, OmlPackage.Literals.PROPERTY_CARDINALITY_RESTRICTION_AXIOM__RANGE, rangeIri); @@ -1034,64 +1148,19 @@ public TypeAssertion addTypeAssertion(Description description, String instanceIr * Creates a property value assertion for a scalar property and adds it to the given ontology * * @param ontology the context ontology - * @param instanceIri the iri of the instance + * @param owner either a structure instance or the iri of a named instance * @param propertyIri the iri of the scalar property * @param literalValue the asserted (literal) value of the property * @return a property value assertion that is added to the given description */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, String instanceIri, String propertyIri, Literal literalValue) { + public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Object owner, String propertyIri, Literal literalValue) { final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, literalValue); setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); - setContainmentReference(ontology, instanceIri, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); - return assertion; - } - - /** - * Creates a property value assertion for a structured property and adds it to the given ontology - * - * @param ontology the context ontology - * @param instanceIri the iri of the instance - * @param propertyIri the iri of the structured property - * @param containedValue the asserted contained value of the property - * @return a property value assertion that is added to the given description - */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, String instanceIri, String propertyIri, StructureInstance containedValue) { - final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, containedValue); - setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); - setContainmentReference(ontology, instanceIri, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); - return assertion; - } - - /** - * Creates a property value assertion for a relation and adds it to the given ontology - * - * @param ontology the context ontology - * @param instanceIri the iri of the instance - * @param propertyIri the iri of the relation property - * @param referencedValueIri the asserted referenced value (identified by iri) of the property - * @return a property value assertion that is added to the given description - */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, String instanceIri, String propertyIri, String referencedValueIri) { - final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, (NamedInstance) null); - setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__REFERENCED_VALUE, referencedValueIri); - setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); - setContainmentReference(ontology, instanceIri, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); - return assertion; - } - - /** - * Creates a property value assertion for a scalar property and adds it to the given ontology - * - * @param ontology the context ontology - * @param instance the given the instance - * @param propertyIri the iri of the scalar property - * @param literalValue the asserted (literal) value of the property - * @return a property value assertion that is added to the given description - */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, StructureInstance instance, String propertyIri, Literal literalValue) { - final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, literalValue); - instance.getOwnedPropertyValues().add(assertion); - setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); + if (owner instanceof String) { + setContainmentReference(ontology, (String)owner, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); + } else if (owner instanceof StructureInstance) { + ((StructureInstance)owner).getOwnedPropertyValues().add(assertion); + } return assertion; } @@ -1099,15 +1168,19 @@ public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Struc * Creates a property value assertion for a structured property and adds it to the given ontology * * @param ontology the context ontology - * @param instance the given the instance + * @param owner either a structure instance or the iri of a named instance * @param propertyIri the iri of the structured property * @param containedValue the asserted contained value of the property * @return a property value assertion that is added to the given description */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, StructureInstance instance, String propertyIri, StructureInstance containedValue) { + public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Object owner, String propertyIri, StructureInstance containedValue) { final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, containedValue); - instance.getOwnedPropertyValues().add(assertion); setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); + if (owner instanceof String) { + setContainmentReference(ontology, (String)owner, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); + } else if (owner instanceof StructureInstance) { + ((StructureInstance)owner).getOwnedPropertyValues().add(assertion); + } return assertion; } @@ -1115,16 +1188,20 @@ public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Struc * Creates a property value assertion for a relation and adds it to the given ontology * * @param ontology the context ontology - * @param instance the given the instance + * @param owner either a structure instance or the iri of a named instance * @param propertyIri the iri of the relation property * @param referencedValueIri the asserted referenced value (identified by iri) of the property * @return a property value assertion that is added to the given description */ - public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, StructureInstance instance, String propertyIri, String referencedValueIri) { + public PropertyValueAssertion addPropertyValueAssertion(Ontology ontology, Object owner, String propertyIri, String referencedValueIri) { final PropertyValueAssertion assertion = OmlWrite.addPropertyValueAssertion(ontology, null, null, (NamedInstance) null); - instance.getOwnedPropertyValues().add(assertion); setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__REFERENCED_VALUE, referencedValueIri); setCrossReference(ontology, assertion, OmlPackage.Literals.PROPERTY_VALUE_ASSERTION__PROPERTY, propertyIri); + if (owner instanceof String) { + setContainmentReference(ontology, (String)owner, OmlPackage.Literals.INSTANCE__OWNED_PROPERTY_VALUES, assertion); + } else if (owner instanceof StructureInstance) { + ((StructureInstance)owner).getOwnedPropertyValues().add(assertion); + } return assertion; } diff --git a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlConstants.java b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlConstants.java index b1caf1fe..83180fe2 100644 --- a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlConstants.java +++ b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlConstants.java @@ -28,6 +28,8 @@ */ public interface OmlConstants { + // Extensions + /** * The extension of OML Text files */ @@ -53,6 +55,8 @@ public interface OmlConstants { */ public static final List OML_EXTENSION_LIST= Arrays.asList(OML_EXTENSIONS); + // IRI, Namespace, and Prefix + /** * The IRI of the OML vocabulary */ @@ -68,81 +72,147 @@ public interface OmlConstants { */ public static final String OML_PREFIX= "oml"; + // OML Annotations Property IRIs + + /** + * The oml:type annotation IRI + */ + public static final String type = OML_NS + "type"; + + /** + * The oml:namespace annotation IRI + */ + public static final String namespace = OML_NS + "namespace"; + + /** + * The oml:prefix annotation IRI + */ + public static final String prefix = OML_NS + "prefix"; + + /** + * The oml:name annotation IRI + */ + public static final String name = OML_NS + "name"; + + /** + * The oml:relationEntity annotation IRI + */ + public static final String relationEntity = OML_NS + "relationEntity"; + + /** + * The oml:relationBase annotation IRI + */ + public static final String relationBase = OML_NS + "relationBase"; + + /** + * The oml:sourceRelation annotation IRI + */ + public static final String sourceRelation = OML_NS + "hasSource"; + + /** + * The oml:targetRelation annotation IRI + */ + public static final String targetRelation = OML_NS + "hasTarget"; + + // OML Term IRIs + /** - * The IRI of the XSD vocabulary + * The oml:Vocabulary IRI */ - public static final String XSD_IRI = "http://www.w3.org/2001/XMLSchema"; + public static final String Vocabulary = OML_NS + "Vocabulary"; /** - * The namespace of the XSD vocabulary + * The oml:VocabularyBundle IRI */ - public static final String XSD_NS = XSD_IRI+"#"; + public static final String VocabularyBundle = OML_NS + "VocabularyBundle"; /** - * The prefix of the XSD vocabulary + * The oml:Description IRI */ - public static final String XSD_PREFIX= "xsd"; + public static final String Description = OML_NS + "Description"; /** - * The IRI of the RDF vocabulary + * The oml:DescriptionBundle IRI */ - public static final String RDF_IRI = "http://www.w3.org/1999/02/22-rdf-syntax-ns"; + public static final String DescriptionBundle = OML_NS + "DescriptionBundle"; /** - * The namespace of the RDF vocabulary + * The oml:Aspect IRI */ - public static final String RDF_NS = RDF_IRI+"#"; + public static final String Aspect = OML_NS + "Aspect"; /** - * The prefix of the RDF vocabulary + * The oml:Concept IRI */ - public static final String RDF_PREFIX= "rdf"; + public static final String Concept = OML_NS + "Concept"; /** - * The IRI of the RDFS vocabulary + * The oml:RelationEntity IRI */ - public static final String RDFS_IRI = "http://www.w3.org/2000/01/rdf-schema"; + public static final String RelationEntity = OML_NS + "RelationEntity"; /** - * The namespace of the RDFS vocabulary + * The oml:Structure IRI */ - public static final String RDFS_NS = RDFS_IRI+"#"; + public static final String Structure = OML_NS + "Structure"; /** - * The prefix of the RDFS vocabulary + * The oml:Scalar IRI */ - public static final String RDFS_PREFIX= "rdfs"; + public static final String Scalar = OML_NS + "Scalar"; - /** - * The IRI of the OWL vocabulary + /** + * The oml:UnreifiedRelation IRI */ - public static final String OWL_IRI = "http://www.w3.org/2002/07/owl"; + public static final String UnreifiedRelation = OML_NS + "UnreifiedRelation"; /** - * The namespace of the OWL vocabulary + * The oml:ForwardRelation IRI */ - public static final String OWL_NS = OWL_IRI+"#"; + public static final String ForwardRelation = OML_NS + "ForwardRelation"; /** - * The prefix of the OWL vocabulary + * The oml:ReverseRelation IRI */ - public static final String OWL_PREFIX= "owl"; + public static final String ReverseRelation = OML_NS + "ReverseRelation"; /** - * The IRI of the DC vocabulary + * The oml:AnnotationProperty IRI */ - public static final String DC_IRI = "http://purl.org/dc/elements/1.1"; + public static final String AnnotationProperty = OML_NS + "AnnotationProperty"; /** - * The namespace of the DC vocabulary + * The oml:ScalarProperty IRI */ - public static final String DC_NS = DC_IRI+"/"; + public static final String ScalarProperty = OML_NS + "ScalarProperty"; /** - * The prefix of the DC vocabulary + * The oml:StructuredProperty IRI */ - public static final String DC_PREFIX= "dc"; - + public static final String StructuredProperty = OML_NS + "StructuredProperty"; + + /** + * The oml:Rule IRI + */ + public static final String Rule = OML_NS + "Rule"; + + /** + * The oml:ConceptInstance IRI + */ + public static final String ConceptInstance = OML_NS + "ConceptInstance"; + + /** + * The oml:RelationInstance IRI + */ + public static final String RelationInstance = OML_NS + "RelationInstance"; + + /** + * The oml:StructureInstance IRI + */ + public static final String StructureInstance = OML_NS + "StructureInstance"; + + // Flags + /** * A flag that can be set to Boolean.True in a resource set's loading options to enable * resolving IRIs to URIs using already loaded OML ontologies when they are not resolvable using catalogs. diff --git a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlRead.java b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlRead.java index eccdd3a8..91ba6de0 100644 --- a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlRead.java +++ b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlRead.java @@ -84,7 +84,16 @@ * @author elaasar */ public final class OmlRead { - + + /** + * The standard ontology namespaces + */ + private static final String XSD_NS = "http://www.w3.org/2001/XMLSchema#"; + private static final String RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + private static final String RDFS_NS = "http://www.w3.org/2000/01/rdf-schema#"; + private static final String OWL_NS = "http://www.w3.org/2002/07/owl#"; + private static final String SWRLB_NS = "http://www.w3.org/2003/11/swrlb#"; + //------------------------------------------------- // UTILITIES //------------------------------------------------- @@ -954,10 +963,11 @@ public static boolean isStandardScalar(Scalar scalar) { var ontology = scalar.getOntology(); if (ontology != null) { var ontologyNs = ontology.getNamespace(); - return ontologyNs.equals(OmlConstants.XSD_NS) || - ontologyNs.equals(OmlConstants.RDF_NS) || - ontologyNs.equals(OmlConstants.RDFS_NS) || - ontologyNs.equals(OmlConstants.OWL_NS); + return ontologyNs.equals(XSD_NS) || + ontologyNs.equals(RDF_NS) || + ontologyNs.equals(RDFS_NS) || + ontologyNs.equals(OWL_NS) || + ontologyNs.equals(SWRLB_NS); } return false; } @@ -1073,21 +1083,21 @@ public static Object getJavaValue(Literal literal) { var value = ((QuotedLiteral)literal).getValue(); var typeIri = literal.getTypeIri(); if (value != null && typeIri != null) { - if (typeIri.equals(OmlConstants.XSD_NS+"string")) { + if (typeIri.equals(XSD_NS+"string")) { return value; - } else if (typeIri.equals(OmlConstants.XSD_NS+"integer")) { + } else if (typeIri.equals(XSD_NS+"integer")) { return Integer.valueOf(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"decimal")) { + } else if (typeIri.equals(XSD_NS+"decimal")) { return new BigDecimal(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"real")) { + } else if (typeIri.equals(XSD_NS+"real")) { return Double.valueOf(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"double")) { + } else if (typeIri.equals(XSD_NS+"double")) { return Double.valueOf(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"float")) { + } else if (typeIri.equals(XSD_NS+"float")) { return Float.valueOf(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"boolean")) { + } else if (typeIri.equals(XSD_NS+"boolean")) { return Boolean.valueOf(value); - } else if (typeIri.equals(OmlConstants.XSD_NS+"dateTime")) { + } else if (typeIri.equals(XSD_NS+"dateTime")) { try { return new SimpleDateFormat().parse(value); } catch(Exception e) { diff --git a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlWrite.java b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlWrite.java index 23176d84..a6595c8c 100644 --- a/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlWrite.java +++ b/io.opencaesar.oml/src/io/opencaesar/oml/util/OmlWrite.java @@ -556,15 +556,15 @@ public static UnreifiedRelation addUnreifiedRelation(Vocabulary vocabulary, Stri * * @param vocabulary the context vocabulary * @param name the name of the new rule - * @param consequent a list of consequent predicates of the rule * @param antecedent a list of antecedent predicates of the rule + * @param consequent a list of consequent predicates of the rule * @return a rule that is added to the given vocabulary */ - public static Rule addRule(Vocabulary vocabulary, String name, Predicate[] consequent, Predicate[] antecedent) { + public static Rule addRule(Vocabulary vocabulary, String name, Predicate[] antecedent, Predicate[] consequent) { final Rule rule = create(Rule.class); rule.setName(name); - rule.getConsequent().addAll(Arrays.asList(consequent)); rule.getAntecedent().addAll(Arrays.asList(antecedent)); + rule.getConsequent().addAll(Arrays.asList(consequent)); vocabulary.getOwnedStatements().add(rule); return rule; } @@ -725,24 +725,39 @@ public static Import addImport(Ontology ontology, ImportKind kind, String namesp * @param importedOntology The imported ontology */ public static void addImport(Ontology ontology, Ontology importedOntology) { - ImportKind kind; + var namespace = importedOntology.getNamespace(); + var prefix = importedOntology.getPrefix(); + if (ontology instanceof Vocabulary) { if (importedOntology instanceof Vocabulary) { - kind = ImportKind.EXTENSION; - } else { - kind = ImportKind.USAGE; + addImport(ontology, ImportKind.EXTENSION, namespace, prefix); + } else if (importedOntology instanceof Description){ + addImport(ontology, ImportKind.USAGE, namespace, prefix); } - } else { // if (ontology instanceof Description) - if (importedOntology instanceof Vocabulary) { - kind = ImportKind.USAGE; - } else { - kind = ImportKind.EXTENSION; + } else if (ontology instanceof Description) { + if (importedOntology instanceof Description) { + addImport(ontology, ImportKind.EXTENSION, namespace, prefix); + } else if (importedOntology instanceof Vocabulary){ + addImport(ontology, ImportKind.USAGE, namespace, prefix); + } + } else if (ontology instanceof VocabularyBundle) { + if (importedOntology instanceof VocabularyBundle) { + addImport(ontology, ImportKind.EXTENSION, namespace, prefix); + } else if (importedOntology instanceof Vocabulary) { + addImport(ontology, ImportKind.INCLUSION, namespace, prefix); + } + } else if (ontology instanceof DescriptionBundle){ + if (importedOntology instanceof DescriptionBundle) { + addImport(ontology, ImportKind.EXTENSION, namespace, prefix); + } else if (ontology instanceof Description) { + addImport(ontology, ImportKind.INCLUSION, namespace, prefix); + } else if (importedOntology instanceof VocabularyBundle) { + addImport(ontology, ImportKind.USAGE, namespace, prefix); } } - addImport(ontology, kind, importedOntology.getNamespace(), importedOntology.getPrefix()); } - // SpecializationAxiom + // SpecializationAxiom /** * Creates a specialization axiom between two terms and adds it to the given vocabulary @@ -799,7 +814,7 @@ public static ClassifierEquivalenceAxiom addClassifierEquivalenceAxiom(Vocabular * @param maxExclusive the max exclusive facet * @return a scalar equivalence axiom that is added to the vocabulary */ - public static ScalarEquivalenceAxiom addScalarEquivalenceAxiom(Vocabulary vocabulary, Scalar subScalar, Scalar superScalar, Long length, Long minLength, Long maxLength, String pattern, + public static ScalarEquivalenceAxiom addScalarEquivalenceAxiom(Vocabulary vocabulary, Scalar subScalar, Scalar superScalar, Integer length, Integer minLength, Integer maxLength, String pattern, String language, Literal minInclusive, Literal minExclusive, Literal maxInclusive, Literal maxExclusive) { final ScalarEquivalenceAxiom axiom = create(ScalarEquivalenceAxiom.class); axiom.setLength(length); @@ -871,7 +886,7 @@ public static PropertyRangeRestrictionAxiom addPropertyRangeRestrictionAxiom(Voc * @param restrictionKind the kind of the restriction * @return a property cardinality restriction axiom that is added to the given vocabulary */ - public static PropertyCardinalityRestrictionAxiom addPropertyCardinalityRestrictionAxiom(Vocabulary vocabulary, Element owner, SemanticProperty property, CardinalityRestrictionKind restrictionKind, long cardinality, Type range) { + public static PropertyCardinalityRestrictionAxiom addPropertyCardinalityRestrictionAxiom(Vocabulary vocabulary, Element owner, SemanticProperty property, CardinalityRestrictionKind restrictionKind, int cardinality, Type range) { final PropertyCardinalityRestrictionAxiom axiom = create(PropertyCardinalityRestrictionAxiom.class); axiom.setKind(restrictionKind); axiom.setCardinality(cardinality); diff --git a/pom.xml b/pom.xml index d63b8a66..78c7a732 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 io.opencaesar.oml - 2.5.0 + 2.6.0 io.opencaesar.oml.parent pom diff --git a/version.txt b/version.txt index fad066f8..914ec967 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.5.0 \ No newline at end of file +2.6.0 \ No newline at end of file