Mercurial > hg > NamedIdentityManager
changeset 4:f986e74583eb
removed triplestorehandler componentes
author | dwinter |
---|---|
date | Tue, 13 Dec 2011 17:46:51 +0100 |
parents | e3ecb88314a5 |
children | cdc4c12262b1 |
files | .classpath .project src/de/mpiwg/itgroup/nimanager/exceptions/TripleStoreHandlerException.java src/de/mpiwg/itgroup/nimanager/importer/Import.java src/de/mpiwg/itgroup/nimanager/importer/ImportGND.java src/de/mpiwg/itgroup/nimanager/luceneIndices/Importer.java src/de/mpiwg/itgroup/nimanager/owl/MetaDataHandler.java src/de/mpiwg/itgroup/nimanager/owl/TripleStoreHandler.java src/de/mpiwg/itgroup/nimanager/owl/Util.java src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java src/de/mpiwg/itgroup/nimanager/persons/PersonListService.java src/de/mpiwg/itgroup/nimanager/persons/PersonService.java |
diffstat | 12 files changed, 444 insertions(+), 846 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Fri Dec 02 08:37:03 2011 +0100 +++ b/.classpath Tue Dec 13 17:46:51 2011 +0100 @@ -33,5 +33,6 @@ <attribute name="owner.project.facets" value="java"/> </attributes> </classpathentry> + <classpathentry combineaccessrules="false" kind="src" path="/TripleStoreManager"/> <classpathentry kind="output" path="bin"/> </classpath>
--- a/.project Fri Dec 02 08:37:03 2011 +0100 +++ b/.project Tue Dec 13 17:46:51 2011 +0100 @@ -34,6 +34,11 @@ </natures> <linkedResources> <link> + <name>ontologies</name> + <type>2</type> + <locationURI>virtual:/virtual</locationURI> + </link> + <link> <name>libs/virtjdbc3.jar</name> <type>1</type> <locationURI>PARENT-7-PROJECT_LOC/usr/local/virtuoso-opensource/lib/jdbc-3.0/virtjdbc3.jar</locationURI> @@ -53,5 +58,415 @@ <type>1</type> <locationURI>PARENT-7-PROJECT_LOC/usr/local/virtuoso-opensource/lib/jdbc-4.0/virtjdbc4ssl.jar</locationURI> </link> + <link> + <name>ontologies/.hg</name> + <type>2</type> + <locationURI>virtual:/virtual</locationURI> + </link> + <link> + <name>ontologies/.project</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.project</locationURI> + </link> + <link> + <name>ontologies/MPIWGGeneral.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/MPIWGGeneral.owl</locationURI> + </link> + <link> + <name>ontologies/MPIWGGeneral.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/MPIWGGeneral.pprj</locationURI> + </link> + <link> + <name>ontologies/MPIWGGeneral.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/MPIWGGeneral.repository</locationURI> + </link> + <link> + <name>ontologies/annotation-ns.rdf</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotation-ns.rdf</locationURI> + </link> + <link> + <name>ontologies/annotationType.rdf</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotationType.rdf</locationURI> + </link> + <link> + <name>ontologies/annotations.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations.owl</locationURI> + </link> + <link> + <name>ontologies/annotations.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations.pprj</locationURI> + </link> + <link> + <name>ontologies/annotations.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations.repository</locationURI> + </link> + <link> + <name>ontologies/annotations_annotator.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations_annotator.owl</locationURI> + </link> + <link> + <name>ontologies/annotations_annotator.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations_annotator.pprj</locationURI> + </link> + <link> + <name>ontologies/annotations_annotator.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/annotations_annotator.repository</locationURI> + </link> + <link> + <name>ontologies/catalog-v001.xml</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/catalog-v001.xml</locationURI> + </link> + <link> + <name>ontologies/dbpedia_3.6.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/dbpedia_3.6.owl</locationURI> + </link> + <link> + <name>ontologies/dcterms.rdf</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/dcterms.rdf</locationURI> + </link> + <link> + <name>ontologies/ecrm_110404.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/ecrm_110404.owl</locationURI> + </link> + <link> + <name>ontologies/ecrm_plus_110404_dw.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/ecrm_plus_110404_dw.owl</locationURI> + </link> + <link> + <name>ontologies/foaf.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/foaf.owl</locationURI> + </link> + <link> + <name>ontologies/namedIdentities.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentities.owl</locationURI> + </link> + <link> + <name>ontologies/namedIdentities.owl~</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentities.owl~</locationURI> + </link> + <link> + <name>ontologies/namedIdentities.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentities.pprj</locationURI> + </link> + <link> + <name>ontologies/namedIdentities.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentities.repository</locationURI> + </link> + <link> + <name>ontologies/namedIdentitiesTest.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentitiesTest.owl</locationURI> + </link> + <link> + <name>ontologies/namedIdentitiesTest.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentitiesTest.pprj</locationURI> + </link> + <link> + <name>ontologies/namedIdentitiesTest.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/namedIdentitiesTest.repository</locationURI> + </link> + <link> + <name>ontologies/openannotation.rdf</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/openannotation.rdf</locationURI> + </link> + <link> + <name>ontologies/personsLibrary.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/personsLibrary.owl</locationURI> + </link> + <link> + <name>ontologies/personsLibrary.pprj</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/personsLibrary.pprj</locationURI> + </link> + <link> + <name>ontologies/personsLibrary.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/personsLibrary.repository</locationURI> + </link> + <link> + <name>ontologies/rdf-schema</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/rdf-schema</locationURI> + </link> + <link> + <name>ontologies/skos-owl1-dl.rdf</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/skos-owl1-dl.rdf</locationURI> + </link> + <link> + <name>ontologies/test.owl</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/test.owl</locationURI> + </link> + <link> + <name>ontologies/test.repository</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/test.repository</locationURI> + </link> + <link> + <name>ontologies/.hg/00changelog.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/00changelog.i</locationURI> + </link> + <link> + <name>ontologies/.hg/cache</name> + <type>2</type> + <locationURI>virtual:/virtual</locationURI> + </link> + <link> + <name>ontologies/.hg/dirstate</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/dirstate</locationURI> + </link> + <link> + <name>ontologies/.hg/last-message.txt</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/last-message.txt</locationURI> + </link> + <link> + <name>ontologies/.hg/requires</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/requires</locationURI> + </link> + <link> + <name>ontologies/.hg/store</name> + <type>2</type> + <locationURI>virtual:/virtual</locationURI> + </link> + <link> + <name>ontologies/.hg/undo.bookmarks</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/undo.bookmarks</locationURI> + </link> + <link> + <name>ontologies/.hg/undo.branch</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/undo.branch</locationURI> + </link> + <link> + <name>ontologies/.hg/undo.desc</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/undo.desc</locationURI> + </link> + <link> + <name>ontologies/.hg/undo.dirstate</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/undo.dirstate</locationURI> + </link> + <link> + <name>ontologies/.hg/cache/tags</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/cache/tags</locationURI> + </link> + <link> + <name>ontologies/.hg/store/00changelog.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/00changelog.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/00manifest.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/00manifest.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data</name> + <type>2</type> + <locationURI>virtual:/virtual</locationURI> + </link> + <link> + <name>ontologies/.hg/store/fncache</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/fncache</locationURI> + </link> + <link> + <name>ontologies/.hg/store/undo</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/undo</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/_m_p_i_w_g_general.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/_m_p_i_w_g_general.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/_m_p_i_w_g_general.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/_m_p_i_w_g_general.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/_m_p_i_w_g_general.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/_m_p_i_w_g_general.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotation-ns.rdf.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotation-ns.rdf.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotation_type.rdf.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotation_type.rdf.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations__annotator.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations__annotator.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations__annotator.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations__annotator.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/annotations__annotator.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/annotations__annotator.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/catalog-v001.xml.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/catalog-v001.xml.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/dbpedia__3.6.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/dbpedia__3.6.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/dcterms.rdf.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/dcterms.rdf.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/ecrm__110404.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/ecrm__110404.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/ecrm__plus__110404__dw.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/ecrm__plus__110404__dw.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/foaf.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/foaf.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities_test.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities_test.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities_test.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities_test.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/named_identities_test.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/named_identities_test.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/openannotation.rdf.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/openannotation.rdf.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/persons_library.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/persons_library.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/persons_library.pprj.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/persons_library.pprj.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/persons_library.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/persons_library.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/rdf-schema.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/rdf-schema.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/skos-owl1-dl.rdf.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/skos-owl1-dl.rdf.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/test.owl.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/test.owl.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/test.repository.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/test.repository.i</locationURI> + </link> + <link> + <name>ontologies/.hg/store/data/~2eproject.i</name> + <type>1</type> + <locationURI>PARENT-1-PROJECT_LOC/MPIWG-ontologies/.hg/store/data/~2eproject.i</locationURI> + </link> </linkedResources> </projectDescription>
--- a/src/de/mpiwg/itgroup/nimanager/exceptions/TripleStoreHandlerException.java Fri Dec 02 08:37:03 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package de.mpiwg.itgroup.nimanager.exceptions; - -public class TripleStoreHandlerException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -491859023038922276L; - -}
--- a/src/de/mpiwg/itgroup/nimanager/importer/Import.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/importer/Import.java Tue Dec 13 17:46:51 2011 +0100 @@ -31,9 +31,11 @@ import com.hp.hpl.jena.graph.impl.LiteralLabel; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.MetaDataHandler; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.MetaDataHandler; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; + + import edu.stanford.smi.protegex.owl.jena.JenaOWLModel; import edu.stanford.smi.protegex.owl.model.OWLIndividual; import edu.stanford.smi.protegex.owl.model.RDFProperty;
--- a/src/de/mpiwg/itgroup/nimanager/importer/ImportGND.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/importer/ImportGND.java Tue Dec 13 17:46:51 2011 +0100 @@ -37,9 +37,12 @@ import com.hp.hpl.jena.graph.impl.LiteralLabel; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.MetaDataHandler; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.MetaDataHandler; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; + + + import edu.stanford.smi.protegex.owl.jena.JenaOWLModel; import edu.stanford.smi.protegex.owl.model.OWLIndividual; import edu.stanford.smi.protegex.owl.model.RDFProperty;
--- a/src/de/mpiwg/itgroup/nimanager/luceneIndices/Importer.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/luceneIndices/Importer.java Tue Dec 13 17:46:51 2011 +0100 @@ -1,5 +1,5 @@ /* - * Klasse importiert Werte von Triple in einen Lucene Index fŸr die schnellere Suche. + * Klasse importiert Werte von Triple in einen Lucene Index f�r die schnellere Suche. */ package de.mpiwg.itgroup.nimanager.luceneIndices; @@ -26,8 +26,8 @@ import org.openrdf.repository.RepositoryException; import org.openrdf.repository.RepositoryResult; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; public class Importer {
--- a/src/de/mpiwg/itgroup/nimanager/owl/MetaDataHandler.java Fri Dec 02 08:37:03 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,285 +0,0 @@ -package de.mpiwg.itgroup.nimanager.owl; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.openrdf.repository.RepositoryException; - -import com.hp.hpl.jena.graph.impl.LiteralLabel; -import com.hp.hpl.jena.util.FileUtils; - -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; - -import edu.stanford.smi.protege.exception.OntologyLoadException; -import edu.stanford.smi.protege.storage.xml.XMLString; -import edu.stanford.smi.protegex.owl.ProtegeOWL; -import edu.stanford.smi.protegex.owl.jena.JenaOWLModel; -import edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator; -import edu.stanford.smi.protegex.owl.model.OWLIndividual; -import edu.stanford.smi.protegex.owl.model.OWLModel; -import edu.stanford.smi.protegex.owl.model.OWLNamedClass; -import edu.stanford.smi.protegex.owl.model.RDFProperty; -import edu.stanford.smi.protegex.owl.model.RDFResource; -import edu.stanford.smi.protegex.owl.model.RDFSNamedClass; -import edu.stanford.smi.protegex.owl.model.impl.DefaultOWLNamedClass; -import edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty; -import edu.stanford.smi.protegex.owl.model.impl.DefaultRDFSNamedClass; -import edu.stanford.smi.protegex.owl.repository.RepositoryManager; -import edu.stanford.smi.protegex.owl.repository.impl.LocalFolderRepository; -import edu.stanford.smi.protegex.owl.ui.profiles.OWLProfiles; -import edu.stanford.smi.protegex.owl.ui.profiles.ProfilesManager; - -public class MetaDataHandler { - - String ontologieUriString = "file:///Users/dwinter/Documents/Projekte/ECHO-eSciDoc-MPDL/escidocMPIWG/NamedIdentityManager/ontologies/namedIdentities.owl"; - //String rdfUriString = "file:///Users/dwinter/Documents/Projekte/ECHO-eSciDoc-MPDL/escidocMPIWG/NamedIdentityManager/ontologies/rdf-schema"; - String owlFolder = "/Users/dwinter/Documents/Projekte/ECHO-eSciDoc-MPDL/escidocMPIWG/NamedIdentityManager/ontologies"; - - static MetaDataHandler instance=null; - - private JenaOWLModel owlModel; - - public JenaOWLModel getOwlModel() { - return owlModel; - } - - private Logger logger = Logger.getRootLogger(); - - public MetaDataHandler() { - try { - URI ontologieUri = new URI(ontologieUriString); - loadOWL(owlFolder, ontologieUri); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return; - } catch (OntologyLoadException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - logger.info("initialized handler"); - - } - -// public JenaOWLModel createMyJenaOWLModelFromURI(String uri) throws OntologyLoadException { -// //Collection errors = new ArrayList(); -// OwlProjectFromUriCreator creator = new OwlProjectFromUriCreator(); -// creator.setLang(FileUtils. -// creator.setOntologyUri(uri); -// //creator.create(errors); -// JenaOWLModel owlModel = creator.getOwlModel(); -// //handleErrors(errors); -// return owlModel; -// } - - public void loadOWL(String folder, URI uri) throws OntologyLoadException { - //owlModel = ProtegeOWL.createJenaOWLModel(); - - owlModel = ProtegeOWL.createJenaOWLModelFromURI(ontologieUriString); - - //ProfilesManager.setProfile(owlModel, OWLProfiles.RDFSClass_but_not_OWLClass_Type.getURI()); - // Load repository - RepositoryManager rman = owlModel.getRepositoryManager(); - - // Add working directory to repository manager. - File workingDirectory = new File(folder); - rman.addGlobalRepository(new LocalFolderRepository(workingDirectory)); - - LocalFolderRepository localRepository = new LocalFolderRepository(new File("/tmp")); - rman.addProjectRepository(localRepository); - - - - - // Load ontology - - //((JenaOWLModel) owlModel).load(uri, "OWL-FULL"); - } - - /** - * Gibt alle Properties der Klasse zurueck, d.h. auch diejenigen die inferiert werden. - * @param string - * @return - */ - public Set getAssociatedPropsForClass(String string) { - - - - OWLNamedClass owlclass; - try { - owlclass = (OWLNamedClass) owlModel.getOWLNamedClass(string); - } catch (Exception e) { - logger.debug("Problem getting OWLClass, try RDFS later."); - //wenn eine Klasse sowohl eine RDFS als auch per Zuordnung in der Ontologie eine OWL classe ist, wir hier eine Fehler ausgeworfen: - //java.lang.ClassCastException: edu.stanford.smi.protegex.owl.model.impl.DefaultRDFSNamedClass cannot be cast to edu.stanford.smi.protegex.owl.model.OWLNamedClass - //at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.getOWLNamedClass(Unknown Source) - owlclass= null; - } - - if (owlclass != null) { - return owlclass.getAssociatedProperties(); - } else { - logger.debug("Cannot find OWLClass:" + string); - logger.debug("Trying RDFSClass"); - RDFSNamedClass rdfsclass=(RDFSNamedClass)owlModel.getRDFSNamedClass(string); - if (rdfsclass != null) { - return rdfsclass.getAssociatedProperties(); - } else { - logger.debug("Cannot find RDFSClass:" + string); - return null; - } - } - - - - } - - /** - * Gibt alle direkten Properties der angegebenen Klasse zurueck. - * @param string - * @return - */ - public Collection getDirectPropsForClass(String string, Boolean transitiv) { - - - - OWLNamedClass owlclass; - try { - owlclass = (OWLNamedClass) owlModel.getOWLNamedClass(string); - } catch (Exception e) { - logger.debug("Problem getting OWLClass, try RDFS later."); - //wenn eine Klasse sowohl eine RDFS als auch per Zuordnung in der Ontologie eine OWL classe ist, wir hier eine Fehler ausgeworfen: - //java.lang.ClassCastException: edu.stanford.smi.protegex.owl.model.impl.DefaultRDFSNamedClass cannot be cast to edu.stanford.smi.protegex.owl.model.OWLNamedClass - //at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.getOWLNamedClass(Unknown Source) - owlclass= null; - } - - if (owlclass != null) { - return owlclass.getUnionDomainProperties(transitiv); - } else { - logger.debug("Cannot find OWLClass:" + string); - logger.debug("Trying RDFSClass"); - RDFSNamedClass rdfsclass=(RDFSNamedClass)owlModel.getRDFSNamedClass(string); - if (rdfsclass != null) { - - return rdfsclass.getUnionDomainProperties(transitiv); - } else { - logger.debug("Cannot find RDFSClass:" + string); - return null; - } - } - - - - } - - - public List<String> getEquivalentClasses(String string) { - OWLNamedClass owlclass = (OWLNamedClass) owlModel - .getOWLNamedClass(string); - - List<String> retList = new ArrayList<String>(); - Collection eqClasses = owlclass.getEquivalentClasses(); - Iterator it = eqClasses.iterator(); - while(it.hasNext()){ - Object cls = it.next(); - String name = ""; - if (DefaultOWLNamedClass.class.isInstance(cls)){ - name=((DefaultOWLNamedClass)cls).getName(); - } else if (DefaultRDFSNamedClass.class.isInstance(cls)){ - name=((DefaultRDFSNamedClass)cls).getName(); - } - retList.add(name); - - } - - return retList; - } - - - public static void main(String args[]) throws RepositoryException, TripleStoreHandlerException { - TripleStoreHandler th = new TripleStoreHandler("jdbc:virtuoso://virtuoso.mpiwg-berlin.mpg.de:1111", "dba", "dba"); - MetaDataHandler mh = new MetaDataHandler(); - - //Set<DefaultRDFProperty> props= mh.getPropsForClass("http://dbpedia.org/ontology/Person"); - - mh.getEquivalentClasses("http://dbpedia.org/ontology/Person"); - - //Map<String, String> ret = th.getValues(props,"<http://dbpedia.org/resource/Abraham_Lincoln>"); - - //Map<String, String> ret = th.getResources("http://xmlns.com/foaf/0.1/name","Abraham Lincoln","en"); - //System.out.println(ret); - } - - public OWLIndividual generateEntity(String clsName, Map<String, Object> values) { - OWLNamedClass owlclass = (OWLNamedClass) owlModel - .getOWLNamedClass(clsName); - - OWLIndividual inst = (OWLIndividual) owlclass.createInstance(null); - for(String key:values.keySet()){ - RDFProperty property =owlModel.getRDFProperty(key); - inst.setPropertyValue(property, values.get(key)); - - - } - - return inst; - } - - public OWLIndividual generateEntity(String clsName, String instanceName) { - OWLNamedClass owlclass = (OWLNamedClass) owlModel - .getOWLNamedClass(clsName); - - OWLIndividual inst = (OWLIndividual) owlclass.createInstance(instanceName); - - - return inst; - } - - public OWLIndividual generateEntity(String clsName, String instanceName, Map<String, Object> values) { - OWLNamedClass owlclass = (OWLNamedClass) owlModel - .getOWLNamedClass(clsName); - - OWLIndividual inst = (OWLIndividual) owlclass.createInstance(instanceName); - - for(String key:values.keySet()){ - RDFProperty property =owlModel.getRDFProperty(key); - inst.setPropertyValue(property, values.get(key)); - - - } - - return inst; - } - - public void printIndividual(OWLIndividual ind){ - Collection<RDFProperty> props = ind.getRDFProperties(); - Iterator<RDFProperty> propsIts = props.iterator(); - while(propsIts.hasNext()){ - RDFProperty prop = propsIts.next(); - System.err.println(prop.getName()+":"+ind.getPropertyValue(prop)); - } - } - - public static MetaDataHandler getInstance(){ - - if (instance==null){ - instance = new MetaDataHandler(); - } - return instance; - } - - - - -}
--- a/src/de/mpiwg/itgroup/nimanager/owl/TripleStoreHandler.java Fri Dec 02 08:37:03 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,474 +0,0 @@ -package de.mpiwg.itgroup.nimanager.owl; - -import info.aduna.iteration.Iteration; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.sql.Connection; -import java.sql.DriverManager; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.impl.ContextStatementImpl; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.StatementImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.QueryLanguage; -import org.openrdf.query.TupleQuery; -import org.openrdf.query.TupleQueryResult; -import org.openrdf.query.impl.DatasetImpl; -import org.openrdf.repository.Repository; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.RepositoryException; -import org.openrdf.repository.RepositoryResult; -import org.openrdf.repository.http.HTTPRepository; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.rdfxml.RDFXMLWriter; - -import virtuoso.sesame2.driver.VirtuosoRepository; - -import com.hp.hpl.jena.vocabulary.OWL; - -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler.Quadruple; - - -import edu.stanford.smi.protege.widget.StringListWidget; -import edu.stanford.smi.protegex.owl.model.OWLIndividual; -import edu.stanford.smi.protegex.owl.model.OWLModel; -import edu.stanford.smi.protegex.owl.model.OWLNamedClass; -import edu.stanford.smi.protegex.owl.model.RDFProperty; -import edu.stanford.smi.protegex.owl.model.RDFResource; -import edu.stanford.smi.protegex.owl.model.RDFSLiteral; -import edu.stanford.smi.protegex.owl.model.impl.AbstractRDFSClass; -import edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty; - - - -public class TripleStoreHandler { - - - public static class Quadruple { - String subj; - String pred; - Object obj; - String ctx; - - public String getSubj() { - return subj; - } - - public String getPred() { - return pred; - } - - public Object getObj() { - return obj; - } - - public String getCtx() { - return ctx; - } - - - - public Quadruple(String s, String p, String o,String c){ - subj=s; - pred=p; - obj=o; - ctx=c; - } - - - public Quadruple(String s, String p, Value o,String c){ - subj=s; - pred=p; - obj=o; - ctx=c; - } - - public String toString(){ - return String.format("%s %s %s %s.", subj,pred,obj,ctx); - } - - - } - - public static class LiteralQuadruple extends Quadruple{ - String subj; - String pred; - Object obj; - String ctx; - - public LiteralQuadruple(String s, String p, String o,String c){ - super(s,p,o,c); - - - } - - } - public static String ONTOLOGY_NS="http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/"; - private boolean save=true; // wenn false dann schreibt write nicht ins repositorium. - - private Logger logger = Logger.getRootLogger(); - - static Map<String,TripleStoreHandler> instance = new HashMap<String, TripleStoreHandler>(); - private Repository repository; - - private int counter=0; - public Connection sqlCon; - public Repository getRepository() { - return repository; - } - public void setRepository(Repository repository) { - this.repository = repository; - } - public TripleStoreHandler(String url,String username, String password) throws TripleStoreHandlerException { - //String sesameUrl="http://127.0.0.1:8180/openrdf-sesame/repositories/authorityDataPersons"; - //String sesameUrl="http://127.0.0.1:8180/openrdf-sesame/repositories/personsRepository"; - - //String sesameUrl="http://127.0.0.1:8180/openrdf-sesame/repositories/swiftowlimTest"; - // - //repository = new HTTPRepository(sesameUrl); - - - repository = new VirtuosoRepository(url, username, password); - try { - Class.forName("virtuoso.jdbc4.Driver"); - String connectString = url+"/charset=UTF-8"; - this.sqlCon = DriverManager.getConnection(connectString, username, - password); - } catch (Exception e) { - throw new TripleStoreHandlerException(); - } - } - public Map<String,Object> getJenaRDFValues(Collection props, String identifier, OWLModel model) throws RepositoryException { - identifier = identifier.replace("<", ""); - identifier = identifier.replace(">", ""); - Map<String,Object> retMap = new HashMap<String, Object>(); - - URI subj= repository.getValueFactory().createURI(identifier); - RepositoryConnection con = repository.getConnection(); - Iterator propsIterator = props.iterator(); - while(propsIterator.hasNext()){ - //for(DefaultRDFProperty prop:props){ - DefaultRDFProperty prop=(DefaultRDFProperty) propsIterator.next(); - Object newValue; - String name=prop.getName(); - //System.out.println(name); - RepositoryResult<Statement> statements = con.getStatements(subj, repository.getValueFactory().createURI(name), null, true); - //RepositoryResult<Statement> statements = con.getStatements(subj, null, null, false); - //System.out.println(statements); - statements.enableDuplicateFilter(); - while(statements.hasNext()){ - Statement sm = statements.next(); - Value val = sm.getObject(); - if (LiteralImpl.class.isInstance(val)) { // wenn ein - // string - // literal, - // dann - // uebersetze - // in jena - // string - // literal - LiteralImpl li = (LiteralImpl) val; - - newValue = model.createRDFSLiteralOrString(li.getLabel(),li.getLanguage()); - } else { // anderfalls erzeuge generische Instance - - - newValue= model.getRDFResource(val.stringValue()); - - if (newValue==null){ - OWLNamedClass owlclass = (OWLNamedClass) model - .getOWLNamedClass("http://www.w3.org/2002/07/owl#Thing"); - newValue = (OWLIndividual) owlclass.createInstance(val.stringValue()); - } - } - retMap.put(sm.getPredicate().stringValue(), newValue); - - } - } - return retMap; - - } - public Map<String,String> getResources(String subj, String pred, String obj, String lang) throws RepositoryException { - - Map<String,String> retMap = new HashMap<String, String>(); - RepositoryConnection con = repository.getConnection(); - RepositoryResult<Statement> statements = con.getStatements(repository.getValueFactory().createURI(subj), repository.getValueFactory().createURI(pred), repository.getValueFactory().createLiteral(obj, lang), true); - statements.enableDuplicateFilter(); - while(statements.hasNext()){ - Statement sm = statements.next(); - retMap.put(sm.getSubject().stringValue(), sm.getObject().stringValue()); - - } - - return retMap; - } - - public TupleQueryResult querySPARQL(String queryString) throws MalformedQueryException, QueryEvaluationException, TripleStoreHandlerException{ - TupleQuery tupleQuery; - try { - tupleQuery = repository.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString); - } catch (RepositoryException e) { - // possible a time out - //wait a bit - try { - Thread.sleep(10000); - //try again - tupleQuery = repository.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString); - } catch (InterruptedException e1) { - e1.printStackTrace(); - throw new TripleStoreHandlerException(); - } catch (RepositoryException e2) { - try { - //ok try ones more - Thread.sleep(10000); - tupleQuery = repository.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString); - } catch (InterruptedException e1) { - e1.printStackTrace(); - throw new TripleStoreHandlerException(); - } catch (RepositoryException e3) { - e.printStackTrace(); - throw new TripleStoreHandlerException(); - - } - } - } - return tupleQuery.evaluate(); - - } - - public TupleQueryResult querySPARQL(String queryString,String context) throws RepositoryException, MalformedQueryException, QueryEvaluationException{ - TupleQuery tupleQuery = repository.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString); - DatasetImpl ds = new DatasetImpl(); - ds.addNamedGraph(createUri(repository,context)); - tupleQuery.setDataset(ds); - return tupleQuery.evaluate(); - - } - public RepositoryResult<Statement> getStatements(String subj,String pred, String obj) throws RepositoryException { - RepositoryConnection con = repository.getConnection(); - - RepositoryResult<Statement> statements = con.getStatements(createUri(repository,subj), createUri(repository,pred), createUri(repository,obj), true); - - - return statements; - } - - public RepositoryResult<Statement> getStatements(String subj,String pred, String obj, String ctx) throws RepositoryException { - RepositoryConnection con = repository.getConnection(); - - RepositoryResult<Statement> statements = con.getStatements(createUri(repository,subj), createUri(repository,pred), createUri(repository,obj), true, createUri(repository, ctx)); - - - return statements; - } - - public RepositoryResult<Statement> getStatements(Resource subj,URI pred, Value obj, String ctx) throws RepositoryException { - RepositoryConnection con = repository.getConnection(); - - RepositoryResult<Statement> statements = con.getStatements(subj, pred, obj, true, createUri(repository, ctx)); - - - return statements; - } - - public URI createUri(String subj){ - return createUri(repository, subj); - } - - public Value createLiteral(String subj){ - return repository.getValueFactory().createLiteral(subj); - } - - public Value createLiteral(String subj, String lang){ - return repository.getValueFactory().createLiteral(subj,lang); - } - - - public static URI createUri(Repository repository2, String subj) { - if (subj==null) - return null; - return repository2.getValueFactory().createURI(subj); - - } - public static Statement getFirstStatement( - RepositoryResult<Statement> namesStatements) throws RepositoryException { - while(namesStatements.hasNext()){ - return namesStatements.next(); - } - - return null; - } - public void write(OWLIndividual ent,String ctx) throws RepositoryException, TripleStoreHandlerException { - - - String ident = ent.getURI(); -// Iterator<Object> types = ent.getRDFTypes().iterator(); -// -// while(types.hasNext()){ -// -// Object typeObj=types.next(); -// AbstractRDFSClass type = (AbstractRDFSClass)typeObj; -// -// -// write(ident,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",type.getURI()); -// } - - Iterator<RDFProperty> props=ent.getPossibleRDFProperties().iterator(); - while(props.hasNext()){ - RDFProperty prop=props.next(); - Object val = ent.getPropertyValue(prop); - if (val==null){ // nicht belegter wert - continue; - } - if (RDFSLiteral.class.isInstance(val)){ - RDFSLiteral lit = (RDFSLiteral)val; - String lang = lit.getLanguage(); - String litobj = lit.getString(); - Value newLit=null; - if(lang!=null){ - newLit=repository.getValueFactory().createLiteral((String)lit.getString(), lang); - } else { - newLit=repository.getValueFactory().createLiteral((String)litobj); - - - } - write(ident, prop.getURI(), newLit, ctx); - } else if(OWLIndividual.class.isInstance(val)){ - OWLIndividual ind = (OWLIndividual)val; - write(ident, prop.getURI(), repository.getValueFactory().createURI(ind.getURI()),ctx); - } else if (AbstractRDFSClass.class.isInstance(val)){ - AbstractRDFSClass ind = (AbstractRDFSClass)val; - write(ident, prop.getURI(), repository.getValueFactory().createURI(ind.getURI()),ctx); - } else if (String.class.isInstance(val)){ - write(ident, prop.getURI(), repository.getValueFactory().createLiteral((String)val),ctx); - } else { - //don't now this type - throw new TripleStoreHandlerException(); - } - - } - - } - public OWLIndividual getProvider(MetaDataHandler mh, String providerUri) throws RepositoryException { - RepositoryConnection con = repository.getConnection(); - URI createURIProvider = repository.getValueFactory().createURI(ONTOLOGY_NS+"NamedEntityProvider"); - - RepositoryResult<Statement> provider = con.getStatements(repository.getValueFactory().createURI(providerUri), repository.getValueFactory().createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), createURIProvider, true); - Statement providerStatement = getFirstStatement(provider); - if(providerStatement==null) // provider does not exist - return null; - - - Map<String, Object> values = getJenaRDFValues(mh.getAssociatedPropsForClass(createURIProvider.stringValue()),providerUri,mh.getOwlModel()); - OWLIndividual providerEnt = mh.generateEntity(createURIProvider.stringValue(), providerUri,values); - - return providerEnt; - } - - public void write(String subj, String pred, String obj,String ctx) throws RepositoryException { - Value ob; - RepositoryConnection con = repository.getConnection(); - ob=repository.getValueFactory().createURI(obj); - Statement statement = new ContextStatementImpl(repository.getValueFactory().createURI(subj), repository.getValueFactory().createURI(pred), ob,repository.getValueFactory().createURI(ctx)); - logger.debug("Write to triple store:"+subj+":"+pred+":"+obj); - logger.debug("Wrote statement:"); - counter+=1; - logger.debug(counter); - if (save){ - con.add(statement); - con.commit(); - con.close(); - } - } - - public void write(String subj, String pred, Value obj, String ctx) throws RepositoryException { - - RepositoryConnection con = repository.getConnection(); - Statement statement = new ContextStatementImpl(repository.getValueFactory().createURI(subj), repository.getValueFactory().createURI(pred), obj,repository.getValueFactory().createURI(ctx)); - if(LiteralImpl.class.isInstance(obj)){ - logger.debug("Write to triple store:"+subj+":"+pred+":"+((LiteralImpl)obj).stringValue()); - } else - logger.debug("Write to triple store:"+subj+":"+pred+":"+obj.toString()); - - logger.debug("Wrote statement:"); - counter+=1; - logger.debug(counter); - - if (save){ - con.add(statement); - con.commit(); - con.close(); - } - } - - public void write(Quadruple q) throws RepositoryException{ - if (LiteralQuadruple.class.isInstance(q)){ - write(q.getSubj(),q.getPred(),createLiteral((String)q.getObj()),q.getCtx()); - } else { - if (String.class.isInstance(q.getObj())){ - write(q.getSubj(),q.getPred(),(String)q.getObj(),q.getCtx());} - else { - write(q.getSubj(),q.getPred(),(Value)q.getObj(),q.getCtx());} - - } - } - - public void write(List<Quadruple> annots) throws RepositoryException { - for(Quadruple q:annots){ - write(q); - } - - } - public void exportCtx(String ctx, File file) throws RepositoryException, RDFHandlerException, IOException{ - - RepositoryConnection conn = repository.getConnection(); - OutputStream output = (file != null) ? new FileOutputStream(file) : System.out; - - RDFXMLWriter rdfxmlfWriter = new RDFXMLWriter(output); - //conn.export(rdfxmlfWriter, repository.getValueFactory().createURI(ctx)); - conn.exportStatements(null, null, null, true, rdfxmlfWriter, repository.getValueFactory().createURI(ctx)); - output.write('\n'); - conn.close(); - } - - - public static void main(String args[]) throws RepositoryException, RDFHandlerException, IOException, TripleStoreHandlerException{ - TripleStoreHandler th = new TripleStoreHandler("jdbc:virtuoso://virtuoso.mpiwg-berlin.mpg.de:1111", "dba", "dba"); - //th.exportCtx("http://import", new File("/tmp/out.rdf")); - // - th.exportCtx("file://out.owl", new File("/tmp/out2.rdf")); - - } - - - public static TripleStoreHandler getInstance(String url, String user, String password) throws TripleStoreHandlerException{ - - String identString=url+"_"+user+"_"+password; - - if (instance.get(identString)==null){ - instance.put(identString, new TripleStoreHandler(url,user,password)); - } - TripleStoreHandler th= instance.get(identString); - return th; - } -}
--- a/src/de/mpiwg/itgroup/nimanager/owl/Util.java Fri Dec 02 08:37:03 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -package de.mpiwg.itgroup.nimanager.owl; - -import java.util.Map; - -import edu.stanford.smi.protegex.owl.model.RDFSLiteral; - -public class Util { - - public static String rdf2xml(Map<String, Object> values) { - String ret="<properties>\n"; - for(String tagName:values.keySet()){ - - if (RDFSLiteral.class.isInstance(values.get(tagName))){ - String value = ((RDFSLiteral)values.get(tagName)).getString(); - String fTagName = rdfPredToTagNS(tagName); - ret+=String.format("<%s>%s</%s>\n", fTagName,value,rdfPredToTag(tagName)); - - } - } - ret+="</properties>"; - - return ret; - } - - public static String rdfPredToTagNS (String pred){ - String[] splitted= pred.split("/|#"); - String ns=""; - - for (int i=0; i<splitted.length-1;i++){ - if(i!=0) - ns+="/"; - ns+=splitted[i]; - } - - return String.format("%s xmlns=\"%s\"",splitted[splitted.length-1],ns); - } - - public static String rdfPredToTag (String pred){ - String[] splitted= pred.split("/|#"); - - - return splitted[splitted.length-1]; - } -}
--- a/src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java Tue Dec 13 17:46:51 2011 +0100 @@ -25,9 +25,11 @@ import org.restlet.resource.Options; import org.restlet.resource.ServerResource; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; + import virtuoso.jdbc4.VirtuosoResultSet; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; + public class PersonByNameService extends ServerResource {
--- a/src/de/mpiwg/itgroup/nimanager/persons/PersonListService.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/persons/PersonListService.java Tue Dec 13 17:46:51 2011 +0100 @@ -6,8 +6,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ArrayBlockingQueue; import org.apache.log4j.Logger; import org.apache.lucene.analysis.standard.StandardAnalyzer; @@ -21,30 +19,17 @@ import org.apache.lucene.store.FSDirectory; import org.apache.lucene.util.Version; import org.json.JSONArray; -import org.json.JSONException; -import org.omg.CORBA.Request; -import org.openrdf.model.Statement; -import org.openrdf.repository.RepositoryException; -import org.openrdf.repository.RepositoryResult; import org.restlet.Context; import org.restlet.data.Form; import org.restlet.data.MediaType; -import org.restlet.data.Status; import org.restlet.engine.component.ChildContext; import org.restlet.ext.json.JsonRepresentation; import org.restlet.representation.Representation; import org.restlet.representation.StringRepresentation; import org.restlet.resource.Get; import org.restlet.resource.Options; -import org.restlet.resource.Post; import org.restlet.resource.ServerResource; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.luceneIndices.Importer; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; - -import edu.stanford.smi.protegex.owl.swrl.bridge.exceptions.MapperException; - public class PersonListService extends ServerResource { //private String tripleIndexPath="/Users/dwinter/Documents/Projekte/ECHO-eSciDoc-MPDL/escidocMPIWG/NamedIdentityManager/data/tripleIndex";
--- a/src/de/mpiwg/itgroup/nimanager/persons/PersonService.java Fri Dec 02 08:37:03 2011 +0100 +++ b/src/de/mpiwg/itgroup/nimanager/persons/PersonService.java Tue Dec 13 17:46:51 2011 +0100 @@ -23,11 +23,14 @@ import org.restlet.resource.ServerResource; import org.restlet.resource.Get; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; + import de.mpiwg.itgroup.nimanager.luceneIndices.Importer; -import de.mpiwg.itgroup.nimanager.owl.MetaDataHandler; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; -import de.mpiwg.itgroup.nimanager.owl.Util; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.MetaDataHandler; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; +import de.mpiwg.itgroup.triplestoremanager.owl.Util; + + public class PersonService extends ServerResource { private String NAMED_ENTITIES_ONTOLOGIE_URL = "http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities"; @@ -126,9 +129,9 @@ * different modes : * *Indizierte alle werte des triples mit "personId" - *Im Body kann eine Liste von Predicate Ÿbegeben werden die indiziert werden sollen und sich im triplestore befinden mŸssen. - * Wird kein body Ÿbergeben ist das predicate="http://xmlns.com/foaf/0.1/name". - * Wird graphId zusŠtzlich Ÿbergeben, wird der Eintrag aus diesem Graphen indiziert, default ist: "file://newpersonsFromProjects" + *Im Body kann eine Liste von Predicate �begeben werden die indiziert werden sollen und sich im triplestore befinden m�ssen. + * Wird kein body �bergeben ist das predicate="http://xmlns.com/foaf/0.1/name". + * Wird graphId zus�tzlich �bergeben, wird der Eintrag aus diesem Graphen indiziert, default ist: "file://newpersonsFromProjects" * @param entity * @return */