Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCX-54 Fix hid.Hydra#deleteEntityAddress method #46

Merged
merged 4 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ v1.4.2 [unreleased]
- [#47](https://github.com/latera/camunda-ext/pull/47) Fix hid.Hydra#tagify method
- [#2239604](https://github.com/latera/camunda-ext/commit/2239604) Fix hid.Hydra#mergeParams method
- [#44](https://github.com/latera/camunda-ext/pull/44) Add subjTypeId to hid.Hydra#prepareSubjAddParam method
- [#46](https://github.com/latera/camunda-ext/pull/46) Fix hid.Hydra#deleteEntityAddress method

v1.4.1 [2020-02-14]
-------------------
Expand Down
101 changes: 55 additions & 46 deletions src/org/camunda/latera/bss/connectors/hid/hydra/Address.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ trait Address {
beginDate : null,
endDate : null
], input)
Boolean isSubj = isSubject(params.entityTypeId ?: params.entityId)

if (isSubj) {
if (isSubject(params.entityTypeId ?: params.entityId)) {
params.subjAddressId = params.entityAddressId
params.subjectId = params.entityId
return getSubjAddressesBy(params)
Expand All @@ -316,9 +315,7 @@ trait Address {
}

Map getEntityAddress(def entityOrEntityTypeId, def entityAddressId) {
Boolean isSubj = isSubject(entityOrEntityTypeId)

if (isSubj) {
if (isSubject(entityOrEntityTypeId)) {
return getSubjAddress(entityAddressId)
} else {
return getObjAddress(entityAddressId)
Expand Down Expand Up @@ -562,6 +559,22 @@ trait Address {
}
}

private Boolean isSubjectAddress(def entityAddressId, def entityTypeId = null, def entityId = null) {
if (notEmpty(entityTypeId) || notEmpty(entityId)) {
return isSubject(entityTypeId ?: entityId)
}

return notEmpty(getSubjAddress(entityAddressId))
}

private Boolean isObjectAddress(def entityAddressId, def entityTypeId = null, def entityId = null) {
if (notEmpty(entityTypeId) || notEmpty(entityId)) {
return isObject(entityTypeId ?: entityId)
}

return notEmpty(getObjAddress(entityAddressId))
}

private Map putEntityAddress(Map input) {
LinkedHashMap params = mergeParams([
entityAddressId : null,
Expand All @@ -584,9 +597,22 @@ trait Address {
endDate : null
], input)

Boolean isSubj = isSubject(params.entityTypeId ?: params.entityId)
Boolean isSubjectAddr = false
Boolean isObjectAddr = false

if (notEmpty(params.entityAddressId)) {
isSubjectAddr = isSubjectAddress(params.entityAddressId, params.entityTypeId, params.entityId)

if (!isSubjectAddr) {
isObjectAddr = isObjectAddress(params.entityAddressId, params.entityTypeId, params.entityId)
}
}

if (!isSubjectAddr && !isObjectAddr) {
throw new Exception ("No address found!")
}

if (isSubj) {
if (isSubjAddr) {
params.subjAddressId = params.entityAddressId
params.subjectId = params.entityId
LinkedHashMap address = putSubjAddress(params)
Expand Down Expand Up @@ -721,42 +747,22 @@ trait Address {
isMain : null
], input)

Boolean isSubj = false
Boolean isSubjectAddr = false
Boolean isObjectAddr = false

if (params.entityAddressId) {
if (params.entityTypeId || params.entityId) {
isSubj = isSubject(params.entityTypeId ?: params.entityId)
} else {
LinkedHashMap objAddress = getEntityAddress(
entityAddressId : params.entityAddressId,
entityId : params.entityId,
addressId : params.addressId,
addrTypeId : params.addrTypeId,
bindAddrTypeId : params.bindAddrTypeId,
stateId : params.stateId,
isMain : params.isMain
)
LinkedHashMap subjAddress = getEntityAddress(
entityType : 'SUBJ_TYPE_Company',
entityAddressId : params.entityAddressId,
entityId : params.entityId,
addressId : params.addressId,
addrTypeId : params.addrTypeId,
bindAddrTypeId : params.bindAddrTypeId,
stateId : params.stateId,
isMain : params.isMain
)
if (objAddress) {
isSubj = false
} else if (subjAddress) {
isSubj = true
} else {
logger.info("No address found!")
return true
}
if (notEmpty(params.entityAddressId)) {
isSubjectAddr = isSubjectAddress(params.entityAddressId, params.entityTypeId, params.entityId)

if (!isSubjectAddr) {
isObjectAddr = isObjectAddress(params.entityAddressId, params.entityTypeId, params.entityId)
}

if (!isSubjectAddr && !isObjectAddr) {
logger.info("No address found!")
return true
}
} else {
LinkedHashMap address = getEntityAddress(
LinkedHashMap address = getEntityAddressBy(
addressId : params.addressId,
entityTypeId : params.entityTypeId,
entityId : params.entityId,
Expand All @@ -769,18 +775,21 @@ trait Address {
logger.info("No address found!")
return true
}

if (address.n_obj_address_id) {
isSubj = false
params.entityAddressId = address?.n_obj_address_id
isObjectAddr = true
params.entityAddressId = address.n_obj_address_id
} else {
isSubj = true
params.entityAddressId = address?.n_subj_address_id
isSubjectAddr = true
params.entityAddressId = address.n_subj_address_id
}
}

if (isSubj) {
if (isSubjectAddr) {
return deleteSubjAddress(params.entityAddressId)
} else {
}

if (isObjectAddr) {
return deleteObjAddress(params.entityAddressId)
}
}
Expand Down