forked from finos/waltz
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
waltz-data/src/main/java/org/finos/waltz/data/legal_entity/LegalEntityDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
waltz-data/src/main/java/org/finos/waltz/data/legal_entity/LegalRelationshipKindDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters