use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class EntityTitleFetcher method get.
@Override
public TypedValue get(DataFetchingEnvironment env) {
if (env.getSource() instanceof SubjectReference) {
SubjectReference source = env.getSource();
DataSet dataSet = source.getDataSet();
Optional<TypedValue> summaryProperty = summaryPropDataRetriever.createSummaryProperty(source, dataSet);
if (summaryProperty.isPresent()) {
return summaryProperty.get();
}
// fallback to the uri if no summary props can be found for the title
return TypedValue.create(source.getSubjectUri(), STRING, dataSet);
}
return null;
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method createDataSetReturnsTheSamesDataSetForEachCall.
@Test
public void createDataSetReturnsTheSamesDataSetForEachCall() throws Exception {
DataSet dataSet1 = dataSetRepository.createDataSet(User.create(null, "user"), "dataset");
DataSet dataSet2 = dataSetRepository.createDataSet(User.create(null, "user"), "dataset");
assertThat(dataSet1, is(sameInstance(dataSet2)));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method removeDataSetRemovesTheDataSetFromDisk.
@Test
public void removeDataSetRemovesTheDataSetFromDisk() throws Exception {
User user = User.create(null, "user");
final DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
File dataSetPath = new File(new File(tempFile, dataSet.getMetadata().getOwnerId()), "dataset");
assertThat(dataSetPath.exists(), is(true));
given(permissionFetcher.getPermissions(user, dataSet.getMetadata())).willReturn(Sets.newHashSet(Permission.ADMIN));
dataSetRepository.removeDataSet(dataSet.getMetadata().getOwnerId(), "dataset", user);
assertThat(dataSetPath.exists(), is(false));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class SummaryPropDataRetrieverTest method dataSetWithQuadStore.
private DataSet dataSetWithQuadStore(QuadStore quadStore) {
DataSet dataSet = mock(DataSet.class);
given(dataSet.getQuadStore()).willReturn(quadStore);
return dataSet;
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class PermissionBasedFieldVisibilityTest method getFieldDefinitionsShowsNonDataSetFields.
@Test
public void getFieldDefinitionsShowsNonDataSetFields() throws Exception {
final DataSetRepository dataSetRepository = mock(DataSetRepository.class);
DataSet dataSet = createDataSetWithUserPermissions("user__dataSetUserHasAccessTo", Sets.newHashSet(Permission.READ));
DataSet dataSet2 = createDataSetWithUserPermissions("user__dataSetUserDoesNotHasAccessTo", Sets.newHashSet());
Collection<DataSet> dataSetCollection = Sets.newHashSet(dataSet, dataSet2);
given(dataSetRepository.getDataSets()).willReturn(dataSetCollection);
final PermissionBasedFieldVisibility permissionBasedFieldVisibility = new PermissionBasedFieldVisibility(userPermissionCheck, dataSetRepository);
final GraphQLFieldsContainer graphQlFieldsContainer = createGraphQlFieldsContainer("user__dataSetUserHasAccessTo", "user__dataSetUserDoesNotHasAccessTo", "nonDataSetField");
List<GraphQLFieldDefinition> retrievedGraphQlFieldDefinitions = permissionBasedFieldVisibility.getFieldDefinitions(graphQlFieldsContainer);
assertThat(retrievedGraphQlFieldDefinitions, contains(hasProperty("name", is("user__dataSetUserHasAccessTo")), hasProperty("name", is("nonDataSetField"))));
}
Aggregations