Bladeren bron

Add Get Sacon Packages

Sherwin 7 jaren geleden
bovenliggende
commit
f6ad95ade2

+ 54 - 0
GabonTelMobicashMobileAppHelper/src/com/psi/gabontel/mobileapp/helper/GetSatconPackage.java

@@ -0,0 +1,54 @@
+package com.psi.gabontel.mobileapp.helper;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.logging.Logger;
+import org.json.simple.JSONValue;
+
+import com.psi.applicationmanager.AppManagerFunction;
+import com.psi.applicationmanager.AppMessage;
+import com.psi.common.transactions.Message;
+import com.psi.gabontel.mobileapp.helper.objects.SatconPackages.Package;
+
+import com.psi.gabontel.mobileapp.helper.objects.SatconPackages;
+
+@Stateless
+@Remote(AppManagerFunction.class)
+public class GetSatconPackage implements AppManagerFunction {
+
+	private static final Logger log = Logger.getLogger(GetSatconPackage.class);
+
+	@Override
+	public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
+		return manageTransaction(refid, msisdn, message, syntax).getMessage();
+	}
+
+	@Override
+	public AppMessage manageTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
+
+		try {
+			ArrayList<Package> jsondata = null;
+
+			jsondata = SatconPackages.getPackages();
+
+			StringWriter out = new StringWriter();
+			JSONValue.writeJSONString(jsondata, out);
+			out.toString();
+
+			return new Message(0, 0, out.toString());
+
+		} catch (Exception e) {
+			log.error("Awts Error", e);
+		}
+
+		return new Message(0, 0, "{}");
+
+	}
+
+}

+ 86 - 0
GabonTelMobicashMobileAppHelper/src/com/psi/gabontel/mobileapp/helper/objects/SatconPackages.java

@@ -0,0 +1,86 @@
+package com.psi.gabontel.mobileapp.helper.objects;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
+import org.json.simple.JSONObject;
+
+import com.psi.common.db.DataRow;
+import com.psi.common.db.DataRowCollection;
+import com.psi.common.db.DbWrapper;
+import com.psi.gabontel.mobileapp.helper.objects.OcsPackages.Package;
+
+public class SatconPackages {
+	
+	private static DbWrapper db  = DbWrapper.getInstance();
+
+	
+	private static ArrayList<Package> packages;
+	
+	public static ArrayList<Package> getPackages() {
+		return packages;
+	}
+
+
+	static {
+		
+		packages = new ArrayList<Package>();
+		
+		DataRowCollection rows = db.QueryDataRows("SELECT PACKAGECODE,PACKAGENUMBER,PACKAGEPRICE/100 as PACKAGEPRICE,LABEL FROM TBLPACKAGESSATCON WHERE STATUS  = 1 ORDER BY ID ASC");
+		
+		Iterator<DataRow> iterator = rows.iterator();
+		while(iterator.hasNext()) {
+			DataRow row = iterator.next();
+			Package pckge = new Package();
+			pckge.setLabel(row.getString("LABEL"));
+			pckge.setPackagecode(row.getString("PACKAGECODE"));
+			pckge.setPackagenumber("PACKAGENUMBER");
+			pckge.setPackageprice("PACKAGEPRICE");
+			packages.add(pckge);
+		}
+	}
+	
+	public static class Package {
+		
+		private String packagecode;
+		private String packageprice;
+		private String packagenumber;
+		private String label;
+		public String getPackagecode() {
+			return packagecode;
+		}
+		public void setPackagecode(String packagecode) {
+			this.packagecode = packagecode;
+		}
+		public String getPackageprice() {
+			return packageprice;
+		}
+		public void setPackageprice(String packageprice) {
+			this.packageprice = packageprice;
+		}
+		public String getPackagenumber() {
+			return packagenumber;
+		}
+		public void setPackagenumber(String packagenumber) {
+			this.packagenumber = packagenumber;
+		}
+		public String getLabel() {
+			return label;
+		}
+		public void setLabel(String label) {
+			this.label = label;
+		}
+		
+		public String toString() {
+			JSONObject obj = new JSONObject();
+			obj.put("packagecode", this.packagecode);
+			obj.put("packageprice",this.packageprice);
+			obj.put("packagenumber", this.packagenumber);
+			obj.put("label",this.label);
+			
+			return obj.toJSONString();	
+		}
+		
+	}
+}