1
// import Visconte.Onto;
9
* <p>class OWLItem - Represents an abstract OWL Item. this class shouldnt be instantiated not directly. Use one of the Subclasses instead
10
* with dynamic binding OWLItem x = OWLClass(....), you can bind the this class in your code
12
* Construction of all subclasses OWLItems:
13
* For a construction of a new Item use the OWLItemFactory Class - it checks the data for consitence
14
* For retrieval use the get_item methods in class ontology, which will return valid and existing items
17
* If you change any property in an item it will not directly be saved to the ontology. If you want to commit your changes
18
* use the method update(OWLItem) in class ontology e.g. from the ActionClass with ontology->update(YourItem)
20
* Not functional by now:
21
* The euqivalent and different_from restrictions on a class are implementend it this datatstructure, but not in the ontology class.
22
* The restrictions of properties e.g. symetric etc. are also functional here, but not in the ontology class
23
* Working with this elements will (up to now) not be represented in the ontology
31
* <p>Represents the type of the item, with the constants listed below,
32
* subclasses have to replace this type</p>
34
public constant ITEMTYPE = 0;
37
* <p>Represents a Class</p>
39
public constant CLASS = 1;
42
* <p>Represents an Individual</p>
44
public constant INDIVIDUAL = 2;
47
* <p>Represents an Oject Property</p>
49
public constant OBJECT_PROPERTY = 3;
52
* <p>Represents Datatype Property</p>
54
public constant DATATYPE_PROPERTY = 4;
57
* <p>Represents the unique id of the item
58
* to ensure this id is really unique, items should
59
* be constructed with OWLItemFactory</p>
64
* <p>Represents the ontology, this
65
* variable will be init in the subclasses</p>
67
static Visconte.Onto.Ontology ontology;
70
* <p>Represents the labels with the
71
* connected language flag, e.g en fr de etc.
72
* ["en"]:["my label"]</p>
74
static mapping(string:string) label =(["en":""]);
78
* <p>Returns the date of last change in unixtime</p>
81
* @return string timestamp
83
public string get_date_of_change() {
84
return ontology->get_meta(this_object())["lastChanged"];
88
* <p>Returns the author last edited the item</p>
91
* @return string name of author
93
public string get_last_author() {
94
return ontology->get_meta(this_object())["author"];
99
* <p>Returns the id of the Item</p>
104
public string get_Id() {
112
* <p>Test for inequality</p>
117
public int `!=(OWLItem item) {
119
return !is_equal(item);
125
* <p>Test for equality by id comapring the id's</p>
130
public int is_equal(OWLItem item) {
132
return(this_program::id==item->get_Id());
137
* <p>Sets a label for the desired language</p>
138
* the mapping is structured as language code (ed,de,etc...) and label
139
* currently only english is supported!
141
* @param mapping label the label
143
public void set_Label(mapping label)
145
//set the label to the language
147
this_program::label=label;
153
* <p>Get the label for the desired language</p>
154
* currently en is the only supported language code
156
* @param string lang - the language code (en,de etc..)
159
public string get_Label(string|void lang)
161
string item_label="";
164
item_label = label[lang];
168
item_label = label["en"];
181
* Represents an OWL Class Element and provides different properties and connections to other items</p>
182
* see Comment Header in OWLItem for more details!
195
* <p>Represents the type of the item, which is CLASS here</p>
197
public constant ITEMTYPE = CLASS;
200
* <p>Represents the id of the parent class</p>
202
public mixed parent_id;
205
* <p>Represents the ids of the direct childs</p>
207
private array childs ;
209
* <p>Represents the connected individuals</p>
211
private array individuals ;
214
* <p>Represents the connected properties whrer this class is the domain object</p>
216
private array domain_properties ;
219
* <p>Represents the connected properties where this class is the range object</p>
221
private array range_properties ;
224
* <p>contains all class which are set equal to this one</p>
226
private array equivalent_Class=({});
230
* <p>Contains all class which are set different from this</p>
232
private array different_From=({});;
236
* <p>Construct a Class</p>
239
* @param ontology - the ontology object operating on
240
* @param id - the id of the class
241
* @param mixed parent_id - class id this is subclass of
242
* (either int 0, which will be a subclass of Thing, or the id as string)
243
* @param mapping label - the label mapping (e.g. (["en":"Iam the label"])
244
* @param array domain_properties - array with the ids of the Object- and DataProperties this class acts as domain in
245
* @param array range_properties - array with the ids of the ObjectProperties this class acts as range in
246
* @param array childs - array with the ids of the subclasses
247
* @param array individuals - array with the ids of the individuals which where templated from this class (not inherited!)
248
* @param array equivalent_Class - array with the ids of the equivalent classes
249
* @param array different_From - array with the ids of the different classes which are different from
252
public void create(Visconte.Onto.Ontology ontology, string id, mixed parent_id, mapping label,
253
array domain_properties, array range_properties, array childs, array individuals, array equivalent_Class, array different_From)
259
this_program::parent_id="#Thing";
261
this_program::parent_id=parent_id;
262
this_program::ontology=ontology;
264
this_program::label=label;
265
this_program::domain_properties = domain_properties;
266
this_program::childs = childs;
267
this_program::individuals=individuals;
268
this_program::range_properties=range_properties;
269
this_program::equivalent_Class=equivalent_Class;
270
this_program::different_From=different_From;
275
* <p>Is this class a document term</p>
280
public int is_document_term()
282
int isDocumentTerm = 0;
283
if(ontology->is_document_term(this_object()))
287
object owl_class = this_object();
288
while(owl_class->has_parent())
290
owl_class=owl_class->get_parent();
291
if(ontology->is_document_term(owl_class))
300
return isDocumentTerm;
303
* <p>This Method adds the equivalenClass and differentFrom to the
304
* associated classes </p>
309
public void mirror_restrictions()
311
//if myself exists in the ontology
312
if(ontology->item_exists(this_program::id))
314
foreach (equivalent_Class, string class_id)
316
equivalent_Class-=({class_id});
317
set_equivalent_class(class_id);
319
foreach (different_From, string class_id)
321
different_From-=({class_id});
322
set_different_from_class(class_id);
329
* <p>Get the Properties where this class acts as range</p>
332
* @return Visconte.Onto.OWLContainer - filled with OWLProperties
334
public Visconte.Onto.OWLContainer get_range_properties()
336
return ontology->get_Items(range_properties);
342
* <p>Get the Properties where this class acts as domain</p>
345
* @return Visconte.Onto.OWLContainer - filled with OWLProperties
347
public Visconte.Onto.OWLContainer get_domain_properties()
349
return ontology->get_Items(domain_properties);
354
* <p>Returns all Domain properties of this class (inherited and self)</p>
357
* @return Visconte.Onto.OWLContainer - filled with OWLProperties
359
public Visconte.Onto.OWLContainer get_inherited_domain_properties()
363
Visconte.Onto.OWLContainer domains = get_domain_properties() ;
366
OWLClass parent = get_parent();
368
domains->merge(parent->get_inherited_domain_properties());
375
* <p>Returns an array whith the domain ids (only self) </p>
378
* @return array(string) -- ids
380
public array get_property_ids()
382
return domain_properties;
388
* <p>Returns the classes which are equivalent to this</p>
391
* @return Visconte.Onto.OWLContainer - filled with OWLClass
393
public Visconte.Onto.OWLContainer get_equivalent_classes()
395
return ontology->get_Items(equivalent_Class);
400
* <p>Resets all restrictions of equivalent and different classes.</p>
405
public void unset_restrictions()
408
foreach(equivalent_Class, string id)
409
unset_equivalent_class(id);
412
foreach(different_From, string id)
413
unset_different_from_class(id);
417
* <p>Unset a class from the equal state.</p>
418
* TODO: Allow OWLClass object as param
419
* @param string id of the class
422
public int unset_equivalent_class(string id)
425
if(has_equivalent_class(id))
428
int pos = (search(equivalent_Class,id));
429
equivalent_Class-=({equivalent_Class[pos]});
430
ontology->update(this_object());
431
//remove the equivalent_class on the other side of "equal sign"
432
OWLClass mirror_class= ontology->get_Class(id);
433
mirror_class->unset_equivalent_class(this_program::id);
434
ontology->update(mirror_class);
443
* <p>Set an Class equivalent</p>
444
* TODO: Allow OWLClass object as param
445
* @param string id of the class
448
public int set_equivalent_class(string id)
452
//if this item is not in the ontology
453
if(!ontology->item_exists(this_program::id))
455
//iam always equal myself, no need to mention it
456
if(id==this_program::id)
458
if(has_different_from_class(id))
459
unset_different_from_class(id);
461
if(!has_equivalent_class(id))
463
if(ontology->item_exists(id))
466
equivalent_Class+=({id});
467
ontology->update(this_object());
468
//add the equivalent_class on the other side of "equal sign"
469
OWLClass mirror_class= ontology->get_Class(id);
470
mirror_class->set_equivalent_class(this_program::id);
471
ontology->update(mirror_class);
481
* <p>Test if this class is equivaletent to another</p>
482
* Note: This is not test euality of two object, rather semantical euivalent
483
* TODO: Allow OWLClass object as param
484
* @param string id of the class
487
public int has_equivalent_class(string id)
489
if(search(equivalent_Class,id)>=0)
503
public int set_different_from_class(string id)
506
//if this item is not in the ontology
507
if(!ontology->item_exists(this_program::id))
509
//cannot be different from myself
510
if(id==this_program::id)
512
if(has_equivalent_class(id))
513
unset_equivalent_class(id);
514
if(!has_different_from_class(id))
516
if(ontology->item_exists(id))
519
different_From+=({id});
520
ontology->update(this_object());
521
//add the different_from class on the other side of "unequal sign"
522
OWLClass mirror_class= ontology->get_Class(id);
523
mirror_class->set_different_from_class(this_program::id);
524
ontology->update(mirror_class);
533
* <p>Unset a Class differentFrom</p>
534
* TODO: Allow OWLClass object as param
535
* @param string id of the class
538
public int unset_different_from_class(string id)
541
if(has_different_from_class(id))
544
int pos = (search(different_From,id));
545
different_From-=({ different_From[pos] });
546
ontology->update(this_object());
547
//remove the different_from class on the other side of "unequal sign"
548
OWLClass mirror_class= ontology->get_Class(id);
549
mirror_class->set_different_from_class(this_program::id);
550
ontology->update(mirror_class);
559
* <p>Tests if a Class differentFrom</p>
560
* TODO: Allow OWLClass object as param
561
* @param string id of the class
564
public int has_different_from_class(string id)
566
if(search(different_From,id)>=0)
573
* <p>Get all Classes which are differentFrom this class</p>
574
* Note: This is semantical difference
575
* @return Visconte.Onto.OWLContainer - filled with OWLClass objects
577
public Visconte.Onto.OWLContainer get_different_from_classes()
579
return ontology->get_Items(different_From);
585
* <p>Test if this class has child resp subclasses</p>
588
* @return int 0 or number of childs
590
public int has_childs()
592
return sizeof(childs);
596
* <p>Get all direct childs of this class</p>
599
* @return Visconte.Onto.OWLContainer - filled with OWLClass
601
public Visconte.Onto.OWLContainer get_childs()
603
return ontology->get_Items(childs);
608
* <p>Get all childs of the underlying subtree</p>
611
* @return Visconte.Onto.OWLContainer - filled with OWLClass
613
public Visconte.Onto.OWLContainer get_all_childs()
615
Visconte.Onto.OWLContainer child_container = Visconte.Onto.OWLContainer();
616
Visconte.Onto.OWLContainer tmp_container = get_childs();
617
while(tmp_container->has_items())
619
OWLItem item = tmp_container->next();
620
child_container->add(item);
621
child_container->merge(item->get_all_childs());
623
return child_container;
627
* <p>Test if this it the root class</p>
628
* The root class is #Thing
634
if(id=="#Thing" || id=="Thing" || id=="owl:Thing")
642
* <p>Checkif this class is an descendant of the other class</p>
644
* @param OWLClass|string the class or id where this is descendant of
647
public int is_descendant_of(OWLClass|string owl_class)
649
OWLClass _class = ontology->get_Item(get_Id());
650
OWLClass possible_ancestor;
651
if(stringp(owl_class))
653
possible_ancestor = ontology->get_Item(owl_class);
656
possible_ancestor = owl_class;
658
if(possible_ancestor->is_root())
665
if(possible_ancestor->is_equal(_class) )
671
if(_class->is_root())
677
_class=_class->get_parent();
683
* <p>Checks if this class has a parent class</p>
684
* Only false if this is the root class
688
public int has_parent()
690
if(ontology->item_exists(parent_id) && !is_root())
699
* <p>Get the parent class of this class, if exists</p>
700
* Note: This implemenation focus on a single inheritance
702
* @return OWLClass - the parent class
704
public OWLClass get_parent()
707
return ontology->get_Class(parent_id);
714
* <p>Set a new parent class</p>
717
* @param OWLClass - the new parent
719
public void set_parent(OWLClass parent)
721
if(parent->get_Id()==0)
722
this_program::parent_id=Visconte.Onto.Ontology.THING;
724
this_program::parent_id=parent->get_Id();
728
* <p>Returns all individuals of this branch (up and down)</p>
729
* This will retrieve all individuals which are in the branch of this class (from root to the leafes)
731
* @return Visconte.Onto.OWLContainer - filled with OWLIndividual
733
public Visconte.Onto.OWLContainer get_all_individuals()
735
Visconte.Onto.OWLContainer ind = get_individuals_up_to_root();
736
ind->merge(get_individuals_down_to_leaf());
741
* <p>Get individuals of this class and the parent classes</p>
744
* @return Visconte.Onto.OWLContainer - filled with OWLIndividual
746
public Visconte.Onto.OWLContainer get_individuals_up_to_root()
748
Visconte.Onto.OWLContainer ind = get_individuals() ;
751
OWLClass parent = get_parent();
753
ind->merge(parent->get_individuals_up_to_root());
763
* <p>Get individuals of this class and all subclasses</p>
766
* @return Visconte.Onto.OWLContainer - filled with OWLIndividual
768
public Visconte.Onto.OWLContainer get_individuals_down_to_leaf()
770
Visconte.Onto.OWLContainer ind = get_individuals() ;
773
Visconte.Onto.OWLContainer child_container = get_childs();
774
while(child_container->has_items())
776
ind->merge(child_container->next()->get_individuals_down_to_leaf());
784
* <p>Get individuals of this class only</p>
787
* @return Visconte.Onto.OWLContainer - filled with OWLIndividual
789
public Visconte.Onto.OWLContainer get_individuals()
791
return ontology->get_Items(individuals);
796
* <p>Get the number of individuals where this class is the template</p>
797
* This will return only the number of individuals of this class, not the inherited ones
799
* @return int - count
801
public int get_number_of_indivduals()
803
return sizeof(individuals);
808
* <p>Get the weight of this class in relation to its depth in the tree level<p>
809
* The weight is the addition of all individuals of the subclasses and the number of individuals of this class
811
* @param int add - add this amount to the weight of all classes in the branch
812
* (usefull within visconte browser for treemap appearance)
815
public int get_weight(int add)
818
int weight = get_number_of_indivduals();
822
Visconte.Onto.OWLContainer child_container = get_childs();
823
while(child_container->has_items())
825
weight+=child_container->next()->get_weight(add);
838
* I N D I V I D U A L S
840
* <p>class OWLIndividual - Represents an Instance of a class</p>
841
* see Comment Header in OWLItem for more details!
850
* <p>Represents the type of the item, which is INDIVIDUAL here</p>
852
public constant ITEMTYPE = INDIVIDUAL;
855
* <p>Represents the id of the model class </p>
857
private string class_id;
860
* <p>Array with all valid properties of this individual</p>
862
private Visconte.Onto.OWLContainer properties;
866
* <p>Array with all associations of this individual</p>
868
private array association_ids =({});
871
* <p>Array with all valid properties of this individual</p>
873
private array(array(mixed)) property_map =({});
877
* <p>Constructor: creates an OWLIndividual. If you want to create an item which isnt in the ontology,
878
* use the OWLItemFactory to construct the Individual</p>
880
* @param ontology The associated Ontology
881
* @param id - the id of the individual
882
* @param class_id -the id of the model class
883
* @param label - mapping with lang:label items
884
* @param properties - the properties which are allowed for this individual (get from model class and its parents)
885
* @param property_values - the Visconte.MVList with the id to value(s) statements
889
public void create( Visconte.Onto.Ontology ontology, string id, string class_id, mapping label, Visconte.Onto.OWLContainer properties, Visconte.MVList property_values)
891
this_program::ontology=ontology;
893
this_program::class_id=class_id;
895
this_program::label=label;
896
this_program::properties = properties;
897
//set the property values to the matching property
899
set_Properties(property_values);
905
* <p>Checks if this individual is a document term</p>
910
public int is_document_term()
912
return this_object()->get_model_class()->is_document_term();
916
* <p>Return the obejctid and the mimetype of a document individual</p>
921
public mapping get_steam_properties()
923
if(is_document_term())
924
return ontology->get_steam_properties(this_object());
926
return ([ "objectid" : "-1", "mimetype" : "-1" ]);
931
* <p>Method to set an Visconte.MVList with index:property value pairs to this individual
932
* It will call the set_Property method to validate the items</p>
937
public void set_Properties(Visconte.MVList property_values)
940
array indexes = property_values->get_indexes();
941
//reset current properties
943
foreach(indexes,string index)
945
foreach(property_values->get(index), string value)
946
set_Property(index,value);
950
* <p>Returns the model class, from which this individual is derived</p>
953
* @return the model class as OWLClass
955
public OWLClass reset_properties() {
956
association_ids =({});
961
* <p>Returns the model class, from which this individual is derived</p>
964
* @return the model class as OWLClass
966
public OWLClass get_model_class() {
968
return ontology->get_Item(class_id);
972
* <p>This sets a new model class for this individual</p>
975
* @param class the new model class
977
public void set_model_class(OWLClass owl_class) {
979
this_program::class_id=owl_class->get_Id();
983
* <p>This method returns checks for the existence
984
* resp. if this property is set.</p>
987
* @return the multi value property list
989
public int has_property(OWLProperty|string property)
991
string property_search_id;
992
if(objectp(property))
993
property_search_id=property->get_Id();
995
property_search_id=property;
997
foreach(property_map,array prop_value)
999
if(prop_value[0]->get_Id()==property_search_id)
1011
* <p>This method returns the value(s) of a property</p>
1014
* @return array with property definition
1016
public array get_property(OWLProperty|string property)
1019
if(objectp(property))
1020
property_id=property->get_Id();
1022
property_id=property;
1024
foreach(property_map,array prop_value)
1026
if(prop_value[0]->get_ID()==property_search_id)
1035
* <p>This method returns the Visconte.MVList of properties.</p>
1038
* @return the multi value property list
1040
public Visconte.MVList get_property_list()
1042
Visconte.MVList property_mv_list = Visconte.MVList();
1043
foreach(property_map,array prop_value)
1045
if(prop_value[0]->ITEMTYPE==Visconte.Onto.Item.OWLItem.OBJECT_PROPERTY)
1046
property_mv_list->add(prop_value[0]->get_Id(),prop_value[1]->get_Id());
1048
property_mv_list->add(prop_value[0]->get_Id(),prop_value[1]);
1050
return property_mv_list;
1054
* <p>Get OWLContainer with all associated individuals
1057
* @return Visconte.Onto.OWLContainer - filled with OWLIndividuals
1059
public Visconte.Onto.OWLContainer get_associations()
1061
return ontology->get_Items(association_ids);
1065
* <p>Test if this Individual is associated with the given one
1070
public int is_associated_with(OWLIndividual|string individual)
1073
if(objectp(individual))
1074
ind_id=individual->get_Id();
1078
if(has_value(association_ids,ind_id))
1085
* <p>Remove all associations with the given individual
1088
* @return int 0|1 success
1090
public int remove_associations_with(OWLIndividual|string individual)
1094
if(objectp(individual))
1095
ind_id=individual->get_Id();
1098
if(is_associated_with(ind_id))
1100
foreach(property_map,array property_set)
1102
if(property_set[0]->ITEMTYPE==OBJECT_PROPERTY && property_set[1]==ind_id)
1103
remove_Property(property_set[0]);
1113
* <p>Remove all associations with the given individual
1116
* @return int 0|1 success
1118
public int replace_individual(OWLIndividual|string individual, OWLIndividual new_id)
1121
array(array(mixed)) tmp_map =({});
1122
if(objectp(individual))
1123
ind_id=individual->get_Id();
1126
if(is_associated_with(ind_id))
1128
foreach(property_map,array property_set)
1130
if(property_set[0]->ITEMTYPE==OBJECT_PROPERTY && property_set[1]==ind_id)
1131
property_set[1]=new_id->get_Id();
1132
tmp_map+=({property_set});
1135
this_program::property_map = tmp_map;
1143
* <p>This method returns an array with the ordering ({ ({ OWLProperty, (string) value})[0..*] })
1144
* used for the xml constuction
1147
* @return the property map as array
1149
public array get_property_map()
1151
return property_map;
1157
* <p>This method sets a property to the individual
1158
* <li>First its checks if the propagated id is a valid property for this
1159
* individual (by checking for equality of the property domain and the model class of this individual
1161
* <li>Then it test if the value is an ObjectProperty and if the given value is an existing instance
1162
* in the ontology. If so, it will be added to the property list and to the property map. The tests for
1163
* a datatype are similar, except the test for a valid value</p>
1166
* @param id - the id of the property
1167
* @param value - either the id of connected individual or a xsd: datatype (depends on property type)
1170
public void set_Property(string id, string value)
1173
property = this_program::properties->find_by_id(id);
1175
//1st test for the existence in the valid properties
1178
//if its an ObjectProperty, test for a valid individual
1179
//and if the model class of the individual is the same
1180
// as the range type of the Property
1181
if(property->ITEMTYPE==OBJECT_PROPERTY)
1183
if(ontology->item_exists(value))
1186
//get the model class of this individual
1187
//get_items_by_subject avoids a ping-pong effect on individuals refering each other
1188
OWLClass model_class = ontology->get_items_by_subject(value,2,CLASS)->next();
1190
//test for equality of the values modelclass (and its parents) and Property range class
1191
// and dont associate with itself
1192
if(model_class->is_descendant_of(property->get_range()) && get_Id()!=value)
1195
// add the value to OWLProperty object
1196
property_map+=({ ({ property, value}) });
1197
// add the id to the association_id array
1198
association_ids+=({value});
1202
//if its a datatype property, proceed here
1206
property_map+=({ ({ property, value}) });
1214
* <p>Removes an property from the indiviudal,
1215
* NOTE: it removes all property values which are "derived" from this property
1216
* If a single index:value pair should be removed, use method: remove_index_value_pair()</p>
1218
* @param OWLProperty - the property to remove
1221
public int remove_Property(OWLProperty property)
1223
foreach(property_map,array prop_value)
1225
if(prop_value[0]->get_Id()==property->get_Id())
1226
property_map-=({prop_value});
1232
* <p>Removes an property from the indiviudal,
1233
* NOTE: it removes all property values which are "derived" from this property
1234
* If a single index:value pair should be removed, use method: remove_index_value_pair()</p>
1236
* @param OWLProperty - the property to remove
1239
public int replace_Property(OWLProperty old_property, OWLProperty new_property) {
1241
foreach(property_map,array prop_value)
1243
if(prop_value[0]->get_Id()==new_property->get_Id())
1244
property_map-=({prop_value});
1245
prop_value[0]=new_property;
1246
property_map+=({prop_value});
1251
* <p>This method removes a single index value pair from this individual</p>
1256
// public int remove_index_value_pair(string id, string value ) {
1258
// foreach(property_map,array prop_value)
1260
// if(property_set[0]->ITEMTYPE==OBJECT_PROPERTY)
1261
// if(prop_value[0]->get_Id()==new_property->get_Id() && property_set[1]==ind_id)
1262
// property_map-=({prop_value});
1263
// prop_value[0]=new_property;
1264
// property_map+=({prop_value});
1271
* <p>This method returns checks for the existence
1272
* resp. if this property is set.</p>
1275
* @return the multi value property list
1277
// public int has_index_value_pair(OWLProperty|string property, string value)
1279
// string property_id;
1280
// if(objectp(property))
1281
// property_id=property->get_Id();
1283
// property_id=property;
1284
// write("has_index_value_pair: ix:"+property_id+", val"+value+"\n");
1285
//test what type of property we are testing for
1286
// OWLProperty index_property = this_program::properties->find_by_id(property_id);
1287
//if object property modify the id
1288
// if(index_property->ITEMTYPE==OBJECT_PROPERTY)
1289
//value = Visconte.Tools()->flat_ID(value);
1291
// return property_mv_list->has_index_value(property_id, value);
1294
} //end class OWLIndividual
1297
* <p>class OWLProperty - This class defines common methods for Object and Datatype Property</p>
1298
* see Comment Header in OWLItem for more details!
1313
* <p>The bitset used for constraints like semtric propertie and so on</p>
1315
protected int bitset = 0b00000;
1318
* <p>The domain of the property, which is in all cases a class</p>
1320
static OWLClass domain;
1324
* <p>Checks if this property is transitive.</p>
1329
public int is_transitive()
1338
* <p>Checks if this property is functional.</p>
1343
public int is_functional() {
1351
* <p>Checks if this property is symetric..</p>
1356
public int is_symetric()
1365
* <p>Checks if this property is inverse of.</p>
1370
public int is_inverse_of()
1379
* <p>Checks if this property is inverse functional.</p>
1384
public int is_inverse_functional()
1393
* <p>Set the constraing bitset</p>
1395
* 0b00001 - transitive
1396
* 0b00010 - functional
1397
* 0b00100 - symetric
1398
* 0b10000 - inverse functional
1400
* Note: up to now this is not function in the ontology script
1403
public void set_restriction_bitset(int bitset)
1405
this_program::bitset=bitset;
1410
* <p>Set the restriction by a string:int mapping</p>
1411
* valid indexes and values
1412
* are (transitive,functional,symetric,inverse,inverse_functional : 0|1)
1414
* @param mapping(string:int) - the restrictions
1416
public void set_restriction(mapping restriction)
1419
if(restriction["transitive"]==1)
1421
if(restriction["functional"]==1)
1423
if(restriction["symetric"]==1)
1425
if(restriction["inverse"]==1)
1427
if(restriction["inverse_functional"]==1)
1430
this_program::bitset=set;
1435
* <p>Returns the domain of this property</p>
1438
* @return OWLClass - the domain class
1440
public OWLClass get_domain() {
1446
* <p>Set a new domain to this property</p>
1448
* @param OWLClass - the new domain class
1451
public OWLClass set_domain(OWLClass domain) {
1452
this_program::domain = domain;
1458
* <p>Returns all individuals with this property (individuals of the domain)</p>
1459
* This will do the same like the method get_individuals_down_to_leaf() in OWLClass
1463
public Visconte.Onto.OWLContainer get_individuals()
1465
return domain->get_individuals_down_to_leaf();
1476
* <p>class OWLObjectProperty - Represents an OWL ObjectProperty, which is also named an association in this library</p>
1477
* see Comment Header in OWLItem for more details!
1479
class OWLObjectProperty
1482
inherit OWLProperty;
1485
* <p>Represents the type of the item, which is CLASS here</p>
1487
public constant ITEMTYPE = OBJECT_PROPERTY;
1491
* <p>The Range class of this object</p>
1493
private OWLClass range;
1498
* <p>Construct an ObjectProperty</p>
1499
* @param ontology - the ontology object to operate on
1500
* @param id - the id of this Object Property
1501
* @param restrictions - a mapping with the restrictions (see set_restriction() in OWLProperty)
1502
* @param mapping label - the label or name of this property
1503
* @param OWLClass domain - the domain of this property
1504
* @param OWLClass range - the range of this property
1508
public void create(Visconte.Onto.Ontology ontology, string id, mapping restriction, mapping label, OWLClass domain, OWLClass range)
1510
this_program::ontology=ontology;
1511
this_program::id=id;
1512
this_program::label=label;
1513
set_restriction(restriction);
1514
this_program::domain=domain;
1515
this_program::range=range;
1521
* <p>Get the range Class of this property</p>
1523
* @return OWLClass - the range class
1525
public OWLClass get_range() {
1530
* <p>Set a new Range class</p>
1532
* @param OWLClass - the new range
1534
public int set_range(OWLItem range) {
1535
this_program::range=range;
1544
* <p>class OWLDataytypeProperty -Represents an OWL Datatype</p>
1545
* see Comment Header in OWLItem for more details!
1547
class OWLDatatypeProperty
1550
inherit OWLProperty;
1556
* <p>Represents the type of the item, which is CLASS here</p>
1558
public constant ITEMTYPE = DATATYPE_PROPERTY;
1561
* <p>The range as string rpresentaion which is an xsd element (e.g string, anyURI etc.)</p>
1563
private string range;
1566
* <p>If no dataytype is specified use (xsd:)string</p>
1568
private string default_dataype="string";
1571
* <p>List of valid datatypes</p>
1573
private array datatypes = ({"string",
1580
"nonNegativeInteger",
1582
"nonPositiveInteger",
1615
* <p>Construct a Datatype Property</p>
1616
* @param ontology - the ontology object to operate on
1617
* @param id - the id of this Datatype Property
1618
* @param restrictions - a mapping with the restrictions (see set_restriction() in OWLProperty)
1619
* @param mapping label - the label or name of this property
1620
* @param OWLClass domain - the domain of this property
1621
* @param string range - the range of this property (xsd element, with or without trailing xsd:)
1625
public void create(Visconte.Onto.Ontology ontology, string id, mapping restriction, mapping label, OWLClass domain, string range)
1627
this_program::ontology=ontology;
1628
this_program::id=id;
1629
this_program::label=label;
1630
set_restriction(restriction);
1631
validate_datatype(range);
1632
this_program::domain=domain;
1638
* <p>Returns the range </p>
1640
* @return string range
1642
public string get_range() {
1646
* <p>Set a new range</p>
1648
* @param string range - xsd element, with or without trailing xsd:
1650
public int set_range(string range) {
1651
validate_datatype(range);
1657
* <p>Validates it the range is valid</p>
1658
* If its not valid set to default_dataype
1661
private void validate_datatype(string datatype)
1663
//if the type has dataype xsd namepace set to string
1664
if(!has_prefix(datatype,"xsd:"))
1665
this_program::range = default_dataype;
1668
//try to find the datatype, else set to string
1669
int type = search(datatypes,datatype[4..]);
1671
this_program::range=datatypes[type];
1673
this_program::range=default_dataype;