public void postComment(View view) { // Gets the date,user and other things from their classes and changes them to strings and makes // a new comment Dates date = new Dates(); User user = new User(); // Get the other parameters too EditText text = (EditText) findViewById(R.id.comment); String commentText = text.getText().toString(); String currDate = date.getDate(); String theUser = user.getUser(); // Initialize the comments class Comments newComment = new Comments(commentText, currDate, theUser); // How I believe to send the comments through an intent Gson gson = new Gson(); Intent intent = new Intent( this, BrowseComment.class); // Temporary location for now might have to put it in a controller String json = gson.toJson(newComment); intent.putExtra("Class", json); startActivity(intent); }
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; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { InvStage invStage = (InvStage) incomingRequest.get("invStage"); if (invStage == null) { invStage = new InvStage(); } if (incomingRequest.containsKey("InvStage_stageId")) { String stageId = (String) incomingRequest.get("InvStage_stageId"); invStage.setStageId(stageId); } if (incomingRequest.containsKey("InvStage_description")) { String description = (String) incomingRequest.get("InvStage_description"); invStage.setDescription(description); } if (incomingRequest.containsKey("InvStage_respons")) { String respons = (String) incomingRequest.get("InvStage_respons"); invStage.setRespons(respons); } if (incomingRequest.containsKey("InvStage_notes")) { String notes = (String) incomingRequest.get("InvStage_notes"); invStage.setNotes(notes); } if (incomingRequest.containsKey("InvStage_workCenterId")) { String workCenterId = (String) incomingRequest.get("InvStage_workCenterId"); invStage.setWorkCenterId(workCenterId); } if (incomingRequest.containsKey("InvStage_utilization")) { String utilizationString = (String) incomingRequest.get("InvStage_utilization"); if (Utility.isEmpty(utilizationString)) { utilizationString = "0"; } BigDecimal utilization = new BigDecimal(utilizationString); invStage.setUtilization(utilization); } if (incomingRequest.containsKey("InvStage_qtyDays")) { String qtyDaysString = (String) incomingRequest.get("InvStage_qtyDays"); if (Utility.isEmpty(qtyDaysString)) { qtyDaysString = "0"; } BigDecimal qtyDays = new BigDecimal(qtyDaysString); invStage.setQtyDays(qtyDays); } if (incomingRequest.containsKey("InvStage_setupHours")) { String setupHoursString = (String) incomingRequest.get("InvStage_setupHours"); if (Utility.isEmpty(setupHoursString)) { setupHoursString = "0"; } BigDecimal setupHours = new BigDecimal(setupHoursString); invStage.setSetupHours(setupHours); } if (incomingRequest.containsKey("InvStage_partsHour")) { String partsHourString = (String) incomingRequest.get("InvStage_partsHour"); if (Utility.isEmpty(partsHourString)) { partsHourString = "0"; } BigDecimal partsHour = new BigDecimal(partsHourString); invStage.setPartsHour(partsHour); } if (incomingRequest.containsKey("InvStage_timePart")) { String timePartString = (String) incomingRequest.get("InvStage_timePart"); if (Utility.isEmpty(timePartString)) { timePartString = "0"; } BigDecimal timePart = new BigDecimal(timePartString); invStage.setTimePart(timePart); } if (incomingRequest.containsKey("InvStage_vendorName")) { String vendorName = (String) incomingRequest.get("InvStage_vendorName"); invStage.setVendorName(vendorName); } if (incomingRequest.containsKey("InvStage_leadTime")) { String leadTimeString = (String) incomingRequest.get("InvStage_leadTime"); if (Utility.isEmpty(leadTimeString)) { leadTimeString = "0"; } BigDecimal leadTime = new BigDecimal(leadTimeString); invStage.setLeadTime(leadTime); } if (incomingRequest.containsKey("InvStage_outside")) { String outside = (String) incomingRequest.get("InvStage_outside"); invStage.setOutside(outside); } if (incomingRequest.containsKey("InvStage_descriptor")) { String descriptor = (String) incomingRequest.get("InvStage_descriptor"); invStage.setDescriptor(descriptor); } if (incomingRequest.containsKey("InvStage_machineId")) { String machineId = (String) incomingRequest.get("InvStage_machineId"); invStage.setMachineId(machineId); } if (incomingRequest.containsKey("InvStage_backflush")) { String backflush = (String) incomingRequest.get("InvStage_backflush"); invStage.setBackflush(backflush); } if (incomingRequest.containsKey("InvStage_persons")) { String personsString = (String) incomingRequest.get("InvStage_persons"); if (Utility.isEmpty(personsString)) { personsString = "0"; } BigDecimal persons = new BigDecimal(personsString); invStage.setPersons(persons); } if (incomingRequest.containsKey("InvStage_ccost")) { String ccostString = (String) incomingRequest.get("InvStage_ccost"); if (Utility.isEmpty(ccostString)) { ccostString = "0"; } BigDecimal ccost = new BigDecimal(ccostString); invStage.setCcost(ccost); } if (incomingRequest.containsKey("InvStage_unitOfMeasure")) { String unitOfMeasure = (String) incomingRequest.get("InvStage_unitOfMeasure"); invStage.setUnitOfMeasure(unitOfMeasure); } if (incomingRequest.containsKey("InvStage_dateEntered")) { String dateEnteredString = (String) incomingRequest.get("InvStage_dateEntered"); Date dateEntered = Dates.getDate(dateEnteredString); invStage.setDateEntered(dateEntered); } if (incomingRequest.containsKey("InvStage_dateExpires")) { String dateExpiresString = (String) incomingRequest.get("InvStage_dateExpires"); Date dateExpires = Dates.getDate(dateExpiresString); invStage.setDateExpires(dateExpires); } if (incomingRequest.containsKey("InvStage_owner")) { String owner = (String) incomingRequest.get("InvStage_owner"); invStage.setOwner(owner); } if (incomingRequest.containsKey("InvStage_status")) { String status = (String) incomingRequest.get("InvStage_status"); invStage.setStatus(status); } result = invStage; this.status = Status.SUCCEEDED; } catch (Exception e) { this.status = Status.FAILED; throw e; } return result; }
public Object executeTask(Object object) throws Exception { Map incomingRequest = (Map) object; Object result = null; try { BomMethod bomMethod = (BomMethod) incomingRequest.get("bomMethod"); if (bomMethod == null) { bomMethod = new BomMethod(); } if (incomingRequest.containsKey("BomMethod_icMethod")) { String icMethodString = (String) incomingRequest.get("BomMethod_icMethod"); if (Utility.isEmpty(icMethodString)) { icMethodString = "0"; } BigDecimal icMethod = new BigDecimal(icMethodString); bomMethod.setIcMethod(icMethod); } if (incomingRequest.containsKey("BomMethod_parentItem")) { String parentItem = (String) incomingRequest.get("BomMethod_parentItem"); bomMethod.setParentItem(parentItem); } if (incomingRequest.containsKey("BomMethod_componentItem")) { String componentItem = (String) incomingRequest.get("BomMethod_componentItem"); bomMethod.setComponentItem(componentItem); } if (incomingRequest.containsKey("BomMethod_methodId")) { String methodId = (String) incomingRequest.get("BomMethod_methodId"); bomMethod.setMethodId(methodId); } if (incomingRequest.containsKey("BomMethod_batchSize")) { String batchSizeString = (String) incomingRequest.get("BomMethod_batchSize"); if (Utility.isEmpty(batchSizeString)) { batchSizeString = "0"; } BigDecimal batchSize = new BigDecimal(batchSizeString); bomMethod.setBatchSize(batchSize); } if (incomingRequest.containsKey("BomMethod_unitOfMeasure")) { String unitOfMeasure = (String) incomingRequest.get("BomMethod_unitOfMeasure"); bomMethod.setUnitOfMeasure(unitOfMeasure); } if (incomingRequest.containsKey("BomMethod_description")) { String description = (String) incomingRequest.get("BomMethod_description"); bomMethod.setDescription(description); } if (incomingRequest.containsKey("BomMethod_notes")) { String notes = (String) incomingRequest.get("BomMethod_notes"); bomMethod.setNotes(notes); } if (incomingRequest.containsKey("BomMethod_dateEntered")) { String dateEnteredString = (String) incomingRequest.get("BomMethod_dateEntered"); Date dateEntered = Dates.getDate(dateEnteredString); bomMethod.setDateEntered(dateEntered); } if (incomingRequest.containsKey("BomMethod_owner")) { String owner = (String) incomingRequest.get("BomMethod_owner"); bomMethod.setOwner(owner); } result = bomMethod; this.status = Status.SUCCEEDED; } catch (Exception e) { this.status = Status.FAILED; throw e; } return result; }