/** * Uses the map containing the parsed OMIM map to create a list of {@link Entity} */ private void addEntityToGeneEntityList(Map<String, List<List<String>>> omimEntriesByGeneSymbol, String geneSymbol) { Entity entity = new DynamicEntity(getEntityType()); entity.set(OMIM_GENE_SYMBOLS_COL_NAME, geneSymbol); entity.set(OMIM_PHENOTYPE_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(0), ",")); entity.set(OMIM_MIM_NUMBER_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(1), ",")); entity.set(OMIM_CYTO_LOCATION_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(2), ",")); entity.set(OMIM_TYPE_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(3), ",")); entity.set(OMIM_ENTRY_COL_NAME, join(omimEntriesByGeneSymbol.get(geneSymbol).get(4), ",")); List<Entity> entities = entitiesByGeneSymbol.computeIfAbsent(geneSymbol, k -> new ArrayList<>()); entities.add(entity); }
@Override public Entity next() { Entity entity = iterator.next(); if (isEmpty(entity.getString(ALLOWED_IDENTIFIER))) { DynamicEntity dynamicEntity = new DynamicEntity(getEntityType()); dynamicEntity.set(entity); entity = dynamicEntity; entity.set(ALLOWED_IDENTIFIER, String.valueOf(count.incrementAndGet())); } return entity; } };
/** Execute a JavaScript using the Magma API */ Object executeScript(String jsScript, Map<String, Object> parameters) { EntityType entityType = entityTypeFactory.create("entity"); Set<String> attributeNames = parameters.keySet(); attributeNames.forEach(key -> entityType.addAttribute(attributeFactory.create().setName(key))); if (attributeNames.iterator().hasNext()) { entityType.getAttribute(attributeNames.iterator().next()).setIdAttribute(true); } Entity entity = new DynamicEntity(entityType); parameters.forEach(entity::set); return jsMagmaScriptEvaluator.eval(jsScript, entity); } }
private Entity getEmptyEffectsEntity(Entity sourceEntity, EntityType effectsEMD) { Entity effect = new DynamicEntity(effectsEMD); effect.set(ID, idGenerator.generateId()); effect.set(VARIANT, sourceEntity); return effect; }
private Entity createVcfEntityStructureForSingleEntity(Entity variant, List<Entity> effectsForVariant) { createResultEntityType(effectsForVariant.get(0), variant.getEntityType()); Entity newVariant = new DynamicEntity(vcfVariantEntityType); newVariant.set(variant); if (effectsForVariant.size() > 1) { newVariant.set(EFFECT, effectsForVariant); } else { // is this an empty effect entity? Entity effectForVariant = effectsForVariant.get(0); if (!isEmptyEffectEntity(effectForVariant)) newVariant.set(EFFECT, effectsForVariant); } return newVariant; }
private void tryUpdate(JobExecution jobExecution) { Entity jobExecutionCopy = new DynamicEntity(jobExecution.getEntityType()); jobExecutionCopy.set(jobExecution); try { dataService.update(jobExecutionCopy.getEntityType().getId(), jobExecutionCopy); } catch (Exception ex) { LOG.warn("Error updating job execution", ex); } } }
private Entity createVcfEntityStructureForSingleEntity(Entity variant, List<Entity> effectsForVariant) { createResultEntityType(effectsForVariant.get(0), variant.getEntityType()); Entity newVariant = new DynamicEntity(vcfVariantEntityType); newVariant.set(variant); if (effectsForVariant.size() > 1) { newVariant.set(EFFECT, effectsForVariant); } else { // is this an empty effect entity? Entity effectForVariant = effectsForVariant.get(0); if (!isEmptyEffectEntity(effectForVariant)) newVariant.set(EFFECT, effectsForVariant); } return newVariant; }
private Stream<Entity> createVariantEffectStructureForSingleEntity(Attribute attributeToParse, ArrayList<Attribute> effectFieldAttributeList, EntityType effectsEntityType, Entity vcfInputEntity, EntityType variantEntityType) { List<Entity> results = new ArrayList<>(); Entity variantEntity = new DynamicEntity(variantEntityType); for (String attr : variantEntity.getAttributeNames()) { if (vcfInputEntity.getEntityType().getAttribute(attr) != null) { variantEntity.set(attr, vcfInputEntity.get(attr)); } } List<Entity> result = createEffectsEntitiesForSingleVariant(effectsEntityType, effectFieldAttributeList, vcfInputEntity.getString(attributeToParse.getName()), variantEntity).collect(Collectors.toList()); results.addAll(result); return results.stream(); }
private Stream<Entity> createVariantEffectStructureForSingleEntity(Attribute attributeToParse, ArrayList<Attribute> effectFieldAttributeList, EntityType effectsEntityType, Entity vcfInputEntity, EntityType variantEntityType) { List<Entity> results = new ArrayList<>(); Entity variantEntity = new DynamicEntity(variantEntityType); for (String attr : variantEntity.getAttributeNames()) { if (vcfInputEntity.getEntityType().getAttribute(attr) != null) { variantEntity.set(attr, vcfInputEntity.get(attr)); } } List<Entity> result = createEffectsEntitiesForSingleVariant(effectsEntityType, effectFieldAttributeList, vcfInputEntity.getString(attributeToParse.getName()), variantEntity).collect(Collectors.toList()); results.addAll(result); return results.stream(); }
private Entity applyMappingToEntity(EntityMapping sourceMapping, Entity sourceEntity, EntityType targetMetaData) { Entity target = new DynamicEntity(targetMetaData); if (targetMetaData.getAttribute(SOURCE) != null) { target.set(SOURCE, sourceMapping.getName()); } sourceMapping.getAttributeMappings().forEach( attributeMapping -> applyMappingToAttribute(attributeMapping, sourceEntity, target, sourceMapping.getSourceEntityType())); return target; }
private Entity addEntry(String term, PubMedTFEntity pubMedTFEntity, DataService dataService) { if (pubMedTFEntity == null) return null; // FIXME remove reference to getApplicationContext TermFrequencyMetaData termFrequencyEntityType = getApplicationContext().getBean(TermFrequencyMetaData.class); Entity entity = new DynamicEntity(termFrequencyEntityType); entity.set(TERM, term); entity.set(FREQUENCY, pubMedTFEntity.getFrequency()); entity.set(OCCURRENCE, pubMedTFEntity.getOccurrence()); dataService.add(TERM_FREQUENCY, entity); return entity; }
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; } }
private Entity toAttributeMappingEntity(AttributeMapping attributeMapping) { Entity attributeMappingEntity = new DynamicEntity(attributeMappingMetaData); attributeMappingEntity.set(IDENTIFIER, attributeMapping.getIdentifier()); attributeMappingEntity.set(TARGET_ATTRIBUTE, attributeMapping.getTargetAttribute() != null ? attributeMapping.getTargetAttribute() .getName() : null); 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; }
/** * 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; }
/** * 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; }
protected Entity toEntity(String line) throws IOException { Entity result = new DynamicEntity(entityType); CSVParser csvParser = getCsvParser(); String[] columns = csvParser.parseLine(line); int i = 0; for (Attribute amd : entityType.getAtomicAttributes()) { if (i < columns.length) { result.set(amd.getName(), DataConverter.convert(columns[i++], amd)); } } return result; }
Entity getDefaultSettings() { Entity defaultSettingsEntity = new DynamicEntity(this); for (Attribute attr : this.getAtomicAttributes()) { // default values are stored/retrieved as strings, so we convert them to the required type // here. String defaultValue = attr.getDefaultValue(); if (defaultValue != null) { Object typedDefaultValue = getTypedValue(defaultValue, attr, entityManager); defaultSettingsEntity.set(attr.getName(), typedDefaultValue); } } defaultSettingsEntity.set(ATTR_ID, getSettingsEntityId()); return defaultSettingsEntity; }
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; } }
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; } }
/** * 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.NAME, mappingProject.getName()); result.set(DEPTH, mappingProject.getDepth()); List<Entity> mappingTargetEntities = mappingTargetRepo.upsert(mappingProject.getMappingTargets()); result.set(MappingProjectMetaData.MAPPING_TARGETS, mappingTargetEntities); return result; }