public boolean isScheduled() { for (StageInstanceModel stageInstanceModel : stageHistory) { if (stageInstanceModel.isScheduled()) { return true; } } return false; }
public Date getScheduledDate() { Date earliestScheduledDate = null; for (StageInstanceModel stage : this) { if (!stage.isScheduled()) { continue; } Date stageDate = stage.getScheduledDate(); if (earliestScheduledDate == null || stageDate.before(earliestScheduledDate)) { earliestScheduledDate = stageDate; } } return earliestScheduledDate; }
public boolean getCanApprove() { return (getCanRun() && !isScheduled()); }
public void selectStage(String selectedStageName) { StageInstanceModel stage = stageHistory.byName(selectedStageName); if (stage != null && stage.isScheduled()) { stage.setSelected(true); } }
public boolean hasPreviousStageBeenScheduled(String stageName) { StageInstanceModel stage = stageHistory.byName(stageName); int index = stageHistory.indexOf(stage); if (index == 0) { return true; } if (index > 0) { return stageHistory.get(index - 1).isScheduled(); } return false; }
private List stageHistoryAsJson(PipelineInstanceModel pipelineInstanceModel, StageInstanceModels stageHistory) { List json = new ArrayList(); for (StageInstanceModel stageHistoryItem : stageHistory) { Map<String, Object> jsonMap = new LinkedHashMap<>(); jsonMap.put("stageName", stageHistoryItem.getName()); jsonMap.put("stageId", stageHistoryItem.getId()); jsonMap.put("stageStatus", stageHistoryItem.getState().toString()); StageIdentifier stageIdentifier = new StageIdentifier(pipelineInstanceModel.getPipelineIdentifier(), stageHistoryItem.getName(), stageHistoryItem.getCounter()); jsonMap.put("stageLocator", encodeInUtf8(stageIdentifier.stageLocator())); jsonMap.put("getCanRun", Boolean.toString(stageHistoryItem.getCanRun())); jsonMap.put("getCanCancel", Boolean.toString(stageHistoryItem.getCanCancel())); jsonMap.put("scheduled", Boolean.toString(stageHistoryItem.isScheduled())); jsonMap.put("stageCounter", stageHistoryItem.getCounter()); handleApproval(stageHistoryItem, jsonMap); json.add(jsonMap); } return json; }