Search in sources :

Example 1 with EntityNamedNoteTypeRecord

use of com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord in project waltz by khartec.

the class EntityNamedNoteTypeDao method create.

/**
 * Creates a new record and returns the generated id.  All fields in the command must be
 * provided.
 * @param command
 * @return
 */
public long create(EntityNamedNoteTypeChangeCommand command) {
    String name = Checks.checkOptionalIsPresent(command.name(), "Name must be provided");
    Set<EntityKind> applicableEntityKinds = Checks.checkOptionalIsPresent(command.applicableEntityKinds(), "Applicable Entity Kinds must be provided");
    String kinds = join(applicableEntityKinds, SEPARATOR);
    EntityNamedNoteTypeRecord record = dsl.newRecord(ENTITY_NAMED_NOTE_TYPE);
    record.setName(name);
    record.setDescription(command.description().orElse(""));
    record.setApplicableEntityKinds(kinds);
    record.setIsReadonly(command.isReadOnly().orElse(false));
    record.store();
    return record.getId();
}
Also used : EntityNamedNoteTypeRecord(com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord) EntityKind(com.khartec.waltz.model.EntityKind)

Example 2 with EntityNamedNoteTypeRecord

use of com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord in project waltz by khartec.

the class EntityNamedNoteTypeDao method update.

public boolean update(long id, EntityNamedNoteTypeChangeCommand command) {
    EntityNamedNoteTypeRecord record = new EntityNamedNoteTypeRecord();
    record.set(ENTITY_NAMED_NOTE_TYPE.ID, id);
    record.changed(ENTITY_NAMED_NOTE_TYPE.ID, false);
    command.name().ifPresent(name -> record.setName(name));
    command.description().ifPresent(desc -> record.setDescription(desc));
    command.applicableEntityKinds().ifPresent(kinds -> record.setApplicableEntityKinds(join(kinds, SEPARATOR)));
    command.isReadOnly().ifPresent(readOnly -> record.setIsReadonly(readOnly));
    return dsl.executeUpdate(record) == 1;
}
Also used : EntityNamedNoteTypeRecord(com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord)

Aggregations

EntityNamedNoteTypeRecord (com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord)2 EntityKind (com.khartec.waltz.model.EntityKind)1