use of nl.knaw.huygens.timbuctoo.v5.util.RdfConstants.TIM_SUMMARYIMAGEPREDICATE in project timbuctoo by HuygensING.
the class SummaryPropsMutation method executeAction.
@Override
public Object executeAction(DataFetchingEnvironment env) {
DataSet dataSet = MutationHelpers.getDataSet(env, dataSetRepository::getDataSet);
MutationHelpers.checkPermission(env, dataSet.getMetadata(), Permission.CHANGE_SUMMARYPROPS);
try {
String collectionUri = env.getArgument("collectionUri");
Map data = env.getArgument("summaryProperties");
final PredicateMutation mutation = new PredicateMutation();
mutation.entity(collectionUri, getValue(data, "title", dataSet).map(v -> replace(TIM_SUMMARYTITLEPREDICATE, value(v))).orElse(null), getValue(data, "image", dataSet).map(v -> replace(TIM_SUMMARYIMAGEPREDICATE, value(v))).orElse(null), getValue(data, "description", dataSet).map(v -> replace(TIM_SUMMARYDESCRIPTIONPREDICATE, value(v))).orElse(null));
MutationHelpers.addMutation(dataSet, mutation);
return new LazyTypeSubjectReference(collectionUri, Optional.empty(), dataSet);
} catch (LogStorageFailedException | InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.util.RdfConstants.TIM_SUMMARYIMAGEPREDICATE in project timbuctoo by HuygensING.
the class SummaryPropsMutation method get.
@Override
public Object get(DataFetchingEnvironment env) {
DataSet dataSet = MutationHelpers.getDataSet(env, dataSetRepository::getDataSet);
MutationHelpers.checkAdminPermissions(env, dataSet.getMetadata());
try {
String collectionUri = env.getArgument("collectionUri");
Map data = env.getArgument("summaryProperties");
final PredicateMutation mutation = new PredicateMutation();
mutation.entity(collectionUri, getValue(data, "title").map(v -> replace(TIM_SUMMARYTITLEPREDICATE, value(v))).orElse(null), getValue(data, "image").map(v -> replace(TIM_SUMMARYIMAGEPREDICATE, value(v))).orElse(null), getValue(data, "description").map(v -> replace(TIM_SUMMARYDESCRIPTIONPREDICATE, value(v))).orElse(null));
MutationHelpers.addMutation(dataSet, mutation);
return new LazyTypeSubjectReference(collectionUri, dataSet);
} catch (LogStorageFailedException | InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
Aggregations