use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate in project timbuctoo by HuygensING.
the class RdfDescriptionSaver method delValue.
@Override
public void delValue(String subject, String predicate, String value, String dataType, String graph) throws RdfProcessingFailedException {
try {
if (Objects.equals(subject, baseUri)) {
ValueFactory vf = SimpleValueFactory.getInstance();
model.remove(vf.createIRI(subject), vf.createIRI(predicate), vf.createLiteral(value));
}
} catch (Exception e) {
throw new RdfProcessingFailedException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate in project timbuctoo by HuygensING.
the class RdfDescriptionSaver method addRelation.
@Override
public void addRelation(String subject, String predicate, String object, String graph) throws RdfProcessingFailedException {
try {
if (Objects.equals(subject, baseUri) && isDescriptionPredicate(predicate)) {
ValueFactory vf = SimpleValueFactory.getInstance();
model.add(vf.createIRI(subject), vf.createIRI(predicate), vf.createIRI(object));
}
} catch (Exception e) {
throw new RdfProcessingFailedException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate in project timbuctoo by HuygensING.
the class BdbSchemaStore method setPredicateOccurrence.
public void setPredicateOccurrence(Type type, String predicateUri, Direction direction, int listMutation, int subjectMutation) {
final Predicate predicate = type.getOrCreatePredicate(predicateUri, direction);
predicate.registerListOccurrence(listMutation);
predicate.registerSubject(subjectMutation);
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate in project timbuctoo by HuygensING.
the class BdbSchemaStore method updatePredicateOccurrence.
public void updatePredicateOccurrence(List<Type> addedTypes, List<Type> removedTypes, List<Type> unchangedTypes, int retractedCount, int unchangedCount, int assertedCount, String predicate, Direction direction) {
if (!predicate.isEmpty()) {
boolean wasList = (retractedCount + unchangedCount) > 1;
boolean isList = (unchangedCount + assertedCount) > 1;
boolean wasPresent = (retractedCount + unchangedCount) > 0;
boolean isPresent = (unchangedCount + assertedCount) > 0;
for (Type type : removedTypes) {
setPredicateOccurrence(type, predicate, direction, wasList ? -1 : 0, wasPresent ? -1 : 0);
}
for (Type type : unchangedTypes) {
setPredicateOccurrence(type, predicate, direction, wasList == isList ? 0 : isList ? 1 : -1, wasPresent == isPresent ? 0 : isPresent ? 1 : -1);
}
for (Type type : addedTypes) {
setPredicateOccurrence(type, predicate, direction, isList ? 1 : 0, isPresent ? 1 : 0);
}
}
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate in project timbuctoo by HuygensING.
the class RdfWiringFactory method getDataFetcher.
@Override
public DataFetcher getDataFetcher(FieldWiringEnvironment environment) {
if (environment.getFieldDefinition().getDirective("passThrough") != null) {
return DataFetchingEnvironment::getSource;
} else if (environment.getFieldDefinition().getDirective("related") != null) {
final Directive directive = environment.getFieldDefinition().getDirective("related");
String source = ((StringValue) directive.getArgument("source").getValue()).getValue();
String predicate = ((StringValue) directive.getArgument("predicate").getValue()).getValue();
String direction = ((StringValue) directive.getArgument("direction").getValue()).getValue();
return new CollectionFetcherWrapper(argumentsHelper, new RelationsOfSubjectDataFetcher(source, predicate, Direction.valueOf(direction)));
} else if (environment.getFieldDefinition().getDirective("fromCollection") != null) {
final Directive directive = environment.getFieldDefinition().getDirective("fromCollection");
String uri = ((StringValue) directive.getArgument("uri").getValue()).getValue();
boolean listAll = ((BooleanValue) directive.getArgument("listAll").getValue()).isValue();
if (listAll) {
return new CollectionFetcherWrapper(argumentsHelper, new CollectionDataFetcher(uri));
} else {
return lookupFetcher;
}
} else if (environment.getFieldDefinition().getDirective("rdf") != null) {
final Directive directive = environment.getFieldDefinition().getDirective("rdf");
String uri = ((StringValue) directive.getArgument("predicate").getValue()).getValue();
Direction direction = valueOf(((StringValue) directive.getArgument("direction").getValue()).getValue());
boolean isList = ((BooleanValue) directive.getArgument("isList").getValue()).isValue();
boolean isObject = ((BooleanValue) directive.getArgument("isObject").getValue()).isValue();
boolean isValue = ((BooleanValue) directive.getArgument("isValue").getValue()).isValue();
if (isObject && isValue) {
return new DataFetcherWrapper(argumentsHelper, isList, new UnionDataFetcher(uri, direction));
} else {
if (isObject) {
return new DataFetcherWrapper(argumentsHelper, isList, new RelationDataFetcher(uri, direction));
} else {
return new DataFetcherWrapper(argumentsHelper, isList, new TypedLiteralDataFetcher(uri));
}
}
} else if (environment.getFieldDefinition().getDirective("uri") != null) {
return uriFetcher;
} else if (environment.getFieldDefinition().getDirective("dataSet") != null) {
final Directive directive = environment.getFieldDefinition().getDirective("dataSet");
String userId = ((StringValue) directive.getArgument("userId").getValue()).getValue();
String dataSetId = ((StringValue) directive.getArgument("dataSetId").getValue()).getValue();
final DataSet dataSet = dataSetRepository.unsafeGetDataSetWithoutCheckingPermissions(userId, dataSetId).orElse(null);
return dataFetchingEnvironment -> new DatabaseResult() {
@Override
public DataSet getDataSet() {
return dataSet;
}
};
} else if (environment.getFieldDefinition().getDirective("entityTitle") != null) {
return entityTitleFetcher;
} else if (environment.getFieldDefinition().getDirective("entityDescription") != null) {
return entityDescriptionFetcher;
} else if (environment.getFieldDefinition().getDirective("entityImage") != null) {
return entityImageFetcher;
}
return null;
}
Aggregations