|
From: Elmer G. <ega...@us...> - 2004-08-25 19:12:10
|
Update of /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/remote In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7743/src/org/javaowl/editor/remote Modified Files: RemoteModelEditor.java RemoteModelEditorWrapper.java Log Message: Changes in remote API. Index: RemoteModelEditorWrapper.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/remote/RemoteModelEditorWrapper.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RemoteModelEditorWrapper.java 24 Aug 2004 12:11:54 -0000 1.9 --- RemoteModelEditorWrapper.java 25 Aug 2004 19:12:00 -0000 1.10 *************** *** 38,264 **** public class RemoteModelEditorWrapper implements ModelEditor { ! private String name; ! private OntModel ontModel; private RemoteModelEditor remote; ! public RemoteModelEditorWrapper(String name, RemoteModelEditor remote) { ! this.remote = remote; ! this.name = name; } ! public StatementEditorBean addDataValue(ResourceEditorBean resource, Property property, Literal typedLiteral) { SerializableTriple triple; ! try { ! triple = remote.addDataValue(resource.getURI(), property.getURI(), typedLiteral.getString(), typedLiteral.getDatatype().getURI()); ! return createStatementFromTriple(triple); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public StatementEditorBean addObjectValue(ResourceEditorBean resource, Property property, ResourceEditorBean value) { try { ! SerializableTriple triple = ! remote.addDataValue(resource.getURI(), property.getURI(), value.getURI()); ! return createStatementFromTriple(triple); } catch (RemoteException e) { ! throw new RuntimeException(e); } } ! public void addPropertyValue(ResourceEditorBean resource, Property property, String value) { ! try { ! remote.addDataValue(resource.getURI(), property.getURI(), value); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! private OntClass[] createOntClassesFromUri(String[] uris) { ! OntClass[] classes = new OntClass[uris.length]; ! for (int i = 0; i < uris.length; i++) ! classes[i] = ontModel.createClass(uris[i]); ! return classes; ! } ! private OntProperty[] createOntPropertiesFromURIs(String[] uris) { ! OntProperty[] properties = new OntProperty[uris.length]; ! for (int i = 0; i < uris.length; i++) ! properties[i] = ontModel.createOntProperty(uris[i]); ! return properties; ! } ! public ResourceEditorBean createResourceEditor(OntClass clazz) { ! try { ! Resource resource = ontModel.createResource(remote.createResource(clazz.getURI())); ! return ModelEditorBean.getResourceEditor(resource, this); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public ResourceEditorBean createResourceEditor(String uri, OntClass clazz) { ! try { ! Resource resource = ontModel.createResource(remote.createResource(uri, clazz.getURI())); ! return ModelEditorBean.getResourceEditor(resource, this); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntClass[] getAllClasses() { ! try { ! String[] uris = remote.getAllClasses(); ! return createOntClassesFromUri(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntProperty[] getAllDatatypeProperties() { ! try { ! String[] uris = remote.getAllDatatypeProperties(); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntProperty[] getApplicableProperties(ResourceEditorBean resource) { ! try { ! String[] uris = remote.getApplicableProperties(resource.getURI()); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public StatementEditorBean[] getDeclaredProperties(ResourceEditorBean resource) { ! try { ! SerializableTriple[] triples = remote.getDeclaredProperties(resource.getURI()); ! StatementEditorBean[] statements = new StatementEditorBean[triples.length]; ! for (int i = 0 ; i < triples.length; i ++) { ! statements[i] = createStatementFromTriple(triples[i]); ! } ! return statements; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! ! private StatementEditorBean createStatementFromTriple(SerializableTriple triple) { ! RDFNode subject = ontModel.getRDFNode(TripleUtil.stringToNode(triple.getSubject())); ! RDFNode predicate = ontModel.getRDFNode(TripleUtil.stringToNode(triple.getPredicate())); ! RDFNode object = ontModel.getRDFNode(TripleUtil.stringToNode(triple.getObject())); ! return ModelEditorBean.getStatementEditor(ontModel.createStatement((Resource) subject, (Property) predicate, object), this); ! } ! ! public ResourceEditorBean[] getInstances(OntClass clazz, boolean all) { ! try { ! String[] uris = remote.getInstances(clazz.getURI(), all); ! ResourceEditorBean[] resources = new ResourceEditorBean[uris.length]; ! for (int i = 0; i < uris.length; i++) ! resources[i] = ModelEditorBean.getResourceEditor(ontModel.createResource(uris[i]), this); ! return resources; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public String getLabel(ResourceEditorBean resource) { ! try { ! return remote.getLabel(resource.getURI()); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public OntClass getOntClass(Resource resource) { ! return ontModel.createClass(resource.getURI()); ! } ! public OntProperty getOntProperty(Property property) { ! return ontModel.createOntProperty(property.getURI()); ! } ! public OntProperty[] getProperties(OntClass clazz, boolean all) { ! try { ! String[] uris = remote.getProperties(clazz.getURI(), all); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public String getPropertyValue(OntClass clazz, Property label, boolean uri) { ! try { ! return remote.getPropertyValue(clazz.getURI(), label.getURI(), uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public String getPropertyValue(ResourceEditorBean resource, Property property, boolean uri) { ! try { ! return remote.getPropertyValue(resource.getURI(), property.getURI(), uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntClass[] getSubClasses(OntClass clazz) { ! try { ! String[] uris = remote.getSubClasses(clazz.getURI()); ! return createOntClassesFromUri(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public Literal getTypedLiteral(Object value, OntResource type) { ! return ontModel.createTypedLiteral(value, type.getURI()); ! } public OntClass getValidLeafClass(Property property) { ! try { ! String uri = remote.getValidLeafClass(property.getURI()); ! return ontModel.createClass(uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } public ResourceEditorBean[] getValidObjects(OntClass clazz) { ! try { ! String[] uris = remote.getValidObjects(clazz.getURI()); ! ResourceEditorBean[] individuals = new ResourceEditorBean[uris.length]; ! for (int i = 0; i < uris.length; i++) ! individuals[i] = ModelEditorBean.getResourceEditor(ontModel.createResource(uris[i]), this); ! return individuals; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public void removeResource(ResourceEditorBean resource) { ! try { ! remote.removeResource(resource.getURI()); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public void removeStatement(StatementEditorBean statement) { ! try { ! remote.removeStatement(new SerializableTriple(statement.asTriple())); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! } --- 38,275 ---- public class RemoteModelEditorWrapper implements ModelEditor { ! ! private OntModel ontModel; private RemoteModelEditor remote; ! public RemoteModelEditorWrapper(String prefix, RemoteModelEditor remote) { ! try { ! this.remote = remote; ! remote.init(prefix); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public StatementEditorBean addDataValue(ResourceEditorBean resource, Property property, ! Literal typedLiteral) { SerializableTriple triple; ! try { ! triple = remote.addDataValue(resource.getURI(), property.getURI(), ! typedLiteral.getString(), ! typedLiteral.getDatatype().getURI()); ! return createStatementFromTriple(triple); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public StatementEditorBean addObjectValue(ResourceEditorBean resource, Property property, ! ResourceEditorBean value) { try { ! SerializableTriple triple = ! remote.addDataValue(resource.getURI(), property.getURI(), value.getURI()); ! return createStatementFromTriple(triple); } catch (RemoteException e) { ! throw new RuntimeException(e); } } ! public void addPropertyValue(ResourceEditorBean resource, Property property, ! String value) { ! try { ! remote.addDataValue(resource.getURI(), property.getURI(), value); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! private OntClass[] createOntClassesFromUri(String[] uris) { ! OntClass[] classes = new OntClass[uris.length]; ! for (int i = 0; i < uris.length; i++) ! classes[i] = ontModel.createClass(uris[i]); ! return classes; ! } ! private OntProperty[] createOntPropertiesFromURIs(String[] uris) { ! OntProperty[] properties = new OntProperty[uris.length]; ! for (int i = 0; i < uris.length; i++) ! properties[i] = ontModel.createOntProperty(uris[i]); ! return properties; ! } ! public ResourceEditorBean createResourceEditor(OntClass clazz) { ! try { ! Resource resource = ontModel ! .createResource(remote.createResource(clazz.getURI())); ! return ModelEditorBean.getResourceEditor(resource, this); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public ResourceEditorBean createResourceEditor(String uri, OntClass clazz) { ! try { ! Resource resource = ontModel ! .createResource(remote.createResource(uri, clazz.getURI())); ! return ModelEditorBean.getResourceEditor(resource, this); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntClass[] getAllClasses() { ! try { ! String[] uris = remote.getAllClasses(); ! return createOntClassesFromUri(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntProperty[] getAllDatatypeProperties() { ! try { ! String[] uris = remote.getAllDatatypeProperties(); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntProperty[] getApplicableProperties(ResourceEditorBean resource) { ! try { ! String[] uris = remote.getApplicableProperties(resource.getURI()); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public StatementEditorBean[] getDeclaredProperties(ResourceEditorBean resource) { ! try { ! SerializableTriple[] triples = remote.getDeclaredProperties(resource.getURI()); ! StatementEditorBean[] statements = new StatementEditorBean[triples.length]; ! for (int i = 0 ; i < triples.length; i ++) { ! statements[i] = createStatementFromTriple(triples[i]); ! } ! return statements; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public ResourceEditorBean getResourceEditor(String uri) { ! throw new UnsupportedOperationException(); ! } ! private StatementEditorBean createStatementFromTriple(SerializableTriple triple) { ! RDFNode subject = ontModel ! .getRDFNode(TripleUtil.stringToNode(triple.getSubject())); ! RDFNode predicate = ontModel ! .getRDFNode(TripleUtil.stringToNode(triple.getPredicate())); ! RDFNode object = ontModel.getRDFNode(TripleUtil.stringToNode(triple.getObject())); ! return ModelEditorBean ! .getStatementEditor(ontModel.createStatement((Resource) subject, ! (Property) predicate, object), this); ! } ! public ResourceEditorBean[] getInstances(OntClass clazz, boolean all) { ! try { ! String[] uris = remote.getInstances(clazz.getURI(), all); ! ResourceEditorBean[] resources = new ResourceEditorBean[uris.length]; ! for (int i = 0; i < uris.length; i++) ! resources[i] = ModelEditorBean ! .getResourceEditor(ontModel.createResource(uris[i]), this); ! return resources; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public OntClass getOntClass(Resource resource) { ! return ontModel.createClass(resource.getURI()); ! } ! public OntProperty getOntProperty(Property property) { ! return ontModel.createOntProperty(property.getURI()); ! } ! public OntProperty[] getProperties(OntClass clazz, boolean all) { ! try { ! String[] uris = remote.getProperties(clazz.getURI(), all); ! return createOntPropertiesFromURIs(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public String getPropertyValue(OntClass clazz, Property label, boolean uri) { ! try { ! return remote.getPropertyValue(clazz.getURI(), label.getURI(), uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public String getPropertyValue(ResourceEditorBean resource, Property property, ! boolean uri) { ! try { ! return remote.getPropertyValue(resource.getURI(), property.getURI(), uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public OntClass[] getSubClasses(OntClass clazz) { ! try { ! String[] uris = remote.getSubClasses(clazz.getURI()); ! return createOntClassesFromUri(uris); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public Literal getTypedLiteral(Object value, OntResource type) { ! return ontModel.createTypedLiteral(value, type.getURI()); ! } public OntClass getValidLeafClass(Property property) { ! try { ! String uri = remote.getValidLeafClass(property.getURI()); ! return ontModel.createClass(uri); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } public ResourceEditorBean[] getValidObjects(OntClass clazz) { ! try { ! String[] uris = remote.getValidObjects(clazz.getURI()); ! ResourceEditorBean[] individuals = new ResourceEditorBean[uris.length]; ! for (int i = 0; i < uris.length; i++) ! individuals[i] = ModelEditorBean ! .getResourceEditor(ontModel.createResource(uris[i]), this); ! return individuals; ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } } ! public void removeResource(ResourceEditorBean resource) { ! try { ! remote.removeResource(resource.getURI()); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } ! public void removeStatement(StatementEditorBean statement) { ! try { ! remote.removeStatement(new SerializableTriple(statement.asTriple())); ! } catch (RemoteException e) { ! throw new RuntimeException(e); ! } ! } } Index: RemoteModelEditor.java =================================================================== RCS file: /cvsroot/javaowl/JavaOWL/src/org/javaowl/editor/remote/RemoteModelEditor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RemoteModelEditor.java 24 Aug 2004 12:11:54 -0000 1.7 --- RemoteModelEditor.java 25 Aug 2004 19:12:00 -0000 1.8 *************** *** 25,65 **** public interface RemoteModelEditor extends Remote{ ! SerializableTriple addDataValue(String resource, String property, String object) throws RemoteException; ! ! SerializableTriple addDataValue(String resource, String property, String value, String dataType) throws RemoteException; String createResource(String clazz) throws RemoteException; ! String createResource(String uri, String clazz) throws RemoteException; ! ! String[] getAllClasses() throws RemoteException; ! ! String[] getAllDatatypeProperties() throws RemoteException; ! String[] getApplicableProperties(String resource) throws RemoteException; ! ! String getComment(String resource) throws RemoteException; ! ! SerializableTriple[] getDeclaredProperties(String resource) throws RemoteException; ! ! String[] getInstances(String clazz, boolean all) throws RemoteException; ! ! String getLabel(String resource) throws RemoteException; ! ! String[] getProperties(String resource, boolean all) throws RemoteException; ! ! String getPropertyValue(String clazz, String label, boolean uri) throws RemoteException; ! ! String[] getSubClasses(String clazz) throws RemoteException; ! String getValidLeafClass(String property) throws RemoteException; String[] getValidObjects(String clazz) throws RemoteException; ! void removeEditor(String name) throws RemoteException; ! void removeResource(String uri) throws RemoteException; ! ! void removeStatement(SerializableTriple statement) throws RemoteException; void setComment(String resource, String comment) throws RemoteException; --- 25,63 ---- public interface RemoteModelEditor extends Remote{ ! SerializableTriple addDataValue(String resource, String property, String object) throws RemoteException; ! ! SerializableTriple addDataValue(String resource, String property, String value, String dataType) throws RemoteException; ! ! void clearEditor() throws RemoteException; String createResource(String clazz) throws RemoteException; ! String createResource(String uri, String clazz) throws RemoteException; ! ! String[] getAllClasses() throws RemoteException; ! ! String[] getAllDatatypeProperties() throws RemoteException; ! String[] getApplicableProperties(String resource) throws RemoteException; ! ! SerializableTriple[] getDeclaredProperties(String resource) throws RemoteException; ! ! String[] getInstances(String clazz, boolean all) throws RemoteException; ! ! String[] getProperties(String resource, boolean all) throws RemoteException; ! ! String getPropertyValue(String clazz, String label, boolean uri) throws RemoteException; ! ! String[] getSubClasses(String clazz) throws RemoteException; ! String getValidLeafClass(String property) throws RemoteException; String[] getValidObjects(String clazz) throws RemoteException; ! void init(String prefix) throws RemoteException; ! void removeResource(String uri) throws RemoteException; ! ! void removeStatement(SerializableTriple statement) throws RemoteException; void setComment(String resource, String comment) throws RemoteException; |