Search in sources :

Example 31 with Type

use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type in project timbuctoo by HuygensING.

the class JsonProvenanceToRdfPatchTest method testReplacement.

@Test
public void testReplacement() throws Exception {
    String testReplacement = "{\n" + "   \"@type\":\"prov:Activity\",\n" + "   \"http://www.w3.org/ns/prov#generates\":[\n" + "      {\n" + "         \"@type\":\"prov:Entity\",\n" + "         \"specializationOf\":{\n" + "            \"@id\":\"http://example.com/the/actual/entitys\"\n" + "         },\n" + "         \"replacements\":[\n" + "            {\n" + "               \"@type\":\"http://timbuctoo.huygens.knaw.nl/v5/vocabulary#mutation\",\n" + "               \"predicate\":\"http://example.org/pred1\",\n" + "               \"value\":\"value1\"\n" + "            }\n" + "         ]\n" + "      }\n" + "   ],\n" + context + "}";
    QuadStore testQuadStore = new DummyQuadStore().with("http://example.com/the/actual/entitys", "http://example.org/pred1", "old value", "http://www.w3.org/2001/XMLSchema#string");
    JsonProvenanceToRdfPatch creator = fromCurrentState(new DocumentLoader(), testReplacement, testQuadStore, EDITOR_URI, "test", CLOCK);
    creator.sendQuads(basicRdfPatchSerializer, s -> {
    }, null);
    List<String> filteredResult = Lists.newArrayList(Collections2.filter(result, Predicates.containsPattern("http://example.org/pred")));
    filteredResult = Lists.newArrayList(Collections2.filter(filteredResult, Predicates.not(Predicates.containsPattern("skolemized"))));
    assertThat(filteredResult, containsInAnyOrder("-<http://example.com/the/actual/entitys> <http://example.org/pred1> \"old value\"" + "^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n", "+<http://example.com/the/actual/entitys> <http://example.org/pred1> \"value1\"" + "^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n"));
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) DocumentLoader(com.github.jsonldjava.core.DocumentLoader) Test(org.junit.Test)

Example 32 with Type

use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type in project timbuctoo by HuygensING.

the class BdbSchemaStoreTest method generatesASchemaForAllAdded.

@Test
public void generatesASchemaForAllAdded() throws Exception {
    final DummyDataStorage dataStore = new DummyDataStorage();
    ChangeFetcher changeFetcher = new DummyChangeFetcher(CursorQuad.create("subj", "pred", Direction.OUT, ChangeType.ASSERTED, "obj", null, null, ""), CursorQuad.create("subj", RdfConstants.RDF_TYPE, Direction.OUT, ChangeType.ASSERTED, "type", null, null, ""), CursorQuad.create("obj", "pred", Direction.IN, ChangeType.ASSERTED, "subj", null, null, ""));
    BdbSchemaStore schemaStore = new BdbSchemaStore(dataStore, new ImportStatus(new LogList()));
    schemaStore.start();
    schemaStore.onChangedSubject("subj", changeFetcher);
    schemaStore.onChangedSubject("obj", changeFetcher);
    schemaStore.finish();
    assertThat(dataStore.getResult(), is("{\n" + "  \"http://timbuctoo.huygens.knaw.nl/static/v5/vocabulary#unknown\" : {\n" + "    \"name\" : \"http://timbuctoo.huygens.knaw.nl/static/v5/vocabulary#unknown\",\n" + "    \"predicates\" : [ {\n" + "      \"name\" : \"pred\",\n" + "      \"direction\" : \"IN\",\n" + "      \"valueTypes\" : { },\n" + "      \"referenceTypes\" : {\n" + "        \"type\" : 1\n" + "      },\n" + "      \"subjectsWithThisPredicate\" : 1,\n" + "      \"subjectsWithThisPredicateAsList\" : 0,\n" + "      \"hasBeenList\" : false,\n" + "      \"hasBeenSingular\" : true\n" + "    } ],\n" + "    \"subjectsWithThisType\" : 1\n" + "  },\n" + "  \"type\" : {\n" + "    \"name\" : \"type\",\n" + "    \"predicates\" : [ {\n" + "      \"name\" : \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n" + "      \"direction\" : \"OUT\",\n" + "      \"valueTypes\" : { },\n" + "      \"referenceTypes\" : {\n" + "        \"http://timbuctoo.huygens.knaw.nl/static/v5/vocabulary#unknown\" : 1\n" + "      },\n" + "      \"subjectsWithThisPredicate\" : 1,\n" + "      \"subjectsWithThisPredicateAsList\" : 0,\n" + "      \"hasBeenList\" : false,\n" + "      \"hasBeenSingular\" : true\n" + "    }, {\n" + "      \"name\" : \"pred\",\n" + "      \"direction\" : \"OUT\",\n" + "      \"valueTypes\" : { },\n" + "      \"referenceTypes\" : {\n" + "        \"http://timbuctoo.huygens.knaw.nl/static/v5/vocabulary#unknown\" : 1\n" + "      },\n" + "      \"subjectsWithThisPredicate\" : 1,\n" + "      \"subjectsWithThisPredicateAsList\" : 0,\n" + "      \"hasBeenList\" : false,\n" + "      \"hasBeenSingular\" : true\n" + "    } ],\n" + "    \"subjectsWithThisType\" : 1\n" + "  }\n" + "}"));
}
Also used : LogList(nl.knaw.huygens.timbuctoo.v5.dataset.dto.LogList) ImportStatus(nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus) ChangeFetcher(nl.knaw.huygens.timbuctoo.v5.dataset.ChangeFetcher) Test(org.junit.Test)

Example 33 with Type

use of nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type in project timbuctoo by HuygensING.

the class PredicateTest method createPredicate.

private Predicate createPredicate(String predicate12, Direction out, String testOwner) {
    Predicate predicate1 = new Predicate(predicate12, out);
    predicate1.setOwner(new Type(testOwner));
    return predicate1;
}
Also used : Type(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type) Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)

Aggregations

Type (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type)17 Test (org.junit.Test)13 HashMap (java.util.HashMap)9 Map (java.util.Map)8 Predicate (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)8 MergeSchemas (nl.knaw.huygens.timbuctoo.v5.graphql.customschema.MergeSchemas)8 IOException (java.io.IOException)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 List (java.util.List)5 Optional (java.util.Optional)5 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)5 QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)5 Logger (org.slf4j.Logger)5 ArrayList (java.util.ArrayList)4 ImportStatus (nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus)4 CursorQuad (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad)4 Direction (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction)4 DocumentLoader (com.github.jsonldjava.core.DocumentLoader)3 Collectors (java.util.stream.Collectors)3 LoggerFactory (org.slf4j.LoggerFactory)3