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);
}
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;
}
Aggregations