diff --git a/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/get.jag b/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/get.jag
index 5db314a32..eec03b14c 100755
--- a/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/get.jag
+++ b/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/get.jag
@@ -72,11 +72,13 @@ var getTasks = function (filterCategory,taskType) {
createdTime:time,
date:dueDate
});}else{
+ var log = new Log();
+ log.info("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
- var mod = jagg.module("manager");
- var storeHostObject = mod.getOperatorsHostObject(); //changed from get getstoreObj
+ var mod = jagg.module("manager");
+ var storeHostObject = mod.getOperatorsHostObject(); //changed from get getstoreObj
var appStatus = storeHostObject.getAppStatus(applicationIdVariable.value,operator.value);
-
+
if(appStatus == true){
task.push({
id:taskId,
@@ -89,7 +91,7 @@ var getTasks = function (filterCategory,taskType) {
});
}
}
-
+
}
@@ -412,7 +414,7 @@ function parseApplicationDetailsResponse(response, endpoint, taskId){
var tierAtt = tierAttribute[j];
var attName = tierAtt.*::tierAttributeName.text();
var attVal = tierAtt.*::tierAttributevalue.text();
-
+
if(attVal.length() == 0) {
attVal = tierAtt.*::tierAttributevalue.*;
}
@@ -520,7 +522,7 @@ function parseSubscriptionDetailsResponse(response, endpoint, taskId){
subscriptionDetails.taskId = task_id;
var SubscriptionApprovalData = new XML((response.*::taskData).toString());
-
+
var appId = SubscriptionApprovalData.*::applicationId.text();
var apiId = SubscriptionApprovalData.*::apiID.text();
var operatorId = SubscriptionApprovalData.*::operatorID.text();
@@ -534,7 +536,7 @@ function parseSubscriptionDetailsResponse(response, endpoint, taskId){
subscriptionDetails.applicationDescription = applicationDescription;
subscriptionDetails.subscriber = subscriber;
subscriptionDetails.apiNameVersion = apiName + " - " + apiVersion;
-
+
subscriptionDetails.appId = appId;
subscriptionDetails.apiId = apiId;
subscriptionDetails.operatorId = operatorId;
@@ -593,10 +595,27 @@ function getAllTiers(){
}
}
+function getOperators(){
+ var log = new Log();
+ var billing = jagg.module("manager").getCustomBilling();
+ var operators = [];
+ try {
+ log.info("# # # Operators List LOADING. . .");
+ operators = billing.getOperators();
+ log.info("# # # Operators List: " + stringify(operators));
+ return {error:false, data : operators};
+
+ } catch (e) {
+ log.error(e.message);
+ return { error:true,message:e.message};
+ }
+}
+
+
function getRatesList(apiName, opName){
var workflow, result;
workflow = jagg.module("manager").getWorkflowHostObject();
-
+
try {
result = workflow.getSubscriptionRatesForOperator(apiName, opName);
if (result == null) {
diff --git a/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/module.jag b/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/module.jag
index 9e1ec2eeb..cb7f207bb 100755
--- a/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/module.jag
+++ b/components/jaggery-apps/manage/src/main/manage/modules/taskmanager/module.jag
@@ -39,6 +39,9 @@ jagg.module("taskmanager", {
},
getRatesList:function () {
return jagg.require(jagg.getModulesDir() + "taskmanager/get.jag").getRatesList.apply(this, arguments);
- },
+ },
+ getOperators:function () {
+ return jagg.require(jagg.getModulesDir() + "taskmanager/get.jag").getOperators.apply(this, arguments);
+ }
});
%>
diff --git a/components/jaggery-apps/manage/src/main/manage/site/blocks/app-history/block.jag b/components/jaggery-apps/manage/src/main/manage/site/blocks/app-history/block.jag
index 54f70a25f..eebe7343e 100644
--- a/components/jaggery-apps/manage/src/main/manage/site/blocks/app-history/block.jag
+++ b/components/jaggery-apps/manage/src/main/manage/site/blocks/app-history/block.jag
@@ -1,45 +1,40 @@
<%
jagg.block("app-history", {
initializer:function (data) {
-
- } ,
+ },
getInputs:function () {
- return {
- "usage":null
- }
- } ,
-getOutputs:function (inputs) {
+ return {"usage":null}
+ },
+ getOutputs:function (inputs) {
var numberOfTasks, pageNumber, filterCategory,taskType, result, mod,tasks;
-
var data, user = inputs.user;
var operator ="%";
appid = request.getParameter("AppId");
-
var logedop = jagg.getUser().operator;
- log = new Log();
- log.info('############### OPERATOR : '+ logedop);
-
- mod = jagg.module("approvalaudit");
+ var log = new Log();
+
+ var module = jagg.module("taskmanager");
+ var result_operators = module.getOperators();
+ log.info('############### ALL OPERATORS : '+ stringify(result_operators.data));
+ mod = jagg.module("approvalaudit");
if (user.isAdmin) {
operator = "%";
- } else if (logedop.toUpperCase() == 'SENEGAL') {
- operator = "1";
} else if (logedop.toUpperCase() == 'IVORYCOAST') {
+ operator = "1";
+ } else if (logedop.toUpperCase() == 'SENEGAL') {
operator = "2";
}
-
- result = mod.getApprovalHistoryApp(appid,operator);
- if(result==null){
- tasks=null;
- }
- else{
- tasks = result;
- }
- return {
- "tasks":tasks
- }
- }
+ result = mod.getApprovalHistoryApp(appid,operator);
+ if(result==null){
+ tasks=null;
+ }else{
+ tasks = result;
+ }
+ return {
+ "tasks":tasks
+ }
+ }
});
%>
diff --git a/components/jaggery-apps/manage/src/main/manage/site/blocks/finance/block.jag b/components/jaggery-apps/manage/src/main/manage/site/blocks/finance/block.jag
index 8296d3a5c..8a70f5e97 100755
--- a/components/jaggery-apps/manage/src/main/manage/site/blocks/finance/block.jag
+++ b/components/jaggery-apps/manage/src/main/manage/site/blocks/finance/block.jag
@@ -3,14 +3,9 @@ jagg.block("finance", {
initializer:function (data) {
} ,
- // getInputs:function () {
- // return {
- // "usage":null
- // }
- // },
getOutputs:function (inputs) {
-
+
var data, user = inputs.user;
var isOperator = jagg.getUser().operator;
var data_subscribers;
@@ -27,14 +22,14 @@ jagg.block("finance", {
var financeReportModule = jagg.module("finance-report");
var result_operators = financeReportModule.getOperatorsBySubscriber(jagg.getUser().username);
var result_applications = financeReportModule.getAppsBySubscriber(jagg.getUser().username);
-
+
data_operators = result_operators.data;
data_applications = result_applications.data;
}else if(isOperator != null){
var financeReportModule = jagg.module("finance-report");
var result_applications = financeReportModule.getAppsByOperator(isOperator);
var result_subscribers = financeReportModule.getSubscribersByOperator(isOperator);
-
+
data_operators = isOperator;
data_subscribers = result_subscribers.data;
data_applications = result_applications.data;
diff --git a/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/js/tiers.js b/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/js/tiers.js
index 7deea98f7..137a440b9 100755
--- a/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/js/tiers.js
+++ b/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/js/tiers.js
@@ -14,7 +14,7 @@ function getLblText(lblInfo){
function getAllTiers(lblText){
var action = "getAllTiers";
-
+
jagg.post("/site/blocks/app-history/ajax/tier-details.jag", {
action : action,
lblText : lblText
@@ -35,4 +35,24 @@ function setTierDetailsToToolTip(tierAttributevalue){
$("#tierattribute_tooltip").html(tierAttributevalue);
}
+function getAllOperators(){
+ var action = "getAllOperators";
+
+ jagg.post("/site/blocks/app-history/ajax/tier-details.jag", {
+ action : action,
+ lblText : lblText
+ }, function(result) {
+ if (!result.error) {
+ if (result.data != null) {
+ setTierDetailsToToolTip(result.data);
+ } else {
+ jagg.showLogin();
+ }
+ } else {
+ jagg.showLogin();
+ }
+ }, "json");
+}
+
+
diff --git a/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/template.jag b/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/template.jag
index f538703fa..1371c6632 100755
--- a/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/template.jag
+++ b/components/jaggery-apps/manage/src/main/manage/site/themes/default/subthemes/dark/templates/app-history/template.jag
@@ -86,8 +86,6 @@
IVORYCOAST : |
<%} else if (opcoapps[i].operatorid==2) {%>
SENEGAL : |
-
-
<%}%>
<%=opcoapps[i].status%> |
@@ -177,8 +175,6 @@
<%if (opcosubs[j].operatorid==1) {%>
IVORYCOAST : |
<%} else if (opcosubs[j].operatorid==2) {%>
-
-
SENEGAL : |
<%}%>
diff --git a/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/BillingHostObject.java b/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/BillingHostObject.java
index 12191b7a6..550a3e938 100644
--- a/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/BillingHostObject.java
+++ b/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/BillingHostObject.java
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved.
- *
+ *
* WSO2.Telco Inc. licences this file to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,9 +20,12 @@
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
import javax.xml.stream.XMLStreamException;
+
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.commons.logging.Log;
@@ -42,6 +45,7 @@
import org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.apimgt.usage.client.dto.APIVersionUserUsageDTO;
+
import com.wso2telco.core.dbutils.exception.BusinessException;
import com.wso2telco.dep.reportingservice.dao.Approval;
import com.wso2telco.dep.reportingservice.dao.BillingDAO;
@@ -61,23 +65,23 @@ public class BillingHostObject extends ScriptableObject {
/** The Constant log. */
private static final Log log = LogFactory.getLog(BillingHostObject.class);
-
+
/** The hostobject name. */
private String hostobjectName = "BillingHostObject";
-
+
/** The api consumer. */
private APIConsumer apiConsumer;
-
+
/** The tier pricing. */
private static Map tierPricing = new HashMap();
-
+
/** The tier maximum count. */
private static Map tierMaximumCount = new HashMap();
-
+
/** The tier unit time. */
private static Map tierUnitTime = new HashMap();
-
-
+
+
/**
* Gets the tier pricing.
*
@@ -113,7 +117,7 @@ public static Map getTierUnitTime() {
public String getUsername() {
return username;
}
-
+
/** The username. */
private String username;
@@ -129,7 +133,7 @@ public String getClassName() {
* Instantiates a new billing host object.
*
* @param username the username
- * @throws BusinessException
+ * @throws BusinessException
* @throws APIManagementException the API management exception
*/
public BillingHostObject(String username) throws BusinessException{
@@ -185,12 +189,12 @@ private static APIConsumer getAPIConsumer(Scriptable thisObj) {
* @param args the args
* @param funObj the fun obj
* @return the string
- * @throws Exception
+ * @throws Exception
*/
public static String jsFunction_getReportFileContent(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws BusinessException {
- if (args == null || args.length == 0) {
+ if (args == null || args.length == 0) {
log.error("jsFunction_getReportFileContent null or empty arguments");
throw new BusinessException(ReportingServiceError.INPUT_ERROR);
}
@@ -198,7 +202,7 @@ public static String jsFunction_getReportFileContent(Context cx, Scriptable this
String subscriberName = (String) args[0];
String period = (String) args[1];
boolean isNorthbound = (Boolean) args[2];
-
+
try {
generateReport(subscriberName, period, true, isNorthbound, "__ALL__");
} catch (Exception e) {
@@ -219,7 +223,7 @@ public static String jsFunction_getReportFileContent(Context cx, Scriptable this
* @param funObj the fun obj
* @return the native array
* @throws APIManagementException the API management exception
- * @throws BusinessException
+ * @throws BusinessException
*/
public static NativeArray jsFunction_getCustomCareDataReport(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
@@ -274,8 +278,8 @@ public static String jsFunction_getCustomCareDataRecordsCount(Context cx, Script
String app = (String) args[5];
String api = (String) args[6];
- String dataString;
- dataString = getCustomCareDataRecordCount(fromDate, toDate, msisdn, subscriberName, operator, app, api);
+ String dataString;
+ dataString = getCustomCareDataRecordCount(fromDate, toDate, msisdn, subscriberName, operator, app, api);
return dataString;
}
@@ -366,7 +370,7 @@ public static NativeArray jsFunction_getAPIUsageforSubscriber(Context cx, Script
* @param args the args
* @param funObj the fun obj
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
public static NativeArray jsFunction_getCostPerAPI(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
@@ -463,7 +467,7 @@ public static NativeArray jsFunction_getCostPerAPI(Context cx, Scriptable thisOb
}
}
} catch (Exception e) {
-
+
log.error("jsFunction_getCostPerAPI",e);
throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
@@ -480,7 +484,7 @@ public static NativeArray jsFunction_getCostPerAPI(Context cx, Scriptable thisOb
apiPriceResponse.put(i, apiPriceResponse, row);
i++;
}
-
+
return apiPriceResponse;
}
@@ -493,7 +497,7 @@ public static NativeArray jsFunction_getCostPerAPI(Context cx, Scriptable thisOb
* @param isNorthbound the is northbound
* @param operatorName the operator name
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
private static NativeArray generateReport(String subscriberName, String period, boolean persistReport, boolean isNorthbound, String operatorName) throws BusinessException {
@@ -509,7 +513,7 @@ private static NativeArray generateReport(String subscriberName, String period,
NativeArray ret = null;
try {
ret = (isNorthbound) ? NbHostObjectUtils.generateReportofSubscriber(persistReport, subscriberName, period, rateCard) : SbHostObjectUtils.generateReportofSubscriber(persistReport, subscriberName, period, rateCard, operatorName);
- } catch (Exception e) {
+ } catch (Exception e) {
log.error("generateReport",e);
throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
@@ -538,14 +542,14 @@ private static NativeArray generateCustomApiTrafficReport(String fromDate, Strin
try {
ret = NbHostObjectUtils.generateCustomTrafficReport(true, fromDate, toDate, subscriberName, operator, api, isError, applicationId, timeOffset, resType);
} catch (Exception e) {
-
+
e.printStackTrace();
}
} else {
ret = SbHostObjectUtils.generateCustomTrafficReport(true, fromDate, toDate, subscriberName, operator, api, isError, applicationId, timeOffset, resType);
}
} catch (Exception e) {
- log.error("generateCustomApiTrafficReport",e);
+ log.error("generateCustomApiTrafficReport",e);
throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
return ret;
@@ -592,7 +596,7 @@ private static NativeArray getCustomCareDataReport(String fromDate, String toDat
* @param api the api
* @return the custom care data record count
* @throws APIManagementException the API management exception
- * @throws BusinessException
+ * @throws BusinessException
*/
private static String getCustomCareDataRecordCount(String fromDate, String toDate, String msisdn, String subscriberName, String operator, String app, String api) throws BusinessException {
@@ -665,7 +669,7 @@ public static NativeArray jsFunction_getResponseTimeData(Context cx, Scriptable
} catch (Exception e) {
log.error("Error occured getResponseTimeData ",e);
- throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
+ throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
log.info("End of getResponseTimeData");
return nativeArray;
@@ -797,6 +801,30 @@ public static NativeArray jsFunction_getAllOperators() throws BusinessException
return nativeArray;
}
+ public static NativeArray jsFunction_getOperators() throws BusinessException {
+ NativeArray nativeArray = new NativeArray(0);
+
+ try {
+ Map operators = SbHostObjectUtils.getOperators();
+ short i = 0;
+ if (operators != null) {
+ nativeArray = new NativeArray(0);
+ }
+ for (Map.Entry entry : operators.entrySet()) {
+ NativeObject row = new NativeObject();
+ row.put("operatorId", row, entry.getKey().toString());
+ row.put("operatorName", row, entry.getValue().toString());
+ nativeArray.put(i, nativeArray, row);
+ i++;
+ }
+
+ } catch (Exception e) {
+ log.error("Error occurred getOperators",e);
+ throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
+ }
+ return nativeArray;
+ }
+
/**
* Js function_get total api traffic for pie chart.
*
@@ -806,7 +834,7 @@ public static NativeArray jsFunction_getAllOperators() throws BusinessException
* @param funObj the fun obj
* @return the native array
* @throws APIManagementException the API management exception
- * @throws BusinessException
+ * @throws BusinessException
*/
public static NativeArray jsFunction_getTotalAPITrafficForPieChart(Context cx, Scriptable thisObj, Object[] args,
Function funObj) throws BusinessException {
@@ -974,7 +1002,7 @@ public static NativeArray jsFunction_getOperatorWiseAPITrafficForPieChart(Contex
* @param funObj the fun obj
* @return the native array
* @throws APIManagementException the API management exception
- * @throws BusinessException
+ * @throws BusinessException
*/
public static NativeArray jsFunction_getSubscribersByOperator(Context cx, Scriptable thisObj, Object[] args,
Function funObj) throws BusinessException {
@@ -1008,7 +1036,7 @@ public static NativeArray jsFunction_getSubscribersByOperator(Context cx, Script
* @param funObj the fun obj
* @return the native array
* @throws APIManagementException the API management exception
- * @throws BusinessException
+ * @throws BusinessException
*/
public static NativeArray jsFunction_getApplicationsBySubscriber(Context cx, Scriptable thisObj, Object[] args,
Function funObj) throws BusinessException {
@@ -1367,7 +1395,7 @@ public static NativeArray jsFunction_getErrorResponseCodesForHistogram(Context c
}
} catch (Exception e) {
log.error("Error occurred getErrorResponseCodesForHistogram",e);
- throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
+ throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
return nativeArray;
}
@@ -1483,7 +1511,7 @@ private static void handleException(String msg, Throwable t) throws APIManagemen
* @param args the args
* @param funObj the fun obj
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
@SuppressWarnings("null")
public static NativeArray jsFunction_getSPforBlacklist(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws BusinessException {
@@ -1492,17 +1520,17 @@ public static NativeArray jsFunction_getSPforBlacklist(Context cx, Scriptable th
}
String operator = String.valueOf(args[2]);
Boolean isadmin = Boolean.valueOf(String.valueOf(args[1]));
-
+
BillingDAO billingDAO = new BillingDAO();
-
+
List spList;
-
+
try {
spList = billingDAO.generateSPList();
} catch (Exception e) {
throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
}
-
+
List spListoperator = OperatorDAO.getSPList(operator);
NativeArray nativeArray = new NativeArray(0);
NativeObject nativeObject;
@@ -1526,7 +1554,7 @@ public static NativeArray jsFunction_getSPforBlacklist(Context cx, Scriptable th
i++;
}
}
-
+
return nativeArray;
}
@@ -1538,7 +1566,7 @@ public static NativeArray jsFunction_getSPforBlacklist(Context cx, Scriptable th
* @param args the args
* @param funObj the fun obj
* @return the native object
- * @throws Exception
+ * @throws Exception
*/
public static NativeObject jsFunction_getAppforBlacklist(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws BusinessException {
if (args == null || args.length == 0) {
@@ -1626,7 +1654,7 @@ public static NativeArray jsFunction_getDashboardAPITrafficForPieChart(Context c
return nativeArray;
}
-
+
/**
* Subtract time range.
*
@@ -1650,7 +1678,7 @@ private static String subtractTimeRange(Calendar date, String timeRange) {
return fromDate;
}
-
+
/**
* Gets the current time.
*
@@ -1661,7 +1689,7 @@ private static String getCurrentTime(Calendar date) {
return date.get(Calendar.YEAR) + "-" + (date.get(Calendar.MONTH) + 1) + "-" + date.get(Calendar.DATE);
}
-
+
/**
* Gets the time in milli.
*
@@ -1757,7 +1785,7 @@ public static NativeArray jsFunction_getDashboardAPITrafficForLineChart(Context
*/
public static NativeObject jsFunction_getDashboardAPIResponseTimeForLineChart(Context cx, Scriptable thisObj, Object[] args,
Function funObj) throws BusinessException {
-
+
NativeObject nativeObject = new NativeObject();
String timeRange = args[0].toString();
diff --git a/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/dao/OperatorDAO.java b/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/dao/OperatorDAO.java
index cd2b6de0f..b5822b6ee 100644
--- a/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/dao/OperatorDAO.java
+++ b/components/reporting-service/src/main/java/com/wso2telco/dep/reportingservice/dao/OperatorDAO.java
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2015-2016, WSO2.Telco Inc. (http://www.wso2telco.com) All Rights Reserved.
- *
+ *
* WSO2.Telco Inc. licences this file to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,17 +18,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException;
+
import com.wso2telco.core.dbutils.DbUtils;
import com.wso2telco.core.dbutils.util.DataSourceNames;
import com.wso2telco.dep.reportingservice.SPObject;
import com.wso2telco.dep.reportingservice.dao.Approval;
import com.wso2telco.dep.reportingservice.util.ReportingTable;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
// TODO: Auto-generated Javadoc
/**
@@ -68,7 +72,32 @@ public static List getAllOperators() throws APIMgtUsageQueryServiceClien
}
return op;
}
-
+
+ public static Map getOperators() throws APIMgtUsageQueryServiceClientException, SQLException {
+ Connection conn = null;
+ PreparedStatement ps = null;
+ ResultSet results = null;
+ String sql = "SELECT * FROM "+ ReportingTable.OPERATORS +"";
+ Map op = new HashMap();
+ try {
+ conn = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_DEP_DB);
+ ps = conn.prepareStatement(sql);
+ log.debug("getOperators");
+ results = ps.executeQuery();
+ while (results.next()) {
+ Integer id = results.getInt("ID");
+ String name = results.getString("operatorname");
+ op.put(id, name);
+ }
+ } catch (Exception e) {
+ log.error("Error occured while getting Operators from the database" + e);
+ } finally {
+ DbUtils.closeAllConnections(ps, conn, results);
+ }
+ return op;
+ }
+
+
/**
* Gets the applications by operator.
*
@@ -100,7 +129,7 @@ public static List getApplicationsByOperator(String operatorName) throw
}
return applicationIds;
}
-
+
/**
* Gets the operator names by application.
*
@@ -130,10 +159,10 @@ public static List getOperatorNamesByApplication(int applicationId) thro
} finally {
DbUtils.closeAllConnections(ps, conn, results);
}
-
+
return operatorNames;
}
-
+
/**
* Fill operator trace.
*
@@ -153,14 +182,14 @@ public static void fillOperatorTrace(int applicationId,String operatorId, List> getBillingSubscriptionsForUser(
String username, String year, String month)
@@ -177,7 +177,7 @@ public static Map> getBillingSubscriptions
* @return true, if is subscription valid for month
* @throws APIManagementException the API management exception
* @throws APIMgtUsageQueryServiceClientException the API mgt usage query service client exception
- * @throws BusinessException
+ * @throws BusinessException
*/
private static boolean isSubscriptionValidForMonth(SubscribedAPI subAPI,
String year, String month) throws BusinessException {
@@ -277,7 +277,7 @@ public static APIKey getKeyOfType(List apiKeys, String keyType) {
* @param rateCard the rate card
* @param year the year
* @param month the month
- * @throws Exception
+ * @throws Exception
*/
public static void applyChargingPlan(
Map> billingSubs,
@@ -328,7 +328,7 @@ public static void applyChargingPlan(
* @param appId the app id
* @param apiId the api id
* @param subsId the subs id
- * @throws Exception
+ * @throws Exception
*/
private static void billComponent(ChargeRate rate,
Map rateCard,
@@ -509,7 +509,7 @@ private static Object getRateSubcategory(ChargeRate rate,
*
* @param subscription the subscription
* @param rateCard the rate card
- * @throws Exception
+ * @throws Exception
*/
private static void calculateChargeForSubscription(
BillingSubscription subscription, Map rateCard)
@@ -568,7 +568,7 @@ private static void calculateChargeForSubscription(
* @param appId the app id
* @param apiId the api id
* @param subId the sub id
- * @throws Exception
+ * @throws Exception
*/
private static void applyChargesForPaymentApi(
BillingSubscription.OperatorSubscription opSubscription,
@@ -698,7 +698,7 @@ private static void applyChargesForPaymentApi(
// Get the percentage from the rate value
// apply category wise charge percentage
-
+
categoryEntry.getValue().addAdscom(totaladscom);
categoryEntry.getValue().addOpcom(totalopcom);
categoryEntry.getValue().addSpcom(totalspcom);
@@ -712,7 +712,7 @@ private static void applyChargesForPaymentApi(
* @param opSubscription the op subscription
* @param categoryCharge the category charge
* @param paymentRequestSet the payment request set
- * @throws Exception
+ * @throws Exception
*/
private static void applyPaymentChargesByCategory(
BillingSubscription.OperatorSubscription opSubscription,
@@ -768,7 +768,7 @@ private static void applyPaymentChargesByCategory(
* @param operatorSub the operator sub
* @param CatEntry the cat entry
* @param rate the rate
- * @throws Exception
+ * @throws Exception
*/
private static void applyChargesWithTax(String apiYear, String apiMonth,
Application application, String apiName, String apiVersion,
@@ -788,7 +788,7 @@ private static void applyChargesWithTax(String apiYear, String apiMonth,
Set requestTimes = new HashSet();
if (prodKey != null) {
String api_version = apiName + ":v" + apiVersion;
-
+
TaxDAO taxDAO = new TaxDAO();
requestTimes = taxDAO
.getAPIRequestTimesForSubscription(Short.parseShort(year),
@@ -820,7 +820,7 @@ private static void applyChargesWithTax(String apiYear, String apiMonth,
.getSurchargeElementOpco()).divide(new BigDecimal(100));
isSurcharge = true;
}
-
+
TaxDAO taxDAO = new TaxDAO();
List taxList = taxDAO.getTaxesForTaxList(rate
.getTaxList());
@@ -873,12 +873,12 @@ private static void applyChargesWithTax(String apiYear, String apiMonth,
* @param rate the rate
* @param year the year
* @param month the month
- * @throws Exception
+ * @throws Exception
*/
private static void applyTaxForBlockCharging(
Map.Entry CatEntry, ChargeRate rate,
String year, String month) throws Exception {
-
+
TaxDAO taxDAO = new TaxDAO();
List taxList = taxDAO.getTaxesForTaxList(rate
.getTaxList());
@@ -910,7 +910,7 @@ private static void applyTaxForBlockCharging(
* @param month the month
* @param rateCard the rate card
* @return the map
- * @throws Exception
+ * @throws Exception
*/
public static Map> chargeSubscriberForMonth(
String subscriber, String year, String month,
@@ -928,7 +928,7 @@ public static Map> chargeSubscriberForMont
*
* @param subscription the subscription
* @param rateCard the rate card
- * @throws Exception
+ * @throws Exception
*/
private static void populateOperatorDetailsOfSubscription(
BillingSubscription subscription, Map rateCard)
@@ -969,8 +969,8 @@ private static void populateOperatorDetailsOfSubscription(
* Populate category vise api counts.
*
* @param subscription the subscription
- * @throws Exception
- * @throws
+ * @throws Exception
+ * @throws
*/
private static void populateCategoryViseAPICounts(
BillingSubscription subscription) throws Exception {
@@ -1008,7 +1008,7 @@ private static void populateCategoryViseAPICounts(
*
* @param username the username
* @return the response times for subscriber
- * @throws Exception
+ * @throws Exception
*/
public static Map getResponseTimesForSubscriber(
String username) throws Exception {
@@ -1051,7 +1051,7 @@ public static Map getResponseTimesForSubscriber(
* @param fromDate the from date
* @param toDate the to date
* @return the all response times
- * @throws Exception
+ * @throws Exception
*/
public static Map> getAllResponseTimes(
String opName, String username, String application, String appId,
@@ -1276,7 +1276,7 @@ public static NativeArray generateCostperApisummary(
* @param endLimit the end limit
* @param timeOffset the time offset
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
public static NativeArray generateCustomrCareDataReport(
boolean isPersistReport, String fromDate, String toDate,
@@ -1315,7 +1315,7 @@ public static NativeArray generateCustomrCareDataReport(
* @param app the app
* @param api the api
* @return the string
- * @throws Exception
+ * @throws Exception
*/
public static String generateCustomrCareDataRecordCount(
boolean isPersistReport, String fromDate, String toDate,
@@ -1341,7 +1341,7 @@ public static String generateCustomrCareDataRecordCount(
* @param timeOffset the time offset
* @param resType the res type
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
public static NativeArray generateCustomTrafficReport(
boolean isPersistReport, String fromDate, String toDate,
@@ -1469,7 +1469,7 @@ public static NativeArray generateCustomTrafficReport(
* @param rateCard the rate card
* @param operatorName the operator name
* @return the native array
- * @throws Exception
+ * @throws Exception
*/
public static NativeArray generateReportofSubscriber(
boolean isPersistReport, String subscriberName, String period,
@@ -1487,7 +1487,7 @@ public static NativeArray generateReportofSubscriber(
if (isPersistReport) {
fileWriter = getReportLocation(subscriberName, period);
-
+
fileWriter
.write(String
.format("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s, %s, %s, %s, %s, %s %n",
@@ -1874,7 +1874,7 @@ public static NativeArray generateReportofSubscriber(
NativeArray subscriptionOperators = new NativeArray(0);
for (BillingSubscription.OperatorSubscription operatorSub : billingSubscription
.getOperatorSubscriptionList()) {
-
+
log.debug("operatorSub:" + operatorSub.toString());
if ((operatorName.equalsIgnoreCase("__All__"))
|| (operatorSub.getOperator()
@@ -1915,7 +1915,7 @@ public static NativeArray generateReportofSubscriber(
.put(subscriptionOperators.size(),
subscriptionOperators,
subscriptionOperator);
-
+
if (isPersistReport && fileWriter != null) {
String currencyStr = operatorSub.getRate()
.getCurrency() + " ";
@@ -2096,7 +2096,7 @@ public static boolean isUserAdminUser(String username) {
* Gets the all subscribers.
*
* @return the all subscribers
- * @throws Exception
+ * @throws Exception
*/
public static List getAllSubscribers() throws Exception {
BillingDAO billingDAO = new BillingDAO();
@@ -2110,7 +2110,7 @@ public static List getAllSubscribers() throws Exception {
* Gets the operation types.
*
* @return the operation types
- * @throws Exception
+ * @throws Exception
*/
public static List getOperationTypes() throws Exception {
BillingDAO billingDAO = new BillingDAO();
@@ -2131,6 +2131,11 @@ public static List getAllOperators() throws SQLException,
return operators;
}
+ public static Map getOperators() throws SQLException,APIMgtUsageQueryServiceClientException {
+ Map operators = OperatorDAO.getOperators();
+ return operators;
+ }
+
/**
* Gets the operatorbreakdown.
*
@@ -2140,7 +2145,7 @@ public static List getAllOperators() throws SQLException,
* @param subscriber the subscriber
* @param api the api
* @return the operatorbreakdown
- * @throws Exception
+ * @throws Exception
*/
public static Map getOperatorbreakdown(
String applicationid, String year, String month, String subscriber,
@@ -2148,7 +2153,7 @@ public static Map getOperatorbreakdown(
BillingDAO billingDAO = new BillingDAO();
String consumerkey = "%";
if (applicationid != null) {
-
+
consumerkey = billingDAO.getApplicationconsumer(
Integer.parseInt(applicationid),
APIConstants.API_KEY_TYPE_PRODUCTION);
@@ -2196,7 +2201,7 @@ public static String getApplicationNameById(String applicationid)
* @param operator the operator
* @param applicationId the application id
* @return the total api traffic for pie chart
- * @throws Exception
+ * @throws Exception
*/
public static List getTotalAPITrafficForPieChart(String fromDate,
String toDate, String subscriber, String operator, int applicationId)
@@ -2218,7 +2223,7 @@ public static List getTotalAPITrafficForPieChart(String fromDate,
* @param applicationId the application id
* @param api the api
* @return the total api traffic for histogram
- * @throws Exception
+ * @throws Exception
*/
public static List getTotalAPITrafficForHistogram(
String fromDate, String toDate, String subscriber, String operator,
@@ -2239,7 +2244,7 @@ public static List getTotalAPITrafficForHistogram(
* @param api the api
* @param applicationId the application id
* @return the operator wise api traffic for pie chart
- * @throws Exception
+ * @throws Exception
*/
public static List getOperatorWiseAPITrafficForPieChart(
String fromDate, String toDate, String subscriber, String api,
@@ -2261,7 +2266,7 @@ public static List getOperatorWiseAPITrafficForPieChart(
* @param applicationId the application id
* @param operator the operator
* @return the approval history
- * @throws Exception
+ * @throws Exception
*/
public static List getApprovalHistory(String fromDate,
String toDate, String subscriber, String api, int applicationId,
@@ -2279,7 +2284,7 @@ public static List getApprovalHistory(String fromDate,
* @param applicationId the application id
* @param operator the operator
* @return the approval history app
- * @throws Exception
+ * @throws Exception
*/
public static List getApprovalHistoryApp(int applicationId,
String operator) throws Exception {
@@ -2299,7 +2304,7 @@ public static List getApprovalHistoryApp(int applicationId,
* @param applicationId the application id
* @param api the api
* @return the all ap is
- * @throws Exception
+ * @throws Exception
*/
public static List getAllAPIs(String fromDate, String toDate,
String subscriber, String operator, int applicationId, String api)
@@ -2320,7 +2325,7 @@ public static List getAllAPIs(String fromDate, String toDate,
* @param applicationId the application id
* @param api the api
* @return the all error response codes
- * @throws Exception
+ * @throws Exception
*/
public static List getAllErrorResponseCodes(String fromDate,
String toDate, String subscriber, String operator,
@@ -2482,7 +2487,7 @@ public static List getAPIsBySubscriber(String subscriberName)
* @param operator the operator
* @param api the api
* @return the API wise traffic for report
- * @throws Exception
+ * @throws Exception
*/
public static List getAPIWiseTrafficForReport(String fromDate,
String toDate, String subscriber, String operator, String api,boolean isError, int applicationId)
@@ -2508,7 +2513,7 @@ public static List getAPIWiseTrafficForReport(String fromDate,
* @param endLimit the end limit
* @param timeOffset the time offset
* @return the filtered customer care report
- * @throws Exception
+ * @throws Exception
*/
public static List getFilteredCustomerCareReport(String fromDate,
String toDate, String msisdn, String subscriber, String operator,
@@ -2531,7 +2536,7 @@ public static List getFilteredCustomerCareReport(String fromDate,
* @param operator the operator
* @param api the api
* @return the API wise traffic for report charging
- * @throws Exception
+ * @throws Exception
*/
public static List getAPIWiseTrafficForReportCharging(
String fromDate, String toDate, String subscriber, String operator,
@@ -2543,7 +2548,7 @@ public static List getAPIWiseTrafficForReportCharging(
return charging_request_data;
}
-
+
/**
* Gets the report.
*
@@ -2632,7 +2637,7 @@ public static String getCustomReport(String fromDate, String toDate,
* @param applicationId the application id
* @param api the api
* @return the error response codes for pie chart
- * @throws Exception
+ * @throws Exception
*/
public static List getErrorResponseCodesForPieChart(
String fromDate, String toDate, String subscriber, String operator,
@@ -2654,7 +2659,7 @@ public static List getErrorResponseCodesForPieChart(
* @param applicationId the application id
* @param api the api
* @return the error response codes for histogram
- * @throws Exception
+ * @throws Exception
*/
public static List getErrorResponseCodesForHistogram(
String fromDate, String toDate, String subscriber, String operator,
@@ -2666,7 +2671,7 @@ public static List getErrorResponseCodesForHistogram(
return api_response_codes;
}
-
+
/**
* Gets the rate card.
*
@@ -3111,7 +3116,7 @@ public static Map getRateCard()
}
// ========================SUB
// CATEGORY====================================
-
+
chargeRate
.setCategories(categoryEntityMap);
}
@@ -3151,7 +3156,7 @@ public static Map getRateCard()
return ratecard;
}
-
+
/**
* Gets the rates for operator api.
*
@@ -3294,7 +3299,7 @@ public static List getRatesForOperatorApi(String operatorName,
* @param applicationId the application id
* @param api the api
* @return the total api traffic for line chart
- * @throws Exception
+ * @throws Exception
*/
public static List getTotalAPITrafficForLineChart(
String fromDate, String toDate, String subscriber, String operator,
@@ -3315,7 +3320,7 @@ public static List getTotalAPITrafficForLineChart(
* @param operator the operator
* @param timeRange the time range
* @return the total api response time for line chart
- * @throws Exception
+ * @throws Exception
*/
public static List getTotalAPIResponseTimeForLineChart(
String fromDate, String toDate, String subscriber, String operator,
@@ -3335,7 +3340,7 @@ public static List getTotalAPIResponseTimeForLineChart(
* @param fromDate the from date
* @param toDate the to date
* @return the all response times by date
- * @throws Exception
+ * @throws Exception
*/
public static Map> getAllResponseTimesByDate(
String opName, String username, String fromDate, String toDate)
@@ -3363,7 +3368,7 @@ public static Map> getAllResponseTimesByDate(
* @param fromDate the from date
* @param toDate the to date
* @return the time consumption for all ap is
- * @throws Exception
+ * @throws Exception
*/
public static Map getTimeConsumptionForAllAPIs(
String opName, String username, String fromDate, String toDate)
@@ -3411,7 +3416,7 @@ public static Map getRateCardNorthBound()
* @param appId the app id
* @param apiId the api id
* @param subsId the subs id
- * @throws Exception
+ * @throws Exception
*/
private static void calculateTiersCharges(
List selectedUsageTier,
@@ -3498,4 +3503,6 @@ private static void calculateTiersCharges(
private static String nvlDefault(String val) {
return (val == null || val.isEmpty()) ? DISPLAY_DEFAULT : val;
}
+
+
}