use of com.epam.pipeline.entity.datastorage.rules.DataStorageRule in project cloud-pipeline by epam.
the class PipelineCRUDManager method createDefaultDataStorageRule.
private DataStorageRule createDefaultDataStorageRule(Pipeline pipeline, Date now) {
DataStorageRule rule = new DataStorageRule();
rule.setPipelineId(pipeline.getId());
rule.setCreatedDate(now);
rule.setMoveToSts(DataStorageRule.DEFAULT_MOVE_TO_STS);
rule.setFileMask(DataStorageRule.DEFAULT_FILE_MASK);
return rule;
}
use of com.epam.pipeline.entity.datastorage.rules.DataStorageRule in project cloud-pipeline by epam.
the class DataStorageRuleManager method loadRule.
@Transactional(propagation = Propagation.REQUIRED)
public DataStorageRule loadRule(Long pipelineId, String fileMask) {
DataStorageRule rule = dataStorageRuleDao.loadDataStorageRule(pipelineId, fileMask);
Assert.notNull(rule, messageHelper.getMessage(MessageConstants.ERROR_DATASTORAGE_RULE_NOT_FOUND, pipelineId, fileMask));
return rule;
}
use of com.epam.pipeline.entity.datastorage.rules.DataStorageRule in project cloud-pipeline by epam.
the class DataStorageRuleManager method deleteRule.
@Transactional(propagation = Propagation.REQUIRED)
public DataStorageRule deleteRule(Long pipelineId, String fileMask) {
pipelineManager.load(pipelineId);
DataStorageRule rule = loadRule(pipelineId, fileMask);
dataStorageRuleDao.deleteDataStorageRule(pipelineId, fileMask);
return rule;
}
use of com.epam.pipeline.entity.datastorage.rules.DataStorageRule in project cloud-pipeline by epam.
the class PipelineCRUDManager method save.
@Transactional(propagation = Propagation.REQUIRED)
public Pipeline save(final Pipeline pipeline) {
Date now = DateUtils.now();
pipeline.setCreatedDate(now);
pipelineDao.createPipeline(pipeline);
DataStorageRule rule = createDefaultDataStorageRule(pipeline, now);
dataStorageRuleDao.createDataStorageRule(rule);
return pipeline;
}
use of com.epam.pipeline.entity.datastorage.rules.DataStorageRule in project cloud-pipeline by epam.
the class PipelineDocumentTemplateManager method applyFilesGeneratedByPipeline.
private void applyFilesGeneratedByPipeline(PipelineDocumentTemplate template) {
Optional<AbstractDataStorage> dataStorageOptional = dataStorageManager.getDataStorages().stream().filter(ds -> ds.getName().toLowerCase().contains("analysis")).findAny();
if (dataStorageOptional.isPresent()) {
AbstractDataStorage abstractDataStorage = dataStorageOptional.get();
StoragePolicy policy = abstractDataStorage.getStoragePolicy();
Integer totalDays = policy == null ? 0 : policy.getLongTermStorageDuration();
final Integer daysInYear = 365;
final Integer daysInMonth = 30;
Integer years = Math.floorDiv(totalDays, daysInYear);
Integer months = Math.floorDiv(totalDays - years * daysInYear, daysInMonth);
Integer days = totalDays - years * daysInYear - months * daysInMonth;
List<String> fates = new ArrayList<>();
if (years > 1) {
fates.add(String.format("%d years", years));
} else if (years == 1) {
fates.add(String.format("%d year", years));
}
if (months > 1) {
fates.add(String.format("%d months", months));
} else if (months == 1) {
fates.add(String.format("%d month", months));
}
if (days > 1 || (days == 0 && fates.size() == 0)) {
fates.add(String.format("%d days", days));
} else if (days == 1) {
fates.add(String.format("%d day", days));
}
String fateDescription = String.join(", ", fates);
List<DataStorageRule> rules = dataStorageRuleManager.loadAllRulesForPipeline(template.getPipeline().getId());
for (DataStorageRule rule : rules) {
String name = rule.getFileMask();
String fate = rule.getMoveToSts() ? fateDescription : "Removed at completion";
template.getFilesGeneratedDuringPipelineProcessing().add(new ImmutablePair<>(name, fate));
}
}
}
Aggregations