Atomic

Atomic #

This page contains the following content:

The group of Atomic classes is used to store exactly one value. The counterpart in programming languages such as java are data types like integer, double, string, or boolean. It is possible to restrict the value ranges by using an interval predicate or an enumeration predicate.

Boolean #

The Boolean class is the simplest Atomic class because it represents a boolean value similar to programming languages, e.g., true or false. Further optional restrictions are not needed.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    BooleanObject booleanObject = (BooleanObject) ModelFactory.getDefaultModel().getBooleanSystemClass().newObject();

The XML representation of the boolean object depicted above is as follows:

casebase.xml

    <cdol:A c="Boolean" v="false" id="testBoolean"/>

To create a subclass of the Boolean class, the following XML definition can be used:

model.xml

    <BooleanClass name="customBooleanClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    BooleanClass booleanClass = ModelFactory.getDefaultModel().getBooleanSystemClass();
    BooleanClass customBooleanClass = (BooleanClass) booleanClass.createSubclass("customBooleanClass");
    customBooleanClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    BooleanObject customBooleanObject = (BooleanObject) ModelFactory.getDefaultModel().createObject("customBooleanClass");

The XML representation of the boolean object depicted above is as follows:

casebase.xml

    <cdol:A c="customBooleanClass" v="false" id="testBooleanCustom"/>

ByteArray #

A ByteArray can be used to store more complex data objects like serialized images or serialized documents. Internally, it is an array of bytes but conceptually it is used as one value, e.g., one serialized object. To distinguish the different kinds of content types, it is necessary to specify the mime type of the content. This can be text, image, audio, or video, for example.

To create a ByteArray class, the following XML code has to be used:

model.xml

    <ByteArrayClass name="customByteArrayClass" mimeType="image" maxSize="500"/>

To create this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    ByteArrayClass byteArrayClass = (ByteArrayClass) ModelFactory.getDefaultModel().getByteArraySystemClass();
    ByteArrayClass customByteArrayClass = (ByteArrayClass) byteArrayClass.createSubclass("customByteArrayClass");
    customByteArrayClass.setMimeType("image");
    customByteArrayClass.setMaxSize(500);
    customByteArrayClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    ByteArrayObject byteArrayObject = (ByteArrayObject) ModelFactory.getDefaultModel().createObject("customByteArrayClass");

The XML representation of the byte array object depicted above is as follows:

casebase.xml

    <cdol:B c="customByteArrayClass" id="testByteArray">
        <cdol:c></cdol:c>
    </cdol:B>

Please note that all byte arrays are serialized as Base64-encoded strings. For more information on this encoding, read here.

Chronological #

The Chronological class defines a specific instance in time with millisecond precision. The Chronological class is an abstract class that can not be instantiated directly. Thus, one of the inherited classes must be used:

Please note that all objects of chronological classes are totally ordered.

Date #

The Date class is the specification of a date (without time information). It represents a date as a value in milliseconds. The Date object extends the java.sql.Date as native object. The Date class represents a particular moment in time with millisecond precision since the 1st of January 1970. For this reason, it is not possible to represent dates before that day.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    DateObject dateObject = (DateObject) ModelFactory.getDefaultModel().getDateSystemClass().newObject();

The XML representation of the date object depicted above is as follows:

casebase.xml

    <cdol:A c="Date" v="2012-12-21" id="testDate"/>

To create a subclass of the Date class, the following XML definition can be used:

model.xml

    <DateClass name="customDateClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    DateClass dateClass = (DateClass) ModelFactory.getDefaultModel().getDateSystemClass();
    DateClass customDateClass = (DateClass) dateClass.createSubclass("customDateClass");
    customDateClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    DateObject customDateObject = (DateObject) ModelFactory.getDefaultModel().createObject("customDateClass");

The XML representation of the date object depicted above is as follows:

casebase.xml

    <cdol:A c="customDateClass" v="2012-12-21" id="testDateCustom"/>

Time #

The Time class is the specification of a time (without date information). It represents time as a value in milliseconds. The Time object extends the java.sql.Time as native object. This class extends the java.sql.Date class. The Time class refers similar to the Date class to the 1st of January 1970.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    TimeObject timeObject = (TimeObject) ModelFactory.getDefaultModel().getTimeSystemClass().newObject();

The XML representation of the time object depicted above is as follows:

casebase.xml

    <cdol:A c="Time" v="11:11:11" id="testTime"/>

To create a subclass of the Time class, the following XML definition can be used:

model.xml

    <TimeClass name="customTimeClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    TimeClass timeClass = ModelFactory.getDefaultModel().getTimeSystemClass();
    TimeClass customTimeClass = (TimeClass) timeClass.createSubclass("customTimeClass");
    customTimeClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    TimeObject customTimeObject = (TimeObject) ModelFactory.getDefaultModel().createObject("customTimeClass");

The XML representation of the time object depicted above is as follows:

casebase.xml

    <cdol:A c="customTimeClass" v="11:11:11" id="testTimeCustom"/>

Timestamp #

The Timestamp class is the specification of a date (with time information). It represents a date in the format yyyy-mm-dd hh:mm:ss and if desired, the seconds can be represented in smaller units with more characters. The Timestamp object extends the java.sql.Timestamp as native object. To be consistent with the Date and Time class, it is also not possible to represent a day before the 1st of January 1970.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    TimestampObject timestampObject = (TimestampObject) ModelFactory.getDefaultModel().getTimestampSystemClass().newObject();

The XML representation of the timestamp object depicted above is as follows:

casebase.xml

    <cdol:A c="Timestamp" v="2012-12-21 11:11:11.111" id="testTimestamp"/>

To create a subclass of the Timestamp class, the following XML definition can be used:

model.xml

    <TimestampClass name="customTimestampClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    TimestampClass timestampClass = ModelFactory.getDefaultModel().getTimestampSystemClass();
    TimestampClass customTimestampClass = (TimestampClass) timestampClass.createSubclass("customTimestampClass");
    customTimestampClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    TimestampObject customTimestampObject = (TimestampObject) ModelFactory.getDefaultModel().createObject("customTimestampClass");

The XML representation of the timestamp object depicted above is as follows:

casebase.xml

    <cdol:A c="customTimestampClass" v="2012-12-21 11:11:11.111" id="testTimestampCustom"/>

Numeric #

The Numeric class defines a specific numerical object. The NumericClass is an abstract class that can not be instantiated directly. Thus, one of the inherited classes must be used:

Please note that all objects of numeric classes are totally ordered.

Double #

The Double class specifies double values similar to programming languages.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    DoubleObject doubleObject = (DoubleObject) ModelFactory.getDefaultModel().getDoubleSystemClass().newObject();

The XML representation of the double object depicted above is as follows:

casebase.xml

    <cdol:A c="Double" v="0.0" id="testDouble"/>

To create a subclass of the Double class, the following XML definition can be used:

model.xml

    <DoubleClass name="customDoubleClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    DoubleClass doubleClass = ModelFactory.getDefaultModel().getDoubleSystemClass();
    DoubleClass customDoubleClass = (DoubleClass) doubleClass.createSubclass("customDoubleClass");
    customDoubleClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    DoubleObject customDoubleObject = (DoubleObject) ModelFactory.getDefaultModel().createObject("customDoubleClass");

The XML representation of the double object depicted above is as follows:

casebase.xml

    <cdol:A c="customDoubleClass" v="0.0" id="testDoubleCustom"/>

Integer #

The Integer class specifies integer values similar to programming languages.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    IntegerObject integerObject = (IntegerObject) ModelFactory.getDefaultModel().getIntegerSystemClass().newObject();

The XML representation of the integer object depicted above is as follows:

casebase.xml

    <cdol:A c="Integer" v="0" id="testInteger"/>

To create a subclass of the Integer class, the following XML definition can be used:

model.xml

    <IntegerClass name="customIntegerClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    IntegerClass integerClass = ModelFactory.getDefaultModel().getIntegerSystemClass();
    IntegerClass customIntegerClass = (IntegerClass) integerClass.createSubclass("customIntegerClass");
    customIntegerClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    IntegerObject customIntegerObject = (IntegerObject) ModelFactory.getDefaultModel().createObject("customIntegerClass");

The XML representation of the integer object depicted above is as follows:

casebase.xml

    <cdol:A c="customIntegerClass" v="0" id="testIntegerCustom"/>

<cdol:A c="customIntegerClass" v="0" id="testIntegerCustom"/>

String #

The String class defines the domain of String objects that represent string values.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    StringObject stringObject = (StringObject) ModelFactory.getDefaultModel().getStringSystemClass().newObject();

The XML representation of the string object depicted above is as follows:

casebase.xml

    <cdol:A c="String" v="" id="testString"/>

To create a subclass of the String class, the following XML definition can be used:

model.xml

    <StringClass name="customStringClass"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    StringClass stringClass = ModelFactory.getDefaultModel().getStringSystemClass();
    StringClass customStringClass = (StringClass) stringClass.createSubclass("customStringClass");
    customStringClass.finishEditing();

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    StringObject customStringObject = (StringObject) ModelFactory.getDefaultModel().createObject("customStringClass");

The XML representation of the string object depicted above is as follows:

casebase.xml

    <cdol:A c="customStringClass" v="" id="testStringCustom"/>

URI #

The URI class specifies a URI value from an ontology. The class is abstract, so it has to be subclassed and provided with an ontology name. Each URI class has to be linked to an ontology via its name. This must be done in advance in the composition file as described here.

Such a composition entry can look as follows:

composition.xml

    <Factory name="ontology" class="de.uni_trier.wi2.procake.utils.ontology.OntologyFactory">
        <Implementation class="de.uni_trier.wi2.procake.utils.ontology.OntologyFactoryObjectImpl">
            <Parameter name="ontologyName" value="pizza"/>
            <Parameter name="ontologyPath" value="https://protege.stanford.edu/ontologies/pizza/pizza.owl"/>
        </Implementation>
    </Factory>

A creation in XML can look as follows:

model.xml

    <URIClass name="customPizzaClass" ontologyName="pizza"/>

To create a subclass of this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    URIClass customPizzaClass = (URIClass) ModelFactory.getDefaultModel().getURISystemClass().createSubclass("customPizzaClass");
    customPizzaClass.setOntologyName("pizza");
    customPizzaClass.setAbstract(false);
    customPizzaClass.finishEditing();

The actual ontology has to be loaded beforehand from a file via the OntologyFactory where the name of the ontology has to be specified (see here → OntologyFactory).

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    URIObject customPizzaObject = ModelFactory.getDefaultModel().createObject("customPizzaClass");
    customPizzaObject.setNativeURI("http://www.co-ode.org/ontologies/pizza/pizza.owl#TomatoTopping");

The system throws an exception when the given URI value is not part of the ontology of the corresponding class.

The XML representation of the URI object depicted above is as follows:

casebase.xml

    <cdol:A c="customPizzaClass" v="http://www.co-ode.org/ontologies/pizza/pizza.owl#TomatoTopping" id="testURI"/>

Restricting value ranges #

The range of values of atomic classes may be restricted using an InstancePredicate. The following hierarchy of InstancePredicates exists in ProCAKE:

graph TD; InstancePredicate --> InstanceEnumerationPredicate; InstanceEnumerationPredicate --> InstanceValueOrderPredicate; InstanceValueOrderPredicate --> InstanceTaxonomyOrderPredicate; InstanceValueOrderPredicate --> InstanceTotalOrderPredicate; InstancePredicate --> InstanceIntervalPredicate; InstancePredicate --> InstanceOntologyOrderPredicate;

The following classes can be instantiated as predicate for atomic classes:

Instantiable PredicatesPermitted data classesMethods in AtomicClass for creation
InstanceEnumerationPredicateAll Atomic classescreateNewInstanceEnumerationPredicate()
InstanceTaxonomyOrderPredicateString classcreateNewInstanceTaxonomyOrderPredicate()
InstanceTotalOrderPredicateString classcreateNewInstanceTotalOrderPredicate()
InstanceIntervalPredicateNumeric or chronological classcreateNewInstanceIntervalPredicate()
InstanceOntologyOrderPredicateURI classcreateNewInstanceOntologyOrderPredicate()

Please note that predicates can be only defined for custom atomic classes since system classes are abstract and not customizable. At run-time, it can be created using the methods of AtomicClass, presented in the table above.

An interval predicate may be only used for Atomic classes that have totally ordered instances such as instances of subclasses from the Numeric or the Chronologic class. For example, a class Age as a subclass of the Integer class may restrict the value range to 0 and 150. These intervals are just restrictions of possible values of an attribute as a member of an Atomic class. It is not possible to define intervals in instances of classes.

An enumeration predicate restricts the set of valid values for a class. For example, a class Color as a subclass of the String class may restrict valid values to red, green, and blue. Furthermore, the enumeration of values can be ordered totally or arranged in taxonomies. An exceptional role plays the Atomic class ByteArray that can be used to store more complex data objects like serialized images or serialized documents. Internally, it is an array of bytes but conceptually it is used as one value, e.g., one serialized object.

It’s also possible to create a class using an enumeration predicate, that is a subclass of a custom class, which also uses an enumeration predicate. In this case, the restrictions of the super class are inherited to the subclass.

An ontology order predicate works similarly to an enumeration predicate by restricting the valid values for a class. The validity of values is restricted to these present in the subgraph represented by the given root node URI and the given set of relations.

InstanceIntervalPredicate #

In ProCAKE it is possible to set a lower and an upper bound to restrict the possible values for a custom Numeric or Chronological class. The definition of a lower and an upper bound can be defined in the model.xml file.

For example

model.xml

    <IntegerClass name="customIntegerInstanceIntervalPredicateClass" abstract="false">
        <InstanceIntervalPredicate lowerBound="0" upperBound="100"/>
    </IntegerClass>
would create a subclass of Integer. The values for objects of this class are restricted from 0 to 100. Trying to create an object with other values would cause an exception.

To create this class during runtime, the following java code can be used:

Wiki_AtomicTest.java

    IntegerClass integerClass = ModelFactory.getDefaultModel().getIntegerSystemClass();
    IntegerClass customIntegerClass = (IntegerClass) integerClass.createSubclass("customIntegerInstanceIntervalPredicateClass");
    InstanceIntervalPredicate instanceIntervalPredicate = customIntegerClass.createNewInstanceIntervalPredicate();
    IntegerObject lowerBound = (IntegerObject) integerClass.newObject();
    lowerBound.setValueFromString("0");
    instanceIntervalPredicate.setMinimum(lowerBound);
    IntegerObject upperBound = (IntegerObject) integerClass.newObject();
    upperBound.setValueFromString("100");
    instanceIntervalPredicate.setMaximum(upperBound);
    customIntegerClass.finishEditing();
Here, two Integer objects need to be created that represent the values for the lower and the upper bound. To set these values, it is necessary to get an InstanceIntervalPredicate. This can be called by using the class method createNewInstanceIntervalPredicate().

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    IntegerObject customIntegerObject = (IntegerObject) ModelFactory.getDefaultModel().createObject("customIntegerInstanceIntervalPredicateClass");
The value of this object can be set by using the method setNativeInteger of the parent class. If trying to use a value that is not in the defined interval, an exception will be thrown.

InstanceEnumerationPredicate #

In ProCAKE, it is possible to restrict the possible values for a custom Atomic class to a set of valid values. This definition can be specified in the model.xml file.

For example

model.xml

    <StringClass name="customInstanceEnumerationPredicateClass">
        <InstanceEnumerationPredicate>
            <Value v="1"/>
            <Value v="2"/>
            <Value v="3"/>
        </InstanceEnumerationPredicate>
    </StringClass>
would create a subclass of String (with numeric values represented as String). There are only three possible values that objects of this class can have: 1, 2, and 3. Trying to create an object with other values would cause an exception.

To create this class during runtime, the following java code should be used:

Wiki_AtomicTest.java

    StringClass stringClass = ModelFactory.getDefaultModel().getStringSystemClass();
    StringClass testEnumerationClass = (StringClass) stringClass.createSubclass("testEnumerationClass");
    InstanceEnumerationPredicate instanceEnumerationPredicate = testEnumerationClass.createNewInstanceEnumerationPredicate();
    StringObject firstValue = (StringObject) stringClass.newObject();
    firstValue.setValueFromString("1");
    instanceEnumerationPredicate.addValue(firstValue);
    testEnumerationClass.addAtomicObject(firstValue);
    StringObject secondValue = (StringObject) stringClass.newObject();
    secondValue.setValueFromString("2");
    instanceEnumerationPredicate.addValue(secondValue);
    testEnumerationClass.addAtomicObject(secondValue);
    StringObject thirdValue = (StringObject) stringClass.newObject();
    thirdValue.setValueFromString("3");
    instanceEnumerationPredicate.addValue(thirdValue);
    testEnumerationClass.addAtomicObject(thirdValue);
    testEnumerationClass.finishEditing();
The InstanceEnumerationPredicate can be created by using the method createNewInstanceEnumerationPredicate(). Here, a String object (in general an Atomic object) needs to be created for each value. These can be added to the InstanceEnumerationPredicate by using the method addValue. They also need to be added to the created class by using the method addAtomicObject.

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    StringObject customStringObject = (StringObject) ModelFactory.getDefaultModel().createObject("testEnumerationClass");
The value of this object can be set by using the method setValueFromString of the parent class. If trying to use a value that is not in the defined set, an exception will be thrown.

InstanceValueOrderPredicate #

InstanceTotalOrderPredicate #

It is possible to define a total order for the values of a String class. Other Atomic classes are not allowed for this type.

To create such an order, the model.xml file may be extended as follows:

model.xml

    <StringClass name="Weekdays">
        <InstanceTotalOrderPredicate>
            <Value v="Monday"/>
            <Value v="Tuesday"/>
            <Value v="Wednesday"/>
            <Value v="Thursday"/>
            <Value v="Friday"/>
            <Value v="Saturday"/>
            <Value v="Sunday"/>
        </InstanceTotalOrderPredicate>
    </StringClass>
Here, the custom atomic class is a subclass of the String system class. The custom defined class has the values Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. The order is created in the tag InstanceTotalOrderPredicate. This predicate inherits from its super predicate InstanceEnumerationPredicate. All values, defined in the total order are also the only allowed values for this class. The order is defined by listing the values according to this order.

By using this order during runtime, only the values that are defined in the atomic class can be used. Otherwise, an exception would be thrown. The runtime creation can look like:

Wiki_AtomicTest.java

    StringClass stringClass = ModelFactory.getDefaultModel().getStringSystemClass();
    AtomicClass weekdaysClass = (AtomicClass) stringClass.createSubclass("Weekdays");
    InstanceTotalOrderPredicate instanceTotalOrderPredicate = weekdaysClass.createNewInstanceTotalOrderPredicate();

    StringObject monday = (StringObject) stringClass.newObject();
    monday.setValueFromString("Monday");
    instanceTotalOrderPredicate.add(monday);
    weekdaysClass.addAtomicObject(monday);
    StringObject tuesday = (StringObject) stringClass.newObject();
    tuesday.setValueFromString("Tuesday");
    instanceTotalOrderPredicate.add(tuesday);
    weekdaysClass.addAtomicObject(tuesday);
    StringObject wednesday = (StringObject) stringClass.newObject();
    wednesday.setValueFromString("Wednesday");
    instanceTotalOrderPredicate.add(wednesday);
    weekdaysClass.addAtomicObject(wednesday);
    StringObject thursday = (StringObject) stringClass.newObject();
    thursday.setValueFromString("Thursday");
    instanceTotalOrderPredicate.add(thursday);
    weekdaysClass.addAtomicObject(thursday);
    StringObject friday = (StringObject) stringClass.newObject();
    friday.setValueFromString("Friday");
    instanceTotalOrderPredicate.add(friday);
    weekdaysClass.addAtomicObject(friday);
    StringObject saturday = (StringObject) stringClass.newObject();
    saturday.setValueFromString("Saturday");
    instanceTotalOrderPredicate.add(saturday);
    weekdaysClass.addAtomicObject(saturday);
    StringObject sunday = (StringObject) stringClass.newObject();
    sunday.setValueFromString("Sunday");
    instanceTotalOrderPredicate.add(sunday);
    weekdaysClass.addAtomicObject(sunday);

    weekdaysClass.finishEditing();
This code is nearly the same as above in the Enumeration example. Additionally, the total order is created by using the method createNewInstanceTotalOrderPredicate instead of the creation of InstanceEnumerationPredicate. After this, the values have to be added with the method add in the preferred order (which also calls the method addValue of InstanceEnumerationPredicate, if not done manually).

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    StringObject customStringObject = (StringObject) ModelFactory.getDefaultModel().createObject("Weekdays");

InstanceTaxonomyOrderPredicate #

Taxonomies can be used to specify relationships between attribute values. In contrast to enumerations that only contain possible attribute values, a taxonomy represents an additional relationship between the symbols by their position in the taxonomy. A taxonomy is a n-ary tree in which the nodes represent symbolic values, i.e., string objects. Taxonomies can be build upon only StringObject by enumerating values and building a tree-like structure with a TaxonomyOrder.

In the model.xml file, the name of the StringClass and the corresponding super class that determines which kind of values are used must be defined. The tree structure of the values is specified by nesting nodes in the InstanceTaxonomyOrderPredicate. This predicate inherits from its super predicate InstanceEnumerationPredicate. All values, defined in the taxonomy order are also the only allowed values for this class. The order is defined by listing the values according to this order.

For example

model.xml

    <StringClass name="GraphicCardType">
        <InstanceTaxonomyOrderPredicate>
            <Node v="Graphics Card">
                <Node v="S3 Graphics Card">
                    <Node v="S3 Virge Card">
                        <Node v="ELSA 2000"/>
                        <Node v="Stealth 3D200"/>
                    </Node>
                    <Node v="S3 Trio Card">
                        <Node v="Miro Video"/>
                        <Node v="VGA V64"/>
                    </Node>
                </Node>
                <Node v="MGA Graphics Card">
                    <Node v="Matrox Mill. 220"/>
                    <Node v="Matrox Mystique"/>
                </Node>
            </Node>
        </InstanceTaxonomyOrderPredicate>
    </StringClass>

creates the atomic class GraphicCardType with the default system super class String. During runtime, several graphic cards can be instantiated, and the taxonomy defines their order.

To create this class during runtime, the following java code has to be used:

Wiki_AtomicTest.java

    StringClass stringClass = ModelFactory.getDefaultModel().getStringSystemClass();
    StringClass taxonomyStringClass = (StringClass) stringClass.createSubclass("GraphicCardType");

    InstanceTaxonomyOrderPredicate instanceTaxonomyOrderPredicate = taxonomyStringClass.createNewInstanceTaxonomyOrderPredicate();

    StringObject graphicsCard = (StringObject) stringClass.newObject();
    graphicsCard.setValueFromString("Graphics Card");
    instanceTaxonomyOrderPredicate.addValue(graphicsCard);
    instanceTaxonomyOrderPredicate.addRelation(null, graphicsCard);

    StringObject s3GraphicsCard = (StringObject) stringClass.newObject();
    s3GraphicsCard.setValueFromString("S3 Graphics Card");
    instanceTaxonomyOrderPredicate.addValue(s3GraphicsCard);
    instanceTaxonomyOrderPredicate.addRelation(graphicsCard, s3GraphicsCard);
    StringObject s3VirgeCard = (StringObject) stringClass.newObject();
    s3VirgeCard.setValueFromString("S3 Virge Card");
    instanceTaxonomyOrderPredicate.addRelation(s3GraphicsCard, s3VirgeCard);
    StringObject elsa2000 = (StringObject) stringClass.newObject();
    elsa2000.setValueFromString("ELSA 2000");
    instanceTaxonomyOrderPredicate.addRelation(s3VirgeCard, elsa2000);
    StringObject stealth3D200 = (StringObject) stringClass.newObject();
    stealth3D200.setValueFromString("Stealth 3D200");
    instanceTaxonomyOrderPredicate.addRelation(s3VirgeCard, stealth3D200);
    StringObject s3TrioCard = (StringObject) stringClass.newObject();
    s3TrioCard.setValueFromString("S3 Trio Card");
    instanceTaxonomyOrderPredicate.addRelation(s3GraphicsCard, s3TrioCard);
    StringObject miroVideo = (StringObject) stringClass.newObject();
    miroVideo.setValueFromString("Miro Video");
    instanceTaxonomyOrderPredicate.addRelation(s3TrioCard, miroVideo);
    StringObject vgaV64 = (StringObject) stringClass.newObject();
    vgaV64.setValueFromString("VGA V64");
    instanceTaxonomyOrderPredicate.addRelation(s3TrioCard, vgaV64);
    StringObject mgaGraphicsCard = (StringObject) stringClass.newObject();
    mgaGraphicsCard.setValueFromString("MGA Graphics Card");
    instanceTaxonomyOrderPredicate.addRelation(graphicsCard, mgaGraphicsCard);
    StringObject matroxMill220 = (StringObject) stringClass.newObject();
    matroxMill220.setValueFromString("Matrox Mill. 220");
    instanceTaxonomyOrderPredicate.addRelation(mgaGraphicsCard, matroxMill220);
    StringObject matroxMystique = (StringObject) stringClass.newObject();
    matroxMystique.setValueFromString("Matrox Mystique");
    instanceTaxonomyOrderPredicate.addRelation(mgaGraphicsCard, matroxMystique);

    taxonomyStringClass.finishEditing();
The InstanceTaxonomyOrderPredicate can be created by using the method createNewInstanceTaxonomyOrderPredicate(). For each value, a String object needs to be created. They and their parent node need to be added to the TaxonomyOrder by using the method addRelation(AtomicObject fatherNode, AtomicObject currentNode) of the taxonomy order (which also calls the method addValue of InstanceEnumerationPredicate, if not done manually).

To create an object of this class, the following java code has to be used:

Wiki_AtomicTest.java

    StringObject customStringObject = (StringObject) ModelFactory.getDefaultModel().createObject("GraphicCardType");
    customStringObject.setNativeString("Miro Video");

The class TaxonomyUpdater can also be used to create taxonomies. In it, a taxonomy can be created that contains both, the node values and the node similarity weights (for measure Classic User Weights). From this, the model and the sim model can be created. The application of the TaxonomyUpdater is described here.

Inheritance of Enumerations #

It is also possible to create your own Atomic class that has its own Atomic class as a superclass. If the superclass has a value enumeration (defined directly or in its order), this can also be used for the current class. The values of the superclass are automatically inherited by the subclass as the default of the inherit attribute is set to true. If the values of the superclass are not to be inherited, then inherit must be set to false. It is also possible to define new values in a new value enumeration that are only allowed in the new class and extend the allowed values.

For example, such a class can look like:

model.xml

    <StringClass name="GraphicsCardInheritanceClass" superClass="GraphicCardType">
        <InstanceEnumerationPredicate>
            <Value v="GeForce RTX 2060"/>
        </InstanceEnumerationPredicate>
    </StringClass>

In this case, an atomic class is created, which allows the values of the class GraphicCardType. Additionally, the new value GeForce RTX 2060 is added for this class. The creation of this class during runtime is analogous to the creation of the InstanceEnumeration class. Here, only “GraphicCardType” has to be specified as superclass instead of the general string class.

If an inherited class uses a InstanceValueOrderPredicate, it’s necessary, that all values, defined in the super class, are also existing in the super class. Otherwise, an exception would be thrown. It’s also possible, to inherited from other Atomic classes with InstancePredicates (for example, a Numeric class with a ValueEnumeration inherits from a Numeric class with an interval). In such cases, no specific behavior is provided. There is no check of the value range, but by means of the logger a warning is issued.

InstanceOntologyOrderPredicate #

This predicate can restrict the possible values to a subset of entities in the ontology. By providing a root node URI and a set of relations, a set of valid values is collected by traversing the subtree which is defined by the root and by the nodes reachable via the given relations.

Example:

model.xml

    <URIClass name="Pizza" ontologyName="pizza">
        <InstanceOntologyOrderPredicate rootNodeURI="http://www.co-ode.org/ontologies/pizza/pizza.owl#NamedPizza">
            <Relation type="rdfs:subClassOf"/>
            <Relation type="rdf:type"/>
        </InstanceOntologyOrderPredicate>
    </URIClass>
This allows http://www.co-ode.org/ontologies/pizza/pizza.owl#NamedPizza and all subclasses or individuals (via the rdf:type relation) in arbitrary depth of NamedPizza as values for objects of the class MyURIClass.

To create this class, the following java code can be used:

Wiki_AtomicTest.java

    URIClass pizzaClass = (URIClass) ModelFactory.getDefaultModel().getURISystemClass().createSubclass("Pizza");
    pizzaClass.setOntologyName("pizza");
    InstanceOntologyOrderPredicate pizzaPredicate = pizzaClass.createNewInstanceOntologyOrderPredicate();
    pizzaPredicate.init("http://www.co-ode.org/ontologies/pizza/pizza.owl#NamedPizza", "rdfs:subClassOf", "rdf:type");
    pizzaClass.setAbstract(false);
    pizzaClass.finishEditing();

To create a set of pizza toppings, the following java code can be used:

Wiki_AtomicTest.java

    SetClass pizzaToppingsClass = (SetClass) ModelFactory.getDefaultModel().getSetSystemClass().createSubclass("PizzaToppings");
    pizzaToppingsClass.setElementClass(pizzaClass);
    pizzaToppingsClass.finishEditing();

To create an object of this class, the following java code can be used:

Wiki_AtomicTest.java

    URIObject obj = ModelFactory.getDefaultModel().createObject("Pizza");
    obj.setNativeURI("http://www.co-ode.org/ontologies/pizza/pizza.owl#American");