Search in sources :

Example 1 with ENTITY_TAG

use of com.khartec.waltz.schema.tables.EntityTag.ENTITY_TAG in project waltz by khartec.

the class EntityTagDao method updateTags.

public int[] updateTags(EntityReference ref, Collection<String> tags, String username) {
    LOG.info("Updating tags for entity ref: {}, tags: {} ", ref, tags);
    dsl.delete(ENTITY_TAG).where(ENTITY_TAG.ENTITY_ID.eq(ref.id())).and(ENTITY_TAG.ENTITY_KIND.eq(ref.kind().name())).execute();
    List<EntityTagRecord> records = tags.stream().map(t -> {
        EntityTagRecord record = new EntityTagRecord();
        record.setEntityId(ref.id());
        record.setEntityKind(ref.kind().name());
        record.setTag(t);
        record.setLastUpdatedAt(Timestamp.valueOf(DateTimeUtilities.nowUtc()));
        record.setLastUpdatedBy(username);
        record.setProvenance("waltz");
        return record;
    }).collect(Collectors.toList());
    return dsl.batchInsert(records).execute();
}
Also used : Logger(org.slf4j.Logger) Collections.emptyList(java.util.Collections.emptyList) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityReference(com.khartec.waltz.model.EntityReference) Field(org.jooq.Field) ListUtilities.newArrayList(com.khartec.waltz.common.ListUtilities.newArrayList) Collectors(java.util.stream.Collectors) DateTimeUtilities(com.khartec.waltz.common.DateTimeUtilities) EntityKind(com.khartec.waltz.model.EntityKind) List(java.util.List) EntityNameUtilities(com.khartec.waltz.data.EntityNameUtilities) DSLContext(org.jooq.DSLContext) StringUtilities.isEmpty(com.khartec.waltz.common.StringUtilities.isEmpty) ENTITY_TAG(com.khartec.waltz.schema.tables.EntityTag.ENTITY_TAG) Repository(org.springframework.stereotype.Repository) EntityTagRecord(com.khartec.waltz.schema.tables.records.EntityTagRecord) EntityTagRecord(com.khartec.waltz.schema.tables.records.EntityTagRecord)

Aggregations

DateTimeUtilities (com.khartec.waltz.common.DateTimeUtilities)1 ListUtilities.newArrayList (com.khartec.waltz.common.ListUtilities.newArrayList)1 StringUtilities.isEmpty (com.khartec.waltz.common.StringUtilities.isEmpty)1 EntityNameUtilities (com.khartec.waltz.data.EntityNameUtilities)1 EntityKind (com.khartec.waltz.model.EntityKind)1 EntityReference (com.khartec.waltz.model.EntityReference)1 ENTITY_TAG (com.khartec.waltz.schema.tables.EntityTag.ENTITY_TAG)1 EntityTagRecord (com.khartec.waltz.schema.tables.records.EntityTagRecord)1 Timestamp (java.sql.Timestamp)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DSLContext (org.jooq.DSLContext)1 Field (org.jooq.Field)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Repository (org.springframework.stereotype.Repository)1