Skip to content
Snippets Groups Projects
Commit 45041498 authored by David's avatar David
Browse files

update order

parent af8bba36
Branches
No related merge requests found
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ValidExternallyBoundObject" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>
</component>
\ No newline at end of file
...@@ -10,8 +10,8 @@ import javax.jws.soap.SOAPBinding.Style; ...@@ -10,8 +10,8 @@ import javax.jws.soap.SOAPBinding.Style;
@SOAPBinding(style = Style.RPC) @SOAPBinding(style = Style.RPC)
public interface IOrder { public interface IOrder {
@WebMethod public Account getPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination); @WebMethod public Account[] getPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination);
@WebMethod public Account getNonPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination); @WebMethod public Account[] getNonPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination);
@WebMethod public void PuttransactionDetails(String access_token, int id_driver, String picking_point, String Destination, int rating, String comment); @WebMethod public boolean PuttransactionDetails(String access_token, int id_driver, String picking_point, String Destination, int rating, String comment);
} }
\ No newline at end of file
package com.informatika.ojek.webservice; package com.informatika.ojek.webservice;
import java.sql.*;
import javax.jws.WebService; import javax.jws.WebService;
//Service Implementation //Service Implementation
...@@ -7,14 +7,175 @@ import javax.jws.WebService; ...@@ -7,14 +7,175 @@ import javax.jws.WebService;
public class Order implements IOrder { public class Order implements IOrder {
@Override @Override
public Account getPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination){ public Account[] getPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination){
return null; boolean valid = true;
//cek akses token
int id_active;
if(valid){
id_active = 1;
} else {
return null;
}
try
{
// create our mysql database connection
String myDriver = "org.gjt.mm.mysql.Driver";
String myUrl = "jdbc:mysql://localhost/";
Class.forName(myDriver);
Connection conn = DriverManager.getConnection(myUrl, "root", "");
// our SQL SELECT query.
// if you only need a few columns, specify them by name instead of using "*"
String query = "SELECT distinct pref_loc.IDDriver, rating,totalvote FROM (pref_loc join rating_driver) where pref_loc.IDDriver != "+id_active+" and isdriver = 1 and (Location = '"+picking_point+"' or Location = '"+destination+"')";
// create the java statement
Statement st = conn.createStatement();
// execute the query, and get a java resultset
ResultSet rs = st.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
int n= 0;
// iterate through the java resultset
Account[] accounts = new Account[columnsNumber];
while (rs.next())
{
//dapetin detail akun dari user id
String name = "aa";
if(name == preffered_driver){
Account baru = new Account(1, "aaa", "aaa", "aaa@", "sss", "0808" , "ssss",false);
accounts[n] = baru;
n++;
}
// print the results
}
st.close();
return accounts;
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
return null;
}
} }
@Override @Override
public Account getNonPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination){ public Account[] getNonPrefferedDriver(String access_token, String preffered_driver, String picking_point, String destination){
return null; boolean valid = true;
int id_active;
//cek akses token
if(valid){
id_active = 1;
} else {
return null;
}
try
{
// create our mysql database connection
String myDriver = "org.gjt.mm.mysql.Driver";
String myUrl = "jdbc:mysql://localhost/";
Class.forName(myDriver);
Connection conn = DriverManager.getConnection(myUrl, "root", "");
// our SQL SELECT query.
// if you only need a few columns, specify them by name instead of using "*"
String query = "SELECT distinct pref_loc.IDDriver, rating,totalvote FROM (pref_loc join rating_driver) where pref_loc.IDDriver != "+id_active+" and isdriver = 1 and (Location = '"+picking_point+"' or Location = '"+destination+"')";
// create the java statement
Statement st = conn.createStatement();
// execute the query, and get a java resultset
ResultSet rs = st.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
int n= 0;
// iterate through the java resultset
Account[] accounts = new Account[columnsNumber];
while (rs.next())
{
//dapetin detail akun dari user id
String name = "aa";
if(name != preffered_driver){
Account baru = new Account(1, "aaa", "aaa", "aaa@", "sss", "0808" , "ssss",false);
accounts[n] = baru;
n++;
}
// print the results
}
st.close();
return accounts;
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
return null;
}
} }
@Override public void PuttransactionDetails(String access_token, int id_driver, String picking_point, String Destination, int rating, String comment){ @Override public boolean PuttransactionDetails(String access_token, int id_driver, String picking_point, String destination, int rating, String comment){
boolean valid = true;
int id_active;
//cek akses token
if(valid){
id_active = 1;
} else {
return false;
}
try
{
// create our mysql database connection
String myDriver = "org.gjt.mm.mysql.Driver";
String myUrl = "jdbc:mysql://localhost/";
Class.forName(myDriver);
Connection conn = DriverManager.getConnection(myUrl, "root", "");
// our SQL SELECT query.
// if you only need a few columns, specify them by name instead of using "*"
// create the java statement
Statement st = conn.createStatement();
String query1 = "SELECT * FROM transaction";
ResultSet rs = st.executeQuery(query1);
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
int id_transaksi = columnsNumber +1;
String query2 = "INSERT INTO transaction (IDTransaksi, IDDriver,IDPenumpang,LokasiAwal,LokasiTujuan,Rating,Comment,IsHide, DatePosted) VALUES ('"+id_transaksi+"','"+id_driver+"','"+id_active+"','"+picking_point+"','"+destination+"','"+rating+"','"+comment+"',"+0+",'"+id_transaksi+"')";
st.executeQuery(query2);
String query3 = "SELECT IDTransaksi from transaction where IDDriver = '"+id_driver+"'";
rs = st.executeQuery(query3);
rsmd = rs.getMetaData();
int totalvote = rsmd.getColumnCount();
String query4 = "SELECT sum(rating) from transaction where IDDriver = '"+id_driver+"' group by IDDriver";
rs = st.executeQuery(query4);
int totalrating = rs.getInt("sum(rating)");
float driverrating = totalrating/totalvote;
String query5 = "UPDATE rating_driver SET rating='"+driverrating+"', totalvote='"+totalvote+"' WHERE IDDriver='"+id_driver+"'";
st.close();
return true;
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
return false;
}
} }
......
...@@ -3,7 +3,7 @@ package com.informatika.ojek.webservice; ...@@ -3,7 +3,7 @@ package com.informatika.ojek.webservice;
import javax.jws.WebService; import javax.jws.WebService;
//Service Implementation //Service Implementation
@WebService(endpointInterface = "com.informatika.ojek.webservice.IOrder") @WebService(endpointInterface = "com.informatika.ojek.webservice.IProfile")
public class Profile implements IProfile { public class Profile implements IProfile {
@Override public Account getActiveUser(String access_token){ @Override public Account getActiveUser(String access_token){
return null; return null;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment