Search in sources :

Example 1 with RATING_SCHEME_ITEM

use of org.finos.waltz.schema.tables.RatingSchemeItem.RATING_SCHEME_ITEM in project waltz by khartec.

the class RatingSchemeDAO method saveRatingItem.

public Long saveRatingItem(long schemeId, RatingSchemeItem item) {
    RatingSchemeItemRecord r = dsl.newRecord(RATING_SCHEME_ITEM);
    r.setSchemeId(schemeId);
    r.setName(item.name());
    r.setDescription(item.description());
    r.setCode(Character.toString(item.rating()));
    r.setColor(item.color());
    r.setPosition(item.position());
    r.setUserSelectable(item.userSelectable());
    return item.id().map(id -> {
        r.setId(id);
        r.changed(RATING_SCHEME_ITEM.ID, false);
        r.store();
        return id;
    }).orElseGet(() -> {
        r.insert();
        return r.getId();
    });
}
Also used : java.util(java.util) RATING_SCHEME_ITEM(org.finos.waltz.schema.tables.RatingSchemeItem.RATING_SCHEME_ITEM) DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) Collections.emptyList(java.util.Collections.emptyList) Optional.ofNullable(java.util.Optional.ofNullable) EntityKind(org.finos.waltz.model.EntityKind) RatingSchemeItemRecord(org.finos.waltz.schema.tables.records.RatingSchemeItemRecord) Autowired(org.springframework.beans.factory.annotation.Autowired) org.finos.waltz.model.rating(org.finos.waltz.model.rating) MEASURABLE_CATEGORY(org.finos.waltz.schema.tables.MeasurableCategory.MEASURABLE_CATEGORY) StringUtilities.firstChar(org.finos.waltz.common.StringUtilities.firstChar) RATING_SCHEME(org.finos.waltz.schema.tables.RatingScheme.RATING_SCHEME) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) org.jooq(org.jooq) EntityReference(org.finos.waltz.model.EntityReference) RatingSchemeRecord(org.finos.waltz.schema.tables.records.RatingSchemeRecord) Repository(org.springframework.stereotype.Repository) RatingSchemeItemRecord(org.finos.waltz.schema.tables.records.RatingSchemeItemRecord)

Aggregations

java.util (java.util)1 Collections.emptyList (java.util.Collections.emptyList)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Collectors.toList (java.util.stream.Collectors.toList)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 MapUtilities.groupBy (org.finos.waltz.common.MapUtilities.groupBy)1 StringUtilities.firstChar (org.finos.waltz.common.StringUtilities.firstChar)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference (org.finos.waltz.model.EntityReference)1 org.finos.waltz.model.rating (org.finos.waltz.model.rating)1 Tables (org.finos.waltz.schema.Tables)1 MEASURABLE_CATEGORY (org.finos.waltz.schema.tables.MeasurableCategory.MEASURABLE_CATEGORY)1 RATING_SCHEME (org.finos.waltz.schema.tables.RatingScheme.RATING_SCHEME)1 RATING_SCHEME_ITEM (org.finos.waltz.schema.tables.RatingSchemeItem.RATING_SCHEME_ITEM)1 RatingSchemeItemRecord (org.finos.waltz.schema.tables.records.RatingSchemeItemRecord)1 RatingSchemeRecord (org.finos.waltz.schema.tables.records.RatingSchemeRecord)1 org.jooq (org.jooq)1 DSL (org.jooq.impl.DSL)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Repository (org.springframework.stereotype.Repository)1