int promotionLevelId = run.getPromotionLevel().id(); if (index.contains(promotionLevelId)) { index.remove(promotionLevelId);
public EventBuilder withPromotionRun(PromotionRun promotionRun) { return withBuild(promotionRun.getBuild()).with(promotionRun.getPromotionLevel()).with(promotionRun.getSignature()); }
@Override public Event deletePromotionRun(PromotionRun promotionRun) { return Event.of(DELETE_PROMOTION_RUN) .withBranch(promotionRun.getBuild().getBranch()) .with(promotionRun.getBuild()) .with(promotionRun.getPromotionLevel()) .get(); }
@Override public String render(ProjectEntity projectEntity, Event event) { switch (projectEntity.getProjectEntityType()) { case PROJECT: return ((Project) projectEntity).getName(); case BRANCH: return ((Branch) projectEntity).getName(); case PROMOTION_LEVEL: return ((PromotionLevel) projectEntity).getName(); case VALIDATION_STAMP: return ((ValidationStamp) projectEntity).getName(); case BUILD: return ((Build) projectEntity).getName(); case VALIDATION_RUN: return "#" + ((ValidationRun) projectEntity).getRunOrder(); case PROMOTION_RUN: PromotionRun promotionRun = (PromotionRun) projectEntity; return String.format( "%s->%s", promotionRun.getBuild().getName(), promotionRun.getPromotionLevel().getName() ); default: throw new EventCannotRenderEntityException(event.getEventType().getTemplate(), projectEntity); } }
@Override public PromotionRun newPromotionRun(PromotionRun promotionRun) { return promotionRun.withId( id( dbCreate( "INSERT INTO PROMOTION_RUNS(BUILDID, PROMOTIONLEVELID, CREATION, CREATOR, DESCRIPTION) VALUES (:buildId, :promotionLevelId, :creation, :creator, :description)", params("buildId", promotionRun.getBuild().id()) .addValue("promotionLevelId", promotionRun.getPromotionLevel().id()) .addValue("description", promotionRun.getDescription()) .addValue("creation", dateTimeForDB(promotionRun.getSignature().getTime())) .addValue("creator", promotionRun.getSignature().getUser().getName()) ) ) ); }