taxisrus.implementation.rmi
Class ModelRMI

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--taxisrus.implementation.rmi.ModelRMI
All Implemented Interfaces:
ModelRMIInterface, Remote, Serializable

public class ModelRMI
extends UnicastRemoteObject
implements ModelRMIInterface

See Also:
Serialized Form

Field Summary
protected  ModelInterface _model
           
protected  Object _returnObject
           
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ModelRMI()
          For test reasons.
ModelRMI(String modelServerName)
           
 
Method Summary
 Object addCustomer(Customer customer)
          Adds a customer in system.
PRECONDITION: Customer must have the following information set already:
- call-in time
- pickup address
- pickup time
- destination address
POSTCONDITION: customer's information is set
scheduler now has customer within domain
datastore knows of ride request
 Object cancelCustomer(String customerPhone, String customerLastName, String customerFirstName)
          Cancel the customer, returns true for successful cancellation
 Object changeCustomer(Customer oldCustomer, Customer newCustomer)
          Change a customer
 Object getCustomer(String customerPhone, String customerLastName, String customerFirstName)
          Returns the Customer identified by the phone number and last name
PRECONDITION: scheduler contains the target customer
POSTCONDITION: none
 ManagerReport getReport(int typeOfReport, int specificity, int timeInterval)
          For ManagerUI: Given an enumerated type of report, this method will return a Report designed for a manager of the cab company
 ManagerReport getReport(int typeOfReport, int specificity, int timeInterval, Date from, Date to)
          Passes ManagerReport request from ManagerUI to DataStore Given an enumerated type of report, this method will return a Report designed for a manager of the cab company
 boolean isCreditCardAccepted(double chargedAmount, String creditCardNumber)
          "Approve" credit card
-- passes the charge amount and creditCardNumber to bank and sees if the card is approved
PRECONDITION: none
POSTCONDITION: none
static void main(String[] args)
           
 Boolean registerCabToModel(CabConsoleInterface cabConsole, int cab_id, int driver_id, String gps)
          registers the cab in the model if cab_id and driver_id are valid (in database)
PRECONDITION: both cab and driver identified by cab_id and driver_id registers for the first time.
POSTCONDITION: a cab object corresponding to the cab console has been created and placed in its respective zone in the model
 boolean updateModelCabInfo(String cust_info)
          For Cab Console: After console updates referenced cab object, this method triggers necessary model updates
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_model

protected ModelInterface _model

_returnObject

protected Object _returnObject
Constructor Detail

ModelRMI

public ModelRMI(String modelServerName)
         throws RemoteException

ModelRMI

public ModelRMI()
         throws RemoteException
For test reasons.
Method Detail

addCustomer

public Object addCustomer(Customer customer)
                   throws RemoteException
Description copied from interface: ModelRMIInterface
Adds a customer in system.
PRECONDITION: Customer must have the following information set already:
- call-in time
- pickup address
- pickup time
- destination address
POSTCONDITION: customer's information is set
scheduler now has customer within domain
datastore knows of ride request
Specified by:
addCustomer in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
customer - customer object to be added
Returns:
ETA the estimated pickup time

cancelCustomer

public Object cancelCustomer(String customerPhone,
                             String customerLastName,
                             String customerFirstName)
                      throws RemoteException
Description copied from interface: ModelRMIInterface
Cancel the customer, returns true for successful cancellation
Specified by:
cancelCustomer in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
customer_id -  
customerLastName -  
Returns:
Boolean object (NOT PRIMITIVE!)

getCustomer

public Object getCustomer(String customerPhone,
                          String customerLastName,
                          String customerFirstName)
                   throws RemoteException
Description copied from interface: ModelRMIInterface
Returns the Customer identified by the phone number and last name
PRECONDITION: scheduler contains the target customer
POSTCONDITION: none
Specified by:
getCustomer in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
customerPhone -  
customerLastName -  
Returns:
customer that matches the phone and name

changeCustomer

public Object changeCustomer(Customer oldCustomer,
                             Customer newCustomer)
                      throws RemoteException
Change a customer
Specified by:
changeCustomer in interface ModelRMIInterface
Parameters:
old - customer
new - customer
Returns:
true if change valid and successful

main

public static void main(String[] args)

updateModelCabInfo

public boolean updateModelCabInfo(String cust_info)
For Cab Console: After console updates referenced cab object, this method triggers necessary model updates
Specified by:
updateModelCabInfo in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
must - be in this format:
"cab_id \n status \n gps \n meter \n mileage \n pickuptime", or
"cab_id \n status \n date"
where status = 0 dropped off customer, 1 accepted fare, 2 picked up customer
where date = Date.toString()
assumes: cab_id is int,
gps is "(,)",
meter is double, status is true or false,
ride mileage is float

registerCabToModel

public Boolean registerCabToModel(CabConsoleInterface cabConsole,
                                  int cab_id,
                                  int driver_id,
                                  String gps)
Description copied from interface: ModelRMIInterface
registers the cab in the model if cab_id and driver_id are valid (in database)
PRECONDITION: both cab and driver identified by cab_id and driver_id registers for the first time.
POSTCONDITION: a cab object corresponding to the cab console has been created and placed in its respective zone in the model
Specified by:
registerCabToModel in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Returns:
true (Boolean object) if both id's are valid, false otherwise

isCreditCardAccepted

public boolean isCreditCardAccepted(double chargedAmount,
                                    String creditCardNumber)
Description copied from interface: ModelRMIInterface
"Approve" credit card
-- passes the charge amount and creditCardNumber to bank and sees if the card is approved
PRECONDITION: none
POSTCONDITION: none
Specified by:
isCreditCardAccepted in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
chargedAmount - amount to charge
creditCardNumber - credit card number
Returns:
whether the card was accepted

getReport

public ManagerReport getReport(int typeOfReport,
                               int specificity,
                               int timeInterval)
Description copied from interface: ModelRMIInterface
For ManagerUI: Given an enumerated type of report, this method will return a Report designed for a manager of the cab company
Specified by:
getReport in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
typeOfReport -  
specificity -  
timeInterval -  
Returns:
ManagerReport

getReport

public ManagerReport getReport(int typeOfReport,
                               int specificity,
                               int timeInterval,
                               Date from,
                               Date to)
Description copied from interface: ModelRMIInterface
Passes ManagerReport request from ManagerUI to DataStore Given an enumerated type of report, this method will return a Report designed for a manager of the cab company
Specified by:
getReport in interface ModelRMIInterface
Following copied from interface: taxisrus.publicinterface.ModelRMIInterface
Parameters:
typeOfReport - - type of report
specificity -  
timeInterval -  
from - - starting date for query
to - - ending date for query
Returns:
the manager report


API documentation for build 958