BrightSide Workbench Full Report + Source Code
Workload.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 java.util.Date;
22 import org.turro.erp.entity.OrderItem;
23 import org.turro.erp.entity.RequiredUsage;
24 import org.turro.erp.entity.Task;
25 import org.turro.util.CompareUtil;
26 
31 public class Workload implements Comparable<Workload> {
32 
33  private RequiredUsage requiredUsage;
34  private OrderItem orderItem;
35  private Task task;
36  private boolean checked = true;
37  private double orderUnits;
38 
39  public Workload(RequiredUsage requiredUsage) {
40  this.requiredUsage = requiredUsage;
41  task = requiredUsage.getTask();
42  task.checkStatus(new Date());
43  checked = !task.isWaiting();
44  }
45 
46  public Workload(OrderItem orderItem) {
47  this.orderItem = orderItem;
48  task = orderItem.getOwnerRequiredUsage().getTask();
49  task.checkStatus(new Date());
50  checked = !task.isWaiting();
51  }
52 
54  return requiredUsage;
55  }
56 
58  return orderItem;
59  }
60 
61  public boolean isChecked() {
62  return checked;
63  }
64 
65  public void setChecked(boolean checked) {
66  this.checked = checked;
67  }
68 
69  public double getOrderUnits() {
70  return orderUnits;
71  }
72 
73  public void setOrderUnits(double orderUnits) {
74  this.orderUnits = orderUnits;
75  }
76 
77  public Task getTask() {
78  return task;
79  }
80 
81  public void setTask(Task task) {
82  this.task = task;
83  }
84 
85  @Override
86  public int compareTo(Workload o) {
87  int result = 0;
88  if(orderItem != null) {
89  result = -CompareUtil.compare(orderItem.getDocumentDate(), o.orderItem.getDocumentDate());
90  if(result == 0) {
91  result = new PendingTask(task).compareTo(new PendingTask(o.task));
92  }
93  if(result == 0) {
94  result = CompareUtil.compare(orderItem.getId(), o.orderItem.getId());
95  }
96  } else {
97  result = new PendingTask(task).compareTo(new PendingTask(o.task));
98  if(result == 0) {
99  result = CompareUtil.compare(!requiredUsage.isCanChange(), !o.requiredUsage.isCanChange());
100  }
101  if(result == 0) {
102  result = CompareUtil.compare(requiredUsage.getId(), o.requiredUsage.getId());
103  }
104  }
105  return result;
106  }
107 
108 }
RequiredUsage getOwnerRequiredUsage()
Definition: OrderItem.java:374
int compareTo(PendingTask o)
void setTask(Task task)
Definition: Workload.java:81
void setChecked(boolean checked)
Definition: Workload.java:65
void setOrderUnits(double orderUnits)
Definition: Workload.java:73
int compareTo(Workload o)
Definition: Workload.java:86
Workload(RequiredUsage requiredUsage)
Definition: Workload.java:39
Workload(OrderItem orderItem)
Definition: Workload.java:46
RequiredUsage getRequiredUsage()
Definition: Workload.java:53