Skip to content

Commit

Permalink
Working ddl for legal entity
Browse files Browse the repository at this point in the history
#CTCTOWALTZ-2626
finos#6368
  • Loading branch information
jessica-woodland-scott-db committed Jan 13, 2023
1 parent b99211e commit ea207d1
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,57 @@
package org.finos.waltz.data.legal_entity;

import org.finos.waltz.common.DateTimeUtilities;
import org.finos.waltz.model.legal_entity.ImmutableLegalEntity;
import org.finos.waltz.model.legal_entity.LegalEntity;
import org.finos.waltz.model.logical_flow.LogicalFlow;
import org.finos.waltz.schema.tables.records.LegalEntityRecord;
import org.finos.waltz.schema.tables.records.LogicalFlowRecord;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.RecordMapper;

import java.sql.Timestamp;
import java.util.Set;

import static org.finos.waltz.schema.Tables.LEGAL_ENTITY;

public class LegalEntityDao {

private final DSLContext dsl;

public LegalEntityDao(DSLContext dsl) {
this.dsl = dsl;
}

private static final RecordMapper<Record, LegalEntity> TO_DOMAIN_MAPPER = r -> {
LegalEntityRecord record = r.into(LEGAL_ENTITY);

return ImmutableLegalEntity.builder()
.id(record.getId())
.name(record.getName())
.description(record.getDescription())
.externalId(record.getExternalId())
.entityLifecycleStatus(record.getEntityLifecycleStatus())
.lastUpdatedAt(record.getLastUpdatedAt())
.lastUpdatedBy(record.getLastUpdatedBy())
.provenance(record.getProvenance())
.build();
};

public LegalEntity getById(long id) {
return dsl
.select(LEGAL_ENTITY.fields())
.from(LEGAL_ENTITY)
.where(LEGAL_ENTITY.ID.eq(id))
.fetchOne(TO_DOMAIN_MAPPER);
}


public Set<LegalEntity> findAll() {
return dsl
.select(LEGAL_ENTITY.fields())
.from(LEGAL_ENTITY)
.fetchSet(TO_DOMAIN_MAPPER);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.finos.waltz.data.legal_entity;

import org.finos.waltz.model.legal_entity.ImmutableLegalEntity;
import org.finos.waltz.model.legal_entity.LegalEntity;
import org.finos.waltz.schema.tables.records.LegalEntityRecord;
import org.jooq.DSLContext;
import org.jooq.Record;
import org.jooq.RecordMapper;

import java.util.Set;

import static org.finos.waltz.schema.Tables.LEGAL_ENTITY;

public class LegalRelationshipKindDao {

private final DSLContext dsl;

public LegalRelationshipKindDao(DSLContext dsl) {
this.dsl = dsl;
}

private static final RecordMapper<Record, LegalEntity> TO_DOMAIN_MAPPER = r -> {
LegalEntityRecord record = r.into(LEGAL_ENTITY);

return ImmutableLegalEntity.builder()
.id(record.getId())
.name(record.getName())
.description(record.getDescription())
.externalId(record.getExternalId())
.entityLifecycleStatus(record.getEntityLifecycleStatus())
.lastUpdatedAt(record.getLastUpdatedAt())
.lastUpdatedBy(record.getLastUpdatedBy())
.provenance(record.getProvenance())
.build();
};

public LegalEntity getById(long id) {
return dsl
.select(LEGAL_ENTITY.fields())
.from(LEGAL_ENTITY)
.where(LEGAL_ENTITY.ID.eq(id))
.fetchOne(TO_DOMAIN_MAPPER);
}


public Set<LegalEntity> findAll() {
return dsl
.select(LEGAL_ENTITY.fields())
.from(LEGAL_ENTITY)
.fetchSet(TO_DOMAIN_MAPPER);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@
remarks="when this legal entity record was last updated"/>
<setColumnRemarks tableName="legal_entity" columnName="last_updated_by"
remarks="user responsible for the last update to this legal entity record"/>
<setColumnRemarks tableName="legal_entity" columnName="entity_lifecycle_status"
remarks="the lifecycle state of this legal entity record (one of: ACTIVE, PENDING, REMOVED)"/>
</changeSet>


Expand Down

0 comments on commit ea207d1

Please sign in to comment.