View Javadoc

1   /*
2    * RFQData.java Created @ Jul 7, 2004
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  
14  package org.gscg.singleuser.interactionlayer.dataobjects.content;
15  
16  import java.io.Serializable;
17  
18  import javax.vecmath.Point2d;
19  
20  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
21  import nl.tudelft.simulation.supplychain.actor.Trader;
22  import nl.tudelft.simulation.supplychain.content.RequestForQuote;
23  import nl.tudelft.simulation.supplychain.transport.TransportMode;
24  
25  import org.gscg.common.geo.CalculateLatLonDistance;
26  import org.gscg.singleuser.interactionlayer.dataobjects.DateIntData;
27  
28  /***
29   * Contains data for a request for quote. This object is send to a client-side
30   * graphical user interface and is used to update information related to a
31   * request for quote.
32   * <p>
33   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
34   * Delft, the Netherlands. All rights reserved.
35   * 
36   * See for project information <a href="http://www.simulation.tudelft.nl/">
37   * www.simulation.tudelft.nl </a>.
38   * 
39   * The source code and binary code of this software is proprietary information
40   * of Delft University of Technology.
41   * 
42   * @author <a
43   *         href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
44   *         van Houten </a>
45   * @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:55 $
46   * @since 1.0.0
47   */
48  public class RFQData extends ContentData
49  {
50  	/*** the serial version uid */
51  	private static final long serialVersionUID = 11L;
52  
53  	/*** the identifier of the rfq this data belongs to */
54  	private Serializable internalDemandIdentifier = null;
55  
56  	/*** the earliest delivery */
57  	private DateIntData earliestDelivery = null;
58  
59  	/*** the latest delivery */
60  	private DateIntData latestDelivery = null;
61  
62  	/*** the cut off date (the before which one should respond) */
63  	private DateIntData cutOffDate = null;
64  
65  	/*** the amount */
66  	private double amount = 0;
67  
68  	/*** the unit price for the product */
69  	private double unitPrice = 0.0;
70  
71  	/*** the distance between the two actors in kilometres */
72  	private double distanceInKilometres = 0.0;
73  
74  	/*** the unit weight */
75  	private double unitWeight = 0.0;
76  
77  	/*** the transport mode */
78  	private TransportMode transPortMode = null;
79  
80  	/*** the product name */
81  	private String productName = null;
82  
83  	/***
84  	 * @param rfq the request for quote
85  	 * @param simulator the simulator
86  	 */
87  	public RFQData(final RequestForQuote rfq, final SimulatorInterface simulator)
88  	{
89  		super(rfq.getSender().getName(), rfq.getSender()
90  				.getLocationDescription(), rfq.getReceiver().getName(), rfq
91  				.getReceiver().getLocationDescription());
92  		// we set the unit price
93  		this.unitPrice = ((Trader) rfq.getReceiver()).getStock().getUnitPrice(
94  				rfq.getProduct());
95  
96  		this.internalDemandIdentifier = rfq.getInternalDemandID();
97  		this.earliestDelivery = DateIntData.makeDateIntData(rfq
98  				.getEarliestDeliveryDate(), simulator);
99  		this.latestDelivery = DateIntData.makeDateIntData(rfq
100 				.getLatestDeliveryDate(), simulator);
101 		this.cutOffDate = DateIntData.makeDateIntData(rfq.getCutoffDate(),
102 				simulator);
103 
104 		this.amount = rfq.getAmount();
105 		this.productName = rfq.getProduct().getName();
106 
107 		// the distance
108 		this.distanceInKilometres = new CalculateLatLonDistance().getDistance(
109 				new Point2d(rfq.getSender().getLocation().x, rfq.getSender()
110 						.getLocation().y), new Point2d(rfq.getReceiver()
111 						.getLocation().x, rfq.getReceiver().getLocation().y));
112 		this.unitWeight = rfq.getProduct().getAverageUnitWeight();
113 		this.transPortMode = TransportMode.PLANE;
114 	}
115 
116 	/***
117 	 * @return Returns the amount.
118 	 */
119 	public double getAmount()
120 	{
121 		return this.amount;
122 	}
123 
124 	/***
125 	 * @return Returns the earliestDelivery.
126 	 */
127 	public DateIntData getEarliestDelivery()
128 	{
129 		return this.earliestDelivery;
130 	}
131 
132 	/***
133 	 * @return Returns the latestDelivery.
134 	 */
135 	public DateIntData getLatestDelivery()
136 	{
137 		return this.latestDelivery;
138 	}
139 
140 	/***
141 	 * @return returns the cut off date
142 	 */
143 	public DateIntData getCutOffDate()
144 	{
145 		return this.cutOffDate;
146 	}
147 
148 	/***
149 	 * @return Returns the productName.
150 	 */
151 	public String getProductName()
152 	{
153 		return this.productName;
154 	}
155 
156 	/***
157 	 * @return Returns the rfqIdentifier.
158 	 */
159 	public Serializable getInternalDemandIdentifier()
160 	{
161 		return this.internalDemandIdentifier;
162 	}
163 
164 	/***
165 	 * @return returns the unit weight
166 	 */
167 	public double getUnitWeight()
168 	{
169 		return this.unitWeight;
170 	}
171 
172 	/***
173 	 * @see java.lang.Object#toString()
174 	 */
175 	public String toString()
176 	{
177 		return this.internalDemandIdentifier.toString();
178 	}
179 
180 	/***
181 	 * @return Returns the current unit price of the product
182 	 */
183 	public double getUnitPrice()
184 	{
185 		return this.unitPrice;
186 	}
187 
188 	/***
189 	 * @return Returns the transport mode
190 	 */
191 	public TransportMode getTransPortMode()
192 	{
193 		return this.transPortMode;
194 	}
195 
196 	/***
197 	 * @return Returns the distance in kilometres
198 	 */
199 	public double getDistanceInKilometres()
200 	{
201 		return this.distanceInKilometres;
202 	}
203 }