use of org.molgenis.data.meta.model.EntityTypeMetadata.ENTITY_TYPE_META_DATA in project molgenis by molgenis.
the class SystemEntityTypePersister method injectExistingEntityTypeAttributeIdentifiers.
/**
* Inject existing attribute identifiers in system entity types
*
* @param entityTypes system entity types
*/
private void injectExistingEntityTypeAttributeIdentifiers(List<EntityType> entityTypes) {
Map<String, EntityType> existingEntityTypeMap = dataService.findAll(ENTITY_TYPE_META_DATA, EntityType.class).collect(toMap(EntityType::getId, entityType -> entityType));
entityTypes.forEach(entityType -> {
EntityType existingEntityType = existingEntityTypeMap.get(entityType.getId());
if (existingEntityType != null) {
entityType.setId(existingEntityType.getId());
Map<String, Attribute> existingAttrs = stream(existingEntityType.getOwnAllAttributes().spliterator(), false).collect(toMap(Attribute::getName, Function.identity()));
entityType.getOwnAllAttributes().forEach(attr -> {
Attribute existingAttr = existingAttrs.get(attr.getName());
if (existingAttr != null) {
// inject existing attribute identifier
attr.setIdentifier(existingAttr.getIdentifier());
}
});
}
});
}
use of org.molgenis.data.meta.model.EntityTypeMetadata.ENTITY_TYPE_META_DATA in project molgenis by molgenis.
the class UntypedTagService method findAttributeEntity.
private Entity findAttributeEntity(EntityType entityType, String attributeName) {
Entity entityTypeEntity = dataService.findOneById(ENTITY_TYPE_META_DATA, entityType.getId());
Optional<Entity> result = stream(entityTypeEntity.getEntities(ATTRIBUTES).spliterator(), false).filter(att -> attributeName.equals(att.getString(AttributeMetadata.NAME))).findFirst();
return result.orElse(null);
}
Aggregations