diff --git a/src/org/camunda/latera/bss/connectors/HID.groovy b/src/org/camunda/latera/bss/connectors/HID.groovy index 1ac429d6..d8e82dfb 100644 --- a/src/org/camunda/latera/bss/connectors/HID.groovy +++ b/src/org/camunda/latera/bss/connectors/HID.groovy @@ -24,10 +24,15 @@ class HID implements Table { this.proxy.setBasicAuth(this.user, this.password) } - List queryDatabase(CharSequence query, Boolean asMap = false, Boolean noLimit = false) { + List queryDatabase(CharSequence query, Boolean asMap = false, Integer limit = 0, Integer page = 1) { List result = [] - Integer pageNumber = noLimit ? 0 : 1 - LinkedHashMap answer = this.proxy.invokeMethod('SELECT', [query.toString(), pageNumber]) + if (limit != 0 && limit != null) { + query = """SELECT * FROM ( +${query} +) +WHERE ROWNUM <= 1""" + } + LinkedHashMap answer = this.proxy.invokeMethod('SELECT', [query.toString(), page]) List rows = answer.SelectResult if (rows) { rows.each{ row -> @@ -57,16 +62,16 @@ class HID implements Table { return result } - List queryDatabaseList(CharSequence query, Boolean noLimit = false) { - return queryDatabase(query, false, noLimit) + List queryDatabaseList(CharSequence query, Integer limit = 0, Integer page = 1) { + return queryDatabase(query, false, limit, page) } - List queryDatabaseMap(CharSequence query, Boolean noLimit = false) { - return queryDatabase(query, true, noLimit) + List queryDatabaseMap(CharSequence query, Integer limit = 0, Integer page = 1) { + return queryDatabase(query, true, limit, page) } - def queryFirst(CharSequence query, Boolean asMap = false, Boolean noLimit = false) { - List result = this.queryDatabase(query, asMap) + def queryFirst(CharSequence query, Boolean asMap = false) { + List result = this.queryDatabase(query, asMap, 1) if (result) { return result.getAt(0) @@ -75,11 +80,11 @@ class HID implements Table { } } - List queryFirstList(CharSequence query, Boolean noLimit = false) { + List queryFirstList(CharSequence query) { return queryFirst(query, false, noLimit) } - Map queryFirstMap(CharSequence query, Boolean noLimit = false) { + Map queryFirstMap(CharSequence query) { return queryFirst(query, true, noLimit) } diff --git a/src/org/camunda/latera/bss/connectors/hid/Table.groovy b/src/org/camunda/latera/bss/connectors/hid/Table.groovy index c1ef00c1..39bb3479 100644 --- a/src/org/camunda/latera/bss/connectors/hid/Table.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/Table.groovy @@ -11,6 +11,7 @@ trait Table { private static LinkedHashMap DEFAULT_WHERE = [:] private static LinkedHashMap DEFAULT_ORDER = [:] private static List DEFAULT_FIELDS = null + private static Integer DEFAULT_LIMIT = 0 List getTableColumns(CharSequence tableName, CharSequence tableOwner = 'AIS_NET') { String tableFullName = "${tableOwner}.${tableName}" @@ -24,7 +25,7 @@ trait Table { FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = '${tableName}' AND OWNER = '${tableOwner}' - """, false, true) + """, false, 0, 0) columnsList = result*.getAt(0) // get only first column values return TableColumnCache.instance.putAndGet(tableFullName, columnsList) @@ -34,7 +35,8 @@ trait Table { CharSequence tableName, fields = DEFAULT_FIELDS, Map where = DEFAULT_WHERE, - order = DEFAULT_ORDER + order = DEFAULT_ORDER, + Integer limit = DEFAULT_LIMIT ) { String query = "SELECT" @@ -97,16 +99,17 @@ trait Table { } } } - return queryDatabase(query, true) + return queryDatabase(query, true, limit) } List getTableData(Map options, CharSequence tableName) { LinkedHashMap params = [ fields : DEFAULT_FIELDS, where : DEFAULT_WHERE, - order : DEFAULT_ORDER + order : DEFAULT_ORDER, + limit : DEFAULT_LIMIT ] + options - return getTableData(tableName, params.fields, params.where, params.order) + return getTableData(tableName, params.fields, params.where, params.order, params.limit) } List getTableData(Map input) { @@ -114,9 +117,10 @@ trait Table { tableName : '', fields : DEFAULT_FIELDS, where : DEFAULT_WHERE, - order : DEFAULT_ORDER + order : DEFAULT_ORDER, + limit : DEFAULT_LIMIT ] + input - return getTableData(params.tableName, params.fields, params.where, params.order) + return getTableData(params.tableName, params.fields, params.where, params.order, params.limit) } def getTableFirst( @@ -126,9 +130,9 @@ trait Table { order = DEFAULT_ORDER ) { if (isString(fields) && fields != '*') { - return getTableData(tableName, [fields], where, order)?.getAt(0)?."${fields}" + return getTableData(tableName, [fields], where, order, 1)?.getAt(0)?."${fields}" } - return getTableData(tableName, fields, where, order)?.getAt(0) + return getTableData(tableName, fields, where, order, 1)?.getAt(0) } def getTableFirst(Map options, CharSequence tableName) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Account.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Account.groovy index 7e47e0a4..d082e8ab 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Account.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Account.groovy @@ -42,7 +42,8 @@ trait Account { number : null, maxOverdraft : null, rem : null, - firmId : getFirmId() + firmId : getFirmId(), + limit : 0 ], input) LinkedHashMap where = [:] @@ -79,11 +80,11 @@ trait Account { if (params.firmId) { where.n_firm_id = params.firmId } - return hid.getTableData(getAccountsTable(), where: where) + return hid.getTableData(getAccountsTable(), where: where, limit: params.limit) } Map getAccountBy(Map input) { - return getAccountsBy(input)?.getAt(0) + return getAccountsBy(input + [limit: 1])?.getAt(0) } Map getAccount(def accountId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Address.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Address.groovy index 60935bb3..0183235d 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Address.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Address.groovy @@ -87,7 +87,8 @@ trait Address { isMain : null, operationDate : null, beginDate : null, - endDate : null + endDate : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -150,18 +151,19 @@ trait Address { String oracleDate = encodeDateStr(params.operationDate) where[oracleDate] = [BETWEEN: "D_BEGIN AND NVL(D_END, ${oracleDate})"] } - return hid.getTableData(getObjectAddressesTable(), where: where, order: ['C_FL_MAIN DESC']) + LinkedHashMap order = [c_fl_main: 'desc'] + return hid.getTableData(getObjectAddressesTable(), where: where, order: order, limit: params.limit) } Map getObjAddressBy(Map input) { - return getObjAddressesBy(input)?.getAt(0) + return getObjAddressesBy(input + [limit: 1])?.getAt(0) } Map getObjAddress(def objAddressId) { LinkedHashMap where = [ n_obj_address_id: objAddressId ] - return hid.getTableData(getObjectAddressesTable(), where: where) + return hid.getTableFirst(getObjectAddressesTable(), where: where) } List getSubjAddressesBy(Map input) { @@ -180,7 +182,8 @@ trait Address { rem : null, bindAddrTypeId : getDefaultAddressBindTypeId(), stateId : getDefaultAddressStateId(), - isMain : null + isMain : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -229,18 +232,19 @@ trait Address { if (params.isMain != null) { where.c_fl_main = encodeBool(params.isMain) } - return hid.getTableData(getSubjectAddressesTable(), where: where, order: ['C_FL_MAIN DESC']) + LinkedHashMap order = [c_fl_main: 'desc'] + return hid.getTableData(getSubjectAddressesTable(), where: where, order: order, limit: params.limit) } Map getSubjAddressBy(Map input) { - return getSubjAddressesBy(input)?.getAt(0) + return getSubjAddressesBy(input + [limit: 1])?.getAt(0) } Map getSubjAddress(def subjAddressId) { LinkedHashMap where = [ n_subj_address_id: subjAddressId ] - return hid.getTableData(getSubjectAddressesTable(), where: where) + return hid.getTableFirst(getSubjectAddressesTable(), where: where) } List getEntityAddressesBy(Map input) { @@ -279,7 +283,7 @@ trait Address { } Map getEntityAddressBy(Map input) { - return getEntityAddressesBy(input)?.getAt(0) + return getEntityAddressesBy(input + [limit: 1])?.getAt(0) } Map getEntityAddress(def entityOrEntityTypeId, def entityAddressId) { @@ -341,11 +345,12 @@ trait Address { if (params.rem) { where.vc_rem = params.rem } - return hid.getTableData(getMainAddressesTable(), where: where, order: ['N_ADDRESS_ID ASC']) + LinkedHashMap order = [n_address_id: 'desc'] + return hid.getTableData(getMainAddressesTable(), where: where, order: order, limit: params.limit) } Map getAddressBy(Map input) { - return getAddressesBy(input)?.getAt(0) + return getAddressesBy(input + [limit: 1])?.getAt(0) } Map getAddress(def addressId) { @@ -1046,10 +1051,10 @@ trait Address { Number getSubnetIdByIP(CharSequence ip) { def subnetId = null try { - subnetId = hid.queryFirst(""" + subnetId = toIntSafe(hid.queryFirst(""" SELECT SI_ADDRESSES_PKG_S.GET_SUBNET_BY_IP_ADDRESS('$ip') FROM DUAL - """)?.getAt(0) + """)?.getAt(0)) } catch (Exception e){ logger.error_oracle(e) } diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Bill.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Bill.groovy index 7abe3a89..268e3277 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Bill.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Bill.groovy @@ -115,7 +115,8 @@ trait Bill { discountDocId : null, operationDate : null, beginDate : null, - endDate : null + endDate : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -193,19 +194,19 @@ trait Bill { where[oracleDate] = [BETWEEN: "D_BEGIN AND NVL(D_END, ${oracleDate})"] } LinkedHashMap order = [n_line_no: 'asc'] - return hid.getTableData(getBillLinesTable(), where: where, order: order) + return hid.getTableData(getBillLinesTable(), where: where, order: order, limit: params.limit) } - List getBillLines(def docId) { + List getBillLines(def docId, Integer limit = 0) { LinkedHashMap where = [ n_doc_id : docId, n_move_type_id : ['not in': [getChargeCanceledTypeId()]] ] - return hid.getTableData(getBillLinesTable(), where: where) + return hid.getTableData(getBillLinesTable(), where: where, limit: limit) } Map getBillLineBy(Map input) { - return getBillLinesBy(input)?.getAt(0) + return getBillLinesBy(input + [limit: 1])?.getAt(0) } Map getBillLine(def lineId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Company.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Company.groovy index 48ad407d..34ff3d18 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Company.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Company.groovy @@ -41,7 +41,8 @@ trait Company { opfId : null, groupId : null, firmId : getFirmId(), - stateId : getSubjectStateOnId() + stateId : getSubjectStateOnId(), + limit : 0 ], input) LinkedHashMap where = [:] @@ -96,11 +97,11 @@ trait Company { if (params.stateId) { where.n_subj_state_id = params.stateId } - return hid.getTableData(getCompaniesTable(), where: where) + return hid.getTableData(getCompaniesTable(), where: where, limit: params.limit) } Map getCompanyBy(Map input) { - return getCompaniesBy(input)?.getAt(0) + return getCompaniesBy(input + [limit: 1])?.getAt(0) } Boolean isCompany(CharSequence entityType) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Customer.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Customer.groovy index 856ad1e9..7988cfe5 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Customer.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Customer.groovy @@ -152,7 +152,8 @@ trait Customer { firmId : getFirmId(), resellerId : getResellerId(), stateId : getSubjectStateOnId(), - tags : null + tags : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -186,11 +187,11 @@ trait Customer { if (params.tags) { where.t_tags = params.tags } - return hid.getTableData(getCustomersTable(), where: where) + return hid.getTableData(getCustomersTable(), where: where, limit: params.limit) } Map getCustomerBy(Map input) { - return getCustomersBy(input)?.getAt(0) + return getCustomersBy(input + [limit: 1])?.getAt(0) } Boolean isCustomer(CharSequence entityType) { @@ -372,7 +373,8 @@ trait Customer { login : null, password : null, passwordHash : null, - hashTypeId : null + hashTypeId : null, + limit : 0 ], input) LinkedHashMap where = [ c_active: encodeBool(true) @@ -408,11 +410,11 @@ trait Customer { if (params.hashTypeId) { where.n_hash_type_id = hashTypeId } - return hid.getTableData(getCustomerNetServicesTable(), where: where) + return hid.getTableData(getCustomerNetServicesTable(), where: where, limit: params.limit) } Map getCustomerNetServiceAccessBy(Map input) { - return getCustomerNetServicesAccessBy(input)?.getAt(0) + return getCustomerNetServicesAccessBy(input + [limit: 1])?.getAt(0) } Map putCustomerNetServiceAccess(Map input) { @@ -522,7 +524,7 @@ trait Customer { } Map getCustomerAppAccessBy(Map input) { - return getCustomerAppsAccessBy(input)?.getAt(0) + return getCustomerAppsAccessBy(input + [limit: 1])?.getAt(0) } Map putCustomerAppAccess(Map input) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Document.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Document.groovy index e90d7dc5..55438bb4 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Document.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Document.groovy @@ -10,7 +10,6 @@ trait Document { private static String DOCUMENT_ADD_PARAMS_TABLE = 'SD_V_DOC_VALUES' private static String DOCUMENT_ADD_PARAM_TYPES_TABLE = 'SS_V_WFLOW_DOC_VALUES_TYPE' private static String DOCUMENT_BINDS_TABLE = 'SD_V_DOC_DOCUMENTS' - private static String DEFAULT_DOCUMENT_TYPE = 'DOC_TYPE_CustomerContract' private static String DOCUMENT_STATE_ACTUAL = 'DOC_STATE_Actual' private static String DOCUMENT_STATE_EXECUTED = 'DOC_STATE_Executed' private static String DOCUMENT_STATE_DRAFT = 'DOC_STATE_Draft' @@ -44,14 +43,6 @@ trait Document { return DOCUMENT_BINDS_TABLE } - String getDefaultDocumentType() { - return DEFAULT_DOCUMENT_TYPE - } - - Number getDefaultDocumentTypeId() { - return getRefIdByCode(getDefaultDocumentType()) - } - String getDocumentStateActual() { return DOCUMENT_STATE_ACTUAL } @@ -158,7 +149,7 @@ trait Document { List getDocumentsBy(Map input) { LinkedHashMap params = mergeParams([ docId : null, - docTypeId : getDefaultDocumentTypeId(), + docTypeId : null, parentDocId : null, reasonDocId : null, workflowId : null, @@ -171,7 +162,8 @@ trait Document { beginDate : null, endDate : null, number : null, - tags : null + tags : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -266,11 +258,11 @@ trait Document { where[oracleDate] = [BETWEEN: "D_BEGIN AND NVL(D_END, ${oracleDate})"] } LinkedHashMap order = [d_begin: 'desc', vc_doc_no: 'desc'] - return hid.getTableData(getDocumentsTable(), where: where, order: order) + return hid.getTableData(getDocumentsTable(), where: where, order: order, limit: params.limit) } Map getDocumentBy(Map input) { - return getDocumentsBy(input)?.getAt(0) + return getDocumentsBy(input + [limit: 1])?.getAt(0) } Number getDocumentTypeId(def docId) { @@ -395,7 +387,8 @@ trait Document { docId : null, roleId : null, subjectId : null, - accountId : null + accountId : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -414,11 +407,11 @@ trait Document { if (params.accountId) { where.n_account_id = params.accountId } - return hid.getTableData(getDocumentSubjectsTable(), where: where) + return hid.getTableData(getDocumentSubjectsTable(), where: where, limit: params.limit) } Map getDocumentSubjectBy(Map input) { - return getDocumentSubjectsBy(input)?.getAt(0) + return getDocumentSubjectsBy(input + [limit: 1])?.getAt(0) } Map getDocumentProviderBy(Map input) { @@ -509,7 +502,8 @@ trait Document { refTypeId : null, canModify : null, isMulti : null, - rem : null + rem : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -537,11 +531,11 @@ trait Document { if (params.isMulti != null) { where.c_fl_multi = encodeBool(params.isMulti) } - return hid.getTableData(getDocumentAddParamTypesTable(), where: where) + return hid.getTableData(getDocumentAddParamTypesTable(), where: where, limit: params.limit) } Map getDocumentAddParamTypeBy(Map input) { - return getDocumentAddParamTypesBy(input)?.getAt(0) + return getDocumentAddParamTypesBy(input + [limit: 1])?.getAt(0) } Map getDocumentAddParamTypeByCode(CharSequence code, def docTypeId = null) { @@ -580,7 +574,8 @@ trait Document { string : null, number : null, bool : null, - refId : null + refId : null, + limit : 0 ], prepareDocumentAddParam(input)) LinkedHashMap where = [:] @@ -605,11 +600,11 @@ trait Document { if (params.refId) { where.n_ref_id = params.refId } - return hid.getTableData(getDocumentAddParamsTable(), where: where) + return hid.getTableData(getDocumentAddParamsTable(), where: where, limit: params.limit) } Map getDocumentAddParamBy(Map input) { - return getDocumentAddParamsBy(input)?.getAt(0) + return getDocumentAddParamsBy(input + [limit: 1])?.getAt(0) } Map putDocumentAddParam(Map input) { @@ -696,7 +691,8 @@ trait Document { bindTypeId : null, docId : null, docBindId : null, - lineNumber : null + lineNumber : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -715,11 +711,11 @@ trait Document { if (params.lineNumber) { where.n_line_no = params.lineNumber } - return hid.getTableData(getDocumentBindsTable(), where: where) + return hid.getTableData(getDocumentBindsTable(), where: where, limit: params.limit) } Map getDocumentBindBy(Map input) { - return getDocumentBindsBy(input)?.getAt(0) + return getDocumentBindsBy(input + [limit: 1])?.getAt(0) } Map putDocumentBind(Map input) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Equipment.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Equipment.groovy index 030a6651..c1f16774 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Equipment.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Equipment.groovy @@ -75,7 +75,8 @@ trait Equipment { name : null, extCode : null, serialNo : null, - invNo : null + invNo : null, + limit : 0 ], input) LinkedHashMap where = [:] if (params.equipmentId) { @@ -108,11 +109,11 @@ trait Equipment { if (params.invNo) { where.vc_inv_no = params.invNo } - return hid.getTableData(getObjectsTable(), where: where) + return hid.getTableData(getObjectsTable(), where: where, limit: params.limit) } Map getObjectBy(Map input) { - return getObjectsBy(input)?.getAt(0) + return getObjectsBy(input + [limit: 1])?.getAt(0) } List getCustomerObjects(def customerId, Map input = [:]) { @@ -283,7 +284,8 @@ trait Equipment { ownerId : null, stateId : getEquipmentStateActualId(), code : null, - name : null + name : null, + limit : 0 ], input) LinkedHashMap where = [:] if (params.componentId) { @@ -310,11 +312,11 @@ trait Equipment { if (params.name) { where.vc_name = params.name } - return hid.getTableData(getEquipmentComponentsTable(), where: where) + return hid.getTableData(getEquipmentComponentsTable(), where: where, limit: params.limit) } Map getEquipmentComponentBy(Map input) { - return getEquipmentComponentsBy(input)?.getAt(0) + return getEquipmentComponentsBy(input + [limit: 1])?.getAt(0) } List getEquipmentEntries(def equipmentId, Map input = [:]) { @@ -539,7 +541,8 @@ trait Equipment { string : null, number : null, bool : null, - refId : null + refId : null, + limit : 0 ], prepareEquipmentAddParam(input)) LinkedHashMap where = [:] @@ -567,11 +570,11 @@ trait Equipment { if (params.refId) { where.n_ref_id = params.refId } - return hid.getTableData(getEquipmentAddParamsTable(), where: where) + return hid.getTableData(getEquipmentAddParamsTable(), where: where, limit: params.limit) } Map getEquipmentAddParamBy(Map input) { - return getEquipmentAddParamsBy(input)?.getAt(0) + return getEquipmentAddParamsBy(input + [limit: 1])?.getAt(0) } Map putEquipmentAddParam(Map input) { @@ -706,7 +709,8 @@ trait Equipment { componentId : null, bindRoleId : null, bindMainId : null, - bindComponentId : null + bindComponentId : null, + limit : 0 ], input) LinkedHashMap where = [:] if (params.bindId) { @@ -727,11 +731,11 @@ trait Equipment { if (params.bindComponentId) { where.n_bind_object_id = params.bindComponentId } - return hid.getTableData(getEquipmentBindsTable(), where: where) + return hid.getTableData(getEquipmentBindsTable(), where: where, limit: params.limit) } Map getEquipmentBindBy(Map input) { - return getEquipmentBindsBy(input)?.getAt(0) + return getEquipmentBindsBy(input + [limit: 1])?.getAt(0) } Map putEquipmentBind(Map input) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Good.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Good.groovy index 9137a3ef..d2b417f2 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Good.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Good.groovy @@ -40,7 +40,8 @@ trait Good { name : null, isProvider : null, isCustomer : null, - tags : null + tags : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -74,11 +75,11 @@ trait Good { if (params.isCustomer != null) { where.c_fl_customer_equipment = encodeBool(params.isCustomer) } - return hid.getTableData(getGoodsTable(), where: where) + return hid.getTableData(getGoodsTable(), where: where, limit: params.limit) } Map getGoodBy(Map input) { - return getGoodsBy(input)?.getAt(0) + return getGoodsBy(input + [limit: 1])?.getAt(0) } Number getGoodUnitId(def goodId) { @@ -92,7 +93,7 @@ trait Good { LinkedHashMap where = [ n_good_value_type_id: paramId ] - return hid.getTableData(getGoodAddParamTypesTable(), where: where) + return hid.getTableFirst(getGoodAddParamTypesTable(), where: where) } List getGoodAddParamTypesBy(Map input) { @@ -106,7 +107,8 @@ trait Good { canModify : null, isMulti : null, isObject : null, - rem : null + rem : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -137,11 +139,11 @@ trait Good { if (params.isObject != null) { where.c_fl_object = encodeBool(params.isObject) } - return hid.getTableData(getGoodAddParamTypesTable(), where: where) + return hid.getTableData(getGoodAddParamTypesTable(), where: where, limit: params.limit) } Map getGoodAddParamTypeBy(Map input) { - return getGoodAddParamTypesBy(input)?.getAt(0) + return getGoodAddParamTypesBy(input + [limit: 1])?.getAt(0) } Map getGoodAddParamTypeByCode(CharSequence code) { @@ -204,22 +206,22 @@ trait Good { if (params.refId) { where.n_ref_id = params.refId } - return hid.getTableData(getGoodAddParamsTable(), where: where) + return hid.getTableData(getGoodAddParamsTable(), where: where, limit: params.limit) } Map getGoodAddParamBy(Map input) { - return getGoodAddParamsBy(input)?.getAt(0) + return getGoodAddParamsBy(input + [limit: 1])?.getAt(0) } String getServSchemesTable() { return SERV_SCHEMES_TABLE } - Map getServSchemes(def servSchemeId) { + Map getServScheme(def servSchemeId) { LinkedHashMap where = [ n_serv_scheme_id: servSchemeId ] - return hid.getTableData(getServSchemesTable(), where: where) + return hid.getTableFirst(getServSchemesTable(), where: where) } List getServSchemesBy(Map input) { @@ -249,7 +251,8 @@ trait Good { servEndChargeTypeId : null, restrictConditionId : null, matchingPriorityId : null, - isArchived : false + isArchived : false, + limit : 0 ], input) LinkedHashMap where = [:] @@ -338,10 +341,10 @@ trait Good { where.c_fl_archived = encodeBool(params.isArchived) } - return hid.getTableData(getServSchemesTable(), where: where) + return hid.getTableData(getServSchemesTable(), where: where, limit: params.limit) } Map getServSchemeBy(Map input) { - return getServSchemesBy(input)?.getAt(0) + return getServSchemesBy(input + [limit: 1])?.getAt(0) } } \ No newline at end of file diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Group.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Group.groovy index 5e530084..625fd43f 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Group.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Group.groovy @@ -31,7 +31,8 @@ trait Group { name : null, code : null, firmId : getFirmId(), - stateId : getSubjectStateOnId() + stateId : getSubjectStateOnId(), + limit : 0 ], input) LinkedHashMap where = [:] @@ -59,11 +60,11 @@ trait Group { if (params.stateId) { where.n_subj_state_id = params.stateId } - return hid.getTableData(getGroupsTable(), where: where) + return hid.getTableData(getGroupsTable(), where: where, limit: params.limit) } Map getGroupBy(Map input) { - return getGroupsBy(input)?.getAt(0) + return getGroupsBy(input + [limit: 1])?.getAt(0) } Boolean isGroup(CharSequence entityType) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Invoice.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Invoice.groovy index 6557f9d1..9f6698e8 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Invoice.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Invoice.groovy @@ -128,7 +128,8 @@ trait Invoice { LinkedHashMap params = mergeParams([ subscriptionId : null, stateId : ['not in': [getDocumentStateCanceledId()]], - operationDate : null + operationDate : null, + limit : 0 ], input) LinkedHashMap where = [ n_subj_good_id: params.subscriptionId @@ -140,7 +141,7 @@ trait Invoice { String oracleDate = encodeDateStr(params.operationDate) where[oracleDate] = [BETWEEN: "D_BEGIN AND NVL(D_END, ${oracleDate})"] } - return hid.getTableData(getGoodMovesTable(), where: where) + return hid.getTableData(getGoodMovesTable(), where: where, limit: params.limit) } List getInvoicesBySubscription(def subscriptionId, def stateId = ['not in': [getDocumentStateCanceledId()]], def operationDate = null) { @@ -236,7 +237,8 @@ trait Invoice { provisionRuleId : null, operationDate : null, beginDate : null, - endDate : null + endDate : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -334,19 +336,19 @@ trait Invoice { where.d_oper = params.operationDate } LinkedHashMap order = [n_line_no: 'asc'] - return hid.getTableData(getInvoiceLinesTable(), where: where, order: order) + return hid.getTableData(getInvoiceLinesTable(), where: where, order: order, limit: params.limit) } - List getInvoiceLines(def docId) { + List getInvoiceLines(def docId, Integer limit = 0) { LinkedHashMap where = [ n_doc_id : docId, n_move_type_id : ['not in': [getChargeCanceledTypeId()]] ] - return hid.getTableData(getInvoiceLinesTable(), where: where) + return hid.getTableData(getInvoiceLinesTable(), where: where, limit: limit) } Map getInvoiceLineBy(Map input) { - return getInvoiceLinesBy(input)?.getAt(0) + return getInvoiceLinesBy(input + [limit: 1])?.getAt(0) } Map getInvoiceLine(def line) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Person.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Person.groovy index 3a2fc180..2cd8172d 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Person.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Person.groovy @@ -46,7 +46,8 @@ trait Person { sexId : null, groupId : null, firmId : getFirmId(), - stateId : getSubjectStateOnId() + stateId : getSubjectStateOnId(), + limit : 0 ], input) LinkedHashMap where = [:] @@ -95,11 +96,11 @@ trait Person { if (params.stateId) { where.n_subj_state_id = params.stateId } - return hid.getTableData(getPersonsTable(), where: where) + return hid.getTableData(getPersonsTable(), where: where, limit: params.limit) } Map getPersonBy(Map input) { - return getPersonsBy(input)?.getAt(0) + return getPersonsBy(input + [limit: 1])?.getAt(0) } Map getPersonPrivate(def subjectId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/PriceOrder.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/PriceOrder.groovy index 6e6e4967..a0ae449f 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/PriceOrder.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/PriceOrder.groovy @@ -35,7 +35,8 @@ trait PriceOrder { deferTypeId : null, schedDeferTypeId : null, schedDeferPayDays : null, - unschedDeferPayDays : null + unschedDeferPayDays : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -114,14 +115,14 @@ trait PriceOrder { where.n_unsched_defer_pay_days = params.unschedDeferPayDays } LinkedHashMap order = [d_begin: 'asc'] - return hid.getTableData(getPriceOrdersTable(), where: where, order: order) + return hid.getTableData(getPriceOrdersTable(), where: where, order: order, limit: params.limit) } Map getPriceOrder(def docId) { LinkedHashMap where = [ n_doc_id: docId ] - return hid.getTableData(getPriceOrdersTable(), where: where) + return hid.getTableFirst(getPriceOrdersTable(), where: where) } List getPriceLinesBy(Map input) { @@ -152,7 +153,8 @@ trait PriceOrder { timeIntervalId : null, providerId : null, priceParam : null, - userRem : null + userRem : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -238,18 +240,18 @@ trait PriceOrder { where.vc_user_rem = params.userRem } LinkedHashMap order = [n_line_no: 'asc'] - return hid.getTableData(getPriceLinesTable(), where: where, order: order) + return hid.getTableData(getPriceLinesTable(), where: where, order: order, limit: params.limit) } - List getPriceLines(def docId) { + List getPriceLines(def docId, Integer limit = 0) { LinkedHashMap where = [ n_doc_id: docId ] - return hid.getTableData(getPriceLinesTable(), where: where) + return hid.getTableData(getPriceLinesTable(), where: where, limit: limit) } Map getPriceLineBy(Map input) { - return getPriceLinesBy(input)?.getAt(0) + return getPriceLinesBy(input + [limit: 1])?.getAt(0) } Map getPriceLine(def lineId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Ref.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Ref.groovy index 1d8b5a82..5481ae06 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Ref.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Ref.groovy @@ -41,7 +41,8 @@ trait Ref { number2 : null, number3 : null, isEditable : null, - isManual : null + isManual : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -106,7 +107,7 @@ trait Ref { where.c_fl_manual = Oracle.encodeBool(params.isManual) } - List result = hid.getTableData(getRefsTable(), where: where) + List result = hid.getTableData(getRefsTable(), where: where, limit: params.limit) if (result) { result.each { ref -> RefCache.instance.put(ref.vc_code, ref.n_ref_id) @@ -116,7 +117,7 @@ trait Ref { } Map getRefBy(Map input) { - return getRefsBy(input)?.getAt(0) + return getRefsBy(input + [limit: 1])?.getAt(0) } Map getRefByCode(CharSequence code) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Region.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Region.groovy index ea1b2fdd..ea089fc4 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Region.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Region.groovy @@ -92,6 +92,7 @@ trait Region { home : null, ownership : null, zip : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -134,11 +135,11 @@ trait Region { if (params.zip) { where.vc_zip = params.zip } - return hid.getTableData(getRegionsTable(), where: where) + return hid.getTableData(getRegionsTable(), where: where, limit: params.limit) } Map getRegionBy(Map input) { - return getRegionsBy(input)?.getAt(0) + return getRegionsBy(input + [limit: 1])?.getAt(0) } Map getRegion(regionId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Reseller.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Reseller.groovy index 870dc820..e226970d 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Reseller.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Reseller.groovy @@ -32,7 +32,8 @@ trait Reseller { name : null, code : null, firmId : getFirmId(), - stateId : getSubjectStateOnId() + stateId : getSubjectStateOnId(), + limit : 0 ], input) LinkedHashMap where = [:] @@ -60,11 +61,11 @@ trait Reseller { if (params.stateId) { where.n_subj_state_id = params.stateId } - return hid.getTableData(getResellersTable(), where: where) + return hid.getTableData(getResellersTable(), where: where, limit: params.limit) } Map getResellerBy(Map input) { - return getResellersBy(input)?.getAt(0) + return getResellersBy(input + [limit: 1])?.getAt(0) } Boolean isReseller(CharSequence entityType) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Subject.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Subject.groovy index 2d89ba41..939bb510 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Subject.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Subject.groovy @@ -85,7 +85,8 @@ trait Subject { firmId : getFirmId(), resellerId : getResellerId(), stateId : getSubjectStateOnId(), - tags : null + tags : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -128,11 +129,11 @@ trait Subject { if (params.tags) { where.t_tags = params.tags } - return hid.getTableData(getSubjectsTable(), where: where) + return hid.getTableData(getSubjectsTable(), where: where, limit: params.limit) } Map getSubjectBy(Map input) { - return getSubjectsBy(input)?.getAt(0) + return getSubjectsBy(input + [limit: 1])?.getAt(0) } Map getSubject(def subjectId) { @@ -192,7 +193,7 @@ trait Subject { LinkedHashMap where = [ n_subj_value_type_id: paramId ] - return hid.getTableData(getSubjectAddParamTypesTable(), where: where) + return hid.getTableFirst(getSubjectAddParamTypesTable(), where: where) } List getSubjectAddParamTypesBy(Map input) { @@ -206,7 +207,8 @@ trait Subject { canModify : null, isMulti : null, isReadOnly : null, - rem : null + rem : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -237,11 +239,11 @@ trait Subject { if (params.isReadOnly != null) { where.c_fl_read_only = encodeBool(params.isReadOnly) } - return hid.getTableData(getSubjectAddParamTypesTable(), where: where) + return hid.getTableData(getSubjectAddParamTypesTable(), where: where, limit: params.limit) } Map getSubjectAddParamTypeBy(Map input) { - return getSubjectAddParamTypesBy(input)?.getAt(0) + return getSubjectAddParamTypesBy(input + [limit: 1])?.getAt(0) } Map getSubjectAddParamTypeByCode(CharSequence code, def subjTypeId = null) { @@ -276,7 +278,8 @@ trait Subject { string : null, number : null, bool : null, - refId : null + refId : null, + limit : 0 ], prepareSubjectAddParam(input)) LinkedHashMap where = [:] @@ -304,11 +307,11 @@ trait Subject { if (params.refId) { where.n_ref_id = params.refId } - return hid.getTableData(getSubjectAddParamsTable(), where: where) + return hid.getTableData(getSubjectAddParamsTable(), where: where, limit: params.limit) } Map getSubjectAddParamBy(Map input) { - return getSubjectAddParamsBy(input)?.getAt(0) + return getSubjectAddParamsBy(input + [limit: 1])?.getAt(0) } Map putSubjectAddParam(Map input) { @@ -387,7 +390,8 @@ trait Subject { LinkedHashMap params = mergeParams([ subjectId : null, groupId : null, - isMain : null + isMain : null, + limit : 0 ], input) LinkedHashMap where = [:] LinkedHashMap order = [c_fl_main: 'DESC'] @@ -401,11 +405,11 @@ trait Subject { if (params.isMain != null) { where.c_fl_main = encodeBool(params.isMain) } - return hid.getTableData(getSubjectGroupsTable(), where: where, order: order) + return hid.getTableData(getSubjectGroupsTable(), where: where, order: order, limit: params.limit) } Map getSubjectGroupBy(Map input) { - return getSubjectGroupsBy(input)?.getAt(0) + return getSubjectGroupsBy(input + [limit: 1])?.getAt(0) } List getSubjectGroups(def subjectId) { diff --git a/src/org/camunda/latera/bss/connectors/hid/hydra/Subscription.groovy b/src/org/camunda/latera/bss/connectors/hid/hydra/Subscription.groovy index ad0a771a..8aef834b 100644 --- a/src/org/camunda/latera/bss/connectors/hid/hydra/Subscription.groovy +++ b/src/org/camunda/latera/bss/connectors/hid/hydra/Subscription.groovy @@ -31,7 +31,8 @@ trait Subscription { isClosed : null, operationDate : null, beginDate : null, - endDate : null + endDate : null, + limit : 0 ], input) LinkedHashMap where = [:] @@ -76,11 +77,11 @@ trait Subscription { where[oracleDate] = [BETWEEN: "D_BEGIN AND NVL(D_END, ${oracleDate})"] } LinkedHashMap order = [d_begin: 'asc'] - return hid.getTableData(getSubscriptionsTable(), where: where, order: order) + return hid.getTableData(getSubscriptionsTable(), where: where, order: order, limit: params.limit) } Map getSubscriptionBy(Map input) { - return getSubscriptionsBy(input)?.getAt(0) + return getSubscriptionsBy(input + [limit: 1])?.getAt(0) } List getChildSubscriptions(def customerId, def subscriptionId, Map input = [:]) {