Search in sources :

Example 1 with ScenarioRecord

use of org.finos.waltz.schema.tables.records.ScenarioRecord in project waltz by khartec.

the class ScenarioDao method add.

public Scenario add(long roadmapId, String name, String userId) {
    Scenario scenario = ImmutableScenario.builder().roadmapId(roadmapId).name(name).description("").entityLifecycleStatus(EntityLifecycleStatus.PENDING).scenarioType(ScenarioType.INTERIM).releaseStatus(ReleaseLifecycleStatus.DRAFT).effectiveDate(today()).lastUpdatedAt(nowUtc()).lastUpdatedBy(userId).position(0).build();
    ScenarioRecord record = TO_RECORD_MAPPER.apply(scenario, dsl);
    record.store();
    return ImmutableScenario.copyOf(scenario).withId(record.getId());
}
Also used : ScenarioRecord(org.finos.waltz.schema.tables.records.ScenarioRecord) Scenario(org.finos.waltz.model.scenario.Scenario) ImmutableScenario(org.finos.waltz.model.scenario.ImmutableScenario)

Example 2 with ScenarioRecord

use of org.finos.waltz.schema.tables.records.ScenarioRecord in project waltz by khartec.

the class ScenarioDao method updateReleaseStatus.

public Boolean updateReleaseStatus(long scenarioId, ReleaseLifecycleStatus newValue, String userId) {
    ScenarioRecord record = dsl.fetchOne(SCENARIO, SCENARIO.ID.eq(scenarioId));
    if (record.getReleaseStatus().equals(newValue.name())) {
        return false;
    } else {
        record.setReleaseStatus(newValue.name());
        record.setLifecycleStatus(newValue == ReleaseLifecycleStatus.DRAFT ? EntityLifecycleStatus.PENDING.name() : EntityLifecycleStatus.ACTIVE.name());
        record.setLastUpdatedAt(nowUtcTimestamp());
        record.setLastUpdatedBy(userId);
        return record.store() == 1;
    }
}
Also used : ScenarioRecord(org.finos.waltz.schema.tables.records.ScenarioRecord)

Example 3 with ScenarioRecord

use of org.finos.waltz.schema.tables.records.ScenarioRecord in project waltz by khartec.

the class ScenarioDao method cloneScenario.

public Scenario cloneScenario(CloneScenarioCommand command) {
    Scenario orig = getById(command.scenarioId());
    Scenario clone = ImmutableScenario.copyOf(orig).withName(command.newName()).withEntityLifecycleStatus(EntityLifecycleStatus.PENDING).withReleaseStatus(ReleaseLifecycleStatus.DRAFT).withLastUpdatedAt(nowUtc()).withLastUpdatedBy(command.userId());
    ScenarioRecord clonedRecord = TO_RECORD_MAPPER.apply(clone, dsl);
    clonedRecord.store();
    return ImmutableScenario.copyOf(clone).withId(clonedRecord.getId());
}
Also used : ScenarioRecord(org.finos.waltz.schema.tables.records.ScenarioRecord) Scenario(org.finos.waltz.model.scenario.Scenario) ImmutableScenario(org.finos.waltz.model.scenario.ImmutableScenario)

Aggregations

ScenarioRecord (org.finos.waltz.schema.tables.records.ScenarioRecord)3 ImmutableScenario (org.finos.waltz.model.scenario.ImmutableScenario)2 Scenario (org.finos.waltz.model.scenario.Scenario)2