Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 134   Methods: 1
NCLOC: 87   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeRelation.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.*;
 21    import java.util.*;
 22   
 23    import org.deri.wsmo4j.io.parser.rdf.RDFExprParser;
 24    import org.omwg.ontology.*;
 25    import org.openrdf.model.*;
 26    import org.openrdf.model.Value;
 27    import org.openrdf.vocabulary.*;
 28    import org.wsmo.common.*;
 29   
 30    /**
 31    * Helper type to serialize/deserialize xml element relation
 32    *
 33    * @author not attributable
 34    */
 35    class NodeRelation {
 36   
 37  0 static void serialize(Relation relation, WsmlRdfSerializer serializer) {
 38  0 if (!relation.listParameters().isEmpty() && relation.listParameters().size()==2) {
 39  0 try {
 40  0 URI rel = serializer.getFactory().createURI(relation.getIdentifier().toString());
 41   
 42  0 serializer.getWriter().writeStatement(
 43    rel,
 44    serializer.getFactory().createURI(RDF.TYPE),
 45    serializer.getFactory().createURI(RDF.PROPERTY));
 46   
 47  0 Set domain = relation.listParameters().get(0).listTypes();
 48  0 Set range = relation.listParameters().get(1).listTypes();
 49    // keep in mind whether it is a constraining relation parameter or not (for better roundtripping)
 50  0 if (relation.listParameters().get(0).isConstraining()) {
 51  0 serializer.getWriter().writeStatement(
 52    serializer.getFactory().createURI(relation.getIdentifier().toString()),
 53    serializer.getFactory().createURI(RDFS.COMMENT),
 54    serializer.getFactory().createLiteral(RDFExprParser.CONSTRAINING_REL_1));
 55    }
 56  0 if (relation.listParameters().get(1).isConstraining()) {
 57  0 serializer.getWriter().writeStatement(
 58    serializer.getFactory().createURI(relation.getIdentifier().toString()),
 59    serializer.getFactory().createURI(RDFS.COMMENT),
 60    serializer.getFactory().createLiteral(RDFExprParser.CONSTRAINING_REL_2));
 61    }
 62   
 63  0 for (Iterator j = domain.iterator(); j.hasNext();) {
 64  0 Type type = (Type)j.next();
 65  0 Value val = null;
 66  0 if (type instanceof Concept) {
 67  0 val = serializer.getFactory().createURI(
 68    ((Concept)type).getIdentifier().toString());
 69    }
 70    else {
 71  0 val = serializer.getFactory().createURI(
 72    XmlSchema.NAMESPACE +
 73    ((WsmlDataType)type).getIRI().getLocalName().toString());
 74    }
 75  0 serializer.getWriter().writeStatement(
 76    rel,
 77    serializer.getFactory().createURI(RDFS.DOMAIN),
 78    val);
 79    }
 80  0 for(Iterator i = range.iterator(); i.hasNext();) {
 81  0 Type type = (Type)i.next();
 82  0 Value val = null;
 83  0 if (type instanceof Concept) {
 84  0 val = serializer.getFactory().createURI(
 85    ((Concept)type).getIdentifier().toString());
 86    }
 87    else {
 88  0 val = serializer.getFactory().createURI(
 89    XmlSchema.NAMESPACE +
 90    ((WsmlDataType)type).getIRI().getLocalName().toString());
 91    }
 92  0 serializer.getWriter().writeStatement(
 93    rel,
 94    serializer.getFactory().createURI(RDFS.RANGE),
 95    val);
 96    }
 97  0 if (!relation.listSuperRelations().isEmpty()) {
 98  0 Object[] entities = relation.listSuperRelations().toArray();
 99  0 for (int i = 0; i < entities.length; i++) {
 100  0 serializer.getWriter().writeStatement(
 101    rel,
 102    serializer.getFactory().createURI(RDFS.SUBPROPERTYOF),
 103    serializer.getFactory().createURI(
 104    ((Entity) entities[i]).getIdentifier().toString()));
 105    }
 106    }
 107  0 if (!relation.listNFPValues().isEmpty()) {
 108  0 NodeNFP.serialize(rel, relation, serializer);
 109    }
 110    } catch(IOException e) {
 111  0 throw new RuntimeException(e);
 112    }
 113    } else {
 114  0 return;
 115    }
 116    }
 117    }
 118   
 119    /*
 120    * $Log$
 121    * Revision 1.3 2007/04/02 12:13:23 morcen
 122    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 123    *
 124    * Revision 1.2 2006/11/10 15:38:49 ohamano
 125    * *** empty log message ***
 126    *
 127    * Revision 1.1 2006/11/10 15:02:59 ohamano
 128    * *** empty log message ***
 129    *
 130    * Revision 1.1 2006/11/10 10:08:42 ohamano
 131    * *** empty log message ***
 132    *
 133    *
 134    */