use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class EntityMappingRepositoryImpl method toEntityMappingEntity.
private Entity toEntityMappingEntity(EntityMapping entityMapping, List<Entity> attributeMappingEntities) {
Entity entityMappingEntity = new DynamicEntity(entityMappingMetaData);
entityMappingEntity.set(EntityMappingMetaData.IDENTIFIER, entityMapping.getIdentifier());
entityMappingEntity.set(EntityMappingMetaData.SOURCE_ENTITY_TYPE, entityMapping.getName());
entityMappingEntity.set(EntityMappingMetaData.TARGET_ENTITY_TYPE, entityMapping.getTargetEntityType() != null ? entityMapping.getTargetEntityType().getId() : null);
entityMappingEntity.set(EntityMappingMetaData.ATTRIBUTE_MAPPINGS, attributeMappingEntities);
return entityMappingEntity;
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class MappingTargetRepositoryImpl method toMappingTargetEntity.
/**
* Creates a new {@link DynamicEntity} for this MappingProject. Doesn't yet fill the {@link EntityMapping}s.
*/
private Entity toMappingTargetEntity(MappingTarget mappingTarget, List<Entity> entityMappingEntities) {
Entity mappingTargetEntity = new DynamicEntity(mappingTargetMetaData);
mappingTargetEntity.set(MappingProjectMetaData.IDENTIFIER, mappingTarget.getIdentifier());
mappingTargetEntity.set(MappingTargetMetaData.TARGET, mappingTarget.getTarget().getId());
mappingTargetEntity.set(MappingTargetMetaData.ENTITY_MAPPINGS, entityMappingEntities);
return mappingTargetEntity;
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInXref_Entities.
@Test
public void generateOneQueryRuleInXref_Entities() {
Entity ref0 = new DynamicEntity(refEntityType);
ref0.set(idAttrName, "id0");
Entity ref1 = new DynamicEntity(refEntityType);
ref1.set(idAttrName, "id1");
Entity ref2 = new DynamicEntity(refEntityType);
ref2.set(idAttrName, "id2");
Iterable<Object> values = Arrays.asList(ref0, ref1, ref2);
Query<Entity> q = new QueryImpl<>().in(xrefAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(nestedQuery(xrefAttrName, termsQuery(xrefAttrName + '.' + idAttrName + '.' + FIELD_NOT_ANALYZED, new Object[] { "id0", "id1", "id2" }), ScoreMode.Avg));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInMref_Entities.
@Test
public void generateOneQueryRuleInMref_Entities() {
Entity ref0 = new DynamicEntity(refEntityType);
ref0.set(idAttrName, "id0");
Entity ref1 = new DynamicEntity(refEntityType);
ref1.set(idAttrName, "id1");
Entity ref2 = new DynamicEntity(refEntityType);
ref2.set(idAttrName, "id2");
Iterable<Object> values = Arrays.asList(ref0, ref1, ref2);
Query<Entity> q = new QueryImpl<>().in(mrefAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(nestedQuery(mrefAttrName, termsQuery(mrefAttrName + '.' + idAttrName + '.' + FIELD_NOT_ANALYZED, new Object[] { "id0", "id1", "id2" }), ScoreMode.Avg));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class ExcelSheetWriterTest method write.
@Test
public void write() throws IOException {
Entity entity1 = new DynamicEntity(mock(EntityType.class)) {
@Override
protected void validateValueType(String attrName, Object value) {
// noop
}
};
entity1.set("col1", "val1");
entity1.set("col2", "val2");
excelSheetWriter.add(entity1);
Entity entity2 = new DynamicEntity(mock(EntityType.class)) {
@Override
protected void validateValueType(String attrName, Object value) {
// noop
}
};
entity2.set("col1", "val3");
entity2.set("col2", "val4");
excelSheetWriter.add(entity2);
excelWriter.close();
}
Aggregations