-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contract methods to hoper.Hydra class
- Loading branch information
Showing
2 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
src/org/camunda/latera/bss/connectors/hoper/hydra/Contract.groovy
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,111 @@ | ||
package org.camunda.latera.bss.connectors.hoper.hydra | ||
|
||
trait Contract { | ||
private static LinkedHashMap CONTRACT_ENTITY_TYPE = [ | ||
one : 'contract', | ||
plural : 'contracts' | ||
] | ||
private static Integer CONTRACT_TYPE = 1002 // 'DOC_TYPE_SubscriberContract' | ||
private static Integer CONTRACT_APP_TYPE = 2002 // 'DOC_TYPE_ContractAPP' | ||
private static Integer ADD_AGREEMENT_TYPE = 13002 // 'DOC_TYPE_AddAgreement' | ||
private static Integer DEFAULT_CONTRACT_WORKFLOW_ID = 10021 // 'WFLOW_SubscriberContract' | ||
|
||
def getContractEntityType(def parentType, def parentId) { | ||
def parent = "${parentType.parent}/${parentType.plural}/${parentId}" | ||
return CONTRACT_ENTITY_TYPE + [parent: parent] | ||
} | ||
|
||
def getCustomerContractEntityType(def customerId) { | ||
return getContractEntityType(getCustomerEntityType(), customerId) | ||
} | ||
|
||
def getContractTypeId() { | ||
return CONTRACT_TYPE | ||
} | ||
|
||
def getContractAppTypeId() { | ||
return CONTRACT_APP_TYPE | ||
} | ||
|
||
def getAddAgreementTypeId() { | ||
return ADD_AGREEMENT_TYPE | ||
} | ||
|
||
def getDefaultContractWorkflowId() { | ||
return DEFAULT_CONTRACT_WORKFLOW_ID | ||
} | ||
|
||
LinkedHashMap getContractDefaultParams() { | ||
return [ | ||
number : null, | ||
providerId : getFirmId(), | ||
docTypeId : getContractTypeId(), | ||
workflowId : getDefaultContractWorkflowId(), | ||
parentDocId : null, | ||
beginDate : null, | ||
endDate : null, | ||
stateId : null, | ||
rem : null | ||
] | ||
} | ||
|
||
LinkedHashMap getContractParamsMap(LinkedHashMap params) { | ||
return [ | ||
vc_doc_no : params.number, | ||
n_provider_id : params.providerId, | ||
n_doc_type_id : params.docTypeId, | ||
n_workflow_id : params.workflowId, | ||
n_parent_doc_id : params.parentDocId, | ||
d_begin : params.beginDate, | ||
d_end : params.endDate, | ||
n_doc_state_id : params.stateId, | ||
vc_rem : params.rem | ||
] | ||
} | ||
|
||
LinkedHashMap getContractParams(LinkedHashMap input) { | ||
def params = getContractDefaultParams() + input | ||
def data = getContractParamsMap(params) | ||
return nvlParams(data) | ||
} | ||
|
||
List getCustomerContracts(def customerId, LinkedHashMap input = [:]) { | ||
def params = getPaginationDefaultParams() + input | ||
return getEntities(getCustomerContractEntityType(customerId), params) | ||
} | ||
|
||
LinkedHashMap getCustomerContract(def customerId, def contractId) { | ||
return getEntity(getCustomerContractEntityType(customerId), contractId) | ||
} | ||
|
||
LinkedHashMap createCustomerContract(def customerId, LinkedHashMap input = [:]) { | ||
LinkedHashMap params = getContractParams(input) | ||
params.remove('n_doc_state_id') | ||
|
||
def result = createEntity(getCustomerContractEntityType(customerId), params) | ||
if (input.stateId && result.n_doc_id) { | ||
result = updateCustomerContract(customerId, result.n_doc_id, input) | ||
} | ||
return result | ||
} | ||
|
||
LinkedHashMap updateCustomerContract(def customerId, def contractId, LinkedHashMap input) { | ||
LinkedHashMap params = getContractParams(input) | ||
return updateEntity(getCustomerContractEntityType(customerId), contractId, params) | ||
} | ||
|
||
LinkedHashMap putCustomerContract(def customerId, LinkedHashMap input) { | ||
def contractId = input.contractId | ||
input.remove('contractId') | ||
|
||
if (contractId) { | ||
return updateCustomerContract(customerId, contractId, input) | ||
} else { | ||
return createCustomerContract(customerId, input) | ||
} | ||
} | ||
|
||
Boolean deleteCustomerContract(def customerId, def contractId) { | ||
return deleteEntity(getCustomerContractEntityType(customerId), contractId) | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/org/camunda/latera/bss/connectors/hoper/hydra/Document.groovy
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,54 @@ | ||
package org.camunda.latera.bss.connectors.hoper.hydra | ||
|
||
trait Document { | ||
private static Integer DOCUMENT_STATE_ACTUAL_ID = 4003 // 'DOC_STATE_Actual' | ||
private static Integer DOCUMENT_STATE_EXECUTED_ID = 6003 // 'DOC_STATE_Executed' | ||
private static Integer DOCUMENT_STATE_DRAFT_ID = 3003 // 'DOC_STATE_Draft' | ||
private static Integer DOCUMENT_STATE_CANCELED_ID = 5003 // 'DOC_STATE_Canceled' | ||
private static Integer DOCUMENT_STATE_CLOSED_ID = 9003 // 'DOC_STATE_Closed' | ||
private static Integer DOCUMENT_STATE_DISSOLVED_ID = 12003 // 'DOC_STATE_Dissolved' | ||
private static Integer DOCUMENT_STATE_PROCESSING_ID = 11003 // 'DOC_STATE_Processing' | ||
private static Integer DOCUMENT_STATE_PREPARED_ID = 10003 // 'DOC_STATE_Prepared' | ||
private static Integer PROVIDER_ROLE_ID = 2004 // 'SUBJ_ROLE_Provider' | ||
private static Integer RECEIVER_ROLE_ID = 1004 // 'SUBJ_ROLE_Receiver' | ||
|
||
def getDocumentStateActualId() { | ||
return DOCUMENT_STATE_ACTUAL_ID | ||
} | ||
|
||
def getDocumentStateExecutedId() { | ||
return DOCUMENT_STATE_EXECUTED_ID | ||
} | ||
|
||
def getDocumentStateDraftId() { | ||
return DOCUMENT_STATE_DRAFT_ID | ||
} | ||
|
||
def getDocumentStateCanceledId() { | ||
return DOCUMENT_STATE_CANCELED_ID | ||
} | ||
|
||
def getDocumentStateClosedId() { | ||
return DOCUMENT_STATE_CLOSED_ID | ||
} | ||
|
||
def getDocumentStateDissolvedId() { | ||
return DOCUMENT_STATE_DISSOLVED_ID | ||
} | ||
|
||
def getDocumentStateProcessingId() { | ||
return DOCUMENT_STATE_PROCESSING_ID | ||
} | ||
|
||
def getDocumentStatePreparedId() { | ||
return DOCUMENT_STATE_PREPARED_ID | ||
} | ||
|
||
def getProviderRoleId() { | ||
return PROVIDER_ROLE_ID | ||
} | ||
|
||
def getReceiverRoleId() { | ||
return RECEIVER_ROLE_ID | ||
} | ||
} |