Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 179   Methods: 1
NCLOC: 129   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeConcept.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    import org.wsmo.factory.Factory;
 30   
 31    /**
 32    * Helper type to serialize/deserialize xml element concept
 33    *
 34    * @author not attributable
 35    */
 36    class NodeConcept {
 37   
 38  0 static void serialize(Concept concept, WsmlRdfSerializer serializer) {
 39  0 if(concept.getIdentifier().toString().equals(RDFS.CLASS)) {
 40  0 return;
 41    } else {
 42  0 try {
 43  0 Resource name = serializer.getFactory().createURI(concept.getIdentifier().toString());
 44   
 45  0 serializer.getWriter().writeStatement(
 46    name,
 47    serializer.getFactory().createURI(RDF.TYPE),
 48    serializer.getFactory().createURI(RDFS.CLASS));
 49   
 50  0 if (!concept.listSuperConcepts().isEmpty()) {
 51  0 Object[] entities = concept.listSuperConcepts().toArray();
 52  0 for (int i = 0; i < entities.length; i++) {
 53  0 serializer.getWriter().writeStatement(
 54    name,
 55    serializer.getFactory().createURI(RDFS.SUBCLASSOF),
 56    serializer.getFactory().createURI(
 57    ((Entity)entities[i]).getIdentifier().toString()));
 58    }
 59    }
 60  0 if (!concept.listNFPValues().isEmpty()) {
 61  0 NodeNFP.serialize(name, concept, serializer);
 62  0 Set<Object> relationNFPs = concept.listNFPValues(Factory.createWsmoFactory(null).
 63    createIRI(WsmlRdfSerializer.DC_RELATION));
 64  0 if (!relationNFPs.isEmpty()) {
 65  0 for (Object nfpValue : relationNFPs) {
 66  0 if (nfpValue instanceof SimpleDataValue) {
 67  0 String value = ((SimpleDataValue) nfpValue).toString();
 68  0 serializer.getWriter().writeStatement(
 69    name,
 70    serializer.getFactory().createURI(RDFS.ISDEFINEDBY),
 71    serializer.getFactory().createLiteral(value));
 72    }
 73  0 else if (nfpValue instanceof IRI) {
 74  0 String value = ((IRI) nfpValue).toString();
 75  0 serializer.getWriter().writeStatement(
 76    name,
 77    serializer.getFactory().createURI(RDFS.ISDEFINEDBY),
 78    serializer.getFactory().createURI(value));
 79    }
 80    }
 81    }
 82    }
 83  0 if (!concept.listAttributes().isEmpty()) {
 84  0 Object[] attrList = concept.listAttributes().toArray();
 85  0 for (int i = 0; i < attrList.length; i++) {
 86  0 Attribute attribute = (Attribute) attrList[i];
 87    // keep in mind whether it is a constraining attribute or not (for better roundtripping)
 88  0 if (attribute.isConstraining()) {
 89  0 serializer.getWriter().writeStatement(
 90    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 91    serializer.getFactory().createURI(RDFS.COMMENT),
 92    serializer.getFactory().createLiteral(RDFExprParser.CONSTRAINING_ATTR));
 93    }
 94    // keep in mind whether it is a transitive attribute or not (for better roundtripping)
 95  0 if (attribute.isTransitive()) {
 96  0 serializer.getWriter().writeStatement(
 97    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 98    serializer.getFactory().createURI(RDFS.COMMENT),
 99    serializer.getFactory().createLiteral(RDFExprParser.TRANSITIVE_ATTR));
 100    }
 101    // keep in mind whether it is a reflexive attribute or not (for better roundtripping)
 102  0 if (attribute.isTransitive()) {
 103  0 serializer.getWriter().writeStatement(
 104    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 105    serializer.getFactory().createURI(RDFS.COMMENT),
 106    serializer.getFactory().createLiteral(RDFExprParser.REFLEXIVE_ATTR));
 107    }
 108    // keep in mind whether it is a symmetric attribute or not (for better roundtripping)
 109  0 if (attribute.isTransitive()) {
 110  0 serializer.getWriter().writeStatement(
 111    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 112    serializer.getFactory().createURI(RDFS.COMMENT),
 113    serializer.getFactory().createLiteral(RDFExprParser.SYMMETRIC_ATTR));
 114    }
 115    // keep in mind whether it is an inverse attribute or not (for better roundtripping)
 116  0 if (attribute.getInverseOf() != null) {
 117  0 serializer.getWriter().writeStatement(
 118    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 119    serializer.getFactory().createURI(RDFExprParser.WSML_INVERSE_ATTR),
 120    serializer.getFactory().createURI(attribute.getIdentifier().toString()));
 121    }
 122  0 serializer.getWriter().writeStatement(
 123    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 124    serializer.getFactory().createURI(RDF.TYPE),
 125    serializer.getFactory().createURI(RDF.PROPERTY));
 126  0 serializer.getWriter().writeStatement(
 127    serializer.getFactory().createURI(attribute.getIdentifier().toString()),
 128    serializer.getFactory().createURI(RDFS.DOMAIN),
 129    name);
 130  0 Resource attr = serializer.getFactory().createURI(attribute.getIdentifier().toString());
 131  0 if (!attribute.listTypes().isEmpty()) {
 132  0 Value value = null;
 133  0 for (Iterator j = attribute.listTypes().iterator(); j.hasNext();) {
 134  0 Object o = j.next();
 135  0 if (o instanceof Concept)
 136  0 value = serializer.getFactory().createURI(
 137    ((Concept)o).getIdentifier().toString());
 138  0 else if (o instanceof WsmlDataType) {
 139  0 value = serializer.getFactory().createURI(
 140    XmlSchema.NAMESPACE +
 141    ((WsmlDataType) o).getIRI().getLocalName().toString());
 142    }
 143    else {
 144  0 throw new RuntimeException("Unknown range for attribute!");
 145    }
 146  0 serializer.getWriter().writeStatement(
 147    attr,
 148    serializer.getFactory().createURI(RDFS.RANGE),
 149    value);
 150    }
 151    }
 152  0 if (!attribute.listNFPValues().isEmpty()) {
 153  0 NodeNFP.serialize(attr,attribute, serializer);
 154    }
 155    }
 156    }
 157    } catch(IOException e) {
 158  0 throw new RuntimeException(e);
 159    }
 160    }
 161    }
 162    }
 163   
 164    /*
 165    * $Log$
 166    * Revision 1.3 2006/11/16 14:35:09 ohamano
 167    * *** empty log message ***
 168    *
 169    * Revision 1.2 2006/11/10 15:38:49 ohamano
 170    * *** empty log message ***
 171    *
 172    * Revision 1.1 2006/11/10 15:02:59 ohamano
 173    * *** empty log message ***
 174    *
 175    * Revision 1.1 2006/11/10 10:08:42 ohamano
 176    * *** empty log message ***
 177    *
 178    *
 179    */