use of org.jboss.pnc.bpm.task.BpmBuildTask in project pnc by project-ncl.
the class BpmBuildScheduler method cancel.
@Override
public boolean cancel(BuildTask buildTask) {
Map<String, String> genericParameters = buildTask.getBuildConfigurationAudited().getGenericParameters();
BpmBuildTask task = new BpmBuildTask(buildTask);
if (useNewProcessForBuild(genericParameters, bpmConfig.isNewBpmForced())) {
return restConnector.cancelByCorrelation(buildTask.getId(), task.getAccessToken());
} else {
Optional<BpmBuildTask> taskOptional = manager.getActiveTasks().stream().filter(bpmTask -> bpmTask instanceof BpmBuildTask).map(bpmTask -> (BpmBuildTask) bpmTask).filter(bpmTask -> bpmTask.getBuildTask().getId().equals(buildTask.getId())).findAny();
if (taskOptional.isPresent()) {
return manager.cancelTask(taskOptional.get());
} else {
return false;
}
}
}
use of org.jboss.pnc.bpm.task.BpmBuildTask in project pnc by project-ncl.
the class BpmBuildScheduler method startBuilding.
@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
try {
Map<String, String> genericParameters = buildTask.getBuildConfigurationAudited().getGenericParameters();
BpmBuildTask task = new BpmBuildTask(buildTask);
if (useNewProcessForBuild(genericParameters, bpmConfig.isNewBpmForced())) {
task.setGlobalConfig(globalConfig);
task.setBpmConfig(bpmConfig);
task.setJsonEncodedProcessParameters(false);
restConnector.startProcess(bpmConfig.getBpmNewBuildProcessName(), task.getExtendedProcessParameters(), buildTask.getId(), task.getAccessToken());
} else {
manager.startTask(task);
}
} catch (Exception e) {
throw new CoreException("Error while trying to startBuilding with BpmBuildScheduler.", e);
}
}
use of org.jboss.pnc.bpm.task.BpmBuildTask in project pnc by project-ncl.
the class ConnectorSelector method useNewProcess.
public static boolean useNewProcess(BpmTask task, boolean forceNew) {
if (task instanceof BpmBuildTask) {
BpmBuildTask buildTask = (BpmBuildTask) task;
Map<String, String> genericParameters = buildTask.getBuildTask().getBuildConfigurationAudited().getGenericParameters();
return useNewProcessForBuild(genericParameters, forceNew);
}
return false;
}
Aggregations