-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
530 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
rdfunit-core/src/main/java/org/aksw/rdfunit/model/helper/AnnotationTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.aksw.rdfunit.model.helper; | ||
|
||
import com.google.common.collect.Maps; | ||
import com.google.common.collect.Range; | ||
import com.hp.hpl.jena.rdf.model.Property; | ||
|
||
import java.util.HashMap; | ||
import java.util.Set; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/28/15 8:47 PM | ||
*/ | ||
public final class AnnotationTemplate { | ||
private final HashMap<Property, Range<Integer>> template = Maps.newHashMap(); | ||
|
||
private AnnotationTemplate() { } | ||
|
||
public static AnnotationTemplate create() { return new AnnotationTemplate(); } | ||
|
||
public void addTemplateMin(Property property, int minOccurs) { | ||
template.put(property, Range.<Integer>atLeast(minOccurs)); | ||
} | ||
|
||
public void addTemplateMax(Property property, int maxOccurs) { | ||
template.put(property, Range.<Integer>atMost(maxOccurs)); | ||
} | ||
|
||
public void addTemplateMinMax(Property property, int minOccurs, int maxOccurs) { | ||
template.put(property, Range.<Integer>closed(minOccurs, maxOccurs)); | ||
} | ||
|
||
public Set<Property> getProprtiesAsSet() { | ||
return template.keySet(); | ||
} | ||
|
||
public boolean existsInTemplate(SimpleAnnotation simpleAnnotation) { | ||
return template.containsKey(simpleAnnotation.getProperty()); | ||
} | ||
|
||
public boolean isValidAccordingToTemplate(SimpleAnnotation simpleAnnotation) { | ||
int occurences = simpleAnnotation.getValues().size(); | ||
if (existsInTemplate(simpleAnnotation)) { | ||
return template.get(simpleAnnotation.getProperty()).contains(occurences); | ||
} | ||
return false; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
rdfunit-core/src/main/java/org/aksw/rdfunit/model/helper/SelectVar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.aksw.rdfunit.model.helper; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* Holds a select variable mapping | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/28/15 4:39 PM | ||
*/ | ||
public final class SelectVar { | ||
private final String name; | ||
private final String label; | ||
|
||
private SelectVar(String name, String label) { | ||
this.name = checkNotNull(name); | ||
this.label = checkNotNull(label); | ||
} | ||
|
||
public static SelectVar create(String name) { | ||
return new SelectVar(name, name); | ||
} | ||
|
||
public static SelectVar create(String name, String label) { | ||
return new SelectVar(name, label); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
if (isLabeled()) { | ||
return " ( ?" + name + " AS ?" +label + " ) "; | ||
} else { | ||
return " ?" + name + " "; | ||
} | ||
} | ||
|
||
private boolean isLabeled() { | ||
return !label.equals(name); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
rdfunit-core/src/main/java/org/aksw/rdfunit/model/helper/SimpleAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.aksw.rdfunit.model.helper; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.hp.hpl.jena.rdf.model.Property; | ||
import com.hp.hpl.jena.rdf.model.RDFNode; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/28/15 8:36 PM | ||
*/ | ||
public final class SimpleAnnotation { | ||
private final Property property; | ||
private final Collection<RDFNode> values; | ||
|
||
private SimpleAnnotation(Property property, Collection<RDFNode> values) { | ||
this.property = checkNotNull(property); | ||
this.values = ImmutableList.copyOf(checkNotNull(values)); | ||
} | ||
|
||
public static SimpleAnnotation create(Property property, RDFNode rdfNode) { | ||
return new SimpleAnnotation(property, Arrays.asList(rdfNode)); | ||
} | ||
|
||
public static SimpleAnnotation create(Property property, Collection<RDFNode> rdfNode) { | ||
return new SimpleAnnotation(property, rdfNode); | ||
} | ||
|
||
public Property getProperty() { | ||
return property; | ||
} | ||
|
||
public Collection<RDFNode> getValues() { | ||
return values; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
rdfunit-core/src/main/java/org/aksw/rdfunit/model/impl/ConstraintTemplateImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.aksw.rdfunit.model.impl; | ||
|
||
import com.google.common.base.Optional; | ||
import com.hp.hpl.jena.rdf.model.Property; | ||
import com.hp.hpl.jena.rdf.model.Resource; | ||
import org.aksw.rdfunit.enums.RLOGLevel; | ||
import org.aksw.rdfunit.model.interfaces.Argument; | ||
import org.aksw.rdfunit.model.interfaces.ConstraintTemplate; | ||
import org.aksw.rdfunit.model.interfaces.ResultAnnotation; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 4:06 PM | ||
* @version $Id: $Id | ||
*/ | ||
public class ConstraintTemplateImpl implements ConstraintTemplate { | ||
|
||
|
||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public String getDefaultMessage() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Property getPrperty() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Collection<ResultAnnotation> getResultAnnotations() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public RLOGLevel getSeverity() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Collection<Argument> getArguments() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public String getSparql() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Optional<String> getLabelTemplate() { | ||
return null; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Optional<Resource> getResource() { | ||
return null; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
rdfunit-core/src/main/java/org/aksw/rdfunit/model/interfaces/ConstraintTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.aksw.rdfunit.model.interfaces; | ||
|
||
import com.hp.hpl.jena.rdf.model.Property; | ||
import org.aksw.rdfunit.enums.RLOGLevel; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 2:12 PM | ||
* @version $Id: $Id | ||
*/ | ||
public interface ConstraintTemplate extends Template { | ||
|
||
//TODO multiple languages | ||
/** | ||
* <p>getDefaultMessage.</p> | ||
* | ||
* @return a {@link java.lang.String} object. | ||
*/ | ||
String getDefaultMessage(); | ||
|
||
/** | ||
* <p>getPrperty.</p> | ||
* | ||
* @return a {@link com.hp.hpl.jena.rdf.model.Property} object. | ||
*/ | ||
Property getPrperty(); | ||
|
||
/** | ||
* <p>getResultAnnotations.</p> | ||
* | ||
* @return a {@link java.util.Collection} object. | ||
*/ | ||
Collection<ResultAnnotation> getResultAnnotations(); | ||
|
||
/** | ||
* <p>getSeverity.</p> | ||
* | ||
* @return a {@link org.aksw.rdfunit.enums.RLOGLevel} object. | ||
*/ | ||
RLOGLevel getSeverity(); | ||
} |
11 changes: 11 additions & 0 deletions
11
rdfunit-core/src/main/java/org/aksw/rdfunit/model/interfaces/PropertyConstraint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.aksw.rdfunit.model.interfaces; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 12:18 AM | ||
* @version $Id: $Id | ||
*/ | ||
public interface PropertyConstraint { | ||
} |
12 changes: 12 additions & 0 deletions
12
rdfunit-core/src/main/java/org/aksw/rdfunit/model/interfaces/Scope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.aksw.rdfunit.model.interfaces; | ||
|
||
/** | ||
* aSHACL scope | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 11:46 AM | ||
* @version $Id: $Id | ||
*/ | ||
public interface Scope extends Element{ | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
rdfunit-core/src/main/java/org/aksw/rdfunit/model/interfaces/Shape.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.aksw.rdfunit.model.interfaces; | ||
|
||
import com.google.common.base.Optional; | ||
import org.aksw.rdfunit.enums.RLOGLevel; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* A SHACL Shape | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 12:18 AM | ||
* @version $Id: $Id | ||
*/ | ||
public interface Shape extends Element{ | ||
|
||
/** | ||
* <p>getScope.</p> | ||
* | ||
* @return a {@link com.google.common.base.Optional} object. | ||
*/ | ||
Optional<Scope> getScope(); | ||
|
||
/** | ||
* <p>getLogLevel.</p> | ||
* | ||
* @return a {@link com.google.common.base.Optional} object. | ||
*/ | ||
Optional<RLOGLevel> getSeverityLevel(); | ||
|
||
/** | ||
* <p>getPropertyConstraints.</p> | ||
* | ||
* @return a {@link java.util.Collection} object. | ||
*/ | ||
Collection<PropertyConstraint> getPropertyConstraints(); | ||
} |
36 changes: 36 additions & 0 deletions
36
rdfunit-core/src/main/java/org/aksw/rdfunit/model/interfaces/Template.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.aksw.rdfunit.model.interfaces; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Description | ||
* | ||
* @author Dimitris Kontokostas | ||
* @since 8/21/15 2:30 PM | ||
* @version $Id: $Id | ||
*/ | ||
public interface Template extends Element { | ||
|
||
/** | ||
* <p>getArguments.</p> | ||
* | ||
* @return a {@link java.util.Collection} object. | ||
*/ | ||
Collection<Argument> getArguments(); | ||
|
||
/** | ||
* <p>getSparql.</p> | ||
* | ||
* @return a {@link java.lang.String} object. | ||
*/ | ||
String getSparql(); | ||
|
||
/** | ||
* <p>getLabelTemplate.</p> | ||
* | ||
* @return a {@link com.google.common.base.Optional} object. | ||
*/ | ||
Optional<String> getLabelTemplate(); | ||
} |
Oops, something went wrong.