Skip to content

Commit

Permalink
Merge pull request #10 from yngwi:0.1.2
Browse files Browse the repository at this point in the history
0.1.2
  • Loading branch information
yngwi authored May 15, 2021
2 parents a057652 + 6c7f588 commit 69a1eea
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 68 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>eu.nampi</groupId>
<artifactId>backend</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<name>nampi-backend</name>
<description>The NAMPI backend</description>

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/eu/nampi/backend/repository/ActRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public class ActRepository extends AbstractHydraRepository {
model
.add(main, Core.isAuthoredOn, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime, row.getLiteral(VAR_DATE_TIME.toString()));
.add(resDate, Core.hasDateTime, row.getLiteral(VAR_DATE_TIME.toString()));
// Source location
Resource resLocation = row.getResource(VAR_LOC.toString());
model
.add(main, Core.hasSourceLocation, resLocation)
.add(resLocation, RDF.type, Core.sourceLocation)
.add(resLocation, Core.hasXsdString, row.getLiteral(VAR_LOC_STRING.toString()));
.add(resLocation, Core.hasText, row.getLiteral(VAR_LOC_STRING.toString()));
// Source
Resource resSource = row.getResource(VAR_SRC.toString());
model
Expand Down Expand Up @@ -142,12 +142,12 @@ private void addData(WhereBuilder builder) {
.addWhere(VAR_INT, RDFS.label, VAR_INT_LABEL)

.addWhere(VAR_MAIN, Core.hasSourceLocation, VAR_LOC)
.addWhere(VAR_LOC, Core.hasXsdString, VAR_LOC_STRING)
.addWhere(VAR_LOC, Core.hasText, VAR_LOC_STRING)
.addWhere(VAR_LOC, Core.hasSource, VAR_SRC)
.addWhere(VAR_SRC, RDFS.label, VAR_SRC_LABEL)

.addWhere(VAR_MAIN, Core.isAuthoredOn, VAR_DATE)
.addWhere(VAR_DATE, Core.hasXsdDateTime, VAR_DATE_TIME);
.addWhere(VAR_DATE, Core.hasDateTime, VAR_DATE_TIME);
}

}
11 changes: 5 additions & 6 deletions src/main/java/eu/nampi/backend/repository/AspectRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import eu.nampi.backend.model.hydra.HydraSingleBuilder;
import eu.nampi.backend.vocabulary.Api;
import eu.nampi.backend.vocabulary.Core;
import eu.nampi.backend.vocabulary.SchemaOrg;

@Repository
@CacheConfig(cacheNames = "aspects")
Expand All @@ -51,10 +50,10 @@ public class AspectRepository extends AbstractHydraRepository {
.ifPresent(comment -> model.add(main, RDFS.comment, comment));
// XSD-String
Optional.ofNullable(row.getLiteral(VAR_STRING.toString())).map(Literal::getString)
.ifPresent(string -> model.add(main, Core.hasXsdString, string));
.ifPresent(string -> model.add(main, Core.hasText, string));
// SameAs
Optional.ofNullable(row.getResource(VAR_SAME_AS.toString())).map(Resource::getURI)
.ifPresent(string -> model.add(main, SchemaOrg.sameAs, string));
.ifPresent(string -> model.add(main, Core.sameAs, string));
return main;
};

Expand All @@ -79,7 +78,7 @@ public String findAll(QueryParameters params, Lang lang, Optional<String> partic
Node varSearchString = NodeFactory.createVariable("searchString");
Path path = PathFactory.pathAlt(
PathFactory.pathLink(RDFS.label.asNode()),
PathFactory.pathLink(Core.hasXsdString.asNode()));
PathFactory.pathLink(Core.hasText.asNode()));
builder.coreData
.addOptional(VAR_MAIN, path, varSearchString)
.addFilter(ef.regex(varSearchString, params.getText().get(), "i"));
Expand All @@ -104,8 +103,8 @@ private String build(AbstractHydraBuilder builder, Lang lang) {

private void addData(WhereBuilder builder) {
builder
.addOptional(VAR_MAIN, Core.hasXsdString, VAR_STRING)
.addOptional(VAR_MAIN, SchemaOrg.sameAs, VAR_SAME_AS);
.addOptional(VAR_MAIN, Core.hasText, VAR_STRING)
.addOptional(VAR_MAIN, Core.sameAs, VAR_SAME_AS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ private void addAspectClass(Class doc) {
Class aspect = new Class(Core.aspect, Core.aspect.getLocalName());
aspect.addSupportedProperty(new SupportedProperty(RDFS.label, XSD.xstring,
RDFS.label.getLocalName(), true, false, false));
aspect.addSupportedProperty(new SupportedProperty(Core.hasXsdString, XSD.xstring,
Core.hasXsdString.getLocalName(), true, false, false));
aspect.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
aspect.addSupportedProperty(new SupportedProperty(Core.hasText, XSD.xstring,
Core.hasText.getLocalName(), true, false, false));
aspect.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, aspect);
}

Expand All @@ -104,8 +104,8 @@ private void addClassClass(Class doc) {

private void addDateClass(Class doc) {
Class date = new Class(Core.date, Core.date.getLocalName());
date.addSupportedProperty(new SupportedProperty(Core.hasXsdDateTime, XSD.dateTime,
Core.hasXsdDateTime.getLocalName(), true, false, false));
date.addSupportedProperty(new SupportedProperty(Core.hasDateTime, XSD.dateTime,
Core.hasDateTime.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, date);
}

Expand Down Expand Up @@ -134,17 +134,17 @@ private void addGroupClass(Class doc) {
Class group = new Class(Core.group, Core.group.getLocalName());
group.addSupportedProperty(new SupportedProperty(RDFS.label, XSD.xstring,
RDFS.label.getLocalName(), true, false, false));
group.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
group.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, group);
}

private void addPersonClass(Class doc) {
Class person = new Class(Core.person, Core.person.getLocalName());
person.addSupportedProperty(new SupportedProperty(RDFS.label, XSD.xstring,
RDFS.label.getLocalName(), true, false, false));
person.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
person.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
person.addSupportedProperty(new SupportedProperty(Core.isBornIn, Core.event,
Core.isBornIn.getLocalName(), true, false, false));
person.addSupportedProperty(new SupportedProperty(Core.diesIn, Core.event,
Expand All @@ -156,26 +156,26 @@ private void addPlaceClass(Class doc) {
Class place = new Class(Core.place, Core.place.getLocalName());
place.addSupportedProperty(new SupportedProperty(RDFS.label, XSD.xstring,
RDFS.label.getLocalName(), true, false, false));
place.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
place.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, place);
}

private void addSourceClass(Class doc) {
Class source = new Class(Core.source, Core.source.getLocalName());
source.addSupportedProperty(new SupportedProperty(RDFS.label, XSD.xstring,
RDFS.label.getLocalName(), true, false, false));
source.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
source.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, source);
}

private void addSourceLocationClass(Class doc) {
Class sourceLocation = new Class(Core.sourceLocation, Core.sourceLocation.getLocalName());
sourceLocation.addSupportedProperty(new SupportedProperty(Core.hasSource, Core.source,
Core.hasSource.getLocalName(), true, false, false));
sourceLocation.addSupportedProperty(new SupportedProperty(Core.hasXsdString, XSD.xstring,
Core.hasXsdString.getLocalName(), true, false, false));
sourceLocation.addSupportedProperty(new SupportedProperty(Core.hasText, XSD.xstring,
Core.hasText.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, sourceLocation);
}

Expand All @@ -193,8 +193,8 @@ private void addUserClass(Class doc) {
SchemaOrg.identifier.getNameSpace(), true, false, false));
user.addSupportedProperty(new SupportedProperty(SchemaOrg.email, XSD.xstring,
SchemaOrg.email.getLocalName(), true, false, false));
user.addSupportedProperty(new SupportedProperty(SchemaOrg.sameAs, SchemaOrg.URL,
SchemaOrg.sameAs.getLocalName(), true, false, false));
user.addSupportedProperty(new SupportedProperty(Core.sameAs, SchemaOrg.URL,
Core.sameAs.getLocalName(), true, false, false));
doc.add(Hydra.supportedClass, user);
}

Expand Down
21 changes: 10 additions & 11 deletions src/main/java/eu/nampi/backend/repository/EventRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public class EventRepository extends AbstractHydraRepository {
private static final Node VAR_PLACE_LABEL = NodeFactory.createVariable("placeLabel");

private static final BiFunction<Model, QuerySolution, RDFNode> ROW_MAPPER = (model, row) -> {
System.out.println(row);
Resource main = row.getResource(VAR_MAIN.toString());
// Main
model.add(main, RDF.type, Core.event);
Expand All @@ -87,7 +86,7 @@ public class EventRepository extends AbstractHydraRepository {
Optional.ofNullable(row.getLiteral(VAR_ASPECT_LABEL.toString()))
.ifPresent(label -> model.add(aspect, RDFS.label, label));
Optional.ofNullable(row.getLiteral(VAR_ASPECT_STRING.toString()))
.ifPresent(str -> model.add(aspect, Core.hasXsdString, str));
.ifPresent(str -> model.add(aspect, Core.hasText, str));
});
// Participant
Optional.ofNullable(row.getResource(VAR_PARTICIPANT.toString()))
Expand All @@ -108,31 +107,31 @@ public class EventRepository extends AbstractHydraRepository {
model
.add(main, Core.takesPlaceOn, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime, dateTime);
.add(resDate, Core.hasDateTime, dateTime);
});
// Earliest date
Optional.ofNullable(row.getLiteral(VAR_DATE_TIME_EARLIEST.toString())).ifPresent(dateTime -> {
Resource resDate = row.getResource(VAR_DATE_EARLIEST.toString());
model
.add(main, Core.takesPlaceNotEarlierThan, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime, dateTime);
.add(resDate, Core.hasDateTime, dateTime);
});
// Latest date
Optional.ofNullable(row.getLiteral(VAR_DATE_TIME_LATEST.toString())).ifPresent(dateTime -> {
Resource resDate = row.getResource(VAR_DATE_LATEST.toString());
model
.add(main, Core.takesPlaceNotLaterThan, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime, dateTime);
.add(resDate, Core.hasDateTime, dateTime);
});
// Sorting date
Optional.ofNullable(row.getLiteral(VAR_DATE_OUTER.toString())).ifPresent(dateTime -> {
Resource resDate = row.getResource(VAR_DATE_REAL_SORT_OUTER.toString());
model
.add(main, Core.hasSortingDate, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime, dateTime);
.add(resDate, Core.hasDateTime, dateTime);
});
return main;
};
Expand Down Expand Up @@ -269,7 +268,7 @@ private WhereBuilder aspectWhere() {
return new WhereBuilder()
.addWhere(VAR_MAIN, Core.usesAspect, VAR_ASPECT)
.addWhere(VAR_ASPECT, RDFS.label, VAR_ASPECT_LABEL)
.addOptional(VAR_ASPECT, Core.hasXsdString, VAR_ASPECT_STRING);
.addOptional(VAR_ASPECT, Core.hasText, VAR_ASPECT_STRING);
}

private WhereBuilder datesWhere(Order order, Node varDate, Node varDateTime) {
Expand All @@ -278,16 +277,16 @@ private WhereBuilder datesWhere(Order order, Node varDate, Node varDateTime) {
builder
.addOptional(new WhereBuilder()
.addWhere(VAR_MAIN, Core.takesPlaceOn, VAR_DATE_EXACT)
.addWhere(VAR_DATE_EXACT, Core.hasXsdDateTime, VAR_DATE_TIME_EXACT))
.addWhere(VAR_DATE_EXACT, Core.hasDateTime, VAR_DATE_TIME_EXACT))
.addOptional(new WhereBuilder()
.addWhere(VAR_MAIN, Core.takesPlaceNotEarlierThan, VAR_DATE_EARLIEST)
.addWhere(VAR_DATE_EARLIEST, Core.hasXsdDateTime, VAR_DATE_TIME_EARLIEST))
.addWhere(VAR_DATE_EARLIEST, Core.hasDateTime, VAR_DATE_TIME_EARLIEST))
.addOptional(new WhereBuilder()
.addWhere(VAR_MAIN, Core.takesPlaceNotLaterThan, VAR_DATE_LATEST)
.addWhere(VAR_DATE_LATEST, Core.hasXsdDateTime, VAR_DATE_TIME_LATEST))
.addWhere(VAR_DATE_LATEST, Core.hasDateTime, VAR_DATE_TIME_LATEST))
.addOptional(new WhereBuilder()
.addWhere(VAR_MAIN, Core.hasSortingDate, VAR_DATE_SORT)
.addWhere(VAR_DATE_SORT, Core.hasXsdDateTime, VAR_DATE_TIME_SORT))
.addWhere(VAR_DATE_SORT, Core.hasDateTime, VAR_DATE_TIME_SORT))
.addBind(
ef.cond(ef.bound(VAR_DATE_SORT), ef.asVar(VAR_DATE_SORT),
ef.cond(ef.bound(VAR_DATE_EXACT), ef.asVar(VAR_DATE_EXACT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import eu.nampi.backend.model.hydra.HydraSingleBuilder;
import eu.nampi.backend.vocabulary.Api;
import eu.nampi.backend.vocabulary.Core;
import eu.nampi.backend.vocabulary.SchemaOrg;

@Repository
@CacheConfig(cacheNames = "groups")
Expand All @@ -45,7 +44,7 @@ public class GroupRepository extends AbstractHydraRepository {
.ifPresent(comment -> model.add(main, RDFS.comment, comment));
// SameAs
Optional.ofNullable(row.getResource(VAR_SAME_AS.toString())).map(Resource::getURI)
.ifPresent(string -> model.add(main, SchemaOrg.sameAs, string));
.ifPresent(string -> model.add(main, Core.sameAs, string));
return main;
};

Expand All @@ -54,15 +53,15 @@ public class GroupRepository extends AbstractHydraRepository {
public String findAll(QueryParameters params, Lang lang) {
HydraCollectionBuilder builder = new HydraCollectionBuilder(jenaService, endpointUri("groups"),
Core.group, Api.groupOrderByVar, params);
builder.extendedData.addOptional(VAR_MAIN, SchemaOrg.sameAs, VAR_SAME_AS);
builder.extendedData.addOptional(VAR_MAIN, Core.sameAs, VAR_SAME_AS);
return build(builder, lang);
}

@Cacheable(key = "{#lang, #id}")
public String findOne(Lang lang, UUID id) {
HydraSingleBuilder builder =
new HydraSingleBuilder(jenaService, individualsUri(Core.group, id), Core.group);
builder.coreData.addOptional(VAR_MAIN, SchemaOrg.sameAs, VAR_SAME_AS);
builder.coreData.addOptional(VAR_MAIN, Core.sameAs, VAR_SAME_AS);
return build(builder, lang);
}

Expand Down
21 changes: 10 additions & 11 deletions src/main/java/eu/nampi/backend/repository/PersonRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import eu.nampi.backend.model.hydra.HydraSingleBuilder;
import eu.nampi.backend.vocabulary.Api;
import eu.nampi.backend.vocabulary.Core;
import eu.nampi.backend.vocabulary.SchemaOrg;

@Repository
@CacheConfig(cacheNames = "persons")
Expand All @@ -50,7 +49,7 @@ public class PersonRepository extends AbstractHydraRepository {
.ifPresent(comment -> model.add(main, RDFS.comment, comment));
// SameAs
Optional.ofNullable(row.getResource(VAR_SAME_AS.toString())).map(Resource::getURI)
.ifPresent(string -> model.add(main, SchemaOrg.sameAs, string));
.ifPresent(string -> model.add(main, Core.sameAs, string));
// Birth
addEvent(model, row, main, PREF_BIRTH, Core.isBornIn);
addEvent(model, row, main, PREF_DEATH, Core.diesIn);
Expand All @@ -70,25 +69,25 @@ private static final void addEvent(Model model, QuerySolution row, Resource main
.ifPresent(resDate -> model
.add(evt, Core.takesPlaceAt, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime,
.add(resDate, Core.hasDateTime,
row.getLiteral(varDateTimeExact(base).toString())));
Optional.ofNullable(row.getResource(varDateNotEarlier(base).toString()))
.ifPresent(resDate -> model
.add(evt, Core.takesPlaceNotEarlierThan, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime,
.add(resDate, Core.hasDateTime,
row.getLiteral(varDateTimeNotEarlier(base).toString())));
Optional.ofNullable(row.getResource(varDateNotLater(base).toString()))
.ifPresent(resDate -> model
.add(evt, Core.takesPlaceNotLaterThan, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime,
.add(resDate, Core.hasDateTime,
row.getLiteral(varDateTimeNotLater(base).toString())));
Optional.ofNullable(row.getResource(varDateSort(base).toString()))
.ifPresent(resDate -> model
.add(evt, Core.hasSortingDate, resDate)
.add(resDate, RDF.type, Core.date)
.add(resDate, Core.hasXsdDateTime,
.add(resDate, Core.hasDateTime,
row.getLiteral(varDateTimeSort(base).toString())));
});
}
Expand Down Expand Up @@ -119,7 +118,7 @@ private WhereBuilder dataWhere() {
return new WhereBuilder()
.addWhere(eventWhere(PREF_BIRTH, Core.isBornIn))
.addWhere(eventWhere(PREF_DEATH, Core.diesIn))
.addOptional(VAR_MAIN, SchemaOrg.sameAs, VAR_SAME_AS);
.addOptional(VAR_MAIN, Core.sameAs, VAR_SAME_AS);
}

private WhereBuilder eventWhere(String base, Property type) {
Expand All @@ -130,17 +129,17 @@ private WhereBuilder eventWhere(String base, Property type) {
.addWhere(var, RDFS.label, varEventLabel(base))
.addOptional(new WhereBuilder()
.addWhere(var, Core.takesPlaceOn, varDateExact(base))
.addWhere(varDateExact(base), Core.hasXsdDateTime, varDateTimeExact(base)))
.addWhere(varDateExact(base), Core.hasDateTime, varDateTimeExact(base)))
.addOptional(new WhereBuilder()
.addWhere(var, Core.takesPlaceNotEarlierThan, varDateNotEarlier(base))
.addWhere(varDateNotEarlier(base), Core.hasXsdDateTime,
.addWhere(varDateNotEarlier(base), Core.hasDateTime,
varDateTimeNotEarlier(base)))
.addOptional(new WhereBuilder()
.addWhere(var, Core.takesPlaceNotLaterThan, varDateNotLater(base))
.addWhere(varDateNotLater(base), Core.hasXsdDateTime, varDateTimeNotLater(base)))
.addWhere(varDateNotLater(base), Core.hasDateTime, varDateTimeNotLater(base)))
.addOptional(new WhereBuilder()
.addWhere(var, Core.hasSortingDate, varDateSort(base))
.addWhere(varDateSort(base), Core.hasXsdDateTime, varDateTimeSort(base))));
.addWhere(varDateSort(base), Core.hasDateTime, varDateTimeSort(base))));
}

private static Node varDateExact(String base) {
Expand Down
Loading

0 comments on commit 69a1eea

Please sign in to comment.