Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 191   Methods: 9
NCLOC: 101   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WsmlCoreValidator.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3    Copyright (c) 2005, University of Innsbruck, Austria
 4    This library is free software; you can redistribute it and/or modify it under
 5    the terms of the GNU Lesser General Public License as published by the Free
 6    Software Foundation; either version 2.1 of the License, or (at your option)
 7    any later version.
 8    This library is distributed in the hope that it will be useful, but WITHOUT
 9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 10    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 11    details.
 12    You should have received a copy of the GNU Lesser General Public License along
 13    with this library; if not, write to the Free Software Foundation, Inc.,
 14    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 15    */
 16    package org.deri.wsmo4j.validator;
 17   
 18   
 19    import java.util.*;
 20   
 21    import org.omwg.logicalexpression.*;
 22    import org.omwg.ontology.*;
 23    import org.wsmo.common.*;
 24    import org.wsmo.common.exception.*;
 25    import org.wsmo.factory.LogicalExpressionFactory;
 26    import org.wsmo.validator.ValidationError;
 27    import org.wsmo.validator.ValidationWarning;
 28   
 29   
 30    /**
 31    * Checks an ontology for wsml-core validity.
 32    *
 33    * <pre>
 34    * Created on Aug 18, 2005
 35    * Committed by $Author: morcen $
 36    * $Source$,
 37    * </pre>
 38    *
 39    * @author Holger Lausen (holger.lausen@deri.org)
 40    * @author nathalie.steinmetz@deri.org
 41    * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
 42    */
 43    public class WsmlCoreValidator
 44    extends WsmlDLValidator {
 45   
 46    private WsmlFlightValidator flightVal;
 47   
 48  0 public WsmlCoreValidator(LogicalExpressionFactory leFactory) {
 49  0 super(leFactory);
 50  0 flightVal = new WsmlFlightValidator(leFactory);
 51    }
 52   
 53  0 private void setup(){
 54  0 flightVal.setErrors(this.errors);
 55  0 flightVal.setWarnings(this.warnings);
 56    }
 57   
 58    /**
 59    * Checks if an axiom is valid to wsml-core.
 60    *
 61    * @see org.deri.wsmo4j.validator.WsmlFullValidator#visitAxiom(org.omwg.ontology.Axiom)
 62    */
 63  0 protected void visitAxiom(Axiom axiom) {
 64  0 setup();
 65  0 WsmlCoreExpressionValidator coreExprVal = new WsmlCoreExpressionValidator(axiom, leFactory, errors, this);
 66  0 WsmlDLExpressionValidator dlExprVal = new WsmlDLExpressionValidator(axiom, leFactory, errors, this);
 67  0 WsmlFlightExpressionValidator flightExprVal = new WsmlFlightExpressionValidator(axiom, leFactory, errors, this);
 68  0 WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(axiom, errors, this);
 69  0 WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(axiom, errors);
 70  0 FunctionSymbolHelper fsHelper = new FunctionSymbolHelper(axiom, errors, WSML.WSML_CORE, this);
 71  0 IDCollectHelper idHelper = new IDCollectHelper();
 72  0 Iterator axioms = axiom.listDefinitions().iterator();
 73  0 while (axioms.hasNext()){
 74  0 LogicalExpression le = (LogicalExpression) axioms.next();
 75   
 76  0 le.accept(idHelper);
 77    // adding the Axiom's Concepts, Instances and Relations to the vectors
 78  0 idConcepts.addAll(idHelper.getConceptIds());
 79  0 idInstances.addAll(idHelper.getInstanceIds());
 80  0 idRelations.addAll(idHelper.getRelationIds());
 81  0 idAbstractRelations.addAll(idHelper.getIdAbstractRelations());
 82  0 idConcreteRelations.addAll(idHelper.getIdConcreteRelations());
 83   
 84  0 le.accept(fsHelper);
 85   
 86  0 le.accept(fullExprVal);
 87  0 ruleExprVal.setup();
 88  0 le.accept(ruleExprVal);
 89  0 flightExprVal.setup();
 90  0 le.accept(flightExprVal);
 91  0 dlExprVal.setup();
 92  0 le.accept(dlExprVal);
 93  0 coreExprVal.setup();
 94  0 le.accept(coreExprVal);
 95    }
 96    }
 97   
 98    /**
 99    * Checks if a concept is valid to wsml-core.
 100    *
 101    * @see org.deri.wsmo4j.validator.WsmlFullValidator#visitConcept(org.omwg.ontology.Concept)
 102    */
 103  0 protected void visitConcept(Concept concept) {
 104  0 super.visitConcept(concept);
 105    // setup();
 106    // flightVal.visitConcept(concept);
 107    }
 108   
 109    /**
 110    * Checks if an instance is valid to wsml-core.
 111    *
 112    * @see org.deri.wsmo4j.validator.WsmlFullValidator#visitInstance(org.omwg.ontology.Instance)
 113    */
 114  0 protected void visitInstance(Instance instance) {
 115  0 super.visitInstance(instance);
 116    // setup();
 117    // flightVal.visitInstance(instance);
 118    }
 119   
 120    /**
 121    * Checks if a relation is valid to wsml-core.
 122    *
 123    * @see org.deri.wsmo4j.validator.WsmlFullValidator#visitRelation(org.omwg.ontology.Relation)
 124    */
 125  0 protected void visitRelation(Relation relation) {
 126  0 super.visitRelation(relation);
 127    // setup();
 128    // flightVal.visitRelation(relation);
 129    }
 130   
 131    /**
 132    * Checks if a relation instance is valid to wsml-core.
 133    *
 134    * @throws InvalidModelException
 135    * @throws SynchronisationException
 136    * @see org.deri.wsmo4j.validator.WsmlFullValidator#visitRelationInstance(org.omwg.ontology.RelationInstance)
 137    */
 138  0 protected void visitRelationInstance(RelationInstance relationInstance)
 139    throws SynchronisationException, InvalidModelException {
 140  0 super.visitRelationInstance(relationInstance);
 141    // setup();
 142    // flightVal.visitRelationInstance(relationInstance);
 143    }
 144   
 145  0 public boolean isValid(LogicalExpression logExpr, List <ValidationError> errorMessages, List <ValidationWarning> warningMessages) {
 146  0 super.isValid(logExpr, errorMessages, warningMessages);
 147  0 errors = errorMessages;
 148  0 warnings = warningMessages;
 149  0 setup();
 150  0 WsmlCoreExpressionValidator coreExprVal = new WsmlCoreExpressionValidator(null, leFactory, errors, this);
 151  0 WsmlDLExpressionValidator dlExprVal = new WsmlDLExpressionValidator(null, leFactory, errors, this);
 152  0 WsmlFlightExpressionValidator flightExprVal = new WsmlFlightExpressionValidator(null, leFactory, errors, this);
 153  0 WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(null, errors, this);
 154  0 WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(null, errors);
 155  0 FunctionSymbolHelper fsHelper = new FunctionSymbolHelper(
 156    null, errors, WSML.WSML_CORE, this);
 157  0 IDCollectHelper idHelper = new IDCollectHelper();
 158   
 159  0 logExpr.accept(idHelper);
 160    // adding the Axiom's Concepts, Instances and Relations to the vectors
 161  0 idConcepts.addAll(idHelper.getConceptIds());
 162  0 idInstances.addAll(idHelper.getInstanceIds());
 163  0 idRelations.addAll(idHelper.getRelationIds());
 164  0 idAbstractRelations.addAll(idHelper.getIdAbstractRelations());
 165  0 idConcreteRelations.addAll(idHelper.getIdConcreteRelations());
 166   
 167  0 logExpr.accept(fsHelper);
 168   
 169  0 logExpr.accept(fullExprVal);
 170  0 ruleExprVal.setup();
 171  0 logExpr.accept(ruleExprVal);
 172  0 flightExprVal.setup();
 173  0 logExpr.accept(flightExprVal);
 174  0 dlExprVal.setup();
 175  0 logExpr.accept(dlExprVal);
 176  0 coreExprVal.setup();
 177  0 logExpr.accept(coreExprVal);
 178   
 179  0 return (errors.isEmpty());
 180    }
 181   
 182    /*
 183    * Adds a new ValidationError to the error list
 184    */
 185  0 protected void addError(Entity ent, String msg) {
 186  0 ValidationErrorImpl ve = new ValidationErrorImpl(ent, msg, WSML.WSML_CORE);
 187  0 if (!errors.contains(ve)) {
 188  0 errors.add(ve);
 189    }
 190    }
 191    }