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.Hashtable;
9   import java.util.Vector;
10  
11  /***
12   * Properties let us assert general facts about the members of classes and
13   * specific facts about individuals. From a mathematical point of view a 
14   * property is a binary relation. Two types of properties are distinguished:
15   * - Object properties link individuals to individuals.  They are relations 
16   *   between instances of two classes
17   * - Datatype properties link individuals to data values. They are relations 
18   *   between instances of classes and RDF literals and XML Schema datatypes
19   * 
20   * ObjectProperty concept corresponds to the relationship (among entities) 
21   * in the Databases field while Datatype properties correspond to entity's 
22   * attributes. 
23   */
24  public abstract class OdmProperty {
25  
26  	String name;
27  	String id;
28  	Vector annotationProps;  //list of OdmAnnotationProperty class instances
29  	
30  	/* 
31  	 * It is actually the conjuction of class descriptions
32  	 * This conjuction restricts the domain of the property to those
33  	 * individuals that belong to the intersection of the class descriptions
34  	 * 
35  	 * An rdfs:domain axiom asserts that the subjects of such property 
36  	 * statements must belong to the class extension of the indicated class 
37  	 * description
38  	 * 
39  	 * List of OntologyClass instances
40  	 */
41  	Vector domain;		
42  	
43  	/*
44  	 * It is actually the conjuction of class descriptions or of data ranges
45  	 * In other words, Multiple range restrictions are interpreted as stating
46  	 * that the range of the property is the intersection of all ranges 
47  	 * (i.e., the intersection of the class extension of the class descriptions 
48  	 * c.q. the intersection of the data ranges).
49  	 * 
50  	 * An rdfs:range axiom asserts that the values of this property must belong
51  	 * to the class extension of the class description or to data values in the
52  	 * specified data range
53  	 * 
54  	 * List of OntologyClass or DataRange class intances.  
55  	 */
56  	Vector range;
57  	
58  	/*
59  	 * A rdfs:subPropertyOf axiom defines that the property is a subproperty
60  	 * of some other property. Formally this means that if P1 is a subproperty
61  	 * of P2, then the property extension of P1 (a set of pairs) should be a
62  	 * subset of the property extension of P2 (also a set of pairs).
63  	 * 
64  	 * A consider that subPropertyOf suports multiple inheritance, that is why
65  	 * the variable is define as Vector
66  	 * 
67  	 * List of Poperty instances
68  	 */
69  	Vector subPropertyOf;
70  	Hashtable superPropertyOf;
71  	
72  	/*
73  	 * The owl:equivalentProperty construct can be used to state that two 
74  	 * properties have the same property extension. Syntactically, 
75  	 * owl:equivalentProperty is a built-in OWL property with rdf:Property
76  	 * as both its domain and range.
77  	 * 
78  	 * List of Property class instances
79  	 */
80  	Vector equivalentProperties; 
81  	
82  	/*
83  	 * A functional property is a property that can have only one (unique)
84  	 * value y for each instance x, i.e. there cannot be two distinct values
85  	 * y1 and y2 such that the pairs (x,y1) and (x,y2) are both instances of
86  	 * this property. Both object properties and datatype properties can be
87  	 * declared as "functional" 
88  	 */
89  	boolean isFunctional;	
90  	
91  	/*
92  	 * The ontology into which a Property is defined
93  	 */
94  	OdmOntology ontology;
95  	
96  	public OdmProperty() {
97  		
98  	}
99  	
100 	public OdmProperty(OdmOntology ontology, String name, String id) {
101 		
102 		//It keeps a reference to the ontology it belongs to
103 		this.ontology = ontology;
104 		//It adds itself to the ontology it belongs to !!
105 			
106 		this.name = name;
107 		this.id = id;
108 		
109 		if (this instanceof OdmObjectProperty) {
110 			this.ontology.addObjectProperty((OdmObjectProperty)this);
111 		}
112 	}
113 	
114 	public void addDomain(OdmOntologyClass oc) {
115 		if (domain == null) {
116 			domain = new Vector();			
117 		}
118 		domain.add(oc);
119 	}
120 	
121 	public void removeDomain(OdmOntologyClass oc) {
122 		if (domain != null) {
123 			domain.remove(oc);
124 		}
125 	}
126 	
127 	public void addSubproperty(OdmProperty p) {
128 		if (subPropertyOf == null) {
129 			subPropertyOf = new Vector();
130 		}
131 		// it ensures that the super and subproperty is of the same kind,
132 		// i.e. they are both object or datatype properties
133 		if (this.getClass() == p.getClass()) {
134 			subPropertyOf.add(p);
135 		}
136 	}
137 	
138 	public void removeSubproperty(OdmProperty p) {
139 		if (subPropertyOf != null) {
140 			subPropertyOf.remove(p);
141 		}
142 	}
143 	
144 	public void addSuperProperty(OdmProperty p) {
145 		if (superPropertyOf == null) {
146 			superPropertyOf = new Hashtable();			
147 		}
148 		superPropertyOf.put(p.getId(), p);
149 	}
150 
151 	public void removeSuperProperty(OdmProperty p) {
152 		if (superPropertyOf != null) {
153 			superPropertyOf.remove(p.getId());
154 		}
155 	}
156 	
157 	public void addEquivalentProperty(OdmProperty p) {
158 		if (equivalentProperties == null) {
159 			equivalentProperties = new Vector();			
160 		}
161 		if (this.getClass() == p.getClass()) {
162 			equivalentProperties.add(p);
163 		}
164 	}
165 
166 	public void removeEquivalentProperty(OdmProperty p) {
167 		if (equivalentProperties != null) {
168 			equivalentProperties.remove(p);
169 		}
170 	}
171 	
172 	public void addAnnotationProp(OdmAnnotationProperty ap) {
173 		if ( annotationProps == null ) {
174 			annotationProps = new Vector();
175 		}
176 		annotationProps.add(ap);
177 		
178 	}
179 	
180 	public void removeAnnotationProp(OdmAnnotationProperty ap) {
181 		if (annotationProps != null) {
182 			annotationProps.remove(ap);
183 		}
184 	}
185 			
186 	public void setName(String name) {
187 		this.name = name;
188 	}
189 	
190 	public void setId(String id) {
191 		this.id = id;
192 	}
193 	
194 	public void setOntology(OdmOntology ont) {
195 		ontology = ont;
196 	}
197 	
198 	public void setAnnotationProps(Vector a) {
199 		annotationProps = a;
200 	}
201 	
202 	public void setIsFunctional( boolean iF) {
203 		isFunctional = iF;
204 	}	
205 	
206 	public String getName() {
207 		return name;
208 	}
209 	
210 	public String getId() {
211 		return id;
212 	}
213 	
214 	public OdmOntology getOntology() {
215 		return ontology;
216 	}
217 	
218 	public Vector getAnnotationProps() {
219 		return annotationProps;
220 	}
221 	
222 	public boolean getIsFunctional() {
223 		return isFunctional;
224 	}
225 	
226 	public Vector getDomain() {
227 		return domain;
228 	}
229 	
230 	public Vector getRange() {
231 		return range;
232 	}
233 	
234 	public Vector getSubPropertyOf() {
235 		return subPropertyOf;
236 	}
237 	
238 	public Hashtable getSuperPropertyOf() {
239 		return superPropertyOf;
240 	}
241 	
242 	public Vector getEquivalentProperties() {
243 		return equivalentProperties;
244 	}
245 }