QuestionQuestion

Introduction to Software Engineering

This document discusses a) the structure of the Warehouse Management System, b) the use cases to be considered for the first deliverable, and c) the specification and implementation artifacts for the use cases related to the first deliverable.

The Warehouse Management System (WMS) is a software system that simulates the operations of the warehouse of a simple company that sells goods to clients, and buys products from suppliers. The model of the warehouse of the company is implemented as a database with one table denoting the ID of each product, the name of the product, its stock quantity, and its unit price. Once a specific quantity of product is sold to a customer, this quantity is taken out of the available stock of this product from the corresponding database entry pertaining to this product. If the stock quantity of a product drops below 10 items or an order cannot be fulfilled the product’s state is set as “out of stock” (see packages ca.uwo.model and ca.uwo.model.item.states for the different states a product can be in). Once a product’s state is “out of stock” then a notification is sent so that a purchase (i.e. restock) action can be triggered and the item be restocked from a supplier. Each product is restocked according to a specific strategy (e.g. a restocking strategy for a product can be 50 units per restock operation, while for another product a different restocking strategy could be used, leading thus to a different restock quantities to be added). In addition to the restocking strategies, the price of an individual product for a given order can be calculated using different strategies (e.g. orders of apples more than 100 units get a 10% discount for this product), and the total price for the whole order (an order may contain many products with different quantities each) is also calculated using different strategies (e.g. orders of total value more than 1,000 dollars get an additional aggregate 5% discount to any other individual discounts applied for each product in this order).

2. Overall System Structure
The Warehouse Management System is split for modularity into a number of different packages. An outline of each package and its contents is provided below:

• ca.uwo.banking package: This package provides the initiation of a payment (to a supplier) and the reception of a payment (from a buyer) after a transaction (buy, or restock) is completed. This package is a placeholder for future system extensions

oBankingTransactions.java:ThisclassimplementstheoperationsreceivePaymentandpaySupplier

• ca.uwo.client package: This package implements the buyer and the supplier.

o Buyer.java:Thisclassimplementstheoperationsbuy,andpay.Thebuyoperationisaclient-side process that sends a placeOrder invocation to the WelcomeProxy of the Warehouse Management System. The pay operation just prints the generated invoice. The Buyer class has two attributes userName and password which are used later for authentication purposes using an authenticate method in the receiving proxies of the Warehouse Management System.

o Supplier.java:Thisclassimplementsthesupplyoperationwhichisaclient sideprocessthatsends a restock invocation to the WelcomeProxy of the Warehouse Management System.

o Client.java:ThisisanabstractclassfromwhichtheBuyerclassandtheSupplierclassinherit from. The class provides two attributes

• Ca.uwo.controller: This package implements the Controller module in a Model-View-Controller architecture. It contains all classes that offer operations (i.e. the Controller) that change the Model (i.e. the data).

o Controller.java:ThisclassimplementsthedepleteStock,replenishStock,andcreateInvoice operations. This class references all key underlying operations of the warehouse system using the attributes createInvoiceOp, depleteStockOp, and replenishStockOp. All the referenced operations implement the perform method (see OperationInterface class). This class keeps also a reference to the current order through the currentOrder attribute. The Controller class is implemented as a singleton class.

oOperationInterface.java:Thisclassprovidesthecommoninterfaceforallsystemoperations(i.e the CreateInvoiceOperation, DepleteStockOperation, ReplenishStockOperation and which all implement the interface (i.e. the perform method of the OperationInterface interface).

o Operation.java: This is an abstract class form which all operation classes inherit from. It provides three attributes namely, the itemRepo attribute that references a model of the database stored in the dynamic memory as products are fetched from the data base, the items attribute is a hash map that links the item name to an Item object (see the ca.uwo.model package), and the attribute dataManager which keeps a reference to a DataManager object that provides the operations to connect with the underlying database and manipulate the items in the underlying data base, providing thus a layer of isolation between the Warehouse Management System and the underlying data base technology used.

oCreateInvoiceOperation.java:Thisclassimplementsthroughitsperformmethodthecreationof an invoice.

oDepleteStockOperation.java:Thisclassimplementsthroughitsperformmethodthereductionof the stock by calling the depleteItemStock method on the corresponding itemRepo.

oReplenishStockOperation.java:Thisclassimplementsthroughitsperformmethodtheincreaseof the stock by calling the replenishItemStock method on the corresponding itemRepo.

• ca.uwo.dataAccess package: This package provides the isolation layer between the underlying data base technology used and the Warehouse Management System.

o DataManager.java:Thisclassprovidestheoperationstoconnectwiththeunderlyingdatabase and manipulate the items in the underlying data base, providing thus a layer of isolation between the Warehouse Management System and the underlying data base technology used. It provides the methods connect, createNewDatabase, createNewTable, getItem, insertItem, and updateItem. The DataManager is implemented as a singleton class.

• ca.uwo.Driver package:This package provides the environment to automate the Warehouse Management System by providing a class that reads a number of buy transactions from different buyers.

o Driver.java:Thisclasshasthemainmethodtorunthesystem.Themainmethodreadsthefor the file buyer_file the available buyers and their IDs, and from the driver_file the different buy transactions which are to be performed from the corresponding buyers.

• ca.uwo.frontend package: This package provides a façade for the commands issued by the buyers and the suppliers. A Façade implements a workflow for a given command. For example, for the placeOrder command (method), the Façade will do a) createOrder, b) depleteStock, c) createInvoice, and d) receivePayment.

o Facade.java:ThisclassimplementstheFacadeCommandsinterface.Thisisalsotheinterface exposed by all proxies including the WelcomeProxy. (see below). This interface provides the createOrder, restock, and placeOrder methods (API).

• ca.uwo.frontend.interfaces package:This package provides a module containing the interfaces exposed by the whole system. In this implementation it is only the FacadeCommands interface that is exposed by the WMS.

oFacadeCommads.java:ThisinterfacespecifiestheAPI(interface)exposedbythewholeWMS. The Warehouse Management System exposes the restock and the placeOrder operations.

• ca.uwo.model package: This package implements the Model module in a Model-View-Controller architecture. It contains all classes that offer an abstraction of the data that can be changed the Controller.

o Item.java:Thisclassprovidesaruntimeabstractionofaproductfoundinthedatabase.It provides the following attributes.

▪ id: the unique Id of the item (i.e. product) as is in the database
▪ name: the name of the item as is in the database
▪ availableQuantity: the available quantity of the item as it currently is
▪ price: the unit price of the item as is in the database
▪ state: the current state of the item. The Item class references through this attribute an

ItemState class which denotes the state the item is in at any given moment. An Item can reference an InStockState, a LowStockState, and an OutOfStockState class. These classes along with the Item class implement the State design pattern.

▪ viewers: this attribute is a list of viewers which need to be notified through the method notifyViewers.

In addition to the accessor and mutator methods, the Item class provides the addViewer, removeViewer, and notifyViewers methods. These methods along with the Viewers and the Item implement the Observer design pattern.

o ItemRepository.java:Thisclassprovidesaruntimeabstractionofaproductsretrievedsofar.It has a hash map called savedItems that maps product names to Item objects, and has a reference to the DataManager in the ca.uwo.dataAccess package to have access to back-end database operations (see ca.uwo.dataAccess package). The class offers the replenishItemStock and depleteItemStock methods that access the DataManager which in turn accesses the database and performs the database operations (e.g. an update on a database table entry). The ItemRepository is implemented as a singleton.

• ca.uwo.model.item.states package: This package is a module that holds the different states a product can be in. Each item state implements the State design pattern. An item state is referenced by the Item.java class (see above).

o ItemState.java:ThisclassprovidestheinterfaceforallItemStatesimplementedbythe InStockState, a LowStockState, and an OutOfStockState classes. It provides the deplete and the replentish operations that hold the mechanics of removing or adding new products (i.e. changing the stock state, returning the result using the ItemResult class etc.).

o ItemStateFactory.java:ThisclassimplementstheFactorydesignpattern.Itprovidesamethod create which uses the value of its parameter to create an object of type ItemState.

o InStockState.java:Providesthelogicofthedepleteandreplenishmethodswhentheitemis considered as “in stock” (i.e. has available quantities in the warehouse).

o LowStockState.java:Providesthelogicofthedepleteandreplenishmethodswhentheitemis considered as “low stock” (i.e. there are less than 10 available items in the warehouse).

o OutOfStockState.java:Providesthelogicofthedepleteandreplenishmethodswhentheitemis considered as “out of stock” (i.e. the quantity of the available items is 0) (relate to Item.java constructor).

• ca.uwo.pricingStrategies.aggregate package: This package is a module that contains the strategies for computing the final price for the whole order (all products and their quantities included in the order).

o AggregatePricingStrategy.java:Providestheinterfaceforallaggregatepricingstrategies. Specifies the calculateTotal method.

o AggregatePricingStrategyFactory.java: This class implements the Factory design pattern which creates the appropriate aggregate pricing strategy depending the parameter passed on the create method defined in this factory class.

o AggregateDefaultPricingStrategy.java: This class implements the default aggregate pricing strategy which just adds the price for each ordered product that is included in the whole order (note an order may be composed of orders of individual products).

oTestAggregatePricingStrategy.java:Thisclassimplementsatestaggregatepricingstrategywhich just provides a 10% discount on the price of the whole order (note an order may be composed of orders of individual products).

oAggregatePricingStrategyRepo.java:Thisclassprovidesanabstractionforallavailableaggregate pricing strategies as these are specified in the aggr_pricing_strategy_file file (see the constructor of the AggregatePricingStrategyRepo class.

The aggregate pricing strategy is used by the calculateInvoiceTotal method in the Invoice.java class

• ca.uwo.pricingStrategies.individual package: This package is a module that contains the strategies for computing the price for the individual product in an order. It has the dual structure as the aggregate pricing package above.

• ca.uwo.proxies package: This package is a module that contains the different Proxy classes of the system. The Proxy classes implement the FacadeCommands interface and inherit from the Proxy abstract class. All proxies are singletons (i.e. implement the Singleton design pattern).

o Proxy.java: This is an abstract class from which all other proxy classes (see below) inherit from.

o WelcomeProxy.java: This is the first proxy that accepts external client-side requests (see also the
ca.uwo.client package). The WelcomeProxy is the first element of a sequence of chained proxies. These chained proxies collectively implement the Chain of Responsibility design pattern. The proxy which is next to the WelcomeProxy in the sequence of chained proxies is the SupplierProxy which is referenced by the next attribute of the WelcomeProxy.

o SupplierProxy.java:Thisclassimplementsthelogicoftherestockoperationbyforwardingthe
request to the restock operation of the Facade. If the request is a placeOrder operation request then it forwards the request to the next proxy in the sequence (i.e. the LowQuantityProxy) .

o LowQuantityProxy.java.ThisclassimplementsthelogicoftheplaceOrderoperationby
forwarding the request to the placeOrder operation of the Facade. If the request is a placeOrder operation request and is more than 10 items then it forwards the request to the next proxy in the sequence (i.e. the HighQuantityProxy). The operation placeOrder can procced if the user is authenticated, so the LowQuantityProxy is this way is implementing the Proxy design pattern.

o HighQuantityProxy.java.ThisclassimplementsthelogicoftheplaceOrderoperationby forwarding the request to the placeOrder operation of the Facade. The operation placeOrder can procced if the user is authenticated, so the HighQuantityProxy is this way is implementing the Proxy design pattern. There is no other proxy in the sequence after the HighQuantityProxy. You are free to change this order and implement your own proxies.

• ca.uwo.utils package: This package is a module that hosts a number of utility classes.

o Invoice.java:Thisclassholdsthedetailsofaninvoice(amount,breakdown)andalsohasa
reference to the AggregatePricingStrategy to be used for calculating the final price for the whole order. This class also implements the calculateInvoiceTotal method. The class along with the AggregatePricingStrategy class implement the Strategy design pattern.

o Order.java:Thisclassholdsthedetailsofanorder,thatistheclient’sname,thelistofitems being included in this order, and a reference to the invoice.

o OrderItem.java:Thisclassholdsthedetailsofanindividualitemthatispartofanorder.Itholds details such as the item name, the quantity of the item in the order, and the price that is to be computed by the associated to this class IndividualPricingStrategy referenced by the pricingStrategy field. In this respect, the class OrderItem along with the class IndividualPricingStrategy implement the Strategy design pattern. This class references an ItemResult object via its itemResult attribute.

o ItemResult.java:Thisclassrepresentsholdstheinformationabouttheresultofadepleteor replenish operation as these are implemented in the InStockState, OutOfStockState, and LowStockState classes. This class holds also the response code of the operation as ResponseCode.Not_Completed or ResponseCode.Completed (see InStockState, OutOfStockState, and LowStockState classes) and a message to be displayed.

oResponseCode.java.Thisisanenumerationofpossibleresponsecodesthatcanbeproducedasa result of the deplete or replenish operations as these are implemented in the InStockState, OutOfStockState, and LowStockState classes.

• ca.uwo.viewer package: This package holds the classes that need be notified when the model changes implementing thus the View part of the Model-View-Controller architectural style.

o Viewer.java:Thisisanabstractclassfromwhichallviewerswillinherit.Inspecifiestheabstract method inform. The viewers are informed (i.e. notified) by the Model component.

o StockManager.java:ThisclassacceptsisinformedbytheModel(seemethodnotifyViewersin the Item.java class which calls the inform method in each viewer associated with the Item). The inform method here calculates the quantity of the items to be restocked using the appropriate strategy, and attaches it to a HashMap that associates the item name with the restock quantity.

In a separate thread the class runs in an infinite loop the method order.

o Messenger.java:Thisisatestclassforwhichitsinformmethodjustprintsamessage.

• ca.uwo.viewer.restockstrategies package: This package holds all classes that relate to the restocking strategies.

o RestockStrategy.java:ThisisaninterfacethatspecifiesthemethodcalculateQuantitythatis implemented in the other classes of the package.

oUnits50RestockStrategy.java:Thisisastrategythatalwaysrestocksanitemwith50newunitsby implementing the calculateQuantity method.

o WeirdRestockStrategy.java:Thisisastrategythatalwaysrestocksappleswith500newitems, otherwise with so many items as twice the product of remaining quantity+1 multiplied by the unit price of the item!

oRestockStrategyFactory.java:ThisisafactorythatgeneratesRestockStrategyobjectsusingthe Factory design pattern. It uses the method create to generate different types of RestockStrategy objects depending the parameter passed in the create method.

driver_file (structure)
<buyerID> <item> <quantity> <item> <quantity> ... .....
StrategyChange <restock strategy name>
....
<buyerID> <item> <quantity> <item> <quantity> ...
buyer_file (structure)
<buyer name> <buyerID> <buyer name> <buyerID> ...
indiv_pricing_strategy_file (structure)
<item name> <individual pricing strategy name> <item name> <individual pricing strategy name> ...
aggr_pricing_strategy_file (structure)
<Buyer name> <aggregate pricing strategy name> <Buyer name> <aggregate pricing strategy name> ...

3. How to Run the System
Run the Driver class (its main) as a java application from Eclipse.

The system will execute the orders specified in the driver_file

Once the system starts printing constantly in the console the message
Stockmanager looking for potential orders... Wait for orders to accumulate... Stockmanager looking for potential orders... Wait for orders to accumulate...

You can terminate the process.

4. Use Cases for Project 1
For the first deliverable you can consider the following use cases:

UC1: A user sends a placeOrder request to the system (i.e. the Welcome Proxy). The user needs to be authenticated. If the user is authenticated then his/her request is handled by the back-end system. Consider that there is a database with user credentials. The users can be authenticated using user name and password or just a PIN. In special cases can be authenticated by calling an agent on the phone.

5. Tasks for Project 1

Part B.
Implement the following:
I1. The appropriate proxies. Make sure you implement the Chain of Responsibility design pattern and the Proxy design pattern.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

package ca.uwo.dataAccess;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import ca.uwo.model.Item;

/**
* @author
* This class is responsible for the data persistence, i.e., database connection, updates, etc.
*/
public class DataManager {
private static DataManager instance = null;

private Connection conn;

/**
* connect to sqlite database, prints the error message if failed.
*/
public void connect() {
       conn = null;
       try {
            // db parameters
            String url = "jdbc:sqlite:warehouse.db";
            // create a connection to the database
            conn = DriverManager.getConnection(url);
            
            System.out.println("Connection to SQLite has been established.");
            
       } catch (SQLException e) {
            System.out.println(e.getMessage());
       }
    }

/**
* create a new database.
*/
public void createNewDatabase() {

if (conn != null) {
DatabaseMetaData meta;
try {
meta = conn.getMetaData();
System.out.println("The driver name is " + meta.getDriverName());
            System.out.println("A new database has been created.");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}...
$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats