public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icCodeString = (String) incomingRequest.get("InvBinLocHistory_icCode"); BigDecimal icCode = new BigDecimal(icCodeString); String queryString = "from InvBinLocHistory as InvBinLocHistory where InvBinLocHistory.id.icCode = ? "; List resultList = dbs.query( queryString, new Object[] { icCode, }, new Type[] {Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { if (incomingRequest.containsKey("RfqNote_icHeader") && incomingRequest.containsKey("RfqNote_icLine")) { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icHeader = (String) incomingRequest.get("RfqNote_icHeader"); String icLine = (String) incomingRequest.get("RfqNote_icLine"); StringBuffer queryString = new StringBuffer( "from RfqNote as rfqnote where rfqnote.id.icHeader = '" + icHeader + "' and rfqnote.id.icLine = '" + icLine + "'"); result = dbs.query(queryString.toString()); this.setStatus(dbs.getStatus()); } else { throw new Exception("The value for RfqNote_icHeader and RfqNote_icLine must be set."); } } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icRecHeaderString = (String) incomingRequest.get("InspectionMte_icRecHeader"); BigDecimal icRecHeader = new BigDecimal(icRecHeaderString); String icRecLineString = (String) incomingRequest.get("InspectionMte_icRecLine"); BigDecimal icRecLine = new BigDecimal(icRecLineString); String keySequenceString = (String) incomingRequest.get("InspectionMte_keySequence"); BigDecimal keySequence = new BigDecimal(keySequenceString); String queryString = "from InspectionMte as InspectionMte where InspectionMte.id.icRecHeader = ? and InspectionMte.id.icRecLine = ? and InspectionMte.id.keySequence = ? "; List resultList = dbs.query( queryString, new Object[] { icRecHeader, icRecLine, keySequence, }, new Type[] {Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icHeaderHistoryString = (String) incomingRequest.get("InvItem_icHeaderHistory"); BigDecimal icHeaderHistory = new BigDecimal(0); if (!HiltonUtility.isEmpty(icHeaderHistoryString)) { icHeaderHistory = new BigDecimal(icHeaderHistoryString); } String queryString = "from InvItem as InvItem where InvItem.icHeaderHistory = ? "; List resultList = dbs.query( queryString, new Object[] {icHeaderHistory}, new Type[] {Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; List result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String itemNumber = (String) incomingRequest.get("InvFormProduct_itemNumber"); if (Utility.isEmpty(itemNumber)) { throw new Exception( "InvFormProduct_itemNumber cannot be empty. InvFormProduct could not be retrieved."); } String queryString = "from InvFormProduct as InvFormProduct where InvFormProduct.id.itemNumber = ? "; result = dbs.query( queryString, new Object[] { itemNumber, }, new Type[] {Hibernate.STRING}); this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String id = (String) incomingRequest.get("BomRouting_stageId"); String seq = "01"; if (incomingRequest.containsKey("BomRouting_icMethod")) { BigDecimal icMethod = new BigDecimal((String) incomingRequest.get("BomRouting_icMethod")); String sql = "Select MAX(bomRouting.stageId) from BomRouting as bomRouting " + "Where bomRouting.icMethod = ?"; List resultList = dbs.query(sql, new Object[] {icMethod}, new Type[] {Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { if (resultList.get(0) != null) { seq = resultList.get(0).toString().substring(0, 2); seq = Integer.toString(Integer.parseInt(seq) + 1); if (seq.length() < 2) seq = "0" + seq; } } else { seq = "01"; } id = seq + "-" + id; } this.setStatus(dbs.getStatus()); return id; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icHeader = (String) incomingRequest.get("ShipTo_icHeader"); String icLine = (String) incomingRequest.get("ShipTo_icLine"); if (icLine == null) { icLine = "0"; } String queryString = "from ShipTo as s where s.id.icHeader = ? AND s.id.icLine = ?"; BigDecimal bdHeader = new BigDecimal(icHeader); BigDecimal bdLine = new BigDecimal(icLine); List result = dbs.query( queryString, new Object[] {bdHeader, bdLine}, new Type[] {Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL}); this.setStatus(dbs.getStatus()); return result; }
/** * Method executeTask. * * @param object * <p>incomingRequest */ public Object executeTask(Object object) throws Exception { Object ret = null; try { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String AssetCost_tagNumber = (String) incomingRequest.get("AssetCost_tagNumber"); if (Utility.isEmpty(AssetCost_tagNumber)) { AssetCost_tagNumber = (String) incomingRequest.get("Asset_tagNumber"); } String sql = "Select MAX(AssetCost.id.sequenceNo) from AssetCost AssetCost Where AssetCost.id.tagNumber = ?"; List resultList = dbs.query(sql, new Object[] {AssetCost_tagNumber}, new Type[] {Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { ret = resultList.get(0); if (ret == null) { ret = new BigDecimal(0); } } else { ret = new BigDecimal(0); } this.setStatus(Status.SUCCEEDED); } catch (Exception e) { this.setStatus(Status.FAILED); throw new TsaException(this.getName(), e); } return ret; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { // Always use host database configuration for this table DBSession dbs = new DBSession("host"); String mailId = (String) incomingRequest.get("HostUser_mailId"); mailId = Utility.ckNull(mailId).toLowerCase(); String queryString = "from HostUser as HostUser where HostUser.mailId = ? "; List resultList = dbs.query( queryString, new Object[] { mailId, }, new Type[] {Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); dbs.close(); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icRfqHeaderString = (String) incomingRequest.get("RfqVendor_icRfqHeader"); BigDecimal icRfqHeader = new BigDecimal(icRfqHeaderString); String vendorId = (String) incomingRequest.get("RfqVendor_vendorId"); String queryString = "from RfqVendor as rfqVendor where rfqVendor.id.icRfqHeader = ? and rfqVendor.id.vendorId = ?"; List resultList = dbs.query( queryString, new Object[] { icRfqHeader, vendorId, }, new Type[] {Hibernate.BIG_DECIMAL, Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); PoHeader poHeader = (PoHeader) incomingRequest.get("poHeader"); if (poHeader != null) { String queryString = "from InvoiceHeader as InvoiceHeader where InvoiceHeader.icPoHeader = ? and InvoiceHeader.invoiceNumber<>'N/A' order by InvoiceHeader.invoiceDate"; List resultList = dbs.query( queryString, new Object[] {poHeader.getIcPoHeader()}, new Type[] {Hibernate.BIG_DECIMAL}); result = resultList; } else { Log.error( this, "IcPoHeader was empty. InvoiceHeaderRetrieveByOrder could not be executed."); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icHeader = (String) incomingRequest.get("RfqLine_icRfqHeader"); // String lineNumber = (String) incomingRequest.get("RfqLine_rfqLine"); String lineNumber = (String) incomingRequest.get("lineToRetrieve"); BigDecimal bdHeader = new BigDecimal(icHeader); BigDecimal bdNumber = new BigDecimal(lineNumber); String queryString = "select b from RfqLine as b where b.icRfqHeader = ? AND b.rfqLine = ?"; List resultList = dbs.query( queryString, new Object[] {bdHeader, bdNumber}, new Type[] {Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); return result; }
public Object executeTask(Object object) throws Exception { StringBuffer query = new StringBuffer(); Object result = null; Map incomingRequest = (Map) object; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); BrowseObject b = (BrowseObject) incomingRequest.get("browseObject"); String organizationId = (String) incomingRequest.get("organizationId"); String userTimeZone = (String) incomingRequest.get("userTimeZone"); String userDateFormat = (String) incomingRequest.get("userDateFormat"); String sqlWhere = (String) incomingRequest.get("sqlWhere"); List dateArguments = new ArrayList(); if (Utility.isEmpty(userDateFormat)) { userDateFormat = PropertiesManager.getInstance(organizationId) .getProperty("MISC", "DATEFORMAT", "MM-dd-yyyy"); } sqlWhere = ReportDates.dateWhereClauseDecoder( sqlWhere, dateArguments, organizationId, userTimeZone, userDateFormat); if (Utility.isEmpty(sqlWhere)) { sqlWhere = ""; } String sqlSelect = b.getSqlSelect(); query.append(sqlSelect); query.append(" from " + b.getSqlFrom()); query.append(" " + sqlWhere); Log.debug(this, incomingRequest.get("userId") + " - query: " + query.toString()); long start = System.currentTimeMillis(); System.out.println("Report Query: " + query.toString()); List list = dbs.query(query.toString(), dateArguments.toArray(), b.getMaxRows()); long end = System.currentTimeMillis(); Log.error( this, "It took " + ((end - start) / 1000) + " seconds to execute the query: " + query.toString()); Log.debug(this, incomingRequest.get("userId") + " - dbs.query COMPLETE."); result = list; this.setStatus(dbs.getStatus()); } catch (Exception e) { incomingRequest.put("failed", Boolean.TRUE); Log.error( this, "Error executing Report Query: " + query.toString() + " -Exception: " + e.getMessage()); e.printStackTrace(); this.setStatus(Status.FAILED); } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object ret = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icRfqHeader = (String) incomingRequest.get("RfqVendor_icRfqHeader"); if (icRfqHeader == null) { icRfqHeader = (String) incomingRequest.get("RfqHeader_icRfqHeader"); } StringBuffer queryString = new StringBuffer( "from RfqVendor as rfqvendor where rfqvendor.id.icRfqHeader = " + icRfqHeader + " AND rfqvendor.id.vendorId IN (SELECT RfqLine.vendorAwarded FROM RfqLine RfqLine WHERE RfqLine.icRfqHeader = " + icRfqHeader + ")"); queryString.append(" order by rfqvendor.id.vendorId ASC"); List result = dbs.query(queryString.toString()); ret = result; this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw new TsaException("Awarded Vendors List couls not be retrieved. " + e.getMessage(), e); } return ret; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String department = (String) incomingRequest.get("RequisitionHeader_departmentCode"); String queryString = "from DepartmentBuyer as d where d.id.departmentCode = ? "; List resultList = dbs.query(queryString, new Object[] {department}, new Type[] {Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String queryString = "from AssetService as assetService"; List result = dbs.query(queryString); this.setStatus(dbs.getStatus()); return result; }
public Object executeTask(Object object) throws Exception { Object result = null; Map incomingRequest = (Map) object; PoHeader poHeader = (PoHeader) incomingRequest.get("poHeader"); DBSession dbs = (DBSession) incomingRequest.get("dbsession"); BigDecimal icPoHeader = poHeader.getIcPoHeader(); String queryString = "select sum(invoiceLine.quantity) from InvoiceLine as invoiceLine where invoiceLine.icPoHeader= ? group by invoiceLine.lineNumber order by invoiceLine.lineNumber"; result = dbs.query(queryString, icPoHeader, Hibernate.BIG_DECIMAL); this.setStatus(dbs.getStatus()); return result; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; String section = "%DEFAULTS"; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String queryString = "from Property as prop where prop.id.section like ?"; List result = dbs.query(queryString, section, Hibernate.STRING); // List result = dbs.query(queryString) ; this.setStatus(dbs.getStatus()); return result; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String queryString = "from HistoryLog as hst where hst.icHeaderHistory = ? and (hst.doctype like '%H' or hst.doctype = 'REQ') order by hst.icHistory ASC"; String icHeaderHistory = (String) incomingRequest.get("HistoryLog_icHeaderHistory"); BigDecimal bdHeaderHistory = new BigDecimal(icHeaderHistory); List result = dbs.query(queryString, new Object[] {bdHeaderHistory}, new Type[] {Hibernate.BIG_DECIMAL}); this.setStatus(dbs.getStatus()); return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; List resultList = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String budgetId = (String) incomingRequest.get("BudgetCenter_budgetId"); String queryString = "from BudgetCenter BudgetCenter where BudgetCenter.id = ? "; resultList = dbs.query(queryString, new Object[] {budgetId}, new Type[] {Hibernate.STRING}); this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return resultList; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); StringBuffer queryString = new StringBuffer("from RecentReceipt as recentreceipt where 1=1 "); if (incomingRequest.containsKey("RecentReceipt_receivedBy")) { String receivedBy = (String) incomingRequest.get("RecentReceipt_receivedBy"); queryString.append(" AND recentreceipt.id.receivedBy = '" + receivedBy + "'"); } if (incomingRequest.containsKey("RecentReceipt_icRecHeader")) { String icRecHeader = (String) incomingRequest.get("RecentReceipt_icRecHeader"); queryString.append(" AND recentreceipt.id.icRecHeader = '" + icRecHeader + "'"); } if (incomingRequest.containsKey("RecentReceipt_dateEntered")) { String dateEntered = (String) incomingRequest.get("RecentReceipt_dateEntered"); queryString.append(" AND recentreceipt.dateEntered = '" + dateEntered + "'"); } List result = dbs.query(queryString.toString()); this.setStatus(dbs.getStatus()); return result; }
/** * Method executeTask. * * @param object * <p>incomingRequest */ public Object executeTask(Object object) throws Exception { Object ret = null; try { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String vendorId = (String) incomingRequest.get("Contact_vendorId"); String queryString = "from Contact as Contact where Contact.id.vendorId = ? order by Contact.id.contactType DESC, Contact.id.contactCode ASC"; List resultList = dbs.query(queryString, new Object[] {vendorId}, new Type[] {Hibernate.STRING}); ret = resultList; this.setStatus(dbs.getStatus()); } catch (Exception e) { Log.error(this, e.toString()); this.setStatus(Status.FAILED); } return ret; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icRecLineString = (String) incomingRequest.get("InspectionHeader_icRecLine"); if (icRecLineString == null) icRecLineString = (String) incomingRequest.get("ReceiptLine_icRecLine"); if (icRecLineString == null) icRecLineString = "0"; BigDecimal icRecLine = new BigDecimal(icRecLineString); String queryString = "from InspectionHeader as InspectionHeader where InspectionHeader.icRecLine = ? "; List resultList = dbs.query( queryString, new Object[] { icRecLine, }, new Type[] {Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { for (int i = 0; i < resultList.size(); i++) { InspectionHeader inh = (InspectionHeader) resultList.get(i); if (inh.getInspectType().startsWith("R")) { result = resultList.get(i); break; } } if (result == null) result = resultList.get(0); } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; List result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String icLineKeyString = (String) incomingRequest.get("Asset_icLineKey"); BigDecimal icLineKey = new BigDecimal(icLineKeyString); String queryString = "from Asset Asset where Asset.icLineKey = ? "; List resultList = dbs.query(queryString, new Object[] {icLineKey}, new Type[] {Hibernate.BIG_DECIMAL}); if (resultList != null && resultList.size() > 0) { result = resultList; } this.setStatus(dbs.getStatus()); } catch (Exception e) { this.setStatus(Status.FAILED); throw e; } return result; }
public Object executeTask(Object object) throws Exception { List result; try { Map incomingRequest = (Map) object; DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String o = (String) incomingRequest.get("organizationId"); String userId = (String) incomingRequest.get("userId"); String userDateFormat = (String) incomingRequest.get("userDateFormat"); BrowseObject b = (BrowseObject) incomingRequest.get("browseObject"); List groupFilters = b.getGroupFilters(); List groupFilterOptions = new ArrayList(); List commodities = new ArrayList(); // boolean unspscCommodities = PropertiesManager.getInstance(o).getProperty("MISC", // "CommodityType", "").equalsIgnoreCase("UNSPSC"); boolean unspscCommodities = false; boolean commoditySet = false; PropertiesManager propertiesManager = PropertiesManager.getInstance(o); if (Utility.isEmpty(userDateFormat)) { userDateFormat = propertiesManager.getProperty("MISC", "DateFormat", "MM-dd-yyyy"); } for (int ix = 0; ix < groupFilters.size(); ix++) { BrowseGroupFilter gf = (BrowseGroupFilter) groupFilters.get(ix); StringBuffer query = new StringBuffer(); StringBuffer queryFilter = new StringBuffer(); if (!Utility.isEmpty(gf.getType()) && gf.getType().equals("CostRange")) { incomingRequest.put("CostRange_itemType", incomingRequest.get("as_item_type")); } List dateArguments = new ArrayList(); if (Utility.isEmpty(gf.getType()) || !gf.getType().equals("Keywords")) { query.append(gf.getSqlSelect() + " from " + gf.getSqlFrom() + " where 1 = 1"); if (Utility.ckNull(gf.getSqlWhere()).length() > 0) { query.append(" and ( " + gf.getSqlWhere() + ")"); } if (Utility.ckNull(b.getSqlWhere()).length() > 0) { String sqlWhere = b.getSqlWhere(); sqlWhere = sqlWhere.replaceAll(":as_userid", "'" + userId + "'"); if (sqlWhere.indexOf(":as_today") > 0) { dateArguments.add( Dates.getDate( Dates.today(userDateFormat, (String) incomingRequest.get("userTimeZone")))); } sqlWhere = sqlWhere.replaceAll(":as_today", "?"); query.append(" and ( " + sqlWhere + ")"); } List filters = b.getBrowseFilters(); if (filters != null) { for (int i = 0; i < filters.size(); i++) { BrowseFilter filter = (BrowseFilter) filters.get(i); String key = filter.getColumnName(); if (!b.validateColumn(key)) { // skip this filter continue; } String value = encoder.encodeForSQL(new OracleCodec(), filter.getValue()); String operator = filter.getOperator(); String logicalOperator = filter.getLogicalOperator(); if (!BrowseValidationUtility.permissibleOperators.contains(operator)) { operator = "="; } if (!BrowseValidationUtility.permissibleLogicalOperators.contains(logicalOperator)) { logicalOperator = "AND"; } String type = filter.getType(); if (!Utility.isEmpty(value)) { if (Utility.isEmpty(operator)) { operator = "="; } if (Utility.isEmpty(logicalOperator)) { logicalOperator = "AND"; } if (Utility.isEmpty(type)) { type = "STRING"; } if (queryFilter.length() > 0) { queryFilter.append(" " + logicalOperator + " "); } if (type.equalsIgnoreCase("DATE")) { dateArguments.add(Dates.getDate(userDateFormat, value)); queryFilter.append(" " + key + " " + operator + " ?"); } else if (operator.equalsIgnoreCase("LIKE")) { queryFilter.append(" UPPER(" + key + ") " + operator + " '" + value + "'"); } else { queryFilter.append(" " + key + " " + operator + " '" + value + "'"); } if (key.indexOf(".commodity") > 0) { if (!Utility.isEmpty(value)) { commoditySet = true; if (value.indexOf("%") > 0) { String commodity = "00000000"; for (int iv = 0; iv < value.length(); iv++) { char temp = value.charAt(iv); if (temp != '%') { if (iv == 0) { commodity = temp + commodity.substring(iv + 1); } else if (commodity.length() >= (iv + 1)) { commodity = commodity.substring(0, iv) + temp + commodity.substring(iv + 1); } else { commodity = commodity.substring(0, iv) + temp; } } } if (!commodities.contains(commodity)) { commodities.add(commodity); } } } } } } } if (queryFilter.length() > 0) { query.append("AND (" + queryFilter + " )"); } if (gf.getType().equalsIgnoreCase("Commodity") && unspscCommodities) { String originalQueryString = query.toString(); List commodityList = null; CommodityGetUNSPSCWhereClause commodityWhere = new CommodityGetUNSPSCWhereClause(); int attempts = 0; while ((commodityList == null || commodityList.size() == 0) && attempts <= 3) { query = new StringBuffer(originalQueryString); String commodityArray[] = new String[commodities.size()]; commodities.toArray(commodityArray); incomingRequest.put("Commodity_commodity", commodityArray); incomingRequest.put("retrieveAllCodes", "N"); if (attempts > 0) { incomingRequest.put("retrieveAllFamilies", "Y"); if (attempts > 1) { incomingRequest.put("retrieveAllGroups", "Y"); if (attempts > 2) { incomingRequest.put("retrieveAllCommodities", "Y"); } } } String unspscWhere = (String) commodityWhere.executeTask(incomingRequest); if (!Utility.isEmpty(unspscWhere)) { query.append(" AND (" + unspscWhere + ")"); } if (!Utility.isEmpty(gf.getSqlGroupBy())) { query.append(" group by " + gf.getSqlGroupBy()); } if (!Utility.isEmpty(gf.getSqlOrderBy())) { query.append(" order by " + gf.getSqlOrderBy()); } Log.debug(this, "group filter query: " + query.toString()); Object arguments[] = new Object[dateArguments.size()]; for (int i = 0; i < dateArguments.size(); i++) { arguments[i] = dateArguments.get(i); } commodityList = dbs.query(query.toString(), arguments); attempts++; } gf.setSelectionValues(commodityList); } else { if (!Utility.isEmpty(gf.getSqlGroupBy())) { query.append(" group by " + gf.getSqlGroupBy()); } if (!Utility.isEmpty(gf.getSqlOrderBy())) { query.append(" order by " + gf.getSqlOrderBy()); } Log.debug(this, "group filter query: " + query.toString()); Object arguments[] = new Object[dateArguments.size()]; for (int i = 0; i < dateArguments.size(); i++) { arguments[i] = dateArguments.get(i); } List list = dbs.query(query.toString(), arguments); gf.setSelectionValues(list); } } } result = groupFilters; this.setStatus(dbs.getStatus()); } catch (Exception e) { e.printStackTrace(); throw e; } return result; }
/* (non-Javadoc) * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object) */ public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { String organizationId = (String) incomingRequest.get("organizationId"); String userDateFormat = (String) incomingRequest.get("userDateFormat"); PropertiesManager propertiesManager = PropertiesManager.getInstance(organizationId); CatalogSecurity catalogSecurity = (CatalogSecurity) incomingRequest.get("catalogSecurity"); String isCatalog = HiltonUtility.ckNull((String) incomingRequest.get("isCatalog")); String catalogId = (String) catalogSecurity.getCatalogId(); String accesType = (String) catalogSecurity.getAccessType(); String accessId = (String) catalogSecurity.getAccessId(); if (HiltonUtility.isEmpty(userDateFormat)) { userDateFormat = propertiesManager.getProperty("MISC", "DateFormat", "MM-dd-yyyy"); } String today = Dates.today(userDateFormat, (String) incomingRequest.get("userTimeZone")); if (isCatalog.equalsIgnoreCase("V")) { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); String queryString = "from CatalogSecurity as cs " + "where cs.catalogId = ? and cs.itemNumber != '0' " + "and cs.accessType = ? "; List resultList = dbs.query( queryString, new Object[] {catalogId, accesType}, new Type[] {Hibernate.STRING, Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { for (int i = 0; i < resultList.size(); i++) { CatalogSecurity catalogItemSecurity = (CatalogSecurity) resultList.get(i); if (!accessId.equalsIgnoreCase(catalogItemSecurity.getAccessId())) { PuridiomProcessLoader processLoader = new PuridiomProcessLoader((String) incomingRequest.get("organizationId")); PuridiomProcess process = processLoader.loadProcess("catalogsecurity-add.xml"); Map updateParameters = new HashMap(); updateParameters.put("organizationId", organizationId); updateParameters.put("dbsession", incomingRequest.get("dbsession")); updateParameters.put( "CatalogSecurity_catalogId", (String) catalogSecurity.getCatalogId()); updateParameters.put( "CatalogSecurity_itemNumber", (String) catalogItemSecurity.getItemNumber()); updateParameters.put( "CatalogSecurity_accessType", (String) catalogSecurity.getAccessType()); updateParameters.put( "CatalogSecurity_accessId", (String) catalogSecurity.getAccessId()); updateParameters.put("CatalogSecurity_owner", (String) catalogSecurity.getOwner()); updateParameters.put("CatalogSecurity_dateEntered", today); updateParameters.put("CatalogSecurity_dateChanged", today); updateParameters.put( "CatalogSecurity_lastChangedBy", (String) catalogSecurity.getCatalogId()); process.executeProcess(updateParameters); catalogSecurity.setAccessId(accessId); dbs.add(catalogSecurity); if (dbs.getStatus() != Status.SUCCEEDED) { throw new TsaException( "error ocurred at update catalog security from for " + catalogSecurity.getItemNumber()); } } } } } this.setStatus(Status.SUCCEEDED); } catch (Exception e) { this.setStatus(Status.FAILED); Log.error(this, "An Error occurred at CatalogItemSecurityAddFromCatalog" + e); e.printStackTrace(); throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { DBSession dbs = (DBSession) incomingRequest.get("dbsession"); InvoiceHeader invoiceHeader = (InvoiceHeader) incomingRequest.get("invoiceHeader"); BigDecimal icIvcHeader = invoiceHeader.getIcIvcHeader(); String newStatus = invoiceHeader.getStatus(); String invoiceUser = invoiceHeader.getEnteredBy(); // String buyerUser = invoiceHeader.getAssignedBuyer() ; /*String reqTotal = "$" + requisitionHeader.getTotal().toString() ;*/ String invoiceTotal = HiltonUtility.getCurrency( invoiceHeader.getInvoiceTotal(), invoiceHeader.getCurrencyCode(), (String) incomingRequest.get("organizationId"), true); if (invoiceTotal.indexOf("yen") > 0) { invoiceTotal = invoiceTotal.replaceAll(";", ""); invoiceTotal = invoiceTotal.replaceAll("¥", "¥"); } String purpose = invoiceHeader.getInvoiceDesc(); String nextUser = ""; String queryString = "select UserProfile.mailId from ApprovalLog as ApprovalLog, UserProfile as UserProfile where ApprovalLog.id.userId = UserProfile.userId and ApprovalLog.id.icHeader = ? and ApprovalLog.id.userId <> ? "; List resultList = dbs.query( queryString, new Object[] {icIvcHeader, invoiceUser}, new Type[] {Hibernate.BIG_DECIMAL, Hibernate.STRING}); if (resultList != null && resultList.size() > 0) { for (int x = 0; x < resultList.size(); x++) { nextUser += (String) resultList.get(x) + "; "; } } this.setStatus(dbs.getStatus()); nextUser += UserManager.getInstance() .getUser((String) incomingRequest.get("organizationId"), invoiceUser) .getMailId(); if (invoiceHeader == null) { this.setStatus(Status.FAILED); throw new TsaException(this.getName() + " Invoice could not be recalled!"); } Log.debug( this, "Writting send_queue record for invoice: " + invoiceHeader.getInvoiceNumber() + ", status " + newStatus); if (newStatus.equals(DocumentStatus.IVC_RECALLED) && !Utility.isEmpty(nextUser)) { String owner = (String) incomingRequest.get("userId"); StringBuffer subject = new StringBuffer("Invoice "); subject.append(invoiceHeader.getInvoiceNumber()); subject.append(" recalled"); StringBuffer message = new StringBuffer("Invoice "); message.append(invoiceHeader.getInvoiceNumber()); message.append( " was recalled by " + UserManager.getInstance() .getUser((String) incomingRequest.get("organizationId"), owner) .getDisplayName()); message.append(" on " + Dates.today("") + "\n\n"); message.append( "Invoice Creator: " + UserManager.getInstance() .getUser((String) incomingRequest.get("organizationId"), invoiceUser) .getDisplayName() + "\n"); message.append("Invoice Total: " + invoiceTotal + "\n"); message.append("Description: " + purpose); incomingRequest.put("SendQueue_doctype", "IVC"); incomingRequest.put( "SendQueue_docic", (String) incomingRequest.get("InvoiceHeader_icIvcHeader")); incomingRequest.put("SendQueue_subject", subject.toString()); incomingRequest.put("SendQueue_messagetext", message.toString()); incomingRequest.put("SendQueue_owner", owner); incomingRequest.put("SendQueue_sendfromtype", "E"); incomingRequest.put( "SendQueue_sendfrom", UserManager.getInstance() .getUser((String) incomingRequest.get("organizationId"), owner) .getMailId()); incomingRequest.put("SendQueue_sendtotype", "E"); incomingRequest.put("SendQueue_sendto", nextUser); incomingRequest.put("SendQueue_action", EmailActionCodes.EMAIL); PuridiomProcessLoader processLoader = new PuridiomProcessLoader(); PuridiomProcess process = processLoader.loadProcess("sendqueue-add.xml"); process.executeProcess(incomingRequest); this.status = process.getStatus(); } else { this.setStatus(Status.SUCCEEDED); Log.debug( this, "No record will be written for this Invoice: " + invoiceHeader.getInvoiceNumber()); } } catch (Exception e) { this.setStatus(Status.FAILED); throw new TsaException("Invoice Approval Email couldn't be processed.", e); } return result; }