2
// import Visconte.Onto;
3
// import Visconte.Onto.Item;
4
// import Visconte.Request;
11
* <p>class Action - A generic action which should not be instanciated at all. Use the dynamic binding instead and define
12
* sublcasses for new actions from this class. e.g GenericAction a = ClassAcion() </p>
13
* Most of the Methods will return an Visconte.Request.Result object, which can be used for xml rendering and finding errors
18
* <p>The type of the action, subclasses should overwrite this value with its action type, e.g for ClassAction use class etc.</p>
20
public constant action_type ="GENERICACTION";
24
* <p>the language of the ontology retrieval</p>
26
protected string lang = "en";
29
* <p>The ontology object</p>
31
protected Visconte.Onto.Ontology ontology;
34
* <p>The Visconte.Onto.Item.OWLItem Factory to produce items</p>
36
protected Visconte.Onto.OWLItemFactory factory = Visconte.Onto.OWLItemFactory();
39
* <p>construcor of the specified action. Use it in dynamic binding style, e.g Action a = ClassAction(...) </p>
42
* @param ontology the ontology
45
public void create(Visconte.Onto.Ontology ontology)
47
this_program::ontology = ontology;
52
* <p>get a specific item</p>
55
* @param ID id - the id of the item to get
56
* @return Visconte.Request.Result - the item
58
public Visconte.Request.Result get_Item(ID id)
62
Visconte.Request.Result res = Visconte.Request.Result();
63
Visconte.Onto.Item.OWLItem owl_item;
66
if(ontology->item_exists(id->ref))
68
owl_item = ontology->get_Item(id->ref);
71
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
74
res->add_Message(Visconte.Request.Message(error));
76
res->set_OWLItem(owl_item);
84
* <p>get a specific item</p>
87
* @param ID id - the id of the item to get
88
* @return Visconte.Onto.Item.OWLItem - the item as object
90
public Visconte.Onto.Item.OWLItem get_RawItem(ID id)
92
Visconte.Onto.Item.OWLItem owl_item;
95
if(ontology->item_exists(id->ref))
97
return ontology->get_Item(id->ref);
106
* <p>Changes the name of any OWLItem
109
* @param ID id - current id of the item to rename
110
* @param label - the new label of the item
111
* @param string comment - a comment for the ontology log
112
* @return Result - the renamed item
114
public Visconte.Request.Result rename(ID id, mapping label, string comment)
116
Visconte.Request.Result res = Visconte.Request.Result();
117
Visconte.Onto.Item.OWLItem item;
122
item = ontology->get_Item(id->ref);
123
oldname= item->get_Label();
124
item->set_Label(label);
125
ontology->update(item);
129
res->add_Message(Visconte.Request.Message(error));
133
switch(item->ITEMTYPE)
136
case Visconte.Onto.Item.OWLItem.CLASS:
137
action = "class_renamed";
140
case Visconte.Onto.Item.OWLItem.OBJECT_PROPERTY:
141
action = "association_renamed";
144
case Visconte.Onto.Item.OWLItem.DATATYPE_PROPERTY:
145
action = "datatype_renamed";
148
case Visconte.Onto.Item.OWLItem.INDIVIDUAL:
149
action = "individual_renamed";
153
action = "unspecified_item_renamed";
157
ontology->add_annotation(item,action,(string)comment,oldname);
159
res->set_OWLItem(item);
169
* <p>class ClassAction - Class related Actions take place in here</p>
173
inherit GenericAction;
177
* <p>move a class to a new location.</p>
180
* @param id the id of the class
181
* @param new_parent the parent id where this class should be moved
182
* @param with_subtree indicate if the subtree should be moved too
183
* @param string comment - a comment for the ontology log
186
public Visconte.Request.Result move(ID class_id, ID new_parent_id, string comment)
188
Visconte.Request.Result res = Visconte.Request.Result();
189
string move_class_label="";
190
Visconte.Onto.Item.OWLItem move_class;
191
Visconte.Onto.Item.OWLItem new_parent;
193
if(ontology->item_exists(class_id->ref) && ontology->item_exists(new_parent_id->ref))
197
move_class = ontology->get_Item(class_id->ref);
198
move_class_label=move_class->get_Label();
199
new_parent = ontology->get_Item(new_parent_id->ref);
200
//test for a possible move to a child of itself
201
if(new_parent->is_descendant_of(move_class->get_Id()))
203
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 221, class_id->ref }) ));
207
move_class->set_parent(ontology->get_Item(new_parent_id->ref));
208
ontology->update(move_class);
211
res->set_OWLItem(move_class);
213
res->add_Message(Visconte.Request.Message(error));
215
ontology->add_annotation(move_class_label,"class_moved",(string)comment,new_parent->get_Label());
217
//check what not exists
220
if(!ontology->item_exists(class_id->ref))
221
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, class_id->ref }) ));
222
if(!ontology->item_exists(new_parent_id->ref))
223
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, new_parent_id->ref }) ));
229
* <p>Add a new class to the ontology</p>
232
* @param ID new_id - the new id of the subclass
233
* @param ID parent_id - the id this class should be subclass of
234
* @param label - mapping with name value pairs: e.g. en->class, de->klasse etc
235
* @param string comment - a comment for the ontology log
238
public Visconte.Request.Result subclass(ID new_id, ID parent_id, mapping label, array equivalent_Class, array different_From , string comment)
240
Visconte.Request.Result res = Visconte.Request.Result();
241
Visconte.Onto.Item.OWLItem new_class;
245
new_class = factory->construct_Class(ontology,new_id,parent_id,label, equivalent_Class, different_From,);
246
ontology->add_Item(new_class);
247
new_class->mirror_restrictions();
254
res->add_Message(Visconte.Request.Message(error));
256
ontology->add_annotation(new_class,"class_subclassed",(string)comment,parent_id->ref);
257
res->set_OWLItem(new_class);
264
* <p>Sets a class as document term for specified object</p>
267
* @param id the id, the comment should linked with
268
* @param isDocumentTerm is this class a document term
271
public int set_as_document_term(ID id,int isDocumentTerm) {
273
Visconte.Onto.Item.OWLItem i = ontology->get_Item(id->ref);
276
ontology->set_as_document_term(i, isDocumentTerm);
282
* <p>Sets a class as document term for specified object</p>
285
* @param id the id, the comment should linked with
286
* @param isDocumentTerm is this class a document term
289
public int is_document_term(ID id) {
291
Visconte.Onto.Item.OWLItem i = ontology->get_Item(id->ref);
292
return i->is_document_term();
295
* <p>Delete all classes under this id recursive</p>
298
* @param ID id the id to delete
302
private int delete_tree(ID id)
305
//first remove all restrictions;
306
set_restrictions(id,0,0,1,"");
307
Visconte.Onto.Item.OWLClass start_class = ontology->get_Item(id->ref);
308
if(!start_class) return 0;
310
if(start_class->has_childs())
312
Visconte.Onto.OWLContainer container = start_class->get_childs();
313
while(container->has_items())
315
delete_tree(ID(container->next()->get_Id(),1));
325
* <p>Delete a class from the ontology</p>
328
* @param ID id the id to delete
329
* @param string comment - a comment for the ontology log
330
* @param string comment - a comment for the ontology log
334
public Visconte.Request.Result delete(ID id, int with_subtree, string comment)
336
Visconte.Request.Result res = Visconte.Request.Result();
337
Visconte.Onto.Item.OWLClass class_to_remove;
341
//the whole subtree should be deleted go recursive
347
//test for the existence of the Class!
348
if(ontology->item_exists(id->ref))
351
class_to_remove = ontology->get_Item(id->ref);
352
class_label=class_to_remove->get_Label();
353
//get the parent of this class
355
Visconte.Onto.Item.OWLClass parent = class_to_remove->get_parent();
357
//define the containers
358
Visconte.Onto.OWLContainer individuals = class_to_remove->get_individuals();
359
Visconte.Onto.OWLContainer child_container = class_to_remove->get_childs();
360
Visconte.Onto.OWLContainer class_is_domain_cnt = class_to_remove->get_domain_properties();
361
Visconte.Onto.OWLContainer class_is_range_cnt = class_to_remove->get_range_properties();
363
//remove the individuals which have this class as constructor
364
while(individuals->has_items())
366
Visconte.Onto.Item.OWLIndividual i = individuals->next();
367
//get the indivduals pointing with an assocaition to this resp. i
368
//and unset this association
369
Visconte.Onto.OWLContainer in_associated = ontology->get_items_by_object(i->get_Id(),0,Visconte.Onto.Item.OWLItem.INDIVIDUAL);
370
while(in_associated->has_items())
372
Visconte.Onto.Item.OWLIndividual in_individual = in_associated->next();
373
in_individual->remove_associations_with(i);
374
ontology->update(in_individual);
378
//give the childs a new parent :)
379
while(child_container->has_items())
381
Visconte.Onto.Item.OWLItem i = child_container->next();
384
i->set_parent(parent);
391
// remove all ObjectProperties where the class act as range
392
while(class_is_range_cnt->has_items())
394
Visconte.Onto.Item.OWLItem i = class_is_range_cnt->next();
395
if(i->ITEMTYPE==Visconte.Onto.Item.OWLItem.OBJECT_PROPERTY)
397
Visconte.Onto.OWLContainer inds_pointing_to_this = i->get_individuals();
401
//remove all properties where the class acta as the domain
402
while(class_is_domain_cnt->has_items())
404
Visconte.Onto.Item.OWLItem i = class_is_domain_cnt->next();
407
//finally remove the class itself
408
ontology->remove(class_to_remove);
414
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, id->ref }) ));
417
}//end if with_subtree
421
res->set_OWLItem(class_to_remove);
423
res->add_Message(Visconte.Request.Message(error));
425
ontology->add_annotation(class_label,"class_deleted",(string)comment,0);
431
* <p>Get individuals which match this (and sub) classes as template</p>
434
* @param ID class_id - the id of the template class
435
* @param void|int only_this - only return individuals of this class (not the ones of the subclasses)
436
* @param void|int with_associated - if set, the associated indivudals will be returned, too
437
* @return Visconte.Request.Result - the result
440
public Visconte.Request.Result get_matching_individuals(ID class_id, void|int only_this, void|int with_associated)
442
Visconte.Request.Result res = Visconte.Request.Result();
443
Visconte.Onto.Item.OWLClass class_ ;
444
Visconte.Onto.OWLContainer ind;
446
if(ontology->item_exists(class_id->ref))
448
class_ = ontology->get_Item(class_id->ref);
450
ind=class_->get_individuals();
452
ind=class_->get_individuals_down_to_leaf();
457
Visconte.Onto.OWLContainer associated_individuals = Visconte.Onto.OWLContainer();
458
while(ind->has_items())
461
associated_individuals->merge(ind->next()->get_associations());
462
write(associated_individuals->to_string());
464
ind->merge(associated_individuals);
465
ind->reset_iterator();
470
//set a not existing error
471
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, class_id->ref }) ));
477
res->add_Message(Visconte.Request.Message(error));
479
res->set_OWLContainer(ind);
485
* <p>Get all associations of the given class (and its parents) is pointing to resp. is domain of</p>
487
* @param ID class_id - the class id of the domain
488
* @param int|void only_this - if set the inherited associations will not be included
490
* @param id the id to delete
493
public Visconte.Request.Result get_all_associations(ID class_id, void|int only_this)
495
Visconte.Request.Result res = Visconte.Request.Result();
496
Visconte.Onto.Item.OWLClass class_ ;
497
Visconte.Onto.OWLContainer assoc;
499
if(ontology->item_exists(class_id->ref))
501
class_ = ontology->get_Item(class_id->ref);
503
assoc=class_->get_domain_properties();
505
assoc=class_->get_inherited_domain_properties();
509
//set a not existing error
510
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, class_id->ref }) ));
515
res->add_Message(Visconte.Request.Message(error));
517
res->set_OWLContainer(assoc);
524
* <p>Changes the id a OWLClass and all affected Inviduals and Properties
527
* @param ID id - current id of the Class to rename
528
* @param new_id - the new id of the class
529
* @param string comment - a comment for the ontology log
530
* @return Result - the renamed class
532
public Visconte.Request.Result changeId(ID id, ID new_id, mapping label, string comment)
535
Visconte.Request.Result res = Visconte.Request.Result();
536
Visconte.Onto.Item.OWLItem new_class;
537
Visconte.Onto.Item.OWLItem old_class;
541
old_class = ontology->get_Item(id->ref);
542
if(old_class && !ontology->item_exists(new_id->ref))
544
//if one want to rename the class thing, just change the label
545
if(old_class->is_root())
547
old_class->set_Label(label);
548
ontology->update(old_class);
552
string parent = old_class->get_parent()->get_Id();
555
parent_id=ID("Thing");
557
parent_id=ID(parent);
558
new_class = factory->construct_Class(ontology,new_id,parent_id,label,({ }) ,({ }) );
559
ontology->add_Item(new_class);
560
new_class->mirror_restrictions();
562
//change the individuals
563
Visconte.Onto.OWLContainer inds = old_class->get_individuals();
564
while(inds->has_items())
566
Visconte.Onto.Item.OWLIndividual ind = inds->next();
567
ind->set_model_class(new_class);
568
ontology->update(ind);
571
//change all properties where the old class is the domain
572
Visconte.Onto.OWLContainer domain_props = old_class->get_domain_properties();
573
while(domain_props->has_items())
575
Visconte.Onto.Item.OWLProperty domain_prop = domain_props->next();
576
domain_prop->set_domain(new_class);
577
ontology->update(domain_prop);
580
//change all properties where the old class is the range
581
Visconte.Onto.OWLContainer range_props = old_class->get_range_properties();
582
while(range_props->has_items())
584
Visconte.Onto.Item.OWLProperty range_prop = range_props->next();
585
range_prop->set_range(new_class);
586
ontology->update(range_prop);
589
//change all direct subclasses
590
Visconte.Onto.OWLContainer childs = old_class->get_childs();
591
while(childs->has_items())
593
Visconte.Onto.Item.OWLClass child = childs->next();
594
child->set_parent(new_class);
595
ontology->update(child);
598
//finally remove the old class
599
ontology->remove(old_class);
603
//set a not existing error
604
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, id->ref }) ));
608
res->add_Message(Visconte.Request.Message(error));
610
ontology->add_annotation(new_class,"class_id_changed",(string)comment, old_class->get_Label());
612
res->set_OWLItem(new_class);
616
* <p>Set Restrictions to a class - has currently no effect</p>
622
* @param string comment - a comment for the ontology log
625
public Visconte.Request.Result set_restrictions(ID id, array equivalent, array different, int remove, string comment)
627
Visconte.Request.Result res = Visconte.Request.Result();
628
Visconte.Onto.Item.OWLClass class_to_restrict;
631
if(ontology->item_exists(id->ref))
633
class_to_restrict = ontology->get_Item(id->ref);
635
foreach( equivalent,ID cid)
638
if(ontology->item_exists(cid->ref))
640
class_to_restrict->unset_equivalent_class(cid->ref);
642
class_to_restrict->set_equivalent_class(cid->ref);
646
foreach( different,ID cid)
649
if(ontology->item_exists(cid->ref))
651
class_to_restrict->unset_different_from_class(cid->ref);
653
class_to_restrict->set_different_from_class(cid->ref);
656
if(!different && !equivalent && remove)
658
class_to_restrict->unset_restrictions();
663
ontology->update(class_to_restrict);
666
//set a not existing error
667
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, id->ref }) ));
671
res->set_OWLItem(class_to_restrict);
673
res->add_Message(Visconte.Request.Message(error));
675
ontology->add_annotation(class_to_restrict,"class_restricted",(string)comment, 0);
689
* <p>class IndividualAction - Represents Actions on individuals in an ontology</p>
691
class IndividualAction
694
inherit GenericAction;
698
* <p>Adds an Individual to the ontology</p>
700
* @param ID individual_id - the id of the individual
701
* @param ID class_id - the id of the model class
702
* @param MVList properties - MultiValue List for the inserted properties
703
* @param mapping same_as - no effect up to now, pass empty mapping
704
* @param different_from - no effect up to now, pass empty mapping
705
* @param string comment - a comment for the ontology log
706
* @return Result - the new individual (if already exists, the current will be returned!)
708
public Visconte.Request.Result add(ID individual_id, ID class_id, mapping label, Visconte.MVList property_values, mapping same_as, mapping different_from , string comment)
710
Visconte.Request.Result res = Visconte.Request.Result();
711
Visconte.Onto.Item.OWLIndividual new_individual;
715
new_individual = factory->construct_Individual(ontology, individual_id, class_id, label,property_values);
719
ontology->add_Item(new_individual);
722
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, individual_id->ref }) ));
726
res->add_Message(Visconte.Request.Message(error));
728
ontology->add_annotation(new_individual,"individual_added",(string)comment,0);
730
res->set_OWLItem(new_individual);
735
* <p>Adds an Individual to the ontology which is from type document term</p>
737
* @param ID individual_id - the id of the individual
738
* @param ID class_id - the id of the model class
739
* @param MVList properties - MultiValue List for the inserted properties
740
* @param mapping same_as - no effect up to now, pass empty mapping
741
* @param different_from - no effect up to now, pass empty mapping
742
* @param string comment - a comment for the ontology log
743
* @return Result - the new individual (if already exists, the current will be returned!)
745
public Visconte.Request.Result add_document_individual(ID individual_id, ID class_id, mapping label, Visconte.MVList property_values, mapping same_as, mapping different_from , string comment, string objectID, string mimeType)
747
Visconte.Request.Result res = Visconte.Request.Result();
748
Visconte.Onto.Item.OWLIndividual new_individual;
752
new_individual = factory->construct_Individual(ontology, individual_id, class_id, label,property_values);
756
ontology->add_Item(new_individual);
757
if(new_individual->get_model_class()->is_document_term())
758
ontology->set_document_term_properties(new_individual,objectID,mimeType);
761
res->add_Message(Visconte.Request.Message( ({ "", backtrace(),11, individual_id->ref }) ));
765
res->add_Message(Visconte.Request.Message(error));
767
ontology->add_annotation(new_individual,"individual_added",(string)comment,0);
769
res->set_OWLItem(new_individual);
775
* <p>Deletes an individual from the ontology.</p>
777
* @param ID id the id of the individual to delete
778
* @param string comment - a comment for the ontology log
781
public Visconte.Request.Result delete(ID id, string comment)
783
Visconte.Request.Result res = Visconte.Request.Result();
784
Visconte.Onto.Item.OWLItem individual_to_delete;
785
string individual_label;
788
if(ontology->item_exists(id->ref))
790
individual_to_delete = ontology->get_Item(id->ref);
791
individual_label=individual_to_delete->get_Label();
792
Visconte.Onto.Item.OWLClass class_ = ontology->get_Item("#Thing");
793
Visconte.Onto.OWLContainer all_inds = class_->get_individuals_down_to_leaf();
794
all_inds->reset_iterator();
795
while(all_inds->has_items())
797
Visconte.Onto.Item.OWLIndividual ind = all_inds->next();
798
if(ind->is_associated_with(individual_to_delete))
799
ind->remove_associations_with(individual_to_delete);
800
ontology->update(ind);
802
ontology->remove(individual_to_delete);
805
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
809
res->add_Message(Visconte.Request.Message(error));
811
ontology->add_annotation(individual_to_delete,"individual_deleted",(string)comment,0);
812
res->set_OWLItem(individual_to_delete);
820
* <p>Updates an Individual</p>
821
* Give a new MVList to update a given Individual
823
* @param id - the id of the Indvidual
824
* @param properties - the properties
825
* @param comment - a comment for the ontology log
826
* @return Result - the changed Individual
828
public Visconte.Request.Result update(ID id, MVList properties, mapping label, string comment)
830
Visconte.Request.Result res = Visconte.Request.Result();
831
Visconte.Onto.Item.OWLIndividual individual_to_update;
834
if(ontology->item_exists(id->ref))
836
individual_to_update = ontology->get_Item(id->ref);
837
individual_to_update->set_Label(label);
838
individual_to_update->reset_properties();
839
individual_to_update->set_Properties(properties);
840
ontology->update(individual_to_update);
843
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
847
res->add_Message(Visconte.Request.Message(error));
849
ontology->add_annotation(individual_to_update,"individual_updated",(string)comment,0);
850
res->set_OWLItem(individual_to_update);
855
* <p>Updates an Individual</p>
856
* Give a new MVList to update a given Individual
858
* @param id - the id of the Indvidual
859
* @param properties - the properties
860
* @param comment - a comment for the ontology log
861
* @return Result - the changed Individual
863
public Visconte.Request.Result update_document_individual(ID id, MVList properties, mapping label, string comment, string objectID, string mimetype)
865
Visconte.Request.Result res = Visconte.Request.Result();
866
Visconte.Onto.Item.OWLIndividual individual_to_update;
869
if(ontology->item_exists(id->ref))
871
individual_to_update = ontology->get_Item(id->ref);
872
individual_to_update->set_Label(label);
873
individual_to_update->reset_properties();
874
individual_to_update->set_Properties(properties);
876
ontology->update(individual_to_update);
877
if(individual_to_update->get_model_class()->is_document_term())
878
ontology->set_document_term_properties(individual_to_update,objectID,mimetype);
881
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
885
res->add_Message(Visconte.Request.Message(error));
887
ontology->add_annotation(individual_to_update,"individual_updated",(string)comment,0);
888
res->set_OWLItem(individual_to_update);
895
public Visconte.Request.Result change_Id(ID id, ID new_id, mapping label, string comment)
897
Visconte.Request.Result res = Visconte.Request.Result();
898
Visconte.Onto.Item.OWLIndividual current_ind;
899
Visconte.Onto.Item.OWLIndividual new_individual;
902
if(ontology->item_exists(id->ref) && !ontology->item_exists(new_id->ref))
904
current_ind = ontology->get_Item(id->ref);
905
ID model_class = ID(current_ind->get_model_class()->get_Id());
906
new_individual = factory->construct_Individual(ontology, new_id, model_class,label,current_ind->get_property_list());
907
ontology->add_Item(new_individual);
908
//change all interconnections
909
Visconte.Onto.Item.OWLClass class_ = ontology->get_Item("#Thing");
910
Visconte.Onto.OWLContainer all_inds = class_->get_individuals_down_to_leaf();
911
all_inds->reset_iterator();
912
while(all_inds->has_items())
914
Visconte.Onto.Item.OWLIndividual ind = all_inds->next();
915
if(ind->is_associated_with(current_ind))
916
ind->replace_individual(current_ind,new_individual);
917
ontology->update(ind);
919
ontology->remove(current_ind);
923
res->add_Message(Visconte.Request.Message(error));
925
ontology->add_annotation(new_individual,"individual_id_changed",(string)comment,0);
926
res->set_OWLItem(new_individual);
931
* <p>Retrieve all Individuals wich have a connection/association to and from the current one </p>
934
* @param ID id - the id of the individual to retrive the references from
935
* @param int no_back_refs - if set, no incoming assocaitions will be returned
936
* @param int include_self - if set, the given individual will be included to Result
937
* @return Result - Referenced Individuals
939
public Visconte.Request.Result get_all_references(ID indivual_id,int no_back_refs, int include_self)
941
Visconte.Request.Result res = Visconte.Request.Result();
942
Visconte.Onto.OWLContainer references = Visconte.Onto.OWLContainer();
948
Visconte.Onto.Item.OWLClass class_ = ontology->get_Item("#Thing");
949
Visconte.Onto.OWLContainer all_inds = class_->get_individuals_down_to_leaf();
950
all_inds->reset_iterator();
951
while(all_inds->has_items())
953
Visconte.Onto.Item.OWLIndividual ind = all_inds->next();
954
if(ind->is_associated_with(indivual_id->ref))
955
references->add(ind);
958
Visconte.Onto.Item.OWLIndividual ind = ontology->get_Item(indivual_id->ref);
959
references->merge(ind->get_associations());
961
references->add(ind);
965
res->add_Message(Visconte.Request.Message(error));
967
res->set_OWLContainer(references);
974
* <p>Retrieve all Individuals wich have a connection/association to and from the current one </p>
977
* @param ID id - the id of the individual to retrive the references from
978
* @param int no_back_refs - if set, no incoming assocaitions will be returned
979
* @param int include_self - if set, the given individual will be included to Result
980
* @return Result - Referenced Individuals
982
public string get_individual_id(string steamObjectid)
984
Visconte.Request.Result res = Visconte.Request.Result();
985
Visconte.Onto.OWLContainer references = Visconte.Onto.OWLContainer();
986
string result="none";
990
Visconte.Onto.Item.OWLClass class_ = ontology->get_Item("#Thing");
991
Visconte.Onto.OWLContainer all_inds = class_->get_individuals_down_to_leaf();
992
all_inds->reset_iterator();
993
while(all_inds->has_items())
995
Visconte.Onto.Item.OWLIndividual ind = all_inds->next();
996
mapping steam_properties = ind->get_steam_properties();
997
// result+=(string)steam_properties->objectid+"-->"+steamObjectid+"::";
998
string id = (string)steam_properties->objectid+"";
999
if(steamObjectid+"" == steam_properties->objectid+"")
1001
string id = (string)ind->get_Id();
1015
* <p>class PropertyAction - Property related actions</p>
1017
class PropertyAction
1021
inherit GenericAction;
1026
* <p>add a property to the ontology</p>
1027
* TODO: Add cardinality
1028
* @param id the new id of the property
1029
* @param mapping label - the labels of the property (currently only english) (["en":"Your Label"])
1030
* @param ID domain - the id of the domain (source)
1031
* @param ID range - the id of the range (target)
1032
* @param mapping restrictions - symetric, transitive etc. (has currently no effect in the ontology)
1033
* @param string comment - a comment for the ontology log
1034
* @return Result - the new Property (if already exists, the current one will be returned)
1036
public Visconte.Request.Result add(ID id, mapping label, mapping restrictions, ID domain, ID range, string comment)
1039
Visconte.Request.Result res = Visconte.Request.Result();
1040
Visconte.Onto.Item.OWLProperty property;
1043
property = factory->construct_Property(ontology,id,label,restrictions,domain,range);
1044
ontology->add_Item(property);
1045
if(property->ITEMTYPE==Visconte.Onto.Item.OWLItem.OBJECT_PROPERTY)
1046
ontology->add_annotation(property,"add_association", comment,domain->ref);
1048
ontology->add_annotation(property,"add_property", comment,domain->ref);
1053
res->add_Message(Visconte.Request.Message(error));
1056
res->set_OWLItem(property);
1062
* <p>Delete a Property from the ontology</p>
1064
* @param ID id - the id of the property
1065
* @param string comment - a comment for the ontology log
1068
public Visconte.Request.Result delete(ID id, string comment)
1070
Visconte.Request.Result res = Visconte.Request.Result();
1071
Visconte.Onto.Item.OWLProperty prop;
1076
if(ontology->item_exists(id->ref))
1079
prop = ontology->get_Item(id->ref);
1080
//get the class id of the domain
1081
Visconte.Onto.OWLContainer container= prop->get_domain()->get_individuals_down_to_leaf();
1082
//update the Individuals which hold this property, by removing it
1083
while(container->has_items())
1085
Visconte.Onto.Item.OWLIndividual i = container->next();
1086
i->remove_Property(prop);
1087
ontology->update(i);
1090
//remove the poperty
1091
ontology->remove(prop);
1094
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
1097
res->add_Message(Visconte.Request.Message(error));
1099
ontology->add_annotation(prop,"property_deleted",(string)comment,0);
1100
res->set_OWLItem(prop);
1110
* <p>Rename a Property</p>
1112
* @param ID id - the id of the property
1113
* @param ID newId - the new Id of the property
1114
* @param string comment - a comment for the ontology log
1117
public Visconte.Request.Result change_Id(ID id,ID new_id, mapping label, string comment)
1119
Visconte.Request.Result res = Visconte.Request.Result();
1120
Visconte.Onto.Item.OWLProperty prop_old;
1121
Visconte.Onto.Item.OWLProperty prop_new;
1126
if(ontology->item_exists(id->ref) && !ontology->item_exists(new_id->ref))
1129
prop_old = ontology->get_Item(id->ref);
1130
ID domain = ID(prop_old->get_domain()->get_Id());
1132
if(prop_old->ITEMTYPE!=Visconte.Onto.Item.OWLItem.DATATYPE_PROPERTY)
1133
range = ID(prop_old->get_range()->get_Id());
1135
range = ID("xsd:"+prop_old->get_range());
1136
prop_new = factory->construct_Property(ontology,new_id,label,([]),domain,range);
1137
ontology->add_Item(prop_new);
1138
Visconte.Onto.OWLContainer container= prop_old->get_domain()->get_individuals_down_to_leaf();
1139
//update the Individuals which hold this property, by replacing it
1140
while(container->has_items())
1142
Visconte.Onto.Item.OWLIndividual i = container->next();
1143
i->replace_Property(prop_old,prop_new);
1144
ontology->update(i);
1147
//remove the poperty
1148
ontology->remove(prop_old);
1151
res->add_Message(Visconte.Request.Message( ({ "", backtrace(), 11, id->ref }) ));
1154
res->add_Message(Visconte.Request.Message(error));
1156
ontology->add_annotation(prop_new,"property_id_changed",(string)comment,0);
1157
res->set_OWLItem(prop_new);
1169
* @param restrictions
1172
public Visconte.Request.Result set_Restrictions(ID id, mapping restrictions, string comment) {
1180
* <p>class OntologyAction - Action Class for special retrievals on the whole ontology</p>
1182
class OntologyAction
1185
inherit GenericAction;
1188
* <p>Returns a hierarchical map of class dependencies for the representation in the visconte ontology browser.
1189
* An options mapping indicates which informations should be also insert in the map e.g Assocaitions Individuals etc</p>
1192
* @param root_id the root id of the map (class id)
1193
* @param options mappig with name value pairs
1196
public Visconte.Request.Result get_Class_List(ID model_class_id, int|void with_myself)
1198
Visconte.Request.Result res = Visconte.Request.Result();
1199
Visconte.Onto.OWLContainer all_child_container;
1200
Visconte.Onto.Item.OWLClass model;
1203
model = ontology->get_Item(model_class_id->ref);
1204
all_child_container=model->get_all_childs();
1206
all_child_container->add(model);
1209
res->add_Message(Visconte.Request.Message(error));
1211
res->set_OWLContainer(all_child_container);
1218
* <p>Returns a hierarchical map of class dependencies for the representation in the visconte ontology browser.
1219
* An options mapping indicates which informations should be also insert in the map e.g Assocaitions Individuals etc</p>
1222
* @param root_id the root id of the map (class id)
1223
* @param options mappig with name value pairs
1226
public Visconte.Request.Result get_Hierarchical_Map()
1228
Visconte.Request.Result res = Visconte.Request.Result();
1229
Visconte.Onto.Item.OWLClass root;
1232
root = ontology->get_Item("#Thing");
1236
res->add_Message(Visconte.Request.Message(error));
1237
res->set_OWLItem(root,Visconte.Request.Result.RENDER_DEEP);
1244
* <p>Returns a hierarchical map of class dependencies for the representation in the visconte ontology browser.
1245
* An options mapping indicates which informations should be also insert in the map e.g Assocaitions Individuals etc</p>
1248
* @param root_id the root id of the map (class id)
1249
* @param options mappig with name value pairs
1252
public Visconte.Request.Result get_Up_Map(ID model_class_id)
1254
Visconte.Request.Result res = Visconte.Request.Result();
1255
Visconte.Onto.Item.OWLClass klass;
1258
klass=ontology->get_Class(model_class_id->ref);
1262
res->add_Message(Visconte.Request.Message(error));
1263
res->set_OWLItem(klass,Visconte.Request.Result.RENDER_UP);
1269
* <p>Get a cluster of individuals which fit to the constrains in the statements mapping.</p>
1272
* @param statements mapping with matching attributes
1275
public Visconte.Request.Result get_Individuals_by_Class(ID model_class_id, int edge_restriction)
1277
Visconte.Request.Result res = Visconte.Request.Result();
1278
Visconte.Onto.OWLContainer individuals_container;
1281
Visconte.Onto.Item.OWLClass model_class = ontology->get_Item(model_class_id->ref);
1282
write(model_class->get_Id());
1283
switch(edge_restriction)
1287
individuals_container = model_class->get_all_individuals();
1290
individuals_container = model_class->get_individuals_up_to_root();
1293
individuals_container = model_class->get_individuals_down_to_leaf();
1297
individuals_container = model_class->get_all_individuals();
1303
res->add_Message(Visconte.Request.Message(error));
1305
res->set_OWLContainer(individuals_container);
1313
* <p>Get the annotations of an ontology</p>
1316
* @return string xml;
1318
public string get_annotations()
1320
return ontology->get_annotations();
1324
* <p>Get the Parser.XML.Tree.Node of the ontology annotations</p>
1327
* @return string xml;
1329
public Parser.XML.Tree.Node get_annotation_node()
1331
return ontology->ontology_log;
1334
* <p>Retrieves Metainformations about the ontology</p>
1337
* @return int version number
1339
public int get_version() {
1341
return ontology->get_version();
1345
* <p>Sets a comment for specified object</p>
1348
* @param id the id, the comment should linked with
1349
* @param author the author of the comment
1350
* @param msg the message
1353
public int set_Comment(ID id,string comment) {
1355
Visconte.Onto.Item.OWLItem i = ontology->get_Item(id->ref);
1358
ontology->add_annotation(i,"comment_added",(string)comment,0);