use of org.molgenis.data.semantic.Relation in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDATE.
@Test
public void testCreateRfdModelDATE() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
LocalDate value = LocalDate.of(2013, Month.AUGUST, 12);
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getLocalDate("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DATE);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"2013-08-12\"^^<http://www.w3.org/2001/XMLSchema#date>) [null]");
}
use of org.molgenis.data.semantic.Relation in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDATETIME.
@Test
public void testCreateRfdModelDATETIME() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
Instant value = Instant.parse("2011-12-03T10:15:30Z");
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getInstant("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DATE_TIME);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"2011-12-03T10:15:30Z\"^^<http://www.w3.org/2001/XMLSchema#dateTime>) [null]");
}
use of org.molgenis.data.semantic.Relation in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelBOOL.
@Test
public void testCreateRfdModelBOOL() {
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
when(objectEntity.get("attributeName")).thenReturn(true);
when(objectEntity.getBoolean("attributeName")).thenReturn(true);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.BOOL);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>) [null]");
}
use of org.molgenis.data.semantic.Relation in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelIntAttribute.
@Test
public void testCreateRfdModelIntAttribute() {
List<Attribute> attributeList = singletonList(attr2);
when(objectEntity.getEntityType()).thenReturn(entityType);
when(objectEntity.get("attributeName2")).thenReturn(2);
when(objectEntity.getInt("attributeName2")).thenReturn(2);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attr2.getName()).thenReturn("attributeName2");
when(attr2.getDataType()).thenReturn(AttributeType.INT);
LabeledResource tag2 = new LabeledResource("http://IRI2.nl", "tag2Label");
Multimap<Relation, LabeledResource> tags2 = ImmutableMultimap.of(Relation.isAssociatedWith, tag2);
when(tagService.getTagsForAttribute(entityType, attr2)).thenReturn(tags2);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI2.nl, \"2\"^^<http://www.w3.org/2001/XMLSchema#int>) [null]");
}
use of org.molgenis.data.semantic.Relation in project molgenis by molgenis.
the class AlgorithmServiceImplIT method testWhenSourceHasMultipleMatchesThenFirstMappingGetsCreated.
@Test
public void testWhenSourceHasMultipleMatchesThenFirstMappingGetsCreated() {
EntityType targetEntityType = entityTypeFactory.create("target");
Attribute targetAttribute = attrMetaFactory.create().setName("targetHeight");
targetAttribute.setDescription("height");
targetEntityType.addAttribute(targetAttribute);
EntityType sourceEntityType = entityTypeFactory.create("source");
Attribute sourceAttribute1 = attrMetaFactory.create().setName("sourceHeight1");
sourceAttribute1.setDescription("height");
Attribute sourceAttribute2 = attrMetaFactory.create().setName("sourceHeight2");
sourceAttribute2.setDescription("height");
sourceEntityType.addAttributes(Arrays.asList(sourceAttribute1, sourceAttribute2));
User owner = userFactory.create();
owner.setUsername("flup");
owner.setPassword("geheim");
owner.setId("12345");
owner.setActive(true);
owner.setEmail("flup@blah.com");
owner.setFirstName("Flup");
owner.setLastName("de Flap");
MappingProject project = new MappingProject("project", owner);
project.addTarget(targetEntityType);
EntityMapping mapping = project.getMappingTarget("target").addSource(sourceEntityType);
Map<Attribute, ExplainedAttribute> mappings = ImmutableMap.of(sourceAttribute1, ExplainedAttribute.create(sourceAttribute1), sourceAttribute2, ExplainedAttribute.create(sourceAttribute2));
LinkedHashMultimap<Relation, OntologyTerm> ontologyTermTags = LinkedHashMultimap.create();
when(semanticSearchService.decisionTreeToFindRelevantAttributes(sourceEntityType, targetAttribute, ontologyTermTags.values(), null)).thenReturn(mappings);
when(ontologyTagService.getTagsForAttribute(targetEntityType, targetAttribute)).thenReturn(ontologyTermTags);
algorithmService.autoGenerateAlgorithm(sourceEntityType, targetEntityType, mapping, targetAttribute);
assertEquals(mapping.getAttributeMapping("targetHeight").getSourceAttributes().get(0), sourceAttribute1);
}
Aggregations