BrightSide Workbench Full Report + Source Code
WorksheetItem.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.erp.task;
20 
21 import org.turro.erp.entity.OrderItem;
22 import org.turro.erp.entity.OrderReference;
23 import org.turro.erp.entity.RequiredUsage;
24 import org.turro.erp.entity.Task;
25 import org.turro.erp.entity.WorkOrder;
26 import org.turro.util.CompareUtil;
27 
32 public class WorksheetItem extends Workload {
33 
34  private int preferredOrder;
35 
36  public WorksheetItem(OrderItem orderItem, int preferredOrder) {
37  super(orderItem);
38  this.preferredOrder = preferredOrder;
39  }
40 
41  public int getPreferredOrder() {
42  return preferredOrder;
43  }
44 
45  @Override
46  public int compareTo(Workload o) {
47  OrderItem orderItem1 = getOrderItem(),
48  orderItem2 = o.getOrderItem();
49  RequiredUsage requiredUsage1 = orderItem1.getRequiredUsage(),
50  requiredUsage2 = orderItem2.getRequiredUsage();
51  Task task1 = requiredUsage1.getTask(),
52  task2 = requiredUsage2.getTask();
53  OrderReference orderReference1 = task1.getOrderReference(),
54  orderReference2 = task2.getOrderReference();
55  WorkOrder workOrder1 = orderReference1.getWorkOrder(),
56  workOrder2 = orderReference2.getWorkOrder();
57  int result = CompareUtil.compare(workOrder1.getWorkOrderId(), workOrder2.getWorkOrderId());
58  if(result == 0) {
59  result = CompareUtil.compare(workOrder1.getId(), workOrder2.getId());
60  }
61  if(result == 0) {
62  result = CompareUtil.compare(orderReference1.getId(), orderReference2.getId());
63  }
64  if(result == 0) {
65  result = CompareUtil.compare(task1.getId(), task2.getId());
66  }
67  if(result == 0) {
68  result = CompareUtil.compare(requiredUsage1.getId(), requiredUsage2.getId());
69  }
70  if(result == 0) {
71  result = super.compareTo(o);
72  }
73  return result;
74  }
75 
76 }
RequiredUsage getRequiredUsage()
Definition: OrderItem.java:249
WorksheetItem(OrderItem orderItem, int preferredOrder)