Search in sources :

Example 1 with StageEntityId

use of pipelite.entity.StageEntityId in project pipelite by enasequence.

the class StageService method createExecution.

/**
 * Assigns a stage entity to the stage. Uses a saved stage entity if it exists or creates a new
 * one. Saves the stage.
 *
 * @param pipelineName the pipeline name
 * @param processId the process id
 * @param stage the stage
 */
@Timed("pipelite.transactional")
public void createExecution(String pipelineName, String processId, Stage stage) {
    // Uses saved stage if it exists.
    Optional<StageEntity> savedStageEntity = repository.findById(new StageEntityId(processId, pipelineName, stage.getStageName()));
    if (savedStageEntity.isPresent()) {
        stage.setStageEntity(savedStageEntity.get());
    }
    StageEntity.createExecution(pipelineName, processId, stage);
    if (stage.getStageEntity() == null) {
        throw new PipeliteException("Failed to create new stage entity");
    }
    saveStage(stage);
}
Also used : StageEntityId(pipelite.entity.StageEntityId) PipeliteException(pipelite.exception.PipeliteException) StageEntity(pipelite.entity.StageEntity) Timed(io.micrometer.core.annotation.Timed)

Aggregations

Timed (io.micrometer.core.annotation.Timed)1 StageEntity (pipelite.entity.StageEntity)1 StageEntityId (pipelite.entity.StageEntityId)1 PipeliteException (pipelite.exception.PipeliteException)1