Skip to content

Commit

Permalink
Merge pull request finos#22 in WALTZ/waltz from WALTZ/waltz-jws:CTCTO…
Browse files Browse the repository at this point in the history
…WALTZ-2291-person-application-export-some-records-lost-5561 to db-feature/CTCTOWALTZ-2291-person-app-exporter-fix-5561

* commit 'd73a6644c9635502bf76742dbc511556812c2912':
  adding dsl render inlined
  Fixing person app exporter to ensure all involvements captured
  • Loading branch information
MarkGuerriero committed Aug 11, 2021
2 parents 9a4e977 + d73a664 commit 03821f7
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,30 @@ public void register() {
}


private SelectConditionStep<Record9<Long, String, String, String, String, String, String, String, String>> prepareExtractQuery(String empId) {
private SelectOrderByStep<Record9<Long, String, String, String, String, String, String, String, String>> prepareExtractQuery(String empId) {

Condition appIsActive = APPLICATION.ENTITY_LIFECYCLE_STATUS.notEqual(EntityLifecycleStatus.REMOVED.name())
.and(APPLICATION.IS_REMOVED.isFalse());

SelectConditionStep<Record9<Long, String, String, String, String, String, String, String, String>> directInvolvementQry = mkBaseInvolvementSelect(dsl, empId)
.where(dsl
.renderInlined(INVOLVEMENT.EMPLOYEE_ID.eq(empId)
.and(appIsActive)));

SelectConditionStep<Record9<Long, String, String, String, String, String, String, String, String>> oversightInvolvementQry = mkBaseInvolvementSelect(dsl, empId)
.innerJoin(PERSON_HIERARCHY)
.on(PERSON_HIERARCHY.EMPLOYEE_ID.eq(INVOLVEMENT.EMPLOYEE_ID))
.where(dsl
.renderInlined(PERSON_HIERARCHY.MANAGER_ID.eq(empId)
.and(appIsActive)));

return oversightInvolvementQry.union(directInvolvementQry);
}


private SelectOnConditionStep<Record9<Long, String, String, String, String, String, String, String, String>> mkBaseInvolvementSelect(
DSLContext dsl,
String empId) {

Condition isDirect = DSL.exists(DSL
.select(INVOLVEMENT.ENTITY_ID)
Expand Down Expand Up @@ -99,11 +122,6 @@ private SelectConditionStep<Record9<Long, String, String, String, String, String
.on(INVOLVEMENT.ENTITY_ID.eq(APPLICATION.ID)
.and(INVOLVEMENT.ENTITY_KIND.eq(EntityKind.APPLICATION.name())))
.innerJoin(ORGANISATIONAL_UNIT)
.on(ORGANISATIONAL_UNIT.ID.eq(APPLICATION.ORGANISATIONAL_UNIT_ID))
.innerJoin(PERSON_HIERARCHY)
.on(PERSON_HIERARCHY.EMPLOYEE_ID.eq(INVOLVEMENT.EMPLOYEE_ID))
.where(PERSON_HIERARCHY.MANAGER_ID.eq(empId)
.and(APPLICATION.ENTITY_LIFECYCLE_STATUS.notEqual(EntityLifecycleStatus.REMOVED.name())));

.on(ORGANISATIONAL_UNIT.ID.eq(APPLICATION.ORGANISATIONAL_UNIT_ID));
}
}

0 comments on commit 03821f7

Please sign in to comment.