Hola ,necesitaria si me pueden ayudar a convertir esta clase groovy que tiene filtros a clase java .Clase Goovy
private List searchFilters() {
List availableFilters
Map storeMapInKvs = keyValueStoreService.get("cbk_available_filters")
if (storeMapInKvs) { log.info("Load availableFilters from kvs") availableFilters = storeMapInKvs."available_filters" } else { def filterableField = ["status", "cc_type", "operator_id", "flow_type", "response_pend", "labels", "fraud_status_buyer", "fraud_status_seller", "dispute_status", "typification_payer"] availableFilters = filterableField.collect { def filter = [:] filter."id" = it if (it == "response_pend") { filter."name" = "Response Pending" } else { filter."name" = SEARCH_PARAMS_DESC."$it" }
def fieldName = it
if (it == "cc_type") { fieldName = "credit_card.type" } else if (it == "typification_payer") { fieldName = "buyer.typification" } else if (it == "dispute_status") { fieldName = "case_status.dispute_status" }
if (it == "response_pend") { filter."values" = [ [ "id": "RESPONSE_PEND_SELLER", "name": "Pend. Resp. Vendedor" ], [ "id": "RESPONSE_PEND_BUYER", "name": "Pend. Resp. Comprador" ], [ "id": "RESPONSE_PEND_BOTH", "name": "Pend. Resp" ] ] } else if (it == "fraud_status_buyer") { filter."values" = [ [ "id": "FRAUD", "name": "Buyer Fraud" ], [ "id": "TRANSACTIONAL", "name": "Buyer Transactional" ] ] } else if (it == "fraud_status_seller") { filter."values" = [ [ "id": "FRAUD", "name": "Seller Fraude" ], [ "id": "TRANSACTIONAL", "name": "Seller Transactional" ] ] } else if (it == "status") { filter.values = documentSearchService.possibleValuesFromDSByTerm(it).collect { status -> return [ id: status, name: status, status_details: documentSearchService.possibleValuesFromDSByTerm("status_detail", "status", status).collect { statusDetail -> [ id: statusDetail, name: statusDetail ] } ] } } else if (it == "operator_id") { filter.values = grailsApplication.config.sites.keySet().collect { site -> if (site == "HSP") { grailsApplication.config.sites.HSP.keySet().collect { hspSite -> return [ id: hspSite, name: hspSite, operators: getOperatorsBySite(hspSite).collect { operator -> return [ id: operator, name: operator ] } ] } } else { return [ id: site, name: site, operators: getOperatorsBySite(site).collect { operator -> return [ id: operator, name: operator ] } ] } }.flatten() } else if (it == "labels") { filter."values" = cbkLabelDaoService.listLabels() } else { filter."values" = documentSearchService.possibleValuesFromDSByTerm(fieldName).collect { term -> return [ id: term, name: term ] } } return filter }
keyValueStoreService.put("cbk_available_filters", [available_filters: availableFilters], 43200) } return availableFilters }
muchas gracias
Hola ,
necesitaria si me pueden ayudar a convertir esta clase groovy que tiene filtros a clase java .
Clase Goovy
private List searchFilters() {
List availableFilters
Map storeMapInKvs = keyValueStoreService.get("cbk_available_filters")
if (storeMapInKvs) {
log.info("Load availableFilters from kvs")
availableFilters = storeMapInKvs."available_filters"
} else {
def filterableField = ["status", "cc_type", "operator_id", "flow_type", "response_pend", "labels", "fraud_status_buyer", "fraud_status_seller", "dispute_status", "typification_payer"]
availableFilters = filterableField.collect {
def filter = [:]
filter."id" = it
if (it == "response_pend") {
filter."name" = "Response Pending"
} else {
filter."name" = SEARCH_PARAMS_DESC."$it"
}
def fieldName = it
if (it == "cc_type") {
fieldName = "credit_card.type"
} else if (it == "typification_payer") {
fieldName = "buyer.typification"
} else if (it == "dispute_status") {
fieldName = "case_status.dispute_status"
}
if (it == "response_pend") {
filter."values" = [
[
"id": "RESPONSE_PEND_SELLER",
"name": "Pend. Resp. Vendedor"
],
[
"id": "RESPONSE_PEND_BUYER",
"name": "Pend. Resp. Comprador"
],
[
"id": "RESPONSE_PEND_BOTH",
"name": "Pend. Resp"
]
]
} else if (it == "fraud_status_buyer") {
filter."values" = [
[
"id": "FRAUD",
"name": "Buyer Fraud"
],
[
"id": "TRANSACTIONAL",
"name": "Buyer Transactional"
]
]
} else if (it == "fraud_status_seller") {
filter."values" = [
[
"id": "FRAUD",
"name": "Seller Fraude"
],
[
"id": "TRANSACTIONAL",
"name": "Seller Transactional"
]
]
} else if (it == "status") {
filter.values = documentSearchService.possibleValuesFromDSByTerm(it).collect { status ->
return [
id: status,
name: status,
status_details: documentSearchService.possibleValuesFromDSByTerm("status_detail", "status", status).collect { statusDetail ->
[
id: statusDetail,
name: statusDetail
]
}
]
}
} else if (it == "operator_id") {
filter.values = grailsApplication.config.sites.keySet().collect { site ->
if (site == "HSP") {
grailsApplication.config.sites.HSP.keySet().collect { hspSite ->
return [
id: hspSite,
name: hspSite,
operators: getOperatorsBySite(hspSite).collect { operator ->
return [
id: operator,
name: operator
]
}
]
}
} else {
return [
id: site,
name: site,
operators: getOperatorsBySite(site).collect { operator ->
return [
id: operator,
name: operator
]
}
]
}
}.flatten()
} else if (it == "labels") {
filter."values" = cbkLabelDaoService.listLabels()
} else {
filter."values" = documentSearchService.possibleValuesFromDSByTerm(fieldName).collect { term ->
return [
id: term,
name: term
]
}
}
return filter
}
keyValueStoreService.put("cbk_available_filters", [available_filters: availableFilters], 43200)
}
return availableFilters
}
muchas gracias