|
From: Elmer G. <ega...@us...> - 2004-08-23 20:02:23
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17115/src/org/javaowl/editor Modified Files: ModelEditorBean.java ModelEditor.java ResourceEditorBean.java Added Files: StatementEditorBean.java Log Message: Finished refactoring Index: ModelEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditorBean.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ModelEditorBean.java 21 Aug 2004 00:22:49 -0000 1.15 --- ModelEditorBean.java 23 Aug 2004 20:02:11 -0000 1.16 *************** *** 32,36 **** import org.javaowl.editor.reasoner.EditorReasoner; - import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; --- 32,35 ---- *************** *** 157,168 **** } ! public Statement[] getDeclaredProperties(ResourceEditorBean resource) { List resources = new ArrayList(); for (Iterator it = resource.resource.listProperties(); it.hasNext();) { Statement stmt = (Statement) it.next(); if (stmt.getPredicate().getNameSpace().equals(prefix)) ! resources.add(stmt); } ! return (Statement[]) resources.toArray(new Statement[0]); } --- 156,167 ---- } ! public StatementEditorBean[] getDeclaredProperties(ResourceEditorBean resource) { List resources = new ArrayList(); for (Iterator it = resource.resource.listProperties(); it.hasNext();) { Statement stmt = (Statement) it.next(); if (stmt.getPredicate().getNameSpace().equals(prefix)) ! resources.add(new StatementEditorBean(stmt, this)); } ! return (StatementEditorBean[]) resources.toArray(new StatementEditorBean[0]); } *************** *** 212,231 **** } ! public Individual[] getValidObjects(OntClass oc) { List resources = new ArrayList(); for (Iterator it = oc.listInstances(); it.hasNext();) ! resources.add(it.next()); ! return (Individual[]) resources.toArray(new Individual[0]); } ! public Statement addObjectValue(ResourceEditorBean resource, Property property, Resource value) { ! resource.resource.addProperty(property, value); ! return resource.resource.getProperty(property); // TODO: This is a BUG! } ! public Statement addDataValue(ResourceEditorBean resource, Property property, Literal value) { resource.resource.addProperty(property, value); ! return resource.resource.getProperty(property); // TODO: This is a BUG! } --- 211,230 ---- } ! public ResourceEditorBean[] getValidObjects(OntClass oc) { List resources = new ArrayList(); for (Iterator it = oc.listInstances(); it.hasNext();) ! resources.add(new ResourceEditorBean((Resource) it.next(), this)); ! return (ResourceEditorBean[]) resources.toArray(new ResourceEditorBean[0]); } ! public StatementEditorBean addObjectValue(ResourceEditorBean resource, Property property, ResourceEditorBean value) { ! resource.resource.addProperty(property, value.resource); ! return new StatementEditorBean(resource.resource.getProperty(property), this); // TODO: This is a BUG! } ! public StatementEditorBean addDataValue(ResourceEditorBean resource, Property property, Literal value) { resource.resource.addProperty(property, value); ! return new StatementEditorBean(resource.resource.getProperty(property),this); // TODO: This is a BUG! } *************** *** 274,279 **** } ! public void removeStatement(Statement statement) { ! data.remove(statement); } --- 273,278 ---- } ! public void removeStatement(StatementEditorBean statement) { ! data.remove(statement.statement); } --- NEW FILE: StatementEditorBean.java --- /* * StatementEditorBean.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.editor; import com.hp.hpl.jena.graph.Triple; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Statement; public final class StatementEditorBean { final Statement statement; private final ModelEditor editor; StatementEditorBean(Statement statement, ModelEditor editor) { this.statement = statement; this.editor = editor; } public Property getPredicate() { return statement.getPredicate(); } public Object getObject() { Object value = statement.getObject(); if(value instanceof Resource) { return new ResourceEditorBean((Resource)value, editor); } return value; } public Triple asTriple() { return statement.asTriple(); } } Index: ModelEditor.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ModelEditor.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ModelEditor.java 21 Aug 2004 00:22:49 -0000 1.28 --- ModelEditor.java 23 Aug 2004 20:02:11 -0000 1.29 *************** *** 21,25 **** - import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntProperty; --- 21,24 ---- *************** *** 28,38 **** import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; - import com.hp.hpl.jena.rdf.model.Statement; public interface ModelEditor { ! public Statement addDataValue(ResourceEditorBean resource, Property currentProperty, Literal typedLiteral); ! public Statement addObjectValue(ResourceEditorBean resource, Property currentProperty, Resource value); public void addPropertyValue(ResourceEditorBean bean, Property label, String value); --- 27,36 ---- import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; public interface ModelEditor { ! public StatementEditorBean addDataValue(ResourceEditorBean resource, Property currentProperty, Literal typedLiteral); ! public StatementEditorBean addObjectValue(ResourceEditorBean resource, Property currentProperty, ResourceEditorBean value); public void addPropertyValue(ResourceEditorBean bean, Property label, String value); *************** *** 48,52 **** public OntProperty[] getApplicableProperties(ResourceEditorBean resource); ! public Statement[] getDeclaredProperties(ResourceEditorBean resource); public ResourceEditorBean[] getInstances(OntClass clazz, boolean all); --- 46,50 ---- public OntProperty[] getApplicableProperties(ResourceEditorBean resource); ! public StatementEditorBean[] getDeclaredProperties(ResourceEditorBean resource); public ResourceEditorBean[] getInstances(OntClass clazz, boolean all); *************** *** 68,75 **** public OntClass getValidLeafClass(Property currentProperty); ! public Individual[] getValidObjects(OntClass clazz); public void removeResource(ResourceEditorBean resource); ! public void removeStatement(Statement statement); } --- 66,73 ---- public OntClass getValidLeafClass(Property currentProperty); ! public ResourceEditorBean[] getValidObjects(OntClass clazz); public void removeResource(ResourceEditorBean resource); ! public void removeStatement(StatementEditorBean statement); } Index: ResourceEditorBean.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/ResourceEditorBean.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ResourceEditorBean.java 21 Aug 2004 00:22:49 -0000 1.10 --- ResourceEditorBean.java 23 Aug 2004 20:02:11 -0000 1.11 *************** *** 49,53 **** public String getComment(boolean uri) { ! String s = editor.getPropertyValue(this, RDFS.label, uri); return s == null ? "" : s; } --- 49,53 ---- public String getComment(boolean uri) { ! String s = editor.getPropertyValue(this, RDFS.comment, uri); return s == null ? "" : s; } *************** *** 63,66 **** --- 63,71 ---- return test == null || test.length() == 0; } + + public String toString() { + return getLabel(true); + } + /*InstanceClassification ic = getInstanceClassification(resource); for (Iterator it = ic.possibleIterator(); it.hasNext(); ) { |