Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 365   Methods: 28
NCLOC: 256   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
OntologyImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2004-2005, OntoText Lab. / SIRMA
 5   
 6    This library is free software; you can redistribute it and/or modify it under
 7    the terms of the GNU Lesser General Public License as published by the Free
 8    Software Foundation; either version 2.1 of the License, or (at your option)
 9    any later version.
 10    This library is distributed in the hope that it will be useful, but WITHOUT
 11    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 12    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 13    details.
 14    You should have received a copy of the GNU Lesser General Public License along
 15    with this library; if not, write to the Free Software Foundation, Inc.,
 16    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18   
 19    package com.ontotext.wsmo4j.ontology;
 20   
 21   
 22    /**
 23    * <p>Title: WSMO4J</p>
 24    * <p>Description: WSMO API and a Reference Implementation</p>
 25    * <p>Copyright: Copyright (c) 2004-2005</p>
 26    * <p>Company: OntoText Lab. / SIRMA </p>
 27    * @author not attributable
 28    * @version 1.0
 29    *
 30    */
 31    import java.util.*;
 32   
 33    import org.omwg.ontology.*;
 34    import org.wsmo.common.*;
 35    import org.wsmo.common.exception.*;
 36   
 37    import com.ontotext.wsmo4j.common.*;
 38   
 39   
 40    public class OntologyImpl
 41    extends TopEntityImpl
 42    implements Ontology {
 43   
 44    private LinkedHashMap <Identifier, Concept> concepts;
 45   
 46    private LinkedHashMap <Identifier, Relation> relations;
 47   
 48    private LinkedHashMap <Identifier, Instance> instances;
 49   
 50    private LinkedHashMap <Identifier, Axiom> axioms;
 51   
 52    private LinkedHashMap <Identifier, RelationInstance> relationInstances;
 53   
 54  0 public OntologyImpl(IRI thisID) {
 55  0 super(thisID);
 56   
 57  0 concepts = new LinkedHashMap <Identifier, Concept> ();
 58  0 relations = new LinkedHashMap <Identifier, Relation> ();
 59  0 instances = new LinkedHashMap <Identifier, Instance> ();
 60  0 axioms = new LinkedHashMap <Identifier, Axiom> ();
 61  0 relationInstances = new LinkedHashMap <Identifier, RelationInstance> ();
 62    }
 63   
 64  0 public Set <Concept> listConcepts()
 65    throws SynchronisationException {
 66  0 return new LinkedHashSet <Concept> (concepts.values());
 67    }
 68   
 69  0 public void addConcept(Concept concept)
 70    throws SynchronisationException, InvalidModelException {
 71  0 if (concept == null) {
 72  0 throw new IllegalArgumentException();
 73    }
 74  0 concepts.put(concept.getIdentifier(), concept);
 75  0 if (false == this.equals(concept.getOntology())) {
 76  0 concept.setOntology(this);
 77    }
 78    }
 79   
 80  0 public void removeConcept(Concept concept)
 81    throws SynchronisationException, InvalidModelException {
 82  0 if (concept == null) {
 83  0 throw new IllegalArgumentException();
 84    }
 85  0 concepts.remove(concept.getIdentifier());
 86  0 concept.setOntology(null);
 87    }
 88   
 89  0 public void removeConcept(Identifier conceptID)
 90    throws SynchronisationException, InvalidModelException {
 91  0 if (conceptID == null) {
 92  0 throw new IllegalArgumentException();
 93    }
 94  0 Concept concept = concepts.get(conceptID);
 95  0 if (concept != null) {
 96  0 concept.setOntology(null);
 97    }
 98  0 concepts.remove(conceptID);
 99    }
 100   
 101  0 public Set <Relation> listRelations()
 102    throws SynchronisationException {
 103  0 return new LinkedHashSet <Relation> (relations.values());
 104    }
 105   
 106  0 public void addRelation(Relation relation)
 107    throws SynchronisationException, InvalidModelException {
 108  0 if (relation == null) {
 109  0 throw new IllegalArgumentException();
 110    }
 111  0 relations.put(relation.getIdentifier(), relation);
 112  0 if (false == this.equals(relation.getOntology())) {
 113  0 relation.setOntology(this);
 114    }
 115    }
 116   
 117  0 public void removeRelation(Relation relation)
 118    throws SynchronisationException, InvalidModelException {
 119  0 if (relation == null) {
 120  0 throw new IllegalArgumentException();
 121    }
 122  0 relations.remove(relation.getIdentifier());
 123  0 relation.setOntology(null);
 124    }
 125   
 126  0 public void removeRelation(Identifier relationID)
 127    throws SynchronisationException, InvalidModelException {
 128  0 if (relationID == null) {
 129  0 throw new IllegalArgumentException();
 130    }
 131  0 Relation relation = relations.get(relationID);
 132  0 if (relation != null) {
 133  0 relation.setOntology(null);
 134    }
 135  0 relations.remove(relationID);
 136    }
 137   
 138  0 public Set <Instance> listInstances()
 139    throws SynchronisationException {
 140  0 return new LinkedHashSet <Instance> (instances.values());
 141    }
 142   
 143  0 public void addInstance(Instance instance)
 144    throws SynchronisationException, InvalidModelException {
 145  0 if (instance == null) {
 146  0 throw new IllegalArgumentException();
 147    }
 148  0 instances.put(instance.getIdentifier(), instance);
 149  0 if (false == this.equals(instance.getOntology())) {
 150  0 instance.setOntology(this);
 151    }
 152    }
 153   
 154  0 public void removeInstance(Instance instance)
 155    throws SynchronisationException, InvalidModelException {
 156  0 if (instance == null) {
 157  0 throw new IllegalArgumentException();
 158    }
 159  0 instance.setOntology(null);
 160  0 instances.remove(instance.getIdentifier());
 161    }
 162   
 163  0 public void removeInstance(Identifier instanceID)
 164    throws SynchronisationException, InvalidModelException {
 165  0 if (instanceID == null) {
 166  0 throw new IllegalArgumentException();
 167    }
 168  0 Instance instance = instances.get(instanceID);
 169  0 if (instance != null) {
 170  0 instance.setOntology(null);
 171    }
 172  0 instances.remove(instanceID);
 173    }
 174   
 175  0 public Set <Axiom> listAxioms()
 176    throws SynchronisationException {
 177  0 return new LinkedHashSet <Axiom> (axioms.values());
 178    }
 179   
 180  0 public void addAxiom(Axiom axiom)
 181    throws SynchronisationException, InvalidModelException {
 182  0 if (axiom == null) {
 183  0 throw new IllegalArgumentException();
 184    }
 185  0 axioms.put(axiom.getIdentifier(), axiom);
 186  0 if (false == this.equals(axiom.getOntology())) {
 187  0 axiom.setOntology(this);
 188    }
 189    }
 190   
 191  0 public void removeAxiom(Axiom axiom)
 192    throws SynchronisationException, InvalidModelException {
 193  0 if (axiom == null) {
 194  0 throw new IllegalArgumentException();
 195    }
 196  0 axioms.remove(axiom.getIdentifier());
 197  0 axiom.setOntology(null);
 198    }
 199   
 200  0 public void removeAxiom(Identifier axiomID)
 201    throws SynchronisationException, InvalidModelException {
 202  0 if (axiomID == null) {
 203  0 throw new IllegalArgumentException();
 204    }
 205  0 Axiom axiom = axioms.get(axiomID);
 206  0 if (axiom != null) {
 207  0 axiom.setOntology(null);
 208    }
 209  0 axioms.remove(axiomID);
 210    }
 211   
 212  0 public Set <RelationInstance> listRelationInstances()
 213    throws SynchronisationException {
 214  0 return new LinkedHashSet <RelationInstance> (relationInstances.values());
 215    }
 216   
 217  0 public void addRelationInstance(RelationInstance instance)
 218    throws SynchronisationException, InvalidModelException {
 219  0 if (instance == null) {
 220  0 throw new IllegalArgumentException();
 221    }
 222  0 relationInstances.put(instance.getIdentifier(), instance);
 223  0 if (false == this.equals(instance.getOntology())) {
 224  0 instance.setOntology(this);
 225    }
 226    }
 227   
 228  0 public void removeRelationInstance(RelationInstance instance)
 229    throws SynchronisationException, InvalidModelException {
 230  0 if (instance == null) {
 231  0 throw new IllegalArgumentException();
 232    }
 233  0 relationInstances.remove(instance.getIdentifier());
 234  0 instance.setOntology(null);
 235    }
 236   
 237  0 public void removeRelationInstance(Identifier instanceID)
 238    throws SynchronisationException, InvalidModelException {
 239  0 if (instanceID == null) {
 240  0 throw new IllegalArgumentException();
 241    }
 242  0 RelationInstance instance = relationInstances.get(instanceID);
 243  0 if (instance != null) {
 244  0 instance.setOntology(null);
 245    }
 246   
 247  0 relationInstances.remove(instanceID);
 248    }
 249   
 250  0 public Concept findConcept(Identifier id)
 251    throws SynchronisationException {
 252   
 253  0 if (null == id) {
 254  0 throw new IllegalArgumentException();
 255    }
 256  0 return concepts.get(id);
 257    }
 258   
 259  0 public Relation findRelation(Identifier id)
 260    throws SynchronisationException {
 261   
 262  0 if (null == id) {
 263  0 throw new IllegalArgumentException();
 264    }
 265  0 return relations.get(id);
 266    }
 267   
 268  0 public Instance findInstance(Identifier id)
 269    throws SynchronisationException {
 270   
 271  0 if (null == id) {
 272  0 throw new IllegalArgumentException();
 273    }
 274   
 275  0 return instances.get(id);
 276    }
 277   
 278  0 public Axiom findAxiom(Identifier id)
 279    throws SynchronisationException {
 280   
 281  0 if (null == id) {
 282  0 throw new IllegalArgumentException();
 283    }
 284  0 return axioms.get(id);
 285    }
 286   
 287  0 public RelationInstance findRelationInstance(Identifier id)
 288    throws SynchronisationException {
 289   
 290  0 if (null == id) {
 291  0 throw new IllegalArgumentException();
 292    }
 293  0 return relationInstances.get(id);
 294    }
 295   
 296  0 public Set <Entity> findEntity(Identifier id)
 297    throws SynchronisationException {
 298   
 299  0 if (null == id) {
 300  0 throw new IllegalArgumentException();
 301    }
 302    //iterate all collections
 303  0 Set <Entity> entities = new LinkedHashSet <Entity> ();
 304  0 Entity entity = findAxiom(id);
 305  0 if (entity != null)
 306  0 entities.add(entity);
 307  0 entity = findConcept(id);
 308  0 if (entity != null)
 309  0 entities.add(entity);
 310  0 entity = findInstance(id);
 311  0 if (entity != null)
 312  0 entities.add(entity);
 313  0 entity = findRelation(id);
 314  0 if (entity != null)
 315  0 entities.add(entity);
 316  0 entity = findRelationInstance(id);
 317  0 if (entity != null)
 318  0 entities.add(entity);
 319   
 320    //no need to clone/copy since this is a temporary set
 321  0 return entities;
 322    }
 323   
 324  0 public boolean equals(Object object) {
 325  0 if (object == this) {
 326  0 return true;
 327    }
 328  0 if (object == null
 329    || false == object instanceof Ontology) {
 330  0 return false;
 331    }
 332  0 return super.equals(object);
 333    }
 334   
 335    }
 336    /*
 337    * $Log$
 338    * Revision 1.27 2007/04/02 12:13:21 morcen
 339    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 340    *
 341    * Revision 1.26 2005/10/18 10:36:04 vassil_momtchev
 342    * bug fix; findEntity(Identifier) returned Set with null values
 343    *
 344    * Revision 1.25 2005/10/18 09:08:34 marin_dimitrov
 345    * findEntity resturns Set (was Entity[])
 346    *
 347    * Revision 1.24 2005/10/18 08:46:47 vassil_momtchev
 348    * Entity findEntity(Identifier) changed to Entity[] findEntity(Identifier)
 349    *
 350    * Revision 1.23 2005/06/22 09:16:05 alex_simov
 351    * Simplified equals() method. Identity strongly relies on identifier string
 352    *
 353    * Revision 1.22 2005/06/07 07:30:58 alex_simov
 354    * owner ontology not set/cleared for addXXX() and removeXXX() methods
 355    *
 356    * Revision 1.21 2005/06/01 12:09:33 marin_dimitrov
 357    * v0.4.0
 358    *
 359    * Revision 1.2 2005/05/19 14:05:43 marin
 360    * constructor accepts an IRI (was: Identifier)
 361    *
 362    * Revision 1.1 2005/05/12 15:47:15 alex
 363    * initial commit
 364    *
 365    */