Search in sources :

Example 21 with AttributeMapping

use of org.molgenis.semanticmapper.mapping.model.AttributeMapping in project molgenis by molgenis.

the class EntityMappingRepositoryImplTest method testToEntityMappings.

@Test
public void testToEntityMappings() {
    Attribute targetAttribute = attrMetaFactory.create().setName("targetAttribute");
    List<Attribute> sourceAttributes = Lists.newArrayList();
    EntityType sourceEntityType = entityTypeFactory.create("source");
    EntityType targetEntityType = entityTypeFactory.create("target");
    targetEntityType.addAttribute(targetAttribute);
    List<AttributeMapping> attributeMappings = Lists.newArrayList();
    attributeMappings.add(new AttributeMapping("1", "targetAttribute", targetAttribute, "algorithm", sourceAttributes));
    List<EntityMapping> entityMappings = singletonList(new EntityMapping(AUTO_ID, sourceEntityType, targetEntityType, attributeMappings));
    Entity attributeMappingEntity = new DynamicEntity(attrMappingMeta);
    attributeMappingEntity.set(EntityMappingMetaData.IDENTIFIER, AUTO_ID);
    attributeMappingEntity.set(AttributeMappingMetaData.TARGET_ATTRIBUTE, "targetAttribute");
    attributeMappingEntity.set(AttributeMappingMetaData.SOURCE_ATTRIBUTES, "sourceAttributes");
    attributeMappingEntity.set(AttributeMappingMetaData.ALGORITHM, "algorithm");
    List<Entity> attributeMappingEntities = Lists.newArrayList();
    attributeMappingEntities.add(attributeMappingEntity);
    List<Entity> entityMappingEntities = Lists.newArrayList();
    Entity entityMappingEntity = new DynamicEntity(entityMappingMeta);
    entityMappingEntity.set(EntityMappingMetaData.IDENTIFIER, AUTO_ID);
    entityMappingEntity.set(EntityMappingMetaData.TARGET_ENTITY_TYPE, "targetAttribute");
    entityMappingEntity.set(EntityMappingMetaData.ATTRIBUTE_MAPPINGS, attributeMappingEntities);
    entityMappingEntities.add(entityMappingEntity);
    when(dataService.getEntityType(entityMappingEntity.getString(EntityMappingMetaData.TARGET_ENTITY_TYPE))).thenReturn(targetEntityType);
    when(dataService.getEntityType(entityMappingEntity.getString(EntityMappingMetaData.SOURCE_ENTITY_TYPE))).thenReturn(sourceEntityType);
    assertEquals(entityMappingRepository.toEntityMappings(entityMappingEntities), entityMappings);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) Attribute(org.molgenis.data.meta.model.Attribute) DynamicEntity(org.molgenis.data.support.DynamicEntity) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 22 with AttributeMapping

use of org.molgenis.semanticmapper.mapping.model.AttributeMapping in project molgenis by molgenis.

the class MappingServiceImplTest method createMappingProjectWithMappings.

private MappingProject createMappingProjectWithMappings() {
    MappingProject mappingProject = mappingService.addMappingProject("TestRun", user, hopMetaData.getId());
    MappingTarget target = mappingProject.getMappingTarget(hopMetaData.getId());
    when(mappingProjectRepo.getMappingProject("TestRun")).thenReturn(mappingProject);
    EntityMapping mapping = target.addSource(geneMetaData);
    AttributeMapping idMapping = mapping.addAttributeMapping("identifier");
    idMapping.setAlgorithm("$('id').value()");
    AttributeMapping attrMapping = mapping.addAttributeMapping("height");
    attrMapping.setAlgorithm("$('length').value()");
    return mappingProject;
}
Also used : EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) MappingProject(org.molgenis.semanticmapper.mapping.model.MappingProject) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget)

Aggregations

AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)22 Test (org.testng.annotations.Test)16 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)15 Entity (org.molgenis.data.Entity)15 Attribute (org.molgenis.data.meta.model.Attribute)15 DynamicEntity (org.molgenis.data.support.DynamicEntity)13 EntityType (org.molgenis.data.meta.model.EntityType)11 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)8 ExplainedAttribute (org.molgenis.semanticsearch.explain.bean.ExplainedAttribute)8 MappingTarget (org.molgenis.semanticmapper.mapping.model.MappingTarget)5 MappingProject (org.molgenis.semanticmapper.mapping.model.MappingProject)4 ExplainedQueryString (org.molgenis.semanticsearch.explain.bean.ExplainedQueryString)4 Menu (org.molgenis.core.ui.menu.Menu)3 UnknownEntityException (org.molgenis.data.UnknownEntityException)1 User (org.molgenis.data.security.auth.User)1 Relation (org.molgenis.data.semantic.Relation)1 OntologyTerm (org.molgenis.ontology.core.model.OntologyTerm)1 ScriptException (org.molgenis.script.core.ScriptException)1 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)1 GeneratedAlgorithm (org.molgenis.semanticmapper.algorithmgenerator.bean.GeneratedAlgorithm)1