Skip to content

Commit 93518ef

Browse files
committed
ont-api: refactoring transformers subsystem (issue #4) - moving/renaming/removing classes, changing docs
1 parent 303f712 commit 93518ef

31 files changed

+1057
-957
lines changed

src/main/java/com/github/owlcs/ontapi/OntGraphDocumentSource.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.github.owlcs.ontapi;
1616

1717
import com.github.owlcs.ontapi.jena.utils.Graphs;
18+
import com.github.owlcs.ontapi.transforms.TransformationModel;
1819
import org.apache.jena.atlas.web.ContentType;
1920
import org.apache.jena.graph.Graph;
2021
import org.apache.jena.riot.Lang;
@@ -67,7 +68,7 @@ public abstract class OntGraphDocumentSource implements OWLOntologyDocumentSourc
6768
* Answers if the graph must be put in order by the transformations mechanism.
6869
*
6970
* @return {@code true} if graph transformations is allowed
70-
* @see com.github.owlcs.ontapi.transforms.Transform
71+
* @see TransformationModel
7172
* @since 1.3.2
7273
*/
7374
public boolean withTransforms() {

src/main/java/com/github/owlcs/ontapi/OntGraphUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.github.owlcs.ontapi.jena.model.OntModel;
2020
import com.github.owlcs.ontapi.jena.utils.Graphs;
2121
import com.github.owlcs.ontapi.jena.utils.Models;
22-
import com.github.owlcs.ontapi.transforms.GraphTransformers;
22+
import com.github.owlcs.ontapi.transforms.GraphStats;
2323
import org.apache.commons.io.input.ReaderInputStream;
2424
import org.apache.jena.graph.*;
2525
import org.apache.jena.rdf.model.impl.ModelCom;
@@ -225,11 +225,11 @@ public static RDFLiteral literal(Node node) throws IllegalArgumentException {
225225
* Auxiliary method to produce {@link OWLOntologyLoaderMetaData} object.
226226
*
227227
* @param graph {@link Graph}
228-
* @param stats {@link GraphTransformers.Stats} transformation outcome, can be null for fake meta-data
228+
* @param stats {@link GraphStats} transformation outcome, can be null for fake meta-data
229229
* @return {@link OWLOntologyLoaderMetaData} object
230230
* @throws IllegalArgumentException in case {@code graph} and {@code stats} are incompatible
231231
*/
232-
protected static OWLOntologyLoaderMetaData makeParserMetaData(Graph graph, GraphTransformers.Stats stats) {
232+
protected static OWLOntologyLoaderMetaData makeParserMetaData(Graph graph, GraphStats stats) {
233233
if (stats == null)
234234
return OntologyMetaData.createParserMetaData(graph);
235235
if (Graphs.getBase(graph) != stats.getGraph())

src/main/java/com/github/owlcs/ontapi/OntologyLoaderImpl.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.github.owlcs.ontapi.jena.utils.Graphs;
2121
import com.github.owlcs.ontapi.jena.utils.OntModels;
2222
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
23-
import com.github.owlcs.ontapi.transforms.GraphTransformers;
23+
import com.github.owlcs.ontapi.transforms.GraphStats;
2424
import com.github.owlcs.ontapi.transforms.TransformException;
2525
import org.apache.jena.graph.Graph;
2626
import org.apache.jena.graph.GraphUtil;
@@ -224,7 +224,7 @@ protected UnionGraph makeUnionGraph(GraphInfo info,
224224
return graph;
225225
}
226226
// process transformations
227-
GraphTransformers.Stats stats;
227+
GraphStats stats;
228228
Set<Graph> transformed = graphs.values().stream()
229229
.filter(g -> !g.isFresh() || g.noTransforms())
230230
.map(GraphInfo::getGraph)
@@ -237,8 +237,8 @@ protected UnionGraph makeUnionGraph(GraphInfo info,
237237
throw new OntologyFactoryImpl.OWLTransformException(t);
238238
}
239239
info.setStats(stats);
240-
stats.listStats(true)
241-
.filter(GraphTransformers.Stats::isNotEmpty)
240+
stats.stats(true)
241+
.filter(GraphStats::isNotEmpty)
242242
.forEach(s -> {
243243
String uri = Graphs.getURI(s.getGraph());
244244
if (uri == null) {
@@ -697,7 +697,7 @@ public static class GraphInfo {
697697
private boolean fresh, transforms;
698698
private Node ontology;
699699
private Set<String> imports;
700-
private GraphTransformers.Stats stats;
700+
private GraphStats stats;
701701

702702
protected GraphInfo(Graph graph, OntFormat format, IRI source, boolean withTransforms) {
703703
this.graph = graph;
@@ -755,11 +755,11 @@ protected IRI getSource() {
755755
return source;
756756
}
757757

758-
public GraphTransformers.Stats getStats() {
758+
public GraphStats getStats() {
759759
return stats;
760760
}
761761

762-
protected void setStats(GraphTransformers.Stats stats) {
762+
protected void setStats(GraphStats stats) {
763763
this.stats = Objects.requireNonNull(stats, "Null transform stats");
764764
}
765765
}

src/main/java/com/github/owlcs/ontapi/OntologyMetaData.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.github.owlcs.ontapi.jena.utils.Graphs;
1818
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
1919
import com.github.owlcs.ontapi.jena.vocabulary.RDF;
20-
import com.github.owlcs.ontapi.transforms.GraphTransformers;
20+
import com.github.owlcs.ontapi.transforms.GraphStats;
2121
import com.github.owlcs.ontapi.transforms.OWLIDTransform;
2222
import com.google.common.collect.ArrayListMultimap;
2323
import com.google.common.collect.Multimap;
@@ -43,12 +43,12 @@
4343

4444
/**
4545
* Implementation of {@link OWLOntologyLoaderMetaData}.
46-
* A wrapper for {@link GraphTransformers.Stats Transformation Stats} to satisfy OWL-API.
46+
* A wrapper for {@link GraphStats Transformation Stats} to satisfy OWL-API.
4747
* Constructed while loading to provide some additional information about runtime changes in the source.
4848
* <p>
4949
* Created by @szuev on 28.06.2018.
5050
*
51-
* @see GraphTransformers.Stats
51+
* @see GraphStats
5252
*/
5353
@SuppressWarnings("WeakerAccess")
5454
public class OntologyMetaData implements OWLOntologyLoaderMetaData {
@@ -94,26 +94,26 @@ public static OntologyMetaData createParserMetaData(Graph graph) {
9494

9595
/**
9696
* A factory method.
97-
* Creates {@link OWLOntologyLoaderMetaData} from the given {@link GraphTransformers.Stats Transformation Stats}.
97+
* Creates {@link OWLOntologyLoaderMetaData} from the given {@link GraphStats Transformation Stats}.
9898
*
9999
* @param stats not null
100100
* @return {@link OntologyMetaData} instance, not null
101101
*/
102-
public static OntologyMetaData createParserMetaData(GraphTransformers.Stats stats) {
102+
public static OntologyMetaData createParserMetaData(GraphStats stats) {
103103
Graph graph = Graphs.getBase(Objects.requireNonNull(stats, "Null graph").getGraph());
104104
RDFOntologyHeaderStatus header = RDFOntologyHeaderStatus.PARSED_ONE_HEADER;
105105
String idKey = OWLIDTransform.class.getSimpleName();
106-
if (stats.hasTriples(GraphTransformers.Stats.Type.ADDED, idKey)) {
106+
if (stats.hasTriples(GraphStats.Type.ADDED, idKey)) {
107107
header = RDFOntologyHeaderStatus.PARSED_ZERO_HEADERS;
108108
}
109-
if (stats.hasTriples(GraphTransformers.Stats.Type.DELETED, idKey)) {
109+
if (stats.hasTriples(GraphStats.Type.DELETED, idKey)) {
110110
header = RDFOntologyHeaderStatus.PARSED_MULTIPLE_HEADERS;
111111
}
112-
Set<RDFTriple> unparsed = stats.triples(GraphTransformers.Stats.Type.UNPARSED)
112+
Set<RDFTriple> unparsed = stats.triples(GraphStats.Type.UNPARSED)
113113
.map(OntGraphUtils::triple)
114114
.collect(Collectors.toSet());
115115
ArrayListMultimap<IRI, Class<? extends OWLObject>> guessedDeclarations = ArrayListMultimap.create();
116-
stats.triples(GraphTransformers.Stats.Type.ADDED)
116+
stats.triples(GraphStats.Type.ADDED)
117117
.collect(Collectors.toSet())
118118
.forEach(t -> {
119119
// note: anonymous subject also wrapped as iri

src/main/java/com/github/owlcs/ontapi/config/LoadControl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ interface LoadControl<R> extends LoadSettings {
4343
/**
4444
* Sets {@code GraphTransformers.Store} collection.
4545
*
46-
* @param t {@link GraphTransformers.Store}, not {@code null}
46+
* @param t {@link GraphTransformers}, not {@code null}
4747
* @return {@link R} (this or copied instance)
4848
* @see LoadSettings#getGraphTransformers()
4949
* @see LoadSettings#isPerformTransformation()
5050
*/
51-
R setGraphTransformers(GraphTransformers.Store t);
51+
R setGraphTransformers(GraphTransformers t);
5252

5353
/**
5454
* Disables or enables the Graph Transformation mechanism depending on the given flag.

src/main/java/com/github/owlcs/ontapi/config/LoadSettings.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.github.owlcs.ontapi.*;
1818
import com.github.owlcs.ontapi.jena.impl.conf.OntPersonality;
1919
import com.github.owlcs.ontapi.jena.model.OntModel;
20+
import com.github.owlcs.ontapi.transforms.GraphFilter;
2021
import com.github.owlcs.ontapi.transforms.GraphTransformers;
2122
import org.apache.jena.graph.Graph;
2223
import org.semanticweb.owlapi.model.IRI;
@@ -51,7 +52,7 @@ public interface LoadSettings {
5152
OntPersonality getPersonality();
5253

5354
/**
54-
* Gets {@link GraphTransformers.Store Transformers Store}.
55+
* Gets {@link GraphTransformers Transformers Store}.
5556
* <p>
5657
* Transformers Store is a collection of actions that are performed on {@code Graph} before
5758
* it enters into the main system.
@@ -61,22 +62,22 @@ public interface LoadSettings {
6162
* or {@link Ontology Axiomatic Model}, but without a proper transformation
6263
* you might not found valid {@link org.semanticweb.owlapi.model.OWLAxiom Axiom}s inside that data.
6364
* Transformations can be simply disabled through
64-
* the method {@link LoadControl#setGraphTransformers(GraphTransformers.Store)}.
65+
* the method {@link LoadControl#setGraphTransformers(GraphTransformers)}.
6566
* It is recommended to do this in case there is confidence that the data is OWL2,
6667
* since transformations may take significant processor time.
67-
* With the method {@link GraphTransformers.Store#setFilter(GraphTransformers.Filter)}
68+
* With the method {@link GraphTransformers#setFilter(GraphFilter)}
6869
* a whole graph family may be skipped from transformation process.
6970
* And there is one more facility to selectively turn off transformations:
7071
* the method {@link OntGraphDocumentSource#withTransforms()},
7172
* which is used while passing externally loaded graph into the manager
7273
* (see {@link OntologyManager#addOntology(Graph)}.
7374
*
74-
* @return {@link GraphTransformers.Store}
75-
* @see LoadControl#setGraphTransformers(GraphTransformers.Store)
75+
* @return {@link GraphTransformers}
76+
* @see LoadControl#setGraphTransformers(GraphTransformers)
7677
* @see LoadControl#setPerformTransformation(boolean)
7778
* @see OntSettings#ONT_API_LOAD_CONF_TRANSFORMERS
7879
*/
79-
GraphTransformers.Store getGraphTransformers();
80+
GraphTransformers getGraphTransformers();
8081

8182
/**
8283
* Answers {@code true} if the mechanism of graph transformers is enabled, which is {@code true} by default.

src/main/java/com/github/owlcs/ontapi/config/OntConfig.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
package com.github.owlcs.ontapi.config;
1616

17-
import org.semanticweb.owlapi.model.*;
18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
2017
import com.github.owlcs.ontapi.NoOpReadWriteLock;
2118
import com.github.owlcs.ontapi.OntApiException;
2219
import com.github.owlcs.ontapi.jena.impl.conf.OntPersonality;
2320
import com.github.owlcs.ontapi.transforms.GraphTransformers;
21+
import org.semanticweb.owlapi.model.*;
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2424

2525
import javax.annotation.Nonnull;
2626
import java.io.IOException;
@@ -44,7 +44,7 @@
4444
* <li>{@link #setModelCacheLevel(int, boolean)} (<b>since 1.4.2</b>), {@link #setModelCacheLevel(int)} (<b>since 1.4.0</b>)</li>
4545
* <li>{@link #useContentCache()}, {@link #useComponentCache()}, {@link #useIteratorCache()} (<b>since 1.4.2</b>)</li>
4646
* <li>{@link #getPersonality()} and {@link #setPersonality(OntPersonality)}</li>
47-
* <li>{@link #getGraphTransformers()} amd {@link #setGraphTransformers(GraphTransformers.Store)}</li>
47+
* <li>{@link #getGraphTransformers()} amd {@link #setGraphTransformers(GraphTransformers)}</li>
4848
* <li>{@link #isPerformTransformation()} and {@link #setPerformTransformation(boolean)}</li>
4949
* <li>{@link #isProcessImports()} and {@link #setProcessImports(boolean)} (<b>since 1.4.1</b>)</li>
5050
* <li>{@link #getSupportedSchemes()} and {@link #setSupportedSchemes(List)}</li>
@@ -253,20 +253,20 @@ public OntConfig setPersonality(OntPersonality p) {
253253
* {@inheritDoc}
254254
*/
255255
@Override
256-
public GraphTransformers.Store getGraphTransformers() {
256+
public GraphTransformers getGraphTransformers() {
257257
return get(OntSettings.ONT_API_LOAD_CONF_TRANSFORMERS);
258258
}
259259

260260
/**
261261
* An ONT-API manager's load config setter.
262262
* {@inheritDoc}
263263
*
264-
* @param t {@link com.github.owlcs.ontapi.transforms.GraphTransformers.Store}
264+
* @param t {@link GraphTransformers}
265265
* @return this instance
266-
* @see OntLoaderConfiguration#setGraphTransformers(GraphTransformers.Store)
266+
* @see OntLoaderConfiguration#setGraphTransformers(GraphTransformers)
267267
*/
268268
@Override
269-
public OntConfig setGraphTransformers(GraphTransformers.Store t) {
269+
public OntConfig setGraphTransformers(GraphTransformers t) {
270270
return put(OntSettings.ONT_API_LOAD_CONF_TRANSFORMERS, t);
271271
}
272272

src/main/java/com/github/owlcs/ontapi/config/OntLoaderConfiguration.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
package com.github.owlcs.ontapi.config;
1616

17-
import org.semanticweb.owlapi.model.*;
18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
2017
import com.github.owlcs.ontapi.OntApiException;
2118
import com.github.owlcs.ontapi.jena.impl.conf.OntPersonality;
2219
import com.github.owlcs.ontapi.transforms.GraphTransformers;
20+
import org.semanticweb.owlapi.model.*;
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
2323

2424
import javax.annotation.Nonnull;
2525
import java.io.IOException;
@@ -145,19 +145,19 @@ public OntLoaderConfiguration setPerformTransformation(boolean b) {
145145
* {@inheritDoc}
146146
*/
147147
@Override
148-
public GraphTransformers.Store getGraphTransformers() {
148+
public GraphTransformers getGraphTransformers() {
149149
return get(OntSettings.ONT_API_LOAD_CONF_TRANSFORMERS);
150150
}
151151

152152
/**
153153
* An ONT-API config setter.
154154
* {@inheritDoc}
155155
*
156-
* @param t {@link GraphTransformers.Store} new graph transformers store
156+
* @param t {@link GraphTransformers} new graph transformers store
157157
* @return {@link OntLoaderConfiguration}, a copied (new) or this instance in case no changes is made
158158
*/
159159
@Override
160-
public OntLoaderConfiguration setGraphTransformers(GraphTransformers.Store t) {
160+
public OntLoaderConfiguration setGraphTransformers(GraphTransformers t) {
161161
return set(OntSettings.ONT_API_LOAD_CONF_TRANSFORMERS, t);
162162
}
163163

src/main/java/com/github/owlcs/ontapi/config/OntSettings.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
package com.github.owlcs.ontapi.config;
1616

17+
import com.github.owlcs.ontapi.OntApiException;
18+
import com.github.owlcs.ontapi.jena.impl.conf.OntModelConfig;
19+
import com.github.owlcs.ontapi.jena.vocabulary.*;
20+
import com.github.owlcs.ontapi.transforms.*;
1721
import org.apache.jena.vocabulary.RDFS;
1822
import org.semanticweb.owlapi.model.MissingImportHandlingStrategy;
1923
import org.semanticweb.owlapi.model.MissingOntologyHeaderStrategy;
2024
import org.semanticweb.owlapi.model.PriorityCollectionSorting;
2125
import org.semanticweb.owlapi.model.parameters.ConfigurationOptions;
22-
import com.github.owlcs.ontapi.OntApiException;
23-
import com.github.owlcs.ontapi.jena.impl.conf.OntModelConfig;
24-
import com.github.owlcs.ontapi.jena.vocabulary.*;
25-
import com.github.owlcs.ontapi.transforms.*;
2626

2727
import java.io.IOException;
2828
import java.io.InputStream;
@@ -133,20 +133,20 @@ OntModelConfig.StdMode getPersonalityMode() {
133133
, SWRLTransform.class) {
134134
@Override
135135
public Object getDefaultValue() {
136-
GraphTransformers.Store res = new GraphTransformers.Store();
137-
for (Class<? extends Transform> c : getTransformTypes()) {
138-
res = res.add(new GraphTransformers.DefaultMaker(c));
136+
GraphTransformers res = new GraphTransformers();
137+
for (Class<? extends TransformationModel> c : getTransformTypes()) {
138+
res = res.addLast(Transform.Factory.create(c));
139139
}
140140
return res;
141141
}
142142

143143
@SuppressWarnings("unchecked")
144-
List<Class<? extends Transform>> getTransformTypes() {
144+
List<Class<? extends TransformationModel>> getTransformTypes() {
145145
List<?> res = PROPERTIES.getListProperty(key);
146146
if (res == null) {
147147
res = (List<?>) secondary;
148148
}
149-
return (List<Class<? extends Transform>>) res;
149+
return (List<Class<? extends TransformationModel>>) res;
150150
}
151151
};
152152

src/main/java/com/github/owlcs/ontapi/jena/OntVocabulary.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.github.owlcs.ontapi.jena.utils.Iter;
1818
import com.github.owlcs.ontapi.jena.vocabulary.*;
19+
import com.github.owlcs.ontapi.transforms.GraphTransformers;
1920
import org.apache.jena.datatypes.BaseDatatype;
2021
import org.apache.jena.datatypes.RDFDatatype;
2122
import org.apache.jena.datatypes.TypeMapper;
@@ -194,7 +195,7 @@ default Set<Resource> getBuiltinOWLEntities() {
194195
* from the packages {@link com.github.owlcs.ontapi.jena.vocabulary} and {@link org.apache.jena.vocabulary}
195196
* (such as {@link OWL}).
196197
* In ONT-API, a {@link OntVocabulary} is used to build {@link com.github.owlcs.ontapi.jena.impl.conf.OntPersonality}
197-
* and in {@link com.github.owlcs.ontapi.transforms.GraphTransformers} subsystem.
198+
* and in {@link GraphTransformers} subsystem.
198199
* <p>
199200
* Created by @szuev on 21.12.2016.
200201
*/
@@ -355,6 +356,7 @@ private static <X> Set<X> toUnmodifiableSet(Collection<X> input) {
355356
*/
356357
@SuppressWarnings("WeakerAccess")
357358
protected static class OWLImpl extends Impl {
359+
private static final Class<?>[] VOCABULARIES = new Class<?>[]{XSD.class, RDF.class, RDFS.class, OWL.class};
358360
/**
359361
* The list of datatypes from owl-2 specification (35 types)
360362
* (see <a href='https://www.w3.org/TR/owl2-quick-reference/'>Quick References, 3.1 Built-in Datatypes</a>).
@@ -383,7 +385,6 @@ protected static class OWLImpl extends Impl {
383385
Stream.of(OWL.topDataProperty, OWL.bottomDataProperty).collect(Iter.toUnmodifiableSet());
384386
public static final Set<Property> OBJECT_PROPERTIES =
385387
Stream.of(OWL.topObjectProperty, OWL.bottomObjectProperty).collect(Iter.toUnmodifiableSet());
386-
private static final Class<?>[] VOCABULARIES = new Class<?>[]{XSD.class, RDF.class, RDFS.class, OWL.class};
387388
public static final Set<Property> PROPERTIES = getConstants(Property.class, VOCABULARIES);
388389
public static final Set<Resource> RESOURCES = getConstants(Resource.class, VOCABULARIES);
389390

@@ -453,8 +454,8 @@ protected SKOSImpl() {
453454
* @see SWRLB
454455
*/
455456
protected static class SWRLImpl extends Impl {
456-
public static final Set<Resource> BUILTINS = getConstants(Property.class, SWRLB.class);
457457
private static final Class<?>[] VOCABULARIES = new Class<?>[]{SWRL.class, SWRLB.class};
458+
public static final Set<Resource> BUILTINS = getConstants(Property.class, SWRLB.class);
458459
public static final Set<Property> PROPERTIES = getConstants(Property.class, VOCABULARIES);
459460
public static final Set<Resource> RESOURCES = getConstants(Resource.class, VOCABULARIES);
460461

src/main/java/com/github/owlcs/ontapi/transforms/BaseDeclarator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* The collection of base methods for {@link ManifestDeclarator} and {@link ReasonerDeclarator}
3232
*/
3333
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"})
34-
public abstract class BaseDeclarator extends Transform {
34+
public abstract class BaseDeclarator extends TransformationModel {
3535
private static final List<Property> RESTRICTION_PROPERTY_MARKERS = Stream.of(OWL.onProperty, OWL.allValuesFrom,
3636
OWL.someValuesFrom, OWL.hasValue, OWL.onClass,
3737
OWL.onDataRange, OWL.cardinality, OWL.qualifiedCardinality,

0 commit comments

Comments
 (0)