diff --git a/OjekOnlineWebservice/nbproject/build-impl.xml b/OjekOnlineWebservice/nbproject/build-impl.xml index c8e3582f06739b1cb1c56471852660c295e6b42f..e0d210530e9f589cf2e3f331bf368b7ee179e485 100644 --- a/OjekOnlineWebservice/nbproject/build-impl.xml +++ b/OjekOnlineWebservice/nbproject/build-impl.xml @@ -18,6 +18,7 @@ --> <project xmlns:webproject1="http://www.netbeans.org/ns/web-project/1" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:webproject3="http://www.netbeans.org/ns/web-project/3" basedir=".." default="default" name="OjekOnlineWebservice-impl"> + <import file="jaxws-build.xml"/> <import file="ant-deploy.xml"/> <fail message="Please build using Ant 1.7.1 or higher."> <condition> @@ -997,10 +998,13 @@ exists or setup the property manually. For example like this: </target> <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/> <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest"> + <copyfiles files="${file.reference.org.json.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/> <mkdir dir="${build.web.dir}/META-INF"/> <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/> </target> - <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"/> + <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"> + <copyfiles files="${file.reference.org.json.jar}" todir="${build.web.dir}/WEB-INF/lib"/> + </target> <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib"> <delete dir="${build.web.dir}/WEB-INF/lib"/> </target> diff --git a/OjekOnlineWebservice/nbproject/genfiles.properties b/OjekOnlineWebservice/nbproject/genfiles.properties index 06754af887d5e9f7f4a4895b85eeeda5714352e6..23e3766506c505a63b5bd875013b5d28a3381d96 100644 --- a/OjekOnlineWebservice/nbproject/genfiles.properties +++ b/OjekOnlineWebservice/nbproject/genfiles.properties @@ -1,9 +1,9 @@ -build.xml.data.CRC32=6b137e31 +build.xml.data.CRC32=c15f4ce0 build.xml.script.CRC32=4d0c4679 build.xml.stylesheet.CRC32=651128d4@1.77.1.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=6b137e31 -nbproject/build-impl.xml.script.CRC32=52b430c8 +nbproject/build-impl.xml.data.CRC32=c15f4ce0 +nbproject/build-impl.xml.script.CRC32=35f43f9c nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1 nbproject/jaxws-build.xml.stylesheet.CRC32=6608c2cf diff --git a/OjekOnlineWebservice/nbproject/jax-ws.xml b/OjekOnlineWebservice/nbproject/jax-ws.xml index 0c9842be221eb11c69d58a4948973a4aeb48a226..c2918efbcef5951f6a6d5645c703df256b32d696 100644 --- a/OjekOnlineWebservice/nbproject/jax-ws.xml +++ b/OjekOnlineWebservice/nbproject/jax-ws.xml @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <jax-ws xmlns="http://www.netbeans.org/ns/jax-ws/1"> <services> + <service name="History"> + <implementation-class>history.History</implementation-class> + </service> </services> <clients/> </jax-ws> diff --git a/OjekOnlineWebservice/nbproject/jaxws-build.xml b/OjekOnlineWebservice/nbproject/jaxws-build.xml new file mode 100644 index 0000000000000000000000000000000000000000..3562bd3c4d706b6796931aefaef70ba8b3b20a84 --- /dev/null +++ b/OjekOnlineWebservice/nbproject/jaxws-build.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?><!-- + *** GENERATED FROM jax-ws.xml - DO NOT EDIT ! *** + *** TO MODIFY wsimport options USE Web Service node -> Edit WS Attributes *** + *** TO CHANGE TARGETS GENERATED TO jaxws-build.xml COPY THOSE *** + *** TARGETS TO ../build.xml AND MODIFY THAT FILE INSTEAD *** + + --><project xmlns:xalan="http://xml.apache.org/xslt" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1"> + <!-- + =================== + JAX-WS WSGEN SECTION + =================== + --> + <target name="wsgen-init" depends="init, -do-compile"> + <mkdir dir="${build.generated.sources.dir}/jax-ws/resources/"/> + <mkdir dir="${build.classes.dir}"/> + <mkdir dir="${build.classes.dir}/META-INF"/> + <property name="j2ee.platform.wsgen.classpath" value="${libs.jaxws21.classpath}"/> + <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen"> + <classpath path="${java.home}/../lib/tools.jar:${build.classes.dir}:${j2ee.platform.wsgen.classpath}:${javac.classpath}"/> + </taskdef> + </target> + <target name="wsgen-History" depends="wsgen-init"> + <copy todir="${build.classes.dir}/META-INF"> + <fileset dir="${webinf.dir}" includes="wsit-history.History.xml"/> + </copy> + <wsgen sourcedestdir="${build.generated.sources.dir}/jax-ws" resourcedestdir="${build.generated.sources.dir}/jax-ws/resources/" destdir="${build.generated.sources.dir}/jax-ws" verbose="true" keep="true" genwsdl="true" sei="history.History" xendorsed="true"> + <classpath path="${java.home}/../lib/tools.jar:${build.classes.dir}:${j2ee.platform.wsgen.classpath}:${javac.classpath}"/> + </wsgen> + </target> + <!-- + =================== + JAX-WS WSIMPORT SECTION + =================== + --> +</project> diff --git a/OjekOnlineWebservice/nbproject/project.properties b/OjekOnlineWebservice/nbproject/project.properties index f7bfc2a22e0b08c07e76d01574c5fb328bc2fe50..cab92b4d85f485aa6650e43317f09c16579f6d09 100644 --- a/OjekOnlineWebservice/nbproject/project.properties +++ b/OjekOnlineWebservice/nbproject/project.properties @@ -28,6 +28,7 @@ dist.war=${dist.dir}/${war.name} endorsed.classpath=\ ${libs.javaee-endorsed-api-7.0.classpath} excludes= +file.reference.org.json.jar=..\\org.json.jar includes=** j2ee.compile.on.save=true j2ee.copy.static.files.on.save=true @@ -41,7 +42,8 @@ j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.ja j2ee.platform.wsit.classpath= j2ee.server.type=gfv3ee6 jar.compress=false -javac.classpath= +javac.classpath=\ + ${file.reference.org.json.jar} # Space-separated list of extra javac options javac.compilerargs= javac.debug=true diff --git a/OjekOnlineWebservice/nbproject/project.xml b/OjekOnlineWebservice/nbproject/project.xml index fa910d8033cba386764548cb3cb6a6b245d21416..55c59865ff73c451d5e00f9b69437a4733d4c80b 100644 --- a/OjekOnlineWebservice/nbproject/project.xml +++ b/OjekOnlineWebservice/nbproject/project.xml @@ -2,11 +2,18 @@ <project xmlns="http://www.netbeans.org/ns/project/1"> <type>org.netbeans.modules.web.project</type> <configuration> - <buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1"/> + <buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1"> + <extension file="jaxws-build.xml" id="jaxws"/> + </buildExtensions> <data xmlns="http://www.netbeans.org/ns/web-project/3"> <name>OjekOnlineWebservice</name> <minimum-ant-version>1.6.5</minimum-ant-version> - <web-module-libraries/> + <web-module-libraries> + <library dirs="200"> + <file>${file.reference.org.json.jar}</file> + <path-in-war>WEB-INF/lib</path-in-war> + </library> + </web-module-libraries> <web-module-additional-libraries/> <source-roots> <root id="src.dir" name="Source Packages"/> diff --git a/OjekOnlineWebservice/src/java/history/History.java b/OjekOnlineWebservice/src/java/history/History.java new file mode 100644 index 0000000000000000000000000000000000000000..48817aa9c5268e969f7fa05050c3a7ece9a86278 --- /dev/null +++ b/OjekOnlineWebservice/src/java/history/History.java @@ -0,0 +1,134 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package history; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.jws.WebService; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import org.json.JSONException; +import org.json.JSONObject; +/** + * + * @author raudi + */ +@WebService(serviceName = "Items") +public class History { + + /** + * Web service operation + * @param sellerID + * @return + */ + @WebMethod(operationName = "orderhistory") + @WebResult(name="HistoryObj") + public ArrayList<HistoryObj> orderhistory (@WebParam(name = "user_name") String user_name) { + ArrayList<HistoryObj> orderhistory = new ArrayList<>(); + try { + Class.forName("com.mysql.jdbc.Driver"); + Connection conn = DriverManager.getConnection( + "jdbc:mysql://localhost:3306/ojekonline?zeroDateTimeBehavior=convertToNull", + "root", + ""); + + Statement stmt = conn.createStatement(); + String sql; + sql = "SELECT * FROM transaksi WHERE user_name = ?"; + PreparedStatement dbStatement = conn.prepareStatement(sql); + dbStatement.setString(1, user_name); + /* Get every data returned by SQL query */ + ResultSet rs = dbStatement.executeQuery(); + /* Get every data returned by SQL query */ + int i = 0; + while(rs.next()){ + orderhistory.add(new HistoryObj(rs.getInt("id"), + rs.getString("driver_name"), + rs.getString("user_name"), + rs.getString("picking_point"), + rs.getString("destination"), + rs.getString("tanggal"), + rs.getString("comment"), + rs.getInt("rating"), + rs.getBoolean("user_hide"), + rs.getBoolean("driver_hide") + )); + ++i; + } + rs.close(); + stmt.close(); + conn.close(); + } catch (ClassNotFoundException | SQLException ex) { + Logger.getLogger(History.class.getName()).log(Level.SEVERE, null, ex); + } + return orderhistory; + } + + /** + * Web service operation + * @param sellerID + * @return + */ + @WebMethod(operationName = "driverhistory") + @WebResult(name="HistoryObj") + public ArrayList<HistoryObj> driverhistory (@WebParam(name = "driver_name") String driver_name) { + ArrayList<HistoryObj> driverhistory = new ArrayList<>(); + try { + Class.forName("com.mysql.jdbc.Driver"); + Connection conn = DriverManager.getConnection( + "jdbc:mysql://localhost:3306/ojekonline?zeroDateTimeBehavior=convertToNull", + "root", + ""); + + Statement stmt = conn.createStatement(); + String sql; + sql = "SELECT * FROM transaksi WHERE driver_name = ?"; + PreparedStatement dbStatement = conn.prepareStatement(sql); + dbStatement.setString(1, driver_name); + /* Get every data returned by SQL query */ + ResultSet rs = dbStatement.executeQuery(); + /* Get every data returned by SQL query */ + int i = 0; + while(rs.next()){ + driverhistory.add(new HistoryObj(rs.getInt("id"), + rs.getString("driver_name"), + rs.getString("user_name"), + rs.getString("picking_point"), + rs.getString("destination"), + rs.getString("tanggal"), + rs.getString("comment"), + rs.getInt("rating"), + rs.getBoolean("user_hide"), + rs.getBoolean("driver_hide") + )); + ++i; + } + rs.close(); + stmt.close(); + conn.close(); + } catch (ClassNotFoundException | SQLException ex) { + Logger.getLogger(History.class.getName()).log(Level.SEVERE, null, ex); + } + return driverhistory; + } + +} \ No newline at end of file diff --git a/OjekOnlineWebservice/src/java/history/HistoryObj.java b/OjekOnlineWebservice/src/java/history/HistoryObj.java new file mode 100644 index 0000000000000000000000000000000000000000..0f67dd60cc35fba8ada101a225712a6543a16fed --- /dev/null +++ b/OjekOnlineWebservice/src/java/history/HistoryObj.java @@ -0,0 +1,106 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package history; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author TIFAH06 + */ +@XmlRootElement(name = "itemObject") +public class HistoryObj { + @XmlElement(name="id", required=true) + public int id; + @XmlElement(name="driver_name", required=true) + public String driver_name; + @XmlElement(name="user_name", required=true) + public String user_name; + @XmlElement(name="picking_point", required=true) + public String picking_point; + @XmlElement(name="destination", required=true) + public String destination; + @XmlElement(name="tanggal", required=true) + public String tanggal; + @XmlElement(name="comment", required=true) + public String comment; + @XmlElement(name="rating", required=true) + public int rating; + @XmlElement(name="user_hide", required=true) + public boolean user_hide; + @XmlElement(name="driver_hide", required=true) + public boolean driver_hide; + + + public HistoryObj() { + id = 0; + driver_name = ""; + user_name = ""; + picking_point = ""; + destination = ""; + tanggal = ""; + comment = ""; + rating = 0; + user_hide = false; + driver_hide = false; + } + + public HistoryObj(int id, String driver_name, String user_name, String picking_point, String destination, String tanggal, + String comment, int rating, boolean user_hide, boolean driver_hide) { + this.id = id; + this.driver_name = driver_name; + this.user_name = user_name; + this.picking_point = picking_point; + this.destination = destination; + this.tanggal = tanggal; + this.comment = comment; + this.rating = rating; + this.user_hide = user_hide; + this.driver_hide = driver_hide; + + + } + + public int getID() { + return id; + } + + public String getDriverName() { + return driver_name; + } + + public String getUserName() { + return user_name; + } + + public String getPickingPoint() { + return picking_point; + } + + public String getDestination() { + return destination; + } + + public String getTanggal() { + return tanggal; + } + + public String getComment() { + return comment; + } + + public int getRating() { + return rating; + } + + public boolean getUserHide() { + return user_hide; + } + public boolean getDriverHide() { + return driver_hide; + } +} \ No newline at end of file diff --git a/data/derby.log b/data/derby.log index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cb60b6afe609f07af539ac5dfdf6e57c0faaafe0 100644 --- a/data/derby.log +++ b/data/derby.log @@ -0,0 +1 @@ +Wed Nov 08 19:32:27 ICT 2017 : Apache Derby Network Server - 10.11.1.2 - (1629631) started and ready to accept connections on port 1527