MARMOTTA-556: added basic ldf metadata
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/30d351dc Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/30d351dc Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/30d351dc Branch: refs/heads/MARMOTTA-556 Commit: 30d351dc62b2a1063cc2ded881a26bd2ed852ccc Parents: d0dbb7d Author: Sergio Fernández <[email protected]> Authored: Fri Oct 24 19:41:18 2014 +0200 Committer: Sergio Fernández <[email protected]> Committed: Fri Oct 24 19:41:18 2014 +0200 ---------------------------------------------------------------------- .../marmotta/platform/ldf/api/LdfService.java | 11 +- .../platform/ldf/services/LdfServiceImpl.java | 4 +- .../platform/ldf/sesame/LdfRDFHandler.java | 179 ++++++ .../platform/ldf/sesame/PagedRDFHandler.java | 114 ---- .../marmotta/platform/ldf/vocab/HYDRA.java | 600 +++++++++++++++++++ .../marmotta/platform/ldf/vocab/VOID.java | 435 ++++++++++++++ 6 files changed, 1221 insertions(+), 122 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/api/LdfService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/api/LdfService.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/api/LdfService.java index 2d7e3e2..c0a9876 100644 --- a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/api/LdfService.java +++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/api/LdfService.java @@ -1,9 +1,3 @@ -package org.apache.marmotta.platform.ldf.api; - -import org.openrdf.model.Model; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.rio.RDFFormat; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,6 +15,11 @@ import org.openrdf.rio.RDFFormat; * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.marmotta.platform.ldf.api; + +import org.openrdf.model.Resource; +import org.openrdf.model.URI; +import org.openrdf.rio.RDFFormat; import org.openrdf.model.Value; import org.openrdf.repository.RepositoryException; http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java index 49ca8ff..f9e1ea5 100644 --- a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java +++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/services/LdfServiceImpl.java @@ -20,7 +20,7 @@ package org.apache.marmotta.platform.ldf.services; import org.apache.marmotta.commons.sesame.repository.ResultUtils; import org.apache.marmotta.platform.core.api.triplestore.SesameService; import org.apache.marmotta.platform.ldf.api.LdfService; -import org.apache.marmotta.platform.ldf.sesame.PagedRDFHandler; +import org.apache.marmotta.platform.ldf.sesame.LdfRDFHandler; import org.openrdf.model.*; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.RepositoryException; @@ -51,7 +51,7 @@ public class LdfServiceImpl implements LdfService { try { conn.begin(); RepositoryResult<Statement> statements = conn.getStatements(subject, predicate, object, true, context); - RDFHandler handler = new PagedRDFHandler(Rio.createWriter(format, out), offset, limit); + RDFHandler handler = new LdfRDFHandler(Rio.createWriter(format, out), context, offset, limit); Rio.write(ResultUtils.iterable(statements), handler); } catch (RDFHandlerException e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/LdfRDFHandler.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/LdfRDFHandler.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/LdfRDFHandler.java new file mode 100644 index 0000000..dcafb3a --- /dev/null +++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/LdfRDFHandler.java @@ -0,0 +1,179 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.marmotta.platform.ldf.sesame; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import org.apache.marmotta.commons.vocabulary.XSD; +import org.apache.marmotta.platform.ldf.vocab.HYDRA; +import org.apache.marmotta.platform.ldf.vocab.VOID; +import org.openrdf.model.Literal; +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.model.impl.StatementImpl; +import org.openrdf.model.impl.ValueFactoryImpl; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.rio.RDFHandler; +import org.openrdf.rio.RDFHandlerException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * Specialized statements handler doing some LDF specific thing, + * such as paging or metadata generation, before sending them to + * the delegated RDFHandler. + * + * (TODO: find a more performance solution) + * + * @author Sergio Fernández + */ +public class LdfRDFHandler implements RDFHandler { + + public final static int PAGE_SIZE = 100; + + private List<Statement> statements; + private final RDFHandler handler; + private final Resource context; + private final int page; + + /** + * Constructs a PagedRDFHandler with a delegate handler + * + * @param handler The handler to delegate the calls to + */ + public LdfRDFHandler(RDFHandler handler) { + this(handler, null, 1); + } + + /** + * Constructs a PagedRDFHandler with a delegate handler + * + * @param handler The handler to delegate the calls to + * @param page number of page (starting with 1) + */ + public LdfRDFHandler(RDFHandler handler, int page) { + this(handler, null, page); + } + + /** + * Constructs a PagedRDFHandler with a delegate handler + * + * @param handler The handler to delegate the calls to + * @param context dataset + */ + public LdfRDFHandler(RDFHandler handler, Resource context) { + this(handler, context, 1); + } + + /** + * Constructs a PagedRDFHandler with a delegate handler + * + * @param handler The handler to delegate the calls to + * @param context dataset + * @param page number of page (starting with 1) + */ + public LdfRDFHandler(RDFHandler handler, Resource context, int page) { + super(); + this.statements = new ArrayList<>(); + this.handler = handler; + this.context = context; + this.page = page; + } + + @Override + public void startRDF() throws RDFHandlerException { + handler.startRDF(); + } + + @Override + public void endRDF() throws RDFHandlerException { + //first order by a fixed criteria + Collections.sort(statements, new Comparator<Statement>() { + @Override + public int compare(Statement s1, Statement s2) { + int subjectComparison = s1.getSubject().stringValue().compareTo(s2.getSubject().stringValue()); + int predicatedComparison = s1.getPredicate().stringValue().compareTo(s2.getPredicate().stringValue()); + if (subjectComparison != 0) { + return subjectComparison; + } else if (predicatedComparison != 0) { + return predicatedComparison; + } else if((s1.getObject() instanceof Literal) && (s2.getObject() instanceof Resource)) { + return 1; + } else if((s1.getObject() instanceof Resource) && (s2.getObject() instanceof Literal)) { + return -1; + } else { + return s1.getObject().stringValue().compareTo(s2.getObject().stringValue()); + } + } + }); + + //then filter + final int size = statements.size(); + final int offset = PAGE_SIZE * (page - 1); + if (offset > size) { + throw new IllegalArgumentException("page " + page + " can't be generated"); + } + final int limit = PAGE_SIZE < size-offset ? PAGE_SIZE : size-offset; + List<Statement> filteredStatements = statements.subList(offset, limit); + + //send statements to delegate writer + for (Statement statement : filteredStatements) { + handler.handleStatement(statement); + } + + //add ldf metadata + final ValueFactoryImpl vf = new ValueFactoryImpl(); + + Resource dataset = this.context != null ? this.context : vf.createBNode(); + handler.handleStatement(new StatementImpl(dataset, RDF.TYPE, VOID.Dataset)); + handler.handleStatement(new StatementImpl(dataset, RDF.TYPE, HYDRA.Collection)); + + Resource fragment = vf.createBNode(); //TODO + handler.handleStatement(new StatementImpl(dataset, VOID.subset, fragment)); + handler.handleStatement(new StatementImpl(fragment, RDF.TYPE, HYDRA.Collection)); + if (offset != 0 && limit != size) handler.handleStatement(new StatementImpl(fragment, RDF.TYPE, HYDRA.PagedCollection)); + handler.handleStatement(new StatementImpl(fragment, VOID.triples, vf.createLiteral(Integer.toString(filteredStatements.size()), XSD.Integer))); + handler.handleStatement(new StatementImpl(fragment, HYDRA.totalItems, vf.createLiteral(Integer.toString(filteredStatements.size()), XSD.Integer))); + handler.handleStatement(new StatementImpl(fragment, HYDRA.itemsPerPage, vf.createLiteral(Integer.toString(PAGE_SIZE), XSD.Integer))); + //TODO: HYDRA_FIRSTPAGE, HYDRA_PREVIOUSPAGE, HYDRA_NEXTPAGE + + //TODO: hydra controls + + //and actually end the rdf + handler.endRDF(); + } + + @Override + public void handleNamespace(String prefix, String uri) throws RDFHandlerException { + handler.handleNamespace(prefix, uri); + } + + @Override + public void handleStatement(Statement statement) throws RDFHandlerException { + statements.add(statement); + } + + @Override + public void handleComment(String comment) throws RDFHandlerException { + handler.handleComment(comment); + } + +} http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/PagedRDFHandler.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/PagedRDFHandler.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/PagedRDFHandler.java deleted file mode 100644 index 36f59cf..0000000 --- a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/sesame/PagedRDFHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.marmotta.platform.ldf.sesame; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.openrdf.model.Literal; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.rio.RDFHandler; -import org.openrdf.rio.RDFHandlerException; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * Paginates statements before sending them to the delegated RDFHandler. - * (TODO: find a more performance solution) - * - * @author Sergio Fernández - */ -public class PagedRDFHandler implements RDFHandler { - - private List<Statement> statements; - private RDFHandler handler; - private int offset; - private int limit; - - /** - * Constructs a PagedRDFHandler with a delegate handler - * - * @param handler The handler to delegate the calls to - */ - public PagedRDFHandler(RDFHandler handler, int offset, int limit) { - super(); - this.statements = new ArrayList<>(); - this.handler = handler; - this.offset = offset; - this.limit = limit; - } - - @Override - public void startRDF() throws RDFHandlerException { - handler.startRDF(); - } - - @Override - public void endRDF() throws RDFHandlerException { - //first order by a fixed criteria - Collections.sort(statements, new Comparator<Statement>() { - @Override - public int compare(Statement s1, Statement s2) { - int subjectComparison = s1.getSubject().stringValue().compareTo(s2.getSubject().stringValue()); - int predicatedComparison = s1.getPredicate().stringValue().compareTo(s2.getPredicate().stringValue()); - - if (subjectComparison != 0) { - return subjectComparison; - } else if (predicatedComparison != 0) { - return predicatedComparison; - } else if((s1.getObject() instanceof Literal) && (s2.getObject() instanceof Resource)) { - return 1; - } else if((s1.getObject() instanceof Resource) && (s2.getObject() instanceof Literal)) { - return -1; - } else { - return s1.getObject().stringValue().compareTo(s2.getObject().stringValue()); - } - } - }); - - //then filter - List<Statement> filteredStatements = Lists.newArrayList(Iterables.limit(statements, 20)); - - //send statements to delegate writer - for (Statement statement : filteredStatements) { - handler.handleStatement(statement); - } - - //and actually end the rdf - handler.endRDF(); - } - - @Override - public void handleNamespace(String prefix, String uri) throws RDFHandlerException { - handler.handleNamespace(prefix, uri); - } - - @Override - public void handleStatement(Statement statement) throws RDFHandlerException { - statements.add(statement); - } - - @Override - public void handleComment(String comment) throws RDFHandlerException { - handler.handleComment(comment); - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/HYDRA.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/HYDRA.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/HYDRA.java new file mode 100644 index 0000000..3bc261d --- /dev/null +++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/HYDRA.java @@ -0,0 +1,600 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.marmotta.platform.ldf.vocab; + +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.ValueFactoryImpl; + +/** + * Namespace Hydra. + * Prefix: {@code <http://www.w3.org/ns/hydra/core#>} + */ +public class HYDRA { + + /** {@code http://www.w3.org/ns/hydra/core#} **/ + public static final String NAMESPACE = "http://www.w3.org/ns/hydra/core#"; + + /** {@code hydra} **/ + public static final String PREFIX = "hydra"; + + /** + * ApiDocumentation + * <p> + * {@code http://www.w3.org/ns/hydra/core#ApiDocumentation}. + * <p> + * The Hydra API documentation class + * + * @see <a href="http://www.w3.org/ns/hydra/core#ApiDocumentation">ApiDocumentation</a> + */ + public static final URI ApiDocumentation; + + /** + * apiDocumentation + * <p> + * {@code http://www.w3.org/ns/hydra/core#apiDocumentation}. + * <p> + * A link to the API documentation + * + * @see <a href="http://www.w3.org/ns/hydra/core#apiDocumentation">apiDocumentation</a> + */ + public static final URI apiDocumentation; + + /** + * Hydra Class + * <p> + * {@code http://www.w3.org/ns/hydra/core#Class}. + * <p> + * The class of Hydra classes. Hydra classes and their instances are + * dereferenceable resources. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Class">Class</a> + */ + public static final URI Class; + + /** + * Collection + * <p> + * {@code http://www.w3.org/ns/hydra/core#Collection}. + * <p> + * A collection holding references to a number of related resources. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Collection">Collection</a> + */ + public static final URI Collection; + + /** + * CreateResourceOperation + * <p> + * {@code http://www.w3.org/ns/hydra/core#CreateResourceOperation}. + * <p> + * A CreateResourceOperation is a HTTP operation which expects an input + * of the type specified by hydra:expects and creates a resource of the + * type specified by hydra:returns. + * + * @see <a href="http://www.w3.org/ns/hydra/core#CreateResourceOperation">CreateResourceOperation</a> + */ + public static final URI CreateResourceOperation; + + /** + * DeleteResourceOperation + * <p> + * {@code http://www.w3.org/ns/hydra/core#DeleteResourceOperation}. + * <p> + * A DeleteResourceOperation is a HTTP operation that deletes a resource. + * + * @see <a href="http://www.w3.org/ns/hydra/core#DeleteResourceOperation">DeleteResourceOperation</a> + */ + public static final URI DeleteResourceOperation; + + /** + * description + * <p> + * {@code http://www.w3.org/ns/hydra/core#description}. + * <p> + * A description. + * + * @see <a href="http://www.w3.org/ns/hydra/core#description">description</a> + */ + public static final URI description; + + /** + * entrypoint + * <p> + * {@code http://www.w3.org/ns/hydra/core#entrypoint}. + * <p> + * A link to main entry point of the Web API + * + * @see <a href="http://www.w3.org/ns/hydra/core#entrypoint">entrypoint</a> + */ + public static final URI entrypoint; + + /** + * Error + * <p> + * {@code http://www.w3.org/ns/hydra/core#Error}. + * <p> + * A runtime error, used to report information beyond the returned status + * code. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Error">Error</a> + */ + public static final URI Error; + + /** + * expects + * <p> + * {@code http://www.w3.org/ns/hydra/core#expects}. + * <p> + * The information expected by the Web API. + * + * @see <a href="http://www.w3.org/ns/hydra/core#expects">expects</a> + */ + public static final URI expects; + + /** + * first page + * <p> + * {@code http://www.w3.org/ns/hydra/core#firstPage}. + * <p> + * The first page of an interlinked set of PagedCollections + * + * @see <a href="http://www.w3.org/ns/hydra/core#firstPage">firstPage</a> + */ + public static final URI firstPage; + + /** + * freetext query + * <p> + * {@code http://www.w3.org/ns/hydra/core#freetextQuery}. + * <p> + * A property representing a freetext query. + * + * @see <a href="http://www.w3.org/ns/hydra/core#freetextQuery">freetextQuery</a> + */ + public static final URI freetextQuery; + + /** + * IRI Template + * <p> + * {@code http://www.w3.org/ns/hydra/core#IriTemplate}. + * <p> + * The class of IRI templates. + * + * @see <a href="http://www.w3.org/ns/hydra/core#IriTemplate">IriTemplate</a> + */ + public static final URI IriTemplate; + + /** + * IriTemplateMapping + * <p> + * {@code http://www.w3.org/ns/hydra/core#IriTemplateMapping}. + * <p> + * A mapping from an IRI template variable to a property. + * + * @see <a href="http://www.w3.org/ns/hydra/core#IriTemplateMapping">IriTemplateMapping</a> + */ + public static final URI IriTemplateMapping; + + /** + * items per page + * <p> + * {@code http://www.w3.org/ns/hydra/core#itemsPerPage}. + * <p> + * The maximum number of items referenced by each single PagedCollection + * in a set of interlinked PagedCollections. + * + * @see <a href="http://www.w3.org/ns/hydra/core#itemsPerPage">itemsPerPage</a> + */ + public static final URI itemsPerPage; + + /** + * last page + * <p> + * {@code http://www.w3.org/ns/hydra/core#lastPage}. + * <p> + * The last page of an interlinked set of PagedCollections + * + * @see <a href="http://www.w3.org/ns/hydra/core#lastPage">lastPage</a> + */ + public static final URI lastPage; + + /** + * Link + * <p> + * {@code http://www.w3.org/ns/hydra/core#Link}. + * <p> + * The class of properties representing links. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Link">Link</a> + */ + public static final URI Link; + + /** + * mapping + * <p> + * {@code http://www.w3.org/ns/hydra/core#mapping}. + * <p> + * A variable-to-property mapping of the IRI template. + * + * @see <a href="http://www.w3.org/ns/hydra/core#mapping">mapping</a> + */ + public static final URI mapping; + + /** + * member + * <p> + * {@code http://www.w3.org/ns/hydra/core#member}. + * <p> + * A member of the collection + * + * @see <a href="http://www.w3.org/ns/hydra/core#member">member</a> + */ + public static final URI member; + + /** + * method + * <p> + * {@code http://www.w3.org/ns/hydra/core#method}. + * <p> + * The HTTP method. + * + * @see <a href="http://www.w3.org/ns/hydra/core#method">method</a> + */ + public static final URI method; + + /** + * next page + * <p> + * {@code http://www.w3.org/ns/hydra/core#nextPage}. + * <p> + * The page following the current instance in an interlinked set of + * PagedCollections + * + * @see <a href="http://www.w3.org/ns/hydra/core#nextPage">nextPage</a> + */ + public static final URI nextPage; + + /** + * Operation + * <p> + * {@code http://www.w3.org/ns/hydra/core#Operation}. + * <p> + * An operation. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Operation">Operation</a> + */ + public static final URI Operation; + + /** + * operation + * <p> + * {@code http://www.w3.org/ns/hydra/core#operation}. + * <p> + * An operation supported by the Hydra resource + * + * @see <a href="http://www.w3.org/ns/hydra/core#operation">operation</a> + */ + public static final URI operation; + + /** + * PagedCollection + * <p> + * {@code http://www.w3.org/ns/hydra/core#PagedCollection}. + * <p> + * A PagedCollection is a subclass of Collection with the only difference + * that its members are sorted and only a subset of all members are + * returned in a single PagedCollection. To get the other members, the + * nextPage/previousPage properties have to be used. + * + * @see <a href="http://www.w3.org/ns/hydra/core#PagedCollection">PagedCollection</a> + */ + public static final URI PagedCollection; + + /** + * previous page + * <p> + * {@code http://www.w3.org/ns/hydra/core#previousPage}. + * <p> + * The page preceding the current instance in an interlinked set of + * PagedCollections + * + * @see <a href="http://www.w3.org/ns/hydra/core#previousPage">previousPage</a> + */ + public static final URI previousPage; + + /** + * property + * <p> + * {@code http://www.w3.org/ns/hydra/core#property}. + * <p> + * A property + * + * @see <a href="http://www.w3.org/ns/hydra/core#property">property</a> + */ + public static final URI property; + + /** + * ready-only + * <p> + * {@code http://www.w3.org/ns/hydra/core#readonly}. + * <p> + * True if the property is read-only, false otherwise. + * + * @see <a href="http://www.w3.org/ns/hydra/core#readonly">readonly</a> + */ + public static final URI readonly; + + /** + * ReplaceResourceOperation + * <p> + * {@code http://www.w3.org/ns/hydra/core#ReplaceResourceOperation}. + * <p> + * A ReplaceResourceOperation is a HTTP operation which overwrites a + * resource. It expects data of the type specified in hydra:expects and + * results in a resource of the type specified by hydra:returns. + * + * @see <a href="http://www.w3.org/ns/hydra/core#ReplaceResourceOperation">ReplaceResourceOperation</a> + */ + public static final URI ReplaceResourceOperation; + + /** + * required + * <p> + * {@code http://www.w3.org/ns/hydra/core#required}. + * <p> + * True if the property is required, false otherwise. + * + * @see <a href="http://www.w3.org/ns/hydra/core#required">required</a> + */ + public static final URI required; + + /** + * Hydra Resource + * <p> + * {@code http://www.w3.org/ns/hydra/core#Resource}. + * <p> + * The class of dereferenceable resources. + * + * @see <a href="http://www.w3.org/ns/hydra/core#Resource">Resource</a> + */ + public static final URI Resource; + + /** + * returns + * <p> + * {@code http://www.w3.org/ns/hydra/core#returns}. + * <p> + * The information returned by the Web API on success + * + * @see <a href="http://www.w3.org/ns/hydra/core#returns">returns</a> + */ + public static final URI returns; + + /** + * search + * <p> + * {@code http://www.w3.org/ns/hydra/core#search}. + * <p> + * A IRI template that can be used to query a collection + * + * @see <a href="http://www.w3.org/ns/hydra/core#search">search</a> + */ + public static final URI search; + + /** + * status code + * <p> + * {@code http://www.w3.org/ns/hydra/core#statusCode}. + * <p> + * The HTTP status code + * + * @see <a href="http://www.w3.org/ns/hydra/core#statusCode">statusCode</a> + */ + public static final URI statusCode; + + /** + * Status code description + * <p> + * {@code http://www.w3.org/ns/hydra/core#StatusCodeDescription}. + * <p> + * Additional information about a status code that might be returned. + * + * @see <a href="http://www.w3.org/ns/hydra/core#StatusCodeDescription">StatusCodeDescription</a> + */ + public static final URI StatusCodeDescription; + + /** + * status codes + * <p> + * {@code http://www.w3.org/ns/hydra/core#statusCodes}. + * <p> + * Additional information about status codes that might be returned by + * the Web API + * + * @see <a href="http://www.w3.org/ns/hydra/core#statusCodes">statusCodes</a> + */ + public static final URI statusCodes; + + /** + * supported classes + * <p> + * {@code http://www.w3.org/ns/hydra/core#supportedClass}. + * <p> + * A class known to be supported by the Web API + * + * @see <a href="http://www.w3.org/ns/hydra/core#supportedClass">supportedClass</a> + */ + public static final URI supportedClass; + + /** + * supported operation + * <p> + * {@code http://www.w3.org/ns/hydra/core#supportedOperation}. + * <p> + * An operation supported by instances of the specific Hydra class or the + * target of the Hydra link + * + * @see <a href="http://www.w3.org/ns/hydra/core#supportedOperation">supportedOperation</a> + */ + public static final URI supportedOperation; + + /** + * supported properties + * <p> + * {@code http://www.w3.org/ns/hydra/core#supportedProperty}. + * <p> + * The properties known to be supported by a Hydra class + * + * @see <a href="http://www.w3.org/ns/hydra/core#supportedProperty">supportedProperty</a> + */ + public static final URI supportedProperty; + + /** + * Supported Property + * <p> + * {@code http://www.w3.org/ns/hydra/core#SupportedProperty}. + * <p> + * A property known to be supported by a Hydra class. + * + * @see <a href="http://www.w3.org/ns/hydra/core#SupportedProperty">SupportedProperty</a> + */ + public static final URI SupportedProperty; + + /** + * template + * <p> + * {@code http://www.w3.org/ns/hydra/core#template}. + * <p> + * An IRI template as defined by RFC6570. + * + * @see <a href="http://www.w3.org/ns/hydra/core#template">template</a> + */ + public static final URI template; + + /** + * Templated Link + * <p> + * {@code http://www.w3.org/ns/hydra/core#TemplatedLink}. + * <p> + * A templated link. + * + * @see <a href="http://www.w3.org/ns/hydra/core#TemplatedLink">TemplatedLink</a> + */ + public static final URI TemplatedLink; + + /** + * title + * <p> + * {@code http://www.w3.org/ns/hydra/core#title}. + * <p> + * A title, often used along with a description. + * + * @see <a href="http://www.w3.org/ns/hydra/core#title">title</a> + */ + public static final URI title; + + /** + * total items + * <p> + * {@code http://www.w3.org/ns/hydra/core#totalItems}. + * <p> + * The total number of items referenced by a collection or a set of + * interlinked PagedCollections. + * + * @see <a href="http://www.w3.org/ns/hydra/core#totalItems">totalItems</a> + */ + public static final URI totalItems; + + /** + * variable + * <p> + * {@code http://www.w3.org/ns/hydra/core#variable}. + * <p> + * An IRI template variable + * + * @see <a href="http://www.w3.org/ns/hydra/core#variable">variable</a> + */ + public static final URI variable; + + /** + * write-only + * <p> + * {@code http://www.w3.org/ns/hydra/core#writeonly}. + * <p> + * True if the property is write-only, false otherwise. + * + * @see <a href="http://www.w3.org/ns/hydra/core#writeonly">writeonly</a> + */ + public static final URI writeonly; + + static { + ValueFactory factory = ValueFactoryImpl.getInstance(); + + ApiDocumentation = factory.createURI(HYDRA.NAMESPACE, "ApiDocumentation"); + apiDocumentation = factory.createURI(HYDRA.NAMESPACE, "apiDocumentation"); + Class = factory.createURI(HYDRA.NAMESPACE, "Class"); + Collection = factory.createURI(HYDRA.NAMESPACE, "Collection"); + CreateResourceOperation = factory.createURI(HYDRA.NAMESPACE, "CreateResourceOperation"); + DeleteResourceOperation = factory.createURI(HYDRA.NAMESPACE, "DeleteResourceOperation"); + description = factory.createURI(HYDRA.NAMESPACE, "description"); + entrypoint = factory.createURI(HYDRA.NAMESPACE, "entrypoint"); + Error = factory.createURI(HYDRA.NAMESPACE, "Error"); + expects = factory.createURI(HYDRA.NAMESPACE, "expects"); + firstPage = factory.createURI(HYDRA.NAMESPACE, "firstPage"); + freetextQuery = factory.createURI(HYDRA.NAMESPACE, "freetextQuery"); + IriTemplate = factory.createURI(HYDRA.NAMESPACE, "IriTemplate"); + IriTemplateMapping = factory.createURI(HYDRA.NAMESPACE, "IriTemplateMapping"); + itemsPerPage = factory.createURI(HYDRA.NAMESPACE, "itemsPerPage"); + lastPage = factory.createURI(HYDRA.NAMESPACE, "lastPage"); + Link = factory.createURI(HYDRA.NAMESPACE, "Link"); + mapping = factory.createURI(HYDRA.NAMESPACE, "mapping"); + member = factory.createURI(HYDRA.NAMESPACE, "member"); + method = factory.createURI(HYDRA.NAMESPACE, "method"); + nextPage = factory.createURI(HYDRA.NAMESPACE, "nextPage"); + Operation = factory.createURI(HYDRA.NAMESPACE, "Operation"); + operation = factory.createURI(HYDRA.NAMESPACE, "operation"); + PagedCollection = factory.createURI(HYDRA.NAMESPACE, "PagedCollection"); + previousPage = factory.createURI(HYDRA.NAMESPACE, "previousPage"); + property = factory.createURI(HYDRA.NAMESPACE, "property"); + readonly = factory.createURI(HYDRA.NAMESPACE, "readonly"); + ReplaceResourceOperation = factory.createURI(HYDRA.NAMESPACE, "ReplaceResourceOperation"); + required = factory.createURI(HYDRA.NAMESPACE, "required"); + Resource = factory.createURI(HYDRA.NAMESPACE, "Resource"); + returns = factory.createURI(HYDRA.NAMESPACE, "returns"); + search = factory.createURI(HYDRA.NAMESPACE, "search"); + statusCode = factory.createURI(HYDRA.NAMESPACE, "statusCode"); + StatusCodeDescription = factory.createURI(HYDRA.NAMESPACE, "StatusCodeDescription"); + statusCodes = factory.createURI(HYDRA.NAMESPACE, "statusCodes"); + supportedClass = factory.createURI(HYDRA.NAMESPACE, "supportedClass"); + supportedOperation = factory.createURI(HYDRA.NAMESPACE, "supportedOperation"); + supportedProperty = factory.createURI(HYDRA.NAMESPACE, "supportedProperty"); + SupportedProperty = factory.createURI(HYDRA.NAMESPACE, "SupportedProperty"); + template = factory.createURI(HYDRA.NAMESPACE, "template"); + TemplatedLink = factory.createURI(HYDRA.NAMESPACE, "TemplatedLink"); + title = factory.createURI(HYDRA.NAMESPACE, "title"); + totalItems = factory.createURI(HYDRA.NAMESPACE, "totalItems"); + variable = factory.createURI(HYDRA.NAMESPACE, "variable"); + writeonly = factory.createURI(HYDRA.NAMESPACE, "writeonly"); + } + + private HYDRA() { + //static access only + } + +} http://git-wip-us.apache.org/repos/asf/marmotta/blob/30d351dc/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/VOID.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/VOID.java b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/VOID.java new file mode 100644 index 0000000..1affb0a --- /dev/null +++ b/platform/marmotta-ldf/src/main/java/org/apache/marmotta/platform/ldf/vocab/VOID.java @@ -0,0 +1,435 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.marmotta.platform.ldf.vocab; + +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.ValueFactoryImpl; + +/** + * Namespace Void. + * Prefix: {@code <http://rdfs.org/ns/void#>} + */ +public class VOID { + + /** {@code http://rdfs.org/ns/void#} **/ + public static final String NAMESPACE = "http://rdfs.org/ns/void#"; + + /** {@code void} **/ + public static final String PREFIX = "void"; + + /** + * class + * <p> + * {@code http://rdfs.org/ns/void#class}. + * <p> + * The rdfs:Class that is the rdf:type of all entities in a class-based + * partition. + * + * @see <a href="http://rdfs.org/ns/void#class">class</a> + */ + //public static final URI class; + + /** + * classes + * <p> + * {@code http://rdfs.org/ns/void#classes}. + * <p> + * The total number of distinct classes in a void:Dataset. In other + * words, the number of distinct resources occuring as objects of + * rdf:type triples in the dataset. + * + * @see <a href="http://rdfs.org/ns/void#classes">classes</a> + */ + public static final URI classes; + + /** + * class partition + * <p> + * {@code http://rdfs.org/ns/void#classPartition}. + * <p> + * A subset of a void:Dataset that contains only the entities of a + * certain rdfs:Class. + * + * @see <a href="http://rdfs.org/ns/void#classPartition">classPartition</a> + */ + public static final URI classPartition; + + /** + * Data Dump + * <p> + * {@code http://rdfs.org/ns/void#dataDump}. + * <p> + * An RDF dump, partial or complete, of a void:Dataset. + * + * @see <a href="http://rdfs.org/ns/void#dataDump">dataDump</a> + */ + public static final URI dataDump; + + /** + * dataset + * <p> + * {@code http://rdfs.org/ns/void#Dataset}. + * <p> + * A set of RDF triples that are published, maintained or aggregated by a + * single provider. + * + * @see <a href="http://rdfs.org/ns/void#Dataset">Dataset</a> + */ + public static final URI Dataset; + + /** + * dataset description + * <p> + * {@code http://rdfs.org/ns/void#DatasetDescription}. + * <p> + * A web resource whose foaf:primaryTopic or foaf:topics include + * void:Datasets. + * + * @see <a href="http://rdfs.org/ns/void#DatasetDescription">DatasetDescription</a> + */ + public static final URI DatasetDescription; + + /** + * distinct objects + * <p> + * {@code http://rdfs.org/ns/void#distinctObjects}. + * <p> + * The total number of distinct objects in a void:Dataset. In other + * words, the number of distinct resources that occur in the object + * position of triples in the dataset. Literals are included in this + * count. + * + * @see <a href="http://rdfs.org/ns/void#distinctObjects">distinctObjects</a> + */ + public static final URI distinctObjects; + + /** + * distinct subjects + * <p> + * {@code http://rdfs.org/ns/void#distinctSubjects}. + * <p> + * The total number of distinct subjects in a void:Dataset. In other + * words, the number of distinct resources that occur in the subject + * position of triples in the dataset. + * + * @see <a href="http://rdfs.org/ns/void#distinctSubjects">distinctSubjects</a> + */ + public static final URI distinctSubjects; + + /** + * number of documents + * <p> + * {@code http://rdfs.org/ns/void#documents}. + * <p> + * The total number of documents, for datasets that are published as a + * set of individual documents, such as RDF/XML documents or + * RDFa-annotated web pages. Non-RDF documents, such as web pages in HTML + * or images, are usually not included in this count. This property is + * intended for datasets where the total number of triples or entities is + * hard to determine. void:triples or void:entities should be preferred + * where practical. + * + * @see <a href="http://rdfs.org/ns/void#documents">documents</a> + */ + public static final URI documents; + + /** + * number of entities + * <p> + * {@code http://rdfs.org/ns/void#entities}. + * <p> + * The total number of entities that are described in a void:Dataset. + * + * @see <a href="http://rdfs.org/ns/void#entities">entities</a> + */ + public static final URI entities; + + /** + * example resource of dataset + * <p> + * {@code http://rdfs.org/ns/void#exampleResource}. + * + * @see <a href="http://rdfs.org/ns/void#exampleResource">exampleResource</a> + */ + public static final URI exampleResource; + + /** + * feature + * <p> + * {@code http://rdfs.org/ns/void#feature}. + * + * @see <a href="http://rdfs.org/ns/void#feature">feature</a> + */ + public static final URI feature; + + /** + * in dataset + * <p> + * {@code http://rdfs.org/ns/void#inDataset}. + * <p> + * Points to the void:Dataset that a document is a part of. + * + * @see <a href="http://rdfs.org/ns/void#inDataset">inDataset</a> + */ + public static final URI inDataset; + + /** + * a link predicate + * <p> + * {@code http://rdfs.org/ns/void#linkPredicate}. + * + * @see <a href="http://rdfs.org/ns/void#linkPredicate">linkPredicate</a> + */ + public static final URI linkPredicate; + + /** + * linkset + * <p> + * {@code http://rdfs.org/ns/void#Linkset}. + * <p> + * A collection of RDF links between two void:Datasets. + * + * @see <a href="http://rdfs.org/ns/void#Linkset">Linkset</a> + */ + public static final URI Linkset; + + /** + * Objects Target + * <p> + * {@code http://rdfs.org/ns/void#objectsTarget}. + * <p> + * The dataset describing the objects of the triples contained in the + * Linkset. + * + * @see <a href="http://rdfs.org/ns/void#objectsTarget">objectsTarget</a> + */ + public static final URI objectsTarget; + + /** + * open search description + * <p> + * {@code http://rdfs.org/ns/void#openSearchDescription}. + * <p> + * An OpenSearch description document for a free-text search service over + * a void:Dataset. + * + * @see <a href="http://rdfs.org/ns/void#openSearchDescription">openSearchDescription</a> + */ + public static final URI openSearchDescription; + + /** + * number of properties + * <p> + * {@code http://rdfs.org/ns/void#properties}. + * <p> + * The total number of distinct properties in a void:Dataset. In other + * words, the number of distinct resources that occur in the predicate + * position of triples in the dataset. + * + * @see <a href="http://rdfs.org/ns/void#properties">properties</a> + */ + public static final URI properties; + + /** + * property + * <p> + * {@code http://rdfs.org/ns/void#property}. + * <p> + * The rdf:Property that is the predicate of all triples in a + * property-based partition. + * + * @see <a href="http://rdfs.org/ns/void#property">property</a> + */ + public static final URI property; + + /** + * property partition + * <p> + * {@code http://rdfs.org/ns/void#propertyPartition}. + * <p> + * A subset of a void:Dataset that contains only the triples of a certain + * rdf:Property. + * + * @see <a href="http://rdfs.org/ns/void#propertyPartition">propertyPartition</a> + */ + public static final URI propertyPartition; + + /** + * root resource + * <p> + * {@code http://rdfs.org/ns/void#rootResource}. + * <p> + * A top concept or entry point for a void:Dataset that is structured in + * a tree-like fashion. All resources in a dataset can be reached by + * following links from its root resources in a small number of steps. + * + * @see <a href="http://rdfs.org/ns/void#rootResource">rootResource</a> + */ + public static final URI rootResource; + + /** + * has a SPARQL endpoint at + * <p> + * {@code http://rdfs.org/ns/void#sparqlEndpoint}. + * + * @see <a href="http://rdfs.org/ns/void#sparqlEndpoint">sparqlEndpoint</a> + */ + public static final URI sparqlEndpoint; + + /** + * Subjects Target + * <p> + * {@code http://rdfs.org/ns/void#subjectsTarget}. + * <p> + * The dataset describing the subjects of triples contained in the + * Linkset. + * + * @see <a href="http://rdfs.org/ns/void#subjectsTarget">subjectsTarget</a> + */ + public static final URI subjectsTarget; + + /** + * has subset + * <p> + * {@code http://rdfs.org/ns/void#subset}. + * + * @see <a href="http://rdfs.org/ns/void#subset">subset</a> + */ + public static final URI subset; + + /** + * Target + * <p> + * {@code http://rdfs.org/ns/void#target}. + * <p> + * One of the two datasets linked by the Linkset. + * + * @see <a href="http://rdfs.org/ns/void#target">target</a> + */ + public static final URI target; + + /** + * technical feature + * <p> + * {@code http://rdfs.org/ns/void#TechnicalFeature}. + * <p> + * A technical feature of a void:Dataset, such as a supported RDF + * serialization format. + * + * @see <a href="http://rdfs.org/ns/void#TechnicalFeature">TechnicalFeature</a> + */ + public static final URI TechnicalFeature; + + /** + * number of triples + * <p> + * {@code http://rdfs.org/ns/void#triples}. + * <p> + * The total number of triples contained in a void:Dataset. + * + * @see <a href="http://rdfs.org/ns/void#triples">triples</a> + */ + public static final URI triples; + + /** + * has an URI look-up endpoint at + * <p> + * {@code http://rdfs.org/ns/void#uriLookupEndpoint}. + * <p> + * Defines a simple URI look-up protocol for accessing a dataset. + * + * @see <a href="http://rdfs.org/ns/void#uriLookupEndpoint">uriLookupEndpoint</a> + */ + public static final URI uriLookupEndpoint; + + /** + * has URI regular expression pattern + * <p> + * {@code http://rdfs.org/ns/void#uriRegexPattern}. + * <p> + * Defines a regular expression pattern matching URIs in the dataset. + * + * @see <a href="http://rdfs.org/ns/void#uriRegexPattern">uriRegexPattern</a> + */ + public static final URI uriRegexPattern; + + /** + * URI space + * <p> + * {@code http://rdfs.org/ns/void#uriSpace}. + * <p> + * A URI that is a common string prefix of all the entity URIs in a + * void:Dataset. + * + * @see <a href="http://rdfs.org/ns/void#uriSpace">uriSpace</a> + */ + public static final URI uriSpace; + + /** + * vocabulary + * <p> + * {@code http://rdfs.org/ns/void#vocabulary}. + * <p> + * A vocabulary that is used in the dataset. + * + * @see <a href="http://rdfs.org/ns/void#vocabulary">vocabulary</a> + */ + public static final URI vocabulary; + + static { + ValueFactory factory = ValueFactoryImpl.getInstance(); + + //class = factory.createURI(VOID.NAMESPACE, "class"); + classes = factory.createURI(VOID.NAMESPACE, "classes"); + classPartition = factory.createURI(VOID.NAMESPACE, "classPartition"); + dataDump = factory.createURI(VOID.NAMESPACE, "dataDump"); + Dataset = factory.createURI(VOID.NAMESPACE, "Dataset"); + DatasetDescription = factory.createURI(VOID.NAMESPACE, "DatasetDescription"); + distinctObjects = factory.createURI(VOID.NAMESPACE, "distinctObjects"); + distinctSubjects = factory.createURI(VOID.NAMESPACE, "distinctSubjects"); + documents = factory.createURI(VOID.NAMESPACE, "documents"); + entities = factory.createURI(VOID.NAMESPACE, "entities"); + exampleResource = factory.createURI(VOID.NAMESPACE, "exampleResource"); + feature = factory.createURI(VOID.NAMESPACE, "feature"); + inDataset = factory.createURI(VOID.NAMESPACE, "inDataset"); + linkPredicate = factory.createURI(VOID.NAMESPACE, "linkPredicate"); + Linkset = factory.createURI(VOID.NAMESPACE, "Linkset"); + objectsTarget = factory.createURI(VOID.NAMESPACE, "objectsTarget"); + openSearchDescription = factory.createURI(VOID.NAMESPACE, "openSearchDescription"); + properties = factory.createURI(VOID.NAMESPACE, "properties"); + property = factory.createURI(VOID.NAMESPACE, "property"); + propertyPartition = factory.createURI(VOID.NAMESPACE, "propertyPartition"); + rootResource = factory.createURI(VOID.NAMESPACE, "rootResource"); + sparqlEndpoint = factory.createURI(VOID.NAMESPACE, "sparqlEndpoint"); + subjectsTarget = factory.createURI(VOID.NAMESPACE, "subjectsTarget"); + subset = factory.createURI(VOID.NAMESPACE, "subset"); + target = factory.createURI(VOID.NAMESPACE, "target"); + TechnicalFeature = factory.createURI(VOID.NAMESPACE, "TechnicalFeature"); + triples = factory.createURI(VOID.NAMESPACE, "triples"); + uriLookupEndpoint = factory.createURI(VOID.NAMESPACE, "uriLookupEndpoint"); + uriRegexPattern = factory.createURI(VOID.NAMESPACE, "uriRegexPattern"); + uriSpace = factory.createURI(VOID.NAMESPACE, "uriSpace"); + vocabulary = factory.createURI(VOID.NAMESPACE, "vocabulary"); + } + + private VOID() { + //static access only + } + +}
