From 7967de8e35bccd7165af36a7f6fd9ee252e9c2dc Mon Sep 17 00:00:00 2001
From: Diki Ardian <ardiandiki369@gmail.com>
Date: Mon, 6 Nov 2017 22:46:38 +0700
Subject: [PATCH] add history service

---
 WebService/.idea/misc.xml                     |  1 +
 .../informatika/ojek/webservice/History.java  | 64 +++++++++++++++++++
 .../informatika/ojek/webservice/IHistory.java | 15 +++++
 .../informatika/ojek/webservice/IProfile.java | 12 ++--
 .../com/informatika/ojek/webservice/Main.java |  2 +-
 .../informatika/ojek/webservice/Profile.java  |  1 +
 6 files changed, 88 insertions(+), 7 deletions(-)
 create mode 100644 WebService/src/com/informatika/ojek/webservice/History.java
 create mode 100644 WebService/src/com/informatika/ojek/webservice/IHistory.java

diff --git a/WebService/.idea/misc.xml b/WebService/.idea/misc.xml
index cb0f292..6453144 100644
--- a/WebService/.idea/misc.xml
+++ b/WebService/.idea/misc.xml
@@ -6,4 +6,5 @@
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
+  <component name="WebServicesPlugin" addRequiredLibraries="true" />
 </project>
\ No newline at end of file
diff --git a/WebService/src/com/informatika/ojek/webservice/History.java b/WebService/src/com/informatika/ojek/webservice/History.java
new file mode 100644
index 0000000..8c8d518
--- /dev/null
+++ b/WebService/src/com/informatika/ojek/webservice/History.java
@@ -0,0 +1,64 @@
+package com.informatika.ojek.webservice;
+
+import javax.jws.WebService;
+import java.util.Date;
+
+@WebService(endpointInterface = "com.informatika.ojek.webservice.IHistory")
+public class History implements IHistory {
+    @Override
+    public Transaction[] getDriverHistory(String accessToken) {
+        boolean isTokenValid = true; //request identity service
+        int id = 1; //request identity service
+        if (isTokenValid) {
+            //QUERY getTransaction idDriver = id
+            int idTransaction = 1;
+            int idPenumpang = 1;
+            String lokasiAwal = "a";
+            String lokasiTujuan = "b";
+            int rating = 5;
+            String comment = "no comment";
+            boolean isHide = true;
+            Date datePosted = new Date(2017, 7, 10);
+            boolean isDriver = true;
+            Transaction trx = new Transaction(idTransaction, id, idPenumpang, lokasiAwal, lokasiTujuan, rating, comment, isHide, datePosted);
+            return new Transaction[]{trx};
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Transaction[] getPenumpangHistory(String accessToken) {
+        boolean isTokenValid = true; //request identity service
+        int id = 1; //request identity service
+        if (isTokenValid) {
+            //QUERY getTransaction idPenumpang = id
+            int idTransaction = 1;
+            int idDriver = 1;
+            String lokasiAwal = "a";
+            String lokasiTujuan = "b";
+            int rating = 5;
+            String comment = "no comment";
+            boolean isHide = true;
+            Date datePosted = new Date(2017, 7, 10);
+            boolean isDriver = true;
+            Transaction trx = new Transaction(idTransaction, idDriver, id, lokasiAwal, lokasiTujuan, rating, comment, isHide, datePosted);
+            return new Transaction[]{trx};
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public boolean hideHistory(String accessToken, int idTransaction) {
+        boolean isTokenValid = true; //request identity service
+        int id = 1; //request identity service
+        if (isTokenValid) {
+            //QUERY hideTransaction
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}
diff --git a/WebService/src/com/informatika/ojek/webservice/IHistory.java b/WebService/src/com/informatika/ojek/webservice/IHistory.java
new file mode 100644
index 0000000..054fdb9
--- /dev/null
+++ b/WebService/src/com/informatika/ojek/webservice/IHistory.java
@@ -0,0 +1,15 @@
+package com.informatika.ojek.webservice;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+//Service Endpoint Interface
+@WebService
+@SOAPBinding(style = Style.RPC)
+public interface IHistory {
+    @WebMethod public Transaction[] getDriverHistory(String accessToken);
+    @WebMethod public Transaction[] getPenumpangHistory(String accessToken);
+    @WebMethod public boolean hideHistory(String accessToken, int idTransaction);
+}
\ No newline at end of file
diff --git a/WebService/src/com/informatika/ojek/webservice/IProfile.java b/WebService/src/com/informatika/ojek/webservice/IProfile.java
index 9720857..8104294 100644
--- a/WebService/src/com/informatika/ojek/webservice/IProfile.java
+++ b/WebService/src/com/informatika/ojek/webservice/IProfile.java
@@ -9,10 +9,10 @@ import javax.jws.soap.SOAPBinding.Style;
 @WebService
 @SOAPBinding(style = Style.RPC)
 public interface IProfile {
-    @WebMethod public Account getActiveUser(String access_token);
-    @WebMethod public String[] getLocation(String access_token);
-    @WebMethod public boolean addPreferredLocation(String access_token, String location);
-    @WebMethod public boolean delPreferredLocation(String access_token, String location);
-    @WebMethod public boolean updatePreferredLocation(String access_token, String old_location, String new_location);
-    @WebMethod public boolean updateProfile(String access_token, String name, String phone, Boolean is_driver, String photo);
+    @WebMethod public Account getActiveUser(String accessToken);
+    @WebMethod public String[] getLocation(String accessToken);
+    @WebMethod public boolean addPreferredLocation(String accessToken, String location);
+    @WebMethod public boolean delPreferredLocation(String accessToken, String location);
+    @WebMethod public boolean updatePreferredLocation(String accessToken, String old_location, String new_location);
+    @WebMethod public boolean updateProfile(String accessToken, String name, String phone, Boolean is_driver, String photo);
 }
\ No newline at end of file
diff --git a/WebService/src/com/informatika/ojek/webservice/Main.java b/WebService/src/com/informatika/ojek/webservice/Main.java
index 4fb2702..b766ae0 100644
--- a/WebService/src/com/informatika/ojek/webservice/Main.java
+++ b/WebService/src/com/informatika/ojek/webservice/Main.java
@@ -8,7 +8,7 @@ public class Main{
     public static void main(String[] args) {
         Endpoint.publish("http://localhost:9999/ws/profile", new Profile());
         Endpoint.publish("http://localhost:9999/ws/order", new Order());
-
+        Endpoint.publish("http://localhost:9999/ws/history", new History());
     }
 
 }
\ No newline at end of file
diff --git a/WebService/src/com/informatika/ojek/webservice/Profile.java b/WebService/src/com/informatika/ojek/webservice/Profile.java
index dd0662b..ed60e10 100644
--- a/WebService/src/com/informatika/ojek/webservice/Profile.java
+++ b/WebService/src/com/informatika/ojek/webservice/Profile.java
@@ -9,6 +9,7 @@ public class Profile implements IProfile {
         boolean isTokenValid = true; //request identity service
         int id = 1; //request identity service
         if (isTokenValid) {
+            //QUERY getAccount
             String name = "Diki Ardian";
             String username = "dikiardian";
             String email = "diki@gmail.com";
-- 
GitLab