Skip to content

Commit

Permalink
Move (copy) RDF API into api-executor-v1
Browse files Browse the repository at this point in the history
Use temporary names for backend implementation of RDF services,
update dataunit pipeline model.
  • Loading branch information
skodapetr committed Dec 12, 2017
1 parent cec809d commit 9b96469
Show file tree
Hide file tree
Showing 179 changed files with 3,148 additions and 1,911 deletions.
37 changes: 0 additions & 37 deletions api-executor-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<!-- LinkedPipes. -->
<dependency>
<groupId>com.linkedpipes</groupId>
<artifactId>rdf-utils</artifactId>
<version>${lp.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.linkedpipes</groupId>
<artifactId>vocabulary</artifactId>
<version>${lp.version}</version>
<scope>provided</scope>
</dependency>
<!-- Test. -->
<dependency>
<groupId>junit</groupId>
Expand All @@ -46,29 +33,5 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.linkedpipes</groupId>
<artifactId>rdf-utils-rdf4j</artifactId>
<version>${lp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-model</artifactId>
<version>${rdf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-repository-sail</artifactId>
<version>${rdf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-sail-memory</artifactId>
<version>${rdf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedpipes.etl.executor.api.v1;

import com.linkedpipes.etl.rdf.utils.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;

/**
* Observer for pipeline execution events. Can be used by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.linkedpipes.etl.executor.api.v1.component;

import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.rdf.utils.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;
import org.osgi.framework.BundleContext;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.linkedpipes.etl.executor.api.v1.component;

import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.service.DefaultServiceFactory;
import com.linkedpipes.etl.rdf.utils.model.RdfSource;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.wiring.BundleRevision;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.executor.api.v1.dataunit.DataUnit;
import com.linkedpipes.etl.executor.api.v1.dataunit.RuntimeConfiguration;
import com.linkedpipes.etl.rdf.utils.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.executor.api.v1.dataunit.DataUnit;
import com.linkedpipes.etl.executor.api.v1.dataunit.RuntimeConfiguration;
import com.linkedpipes.etl.executor.api.v1.rdf.RdfToPojo;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.rdf.pojo.RdfToPojoLoader;
import com.linkedpipes.etl.executor.api.v1.service.ServiceFactory;
import com.linkedpipes.etl.rdf.utils.RdfUtils;
import com.linkedpipes.etl.rdf.utils.RdfUtilsException;
import com.linkedpipes.etl.rdf.utils.model.RdfSource;

import java.lang.reflect.Field;
import java.util.Map;
Expand Down Expand Up @@ -96,15 +94,7 @@ private void loadConfigurationForField(Field field, String graph,
throw new LpException("Can't create instance of {} for {}",
field.getType().getSimpleName(), field.getName(), ex);
}
//
try {
RdfUtils.loadByType(definition, graph,
instance, RdfToPojo.descriptorFactory());
} catch (RdfUtilsException ex) {
throw new LpException("Can't load for field: {}",
field.getName(), ex);
}
//
RdfToPojoLoader.loadByReflection(definition, graph, instance);
try {
field.set(component, instance);
} catch (IllegalAccessException | IllegalArgumentException ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.linkedpipes.etl.executor.api.v1.dataunit;

import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.rdf.utils.model.RdfSource;
import com.linkedpipes.etl.executor.api.v1.rdf.model.RdfSource;

public interface DataUnitFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.linkedpipes.etl.executor.api.v1.dataunit;

import com.linkedpipes.etl.executor.api.v1.LpException;
import com.linkedpipes.etl.rdf.utils.model.TripleWriter;
import com.linkedpipes.etl.executor.api.v1.rdf.model.TripleWriter;

/**
* Interface for runtime configuration.
* Interface for DataUnit with runtime configuration.
*/
public interface RuntimeConfiguration {

/**
* Write the content of a runtime configuration.
*
* @param writer
*/
void write(TripleWriter writer) throws LpException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.linkedpipes.etl.executor.api.v1.event;

import com.linkedpipes.etl.executor.api.v1.vocabulary.LP_EVENTS;
import com.linkedpipes.etl.rdf.utils.RdfFormatter;
import com.linkedpipes.etl.rdf.utils.RdfUtilsException;
import com.linkedpipes.etl.rdf.utils.model.TripleWriter;
import com.linkedpipes.etl.rdf.utils.vocabulary.RDF;
import com.linkedpipes.etl.rdf.utils.vocabulary.SKOS;
import com.linkedpipes.etl.rdf.utils.vocabulary.XSD;
import com.linkedpipes.etl.executor.api.v1.rdf.model.TripleWriter;
import com.linkedpipes.etl.executor.api.v1.vocabulary.LP;
import com.linkedpipes.etl.executor.api.v1.vocabulary.RDF;
import com.linkedpipes.etl.executor.api.v1.vocabulary.SKOS;

import java.util.Date;

/**
* Default abstract implementation of an event.
* Abstract implementation of an event.
*/
public abstract class AbstractEvent implements Event {

Expand All @@ -26,31 +23,20 @@ public abstract class AbstractEvent implements Event {
public AbstractEvent(String type) {
this.type = type;
this.created = new Date();
this.label = null;
}

/**
* @param type
* @param label Label in english.
*/
public AbstractEvent(String type, String label) {
this.type = type;
this.created = new Date();
this.label = label;
}

@Override
public void setIri(String iri) {
this.iri = iri;
}

@Override
public void write(TripleWriter writer) throws RdfUtilsException {
public void write(TripleWriter writer) {
writer.iri(iri, RDF.TYPE, type);
if (label != null && !label.isEmpty()) {
writer.string(iri, SKOS.PREF_LABEL, label, "en");
}
writer.typed(iri, LP_EVENTS.HAS_CREATED, RdfFormatter.toXsdDate(created),
XSD.DATETIME);
writer.date(iri, LP.HAS_CREATED, created);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.linkedpipes.etl.executor.api.v1.event;

import com.linkedpipes.etl.rdf.utils.RdfUtilsException;
import com.linkedpipes.etl.rdf.utils.model.TripleWriter;
import com.linkedpipes.etl.executor.api.v1.rdf.model.TripleWriter;

public interface Event {

Expand All @@ -12,6 +11,6 @@ public interface Event {
*/
void setIri(String iri);

void write(TripleWriter builder) throws RdfUtilsException;
void write(TripleWriter builder);

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.linkedpipes.etl.executor.api.v1.rdf;

import com.linkedpipes.etl.rdf.utils.pojo.LangString;

/**
* Can be used to load language string with a language tag.
*/
public class LanguageString implements LangString {
public class LanguageString {

private String value;
protected String value;

private String language;
protected String language;

public LanguageString() {
}
Expand All @@ -19,7 +17,6 @@ public LanguageString(String value, String language) {
this.language = language;
}

@Override
public void setValue(String value, String language) {
this.value = value;
this.language = language;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.linkedpipes.etl.executor.api.v1.rdf;

import com.linkedpipes.etl.executor.api.v1.LpException;

public class RdfException extends LpException {

public RdfException(String messages, Object... args) {
super(messages, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.linkedpipes.etl.executor.api.v1.rdf;

import com.linkedpipes.etl.rdf.utils.pojo.DescriptorFactory;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -44,8 +42,4 @@ private RdfToPojo() {

}

public static DescriptorFactory descriptorFactory() {
return new AnnotationDescriptionFactory();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.linkedpipes.etl.executor.api.v1.rdf.model;

import com.linkedpipes.etl.executor.api.v1.rdf.RdfException;

import java.util.List;

/**
* TODO Remove information about GRAPH.
*/
public interface RdfSource {

@FunctionalInterface
interface StatementHandler {

void accept(String predicate, RdfValue value) throws RdfException;

}

void statements(String graph, String subject, StatementHandler handler)
throws RdfException;

List<RdfValue> getPropertyValues(
String graph, String subject, String predicate)
throws RdfException;

List<String> getByType(String graph, String type)
throws RdfException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.linkedpipes.etl.executor.api.v1.rdf.model;

import com.linkedpipes.etl.executor.api.v1.rdf.RdfException;

public interface RdfValue {

String asString();

String getLanguage();

String getType();

Boolean asBoolean() throws RdfException;

Long asLong() throws RdfException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.linkedpipes.etl.executor.api.v1.rdf.model;

import com.linkedpipes.etl.executor.api.v1.rdf.RdfException;

import java.util.Date;

public interface TripleWriter {

void iri(String subject, String predicate, String object);

void string(String subject, String predicate, String object);

void string(String subject, String predicate, String object, String lang);

void date(String subject, String predicate, Date object);

void typed(String subject, String predicate, String object, String type);

void flush() throws RdfException;

}
Loading

0 comments on commit 9b96469

Please sign in to comment.