use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.addMutation in project timbuctoo by HuygensING.
the class ViewConfigMutation method get.
@Override
public Object get(DataFetchingEnvironment env) {
String collectionUri = env.getArgument("collectionUri");
Object viewConfig = env.getArgument("viewConfig");
DataSet dataSet = MutationHelpers.getDataSet(env, dataSetRepository::getDataSet);
MutationHelpers.checkAdminPermissions(env, dataSet.getMetadata());
try {
MutationHelpers.addMutation(dataSet, new PredicateMutation().entity(collectionUri, replace(HAS_VIEW_CONFIG, value(OBJECT_MAPPER.writeValueAsString(viewConfig)))));
return viewConfig;
} catch (LogStorageFailedException | InterruptedException | ExecutionException | JsonProcessingException e) {
throw new RuntimeException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.addMutation 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.graphql.mutations.MutationHelpers.addMutation in project timbuctoo by HuygensING.
the class IndexConfigMutation method get.
@Override
public Object get(DataFetchingEnvironment env) {
String collectionUri = env.getArgument("collectionUri");
Object indexConfig = env.getArgument("indexConfig");
DataSet dataSet = MutationHelpers.getDataSet(env, dataSetRepository::getDataSet);
MutationHelpers.checkAdminPermissions(env, dataSet.getMetadata());
try {
MutationHelpers.addMutation(dataSet, new PredicateMutation().entity(collectionUri, replace(TIM_HASINDEXERCONFIG, value(OBJECT_MAPPER.writeValueAsString(indexConfig)))));
return indexConfig;
} catch (LogStorageFailedException | InterruptedException | ExecutionException | JsonProcessingException e) {
throw new RuntimeException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.addMutation 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);
}
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.addMutation in project timbuctoo by HuygensING.
the class CollectionMetadataMutation 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("metadata");
final PredicateMutation mutation = new PredicateMutation();
mutation.entity(collectionUri, getValue(data, "title").map(v -> replace(RDFS_LABEL, value(v))).orElse(null), getValue(data, "archeType").map(v -> replace("http://www.w3.org/2000/01/rdf-schema#subClassOf", subject(v))).orElse(null));
MutationHelpers.addMutation(dataSet, mutation);
return new LazyTypeSubjectReference(collectionUri, dataSet);
} catch (LogStorageFailedException | InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
Aggregations