You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
(65) |
Sep
(15) |
Oct
(35) |
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18474/src/org/javaowl/models/prevalence Modified Files: PrevalentGraph.java AddTripleCommand.java StorageGraph.java DeleteTripleCommand.java Added Files: TripleUtil.java Removed Files: StorageUtil.java Log Message: Changed serialization to externalization. --- NEW FILE: TripleUtil.java --- /* * (c) Copyright 2003, Hewlett-Packard Development Company, LP [See end of file] */ package org.javaowl.models.prevalence; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import com.hp.hpl.jena.datatypes.RDFDatatype; import com.hp.hpl.jena.datatypes.TypeMapper; import com.hp.hpl.jena.db.RDFRDBException; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Node_Literal; import com.hp.hpl.jena.graph.Node_URI; import com.hp.hpl.jena.graph.Node_Variable; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.graph.impl.LiteralLabel; import com.hp.hpl.jena.rdf.model.AnonId; public class TripleUtil { /* * The following routines are responsible for encoding nodes as database * structures. For each node type stored (currently, literals, URI, blank), * there are two possible encodings depending on the node size. Small nodes * may be stored within a statement table. If the node is long (will not fit * within the statement table), it is be stored in a separate table for that * node type. * * In addition, for resources (URI, blank nodes), the URI may be optionally * compressed. Below, the possibilites are enumerated. * * Literal Encoding in Statement Tables Short Literal: * Lv:[langLen]:[datatypeLen]:[langString][datatypeString]value[:] Long * Literal: Lr:dbid Literal Encoding in Long Literal Table Literal: * Lv:[langLen]:[datatypeLen]:[langString][datatypeString]head[:] hash tail * * Comments: L indicates a literal v indicates a value r indicates a * reference to another table : is used as a delimiter. note that MySQL * trims trailing white space for certain VARCHAR columns so an extra * delimiter is appended when necessary for those columns. it is not * required for dbid, however. dbid references the long literal table * langLen is the length of the language identifier for the literal * langString is the language identifier datatypeLen is the length of the * datatype for the literal datatypeString is the datatype for the literal * value is the lexical form of the string head is a prefix of value that * can be indexed hash is the CRC32 hash value for the tail tail is the * remainder of the value that cannot be indexed * * * * URI Encoding in Statement Tables Short URI: Uv:[pfx_dbid]:URI[:] Long * URI: Ur:[pfx_dbid]:dbid URI Encoding in Long URI Table URI: Uv:head[:] * hash tail * * Comments: U indicates a URI pfx_dbid references the prefix table. if the * prefix is too short (i.e., the length of the prefix is less than * URI_COMPRESS_LENGTH), the URI is not compressed and pfx_dbid is null. URI * is the complete URI other notation same as for literal encoding * * Blank Node Encoding in Statement Tables Short URI: Bv:[pfx_dbid]:bnid[:] * Long URI: Br:[pfx_dbid]:dbid Blank Encoding in Long URI Table URI: * Bv:head[:] hash tail * * Comments: B indicates a blank node bnid is the blank node identifier * other notation same as above Note: currently, blank nodes are always * stored uncompressed (pfix_dbid is null). * * Variable Node Encoding in Statement Tables Variable Node: Vv:name * * Comments: V indicates a variable node v indicates a value name is the * variable name Note: the length must be less than LONG_OBJECT_LENGTH * * ANY Node Encoding in Statement Tables Variable Node: Av: * * Prefix Encoding in Prefix Table Prefix: Pv:val[:] [hash] [tail] * * Comments: P indicates a prefix other notation same as above hash and tail * are only required for long prefixes. * */ private static String RDB_CODE_URI = "U"; private static String RDB_CODE_BLANK = "B"; private static String RDB_CODE_LITERAL = "L"; private static String RDB_CODE_VARIABLE = "V"; private static String RDB_CODE_ANY = "A"; private static String RDB_CODE_VALUE = "v"; private static String RDB_CODE_DELIM = ":"; private static char RDB_CODE_DELIM_CHAR = ':'; private static String nodeToString(Node node) throws RDFRDBException { String res; if (node.isURI()) { String uri = new String(((Node_URI) node).getURI()); if (uri.startsWith(RDB_CODE_URI)) { throw new RDFRDBException("URI Node looks like a blank node: " + uri); } String pfx = RDB_CODE_DELIM + RDB_CODE_DELIM; String qname = uri; res = RDB_CODE_URI + RDB_CODE_VALUE + pfx + qname; } else if (node.isLiteral()) { Node_Literal litNode = (Node_Literal) node; LiteralLabel ll = litNode.getLiteral(); String lval = ll.getLexicalForm(); String lang = ll.language(); String dtype = ll.getDatatypeURI(); String ld = litLangTypeToRDBString(lang, dtype); res = RDB_CODE_LITERAL + RDB_CODE_VALUE + RDB_CODE_DELIM + ld + lval; } else if (node.isBlank()) { String bnID = node.getBlankNodeId().toString(); String delims = "::"; res = RDB_CODE_BLANK + RDB_CODE_VALUE + delims + bnID; } else if (node.isVariable()) { String name = ((Node_Variable) node).getName(); res = RDB_CODE_VARIABLE + RDB_CODE_VALUE + RDB_CODE_DELIM + name; } else if (node.equals(Node.ANY)) { res = RDB_CODE_ANY + RDB_CODE_VALUE + RDB_CODE_DELIM; } else { throw new RDFRDBException("Expected Concrete Node, got " + node.toString()); } return res; } private static Node stringToNode(String rdbString) throws RDFRDBException { Node res = null; int len = rdbString.length(); if (len < 3) throw new RDFRDBException("Bad RDBString Header: " + rdbString); String nodeType = rdbString.substring(0, 1); String valType = rdbString.substring(1, 2); if ((!valType.equals(RDB_CODE_VALUE)) || (rdbString.charAt(2) != RDB_CODE_DELIM_CHAR)) throw new RDFRDBException("Bad RDBString Header: " + rdbString); int pos = 3; if (nodeType.equals(RDB_CODE_URI)) { ParseInt pi = new ParseInt(pos); String prefix = ""; rdbStringParseInt(rdbString, pi, false); pos = pi.pos + 1; String qname = rdbString.substring(pos, len); res = Node.createURI(prefix + qname); } else if (nodeType.equals(RDB_CODE_LITERAL)) { //TODO: Parse to correct datatype ParseInt pi = new ParseInt(pos); String litString = null; litString = rdbString.substring(pos, len); len = litString.length(); String lang; String dType; int langLen = 0; int dTypeLen = 0; LiteralLabel llabel; pi.pos = 0; rdbStringParseInt(litString, pi, false); if (pi.val == null) langLen = 0; else langLen = pi.val.intValue(); pi.pos = pi.pos + 1; rdbStringParseInt(litString, pi, false); if (pi.val == null) dTypeLen = 0; else dTypeLen = pi.val.intValue(); pos = pi.pos + 1; if ((pos + langLen + dTypeLen) > len) throw new RDFRDBException("Malformed Literal: " + litString); lang = litString.substring(pos, pos + langLen); pos = pos + langLen; dType = litString.substring(pos, pos + dTypeLen); pos = pos + dTypeLen; String val = litString.substring(pos); if ((dType == null) || (dType.equals(""))) { llabel = new LiteralLabel(val, lang == null ? "" : lang); } else { RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(dType); llabel = new LiteralLabel(val, lang == null ? "" : lang, dt); } res = Node.createLiteral(llabel); } else if (nodeType.equals(RDB_CODE_BLANK)) { String bstr = rdbString.substring(4, len); res = Node.createAnon(new AnonId(bstr)); } else if (nodeType.equals(RDB_CODE_VARIABLE)) { String vname = rdbString.substring(3, len); res = Node.createVariable(vname); } else if (nodeType.equals(RDB_CODE_ANY)) { res = Node.ANY; } else throw new RDFRDBException("Invalid RDBString Prefix, " + rdbString); return res; } private final static class ParseInt { int pos; Integer val; ParseInt(int p) { pos = p; } } private static void rdbStringParseInt(String rdbString, ParseInt pi, boolean toEnd) { int npos = toEnd ? rdbString.length() : rdbString.indexOf( RDB_CODE_DELIM_CHAR, pi.pos); if (npos < 0) { throw new RDFRDBException("Bad RDB String: " + rdbString); } String intStr = rdbString.substring(pi.pos, npos); pi.pos = npos; if (intStr.equals("")) pi.val = null; else try { pi.val = new Integer(intStr); } catch (NumberFormatException e1) { throw new RDFRDBException("Bad RDB String: " + rdbString); } return; } /** * Encode a literal node's lang and datatype as a string of the form * ":[langLen]:[datatypeLen]:[langString][dataTypeString]" * * @return the string. */ private static String litLangTypeToRDBString(String lang, String dtype) throws RDFRDBException { String res = RDB_CODE_DELIM; res = ((lang == null) ? "" : Integer.toString(lang.length())) + RDB_CODE_DELIM; res = res + ((dtype == null) ? "" : Integer.toString(dtype.length())) + RDB_CODE_DELIM; res = res + (lang == null ? "" : lang) + (dtype == null ? "" : dtype); return res; } public static void writeTriple(Triple triple, ObjectOutput out) throws RDFRDBException, IOException { out.writeUTF(nodeToString(triple.getSubject())); out.writeUTF(nodeToString(triple.getPredicate())); out.writeUTF(nodeToString(triple.getObject())); } public static Triple readTriple(ObjectInput in) throws RDFRDBException, IOException { Node subject = TripleUtil.stringToNode(in.readUTF()); Node predicate = TripleUtil.stringToNode(in.readUTF()); Node object = TripleUtil.stringToNode(in.readUTF()); return new Triple(subject, predicate, object); } } /* * (c) Copyright 2000, 2001 Hewlett-Packard Development Company, LP All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. 2. Redistributions in * binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. 3. The name of the author may not * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ Index: DeleteTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/DeleteTripleCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DeleteTripleCommand.java 27 Jul 2004 16:20:00 -0000 1.2 --- DeleteTripleCommand.java 28 Jul 2004 06:54:07 -0000 1.3 *************** *** 20,38 **** package org.javaowl.models.prevalence; ! import com.hp.hpl.jena.graph.Node; ! import com.hp.hpl.jena.graph.Triple; import org.prevayler.Command; import org.prevayler.PrevalentSystem; ! import java.io.IOException; ! import java.io.ObjectInputStream; ! import java.io.ObjectOutputStream; ! import java.io.Serializable; ! ! class DeleteTripleCommand implements Command { ! private transient Triple triple; DeleteTripleCommand(Triple triple) { this.triple = triple; --- 20,42 ---- package org.javaowl.models.prevalence; ! import java.io.Externalizable; ! import java.io.IOException; ! import java.io.ObjectInput; ! import java.io.ObjectOutput; ! import java.io.Serializable; import org.prevayler.Command; import org.prevayler.PrevalentSystem; ! import com.hp.hpl.jena.graph.Triple; ! class DeleteTripleCommand implements Command, Externalizable { + private static final long serialVersionUID = -4089954040389955762L; + + private Triple triple; + + public DeleteTripleCommand() {} + DeleteTripleCommand(Triple triple) { this.triple = triple; *************** *** 44,59 **** } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); } } --- 48,57 ---- } ! public void writeExternal(ObjectOutput out) throws IOException { ! TripleUtil.writeTriple(triple, out); } ! public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { ! this.triple = TripleUtil.readTriple(in); } } --- StorageUtil.java DELETED --- Index: StorageGraph.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageGraph.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StorageGraph.java 26 Jul 2004 22:55:02 -0000 1.2 --- StorageGraph.java 28 Jul 2004 06:54:07 -0000 1.3 *************** *** 20,24 **** --- 20,31 ---- package org.javaowl.models.prevalence; + import java.io.Externalizable; + import java.io.IOException; + import java.io.ObjectInput; + import java.io.ObjectOutput; + import java.util.Iterator; + import com.hp.hpl.jena.graph.Graph; + import com.hp.hpl.jena.graph.GraphUtil; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.graph.Node; *************** *** 37,46 **** import com.hp.hpl.jena.util.iterator.ExtendedIterator; import org.prevayler.implementation.AbstractPrevalentSystem; ! class StorageGraph extends AbstractPrevalentSystem implements Graph { private final Graph graph = new GraphMem(ReificationStyle.Standard); public boolean dependsOn(Graph other) { return graph.dependsOn(other); --- 44,58 ---- import com.hp.hpl.jena.util.iterator.ExtendedIterator; + import org.prevayler.AlarmClock; import org.prevayler.implementation.AbstractPrevalentSystem; ! class StorageGraph extends AbstractPrevalentSystem implements Graph, Externalizable { + private static final long serialVersionUID = 792795079693766654L; + private final Graph graph = new GraphMem(ReificationStyle.Standard); + public StorageGraph() {} + public boolean dependsOn(Graph other) { return graph.dependsOn(other); *************** *** 53,57 **** } public BulkUpdateHandler getBulkUpdateHandler() { ! return graph.getBulkUpdateHandler(); } public Capabilities getCapabilities() { --- 65,69 ---- } public BulkUpdateHandler getBulkUpdateHandler() { ! throw new UnsupportedOperationException(); } public Capabilities getCapabilities() { *************** *** 97,99 **** --- 109,126 ---- graph.add(t); } + + public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(size()); + out.writeObject(clock()); + for (Iterator it = GraphUtil.findAll(graph); it.hasNext(); ) { + TripleUtil.writeTriple((Triple) it.next(), out); + } + } + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + int size = in.readInt(); + clock((AlarmClock) in.readObject()); + for(int i = 0; i < size; i++) { + add(TripleUtil.readTriple(in)); + } + } } Index: PrevalentGraph.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/PrevalentGraph.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PrevalentGraph.java 26 Jul 2004 22:55:02 -0000 1.2 --- PrevalentGraph.java 28 Jul 2004 06:54:07 -0000 1.3 *************** *** 21,28 **** --- 21,31 ---- import java.io.IOException; + import java.util.Iterator; + import java.util.List; import org.prevayler.implementation.SnapshotPrevayler; import com.hp.hpl.jena.graph.Graph; + import com.hp.hpl.jena.graph.GraphUtil; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.graph.Node; *************** *** 39,43 **** import com.hp.hpl.jena.util.iterator.ExtendedIterator; ! public class PrevalentGraph implements Graph, Runnable{ private final SnapshotPrevayler prevayler; --- 42,46 ---- import com.hp.hpl.jena.util.iterator.ExtendedIterator; ! public class PrevalentGraph implements Graph, BulkUpdateHandler, Runnable{ private final SnapshotPrevayler prevayler; *************** *** 47,50 **** --- 50,54 ---- prevayler = new SnapshotPrevayler(new StorageGraph(), directory); storageGraph = (StorageGraph) prevayler.system(); + new Thread(this).start(); } *************** *** 52,55 **** --- 56,62 ---- for (;;) { try { + prevayler.takeSnapshot(); + System.err.println("Snapshot taken at " + new java.util.Date() + "..."); + try { Thread.sleep(1000 * 60 * 60 * 24); *************** *** 57,62 **** //Ignore } - prevayler.takeSnapshot(); - System.err.println("Snapshot taken at " + new java.util.Date() + "..."); } catch (IOException e) { e.printStackTrace(); --- 64,67 ---- *************** *** 78,82 **** public BulkUpdateHandler getBulkUpdateHandler() { ! return storageGraph.getBulkUpdateHandler(); } --- 83,87 ---- public BulkUpdateHandler getBulkUpdateHandler() { ! return this; } *************** *** 146,148 **** --- 151,201 ---- } } + + public void add(Triple[] triples) { + for (int i = 0; i < triples.length; i++) { + add(triples[i]); + } + } + + public void add(List triples) { + add(triples.iterator()); + } + + public void add(Iterator it) { + while (it.hasNext()) { + add((Triple) it.next()); + } + } + + public void add(Graph graph, boolean withReifications) { + add(GraphUtil.findAll(graph)); + } + + public void add(Graph graph) { + add(graph, false); + } + + public void delete(Triple[] triples) { + for (int i = 0; i < triples.length; i++) { + delete(triples[i]); + } + } + + public void delete(List triples) { + delete(triples.iterator()); + } + + public void delete(Iterator it) { + while (it.hasNext()) { + delete((Triple) it.next()); + } + } + + public void delete(Graph graph) { + delete(graph, false); + } + + public void delete(Graph graph, boolean withReifications) { + delete(GraphUtil.findAll(graph)); + } } Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AddTripleCommand.java 27 Jul 2004 16:20:00 -0000 1.6 --- AddTripleCommand.java 28 Jul 2004 06:54:07 -0000 1.7 *************** *** 20,38 **** package org.javaowl.models.prevalence; ! import com.hp.hpl.jena.graph.Node; ! import com.hp.hpl.jena.graph.Triple; import org.prevayler.Command; import org.prevayler.PrevalentSystem; ! import java.io.Serializable; ! import java.io.ObjectInputStream; ! import java.io.ObjectOutputStream; ! import java.io.IOException; ! ! class AddTripleCommand implements Command { ! private transient Triple triple; AddTripleCommand(Triple triple) { this.triple = triple; --- 20,42 ---- package org.javaowl.models.prevalence; ! import java.io.Externalizable; ! import java.io.IOException; ! import java.io.ObjectInput; ! import java.io.ObjectOutput; ! import java.io.Serializable; import org.prevayler.Command; import org.prevayler.PrevalentSystem; ! import com.hp.hpl.jena.graph.Triple; ! class AddTripleCommand implements Command, Externalizable { + private static final long serialVersionUID = -8900004762584176922L; + + private Triple triple; + + public AddTripleCommand() {} + AddTripleCommand(Triple triple) { this.triple = triple; *************** *** 44,59 **** } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); } } --- 48,61 ---- } ! public void writeExternal(ObjectOutput out) throws IOException { ! TripleUtil.writeTriple(triple, out); } ! public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { ! try { ! this.triple = TripleUtil.readTriple(in); ! } catch (Exception e) { ! e.printStackTrace(); ! } } } |
|
From: Elmer G. <ega...@us...> - 2004-07-28 06:54:25
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18474/src/org/javaowl/editor Modified Files: ModelEditorBean.java ResourceEditorBean.java Log Message: Changed serialization to externalization. Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ModelEditorBean.java 27 Jul 2004 17:25:35 -0000 1.7 --- ModelEditorBean.java 28 Jul 2004 06:54:06 -0000 1.8 *************** *** 136,140 **** return result; } ! public OntProperty[] getAllProperties() { Set props = new HashSet(); --- 136,140 ---- return result; } ! //TODO: rename getAllDatatypeProperties public OntProperty[] getAllProperties() { Set props = new HashSet(); *************** *** 170,174 **** } ! public OntClass createClass(Resource resource) { return ontModel.createClass(resource.getURI()); --- 170,174 ---- } ! //TODO: rename getOntClass etc ... public OntClass createClass(Resource resource) { return ontModel.createClass(resource.getURI()); *************** *** 188,191 **** --- 188,192 ---- } + //TODO: remove where resource is object public void removeResource(Resource resource) { List stmts = new ArrayList(); *************** *** 206,218 **** return (OntClass[]) classes.toArray(new OntClass[0]); } ! ! public Resource[] getDataResources() { ! // TODO: What is this for? ! List resources = new ArrayList(); ! for (Iterator it = data.listSubjects(); it.hasNext();) ! resources.add(it.next()); ! return (Resource[]) resources.toArray(new Resource[0]); ! } ! public ResourceEditorBean getNewResourceEditor(OntResource classResource) { Resource r = data.createResource(); --- 207,211 ---- return (OntClass[]) classes.toArray(new OntClass[0]); } ! //TODO: look for better names public ResourceEditorBean getNewResourceEditor(OntResource classResource) { Resource r = data.createResource(); *************** *** 248,252 **** throw new RuntimeException("ontology reasoner exception: ", e); } ! List classes = new ArrayList(); List leafClasses = new ArrayList(); --- 241,245 ---- throw new RuntimeException("ontology reasoner exception: ", e); } ! //TODO: Remove leafClasses methods List classes = new ArrayList(); List leafClasses = new ArrayList(); Index: ResourceEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ResourceEditorBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ResourceEditorBean.java 23 Jul 2004 01:18:50 -0000 1.4 --- ResourceEditorBean.java 28 Jul 2004 06:54:06 -0000 1.5 *************** *** 48,53 **** private final Resource resource; - // private OntClass[] types; - private final String prefix; --- 48,51 ---- *************** *** 94,104 **** return result; } ! ! /* ! public OntClass[] getTypes() { ! return types; ! } ! */ ! public Statement[] getProperties() { List resources = new ArrayList(); --- 92,96 ---- return result; } ! //TODO: rename getDeclaredPRoperties public Statement[] getProperties() { List resources = new ArrayList(); *************** *** 114,126 **** return false; } ! ! public OntResource[] getValidClasses(OntProperty property) { ! // TODO: This method is never called! ! List resources = new ArrayList(); ! for (Iterator it = property.listRange(); it.hasNext();) ! resources.add(it.next()); ! return (OntResource[]) resources.toArray(new OntResource[0]); ! } ! public OntResource getValidLeafClass(Property property) { OntProperty op; --- 106,111 ---- return false; } ! //TODO: get all valid Instances for the range intersection and the ! // resource restrictions public OntResource getValidLeafClass(Property property) { OntProperty op; |
|
From: Elmer G. <ega...@us...> - 2004-07-27 17:45:39
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/remote In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12907/src/org/javaowl/models/remote Added Files: RemoteGraph.java Log Message: Begined remote work --- NEW FILE: RemoteGraph.java --- /* * RemoteGraph.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer * Garduno Hernandez * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.models.remote; import java.rmi.Remote; import com.hp.hpl.jena.graph.Graph; public interface RemoteGraph extends Remote, Graph { } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 17:45:29
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/remote In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12864/src/org/javaowl/models/remote Log Message: Directory /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/remote added to the repository |
|
From: Elmer G. <ega...@us...> - 2004-07-27 17:26:15
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8571/src/org/javaowl/editor/swing Modified Files: BrowsePage.java Log Message: Added remove statement? Is not changing de prevalent model. Index: BrowsePage.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/BrowsePage.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BrowsePage.java 27 Jul 2004 15:59:56 -0000 1.4 --- BrowsePage.java 27 Jul 2004 17:25:36 -0000 1.5 *************** *** 22,25 **** --- 22,27 ---- import java.awt.event.ItemEvent; import java.awt.event.ItemListener; + import java.awt.event.KeyAdapter; + import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; *************** *** 54,60 **** private final Component component; ! private final JCheckBox allInstances = new JCheckBox("Show inferred instances"); - private final JCheckBox allProperties = new JCheckBox("Show inferred properties"); private final Editor e; --- 56,65 ---- private final Component component; ! private final JCheckBox allInstances = new JCheckBox( ! "Show inferred instances"); ! ! private final JCheckBox allProperties = new JCheckBox( ! "Show inferred properties"); private final Editor e; *************** *** 79,105 **** MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { ! int index = instancesList.locationToIndex(e.getPoint()); ! Resource resource = (Resource) instances.elementAt(index); ! notifyEditResource(resource); } }; instancesList.addMouseListener(mouseListener); instancesList.setCellRenderer(renderer); allProperties.addItemListener(this); allInstances.addItemListener(this); JPanel propertiesPane = new JPanel(); ! propertiesPane.setLayout(new BoxLayout(propertiesPane, BoxLayout.Y_AXIS)); propertiesPane.add(new JScrollPane(propertiesList)); propertiesPane.add(allProperties); JPanel instancesPane = new JPanel(); - instancesPane.setLayout(new BoxLayout(instancesPane, BoxLayout.Y_AXIS)); instancesPane.add(new JScrollPane(instancesList)); instancesPane.add(allInstances); ! JSplitPane left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree ! .getComponent()), propertiesPane); left.setDividerLocation(300); left.setResizeWeight(0.5); ! JSplitPane center = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, instancesPane); center.setDividerLocation(600); center.setResizeWeight(0.5); --- 84,124 ---- MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { ! if (e.getClickCount() == 2) { ! int index = instancesList.locationToIndex(e.getPoint()); ! Resource resource = (Resource) instances.elementAt(index); ! notifyEditResource(resource); ! } } }; instancesList.addMouseListener(mouseListener); + instancesList.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + if (KeyEvent.VK_DELETE == e.getKeyCode()) { + Resource resource = (Resource) instancesList + .getSelectedValue(); + instances.removeElement(resource); + notifyRemoveResource(resource); + } + + } + }); instancesList.setCellRenderer(renderer); allProperties.addItemListener(this); allInstances.addItemListener(this); JPanel propertiesPane = new JPanel(); ! propertiesPane ! .setLayout(new BoxLayout(propertiesPane, BoxLayout.Y_AXIS)); propertiesPane.add(new JScrollPane(propertiesList)); propertiesPane.add(allProperties); JPanel instancesPane = new JPanel(); instancesPane.setLayout(new BoxLayout(instancesPane, BoxLayout.Y_AXIS)); instancesPane.add(new JScrollPane(instancesList)); instancesPane.add(allInstances); ! JSplitPane left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, ! new JScrollPane(tree.getComponent()), propertiesPane); left.setDividerLocation(300); left.setResizeWeight(0.5); ! JSplitPane center = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, ! instancesPane); center.setDividerLocation(600); center.setResizeWeight(0.5); *************** *** 114,118 **** e.editResource(resource); } ! private void notifySetStatus() { e.setStatus(getStatus()); --- 133,141 ---- e.editResource(resource); } ! ! private void notifyRemoveResource(Resource resource) { ! editor.removeResource(resource); ! } ! private void notifySetStatus() { e.setStatus(getStatus()); *************** *** 136,142 **** Util.setList(resources, editor.getAllClasses()); if (resource != null) { ! Util.setList(properties, editor ! .getProperties(resource, allProperties.isSelected())); ! Util.setList(instances, editor.getInstances(resource, allInstances.isSelected())); } notifySetStatus(); --- 159,166 ---- Util.setList(resources, editor.getAllClasses()); if (resource != null) { ! Util.setList(properties, editor.getProperties(resource, ! allProperties.isSelected())); ! Util.setList(instances, editor.getInstances(resource, allInstances ! .isSelected())); } notifySetStatus(); *************** *** 144,149 **** private String getStatus() { ! return (resource != null) ? Util.getPropertyValue(resource, RDFS.label, true) : null; } ! } --- 168,174 ---- private String getStatus() { ! return (resource != null) ? Util.getPropertyValue(resource, RDFS.label, ! true) : null; } ! } \ No newline at end of file |
|
From: Elmer G. <ega...@us...> - 2004-07-27 17:25:49
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8571/src/org/javaowl/editor Modified Files: ModelEditorBean.java Log Message: Added remove statement? Is not changing de prevalent model. Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ModelEditorBean.java 23 Jul 2004 01:18:50 -0000 1.6 --- ModelEditorBean.java 27 Jul 2004 17:25:35 -0000 1.7 *************** *** 187,190 **** --- 187,198 ---- data.remove(statement); } + + public void removeResource(Resource resource) { + List stmts = new ArrayList(); + for(Iterator it = resource.listProperties(); it.hasNext(); ) + stmts.add(it.next()); + ontModel.remove(stmts); + data.remove(stmts); + } public OntClass[] getSubClasses(OntClass resourceClass) { *************** *** 258,262 **** this.classes = (OntResource[]) classes.toArray(new OntResource[0]); this.leafClasses = (OntResource[]) leafClasses.toArray(new OntResource[0]); ! } ! } --- 266,269 ---- this.classes = (OntResource[]) classes.toArray(new OntResource[0]); this.leafClasses = (OntResource[]) leafClasses.toArray(new OntResource[0]); ! } } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 16:20:26
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27545/src/org/javaowl/models/prevalence Modified Files: AddTripleCommand.java DeleteTripleCommand.java Log Message: Fixed delete command. Index: DeleteTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/DeleteTripleCommand.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeleteTripleCommand.java 26 Jul 2004 22:55:02 -0000 1.1 --- DeleteTripleCommand.java 27 Jul 2004 16:20:00 -0000 1.2 *************** *** 1,5 **** /* ! * DeleteTripleCommand.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer ! * Garduno Hernandez * * This library is free software; you can redistribute it and/or modify it under --- 1,5 ---- /* ! * DeleteTripleCommand.java Copyright (C) 2004 Gerardo Horvilleur Martinez, ! * Elmer Garduno Hernandez * * This library is free software; you can redistribute it and/or modify it under *************** *** 20,23 **** --- 20,24 ---- package org.javaowl.models.prevalence; + import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Triple; *************** *** 25,33 **** import org.prevayler.PrevalentSystem; import java.io.Serializable; class DeleteTripleCommand implements Command { ! private final Triple triple; DeleteTripleCommand(Triple triple) { --- 26,37 ---- import org.prevayler.PrevalentSystem; + import java.io.IOException; + import java.io.ObjectInputStream; + import java.io.ObjectOutputStream; import java.io.Serializable; class DeleteTripleCommand implements Command { ! private transient Triple triple; DeleteTripleCommand(Triple triple) { *************** *** 39,42 **** --- 43,60 ---- return null; } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); + out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); + out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); + } + + private void readObject(ObjectInputStream in) throws IOException, + ClassNotFoundException { + Node subject = StorageUtil.rdbStringToNode(in.readUTF()); + Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); + Node object = StorageUtil.rdbStringToNode(in.readUTF()); + this.triple = new Triple(subject, predicate, object); + } } Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AddTripleCommand.java 27 Jul 2004 15:51:00 -0000 1.5 --- AddTripleCommand.java 27 Jul 2004 16:20:00 -0000 1.6 *************** *** 33,64 **** class AddTripleCommand implements Command { ! private transient Triple triple; ! AddTripleCommand(Triple triple) { ! this.triple = triple; ! } ! public Serializable execute(PrevalentSystem system) throws Exception { ! ((StorageGraph) system).add(triple); ! return null; ! } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); ! } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! try { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } } --- 33,60 ---- class AddTripleCommand implements Command { ! private transient Triple triple; ! AddTripleCommand(Triple triple) { ! this.triple = triple; ! } ! public Serializable execute(PrevalentSystem system) throws Exception { ! ((StorageGraph) system).add(triple); ! return null; ! } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); ! } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); ! } } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 16:00:06
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23135/src/org/javaowl/editor/swing Modified Files: StringPropertyEditorPagelet.java OntTreePagelet.java BrowsePage.java Log Message: Removed some warnings Index: OntTreePagelet.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/OntTreePagelet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OntTreePagelet.java 27 Jul 2004 04:10:18 -0000 1.3 --- OntTreePagelet.java 27 Jul 2004 15:59:56 -0000 1.4 *************** *** 34,38 **** import org.javaowl.editor.ModelEditorBean; - import org.javaowl.editor.ResourceEditorBean; import com.hp.hpl.jena.ontology.OntClass; --- 34,37 ---- *************** *** 49,54 **** private final JTree component; - private final ResourceEditorBean resource; - private final Map paths = new HashMap(); --- 48,51 ---- *************** *** 56,68 **** public OntTreePagelet(ModelEditorBean editor, BrowsePage browsePage) { - this(editor, null, browsePage); - } - - public OntTreePagelet(ModelEditorBean editor, ResourceEditorBean resource, BrowsePage browsePage) { this.editor = editor; - this.resource = resource; this.browsePage = browsePage; component = createPanel(); - // showTypes(); } --- 53,59 ---- Index: StringPropertyEditorPagelet.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/StringPropertyEditorPagelet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringPropertyEditorPagelet.java 22 Jul 2004 02:47:41 -0000 1.1 --- StringPropertyEditorPagelet.java 27 Jul 2004 15:59:56 -0000 1.2 *************** *** 37,42 **** private JPanel textPanel = new JPanel(); - private OntResource resourceClass; - private final JPanel component; --- 37,40 ---- Index: BrowsePage.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/BrowsePage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BrowsePage.java 22 Jul 2004 19:16:54 -0000 1.3 --- BrowsePage.java 27 Jul 2004 15:59:56 -0000 1.4 *************** *** 147,154 **** } - private void clear() { - // TODO: This method is never used! - resource = null; - refresh(); - } } --- 147,149 ---- |
|
From: Elmer G. <ega...@us...> - 2004-07-27 15:51:15
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21646/src/org/javaowl/models/prevalence Modified Files: StorageUtil.java AddTripleCommand.java Log Message: Now prevalence work!! Need to test. Index: StorageUtil.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StorageUtil.java 27 Jul 2004 05:23:24 -0000 1.4 --- StorageUtil.java 27 Jul 2004 15:51:00 -0000 1.5 *************** *** 5,21 **** package org.javaowl.models.prevalence; - import java.sql.PreparedStatement; - import java.sql.ResultSet; - import java.sql.SQLException; - import java.util.zip.CRC32; - - import org.apache.xerces.util.XMLChar; - import com.hp.hpl.jena.datatypes.RDFDatatype; [...988 lines suppressed...] ! /** ! * Encode a literal node's lang and datatype as a string of the form ! * ":[langLen]:[datatypeLen]:[langString][dataTypeString]" ! * ! * @return the string. ! */ ! private static String litLangTypeToRDBString(String lang, String dtype) ! throws RDFRDBException { ! String res = RDB_CODE_DELIM; ! res = ((lang == null) ? "" : Integer.toString(lang.length())) ! + RDB_CODE_DELIM; ! res = res + ((dtype == null) ? "" : Integer.toString(dtype.length())) ! + RDB_CODE_DELIM; ! res = res + (lang == null ? "" : lang) + (dtype == null ? "" : dtype); ! return res; ! } } Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AddTripleCommand.java 27 Jul 2004 05:30:48 -0000 1.4 --- AddTripleCommand.java 27 Jul 2004 15:51:00 -0000 1.5 *************** *** 52,59 **** private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); } } --- 52,63 ---- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ! try { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); ! } catch (Exception e) { ! e.printStackTrace(); ! } } } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 05:30:57
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13923/src/org/javaowl/models/prevalence Modified Files: AddTripleCommand.java Log Message: TODO: Fix incorrect readObject method. Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AddTripleCommand.java 27 Jul 2004 05:23:24 -0000 1.3 --- AddTripleCommand.java 27 Jul 2004 05:30:48 -0000 1.4 *************** *** 33,56 **** class AddTripleCommand implements Command { ! private final transient Triple triple; ! AddTripleCommand(Triple triple) { ! this.triple = triple; ! } ! public Serializable execute(PrevalentSystem system) throws Exception { ! ((StorageGraph) system).add(triple); ! return null; ! } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); ! } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! } } --- 33,60 ---- class AddTripleCommand implements Command { ! private transient Triple triple; ! AddTripleCommand(Triple triple) { ! this.triple = triple; ! } ! public Serializable execute(PrevalentSystem system) throws Exception { ! ((StorageGraph) system).add(triple); ! return null; ! } ! private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); ! } ! private void readObject(ObjectInputStream in) throws IOException, ! ClassNotFoundException { ! Node subject = StorageUtil.rdbStringToNode(in.readUTF()); ! Node predicate = StorageUtil.rdbStringToNode(in.readUTF()); ! Node object = StorageUtil.rdbStringToNode(in.readUTF()); ! this.triple = new Triple(subject, predicate, object); ! } } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 05:23:34
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12922/src/org/javaowl/models/prevalence Modified Files: StorageUtil.java AddTripleCommand.java Log Message: Working on prevayler persistence. Serialize through StorageUtil class. Index: StorageUtil.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StorageUtil.java 27 Jul 2004 04:43:42 -0000 1.3 --- StorageUtil.java 27 Jul 2004 05:23:24 -0000 1.4 *************** *** 33,65 **** * EOS_LEN is the length of EOS (0 or 1). */ ! private String EOS = ""; ! private char EOS_CHAR = ':'; ! private int EOS_LEN = 0; /** * the quote character used to delimit characters and strings. */ ! private char QUOTE_CHAR = '\"'; ! ! /** ! * true if URI's are to be compressed by storing prefixes (an approximation ! * of a namespace) in the JENA_PREFIX table. note that "short" prefixes are ! * not stored, i.e., the prefix length not more than URI_COMPRESS_LENGTH. ! */ ! protected boolean URI_COMPRESS; ! ! /** if URI_COMPRESS is true, compress prefixes that are longer than this. */ ! protected int URI_COMPRESS_LENGTH = 100; ! ! /** The maximum size of an object that can be stored in a Statement table */ ! protected int LONG_OBJECT_LENGTH; ! ! /** The maximum possible value for LONG_OBJECT_LENGTH (db-dependent) */ ! protected int LONG_OBJECT_LENGTH_MAX; /** Set to true if IDs are allocated prior to insert */ ! protected boolean PRE_ALLOCATE_ID; // ======================================================================= --- 33,49 ---- * EOS_LEN is the length of EOS (0 or 1). */ ! private final static String EOS = ""; ! private final static char EOS_CHAR = ':'; ! private final static int EOS_LEN = 0; /** * the quote character used to delimit characters and strings. */ ! private final char QUOTE_CHAR = '\"'; /** Set to true if IDs are allocated prior to insert */ ! private final static boolean PRE_ALLOCATE_ID = false; // ======================================================================= *************** *** 71,87 **** * statements * */ ! protected String SYSTEM_STMT_TABLE; /** Name of the long literal table * */ ! protected String LONG_LIT_TABLE; /** Name of the long URI table * */ ! protected String LONG_URI_TABLE; /** Name of the prefix table * */ ! protected String PREFIX_TABLE; /** Name of the graph table * */ ! protected String GRAPH_TABLE; // ======================================================================= --- 55,71 ---- * statements * */ ! private final static String SYSTEM_STMT_TABLE = ""; /** Name of the long literal table * */ ! private final static String LONG_LIT_TABLE = ""; /** Name of the long URI table * */ ! private final static String LONG_URI_TABLE = ""; /** Name of the prefix table * */ ! private final static String PREFIX_TABLE = ""; /** Name of the graph table * */ ! private final static String GRAPH_TABLE = ""; // ======================================================================= *************** *** 92,98 **** * Instance of SQLCache used by Driver for hard-coded db commands */ ! protected SQLCache m_sql = null; ! protected LRUCache prefixCache = null; /* --- 76,82 ---- * Instance of SQLCache used by Driver for hard-coded db commands */ ! private final static SQLCache m_sql = null; ! private final static LRUCache prefixCache = null; /* *************** *** 157,181 **** */ ! protected static String RDB_CODE_URI = "U"; ! protected static String RDB_CODE_BLANK = "B"; ! protected static String RDB_CODE_LITERAL = "L"; ! protected static String RDB_CODE_VARIABLE = "V"; ! protected static String RDB_CODE_ANY = "A"; ! protected static String RDB_CODE_PREFIX = "P"; ! protected static String RDB_CODE_VALUE = "v"; ! protected static String RDB_CODE_REF = "r"; ! protected static String RDB_CODE_DELIM = ":"; ! protected static char RDB_CODE_DELIM_CHAR = ':'; ! protected static String RDB_CODE_INVALID = "X"; private static final int INDEX_KEY_LENGTH = 0; --- 141,165 ---- */ ! private static String RDB_CODE_URI = "U"; ! private static String RDB_CODE_BLANK = "B"; ! private static String RDB_CODE_LITERAL = "L"; ! private static String RDB_CODE_VARIABLE = "V"; ! private static String RDB_CODE_ANY = "A"; ! private static String RDB_CODE_PREFIX = "P"; ! private static String RDB_CODE_VALUE = "v"; ! private static String RDB_CODE_REF = "r"; ! private static String RDB_CODE_DELIM = ":"; ! private static char RDB_CODE_DELIM_CHAR = ':'; ! private static String RDB_CODE_INVALID = "X"; private static final int INDEX_KEY_LENGTH = 0; *************** *** 186,195 **** * @param Node * The node to convert to a string. Must be a concrete node. - * @param addIfLong - * If the node is a long object and is not in the database, add - * it. * @return the string or null if failure. */ ! public String nodeToRDBString(Node node, boolean addIfLong) throws RDFRDBException { String res = null; --- 170,176 ---- * @param Node * The node to convert to a string. Must be a concrete node. * @return the string or null if failure. */ ! public static String nodeToRDBString(Node node) throws RDFRDBException { String res = null; *************** *** 206,218 **** // databases may become inaccessible. int pos = 0; ! boolean noCompress; String pfx; String qname; - if (URI_COMPRESS == true) { - pos = dbSplitNamespace(uri); - noCompress = (pos == uri.length()) - || (pos <= URI_COMPRESS_LENGTH); - } else - noCompress = true; if (noCompress) { pfx = RDB_CODE_DELIM + RDB_CODE_DELIM; --- 187,193 ---- // databases may become inaccessible. int pos = 0; ! boolean noCompress = true; String pfx; String qname; if (noCompress) { pfx = RDB_CODE_DELIM + RDB_CODE_DELIM; *************** *** 220,224 **** } else { // see if it's cached ! DBIDInt pfxid = uriToPrefix(uri, pos, addIfLong); if (pfxid == null) return res; --- 195,199 ---- } else { // see if it's cached ! DBIDInt pfxid = uriToPrefix(uri, pos); if (pfxid == null) return res; *************** *** 228,243 **** } int encodeLen = RDB_CODE_URI.length() + 1 + pfx.length() + EOS_LEN; - boolean uriIsLong = objectIsLong(encodeLen, qname); - if (uriIsLong) { - int dbid; - // belongs in URI table - DBIDInt uriID = getURIID(qname, addIfLong); - if (uriID == null) - return res; - dbid = uriID.getIntID(); - res = new String(RDB_CODE_URI + RDB_CODE_REF + pfx + dbid); - } else { res = RDB_CODE_URI + RDB_CODE_VALUE + pfx + qname + EOS; - } } else if (node.isLiteral()) { // TODO: may need to encode literal value when datatype is not a --- 203,207 ---- *************** *** 251,292 **** int encodeLen = RDB_CODE_LITERAL.length() + 2 + ld.length() + EOS_LEN; ! boolean litIsLong = objectIsLong(encodeLen, lval); ! if (litIsLong) { ! int dbid; ! // belongs in literal table ! DBIDInt lid = getLiteralID(litNode, addIfLong); ! if (lid == null) ! return res; ! dbid = lid.getIntID(); ! res = new String(RDB_CODE_LITERAL + RDB_CODE_REF ! + RDB_CODE_DELIM + dbid); ! } else { ! res = new String(RDB_CODE_LITERAL + RDB_CODE_VALUE + RDB_CODE_DELIM + ld + lval + EOS); - } } else if (node.isBlank()) { ! String bnid = node.getBlankNodeId().toString(); String delims = "::"; int encodeLen = RDB_CODE_BLANK.length() + 1 + delims.length() + EOS_LEN; - boolean BisLong = objectIsLong(encodeLen, bnid); - if (BisLong) { - int dbid; - // belongs in URI table - DBIDInt URIid = getBlankID(bnid, addIfLong); - if (URIid == null) - return res; - dbid = URIid.getIntID(); - res = new String(RDB_CODE_BLANK + RDB_CODE_REF + delims + dbid); - } else { res = new String(RDB_CODE_BLANK + RDB_CODE_VALUE + delims ! + bnid + EOS); ! } ! } else if (node.isVariable()) { String name = ((Node_Variable) node).getName(); int len = name.length(); - if ((len + 3 + EOS_LEN) > LONG_OBJECT_LENGTH) - throw new JenaException("Variable name too long: " + name); res = RDB_CODE_VARIABLE + RDB_CODE_VALUE + RDB_CODE_DELIM + name + EOS; --- 215,230 ---- int encodeLen = RDB_CODE_LITERAL.length() + 2 + ld.length() + EOS_LEN; ! res = new String(RDB_CODE_LITERAL + RDB_CODE_VALUE + RDB_CODE_DELIM + ld + lval + EOS); } else if (node.isBlank()) { ! String bnID = node.getBlankNodeId().toString(); String delims = "::"; int encodeLen = RDB_CODE_BLANK.length() + 1 + delims.length() + EOS_LEN; res = new String(RDB_CODE_BLANK + RDB_CODE_VALUE + delims ! + bnID + EOS); } else if (node.isVariable()) { String name = ((Node_Variable) node).getName(); int len = name.length(); res = RDB_CODE_VARIABLE + RDB_CODE_VALUE + RDB_CODE_DELIM + name + EOS; *************** *** 308,312 **** * @return The node or null if failure. */ ! public Node rdbStringToNode(String rdbString) throws RDFRDBException { Node res = null; int len = rdbString.length(); --- 246,250 ---- * @return The node or null if failure. */ ! public static Node rdbStringToNode(String rdbString) throws RDFRDBException { Node res = null; int len = rdbString.length(); *************** *** 322,350 **** int npos; ! if (nodeType.equals(RDB_CODE_URI)) { ! ParseInt pi = new ParseInt(pos); ! String prefix = ""; ! rdbStringParseInt(rdbString, pi, false); ! if (pi.val != null) { ! if (URI_COMPRESS == false) ! throw new RDFRDBException( ! "Bad URI: Prefix Compression Disabled: " ! + rdbString); ! prefix = idToPrefix(pi.val.intValue()); ! if (prefix == null) ! throw new RDFRDBException("Bad URI Prefix: " + rdbString); ! } ! pos = pi.pos + 1; ! String qname; ! if (valType.equals(RDB_CODE_REF)) { ! qname = idToURI(rdbString.substring(pos)); ! if (qname == null) ! throw new RDFRDBException("Bad URI: " + rdbString); ! } else ! qname = rdbString.substring(pos, len - EOS_LEN); ! ! res = Node.createURI(prefix + qname); ! ! } else if (nodeType.equals(RDB_CODE_LITERAL)) { ParseInt pi = new ParseInt(pos); String litString = null; --- 260,264 ---- int npos; ! if (nodeType.equals(RDB_CODE_LITERAL)) { ParseInt pi = new ParseInt(pos); String litString = null; *************** *** 360,366 **** len = litString.length(); String lang; ! String dtype; int langLen = 0; ! int dtypeLen = 0; LiteralLabel llabel; pi.pos = 0; --- 274,280 ---- len = litString.length(); String lang; ! String dType; int langLen = 0; ! int dTypeLen = 0; LiteralLabel llabel; pi.pos = 0; *************** *** 373,394 **** rdbStringParseInt(litString, pi, false); if (pi.val == null) ! dtypeLen = 0; else ! dtypeLen = pi.val.intValue(); pos = pi.pos + 1; ! if ((pos + langLen + dtypeLen) > len) throw new RDFRDBException("Malformed Literal: " + litString); lang = litString.substring(pos, pos + langLen); pos = pos + langLen; ! dtype = litString.substring(pos, pos + dtypeLen); ! pos = pos + dtypeLen; String val = litString.substring(pos); ! if ((dtype == null) || (dtype.equals(""))) { llabel = new LiteralLabel(val, lang == null ? "" : lang); } else { RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName( ! dtype); llabel = new LiteralLabel(val, lang == null ? "" : lang, dt); } --- 287,308 ---- rdbStringParseInt(litString, pi, false); if (pi.val == null) ! dTypeLen = 0; else ! dTypeLen = pi.val.intValue(); pos = pi.pos + 1; ! if ((pos + langLen + dTypeLen) > len) throw new RDFRDBException("Malformed Literal: " + litString); lang = litString.substring(pos, pos + langLen); pos = pos + langLen; ! dType = litString.substring(pos, pos + dTypeLen); ! pos = pos + dTypeLen; String val = litString.substring(pos); ! if ((dType == null) || (dType.equals(""))) { llabel = new LiteralLabel(val, lang == null ? "" : lang); } else { RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName( ! dType); llabel = new LiteralLabel(val, lang == null ? "" : lang, dt); } *************** *** 435,439 **** * @return the index of the first character of the localname */ ! public static int dbSplitNamespace(String uri) { char ch; int lg = uri.length(); --- 349,353 ---- * @return the index of the first character of the localname */ ! private static int dbSplitNamespace(String uri) { char ch; int lg = uri.length(); *************** *** 460,464 **** } ! class ParseInt { int pos; --- 374,378 ---- } ! private final static class ParseInt { int pos; *************** *** 470,480 **** } ! private void rdbStringParseInt(String RDBString, ParseInt pi, boolean toEnd) { ! int npos = toEnd ? RDBString.length() : RDBString.indexOf( RDB_CODE_DELIM_CHAR, pi.pos); if (npos < 0) { ! throw new RDFRDBException("Bad RDB String: " + RDBString); } ! String intStr = RDBString.substring(pi.pos, npos); pi.pos = npos; if (intStr.equals("")) --- 384,394 ---- } ! private static void rdbStringParseInt(String rdbString, ParseInt pi, boolean toEnd) { ! int npos = toEnd ? rdbString.length() : rdbString.indexOf( RDB_CODE_DELIM_CHAR, pi.pos); if (npos < 0) { ! throw new RDFRDBException("Bad RDB String: " + rdbString); } ! String intStr = rdbString.substring(pi.pos, npos); pi.pos = npos; if (intStr.equals("")) *************** *** 484,498 **** pi.val = new Integer(intStr); } catch (NumberFormatException e1) { ! throw new RDFRDBException("Bad RDB String: " + RDBString); } return; } ! private DBIDInt uriToPrefix(String uri, int pos, boolean add) { DBIDInt res; Object key = prefixCache.getByValue(uri.substring(0, pos)); if (key == null) { RDBLongObject lobj = prefixToLongObject(uri, pos); ! res = getLongObjectID(lobj, PREFIX_TABLE, add); if (res != null) prefixCache.put(res, uri.substring(0, pos)); --- 398,412 ---- pi.val = new Integer(intStr); } catch (NumberFormatException e1) { ! throw new RDFRDBException("Bad RDB String: " + rdbString); } return; } ! private static DBIDInt uriToPrefix(String uri, int pos) { DBIDInt res; Object key = prefixCache.getByValue(uri.substring(0, pos)); if (key == null) { RDBLongObject lobj = prefixToLongObject(uri, pos); ! res = getLongObjectID(lobj, PREFIX_TABLE); if (res != null) prefixCache.put(res, uri.substring(0, pos)); *************** *** 502,506 **** } ! private RDBLongObject prefixToLongObject(String prefix, int split) { RDBLongObject res = new RDBLongObject(); int headLen; --- 416,420 ---- } ! private static RDBLongObject prefixToLongObject(String prefix, int split) { RDBLongObject res = new RDBLongObject(); int headLen; *************** *** 528,532 **** * @return the string. */ ! public String litLangTypeToRDBString(String lang, String dtype) throws RDFRDBException { String res = RDB_CODE_DELIM; --- 442,446 ---- * @return the string. */ ! private static String litLangTypeToRDBString(String lang, String dtype) throws RDFRDBException { String res = RDB_CODE_DELIM; *************** *** 539,553 **** } ! /** ! * Check if an object is long, i.e., it exceeds the length limit for storing ! * in a statement table. ! * ! * @return true if literal is long, else false. ! */ ! protected boolean objectIsLong(int encodingLen, String objAsString) { ! return ((encodingLen + objAsString.length()) > LONG_OBJECT_LENGTH); ! } ! ! class RDBLongObject { String head; /* prefix of long object that can be indexed */ --- 453,457 ---- } ! private final static class RDBLongObject { String head; /* prefix of long object that can be indexed */ *************** *** 557,561 **** } ! protected RDBLongObject literalToLongObject(Node_Literal node) { RDBLongObject res = new RDBLongObject(); int headLen; --- 461,465 ---- } ! private RDBLongObject literalToLongObject(Node_Literal node) { RDBLongObject res = new RDBLongObject(); int headLen; *************** *** 583,587 **** } ! protected long stringToHash(String str) { CRC32 checksum = new CRC32(); checksum.update(str.getBytes()); --- 487,491 ---- } ! private static long stringToHash(String str) { CRC32 checksum = new CRC32(); checksum.update(str.getBytes()); *************** *** 592,598 **** * Return the database ID for the URI, if it exists */ ! public DBIDInt getBlankID(String bstr, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject(bstr, RDB_CODE_BLANK); ! return getLongObjectID(lobj, LONG_URI_TABLE, add); } --- 496,502 ---- * Return the database ID for the URI, if it exists */ ! private DBIDInt getBlankID(String bstr) throws RDFRDBException { ! RDBLongObject lobj = uriToLongObject(bstr, RDB_CODE_BLANK); ! return getLongObjectID(lobj, LONG_URI_TABLE); } *************** *** 600,609 **** * Return the database ID for the URI, if it exists */ ! public DBIDInt getURIID(String qname, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject(qname, RDB_CODE_URI); ! return getLongObjectID(lobj, LONG_URI_TABLE, add); } ! protected RDBLongObject URIToLongObject(String qname, String code) { RDBLongObject res = new RDBLongObject(); int headLen; --- 504,513 ---- * Return the database ID for the URI, if it exists */ ! private DBIDInt getURIID(String qname) throws RDFRDBException { ! RDBLongObject lobj = uriToLongObject(qname, RDB_CODE_URI); ! return getLongObjectID(lobj, LONG_URI_TABLE); } ! private RDBLongObject uriToLongObject(String qname, String code) { RDBLongObject res = new RDBLongObject(); int headLen; *************** *** 628,638 **** * Return the database ID for the literal, if it exists */ ! public DBIDInt getLiteralID(Node_Literal lnode, boolean add) throws RDFRDBException { RDBLongObject lobj = literalToLongObject(lnode); ! return getLongObjectID(lobj, LONG_LIT_TABLE, add); } ! public DBIDInt getLongObjectID(RDBLongObject lobj, String table, boolean add) throws RDFRDBException { try { --- 532,542 ---- * Return the database ID for the literal, if it exists */ ! private DBIDInt getLiteralID(Node_Literal lnode) throws RDFRDBException { RDBLongObject lobj = literalToLongObject(lnode); ! return getLongObjectID(lobj, LONG_LIT_TABLE); } ! private static DBIDInt getLongObjectID(RDBLongObject lobj, String table) throws RDFRDBException { try { *************** *** 650,655 **** result = wrapDBID(rs.getObject(1)); } else { ! if (add) ! result = addRDBLongObject(lobj, table); } m_sql.returnPreparedSQLStatement(ps, opName); --- 554,558 ---- result = wrapDBID(rs.getObject(1)); } else { ! result = addRDBLongObject(lobj, table); } m_sql.returnPreparedSQLStatement(ps, opName); *************** *** 668,672 **** * @return the db index of the added literal */ ! public DBIDInt addRDBLongObject(RDBLongObject lobj, String table) throws RDFRDBException { try { --- 571,575 ---- * @return the db index of the added literal */ ! private static DBIDInt addRDBLongObject(RDBLongObject lobj, String table) throws RDFRDBException { try { *************** *** 721,725 **** * @return */ ! private int getInsertID(String table) { // TODO Auto-generated method stub return 0; --- 624,628 ---- * @return */ ! private static int getInsertID(String table) { // TODO Auto-generated method stub return 0; *************** *** 733,737 **** * @return the prefix string or null if it does not exist. */ ! protected String idToPrefix(int prefixID) { // check cache DBIDInt dbid = new DBIDInt(prefixID); --- 636,640 ---- * @return the prefix string or null if it does not exist. */ ! private static String idToPrefix(int prefixID) { // check cache DBIDInt dbid = new DBIDInt(prefixID); *************** *** 750,754 **** * @return the Blank node string or null if it does not exist. */ ! protected String idToBlank(String bnID) { return idToString(bnID, LONG_URI_TABLE, RDB_CODE_BLANK); } --- 653,657 ---- * @return the Blank node string or null if it does not exist. */ ! private static String idToBlank(String bnID) { return idToString(bnID, LONG_URI_TABLE, RDB_CODE_BLANK); } *************** *** 761,765 **** * @return the uri string or null if it does not exist. */ ! protected String idToURI(String uriID) { return idToString(uriID, LONG_URI_TABLE, RDB_CODE_URI); } --- 664,668 ---- * @return the uri string or null if it does not exist. */ ! private static String idToURI(String uriID) { return idToString(uriID, LONG_URI_TABLE, RDB_CODE_URI); } *************** *** 772,780 **** * @return the long literal string or null if it does not exist. */ ! protected String idToLiteral(int litID) { return idToString(litID, LONG_LIT_TABLE, RDB_CODE_LITERAL); } ! protected String idToString(String dbidAsString, String table, String RDBcode) { int dbID; --- 675,683 ---- * @return the long literal string or null if it does not exist. */ ! private static String idToLiteral(int litID) { return idToString(litID, LONG_LIT_TABLE, RDB_CODE_LITERAL); } ! private static String idToString(String dbidAsString, String table, String RDBcode) { int dbID; *************** *** 788,792 **** } ! protected String idToString(int dbID, String table, String RDBcode) { String res = null; RDBLongObject lobj = idToLongObject(dbID, table); --- 691,695 ---- } ! private static String idToString(int dbID, String table, String RDBcode) { String res = null; RDBLongObject lobj = idToLongObject(dbID, table); *************** *** 803,807 **** } ! protected RDBLongObject idToLongObject(int dbid, String table) { RDBLongObject res = null; try { --- 706,710 ---- } ! private static RDBLongObject idToLongObject(int dbid, String table) { RDBLongObject res = null; try { *************** *** 824,828 **** } ! protected RDBLongObject idToLongObject(String idAsString, String table) { RDBLongObject res = null; int dbid; --- 727,731 ---- } ! private RDBLongObject idToLongObject(String idAsString, String table) { RDBLongObject res = null; int dbid; *************** *** 839,843 **** * java object which meets the DBIDInt interface. */ ! public DBIDInt wrapDBID(Object id) throws RDFRDBException { if (id instanceof Number) { return new DBIDInt(((Number) id).intValue()); --- 742,746 ---- * java object which meets the DBIDInt interface. */ ! private static DBIDInt wrapDBID(Object id) throws RDFRDBException { if (id instanceof Number) { return new DBIDInt(((Number) id).intValue()); Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AddTripleCommand.java 27 Jul 2004 04:43:42 -0000 1.2 --- AddTripleCommand.java 27 Jul 2004 05:23:24 -0000 1.3 *************** *** 45,58 **** private void writeObject(ObjectOutputStream out) throws IOException { ! //String subject = triple.getSubject().equals(Node.NULL) ? null : ! // m_driver.nodeToRDBString(t.getSubject(),true); ! //String predicate = triple.getPredicate().equals(Node.NULL) ? null : ! // m_driver.nodeToRDBString(t.getPredicate(),true); ! //String object = triple.getObject().equals(Node.NULL) ? null : ! // m_driver.nodeToRDBString(t.getObject(),true); ! //System.out.println(PrintUtil.print(triple)); ! //System.out.println(triple.getSubject() + "^" + triple.getSubject().getClass()); ! //System.out.println(triple.getPredicate() + "^" + triple.getPredicate().getClass()); ! //System.out.println(triple.getObject() + "^" + triple.getObject().getClass()); } --- 45,51 ---- private void writeObject(ObjectOutputStream out) throws IOException { ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getSubject())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getPredicate())); ! out.writeUTF(StorageUtil.nodeToRDBString(triple.getObject())); } |
|
From: Elmer G. <ega...@us...> - 2004-07-27 04:43:50
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7764/src/org/javaowl/models/prevalence Modified Files: StorageUtil.java AddTripleCommand.java Log Message: Fixed method and field names. Index: StorageUtil.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StorageUtil.java 27 Jul 2004 04:10:18 -0000 1.2 --- StorageUtil.java 27 Jul 2004 04:43:42 -0000 1.3 *************** *** 1,6 **** /* ! (c) Copyright 2003, Hewlett-Packard Development Company, LP ! [See end of file] ! */ package org.javaowl.models.prevalence; --- 1,5 ---- /* ! * (c) Copyright 2003, Hewlett-Packard Development Company, LP [See end of file] ! */ [...1729 lines suppressed...] ! * modification, are permitted provided that the following conditions are met: ! * 1. Redistributions of source code must retain the above copyright notice, ! * this list of conditions and the following disclaimer. 2. Redistributions in ! * binary form must reproduce the above copyright notice, this list of ! * conditions and the following disclaimer in the documentation and/or other ! * materials provided with the distribution. 3. The name of the author may not ! * be used to endorse or promote products derived from this software without ! * specific prior written permission. ! * ! * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ! * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO ! * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ! * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ! * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ! * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ! * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ! * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ Index: AddTripleCommand.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/AddTripleCommand.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AddTripleCommand.java 26 Jul 2004 22:55:02 -0000 1.1 --- AddTripleCommand.java 27 Jul 2004 04:43:42 -0000 1.2 *************** *** 22,26 **** import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Triple; - import com.hp.hpl.jena.util.PrintUtil; import org.prevayler.Command; --- 22,25 ---- |
|
From: Elmer G. <ega...@us...> - 2004-07-27 04:10:29
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2962/src/org/javaowl/models/prevalence Modified Files: StorageUtil.java Log Message: Fixed build. Index: StorageUtil.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StorageUtil.java 26 Jul 2004 22:55:02 -0000 1.1 --- StorageUtil.java 27 Jul 2004 04:10:18 -0000 1.2 *************** *** 6,21 **** package org.javaowl.models.prevalence; ! import java.util.ArrayList; ! import java.util.Iterator; ! import java.util.List; import java.util.zip.CRC32; import com.hp.hpl.jena.datatypes.RDFDatatype; import com.hp.hpl.jena.datatypes.TypeMapper; - import com.hp.hpl.jena.db.GraphRDB; import com.hp.hpl.jena.db.IDBConnection; import com.hp.hpl.jena.db.RDFRDBException; import com.hp.hpl.jena.db.impl.DBIDInt; ! import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Node_Literal; --- 6,24 ---- package org.javaowl.models.prevalence; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; import java.util.zip.CRC32; + import org.apache.xerces.util.XMLChar; + import com.hp.hpl.jena.datatypes.RDFDatatype; import com.hp.hpl.jena.datatypes.TypeMapper; import com.hp.hpl.jena.db.IDBConnection; import com.hp.hpl.jena.db.RDFRDBException; import com.hp.hpl.jena.db.impl.DBIDInt; ! import com.hp.hpl.jena.db.impl.LRUCache; ! import com.hp.hpl.jena.db.impl.SQLCache; ! import com.hp.hpl.jena.db.impl.SpecializedGraph; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Node_Literal; *************** *** 23,33 **** import com.hp.hpl.jena.graph.Node_Variable; import com.hp.hpl.jena.graph.impl.LiteralLabel; - import com.hp.hpl.jena.rdf.model.AnonId; ! import com.hp.hpl.jena.shared.*; ! ! import com.hp.hpl.jena.vocabulary.RDF; ! ! import org.apache.xerces.util.XMLChar; public class StorageUtil { --- 26,31 ---- import com.hp.hpl.jena.graph.Node_Variable; import com.hp.hpl.jena.graph.impl.LiteralLabel; import com.hp.hpl.jena.rdf.model.AnonId; ! import com.hp.hpl.jena.shared.JenaException; public class StorageUtil { *************** *** 256,270 **** */ ! protected static String RDBCodeURI = "U"; ! protected static String RDBCodeBlank = "B"; ! protected static String RDBCodeLiteral = "L"; ! protected static String RDBCodeVariable = "V"; ! protected static String RDBCodeANY = "A"; ! protected static String RDBCodePrefix = "P"; ! protected static String RDBCodeValue = "v"; ! protected static String RDBCodeRef = "r"; ! protected static String RDBCodeDelim = ":"; ! protected static char RDBCodeDelimChar = ':'; ! protected static String RDBCodeInvalid = "X"; /** --- 254,270 ---- */ ! protected static String RDB_CODE_URI = "U"; ! protected static String RDB_CODE_BLANK = "B"; ! protected static String RDB_CODE_LITERAL = "L"; ! protected static String RDB_CODE_VARIABLE = "V"; ! protected static String RDB_CODE_ANY = "A"; ! protected static String RDB_CODE_PREFIX = "P"; ! protected static String RDB_CODE_VALUE = "v"; ! protected static String RDB_CODE_REF = "r"; ! protected static String RDB_CODE_DELIM = ":"; ! protected static char RDB_CODE_DELIM_CHAR = ':'; ! protected static String RDB_CODE_INVALID = "X"; ! ! private static final int INDEX_KEY_LENGTH = 0; /** *************** *** 278,282 **** if ( node.isURI() ) { String uri = new String(((Node_URI) node).getURI()); ! if ( uri.startsWith(RDBCodeURI) ) { throw new RDFRDBException ("URI Node looks like a blank node: " + uri ); } --- 278,282 ---- if ( node.isURI() ) { String uri = new String(((Node_URI) node).getURI()); ! if ( uri.startsWith(RDB_CODE_URI) ) { throw new RDFRDBException ("URI Node looks like a blank node: " + uri ); } *************** *** 296,300 **** noCompress = true; if ( noCompress ) { ! pfx = RDBCodeDelim + RDBCodeDelim; qname = uri; } else { --- 296,300 ---- noCompress = true; if ( noCompress ) { ! pfx = RDB_CODE_DELIM + RDB_CODE_DELIM; qname = uri; } else { *************** *** 302,309 **** DBIDInt pfxid = URItoPrefix(uri, pos, addIfLong); if ( pfxid == null ) return res; ! pfx = RDBCodeDelim + ((DBIDInt) pfxid).getIntID() + RDBCodeDelim; qname = uri.substring(pos); } ! int encodeLen = RDBCodeURI.length() + 1 + pfx.length() + EOS_LEN; boolean URIisLong = objectIsLong(encodeLen,qname); if ( URIisLong ) { --- 302,309 ---- DBIDInt pfxid = URItoPrefix(uri, pos, addIfLong); if ( pfxid == null ) return res; ! pfx = RDB_CODE_DELIM + ((DBIDInt) pfxid).getIntID() + RDB_CODE_DELIM; qname = uri.substring(pos); } ! int encodeLen = RDB_CODE_URI.length() + 1 + pfx.length() + EOS_LEN; boolean URIisLong = objectIsLong(encodeLen,qname); if ( URIisLong ) { *************** *** 313,319 **** if ( URIid == null ) return res; dbid = URIid.getIntID(); ! res = new String(RDBCodeURI + RDBCodeRef + pfx + dbid); } else { ! res = RDBCodeURI + RDBCodeValue + pfx + qname + EOS; } } else if ( node.isLiteral() ){ --- 313,319 ---- if ( URIid == null ) return res; dbid = URIid.getIntID(); ! res = new String(RDB_CODE_URI + RDB_CODE_REF + pfx + dbid); } else { ! res = RDB_CODE_URI + RDB_CODE_VALUE + pfx + qname + EOS; } } else if ( node.isLiteral() ){ *************** *** 325,329 **** String dtype = ll.getDatatypeURI(); String ld = litLangTypeToRDBString(lang,dtype); ! int encodeLen = RDBCodeLiteral.length() + 2 + ld.length() + EOS_LEN; boolean litIsLong = objectIsLong(encodeLen,lval); if ( litIsLong ) { --- 325,329 ---- String dtype = ll.getDatatypeURI(); String ld = litLangTypeToRDBString(lang,dtype); ! int encodeLen = RDB_CODE_LITERAL.length() + 2 + ld.length() + EOS_LEN; boolean litIsLong = objectIsLong(encodeLen,lval); if ( litIsLong ) { *************** *** 333,344 **** if ( lid == null ) return res; dbid = lid.getIntID(); ! res = new String(RDBCodeLiteral + RDBCodeRef + RDBCodeDelim + dbid); } else { ! res = new String(RDBCodeLiteral + RDBCodeValue + RDBCodeDelim + ld + lval + EOS); } } else if ( node.isBlank() ) { String bnid = node.getBlankNodeId().toString(); String delims = "::"; ! int encodeLen = RDBCodeBlank.length() + 1 + delims.length() + EOS_LEN; boolean BisLong = objectIsLong(encodeLen,bnid); if ( BisLong ) { --- 333,344 ---- if ( lid == null ) return res; dbid = lid.getIntID(); ! res = new String(RDB_CODE_LITERAL + RDB_CODE_REF + RDB_CODE_DELIM + dbid); } else { ! res = new String(RDB_CODE_LITERAL + RDB_CODE_VALUE + RDB_CODE_DELIM + ld + lval + EOS); } } else if ( node.isBlank() ) { String bnid = node.getBlankNodeId().toString(); String delims = "::"; ! int encodeLen = RDB_CODE_BLANK.length() + 1 + delims.length() + EOS_LEN; boolean BisLong = objectIsLong(encodeLen,bnid); if ( BisLong ) { *************** *** 348,354 **** if ( URIid == null ) return res; dbid = URIid.getIntID(); ! res = new String(RDBCodeBlank + RDBCodeRef + delims + dbid); } else { ! res = new String(RDBCodeBlank + RDBCodeValue + delims + bnid + EOS); } --- 348,354 ---- if ( URIid == null ) return res; dbid = URIid.getIntID(); ! res = new String(RDB_CODE_BLANK + RDB_CODE_REF + delims + dbid); } else { ! res = new String(RDB_CODE_BLANK + RDB_CODE_VALUE + delims + bnid + EOS); } *************** *** 358,364 **** if ( (len + 3 + EOS_LEN) > LONG_OBJECT_LENGTH ) throw new JenaException ("Variable name too long: " + name ); ! res = RDBCodeVariable + RDBCodeValue + RDBCodeDelim + name + EOS; } else if ( node.equals(Node.ANY) ) { ! res = RDBCodeANY + RDBCodeValue + RDBCodeDelim; } else { throw new RDFRDBException ("Expected Concrete Node, got " + node.toString() ); --- 358,364 ---- if ( (len + 3 + EOS_LEN) > LONG_OBJECT_LENGTH ) throw new JenaException ("Variable name too long: " + name ); ! res = RDB_CODE_VARIABLE + RDB_CODE_VALUE + RDB_CODE_DELIM + name + EOS; } else if ( node.equals(Node.ANY) ) { ! res = RDB_CODE_ANY + RDB_CODE_VALUE + RDB_CODE_DELIM; } else { throw new RDFRDBException ("Expected Concrete Node, got " + node.toString() ); *************** *** 379,384 **** String nodeType = RDBString.substring(0,1); String valType = RDBString.substring(1,2); ! if ( (!(valType.equals(RDBCodeRef) || valType.equals(RDBCodeValue))) || ! (RDBString.charAt(2) != RDBCodeDelimChar) ) throw new RDFRDBException("Bad RDBString Header: " + RDBString); --- 379,384 ---- String nodeType = RDBString.substring(0,1); String valType = RDBString.substring(1,2); ! if ( (!(valType.equals(RDB_CODE_REF) || valType.equals(RDB_CODE_VALUE))) || ! (RDBString.charAt(2) != RDB_CODE_DELIM_CHAR) ) throw new RDFRDBException("Bad RDBString Header: " + RDBString); *************** *** 386,390 **** int npos; ! if ( nodeType.equals(RDBCodeURI) ) { ParseInt pi = new ParseInt(pos); String prefix = ""; --- 386,390 ---- int npos; ! if ( nodeType.equals(RDB_CODE_URI) ) { ParseInt pi = new ParseInt(pos); String prefix = ""; *************** *** 399,403 **** pos = pi.pos + 1; String qname; ! if ( valType.equals(RDBCodeRef) ) { qname = IDtoURI(RDBString.substring(pos)); if ( qname == null ) --- 399,403 ---- pos = pi.pos + 1; String qname; ! if ( valType.equals(RDB_CODE_REF) ) { qname = IDtoURI(RDBString.substring(pos)); if ( qname == null ) *************** *** 408,415 **** res = Node.createURI(prefix + qname); ! } else if ( nodeType.equals(RDBCodeLiteral) ) { ParseInt pi = new ParseInt(pos); String litString = null; ! if ( valType.equals(RDBCodeRef) ) { RDBStringParseInt(RDBString,pi,true); if ( pi.val != null ) --- 408,415 ---- res = Node.createURI(prefix + qname); ! } else if ( nodeType.equals(RDB_CODE_LITERAL) ) { ParseInt pi = new ParseInt(pos); String litString = null; ! if ( valType.equals(RDB_CODE_REF) ) { RDBStringParseInt(RDBString,pi,true); if ( pi.val != null ) *************** *** 451,457 **** res = Node.createLiteral(llabel); ! } else if ( nodeType.equals(RDBCodeBlank) ) { String bstr = null; ! if ( valType.equals(RDBCodeValue) ) { bstr = RDBString.substring(4,len-EOS_LEN); } else { --- 451,457 ---- res = Node.createLiteral(llabel); ! } else if ( nodeType.equals(RDB_CODE_BLANK) ) { String bstr = null; ! if ( valType.equals(RDB_CODE_VALUE) ) { bstr = RDBString.substring(4,len-EOS_LEN); } else { *************** *** 462,470 **** res = Node.createAnon( new AnonId (bstr) ); ! } else if ( nodeType.equals(RDBCodeVariable) ) { String vname = RDBString.substring(3,len-EOS_LEN); res = Node.createVariable(vname); ! } else if ( nodeType.equals(RDBCodeANY) ) { res = Node.ANY; --- 462,470 ---- res = Node.createAnon( new AnonId (bstr) ); ! } else if ( nodeType.equals(RDB_CODE_VARIABLE) ) { String vname = RDBString.substring(3,len-EOS_LEN); res = Node.createVariable(vname); ! } else if ( nodeType.equals(RDB_CODE_ANY) ) { res = Node.ANY; *************** *** 524,528 **** private void RDBStringParseInt ( String RDBString, ParseInt pi, boolean toEnd ) { ! int npos = toEnd ? RDBString.length() : RDBString.indexOf(RDBCodeDelimChar,pi.pos); if ( npos < 0 ) { throw new RDFRDBException("Bad RDB String: " + RDBString); --- 524,528 ---- private void RDBStringParseInt ( String RDBString, ParseInt pi, boolean toEnd ) { ! int npos = toEnd ? RDBString.length() : RDBString.indexOf(RDB_CODE_DELIM_CHAR,pi.pos); if ( npos < 0 ) { throw new RDFRDBException("Bad RDB String: " + RDBString); *************** *** 560,564 **** int avail; ! res.head = RDBCodePrefix + RDBCodeValue + RDBCodeDelim; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); --- 560,564 ---- int avail; ! res.head = RDB_CODE_PREFIX + RDB_CODE_VALUE + RDB_CODE_DELIM; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); *************** *** 581,587 **** */ public String litLangTypeToRDBString ( String lang, String dtype ) throws RDFRDBException { ! String res = RDBCodeDelim; ! res = ((lang == null) ? "" : Integer.toString(lang.length())) + RDBCodeDelim; ! res = res + ((dtype == null) ? "" : Integer.toString(dtype.length())) + RDBCodeDelim; res = res + (lang == null ? "" : lang) + (dtype == null ? "" : dtype); return res; --- 581,587 ---- */ public String litLangTypeToRDBString ( String lang, String dtype ) throws RDFRDBException { ! String res = RDB_CODE_DELIM; ! res = ((lang == null) ? "" : Integer.toString(lang.length())) + RDB_CODE_DELIM; ! res = res + ((dtype == null) ? "" : Integer.toString(dtype.length())) + RDB_CODE_DELIM; res = res + (lang == null ? "" : lang) + (dtype == null ? "" : dtype); return res; *************** *** 613,617 **** String langType = litLangTypeToRDBString(lang,dtype); ! res.head = RDBCodeLiteral + RDBCodeValue + RDBCodeDelim + langType; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); --- 613,617 ---- String langType = litLangTypeToRDBString(lang,dtype); ! res.head = RDB_CODE_LITERAL + RDB_CODE_VALUE + RDB_CODE_DELIM + langType; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); *************** *** 639,643 **** */ public DBIDInt getBlankID(String bstr, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject (bstr,RDBCodeBlank); return getLongObjectID(lobj, LONG_URI_TABLE, add); } --- 639,643 ---- */ public DBIDInt getBlankID(String bstr, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject (bstr,RDB_CODE_BLANK); return getLongObjectID(lobj, LONG_URI_TABLE, add); } *************** *** 647,651 **** */ public DBIDInt getURIID(String qname, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject (qname,RDBCodeURI); return getLongObjectID(lobj, LONG_URI_TABLE, add); } --- 647,651 ---- */ public DBIDInt getURIID(String qname, boolean add) throws RDFRDBException { ! RDBLongObject lobj = URIToLongObject (qname,RDB_CODE_URI); return getLongObjectID(lobj, LONG_URI_TABLE, add); } *************** *** 656,660 **** int avail; ! res.head = code + RDBCodeValue + RDBCodeDelim; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); --- 656,660 ---- int avail; ! res.head = code + RDB_CODE_VALUE + RDB_CODE_DELIM; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); *************** *** 764,767 **** --- 764,776 ---- /** + * @param table + * @return + */ + private int getInsertID(String table) { + // TODO Auto-generated method stub + return 0; + } + + /** * Return the prefix string that has the given prefix id. * @param prefixID - the dbid of the prefix. *************** *** 775,779 **** return (String) res; else ! return IDtoString ( prefixID, PREFIX_TABLE, RDBCodePrefix); } --- 784,788 ---- return (String) res; else ! return IDtoString ( prefixID, PREFIX_TABLE, RDB_CODE_PREFIX); } *************** *** 784,788 **** */ protected String IDtoBlank(String bnID) { ! return IDtoString(bnID, LONG_URI_TABLE, RDBCodeBlank); } /** --- 793,797 ---- */ protected String IDtoBlank(String bnID) { ! return IDtoString(bnID, LONG_URI_TABLE, RDB_CODE_BLANK); } /** *************** *** 792,796 **** */ protected String IDtoURI(String uriID) { ! return IDtoString(uriID, LONG_URI_TABLE, RDBCodeURI); } --- 801,805 ---- */ protected String IDtoURI(String uriID) { ! return IDtoString(uriID, LONG_URI_TABLE, RDB_CODE_URI); } *************** *** 801,805 **** */ protected String IDtoLiteral ( int litID ) { ! return IDtoString ( litID, LONG_LIT_TABLE, RDBCodeLiteral); } --- 810,814 ---- */ protected String IDtoLiteral ( int litID ) { ! return IDtoString ( litID, LONG_LIT_TABLE, RDB_CODE_LITERAL); } *************** *** 823,827 **** throw new RDFRDBException("Invalid Object ID: " + dbID); // debug check ! if ( !lobj.head.substring(0,3).equals(RDBcode + RDBCodeValue + RDBCodeDelim) ) throw new RDFRDBException("Malformed URI in Database: " + lobj.head); res = lobj.head.substring(3,lobj.head.length() - EOS_LEN); --- 832,836 ---- throw new RDFRDBException("Invalid Object ID: " + dbID); // debug check ! if ( !lobj.head.substring(0,3).equals(RDBcode + RDB_CODE_VALUE + RDB_CODE_DELIM) ) throw new RDFRDBException("Malformed URI in Database: " + lobj.head); res = lobj.head.substring(3,lobj.head.length() - EOS_LEN); |
|
From: Elmer G. <ega...@us...> - 2004-07-27 04:10:27
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2962/src/org/javaowl/editor/swing Modified Files: OntTreePagelet.java PropertyEditorPagelet.java Log Message: Fixed build. Index: OntTreePagelet.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/OntTreePagelet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OntTreePagelet.java 22 Jul 2004 18:28:38 -0000 1.2 --- OntTreePagelet.java 27 Jul 2004 04:10:18 -0000 1.3 *************** *** 31,35 **** import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeSelectionModel; - import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; --- 31,34 ---- Index: PropertyEditorPagelet.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/PropertyEditorPagelet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PropertyEditorPagelet.java 22 Jul 2004 02:47:41 -0000 1.3 --- PropertyEditorPagelet.java 27 Jul 2004 04:10:18 -0000 1.4 *************** *** 19,26 **** package org.javaowl.editor.swing; - import java.awt.event.ActionListener; - - import javax.swing.JPanel; - import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.rdf.model.Resource; --- 19,22 ---- |
|
From: Elmer G. <ega...@us...> - 2004-07-26 22:55:16
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22946/src/org/javaowl/models/prevalence Modified Files: PrevalentGraph.java StorageGraph.java Added Files: AddTripleCommand.java DeleteTripleCommand.java StorageUtil.java Log Message: Working in prevalence. Index: PrevalentGraph.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/PrevalentGraph.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrevalentGraph.java 22 Jul 2004 02:47:41 -0000 1.1 --- PrevalentGraph.java 26 Jul 2004 22:55:02 -0000 1.2 *************** *** 20,24 **** package org.javaowl.models.prevalence; ! public class PrevalentGraph { } --- 20,148 ---- package org.javaowl.models.prevalence; ! import java.io.IOException; ! ! import org.prevayler.implementation.SnapshotPrevayler; ! ! import com.hp.hpl.jena.graph.Graph; ! import com.hp.hpl.jena.graph.Triple; ! import com.hp.hpl.jena.graph.Node; ! import com.hp.hpl.jena.graph.TripleMatch; ! import com.hp.hpl.jena.graph.TransactionHandler; ! import com.hp.hpl.jena.graph.BulkUpdateHandler; ! import com.hp.hpl.jena.graph.Capabilities; ! import com.hp.hpl.jena.graph.GraphEventManager; ! import com.hp.hpl.jena.graph.Reifier; ! import com.hp.hpl.jena.graph.query.QueryHandler; ! import com.hp.hpl.jena.shared.PrefixMapping; ! import com.hp.hpl.jena.shared.AddDeniedException; ! import com.hp.hpl.jena.shared.DeleteDeniedException; ! import com.hp.hpl.jena.util.iterator.ExtendedIterator; ! ! public class PrevalentGraph implements Graph, Runnable{ ! ! private final SnapshotPrevayler prevayler; ! private final Graph storageGraph; ! ! public PrevalentGraph(String directory) throws IOException, ClassNotFoundException { ! prevayler = new SnapshotPrevayler(new StorageGraph(), directory); ! storageGraph = (StorageGraph) prevayler.system(); ! } ! ! public void run() { ! for (;;) { ! try { ! try { ! Thread.sleep(1000 * 60 * 60 * 24); ! } catch (InterruptedException ignore) { ! //Ignore ! } ! prevayler.takeSnapshot(); ! System.err.println("Snapshot taken at " + new java.util.Date() + "..."); ! } catch (IOException e) { ! e.printStackTrace(); ! } ! } ! } ! ! public boolean dependsOn(Graph other) { ! return storageGraph.dependsOn(other); ! } ! ! public QueryHandler queryHandler() { ! return storageGraph.queryHandler(); ! } ! ! public TransactionHandler getTransactionHandler() { ! return storageGraph.getTransactionHandler(); ! } ! ! public BulkUpdateHandler getBulkUpdateHandler() { ! return storageGraph.getBulkUpdateHandler(); ! } ! ! public Capabilities getCapabilities() { ! return storageGraph.getCapabilities(); ! } ! ! public GraphEventManager getEventManager() { ! return storageGraph.getEventManager(); ! } ! ! public Reifier getReifier() { ! return storageGraph.getReifier(); ! } ! ! public PrefixMapping getPrefixMapping() { ! return storageGraph.getPrefixMapping(); ! } ! ! public ExtendedIterator find(TripleMatch m) { ! return storageGraph.find(m); ! } ! ! public ExtendedIterator find(Node s, Node p, Node o) { ! return storageGraph.find(s, p, o); ! } ! ! public boolean isIsomorphicWith(Graph g) { ! return storageGraph.isIsomorphicWith(g); ! } ! ! public boolean contains(Node s, Node p, Node o) { ! return storageGraph.contains(s, p, o); ! } + public boolean contains(Triple t) { + return storageGraph.contains(t); + } + + public void close() { + storageGraph.close(); + } + + public boolean isEmpty() { + return storageGraph.isEmpty(); + } + + public int size() { + return storageGraph.size(); + } + + public void delete(Triple t) throws DeleteDeniedException { + try { + prevayler.executeCommand(new DeleteTripleCommand(t)); + } catch (Exception e) { + e.printStackTrace(); + throw new DeleteDeniedException(e.toString()); + } + } + + public void add(Triple t) throws AddDeniedException { + try { + prevayler.executeCommand(new AddTripleCommand(t)); + } catch (Exception e) { + e.printStackTrace(); + throw new AddDeniedException(e.toString()); + } + } } --- NEW FILE: StorageUtil.java --- /* (c) Copyright 2003, Hewlett-Packard Development Company, LP [See end of file] */ package org.javaowl.models.prevalence; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.zip.CRC32; import com.hp.hpl.jena.datatypes.RDFDatatype; import com.hp.hpl.jena.datatypes.TypeMapper; import com.hp.hpl.jena.db.GraphRDB; import com.hp.hpl.jena.db.IDBConnection; import com.hp.hpl.jena.db.RDFRDBException; import com.hp.hpl.jena.db.impl.DBIDInt; import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Node_Literal; import com.hp.hpl.jena.graph.Node_URI; import com.hp.hpl.jena.graph.Node_Variable; import com.hp.hpl.jena.graph.impl.LiteralLabel; import com.hp.hpl.jena.rdf.model.AnonId; import com.hp.hpl.jena.shared.*; import com.hp.hpl.jena.vocabulary.RDF; import org.apache.xerces.util.XMLChar; public class StorageUtil { /** true if the database engine will trim trailing spaces in strings. to * prevent this, append EOS to strings that should not be trimmed. */ protected boolean STRINGS_TRIMMED; /** EOS is appended to most RDB strings to deal with string trimming. if * STRINGS_TRIMMED is false, EOS is null. otherwise, EOS is EOS_CHAR. * EOS_LEN is the length of EOS (0 or 1). */ protected String EOS = ""; protected char EOS_CHAR = ':'; protected int EOS_LEN = 0; /** the quote character used to delimit characters and strings. */ protected char QUOTE_CHAR = '\"'; /** * Indicates whether search pattern used to select system objects by name should * be upper-case. */ protected boolean DB_NAMES_TO_UPPER = false; /** true if URI's are to be compressed by storing prefixes (an approximation * of a namespace) in the JENA_PREFIX table. note that "short" prefixes are * not stored, i.e., the prefix length not more than URI_COMPRESS_LENGTH. */ protected boolean URI_COMPRESS; /** if URI_COMPRESS is true, compress prefixes that are longer than this.*/ protected int URI_COMPRESS_LENGTH = 100; /** The maximum size of an object that can be stored in a Statement table */ protected int LONG_OBJECT_LENGTH; /** The maximum possible value for LONG_OBJECT_LENGTH (db-dependent) */ protected int LONG_OBJECT_LENGTH_MAX; /** The SQL type to use for storing ids (compatible with wrapDBID) */ protected String ID_SQL_TYPE; /** Set to true if the insert operations already check for duplications */ protected boolean SKIP_DUPLICATE_CHECK; /** Set to true if IDs are allocated prior to insert */ protected boolean PRE_ALLOCATE_ID; /** The name of the sql definition file for this database/layout combo */ protected String SQL_FILE; /** The name of the sql definition file for this database/layout combo */ protected String DEFAULT_SQL_FILE = "etc/generic_generic.sql"; // ======================================================================= // Common variables // ======================================================================= /** * Holds prefix for names of Jena database tables. */ protected String TABLE_NAME_PREFIX = "jena_"; /** * Holds maximum length of table and index names in database. */ protected int TABLE_NAME_LENGTH_MAX; /** * Holds the length of the longest jena table or index name. * This is really a hack and should be better architected. * The currently known longest possible name is: * <prefix>GnTm_StmtXSP where prefix is the table * name prefix (which isn't counted here), n is the * graph identifier, m is the table number within that * graph and XSP refers to the subject-predicate index. * If we assume n and m might be two digits, we get 14. */ protected int JENA_LONGEST_TABLE_NAME_LENGTH = 14; /** Set to true to enable cache of pre-prepared statements */ protected boolean CACHE_PREPARED_STATEMENTS = true; /** The name of the layout type this driver supports */ protected String LAYOUT_TYPE = "TripleStore"; /** Default name of the table that holds system property graph asserted statements **/ protected String SYSTEM_STMT_TABLE; /** Name of the long literal table **/ protected String LONG_LIT_TABLE; /** Name of the long URI table **/ protected String LONG_URI_TABLE; /** Name of the prefix table **/ protected String PREFIX_TABLE; /** Name of the graph table **/ protected String GRAPH_TABLE; /** If not null, newly-created graphs share tables with the identified graph **/ protected String STORE_WITH_MODEL = null; /** Name of the graph holding default properties (the one's that a newly-created * graph will have by default **/ protected final String DEFAULT_PROPS = "JENA_DEFAULT_GRAPH_PROPERTIES"; /** Unique numeric identifier of the graph holding default properties **/ protected final int DEFAULT_ID = 0; /** Driver version number */ protected final String VERSION = "2.0alpha"; /** Database layout version */ protected String LAYOUT_VERSION = "2.0"; // ======================================================================= // Instance variables // ======================================================================= /** * Instance of SQLCache used by Driver for hard-coded db commands */ protected SQLCache m_sql = null; /** Cache a reference to the system property graph (java) **/ protected SpecializedGraph m_sysProperties = null; protected IDBConnection m_dbcon = null; protected LRUCache prefixCache = null; public static final int PREFIX_CACHE_SIZE = 50; /* * The following routines are responsible for encoding nodes * as database structures. For each node type stored (currently, * literals, URI, blank), there are two possible encodings * depending on the node size. Small nodes may be stored * within a statement table. If the node is long (will not * fit within the statement table), it is be stored in a * separate table for that node type. * * In addition, for resources (URI, blank nodes), the URI * may be optionally compressed. Below, the possibilites * are enumerated. * * Literal Encoding in Statement Tables * Short Literal: Lv:[langLen]:[datatypeLen]:[langString][datatypeString]value[:] * Long Literal: Lr:dbid * Literal Encoding in Long Literal Table * Literal: Lv:[langLen]:[datatypeLen]:[langString][datatypeString]head[:] hash tail * * Comments: * L indicates a literal * v indicates a value * r indicates a reference to another table * : is used as a delimiter. note that MySQL trims trailing white space for * certain VARCHAR columns so an extra delimiter is appended when necessary * for those columns. it is not required for dbid, however. * dbid references the long literal table * langLen is the length of the language identifier for the literal * langString is the language identifier * datatypeLen is the length of the datatype for the literal * datatypeString is the datatype for the literal * value is the lexical form of the string * head is a prefix of value that can be indexed * hash is the CRC32 hash value for the tail * tail is the remainder of the value that cannot be indexed * * * * URI Encoding in Statement Tables * Short URI: Uv:[pfx_dbid]:URI[:] * Long URI: Ur:[pfx_dbid]:dbid * URI Encoding in Long URI Table * URI: Uv:head[:] hash tail * * Comments: * U indicates a URI * pfx_dbid references the prefix table. if the prefix is too * short (i.e., the length of the prefix is less than * URI_COMPRESS_LENGTH), the URI is not compressed and * pfx_dbid is null. * URI is the complete URI * other notation same as for literal encoding * * Blank Node Encoding in Statement Tables * Short URI: Bv:[pfx_dbid]:bnid[:] * Long URI: Br:[pfx_dbid]:dbid * Blank Encoding in Long URI Table * URI: Bv:head[:] hash tail * * Comments: * B indicates a blank node * bnid is the blank node identifier * other notation same as above * Note: currently, blank nodes are always stored uncompressed (pfix_dbid is null). * * Variable Node Encoding in Statement Tables * Variable Node: Vv:name * * Comments: * V indicates a variable node * v indicates a value * name is the variable name * Note: the length must be less than LONG_OBJECT_LENGTH * * ANY Node Encoding in Statement Tables * Variable Node: Av: * * Prefix Encoding in Prefix Table * Prefix: Pv:val[:] [hash] [tail] * * Comments: * P indicates a prefix * other notation same as above * hash and tail are only required for long prefixes. * */ protected static String RDBCodeURI = "U"; protected static String RDBCodeBlank = "B"; protected static String RDBCodeLiteral = "L"; protected static String RDBCodeVariable = "V"; protected static String RDBCodeANY = "A"; protected static String RDBCodePrefix = "P"; protected static String RDBCodeValue = "v"; protected static String RDBCodeRef = "r"; protected static String RDBCodeDelim = ":"; protected static char RDBCodeDelimChar = ':'; protected static String RDBCodeInvalid = "X"; /** * Convert a node to a string to be stored in a statement table. * @param Node The node to convert to a string. Must be a concrete node. * @param addIfLong If the node is a long object and is not in the database, add it. * @return the string or null if failure. */ public String nodeToRDBString ( Node node, boolean addIfLong ) throws RDFRDBException { String res = null; if ( node.isURI() ) { String uri = new String(((Node_URI) node).getURI()); if ( uri.startsWith(RDBCodeURI) ) { throw new RDFRDBException ("URI Node looks like a blank node: " + uri ); } // TODO: need to write special version of splitNamespace for rdb. // or else, need a guarantee that splitNamespace never changes. // the problem is that if the splitNamespace algorithm changes, // then URI's may be encoded differently. so, URI's in existing // databases may become inaccessible. int pos = 0; boolean noCompress; String pfx; String qname; if ( URI_COMPRESS == true ) { pos = dbSplitNamespace(uri); noCompress = (pos == uri.length()) || (pos <= URI_COMPRESS_LENGTH); } else noCompress = true; if ( noCompress ) { pfx = RDBCodeDelim + RDBCodeDelim; qname = uri; } else { // see if it's cached DBIDInt pfxid = URItoPrefix(uri, pos, addIfLong); if ( pfxid == null ) return res; pfx = RDBCodeDelim + ((DBIDInt) pfxid).getIntID() + RDBCodeDelim; qname = uri.substring(pos); } int encodeLen = RDBCodeURI.length() + 1 + pfx.length() + EOS_LEN; boolean URIisLong = objectIsLong(encodeLen,qname); if ( URIisLong ) { int dbid; // belongs in URI table DBIDInt URIid = getURIID(qname,addIfLong); if ( URIid == null ) return res; dbid = URIid.getIntID(); res = new String(RDBCodeURI + RDBCodeRef + pfx + dbid); } else { res = RDBCodeURI + RDBCodeValue + pfx + qname + EOS; } } else if ( node.isLiteral() ){ // TODO: may need to encode literal value when datatype is not a string. Node_Literal litNode = (Node_Literal) node; LiteralLabel ll = litNode.getLiteral(); String lval = ll.getLexicalForm(); String lang = ll.language(); String dtype = ll.getDatatypeURI(); String ld = litLangTypeToRDBString(lang,dtype); int encodeLen = RDBCodeLiteral.length() + 2 + ld.length() + EOS_LEN; boolean litIsLong = objectIsLong(encodeLen,lval); if ( litIsLong ) { int dbid; // belongs in literal table DBIDInt lid = getLiteralID(litNode,addIfLong); if ( lid == null ) return res; dbid = lid.getIntID(); res = new String(RDBCodeLiteral + RDBCodeRef + RDBCodeDelim + dbid); } else { res = new String(RDBCodeLiteral + RDBCodeValue + RDBCodeDelim + ld + lval + EOS); } } else if ( node.isBlank() ) { String bnid = node.getBlankNodeId().toString(); String delims = "::"; int encodeLen = RDBCodeBlank.length() + 1 + delims.length() + EOS_LEN; boolean BisLong = objectIsLong(encodeLen,bnid); if ( BisLong ) { int dbid; // belongs in URI table DBIDInt URIid = getBlankID(bnid,addIfLong); if ( URIid == null ) return res; dbid = URIid.getIntID(); res = new String(RDBCodeBlank + RDBCodeRef + delims + dbid); } else { res = new String(RDBCodeBlank + RDBCodeValue + delims + bnid + EOS); } } else if ( node.isVariable() ){ String name = ((Node_Variable)node).getName(); int len = name.length(); if ( (len + 3 + EOS_LEN) > LONG_OBJECT_LENGTH ) throw new JenaException ("Variable name too long: " + name ); res = RDBCodeVariable + RDBCodeValue + RDBCodeDelim + name + EOS; } else if ( node.equals(Node.ANY) ) { res = RDBCodeANY + RDBCodeValue + RDBCodeDelim; } else { throw new RDFRDBException ("Expected Concrete Node, got " + node.toString() ); } return res; } /** * Convert an RDB string to the node that it encodes. Return null if failure. * @param RDBstring The string to convert to a node. * @return The node or null if failure. */ public Node RDBStringToNode ( String RDBString ) throws RDFRDBException { Node res = null; int len = RDBString.length(); if ( len < 3 ) throw new RDFRDBException("Bad RDBString Header: " + RDBString); String nodeType = RDBString.substring(0,1); String valType = RDBString.substring(1,2); if ( (!(valType.equals(RDBCodeRef) || valType.equals(RDBCodeValue))) || (RDBString.charAt(2) != RDBCodeDelimChar) ) throw new RDFRDBException("Bad RDBString Header: " + RDBString); int pos = 3; int npos; if ( nodeType.equals(RDBCodeURI) ) { ParseInt pi = new ParseInt(pos); String prefix = ""; RDBStringParseInt(RDBString, pi, false); if ( pi.val != null ) { if ( URI_COMPRESS == false ) throw new RDFRDBException("Bad URI: Prefix Compression Disabled: " + RDBString); prefix = IDtoPrefix(pi.val.intValue()); if ( prefix == null ) throw new RDFRDBException("Bad URI Prefix: " + RDBString); } pos = pi.pos + 1; String qname; if ( valType.equals(RDBCodeRef) ) { qname = IDtoURI(RDBString.substring(pos)); if ( qname == null ) throw new RDFRDBException("Bad URI: " + RDBString); } else qname = RDBString.substring(pos,len - EOS_LEN); res = Node.createURI(prefix + qname); } else if ( nodeType.equals(RDBCodeLiteral) ) { ParseInt pi = new ParseInt(pos); String litString = null; if ( valType.equals(RDBCodeRef) ) { RDBStringParseInt(RDBString,pi,true); if ( pi.val != null ) litString = IDtoLiteral(pi.val.intValue()); if ( litString == null ) throw new RDFRDBException("Bad Literal Reference: " + RDBString); } else litString = RDBString.substring(pos,len-EOS_LEN); len = litString.length(); String lang; String dtype; int langLen = 0; int dtypeLen = 0; LiteralLabel llabel; pi.pos = 0; RDBStringParseInt(litString, pi, false); if ( pi.val == null ) langLen = 0; else langLen = pi.val.intValue(); pi.pos = pi.pos + 1; RDBStringParseInt(litString, pi, false); if ( pi.val == null ) dtypeLen = 0; else dtypeLen = pi.val.intValue(); pos = pi.pos + 1; if ( (pos + langLen + dtypeLen) > len ) throw new RDFRDBException("Malformed Literal: " + litString); lang = litString.substring(pos,pos+langLen); pos = pos + langLen; dtype = litString.substring(pos,pos+dtypeLen); pos = pos + dtypeLen; String val = litString.substring(pos); if ( (dtype == null) || (dtype.equals("")) ) { llabel = new LiteralLabel(val, lang == null ? "" : lang); } else { RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(dtype); llabel = new LiteralLabel(val, lang == null ? "" : lang, dt); } res = Node.createLiteral(llabel); } else if ( nodeType.equals(RDBCodeBlank) ) { String bstr = null; if ( valType.equals(RDBCodeValue) ) { bstr = RDBString.substring(4,len-EOS_LEN); } else { bstr = IDtoBlank(RDBString.substring(4)); if ( bstr == null ) throw new RDFRDBException("Bad URI: " + RDBString); } res = Node.createAnon( new AnonId (bstr) ); } else if ( nodeType.equals(RDBCodeVariable) ) { String vname = RDBString.substring(3,len-EOS_LEN); res = Node.createVariable(vname); } else if ( nodeType.equals(RDBCodeANY) ) { res = Node.ANY; } else throw new RDFRDBException ("Invalid RDBString Prefix, " + RDBString ); return res; } /** This is cuurently a copy of Util.splitNamespace. It was * copied rather than used directly for two reasons. 1) in the * future it may be desirable to use a different split algorithm * for persistence. 2) the util version could change at any time, * which would render existing databases inaccessible. having a * copy allows the db version to evolve in a controlled way. * * Given an absolute URI, determine the split point between the namespace part * and the localname part. * If there is no valid localname part then the length of the * string is returned. * The algorithm tries to find the longest NCName at the end * of the uri, not immediately preceeded by the first colon * in the string. * @param uri * @return the index of the first character of the localname */ public static int dbSplitNamespace(String uri) { char ch; int lg = uri.length(); if (lg == 0) return 0; int j; int i; for (i = lg - 1; i >= 1; i--) { ch = uri.charAt(i); if (!XMLChar.isNCName(ch)) break; } for (j = i + 1; j < lg; j++) { ch = uri.charAt(j); if (XMLChar.isNCNameStart(ch)) { if (uri.charAt(j - 1) == ':' && uri.lastIndexOf(':', j - 2) == -1) continue; // split "mailto:me" as "mailto:m" and "e" ! else break; } } return j; } class ParseInt { int pos; Integer val; ParseInt(int p) {pos = p;} } private void RDBStringParseInt ( String RDBString, ParseInt pi, boolean toEnd ) { int npos = toEnd ? RDBString.length() : RDBString.indexOf(RDBCodeDelimChar,pi.pos); if ( npos < 0 ) { throw new RDFRDBException("Bad RDB String: " + RDBString); } String intStr = RDBString.substring(pi.pos,npos); pi.pos = npos; if ( intStr.equals("") ) pi.val = null; else try { pi.val = new Integer(intStr); } catch (NumberFormatException e1) { throw new RDFRDBException("Bad RDB String: " + RDBString); } return; } private DBIDInt URItoPrefix ( String uri, int pos, boolean add ) { DBIDInt res; Object key = prefixCache.getByValue(uri.substring(0,pos)); if ( key == null ) { RDBLongObject lobj = PrefixToLongObject(uri,pos); res = getLongObjectID(lobj, PREFIX_TABLE, add); if ( res != null ) prefixCache.put(res,uri.substring(0,pos)); } else res = (DBIDInt) key; return res; } private RDBLongObject PrefixToLongObject ( String prefix, int split ) { RDBLongObject res = new RDBLongObject(); int headLen; int avail; res.head = RDBCodePrefix + RDBCodeValue + RDBCodeDelim; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); if ( split > avail ) { res.head = res.head + prefix.substring(0,avail); res.tail = prefix.substring(avail,split); res.hash = stringToHash(res.tail); } else { res.head = res.head + prefix.substring(0,split); res.tail = ""; } res.head = res.head + EOS; return res; } /** * Encode a literal node's lang and datatype as a string of the * form ":[langLen]:[datatypeLen]:[langString][dataTypeString]" * @return the string. */ public String litLangTypeToRDBString ( String lang, String dtype ) throws RDFRDBException { String res = RDBCodeDelim; res = ((lang == null) ? "" : Integer.toString(lang.length())) + RDBCodeDelim; res = res + ((dtype == null) ? "" : Integer.toString(dtype.length())) + RDBCodeDelim; res = res + (lang == null ? "" : lang) + (dtype == null ? "" : dtype); return res; } /** * Check if an object is long, i.e., it exceeds the length * limit for storing in a statement table. * @return true if literal is long, else false. */ protected boolean objectIsLong ( int encodingLen, String objAsString ) { return ( (encodingLen + objAsString.length()) > LONG_OBJECT_LENGTH); } class RDBLongObject { String head; /* prefix of long object that can be indexed */ long hash; /* hash encoding of tail */ String tail; /* remainder of long object */ } protected RDBLongObject literalToLongObject ( Node_Literal node ) { RDBLongObject res = new RDBLongObject(); int headLen; int avail; LiteralLabel l = node.getLiteral(); String lang = l.language(); String dtype = l.getDatatypeURI(); String val = l.getLexicalForm(); String langType = litLangTypeToRDBString(lang,dtype); res.head = RDBCodeLiteral + RDBCodeValue + RDBCodeDelim + langType; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); if ( val.length() > avail ) { res.head = res.head + val.substring(0,avail); res.tail = val.substring(avail); res.hash = stringToHash(res.tail); } else { res.head = res.head + val; res.tail = ""; } res.head = res.head + EOS; return res; } protected long stringToHash ( String str ) { CRC32 checksum = new CRC32(); checksum.update(str.getBytes()); return checksum.getValue(); } /** * Return the database ID for the URI, if it exists */ public DBIDInt getBlankID(String bstr, boolean add) throws RDFRDBException { RDBLongObject lobj = URIToLongObject (bstr,RDBCodeBlank); return getLongObjectID(lobj, LONG_URI_TABLE, add); } /** * Return the database ID for the URI, if it exists */ public DBIDInt getURIID(String qname, boolean add) throws RDFRDBException { RDBLongObject lobj = URIToLongObject (qname,RDBCodeURI); return getLongObjectID(lobj, LONG_URI_TABLE, add); } protected RDBLongObject URIToLongObject ( String qname, String code ) { RDBLongObject res = new RDBLongObject(); int headLen; int avail; res.head = code + RDBCodeValue + RDBCodeDelim; headLen = res.head.length(); avail = INDEX_KEY_LENGTH - (headLen + EOS_LEN); if ( qname.length() > avail ) { res.head = res.head + qname.substring(0,avail); res.tail = qname.substring(avail); res.hash = stringToHash(res.tail); } else { res.head = res.head + qname; res.tail = ""; } res.head = res.head + EOS; return res; } /** * Return the database ID for the literal, if it exists */ public DBIDInt getLiteralID(Node_Literal lnode, boolean add) throws RDFRDBException { RDBLongObject lobj = literalToLongObject (lnode); return getLongObjectID(lobj, LONG_LIT_TABLE, add); } public DBIDInt getLongObjectID(RDBLongObject lobj, String table, boolean add) throws RDFRDBException { try { String opName = "getLongObjectID"; if ( lobj.tail.length() > 0 ) opName += "withChkSum"; PreparedStatement ps = m_sql.getPreparedSQLStatement(opName, table); ps.setString(1,lobj.head); if ( lobj.tail.length() > 0 ) ps.setLong(2, lobj.hash); ResultSet rs = ps.executeQuery(); DBIDInt result = null; if (rs.next()) { result = wrapDBID(rs.getObject(1)); } else { if ( add ) result = addRDBLongObject(lobj, table); } m_sql.returnPreparedSQLStatement(ps, opName); return result; } catch (SQLException e1) { // /* DEBUG */ System.out.println("Literal truncation (" + l.toString().length() + ") " + l.toString().substring(0, 150)); throw new RDFRDBException("Failed to find literal", e1); } } /** * Insert a long object into the database. * This assumes the object is not already in the database. * @return the db index of the added literal */ public DBIDInt addRDBLongObject(RDBLongObject lobj, String table) throws RDFRDBException { try { int argi = 1; String opname = "insertLongObject"; PreparedStatement ps = m_sql.getPreparedSQLStatement(opname, table); int dbid = 0; // init only needed to satisy java compiler if ( PRE_ALLOCATE_ID ) { dbid = getInsertID(table); ps.setInt(argi++,dbid); } ps.setString(argi++, lobj.head); if ( lobj.tail.length() > 0 ) { ps.setLong(argi++, lobj.hash); ps.setString(argi++, lobj.tail); } else { ps.setNull(argi++,java.sql.Types.BIGINT); ps.setNull(argi++,java.sql.Types.VARCHAR); } /* if (isBlob || (len == 0) ) { // First convert the literal to a UTF-16 encoded byte array // (this wouldn't be needed for jdbc 2.0 drivers but not all db's have them) byte[] temp = lit.getBytes("UTF-8"); int lenb = temp.length; //System.out.println("utf-16 len = " + lenb); byte[] litData = new byte[lenb + 4]; litData[0] = (byte)(lenb & 0xff); litData[1] = (byte)((lenb >> 8) & 0xff); litData[2] = (byte)((lenb >> 16) & 0xff); litData[3] = (byte)((lenb >> 24) & 0xff); System.arraycopy(temp, 0, litData, 4, lenb); // Oracle has its own way to insert Blobs if (isBlob && m_driver.getDatabaseType().equalsIgnoreCase("Oracle")) { //TODO fix to use Blob // For now, we do not support Blobs under Oracle throw new RDFRDBException("Oracle driver does not currently support large literals."); } else { ps.setBinaryStream(argi++, new ByteArrayInputStream(litData), litData.length); } } */ ps.executeUpdate(); //m_sql.returnPreparedSQLStatement(ps,opname); if ( !PRE_ALLOCATE_ID ) dbid = getInsertID(table); return wrapDBID(new Integer(dbid)); } catch (Exception e1) { /* DEBUG */ System.out.println("Problem on long object (l=" + lobj.head + ") " + e1 ); // System.out.println("ID is: " + id); throw new RDFRDBException("Failed to add long object ", e1); } } /** * Return the prefix string that has the given prefix id. * @param prefixID - the dbid of the prefix. * @return the prefix string or null if it does not exist. */ protected String IDtoPrefix ( int prefixID ) { // check cache DBIDInt dbid = new DBIDInt(prefixID); Object res = prefixCache.get(dbid); if ( res != null) return (String) res; else return IDtoString ( prefixID, PREFIX_TABLE, RDBCodePrefix); } /** * Return the Blank node string that has the given database id. * @param bnID - the dbid of the blank node, as a string. * @return the Blank node string or null if it does not exist. */ protected String IDtoBlank(String bnID) { return IDtoString(bnID, LONG_URI_TABLE, RDBCodeBlank); } /** * Return the URI string that has the given database id. * @param uriID - the dbid of the uri, as a string. * @return the uri string or null if it does not exist. */ protected String IDtoURI(String uriID) { return IDtoString(uriID, LONG_URI_TABLE, RDBCodeURI); } /** * Return the long literal string that has the given database id. * @param litID - the dbid of the literal.. * @return the long literal string or null if it does not exist. */ protected String IDtoLiteral ( int litID ) { return IDtoString ( litID, LONG_LIT_TABLE, RDBCodeLiteral); } protected String IDtoString ( String dbidAsString, String table, String RDBcode ) { int dbID; String res = null; try { dbID = Integer.parseInt(dbidAsString); } catch (NumberFormatException e1) { throw new RDFRDBException("Invalid Object ID: " + dbidAsString); } return IDtoString (dbID, table, RDBcode); } protected String IDtoString ( int dbID, String table, String RDBcode ) { String res = null; RDBLongObject lobj = IDtoLongObject(dbID, table); if ( lobj == null ) throw new RDFRDBException("Invalid Object ID: " + dbID); // debug check if ( !lobj.head.substring(0,3).equals(RDBcode + RDBCodeValue + RDBCodeDelim) ) throw new RDFRDBException("Malformed URI in Database: " + lobj.head); res = lobj.head.substring(3,lobj.head.length() - EOS_LEN); if ( lobj.tail != null ) res = res + lobj.tail; return res; } protected RDBLongObject IDtoLongObject ( int dbid, String table ) { RDBLongObject res = null; try { String opName = "getLongObject"; PreparedStatement ps = m_sql.getPreparedSQLStatement(opName, table); ps.setInt(1,dbid); ResultSet rs = ps.executeQuery(); if (rs.next()) { res = new RDBLongObject(); res.head = rs.getString(1); res.tail = rs.getString(2); } m_sql.returnPreparedSQLStatement(ps,opName); } catch (SQLException e1) { // /* DEBUG */ System.out.println("Literal truncation (" + l.toString().length() + ") " + l.toString().substring(0, 150)); throw new RDFRDBException("Failed to find literal", e1); } return res; } protected RDBLongObject IDtoLongObject ( String idAsString, String table ) { RDBLongObject res = null; int dbid; try { dbid = Integer.parseInt(idAsString); } catch (NumberFormatException e1) { throw new RDFRDBException("Invalid Object ID: " + idAsString); } return IDtoLongObject(dbid,table); } /** * Convert the raw SQL object used to store a database identifier into a java object * which meets the DBIDInt interface. */ public DBIDInt wrapDBID(Object id) throws RDFRDBException { if (id instanceof Number) { return new DBIDInt(((Number)id).intValue()); } else if (id == null) { return null; } else { throw new RDFRDBException("Unexpected DB identifier type: " + id); //return null; } } } /* * (c) Copyright 2000, 2001 Hewlett-Packard Development Company, LP * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ Index: StorageGraph.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/models/prevalence/StorageGraph.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StorageGraph.java 22 Jul 2004 02:47:42 -0000 1.1 --- StorageGraph.java 26 Jul 2004 22:55:02 -0000 1.2 *************** *** 20,24 **** package org.javaowl.models.prevalence; ! public class StorageGraph { } --- 20,99 ---- package org.javaowl.models.prevalence; ! import com.hp.hpl.jena.graph.Graph; ! import com.hp.hpl.jena.graph.Triple; ! import com.hp.hpl.jena.graph.Node; ! import com.hp.hpl.jena.graph.TripleMatch; ! import com.hp.hpl.jena.graph.TransactionHandler; ! import com.hp.hpl.jena.graph.BulkUpdateHandler; ! import com.hp.hpl.jena.graph.Capabilities; ! import com.hp.hpl.jena.graph.GraphEventManager; ! import com.hp.hpl.jena.graph.Reifier; ! import com.hp.hpl.jena.graph.query.QueryHandler; ! import com.hp.hpl.jena.mem.GraphMem; ! import com.hp.hpl.jena.shared.ReificationStyle; ! import com.hp.hpl.jena.shared.PrefixMapping; ! import com.hp.hpl.jena.shared.AddDeniedException; ! import com.hp.hpl.jena.shared.DeleteDeniedException; ! import com.hp.hpl.jena.util.iterator.ExtendedIterator; + import org.prevayler.implementation.AbstractPrevalentSystem; + + class StorageGraph extends AbstractPrevalentSystem implements Graph { + + private final Graph graph = new GraphMem(ReificationStyle.Standard); + + public boolean dependsOn(Graph other) { + return graph.dependsOn(other); + } + public QueryHandler queryHandler() { + return graph.queryHandler(); + } + public TransactionHandler getTransactionHandler() { + return graph.getTransactionHandler(); + } + public BulkUpdateHandler getBulkUpdateHandler() { + return graph.getBulkUpdateHandler(); + } + public Capabilities getCapabilities() { + return graph.getCapabilities(); + } + public GraphEventManager getEventManager() { + return graph.getEventManager(); + } + public Reifier getReifier() { + return graph.getReifier(); + } + public PrefixMapping getPrefixMapping() { + return graph.getPrefixMapping(); + } + public ExtendedIterator find(TripleMatch m) { + return graph.find(m); + } + public ExtendedIterator find(Node s, Node p, Node o) { + return graph.find(s, p, o); + } + public boolean isIsomorphicWith(Graph g) { + return graph.isIsomorphicWith(g); + } + public boolean contains(Node s, Node p, Node o) { + return graph.contains(s, p, o); + } + public boolean contains(Triple t) { + return graph.contains(t); + } + public void close() { + } + public boolean isEmpty() { + return graph.isEmpty(); + } + public int size() { + return graph.size(); + } + + public void delete(Triple t) throws DeleteDeniedException { + graph.delete(t); + } + public void add(Triple t) throws AddDeniedException { + graph.add(t); + } } --- NEW FILE: DeleteTripleCommand.java --- /* * DeleteTripleCommand.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer * Garduno Hernandez * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.models.prevalence; import com.hp.hpl.jena.graph.Triple; import org.prevayler.Command; import org.prevayler.PrevalentSystem; import java.io.Serializable; class DeleteTripleCommand implements Command { private final Triple triple; DeleteTripleCommand(Triple triple) { this.triple = triple; } public Serializable execute(PrevalentSystem system) throws Exception { ((StorageGraph) system).delete(triple); return null; } } --- NEW FILE: AddTripleCommand.java --- /* * AddTripleCommand.java Copyright (C) 2004 Gerardo Horvilleur Martinez, Elmer * Garduno Hernandez * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.javaowl.models.prevalence; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.util.PrintUtil; import org.prevayler.Command; import org.prevayler.PrevalentSystem; import java.io.Serializable; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.IOException; class AddTripleCommand implements Command { private final transient Triple triple; AddTripleCommand(Triple triple) { this.triple = triple; } public Serializable execute(PrevalentSystem system) throws Exception { ((StorageGraph) system).add(triple); return null; } private void writeObject(ObjectOutputStream out) throws IOException { //String subject = triple.getSubject().equals(Node.NULL) ? null : // m_driver.nodeToRDBString(t.getSubject(),true); //String predicate = triple.getPredicate().equals(Node.NULL) ? null : // m_driver.nodeToRDBString(t.getPredicate(),true); //String object = triple.getObject().equals(Node.NULL) ? null : // m_driver.nodeToRDBString(t.getObject(),true); //System.out.println(PrintUtil.print(triple)); //System.out.println(triple.getSubject() + "^" + triple.getSubject().getClass()); //System.out.println(triple.getPredicate() + "^" + triple.getPredicate().getClass()); //System.out.println(triple.getObject() + "^" + triple.getObject().getClass()); } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { } } |
|
From: Elmer G. <ega...@us...> - 2004-07-26 22:55:13
|
Update of /cvsroot/javaowl/JavaOWL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22946 Modified Files: build.xml Log Message: Working in prevalence. Index: build.xml =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/build.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** build.xml 19 Jul 2004 04:05:06 -0000 1.11 --- build.xml 26 Jul 2004 22:55:02 -0000 1.12 *************** *** 68,72 **** <arg value="testdata/pru6o.n3"/> <arg value="testdata/pru6p.n3"/> ! <arg value="testdata/pru6d.n3"/> <arg value="uri:pru6:o#"/> <classpath> --- 68,72 ---- <arg value="testdata/pru6o.n3"/> <arg value="testdata/pru6p.n3"/> ! <arg value="testdata/pru6d.prevayler"/> <arg value="uri:pru6:o#"/> <classpath> |
|
From: Elmer G. <ega...@us...> - 2004-07-26 22:55:13
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22946/src/org/javaowl/editor/swing Modified Files: Editor.java Log Message: Working in prevalence. Index: Editor.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/Editor.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Editor.java 23 Jul 2004 01:18:50 -0000 1.23 --- Editor.java 26 Jul 2004 22:55:02 -0000 1.24 *************** *** 25,28 **** --- 25,29 ---- import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; + import java.io.FileInputStream; import java.io.File; import java.io.IOException; *************** *** 39,42 **** --- 40,44 ---- import javax.swing.JTextField; + import org.javaowl.models.prevalence.PrevalentGraph; import org.javaowl.editor.ModelEditorBean; import org.javaowl.editor.ResourceEditorBean; *************** *** 45,48 **** --- 47,52 ---- import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.rdf.model.Resource; + import com.hp.hpl.jena.rdf.model.Model; + import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.vocabulary.XSD; *************** *** 71,76 **** private final Map panels = new HashMap(); ! public static void main(String[] args) throws IOException { ! ModelEditorBean editor = new ModelEditorBean(args[0], args[1], args[2], args[3]); new Editor(editor).show(); } --- 75,87 ---- private final Map panels = new HashMap(); ! public static void main(String[] args) throws IOException, ClassNotFoundException { ! ! Model ontology = ModelFactory.createDefaultModel(); ! ontology.read(new FileInputStream(args[0]), null, "N3"); ! Model props = ModelFactory.createDefaultModel(); ! props.read(new FileInputStream(args[1]), null, "N3"); ! Model data = ModelFactory.createModelForGraph(new PrevalentGraph(args[2])); ! ! ModelEditorBean editor = new ModelEditorBean(ontology, props, data, args[3]); new Editor(editor).show(); } |
|
From: Elmer G. <ega...@us...> - 2004-07-26 14:17:13
|
Update of /cvsroot/javaowl/JavaOWL/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13698/lib Added Files: prevayler1.02.002production.jar Log Message: added prevayler jar --- NEW FILE: prevayler1.02.002production.jar --- (This appears to be a binary file; contents omitted.) |
|
From: Gerardo H. <ma...@us...> - 2004-07-23 01:19:05
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8138/src/org/javaowl/editor Modified Files: ModelEditorBean.java ResourceEditorBean.java Log Message: Some comments and a rename... Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModelEditorBean.java 22 Jul 2004 18:48:42 -0000 1.5 --- ModelEditorBean.java 23 Jul 2004 01:18:50 -0000 1.6 *************** *** 116,119 **** --- 116,120 ---- if (uri.startsWith(prefix)) { OntClass resourceClass = ontModel.getOntClass(uri); + // TODO: fix this. Many domains on a property implies an intersection... for (Iterator it = resourceClass.listDeclaredProperties(false); it.hasNext();) { OntProperty p = (OntProperty) it.next(); *************** *** 136,140 **** } ! public OntProperty[] getProperties() { Set props = new HashSet(); for (Iterator it = ontModel.listDatatypeProperties(); it.hasNext();) { --- 137,141 ---- } ! public OntProperty[] getAllProperties() { Set props = new HashSet(); for (Iterator it = ontModel.listDatatypeProperties(); it.hasNext();) { Index: ResourceEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ResourceEditorBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ResourceEditorBean.java 22 Jul 2004 18:28:38 -0000 1.3 --- ResourceEditorBean.java 23 Jul 2004 01:18:50 -0000 1.4 *************** *** 116,119 **** --- 116,120 ---- public OntResource[] getValidClasses(OntProperty property) { + // TODO: This method is never called! List resources = new ArrayList(); for (Iterator it = property.listRange(); it.hasNext();) *************** *** 129,132 **** --- 130,134 ---- op = ontModel.createOntProperty(property.getURI()); List list = new ArrayList(); + // TODO: fix this. Many ranges on a property implies an intersection... for (Iterator it = op.listRange(); it.hasNext();) { OntResource or = (OntResource) it.next(); |
|
From: Gerardo H. <ma...@us...> - 2004-07-23 01:19:05
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8138/src/org/javaowl/editor/swing Modified Files: Editor.java Log Message: Some comments and a rename... Index: Editor.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/Editor.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Editor.java 22 Jul 2004 18:28:38 -0000 1.22 --- Editor.java 23 Jul 2004 01:18:50 -0000 1.23 *************** *** 110,114 **** try { addPropertyEditor("", Class.forName("org.javaowl.editor.swing.DefaultPropertyEditorPagelet")); ! OntProperty[] props = editor.getProperties(); for(int i = 0; i < props.length; i++) { addPropertyEditor(props[i].getURI(), --- 110,114 ---- try { addPropertyEditor("", Class.forName("org.javaowl.editor.swing.DefaultPropertyEditorPagelet")); ! OntProperty[] props = editor.getAllProperties(); for(int i = 0; i < props.length; i++) { addPropertyEditor(props[i].getURI(), |
|
From: Gerardo H. <ma...@us...> - 2004-07-22 19:17:06
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10883/src/org/javaowl/editor/swing Modified Files: BrowsePage.java Log Message: Removed "directly" from BrowserPage checkboxes Index: BrowsePage.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/swing/BrowsePage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BrowsePage.java 20 Jul 2004 21:43:19 -0000 1.2 --- BrowsePage.java 22 Jul 2004 19:16:54 -0000 1.3 *************** *** 54,60 **** private final Component component; ! private final JCheckBox allInstances = new JCheckBox("Show directly inferred instances"); ! private final JCheckBox allProperties = new JCheckBox("Show directly inferred properties"); private final Editor e; --- 54,60 ---- private final Component component; ! private final JCheckBox allInstances = new JCheckBox("Show inferred instances"); ! private final JCheckBox allProperties = new JCheckBox("Show inferred properties"); private final Editor e; |
|
From: Gerardo H. <ma...@us...> - 2004-07-22 18:48:51
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4948/src/org/javaowl/editor Modified Files: ModelEditorBean.java Log Message: Fixed bug in ModelEditor.getInstances() Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ModelEditorBean.java 22 Jul 2004 18:44:22 -0000 1.4 --- ModelEditorBean.java 22 Jul 2004 18:48:42 -0000 1.5 *************** *** 159,163 **** for (ResIterator it = data.listSubjects(); it.hasNext();) { Resource resource = it.nextResource(); ! if (reasoner.canBeInstanceOf(resource, clazz)) resources.add(resource); } --- 159,163 ---- for (ResIterator it = data.listSubjects(); it.hasNext();) { Resource resource = it.nextResource(); ! if (reasoner.isType(resource, clazz)) resources.add(resource); } |
|
From: Gerardo H. <ma...@us...> - 2004-07-22 18:44:31
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4049/src/org/javaowl/editor Modified Files: ModelEditorBean.java Log Message: Updated ModelEditor.getInstances() to use Pellet reasoner. Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ModelEditorBean.java 22 Jul 2004 18:28:38 -0000 1.3 --- ModelEditorBean.java 22 Jul 2004 18:44:22 -0000 1.4 *************** *** 37,45 **** import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; - import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.vocabulary.RDF; --- 37,46 ---- import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntResource; + import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; + import com.hp.hpl.jena.rdf.model.ResIterator; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.vocabulary.RDF; *************** *** 143,153 **** } ! public Resource[] getInstances(OntResource resource, boolean all) { List resources = new ArrayList(); if (all) { ! for (Iterator it = ontModel.listSubjectsWithProperty(RDF.type, resource); it.hasNext();) ! resources.add(it.next()); } else { ! for (Iterator it = data.listSubjectsWithProperty(RDF.type, resource); it.hasNext();) resources.add(it.next()); } --- 144,167 ---- } ! public Resource[] getInstances(OntResource clazz, boolean all) { List resources = new ArrayList(); if (all) { ! EditorReasoner reasoner = new EditorReasoner(); ! Model model = ModelFactory.createDefaultModel(); ! model.add(ontology); ! model.add(data); ! try { ! reasoner.loadOntology(model); ! } catch (Exception e) { ! e.printStackTrace(); ! throw new RuntimeException("instance reasoner exception: ", e); ! } ! for (ResIterator it = data.listSubjects(); it.hasNext();) { ! Resource resource = it.nextResource(); ! if (reasoner.canBeInstanceOf(resource, clazz)) ! resources.add(resource); ! } } else { ! for (Iterator it = data.listSubjectsWithProperty(RDF.type, clazz); it.hasNext();) resources.add(it.next()); } |
|
From: Gerardo H. <ma...@us...> - 2004-07-22 18:28:52
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv691/src/org/javaowl/editor Modified Files: ModelEditorBean.java ResourceEditorBean.java Log Message: Modified pellet.jar to avoid ClassCastException Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ModelEditorBean.java 22 Jul 2004 02:47:41 -0000 1.2 --- ModelEditorBean.java 22 Jul 2004 18:28:38 -0000 1.3 *************** *** 105,114 **** } ! public OntProperty[] getProperties(OntResource resource, boolean all) { ! OntClass resourceClass = resource.asClass(); Set props = new HashSet(); ! for (Iterator it = resourceClass.listDeclaredProperties(all); it.hasNext();) ! props.add(it.next()); ! return (OntProperty[]) props.toArray(new OntProperty[0]); } --- 105,136 ---- } ! public Set getPropertiesURIs(Resource clazz, boolean all) { ! List l = new ArrayList(); ! l.add(clazz.getURI()); ! if (all) ! l.addAll(ontologyReasoner.getSuperClasses(clazz, true)); Set props = new HashSet(); ! for (Iterator iter = l.iterator(); iter.hasNext(); ) { ! String uri = iter.next().toString(); ! if (uri.startsWith(prefix)) { ! OntClass resourceClass = ontModel.getOntClass(uri); ! for (Iterator it = resourceClass.listDeclaredProperties(false); it.hasNext();) { ! OntProperty p = (OntProperty) it.next(); ! props.add(p.getURI()); ! } ! } ! } ! return props; ! } ! ! public OntProperty[] getProperties(Resource clazz, boolean all) { ! Set props = getPropertiesURIs(clazz, all); ! OntProperty[] result = new OntProperty[props.size()]; ! int i = 0; ! for (Iterator iter = props.iterator(); iter.hasNext(); ) { ! String uri = (String) iter.next(); ! result[i++] = ontModel.getOntProperty(uri); ! } ! return result; } Index: ResourceEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ResourceEditorBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ResourceEditorBean.java 22 Jul 2004 02:47:41 -0000 1.2 --- ResourceEditorBean.java 22 Jul 2004 18:28:38 -0000 1.3 *************** *** 48,54 **** private final Resource resource; ! private final OntProperty[] properties; ! ! private OntClass[] types; private final String prefix; --- 48,52 ---- private final Resource resource; ! // private OntClass[] types; private final String prefix; *************** *** 64,81 **** this.ontModel = ontModel; this.modelEditor = modelEditor; - Set props = new HashSet(); - List classes = new ArrayList(); - for (Iterator it = resource.listProperties(); it.hasNext();) { - Statement stmt = (Statement) it.next(); - if (stmt.getPredicate().equals(RDF.type)) { - Resource r = (Resource) stmt.getObject(); - OntClass resourceClass = ontModel.createClass(r.getURI()); - classes.add(resourceClass); - for (Iterator it2 = resourceClass.listDeclaredProperties(); it2.hasNext();) - props.add(it2.next()); - } - } - properties = (OntProperty[]) props.toArray(new OntProperty[0]); - types = (OntClass[]) classes.toArray(new OntClass[0]); InstanceClassification ic = getInstanceClassification(resource); --- 62,65 ---- *************** *** 93,102 **** public OntProperty[] getApplicableProperties() { ! return properties; } public OntClass[] getTypes() { return types; } public Statement[] getProperties() { --- 77,103 ---- public OntProperty[] getApplicableProperties() { ! Set props = new HashSet(); ! InstanceClassification ic = getInstanceClassification(resource); ! for (Iterator iter = ic.possibleIterator(); iter.hasNext(); ) { ! String uri = (String) iter.next(); ! if (ic.isDeclaredClass(uri) || ic.isInferredClass(uri)) { ! OntClass resourceClass = ontModel.getOntClass(uri); ! props.addAll(modelEditor.getPropertiesURIs(resourceClass, true)); ! } ! } ! OntProperty[] result = new OntProperty[props.size()]; ! int i = 0; ! for (Iterator iter = props.iterator(); iter.hasNext(); ) { ! String uri = (String) iter.next(); ! result[i++] = ontModel.getOntProperty(uri); ! } ! return result; } + /* public OntClass[] getTypes() { return types; } + */ public Statement[] getProperties() { |
|
From: Gerardo H. <ma...@us...> - 2004-07-22 18:28:52
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/reasoner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv691/src/org/javaowl/editor/reasoner Modified Files: EditorReasoner.java Log Message: Modified pellet.jar to avoid ClassCastException Index: EditorReasoner.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/reasoner/EditorReasoner.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EditorReasoner.java 19 Jul 2004 05:52:37 -0000 1.2 --- EditorReasoner.java 22 Jul 2004 18:28:38 -0000 1.3 *************** *** 34,37 **** --- 34,42 ---- } + public Vector getSuperClasses(Resource r, boolean all) { + ATerm c = node2term(r); + return getClassification().getSuperClasses(c, all); + } + public boolean canBeInstanceOf(Resource r, Resource c) { ATerm instance = node2term(r); |