BrightSide Workbench Full Report + Source Code
org.turro.financials.cart.Cart Class Reference
Inheritance diagram for org.turro.financials.cart.Cart:
Collaboration diagram for org.turro.financials.cart.Cart:

Public Member Functions

 Cart ()
 
String getResetOrder ()
 
CartItemSet getItems ()
 
String getOrder ()
 
int getStatus ()
 
void setStatus (int status)
 
boolean isWantBill ()
 
void setWantBill (boolean wantBill)
 
boolean isPickup ()
 
void setPickup (boolean pickup)
 
String getDeliveryValue ()
 
void setDeliveryValue (String deliveryValue)
 
boolean isEmpty ()
 
boolean needsDelivery ()
 
void removeDeliveryItem ()
 
boolean addDeliveryItem (long productId, double quantity, double tax, double price)
 
boolean addItem (long productId, double quantity, double tax, double price)
 
void removeItem (Integer order)
 
void changeItem (Integer order, double quantity)
 
void changeItem (Integer order, String concept)
 
CartItem getItem (Integer order)
 
Collection< CartItemgetProducts (long id)
 
double getTotalAmount ()
 
double getTotalTaxable ()
 
double getTotalTax ()
 
CartAmounts getAmounts ()
 
IContact getContact ()
 
void serializeFor (String email)
 
void serializeFor (IContact contact)
 
void serializeForOrder (IContact contact)
 
void onRegister (String email)
 
Currency getCurrency ()
 

Static Public Member Functions

static Cart deserializeFor (IContact contact)
 
static Cart deserializeForOrder (String order)
 
static void removeFor (IContact contact)
 

Additional Inherited Members

- Static Public Attributes inherited from org.turro.action.IRegisterCallback
static final String REGISTER_CALLBACK_KEY = "regcallback_"
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file Cart.java.

Constructor & Destructor Documentation

◆ Cart()

org.turro.financials.cart.Cart.Cart ( )

Definition at line 45 of file Cart.java.

45  {
46  this.items = new CartItemSet();
47  }
Here is the caller graph for this function:

Member Function Documentation

◆ addDeliveryItem()

boolean org.turro.financials.cart.Cart.addDeliveryItem ( long  productId,
double  quantity,
double  tax,
double  price 
)

Definition at line 117 of file Cart.java.

117  {
118  CartItem ci = new CartItem();
119  ci.setProductId(productId);
120  ci.setQuantity(quantity);
121  ci.setTax(tax);
122  ci.setPrice(price);
123  ci.makeValid();
124  ci.setDeliveryItem(true);
125  return items.addItem(ci);
126  }
boolean addItem(CartItem cartItem)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addItem()

boolean org.turro.financials.cart.Cart.addItem ( long  productId,
double  quantity,
double  tax,
double  price 
)

Definition at line 128 of file Cart.java.

128  {
129  setStatus(0);
130  CartItem ci = new CartItem();
131  ci.setProductId(productId);
132  ci.setQuantity(quantity);
133  ci.setTax(tax);
134  ci.setPrice(price);
135  ci.makeValid();
136  ci.setDeliveryItem(false);
137  return items.addItem(ci);
138  }
void setStatus(int status)
Definition: Cart.java:66
Here is the call graph for this function:

◆ changeItem() [1/2]

void org.turro.financials.cart.Cart.changeItem ( Integer  order,
double  quantity 
)

Definition at line 151 of file Cart.java.

151  {
152  setStatus(0);
153  Iterator<CartItem> it = items.iterator();
154  while(it.hasNext()) {
155  CartItem ci = it.next();
156  if(ci.getOrder() == order) {
157  ci.setQuantity(quantity);
158  break;
159  }
160  }
161  }
Here is the call graph for this function:

◆ changeItem() [2/2]

void org.turro.financials.cart.Cart.changeItem ( Integer  order,
String  concept 
)

Definition at line 163 of file Cart.java.

163  {
164  setStatus(0);
165  Iterator<CartItem> it = items.iterator();
166  while(it.hasNext()) {
167  CartItem ci = it.next();
168  if(ci.getOrder() == order) {
169  ci.setConcept(concept);
170  break;
171  }
172  }
173  }
Here is the call graph for this function:

◆ deserializeFor()

static Cart org.turro.financials.cart.Cart.deserializeFor ( IContact  contact)
static

Definition at line 246 of file Cart.java.

246  {
247  Cart cart = (Cart) Serializer.deserialize("/cart/" + contact.getId() + ".ser");
248  if(cart == null) {
249  String mailFile = "/cart/" + contact.getConnector(IUser.CONNECTOR_EMAIL) + ".ser";
250  cart = (Cart) Serializer.deserialize(mailFile);
251  }
252  return cart;
253  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deserializeForOrder()

static Cart org.turro.financials.cart.Cart.deserializeForOrder ( String  order)
static

Definition at line 255 of file Cart.java.

255  {
256  Cart cart = (Cart) Serializer.deserialize("/cart/" + order + ".ser");
257  Serializer.remove("/cart/" + order + ".ser");
258  return cart;
259  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAmounts()

CartAmounts org.turro.financials.cart.Cart.getAmounts ( )

Definition at line 220 of file Cart.java.

220  {
221  return new CartAmounts(this);
222  }

◆ getContact()

IContact org.turro.financials.cart.Cart.getContact ( )

Definition at line 224 of file Cart.java.

224  {
225  if(contact == null) {
226  contact = Contacts.getContactById(contactId);
227  }
228  return contact;
229  }
Here is the call graph for this function:

◆ getCurrency()

Currency org.turro.financials.cart.Cart.getCurrency ( )

Definition at line 273 of file Cart.java.

273  {
274  if(_currency == null) {
275  _currency = Currency.getInstance(ShopContext.getInstance().getCurrency());
276  }
277  return _currency;
278  }
Here is the call graph for this function:

◆ getDeliveryValue()

String org.turro.financials.cart.Cart.getDeliveryValue ( )

Definition at line 86 of file Cart.java.

86  {
87  return deliveryValue;
88  }
Here is the caller graph for this function:

◆ getItem()

CartItem org.turro.financials.cart.Cart.getItem ( Integer  order)

Definition at line 175 of file Cart.java.

175  {
176  Iterator<CartItem> it = items.iterator();
177  while(it.hasNext()) {
178  CartItem ci = it.next();
179  if(ci.getOrder() == order) {
180  return ci;
181  }
182  }
183  return null;
184  }
Here is the call graph for this function:

◆ getItems()

CartItemSet org.turro.financials.cart.Cart.getItems ( )

Definition at line 54 of file Cart.java.

54  {
55  return items;
56  }
Here is the caller graph for this function:

◆ getOrder()

String org.turro.financials.cart.Cart.getOrder ( )

Definition at line 58 of file Cart.java.

58  {
59  return order;
60  }
Here is the caller graph for this function:

◆ getProducts()

Collection<CartItem> org.turro.financials.cart.Cart.getProducts ( long  id)

Definition at line 186 of file Cart.java.

186  {
187  ArrayList<CartItem> list = new ArrayList<>();
188  for(CartItem ci : items) {
189  if(ci.getProductId() == id) {
190  list.add(ci);
191  }
192  }
193  return list;
194  }

◆ getResetOrder()

String org.turro.financials.cart.Cart.getResetOrder ( )

Definition at line 49 of file Cart.java.

49  {
50  order = IdGenerator.generateLong().substring(2, 14);
51  return order;
52  }
Here is the caller graph for this function:

◆ getStatus()

int org.turro.financials.cart.Cart.getStatus ( )

Definition at line 62 of file Cart.java.

62  {
63  return status;
64  }
Here is the caller graph for this function:

◆ getTotalAmount()

double org.turro.financials.cart.Cart.getTotalAmount ( )

Definition at line 196 of file Cart.java.

196  {
197  double value = 0.0;
198  for(CartItem ci : items) {
199  value += ci.getAmount();
200  }
201  return value;
202  }
Here is the caller graph for this function:

◆ getTotalTax()

double org.turro.financials.cart.Cart.getTotalTax ( )

Definition at line 212 of file Cart.java.

212  {
213  double value = 0.0;
214  for(CartItem ci : items) {
215  value += ci.getTaxAmount();
216  }
217  return value;
218  }

◆ getTotalTaxable()

double org.turro.financials.cart.Cart.getTotalTaxable ( )

Definition at line 204 of file Cart.java.

204  {
205  double value = 0.0;
206  for(CartItem ci : items) {
207  value += ci.getTaxable();
208  }
209  return value;
210  }

◆ isEmpty()

boolean org.turro.financials.cart.Cart.isEmpty ( )

Definition at line 94 of file Cart.java.

94  {
95  return items.isEmpty();
96  }

◆ isPickup()

boolean org.turro.financials.cart.Cart.isPickup ( )

Definition at line 78 of file Cart.java.

78  {
79  return pickup;
80  }
Here is the caller graph for this function:

◆ isWantBill()

boolean org.turro.financials.cart.Cart.isWantBill ( )

Definition at line 70 of file Cart.java.

70  {
71  return wantBill;
72  }

◆ needsDelivery()

boolean org.turro.financials.cart.Cart.needsDelivery ( )

Definition at line 98 of file Cart.java.

98  {
99  Iterator<CartItem> it = items.iterator();
100  while(it.hasNext()) {
101  if(it.next().isNeedsDelivery()) {
102  return true;
103  }
104  }
105  return false;
106  }
Here is the caller graph for this function:

◆ onRegister()

void org.turro.financials.cart.Cart.onRegister ( String  email)

Implements org.turro.action.IRegisterCallback.

Definition at line 267 of file Cart.java.

267  {
268  serializeFor(email);
269  }
void serializeFor(String email)
Definition: Cart.java:231
Here is the call graph for this function:

◆ removeDeliveryItem()

void org.turro.financials.cart.Cart.removeDeliveryItem ( )

Definition at line 108 of file Cart.java.

108  {
109  Iterator<CartItem> it = items.iterator();
110  while(it.hasNext()) {
111  if(it.next().isDeliveryItem()) {
112  it.remove();
113  }
114  }
115  }
Here is the caller graph for this function:

◆ removeFor()

static void org.turro.financials.cart.Cart.removeFor ( IContact  contact)
static

Definition at line 261 of file Cart.java.

261  {
262  Serializer.remove("/cart/" + contact.getId() + ".ser");
263  Serializer.remove("/cart/" + contact.getConnector(IUser.CONNECTOR_EMAIL) + ".ser");
264  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeItem()

void org.turro.financials.cart.Cart.removeItem ( Integer  order)

Definition at line 140 of file Cart.java.

140  {
141  setStatus(0);
142  Iterator<CartItem> it = items.iterator();
143  while(it.hasNext()) {
144  if(it.next().getOrder() == order) {
145  it.remove();
146  break;
147  }
148  }
149  }
Here is the call graph for this function:

◆ serializeFor() [1/2]

void org.turro.financials.cart.Cart.serializeFor ( IContact  contact)

Definition at line 236 of file Cart.java.

236  {
237  setStatus(0);
238  Serializer.serialize("/cart/" + contact.getId() + ".ser", this);
239  }
Here is the call graph for this function:

◆ serializeFor() [2/2]

void org.turro.financials.cart.Cart.serializeFor ( String  email)

Definition at line 231 of file Cart.java.

231  {
232  setStatus(0);
233  Serializer.serialize("/cart/" + email + ".ser", this);
234  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serializeForOrder()

void org.turro.financials.cart.Cart.serializeForOrder ( IContact  contact)

Definition at line 241 of file Cart.java.

241  {
242  contactId = contact.getId();
243  Serializer.serialize("/cart/" + getOrder() + ".ser", this);
244  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDeliveryValue()

void org.turro.financials.cart.Cart.setDeliveryValue ( String  deliveryValue)

Definition at line 90 of file Cart.java.

90  {
91  this.deliveryValue = deliveryValue;
92  }

◆ setPickup()

void org.turro.financials.cart.Cart.setPickup ( boolean  pickup)

Definition at line 82 of file Cart.java.

82  {
83  this.pickup = pickup;
84  }

◆ setStatus()

void org.turro.financials.cart.Cart.setStatus ( int  status)

Definition at line 66 of file Cart.java.

66  {
67  this.status = status;
68  }
Here is the caller graph for this function:

◆ setWantBill()

void org.turro.financials.cart.Cart.setWantBill ( boolean  wantBill)

Definition at line 74 of file Cart.java.

74  {
75  this.wantBill = wantBill;
76  }

The documentation for this class was generated from the following file: