View Javadoc

1   /*
2    * @author Giorgos Anestis, TUC/MUSIC
3    * 
4    * @version 2.0 
5    */
6   package org.dbe.studio.tools.ontologyviewer.metamodels.odm;
7   
8   import java.util.Collection;
9   import java.util.Hashtable;
10  import java.util.Vector;
11  
12  import org.dbe.studio.tools.ontologyviewer.views.OntologyTree;
13  
14  /***
15   * An ontology defines the various elements that can be used to describe and
16   * represent a domain of knowledge. It includes definitions of basic concepts 
17   * within a domain or across domains and the relationships among them, using
18   * elements, such as classes, individuals, properties, etc. 
19   * 
20   */
21  public class OdmOntology {
22  	// The tree into which the ontology will be presented
23  	OntologyTree theTree;
24  	
25  	String name; //attributes inherited from the abstact class NamedElement
26  	String id;
27  	OdmOntologyHeader ontologyHeader;
28  	Hashtable classes;  // list of OntologyClass class instances
29  	Hashtable classInstances;
30  	Vector objectPropertyIntances;
31  	Hashtable dataRanges;  // list of the defined data ranges
32  	
33  	/*
34  	 * The list of ObjectProperties defined in the Ontology
35  	 * Only the ObjectProperties are kept directly in the Ontology because they
36  	 * have some autonomy as concepts. The same is not true for datatype 
37  	 * properties 
38  	 */
39  	Hashtable objectProperties; 
40  	
41  	/***
42  	 * 
43  	 */
44  	public OdmOntology(String name, String id) {
45  		super();
46  		this.name = name;
47  		this.id = id;
48  		ontologyHeader = new OdmOntologyHeader();
49  		classes = new Hashtable();		
50  		classes.put(OdmThingClass.THE_THING_ID, OdmThingClass.getThingClass());
51  		objectProperties = new Hashtable();
52  		classInstances = new Hashtable();		
53  		objectPropertyIntances = new Vector();
54  		dataRanges = new Hashtable();
55  	}
56  		
57  	public void addClass(OdmOntologyClass oc) {
58  		classes.put(oc.getId(), oc);
59  	}
60  	
61  	public void removeClass(OdmOntologyClass oc) {		
62  		classes.remove(oc.getId());		
63  	}
64  	
65  	public OdmOntologyClass findClass(String classID) {
66  		return (OdmOntologyClass)classes.get(classID);
67  	}
68  	
69  	public void addObjectProperty(OdmObjectProperty property) {
70  		objectProperties.put(property.getId(), property);
71  	}
72  	
73  	public void removeObjectProperty(OdmObjectProperty property) {
74  		objectProperties.remove(property.getId());
75  	}
76  	
77  	public OdmObjectProperty findObjectProperty(String propID) {
78  		return (OdmObjectProperty)objectProperties.get(propID);
79  	}
80  	
81  	public void addClassInstance(OdmOntologyClassInst ocInst) {
82  		classInstances.put(ocInst.getId(), ocInst);
83  	}
84  	
85  	public void removeClassInstance(OdmOntologyClassInst ocInst) {
86  		classInstances.remove(ocInst.getId());		
87  	}
88  	
89  	public OdmOntologyClassInst findClassInst(String classID) {
90  		return (OdmOntologyClassInst)classInstances.get(classID);
91  	}
92  	
93  	public void addObjPropertyInst(OdmObjectPropertyInst objPropertyInst) {
94  		objectPropertyIntances.add(objPropertyInst);
95  	}
96  	
97  	public void removeObjPropertyInst(OdmObjectPropertyInst objPropertyInst) {
98  		objectPropertyIntances.remove(objPropertyInst);
99  	}
100 	
101 	public void addDataRange(OdmDataRange dr) {
102 		dataRanges.put(dr.getId(), dr);
103 	}
104 	
105 	public void removeDataRange(OdmDataRange dr) {
106 		dataRanges.remove(dr.getId());
107 	}
108 	
109 	public OdmDataRange findDataRange(String id) {
110 		return (OdmDataRange)dataRanges.get(id);
111 	}
112 	
113 	public OdmDataRange findDataRangeByURI(String uri) {
114 		Collection c = dataRanges.values();
115 		
116 		for(; c.iterator().hasNext() ; ) {
117 			OdmDataRange dr = ((OdmDataRange)c.iterator().next()); 
118 			if ( dr.getName().equals(uri) ) {
119 				return dr;
120 			}
121 		}
122 		return null;
123 	}		
124 	
125 	public void setName(String name) {
126 		this.name = name;
127 	}
128 	
129 	public void setId(String id) {
130 		this.id = id;
131 	}
132 	
133 	public void setOntologyHeader(OdmOntologyHeader op) {		
134 		ontologyHeader = op;
135 	}
136 	
137 	public void setObjectProperties(Hashtable op) {		
138 		objectProperties = op;
139 	}
140 	
141 	public void setClasses(Hashtable oc) {
142 		classes = oc;
143 	}
144 	
145 	public void setTheTree(OntologyTree t) {
146 		theTree = t;
147 	}
148 	
149 	public String getName() {
150 		return name;
151 	}
152 	
153 	public String getId() {
154 		return id;
155 	}
156 	
157 	public OdmOntologyHeader getOntologyHeader() {
158 		return ontologyHeader;
159 	}
160 	
161 	public Hashtable getClasses() {
162 		return classes;
163 	}
164 	
165 	public Hashtable getObjectProperties() {
166 		return objectProperties;
167 	}
168 	
169 	public OntologyTree getTheTree() {
170 		return theTree;
171 	}
172 }