Class NormalizeAnnotation
java.lang.Object
de.wwu.scdh.annotation.selection.wadm.NormalizeAnnotation
- All Implemented Interfaces:
Consumer<org.apache.jena.rdf.model.Resource>
public class NormalizeAnnotation
extends Object
implements Consumer<org.apache.jena.rdf.model.Resource>
NormalizeAnnotation can be used to normalize or rewrite
the WADM annotations targeting a given resource in a graph.
This class implements the Consumer interface and can thus
be used in a functional style like forEach(new
NormalizeAnnoation(...)) on some resource iterator. The
normalization will--by side effect--be written to the Model
which was passed into the constructor.
normalize to do the
normalization.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final URIprotected org.apache.jena.rdf.model.Modelprotected final RewriterConfigprotected final Resource<?> protected final RewriterFactory -
Constructor Summary
ConstructorsConstructorDescriptionNormalizeAnnotation(Resource<?> resource, URI iri, Optional<URI> rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.apache.jena.rdf.model.Resource annotation) This is the method of the function interfaceConsumerand actually does the normalization without throwing errors.org.apache.jena.rdf.model.ModelgetModel()Returns theModel.static org.apache.jena.rdf.model.Modelnormalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, InputStream input, Optional<String> lang, Optional<String> modelBase) Normalize all annotations in aModelwhich is read from anInputStream.static org.apache.jena.rdf.model.Modelnormalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, String graph, Optional<String> lang) Normalize all annotations in aModelgiven by a URI asStringwhich may reference a local file (file URI) or an online resource.static org.apache.jena.rdf.model.Modelnormalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model) Normalize all annotations in the providedModel.static org.apache.jena.rdf.model.Modelrewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, InputStream input, Optional<String> lang, Optional<String> modelBase) Rewrite all annotations in the providedModel.static org.apache.jena.rdf.model.Modelrewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, String graph, Optional<String> lang) Rewrite all annotations in the providedModel.static org.apache.jena.rdf.model.Modelrewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model) Rewrite all annotations in the providedModel.
-
Field Details
-
resource
-
iri
-
rewriteIri
-
model
protected org.apache.jena.rdf.model.Model model -
rewriterFactory
-
normalizerConfig
-
error
-
-
Constructor Details
-
NormalizeAnnotation
public NormalizeAnnotation(Resource<?> resource, URI iri, Optional<URI> rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model)
-
-
Method Details
-
accept
public void accept(org.apache.jena.rdf.model.Resource annotation) This is the method of the function interfaceConsumerand actually does the normalization without throwing errors. -
getModel
public org.apache.jena.rdf.model.Model getModel()Returns theModel. The model is normalized, whenacceptwas called. -
normalize
public static org.apache.jena.rdf.model.Model normalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model) Normalize all annotations in the providedModel.- Parameters:
resource- - the resource the rewriting has to done withiri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationmodel- - the RDF model (graph) containing the annotations- Returns:
- the normalized
Model
-
rewrite
public static org.apache.jena.rdf.model.Model rewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, org.apache.jena.rdf.model.Model model) Rewrite all annotations in the providedModel. In contrast tonormalize(de.wwu.scdh.annotation.selection.Resource, URI, RewriterFactory, RewriterConfig, Model)this method also rewrites theoa:hasSourceproperty and is thus suitable for transforming selectors between representations.- Parameters:
resource- - the resource the rewriting has to done with, should be aMappedResourceiri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriteIri- - the new IRI of rewritten targetsrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationmodel- - the RDF model (graph) containing the annotations- Returns:
- the rewritten
Model
-
normalize
public static org.apache.jena.rdf.model.Model normalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, String graph, Optional<String> lang) Normalize all annotations in aModelgiven by a URI asStringwhich may reference a local file (file URI) or an online resource. Note, that this method sets options to the RDF parser, e.g., theStaticDocumentLoaderas JSON-LD document loader. If you want full control over RDF parsing, the usenormalize(de.wwu.scdh.annotation.selection.Resource, URI, RewriterFactory, RewriterConfig, Model)instead.- Parameters:
resource- - the resource the rewriting has to done withiri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationgraph- - the URI where to read the RDF fromlang- - the serialization language of the graph at the URI- Returns:
- the normalized
Model
-
rewrite
public static org.apache.jena.rdf.model.Model rewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, String graph, Optional<String> lang) Rewrite all annotations in the providedModel. In contrast tonormalize(de.wwu.scdh.annotation.selection.Resource, URI, RewriterFactory, RewriterConfig, String, Optional)this method also rewrites theoa:hasSourceproperty and is thus suitable for transforming selectors between representations. Note, that this method sets options to the RDF parser, e.g., theStaticDocumentLoaderas JSON-LD document loader. If you want full control over RDF parsing, the userewrite(de.wwu.scdh.annotation.selection.Resource, URI, URI, RewriterFactory, RewriterConfig, Model)instead.- Parameters:
resource- - the resource the rewriting has to done with. Should be aMappedResource.iri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriteIri- - the new IRI of rewritten targetsrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationgraph- - the URI where to read the RDF fromlang- - the serialization language of the graph at the URI- Returns:
- the rewritten
Model
-
normalize
public static org.apache.jena.rdf.model.Model normalize(Resource<?> resource, URI iri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, InputStream input, Optional<String> lang, Optional<String> modelBase) Normalize all annotations in aModelwhich is read from anInputStream. Note, that this method sets options to the RDF parser, e.g., theStaticDocumentLoaderas JSON-LD document loader. If you want full control over RDF parsing, the usenormalize(de.wwu.scdh.annotation.selection.Resource, URI, RewriterFactory, RewriterConfig, Model)instead.- Parameters:
resource- - the resource the rewriting has to done withiri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationinput- - theInputStreamlang- - optionally the serialization language of stream data; if not provided, NTriples are assumedmodelBase- - a base URI of the model, given asString- Returns:
- the normalized
Model
-
rewrite
public static org.apache.jena.rdf.model.Model rewrite(Resource<?> resource, URI iri, URI rewriteIri, RewriterFactory rewriterFactory, RewriterConfig normalizerConfig, InputStream input, Optional<String> lang, Optional<String> modelBase) Rewrite all annotations in the providedModel. In contrast tonormalize(de.wwu.scdh.annotation.selection.Resource, URI, RewriterFactory, RewriterConfig, InputStream, Optional, Optional)this method also rewrites theoa:hasSourceproperty and is thus suitable for transforming selectors between representations. Note, that this method sets options to the RDF parser, e.g., theStaticDocumentLoaderas JSON-LD document loader. If you want full control over RDF parsing, the userewrite(de.wwu.scdh.annotation.selection.Resource, URI, URI, RewriterFactory, RewriterConfig, Model)instead. *- Parameters:
resource- - the resource the rewriting has to done with. Should be aMappedResource.iri- - the IRI of sources (oa:hasSource) the rewriting has to done onrewriterFactory- - a factory that returns a rewriter for a pointnormalizerConfig- - a configurationinput- - theInputStreamlang- - optionally the serialization language of stream data; if not provided, NTriples are assumedmodelBase- - a base URI of the model, given asString- Returns:
- the rewritten
Model
-