use of org.molgenis.data.Entity in project molgenis by molgenis.
the class AttributeMappingRepositoryImpl method toAttributeMappingEntity.
private Entity toAttributeMappingEntity(AttributeMapping attributeMapping) {
Entity attributeMappingEntity = new DynamicEntity(attributeMappingMetaData);
attributeMappingEntity.set(IDENTIFIER, attributeMapping.getIdentifier());
attributeMappingEntity.set(TARGET_ATTRIBUTE, attributeMapping.getTargetAttributeName());
attributeMappingEntity.set(ALGORITHM, attributeMapping.getAlgorithm());
attributeMappingEntity.set(SOURCE_ATTRIBUTES, attributeMapping.getSourceAttributes().stream().map(Attribute::getName).collect(Collectors.joining(",")));
attributeMappingEntity.set(ALGORITHM_STATE, attributeMapping.getAlgorithmState().toString());
return attributeMappingEntity;
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class MappingProjectRepositoryImpl method toMappingProject.
/**
* Creates a fully reconstructed MappingProject from an Entity retrieved from the repository.
*
* @param mappingProjectEntity Entity with {@link MappingProjectMetaData} metadata
* @return fully reconstructed MappingProject
*/
private MappingProject toMappingProject(Entity mappingProjectEntity) {
String identifier = mappingProjectEntity.getString(MappingProjectMetaData.IDENTIFIER);
String name = mappingProjectEntity.getString(MappingProjectMetaData.NAME);
User owner = mappingProjectEntity.getEntity(MappingProjectMetaData.OWNER, User.class);
List<Entity> mappingTargetEntities = Lists.newArrayList(mappingProjectEntity.getEntities(MappingProjectMetaData.MAPPING_TARGETS));
List<MappingTarget> mappingTargets = mappingTargetRepo.toMappingTargets(mappingTargetEntities);
return new MappingProject(identifier, name, owner, mappingTargets);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class MappingProjectRepositoryImpl method toEntity.
/**
* Creates a new Entity for a MappingProject. Upserts the {@link MappingProject}'s {@link MappingTarget}s in the
* {@link #mappingTargetRepo}.
*
* @param mappingProject the {@link MappingProject} used to create an Entity
* @return Entity filled with the data from the MappingProject
*/
private Entity toEntity(MappingProject mappingProject) {
Entity result = new DynamicEntity(mappingProjectMeta);
if (mappingProject.getIdentifier() == null) {
mappingProject.setIdentifier(idGenerator.generateId());
}
result.set(MappingProjectMetaData.IDENTIFIER, mappingProject.getIdentifier());
result.set(MappingProjectMetaData.OWNER, mappingProject.getOwner());
result.set(MappingProjectMetaData.NAME, mappingProject.getName());
List<Entity> mappingTargetEntities = mappingTargetRepo.upsert(mappingProject.getMappingTargets());
result.set(MappingProjectMetaData.MAPPING_TARGETS, mappingTargetEntities);
return result;
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityMappingRepositoryImpl method upsert.
private Entity upsert(EntityMapping entityMapping) {
List<Entity> attributeMappingEntities = attributeMappingRepository.upsert(entityMapping.getAttributeMappings());
Entity entityMappingEntity;
if (entityMapping.getIdentifier() == null) {
entityMapping.setIdentifier(idGenerator.generateId());
entityMappingEntity = toEntityMappingEntity(entityMapping, attributeMappingEntities);
dataService.add(entityMappingMetaData.getId(), entityMappingEntity);
} else {
entityMappingEntity = toEntityMappingEntity(entityMapping, attributeMappingEntities);
dataService.update(entityMappingMetaData.getId(), entityMappingEntity);
}
return entityMappingEntity;
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class MappingTargetRepositoryImpl method toMappingTarget.
/**
* Creates a fully reconstructed MappingProject from an Entity retrieved from the repository.
*
* @param mappingTargetEntity Entity with {@link MappingProjectMetaData} metadata
* @return fully reconstructed MappingProject
*/
private MappingTarget toMappingTarget(Entity mappingTargetEntity) {
List<EntityMapping> entityMappings = Collections.emptyList();
String identifier = mappingTargetEntity.getString(MappingTargetMetaData.IDENTIFIER);
if (!dataService.hasRepository(mappingTargetEntity.getString(MappingTargetMetaData.TARGET))) {
return null;
}
EntityType target = dataService.getEntityType(mappingTargetEntity.getString(MappingTargetMetaData.TARGET));
if (mappingTargetEntity.getEntities(MappingTargetMetaData.ENTITY_MAPPINGS) != null) {
List<Entity> entityMappingEntities = Lists.newArrayList(mappingTargetEntity.getEntities(MappingTargetMetaData.ENTITY_MAPPINGS));
entityMappings = entityMappingRepository.toEntityMappings(entityMappingEntities);
}
return new MappingTarget(identifier, target, entityMappings);
}
Aggregations