Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 122   Methods: 1
NCLOC: 86   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeLogExp.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2006, University of Innsbruck, Austria
 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    package org.deri.wsmo4j.io.serializer.rdf;
 19   
 20    import java.io.IOException;
 21    import java.util.Set;
 22   
 23    import org.deri.wsmo4j.io.parser.rdf.RDFExprParser;
 24    import org.omwg.logicalexpression.AttributeValueMolecule;
 25    import org.omwg.logicalexpression.Implication;
 26    import org.omwg.logicalexpression.LogicalExpression;
 27    import org.omwg.ontology.Axiom;
 28    import org.omwg.ontology.SimpleDataValue;
 29    import org.openrdf.model.URI;
 30    import org.openrdf.vocabulary.RDFS;
 31    import org.wsmo.common.IRI;
 32    import org.wsmo.factory.Factory;
 33   
 34    /**
 35    * Helper type to serialize/deserialize xml elements with logical expressions
 36    *
 37    * @author not attributable
 38    */
 39    class NodeLogExp {
 40   
 41  0 static void serialize(Axiom axiom, WsmlRdfSerializer serializer) {
 42  0 if (!axiom.listNFPValues().isEmpty()) {
 43  0 NodeNFP.serialize(serializer.getFactory().createURI(
 44    axiom.getIdentifier().toString()), axiom, serializer);
 45    }
 46  0 if (serializer.axiomAsTriple) {
 47  0 URI axiomID = serializer.getFactory().createURI(axiom.getIdentifier().toString());
 48    // translating the non-functional property dc#relation from the original
 49    // WSML file to an <rdfs:isDefinedBy> tag construct
 50  0 Set<Object> relationNFPs = axiom.listNFPValues(Factory.createWsmoFactory(null).
 51    createIRI(WsmlRdfSerializer.DC_RELATION));
 52  0 if (!relationNFPs.isEmpty()) {
 53  0 for (Object nfpValue : relationNFPs) {
 54  0 try {
 55  0 if (nfpValue instanceof SimpleDataValue) {
 56  0 String value = ((SimpleDataValue) nfpValue).toString();
 57  0 serializer.getWriter().writeStatement(
 58    axiomID,
 59    serializer.getFactory().createURI(RDFS.ISDEFINEDBY),
 60    serializer.getFactory().createLiteral(value));
 61    }
 62  0 else if (nfpValue instanceof IRI) {
 63  0 String value = ((IRI) nfpValue).toString();
 64  0 serializer.getWriter().writeStatement(
 65    axiomID,
 66    serializer.getFactory().createURI(RDFS.ISDEFINEDBY),
 67    serializer.getFactory().createURI(value));
 68    }
 69    } catch (IOException e) {
 70    // TODO Auto-generated catch block
 71  0 e.printStackTrace();
 72    }
 73    }
 74    }
 75    // translating the logExpr to Strings inside of a <wsml:axiom> tag construct
 76  0 Object[] exprs = axiom.listDefinitions().toArray();
 77  0 for (int i = 0; i < exprs.length; i++) {
 78  0 LogicalExpression expr = (LogicalExpression)exprs[i];
 79  0 try {
 80  0 serializer.getWriter().writeStatement(
 81    axiomID,
 82    serializer.getFactory().createURI(RDFExprParser.WSML_AXIOM),
 83    serializer.getFactory().createLiteral(expr.toString(axiom.getOntology())));
 84    } catch (IOException e) {
 85  0 throw new RuntimeException(e);
 86    }
 87    }
 88    }
 89    else {
 90  0 Object[] exprs = axiom.listDefinitions().toArray();
 91  0 for (int i = 0; i < exprs.length; i++) {
 92  0 LogicalExpression expr = (LogicalExpression)exprs[i];
 93  0 if(expr instanceof Implication) {
 94  0 Implication impl = (Implication)expr;
 95  0 if(impl.getLeftOperand() instanceof AttributeValueMolecule &&
 96    impl.getRightOperand() instanceof AttributeValueMolecule) {
 97   
 98  0 try {
 99  0 AttributeValueMolecule left = (AttributeValueMolecule)impl.getLeftOperand();
 100  0 AttributeValueMolecule right = (AttributeValueMolecule)impl.getRightOperand();
 101   
 102  0 serializer.getWriter().writeStatement(
 103    serializer.getFactory().createURI(left.getAttribute().toString()),
 104    serializer.getFactory().createURI(RDFS.SUBPROPERTYOF),
 105    serializer.getFactory().createURI(right.getAttribute().toString()));
 106    } catch(IOException e) {
 107  0 throw new RuntimeException(e);
 108    }
 109    } else {
 110  0 return;
 111    }
 112    } else {
 113  0 return;
 114    }
 115    }
 116    }
 117    }
 118    }
 119   
 120    /*
 121    *
 122    */