use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityVO method convertToMetadataEntity.
public MetadataEntity convertToMetadataEntity() {
MetadataEntity metadataEntity = new MetadataEntity();
MetadataClass metadataClass = new MetadataClass();
metadataClass.setId(classId);
metadataClass.setName(className);
if (parentId != null) {
metadataEntity.setParent(new Folder(parentId));
}
metadataEntity.setId(entityId);
metadataEntity.setName(entityName);
metadataEntity.setExternalId(externalId);
metadataEntity.setClassEntity(metadataClass);
metadataEntity.setData(data);
return metadataEntity;
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityDao method batchUpdate.
@Transactional(propagation = Propagation.MANDATORY)
@SuppressWarnings("unchecked")
public Collection<MetadataEntity> batchUpdate(List<MetadataEntity> entitiesToUpdate) {
for (int i = 0; i < entitiesToUpdate.size(); i += BATCH_SIZE) {
final List<MetadataEntity> batchList = entitiesToUpdate.subList(i, i + BATCH_SIZE > entitiesToUpdate.size() ? entitiesToUpdate.size() : i + BATCH_SIZE);
Map<String, Object>[] batchValues = new Map[batchList.size()];
for (int j = 0; j < batchList.size(); j++) {
MetadataEntity entity = batchList.get(j);
batchValues[j] = MetadataEntityParameters.getParameters(entity).getValues();
}
getNamedParameterJdbcTemplate().batchUpdate(this.updateMetadataEntityQuery, batchValues);
}
return entitiesToUpdate;
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityManager method createAndUpdateEntities.
@Transactional(propagation = Propagation.REQUIRED)
public List<MetadataEntity> createAndUpdateEntities(Long parentId, MetadataParsingResult parsedData) {
checkUploadIntegrity(parsedData.getReferences(), parentId);
Map<String, MetadataEntity> existing = getExistingEntities(parsedData.getEntities().keySet(), parentId, parsedData.getMetadataClass().getName()).stream().collect(Collectors.toMap(MetadataEntity::getExternalId, Function.identity()));
List<MetadataEntity> entitiesToUpdate = new ArrayList<>();
List<MetadataEntity> entitiesToCreate = new ArrayList<>();
parsedData.getEntities().values().forEach(e -> {
if (existing.containsKey(e.getExternalId())) {
MetadataEntity current = existing.get(e.getExternalId());
if (org.apache.commons.lang3.StringUtils.isNotBlank(e.getName())) {
current.setName(e.getName());
}
current.getData().putAll(e.getData());
entitiesToUpdate.add(current);
} else {
entitiesToCreate.add(e);
}
});
List<MetadataEntity> result = new ArrayList<>(entitiesToCreate.size() + entitiesToUpdate.size());
result.addAll(metadataEntityDao.batchInsert(entitiesToCreate));
result.addAll(metadataEntityDao.batchUpdate(entitiesToUpdate));
return result;
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityManager method deleteMetadataItemKey.
@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntity deleteMetadataItemKey(Long id, String key) {
MetadataEntity existingMetadataEntity = existingMetadataItem(id, true);
existingMetadataEntity.getData().keySet().remove(key);
metadataEntityDao.deleteMetadataItemKey(existingMetadataEntity.getId(), key);
return existingMetadataEntity;
}
use of com.epam.pipeline.entity.metadata.MetadataEntity in project cloud-pipeline by epam.
the class MetadataEntityManager method deleteMetadataEntity.
@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntity deleteMetadataEntity(Long id) {
Assert.notNull(id, messageHelper.getMessage(MessageConstants.ERROR_INVALID_METADATA_ENTITY_ID, id));
MetadataEntity metadataEntity = metadataEntityDao.loadMetadataEntityById(id);
Assert.notNull(metadataEntity, messageHelper.getMessage(MessageConstants.ERROR_METADATA_ENTITY_NOT_FOUND, id));
metadataEntityDao.deleteMetadataEntity(metadataEntity.getId());
return metadataEntity;
}
Aggregations