Search in sources :

Example 11 with Predicate

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

the class PredicateTest method mergeThrowsExceptionIfPredicateDirectionsDontMatch.

@Test(expected = IllegalArgumentException.class)
public void mergeThrowsExceptionIfPredicateDirectionsDontMatch() throws Exception {
    Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    Predicate predicate2 = createPredicate("predicate", Direction.IN, "testOwner");
    predicate1.merge(predicate2);
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 12 with Predicate

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

the class PredicateTest method mergeCombinesValuesMap.

@Test
public void mergeCombinesValuesMap() throws Exception {
    Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    Map<String, Long> valueTypes1 = new HashMap<>();
    valueTypes1.put("Test Value", 1L);
    valueTypes1.put("Test Value 2", 1L);
    predicate1.setValueTypes(valueTypes1);
    final Predicate predicate2 = createPredicate("predicate", Direction.OUT, "testOwner");
    Map<String, Long> valueTypes2 = new HashMap<>();
    valueTypes2.put("Test Value", 1L);
    valueTypes2.put("Test Value 2", 1L);
    valueTypes2.put("Test Value 3", 1L);
    predicate2.setValueTypes(valueTypes2);
    Predicate mergedPredicate = predicate1.merge(predicate2);
    assertThat(mergedPredicate.getValueTypes(), IsMapContaining.hasEntry("Test Value", 2L));
    assertThat(mergedPredicate.getValueTypes(), IsMapContaining.hasEntry("Test Value 2", 2L));
    assertThat(mergedPredicate.getValueTypes(), IsMapContaining.hasEntry("Test Value 3", 1L));
}
Also used : HashMap(java.util.HashMap) Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 13 with Predicate

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

the class PredicateTest method mergeThrowsExceptionIfPredicateOwnersDontMatch.

@Test(expected = IllegalArgumentException.class)
public void mergeThrowsExceptionIfPredicateOwnersDontMatch() throws Exception {
    Predicate predicate1 = createPredicate("predicate", Direction.OUT, "testOwner");
    Predicate predicate2 = createPredicate("predicate", Direction.OUT, "testOwner2");
    predicate1.merge(predicate2);
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 14 with Predicate

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

the class PredicateTest method mergeThrowsExceptionIfPredicateNamesDontMatch.

@Test(expected = IllegalArgumentException.class)
public void mergeThrowsExceptionIfPredicateNamesDontMatch() throws Exception {
    Predicate predicate1 = createPredicate("predicate1", Direction.OUT, "testOwner");
    Predicate predicate2 = createPredicate("predicate2", Direction.OUT, "testOwner");
    predicate1.merge(predicate2);
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate) Test(org.junit.Test)

Example 15 with Predicate

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

the class RdfDescriptionSaver method delRelation.

@Override
public void delRelation(String subject, String predicate, String object, String graph) throws RdfProcessingFailedException {
    try {
        if (Objects.equals(subject, baseUri)) {
            ValueFactory vf = SimpleValueFactory.getInstance();
            model.remove(vf.createIRI(subject), vf.createIRI(predicate), vf.createIRI(object));
        }
    } catch (Exception e) {
        throw new RdfProcessingFailedException(e);
    }
}
Also used : ValueFactory(org.eclipse.rdf4j.model.ValueFactory) SimpleValueFactory(org.eclipse.rdf4j.model.impl.SimpleValueFactory) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

Predicate (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)16 Test (org.junit.Test)12 RdfProcessingFailedException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)6 Type (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Type)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)4 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)4 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)4 SAXException (org.xml.sax.SAXException)4 DocumentLoader (com.github.jsonldjava.core.DocumentLoader)3 DatabaseWriteException (nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.DatabaseWriteException)3 CursorQuad (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad)3 Direction (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction)3 StringValue (graphql.language.StringValue)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ChangeType (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.ChangeType)2