use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineManager method update.
@Transactional(propagation = Propagation.REQUIRED)
public Pipeline update(final PipelineVO pipelineVO) {
String pipelineVOName = pipelineVO.getName();
Assert.notNull(pipelineVOName, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NAME_IS_EMPTY));
Assert.isTrue(GitUtils.checkGitNaming(pipelineVOName), messageHelper.getMessage(MessageConstants.ERROR_INVALID_PIPELINE_NAME, pipelineVOName));
Pipeline dbPipeline = load(pipelineVO.getId());
dbPipeline.setName(pipelineVOName);
dbPipeline.setDescription(pipelineVO.getDescription());
dbPipeline.setParentFolderId(pipelineVO.getParentFolderId());
setFolderIfPresent(dbPipeline);
pipelineDao.updatePipeline(dbPipeline);
return dbPipeline;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method addConfiguration.
public List<ConfigurationEntry> addConfiguration(Long id, ConfigurationEntry configuration) throws GitClientException {
Assert.isTrue(configuration.checkConfigComplete(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_INVALID));
String configurationName = configuration.getName();
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
checkDefaultConfig(configuration, currentConfigurations);
List<ConfigurationEntry> updatedConf = removeConfig(configurationName, currentConfigurations);
updatedConf.add(configuration);
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_UPDATE, configurationName);
return saveUpdatedConfiguration(configurationName, pipeline, updatedConf, message);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method renameConfiguration.
public List<ConfigurationEntry> renameConfiguration(Long id, String oldName, String newName) throws GitClientException {
Assert.isTrue(StringUtils.hasText(oldName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Assert.isTrue(StringUtils.hasText(newName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
ConfigurationEntry oldConfig = findConfigByName(currentConfigurations, oldName);
Assert.notNull(oldConfig, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, oldName));
Assert.isTrue(findConfigByName(currentConfigurations, newName) == null, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_EXISTS, newName));
currentConfigurations.forEach(config -> {
if (oldName.equals(config.getName())) {
config.setName(newName);
}
});
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_RENAME, oldName, newName);
return saveUpdatedConfiguration(newName, pipeline, currentConfigurations, message);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method getWorkflowGraph.
public TaskGraphVO getWorkflowGraph(Long id, String version) {
Pipeline pipeline = pipelineManager.load(id);
try {
gitManager.loadRevision(pipeline, version);
} catch (GitClientException e) {
LOGGER.error(e.getMessage(), e);
throw new IllegalArgumentException(e.getMessage());
}
File config = gitManager.getConfigFile(pipeline, version);
TaskGraphVO result = new GraphReader().readGraph(graphScript, config.getParentFile().getAbsolutePath(), CONFIG_FILE_NAME);
mergeToolsRequirements(result);
try {
FileUtils.deleteDirectory(config.getParentFile());
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
return result;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method deleteConfiguration.
public List<ConfigurationEntry> deleteConfiguration(Long id, String configName) throws GitClientException {
Assert.notNull(configName, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
List<ConfigurationEntry> updatedConf = removeConfig(configName, currentConfigurations);
Assert.isTrue(currentConfigurations.size() != updatedConf.size(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, configName));
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_DELETE, configName);
return saveUpdatedConfiguration(configName, pipeline, updatedConf, message);
}
Aggregations