Skip to content

Commit

Permalink
Merge pull request #24 from latera/HCX-12
Browse files Browse the repository at this point in the history
HCX-12 Add methods for files to document attaching
  • Loading branch information
NatalieKor authored Feb 17, 2020
2 parents f20661a + ca2f5a8 commit f654a00
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ v1.4.1 [2020-02-14]
- [#3](https://github.com/latera/camunda-ext/pull/3) Add methods to tag entities into hid.Hydra class
- [#20](https://github.com/latera/camunda-ext/pull/20) Add newMessage method to MailSender class
- [#3200317](https://github.com/latera/camunda-ext/commit/3200317) Allow to pass constant id with non-Integer type into getConstantCode method
- [#24](https://github.com/latera/camunda-ext/pull/24) Add methods for files to document attaching

### Refactoring
- [#8](https://github.com/latera/camunda-ext/pull/8) Prettify runCommand, Add constants, use constants instead of magic numbers in logger, Update docs
Expand Down
82 changes: 81 additions & 1 deletion src/org/camunda/latera/bss/connectors/hoper/hydra/File.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ trait File {
return getFileEntityType(getSubjectEntityType(subjectId), id)
}

Map getContractFileEntityType(def contractId, def id = null) {
return getFileEntityType(getContractEntityType(contractId), id)
}

private Map getFileDefaultParams() {
return [
name : '',
Expand Down Expand Up @@ -53,6 +57,23 @@ trait File {
return result
}

List getContractFiles(Map input = [:], def contractId) {
LinkedHashMap params = getPaginationDefaultParams() + input

List result = []
List files = getEntities(getContractFileEntityType(contractId), params)
if (files) {
files.each { it ->
result.add([
n_doc_file_id : it.n_doc_file_id,
file_name : it.file_name,
content : Base64Converter.from(it.base64_content)
])
}
}
return result
}

Map getSubjectFile(def subjectId, def fileId) {
LinkedHashMap file = getEntity(getSubjectFileEntityType(subjectId), fileId)
if (file) {
Expand All @@ -66,15 +87,37 @@ trait File {
return file
}

Map getContractFile(def contractId, def fileId) {
LinkedHashMap file = getEntity(getContractFileEntityType(contractId), fileId)
if (file) {
LinkedHashMap result = [
n_doc_file_id : file.n_doc_file_id,
file_name : file.file_name,
content : Base64Converter.from(file.base64_content)
]
return result
}
return file
}

Map getSubjectFile(Map input) {
return getSubjectFile(input.subjectId, input.fileId)
}

Map getContractFile(Map input) {
return getContractFile(input.contractId, input.fileId)
}

Map createSubjectFile(Map input = [:], def subjectId) {
LinkedHashMap params = getFileParams(input)
return createEntity(getSubjectFileEntityType(subjectId), params)
}

Map createContractFile(Map input = [:], def contractId) {
LinkedHashMap params = getFileParams(input)
return createEntity(getContractFileEntityType(contractId), params)
}

List createSubjectFiles(Object[] input = [], def subjectId) {
List result = []
input.each { Map item ->
Expand All @@ -83,15 +126,32 @@ trait File {
return result
}

List createContractFiles(Object[] input = [], def contractId) {
List result = []
input.each { Map item ->
result += createContractFile(item, contractId)
}
return result
}

List createSubjectFiles(def subjectId, List input) {
return createSubjectFiles(input as Object[], subjectId)
}

List createContractFiles(def contractId, List input) {
return createContractFiles(input as Object[], contractId)
}

Map updateSubjectFile(Map input = [:], def subjectId, def fileId) {
LinkedHashMap params = getFileParams(input)
return updateEntity(getSubjectFileEntityType(subjectId), fileId, params)
}

Map updateContractFile(Map input = [:], def contractId, def fileId) {
LinkedHashMap params = getFileParams(input)
return updateEntity(getContractFileEntityType(contractId), fileId, params)
}

List updateSubjectFiles(Object[] input = [], def subjectId) {
List result = []
input.each { Map item ->
Expand All @@ -100,15 +160,35 @@ trait File {
return result
}

List updateContractFiles(Object[] input = [], def contractId) {
List result = []
input.each { Map item ->
result += updateContractFile(item + [contractId: contractId])
}
return result
}

List updateSubjectFiles(def subjectId, List input) {
return updateSubjectFiles(input as Object[], subjectId)
}

List updateContractFiles(def contractId, List input) {
return updateContractFiles(input as Object[], subjectId)
}

Boolean deleteSubjectFile(def subjectId, def fileId) {
return deleteEntity(getSubjectFileEntityType(subjectId), fileId)
}

Boolean deleteContractFile(def contractId, def fileId) {
return deleteEntity(getContractFileEntityType(contractId), fileId)
}

Boolean deleteSubjectFile(Map input) {
return deleteSubjectFile(input.subjectId, input.fileId)
}
}

Boolean deleteContractFile(Map input) {
return deleteContractFile(input.contractId, input.fileId)
}
}

0 comments on commit f654a00

Please sign in to comment.