use of nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method assertPropertyWillKeepTrackOfThePredicate.
@Test
public void assertPropertyWillKeepTrackOfThePredicate() {
TinkerPopOperations instance = TinkerPopOperationsStubs.newInstance();
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
instance.addPredicateValueTypeVertexToVre(vre);
vre = instance.loadVres().getVre("vre");
Collection defaultCollection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
instance.assertProperty(vre, "http://example.org/1", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"));
instance.assertProperty(vre, "http://example.org/2", new RdfProperty("http://example.org/propName", "value", "http://www.w3.org/2001/XMLSchema#float"));
List<PredicateInUse> predicates = instance.getPredicatesFor(defaultCollection);
assertThat(predicates, contains(hasProperty("predicateUri", equalTo("http://example.org/propName"))));
List<ValueTypeInUse> valueTypes = predicates.get(0).getValueTypes();
assertThat(valueTypes, containsInAnyOrder(allOf(hasProperty("typeUri", equalTo("http://www.w3.org/2001/XMLSchema#float")), hasProperty("entitiesConnected", contains("http://example.org/2"))), allOf(hasProperty("typeUri", equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")), hasProperty("entitiesConnected", contains("http://example.org/1")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse in project timbuctoo by HuygensING.
the class PropertyFactoryTest method fromRdfPredicateWillNotCreateTheSameClientNameTwice.
@Test
public void fromRdfPredicateWillNotCreateTheSameClientNameTwice() {
ValueTypeInUse valueType1 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type1").addEntitiesConnected("entity1", "entity2").build();
List<PredicateInUse> predicates = Lists.newArrayList(ImmutablePredicateInUse.builder().predicateUri("http://example.org/localName").addValueTypes(valueType1).build(), ImmutablePredicateInUse.builder().predicateUri("http://example.com/localName").addValueTypes(valueType1).build());
List<CreateProperty> properties = instance.fromPredicates(predicates);
assertThat(properties, containsInAnyOrder(allOf(hasProperty("clientName", equalTo("localName")), hasProperty("rdfUri", equalTo("http://example.org/localName"))), allOf(hasProperty("clientName", equalTo("http://example.com/localName")), hasProperty("rdfUri", equalTo("http://example.com/localName")))));
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse in project timbuctoo by HuygensING.
the class PropertyFactoryTest method createPredicates.
private List<PredicateInUse> createPredicates() {
ValueTypeInUse valueType1 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type1").addEntitiesConnected("entity1", "entity2").build();
ValueTypeInUse valueType2 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type2").addEntitiesConnected("entity3").build();
PredicateInUse pred1 = ImmutablePredicateInUse.builder().predicateUri("http://example.org/test#pred1").addValueTypes(valueType1, valueType2).build();
ValueTypeInUse valueType3 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type3").addEntitiesConnected("entity1").build();
ValueTypeInUse valueType4 = ImmutableValueTypeInUse.builder().typeUri("http://example.org/type4").addEntitiesConnected("entity3", "entity2").build();
PredicateInUse pred2 = ImmutablePredicateInUse.builder().predicateUri("http://example.org/pred2").addValueTypes(valueType3, valueType4).build();
return Lists.newArrayList(pred1, pred2);
}
use of nl.knaw.huygens.timbuctoo.core.dto.rdf.ValueTypeInUse in project timbuctoo by HuygensING.
the class PropertyFactory method convertToProperty.
private CreateProperty convertToProperty(PredicateInUse pred) {
Stack<ValueTypeInUse> valueTypes = pred.getValueTypes().stream().sorted(comparingInt(o -> o.getEntitiesConnected().size())).collect(toCollection(Stack::new));
ValueTypeInUse type = valueTypes.pop();
valueTypes.forEach(vt -> vt.getEntitiesConnected().forEach(e -> importErrorReporter.entityHasWrongTypeForProperty(e, pred.getPredicateUri(), type.getTypeUri(), vt.getTypeUri())));
return ImmutableCreateProperty.builder().clientName(getPredicateName(pred)).rdfUri(pred.getPredicateUri()).typeUri(type.getTypeUri()).propertyType(getPropertyType(pred.getPredicateUri(), type)).build();
}
Aggregations