Search in sources :

Example 16 with DataSet

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;
}
Also used : DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) SubjectReference(nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.SubjectReference) TypedValue(nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.TypedValue)

Example 17 with DataSet

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)));
}
Also used : DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) Test(org.junit.Test)

Example 18 with DataSet

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));
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) File(java.io.File) Test(org.junit.Test)

Example 19 with DataSet

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;
}
Also used : DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)

Example 20 with 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"))));
}
Also used : DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) DataSetRepository(nl.knaw.huygens.timbuctoo.v5.dataset.DataSetRepository) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLFieldsContainer(graphql.schema.GraphQLFieldsContainer) Test(org.junit.Test)

Aggregations

DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)44 DataSetRepository (nl.knaw.huygens.timbuctoo.v5.dataset.DataSetRepository)12 DataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData)12 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)12 Test (org.junit.Test)12 IOException (java.io.IOException)11 LogStorageFailedException (nl.knaw.huygens.timbuctoo.v5.filestorage.exceptions.LogStorageFailedException)11 Map (java.util.Map)10 GraphQLFieldDefinition (graphql.schema.GraphQLFieldDefinition)7 GraphQLFieldsContainer (graphql.schema.GraphQLFieldsContainer)7 List (java.util.List)7 Optional (java.util.Optional)7 ExecutionException (java.util.concurrent.ExecutionException)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 HashMap (java.util.HashMap)6 Collectors (java.util.stream.Collectors)6 ImportManager (nl.knaw.huygens.timbuctoo.v5.dataset.ImportManager)6 ImportStatus (nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus)6 DataStoreCreationException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataStoreCreationException)6