-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67ed1fe
commit dec76c9
Showing
14 changed files
with
714 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,25 @@ public static final class ApplicationConstants { | |
|
||
//Specific Version | ||
public static final String VERSION = "1.0"; | ||
|
||
public static final String LBS_URL = "http://127.0.0.1:7000/lbs/locate"; | ||
} | ||
|
||
public static final class ApplicationMessages { | ||
public static final String WELCOME_MSG = "1. Subscribe\n99. Exit"; | ||
public static final String SUBSCRIBE_MESSAGE = "1. Search Location\n2. Register For Pin\n3. Forget Pin\n4. Help\n5. Contact us\n0. Back\n99. Exit"; | ||
public static final String SEARCH_LOCATION = "obata soyanna awashya kenage pin ankaya athulath karanna"; | ||
public static final String REGISTER_FOR_PIN = "keti paniwidayakin obe pin ankaya labenu atha.\n" + | ||
"0. Back\n" + | ||
"99. Exit"; | ||
public static final String HELP_MESSAGE = "Keti Paniwidayak Magein Siyalu Thorathuru Labenu Atha.\n0. Back\n99. Exit"; | ||
public static final String CONTACT = "Sp Name:-S.M.P.K Senevirathna\n" + | ||
" App Developer Details: [email protected].\n" + | ||
" \n0. Back\n99.Exit"; | ||
public static final String HELP_SMS = "welcome to (app eke name) ussd application.\n" + | ||
" Inna Thana Balaganimata :- (app keyword) <space> GPS <space> oba soyana kenage Pin Ankaya.\n" + | ||
" sent to(app number)\n"; | ||
public static final String ExIT_MESSAGE = "Thank you for using. come again!"; | ||
|
||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/ideamart/sample/dashboard/Dashboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.ideamart.sample.dashboard; | ||
|
||
/** | ||
* Created by tharinda on 10/21/16. | ||
*/ | ||
public class Dashboard { | ||
private String totalUsers; | ||
private String pendingUser; | ||
private String activeUsers; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.ideamart.sample.lbs; | ||
|
||
|
||
import com.google.gson.*; | ||
import com.ideamart.sample.common.Constants; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
|
||
import java.io.*; | ||
import java.net.URI; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* Created by tharinda on 10/21/16. | ||
*/ | ||
public class LBS { | ||
|
||
private String APIkey = "AIzaSyDfPfRnA7qzQe5Qhg9SQkNxhGVryguhN3w"; | ||
|
||
public String getLocation(String address) throws Exception { | ||
|
||
LBSbean lbSbean = new LBSbean(); | ||
lbSbean.setApplicationId(Constants.ApplicationConstants.APP_ID); | ||
lbSbean.setPassword(Constants.ApplicationConstants.PASSWORD); | ||
lbSbean.setSubscriberId(address); | ||
lbSbean.setFreshness("HIGH"); | ||
lbSbean.setHorizontalAccuracy("1500"); | ||
lbSbean.setResponseTime("NO_DELAY"); | ||
lbSbean.setVersion("2.0"); | ||
String postUrl = Constants.ApplicationConstants.LBS_URL; | ||
Gson gson = new Gson(); | ||
HttpClient httpClient = HttpClientBuilder.create().build(); | ||
HttpPost post = new HttpPost(postUrl); | ||
StringEntity postingString = new StringEntity(gson.toJson(lbSbean));//gson.tojson() converts your pojo to json | ||
post.setEntity(postingString); | ||
post.setHeader("Content-type", "application/json"); | ||
post.setHeader("Accept", "application/json"); | ||
HttpResponse response = httpClient.execute(post); | ||
System.out.println(response.getStatusLine()); | ||
InputStream inputStream = response.getEntity().getContent(); | ||
Scanner s = new Scanner(inputStream).useDelimiter("\\A"); | ||
String result = s.hasNext() ? s.next() : ""; | ||
return getMessage(result); | ||
|
||
} | ||
|
||
public String getMessage(String jsonLine) throws IOException { | ||
JsonElement jelement = new JsonParser().parse(jsonLine); | ||
JsonObject jobject = jelement.getAsJsonObject(); | ||
String lat = String.valueOf(jobject.get("latitude")).replaceAll("['\"]", ""); | ||
String lon = String.valueOf(jobject.get("longitude")).replaceAll("['\"]", ""); | ||
return getMapLocation(lat, lon); | ||
} | ||
|
||
public String getMapLocation(String lat, String lon) throws IOException { | ||
String url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lon + "&key=" + APIkey; | ||
HttpClient httpClient = HttpClientBuilder.create().build(); | ||
HttpGet get = new HttpGet(); | ||
get.setURI(URI.create(url)); | ||
HttpResponse response = httpClient.execute(get); | ||
System.out.println(response.getStatusLine()); | ||
InputStream inputStream = response.getEntity().getContent(); | ||
Scanner s = new Scanner(inputStream).useDelimiter("\\A"); | ||
String result = s.hasNext() ? s.next() : ""; | ||
JsonElement jelement = new JsonParser().parse(result); | ||
JsonObject jobject = jelement.getAsJsonObject(); | ||
JsonArray array = jobject.getAsJsonArray("results"); | ||
String address = array.get(0).getAsJsonObject().get("formatted_address").toString().replaceAll("['\"]", ""); | ||
String mapURL = "http://maps.google.com/?ll=" + lat + "," + lon; | ||
return address + "\n" + mapURL; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.ideamart.sample.lbs; | ||
|
||
/** | ||
* Created by tharinda on 10/21/16. | ||
*/ | ||
public class LBSbean { | ||
private String applicationId; | ||
private String password; | ||
private String subscriberId; | ||
private String serviceType; | ||
private String responseTime; | ||
private String freshness; | ||
private String horizontalAccuracy; | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(String version) { | ||
this.version = version; | ||
} | ||
|
||
public String getApplicationId() { | ||
return applicationId; | ||
} | ||
|
||
public void setApplicationId(String applicationId) { | ||
this.applicationId = applicationId; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public String getSubscriberId() { | ||
return subscriberId; | ||
} | ||
|
||
public void setSubscriberId(String subscriberId) { | ||
this.subscriberId = subscriberId; | ||
} | ||
|
||
public String getServiceType() { | ||
return serviceType; | ||
} | ||
|
||
public void setServiceType(String serviceType) { | ||
this.serviceType = serviceType; | ||
} | ||
|
||
public String getResponseTime() { | ||
return responseTime; | ||
} | ||
|
||
public void setResponseTime(String responseTime) { | ||
this.responseTime = responseTime; | ||
} | ||
|
||
public String getFreshness() { | ||
return freshness; | ||
} | ||
|
||
public void setFreshness(String freshness) { | ||
this.freshness = freshness; | ||
} | ||
|
||
public String getHorizontalAccuracy() { | ||
return horizontalAccuracy; | ||
} | ||
|
||
public void setHorizontalAccuracy(String horizontalAccuracy) { | ||
this.horizontalAccuracy = horizontalAccuracy; | ||
} | ||
|
||
private String version; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/ideamart/sample/subcription/Subscription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.ideamart.sample.subcription; | ||
|
||
import com.ideamart.sample.common.Constants; | ||
import hms.kite.samples.api.SdpException; | ||
import hms.kite.samples.api.subscription.SubscriptionRequestSender; | ||
import hms.kite.samples.api.subscription.messages.SubscriptionRequest; | ||
import hms.kite.samples.api.subscription.messages.SubscriptionResponse; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
/** | ||
* Created by tharinda on 10/21/16. | ||
*/ | ||
public class Subscription { | ||
|
||
private String subscriptionStatus; | ||
|
||
public String subscribeUser(String address) throws MalformedURLException { | ||
SubscriptionRequestSender subscriptionRequestSender = | ||
new SubscriptionRequestSender(new URL(Constants.ApplicationConstants.SUBSCRIPTION_MESSAGE_URL)); | ||
|
||
SubscriptionRequest subscriptionRequest = new SubscriptionRequest(); | ||
subscriptionRequest.setApplicationId(Constants.ApplicationConstants.APP_ID); | ||
subscriptionRequest.setPassword(Constants.ApplicationConstants.PASSWORD); | ||
subscriptionRequest.setSubscriberId(address); | ||
subscriptionRequest.setAction(Constants.ApplicationConstants.REG_ACTION); | ||
subscriptionRequest.setVersion(Constants.ApplicationConstants.VERSION); | ||
|
||
try { | ||
// Get SubscriptionResponse and assign Subscription Register Status to display | ||
SubscriptionResponse subscriptionResponse | ||
= subscriptionRequestSender.sendSubscriptionRequest(subscriptionRequest); | ||
return subscriptionResponse.getStatusDetail(); | ||
} catch (SdpException e) { | ||
System.out.println("Error Occurred due to" + e); | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.