public BuyerPieChart[] getBuyerPieChart() { ServiceManager serviceManager = new ServiceManager(); BuyerPieChart[] buyerPieChartArray = null; // String jsonArrayAsString = // serviceManager.invokeREAD(RestURIs.getBuyerDashboardURI("57","JAN-15","82","BUYER_PIE_CHART")); String periodParam = null; String operatingUnit = null; Connection conn = null; Statement stmt = null; try { conn = ConnectionFactory.getConnection(); stmt = conn.createStatement(); ResultSet result = stmt.executeQuery( "SELECT SAVED.DASHBOARD_TYPE , SAVED.PARAM_NAME ,SAVED.PARAM_VALUE FROM DASHBOARD_PARAMS SAVED WHERE SAVED.DASHBOARD_TYPE='BUYERS'"); while (result.next()) { String paramName = result.getString("PARAM_NAME"); String paramValue = result.getString("PARAM_VALUE"); if (paramName.equals("CURRENT_PERIOD".toString())) { periodParam = paramValue; } else if (paramName.equals("OPERATING_UNIT".toString())) { operatingUnit = paramValue; } } } catch (Exception e) { periodParam = "JAN-15"; operatingUnit = "82"; } /* Call web Service */ String jsonArrayAsString = serviceManager.invokeREAD( RestURIs.getBuyerDashboardURI("59", periodParam, operatingUnit, "BUYER_PIE_CHART")); try { JSONObject jsonObject = new JSONObject(jsonArrayAsString); JSONObject parent = jsonObject.getJSONObject("X_BUYER_PIE_CHART_TAB"); JSONArray nodeArray = parent.getJSONArray("X_BUYER_PIE_CHART_TAB_ITEM"); // System.out.println(parent); buyerPieChartList.clear(); int size = nodeArray.length(); for (int i = 0; i < size; i++) { JSONObject temp = nodeArray.getJSONObject(i); String buyerName = temp.getString("BUYER_NAME"); BigDecimal buyerPoolPercent = new BigDecimal(temp.getString("BUYER_POOOL_PERCENT")); BigDecimal poAwaitingApprovalPercent = new BigDecimal(temp.getString("PO_AWAITING_APPROVAL_PERCENT")); BigDecimal poAwaitingShippingPercent = new BigDecimal(temp.getString("PO_AWAITING_SHIPPING_PERCENT")); BigDecimal poIncompletePercent = new BigDecimal(temp.getString("PO_INCOMPLETE_PERCENT")); BigDecimal recordId = new BigDecimal(temp.getString("RECORD_ID")); BuyerPieChart buyerPieChart1 = new BuyerPieChart(buyerName, "Buyer Pool Percent", buyerPoolPercent, recordId); buyerPieChartList.add(buyerPieChart1); BuyerPieChart buyerPieChart2 = new BuyerPieChart( buyerName, "PO Awaiting Approval Percent", poAwaitingApprovalPercent, recordId); buyerPieChartList.add(buyerPieChart2); BuyerPieChart buyerPieChart3 = new BuyerPieChart( buyerName, "PO Awaiting Shipping Percent", poAwaitingShippingPercent, recordId); buyerPieChartList.add(buyerPieChart3); BuyerPieChart buyerPieChart4 = new BuyerPieChart(buyerName, "PO Incomplete Percent", poIncompletePercent, recordId); buyerPieChartList.add(buyerPieChart4); } buyerPieChartArray = buyerPieChartList.toArray(new BuyerPieChart[buyerPieChartList.size()]); } catch (Exception e) { e.getMessage(); System.out.println(e.getMessage()); } return buyerPieChartArray; }
public InvResourceAvailReport[] getInvResourceAvailReport() { ServiceManager serviceManager = new ServiceManager(); InvResourceAvailReport[] InvResourceAvailReportArray = null; /* String resourceGrpFrom = AdfmfJavaUtilities.getELValue("#{pageFlowScope.jobFrom}").toString(); String resourceGrpTo = AdfmfJavaUtilities.getELValue("#{pageFlowScope.jobTo}").toString(); String resourceFrom = AdfmfJavaUtilities.getELValue("#{pageFlowScope.assemblyFrom}").toString(); String resourceTo = AdfmfJavaUtilities.getELValue("#{pageFlowScope.assemblyTo}").toString(); String projectName = AdfmfJavaUtilities.getELValue("#{pageFlowScope.jobStatus}").toString(); String onDate = AdfmfJavaUtilities.getELValue("#{pageFlowScope.dateFrom}").toString(); String timeFrame = AdfmfJavaUtilities.getELValue("#{pageFlowScope.dateTo}").toString(); */ String resourceGrpFrom = AdfmfJavaUtilities.getELValue("#{pageFlowScope.resourceGrp}").toString(); String resourceGrpTo = AdfmfJavaUtilities.getELValue("#{pageFlowScope.resourceGrpTo}").toString(); String resourceFrom = AdfmfJavaUtilities.getELValue("#{pageFlowScope.resource}").toString(); String resourceTo = AdfmfJavaUtilities.getELValue("#{pageFlowScope.resourceTo}").toString(); String projectName = AdfmfJavaUtilities.getELValue("#{pageFlowScope.projectName}").toString(); String onDate = "-999"; String timeFrame = "-999"; String jsonArrayAsString = serviceManager.invokeREAD( RestURIs.getResourceAvailReportURI( resourceGrpFrom, resourceGrpTo, resourceFrom, resourceTo, projectName, onDate, timeFrame)); // System.out.println(jsonArrayAsString); try { JSONObject jsonObject = new JSONObject(jsonArrayAsString); JSONObject parent = jsonObject.getJSONObject("X_RESOURCE_AVAIL_TAB"); JSONArray nodeArray = parent.getJSONArray("X_RESOURCE_AVAIL_TAB_ITEM"); // System.out.println(parent); int size = nodeArray.length(); for (int i = 0; i < size; i++) { JSONObject temp = nodeArray.getJSONObject(i); String resourceName = temp.getString("RESOURCE_NAME"); BigDecimal perUtilization = new BigDecimal(temp.getString("PER_UTILIZATION")); InvResourceAvailReport InvResourceAvail = new InvResourceAvailReport(resourceName, perUtilization); InvResourceAvailReportList.add(InvResourceAvail); } InvResourceAvailReportArray = InvResourceAvailReportList.toArray( new InvResourceAvailReport[InvResourceAvailReportList.size()]); } catch (Exception e) { e.getMessage(); System.out.println(e.getMessage()); } return InvResourceAvailReportArray; }