use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction 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.quadstore.dto.Direction 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.quadstore.dto.Direction in project timbuctoo by HuygensING.
the class BdbTruePatchStore method makeCursorQuad.
public CursorQuad makeCursorQuad(String subject, boolean assertions, String value) {
String[] parts = value.split("\n", 5);
Direction direction = parts[1].charAt(0) == '1' ? OUT : IN;
ChangeType changeType = assertions ? ChangeType.ASSERTED : ChangeType.RETRACTED;
return CursorQuad.create(subject, parts[0], direction, changeType, parts[4], parts[2].isEmpty() ? null : parts[2], parts[3].isEmpty() ? null : parts[3], "");
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction 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;
}
use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction in project timbuctoo by HuygensING.
the class MergeSchemasTest method createTypeWithPredicate.
private Type createTypeWithPredicate(String generated, Direction direction) {
Type generatedType = new Type("");
generatedType.getOrCreatePredicate(generated, direction);
generatedType.getPredicate(generated, direction).setIsExplicit(true);
return generatedType;
}
Aggregations