@Override protected Object getResourceAttributeValue(Attribute attr, Entity sourceEntity) { String attrName = EXAC_AF.equals(attr.getName()) ? EXAC_AF_ResourceAttributeName : EXAC_AC_HOM.equals( attr.getName()) ? EXAC_AC_HOM_ResourceAttributeName : EXAC_AC_HET.equals( attr.getName()) ? EXAC_AC_HET_ResourceAttributeName : attr.getName(); return sourceEntity.get(attrName); } };
private void dropUniqueKey(EntityType entityType, Attribute attr) { String dropUniqueKeySql = getSqlDropUniqueKey(entityType, attr); if (LOG.isDebugEnabled()) { LOG.debug( "Dropping unique key for entity [{}] attribute [{}]", entityType.getId(), attr.getName()); if (LOG.isTraceEnabled()) { LOG.trace("SQL: {}", dropUniqueKeySql); } } jdbcTemplate.execute(dropUniqueKeySql); }
private static LocalDate convertDate(Attribute attr, String paramValue) { try { return parseLocalDate(paramValue); } catch (DateTimeParseException e) { throw new MolgenisDataException( format(FAILED_TO_PARSE_ATTRIBUTE_AS_DATE_MESSAGE, attr.getName(), paramValue)); } } }
private static Instant convertDateTime(Attribute attr, String paramValue) { try { return parseInstant(paramValue); } catch (DateTimeParseException e) { throw new MolgenisDataException( format(FAILED_TO_PARSE_ATTRIBUTE_AS_DATETIME_MESSAGE, attr.getName(), paramValue)); } }
private static ConstraintViolation checkDateTime( Entity entity, Attribute attribute, EntityType entityType) { try { entity.getInstant(attribute.getName()); return null; } catch (Exception e) { return createConstraintViolation(entity, attribute, entityType); } }
private void addAnnotatorAttributes(List<Attribute> annotatorAttributes, EntityType effectsEntityType) { for (Attribute attr : annotatorAttributes) { if (effectsEntityType.getAttribute(attr.getName()) == null) { effectsEntityType.addAttribute(attr); } } }
private static ConstraintViolation checkDecimal( Entity entity, Attribute attribute, EntityType entityType) { try { entity.getDouble(attribute.getName()); return null; } catch (Exception e) { return createConstraintViolation(entity, attribute, entityType); } }
private ConstraintViolation checkEnum(Entity entity, Attribute attribute, EntityType entityType) { String value = entity.getString(attribute.getName()); if (value != null) { List<String> enumOptions = attribute.getEnumOptions(); if (!enumOptions.contains(value)) { return createConstraintViolation( entity, attribute, entityType, "Value must be one of " + enumOptions.toString()); } } return null; }
private static void validateChildren(Attribute attr) { boolean childrenIsNullOrEmpty = attr.getChildren() == null || Iterables.isEmpty(attr.getChildren()); if (!childrenIsNullOrEmpty && attr.getDataType() != COMPOUND) { throw new MolgenisDataException( format( "Attribute [%s] is not of type COMPOUND and can therefor not have children", attr.getName())); } }
private EntityTypeDescription createEntityTypeDescription( EntityType entityType, Iterable<Attribute> attributes) { Map<String, AttributeDescription> attributeDescriptions = stream(attributes) .filter(attribute -> !hasJunctionTable(attribute)) .collect( toMap( this::getColumnName, attribute -> AttributeDescription.create(attribute.getName()))); return EntityTypeDescription.create(entityType.getId(), attributeDescriptions); }
private void applyMappingToAttribute( AttributeMapping attributeMapping, Entity sourceEntity, Entity target, EntityType entityType, int depth) { String targetAttributeName = attributeMapping.getTargetAttribute().getName(); Object typedValue = algorithmService.apply(attributeMapping, sourceEntity, entityType, depth); target.set(targetAttributeName, typedValue); }
@Override public void addAttributeTag( EntityType entityType, SemanticTag<Attribute, LabeledResource, LabeledResource> tag) { Entity entity = findAttributeEntity(entityType, tag.getSubject().getName()); List<Entity> tags = new ArrayList<>(); for (Entity tagEntity : entity.getEntities(AttributeMetadata.TAGS)) { tags.add(tagEntity); } tags.add(getTagEntity(tag)); entity.set(AttributeMetadata.TAGS, tags); dataService.update(ATTRIBUTE_META_DATA, entity); }
private SortaJobExecution findSortaJobExecution(String sortaJobExecutionId) { Fetch fetch = new Fetch(); sortaJobExecutionMetaData.getAtomicAttributes().forEach(attr -> fetch.field(attr.getName())); return RunAsSystemAspect.runAsSystem( () -> dataService.findOneById( SORTA_JOB_EXECUTION, sortaJobExecutionId, fetch, SortaJobExecution.class)); }
@Override public Entity findOneById(Object id) { if (id == null) { return null; } return findOne(new QueryImpl<>().eq(entityType.getIdAttribute().getName(), id)); }
@Override public Entity findOneById(Object id, Fetch fetch) { if (id == null) { return null; } return findOne(new QueryImpl<>().eq(entityType.getIdAttribute().getName(), id).fetch(fetch)); }