Search in sources :

Example 1 with BpmBuildTask

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;
        }
    }
}
Also used : GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) Connector(org.jboss.pnc.bpm.Connector) BuildScheduler(org.jboss.pnc.coordinator.builder.BuildScheduler) ConnectorSelector.useNewProcessForBuild(org.jboss.pnc.bpm.ConnectorSelector.useNewProcessForBuild) RestConnector(org.jboss.pnc.bpm.RestConnector) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Inject(javax.inject.Inject) BpmBuildTask(org.jboss.pnc.bpm.task.BpmBuildTask) PreDestroy(javax.annotation.PreDestroy) CoreException(org.jboss.pnc.spi.exception.CoreException) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) BpmManager(org.jboss.pnc.bpm.BpmManager) BpmModuleConfig(org.jboss.pnc.common.json.moduleconfig.BpmModuleConfig) BpmBuildTask(org.jboss.pnc.bpm.task.BpmBuildTask)

Example 2 with BpmBuildTask

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);
    }
}
Also used : BpmBuildTask(org.jboss.pnc.bpm.task.BpmBuildTask) CoreException(org.jboss.pnc.spi.exception.CoreException) CoreException(org.jboss.pnc.spi.exception.CoreException)

Example 3 with BpmBuildTask

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;
}
Also used : BpmBuildTask(org.jboss.pnc.bpm.task.BpmBuildTask)

Aggregations

BpmBuildTask (org.jboss.pnc.bpm.task.BpmBuildTask)3 CoreException (org.jboss.pnc.spi.exception.CoreException)2 Map (java.util.Map)1 Optional (java.util.Optional)1 PostConstruct (javax.annotation.PostConstruct)1 PreDestroy (javax.annotation.PreDestroy)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 BpmManager (org.jboss.pnc.bpm.BpmManager)1 Connector (org.jboss.pnc.bpm.Connector)1 ConnectorSelector.useNewProcessForBuild (org.jboss.pnc.bpm.ConnectorSelector.useNewProcessForBuild)1 RestConnector (org.jboss.pnc.bpm.RestConnector)1 GlobalModuleGroup (org.jboss.pnc.common.json.GlobalModuleGroup)1 BpmModuleConfig (org.jboss.pnc.common.json.moduleconfig.BpmModuleConfig)1 BuildScheduler (org.jboss.pnc.coordinator.builder.BuildScheduler)1 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)1