Search in sources :

Example 1 with DataStorageLink

use of com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink in project cloud-pipeline by epam.

the class DataStorageManager method analyzePipelineRunsParameters.

public void analyzePipelineRunsParameters(List<PipelineRun> pipelineRuns) {
    List<AbstractDataStorage> dataStorages = getDataStorages();
    pipelineRuns.forEach(pipelineRun -> {
        if (pipelineRun.getPipelineRunParameters() == null) {
            return;
        }
        pipelineRun.getPipelineRunParameters().forEach(pipelineRunParameter -> {
            List<DataStorageLink> links = new ArrayList<>();
            for (AbstractDataStorage dataStorage : dataStorages) {
                String value = StringUtils.isNotBlank(pipelineRunParameter.getResolvedValue()) ? pipelineRunParameter.getResolvedValue() : pipelineRunParameter.getValue();
                List<DataStorageLink> dataStorageLinks = getLinks(dataStorage, value);
                if (!dataStorageLinks.isEmpty()) {
                    links.addAll(dataStorageLinks);
                }
            }
            if (!links.isEmpty()) {
                pipelineRunParameter.setDataStorageLinks(links);
            }
        });
    });
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) ArrayList(java.util.ArrayList) DataStorageLink(com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)

Example 2 with DataStorageLink

use of com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink in project cloud-pipeline by epam.

the class DataStorageManager method getLinks.

private List<DataStorageLink> getLinks(AbstractDataStorage dataStorage, String paramValue) {
    if (StringUtils.isBlank(paramValue)) {
        return Collections.emptyList();
    }
    final String mask = String.format("%s%s", dataStorage.getPathMask(), S3Constants.DELIMITER);
    List<DataStorageLink> links = new ArrayList<>();
    for (String path : paramValue.split("[,;]")) {
        if (path.toLowerCase().trim().startsWith(mask.toLowerCase())) {
            DataStorageLink dataStorageLink = new DataStorageLink();
            dataStorageLink.setAbsolutePath(path.trim());
            dataStorageLink.setDataStorageId(dataStorage.getId());
            String relativePath = path.trim().substring(mask.length());
            if (relativePath.startsWith(S3Constants.DELIMITER)) {
                relativePath = relativePath.substring(1);
            }
            String[] parts = relativePath.split(S3Constants.DELIMITER);
            final String lastPart = parts[parts.length - 1];
            if (lastPart.contains(".")) {
                String newPath = "";
                for (int i = 0; i < parts.length - 1; i++) {
                    newPath = newPath.concat(parts[i] + S3Constants.DELIMITER);
                }
                if (newPath.endsWith(S3Constants.DELIMITER)) {
                    newPath = newPath.substring(0, newPath.length() - 1);
                }
                dataStorageLink.setPath(newPath);
            } else {
                dataStorageLink.setPath(relativePath);
            }
            links.add(dataStorageLink);
        }
    }
    return links;
}
Also used : ArrayList(java.util.ArrayList) DataStorageLink(com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)

Example 3 with DataStorageLink

use of com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink in project cloud-pipeline by epam.

the class DataStorageManager method analyzePaths.

public void analyzePaths(List<PipeConfValue> values) {
    if (CollectionUtils.isEmpty(values)) {
        return;
    }
    List<AbstractDataStorage> dataStorages = getDataStorages();
    values.forEach(value -> {
        List<DataStorageLink> links = new ArrayList<>();
        for (AbstractDataStorage dataStorage : dataStorages) {
            List<DataStorageLink> dataStorageLinks = getLinks(dataStorage, value.getValue());
            if (!dataStorageLinks.isEmpty()) {
                links.addAll(dataStorageLinks);
            }
        }
        if (!links.isEmpty()) {
            value.setDataStorageLinks(links);
        }
    });
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) ArrayList(java.util.ArrayList) DataStorageLink(com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)

Aggregations

DataStorageLink (com.epam.pipeline.entity.pipeline.run.parameter.DataStorageLink)3 ArrayList (java.util.ArrayList)3 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2