BrightSide Workbench Full Report + Source Code
RequiredUsageClone.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.clone;
20 
21 import java.util.Collection;
22 import java.util.Date;
23 import org.turro.clone.ClonedEntity;
24 import org.turro.clone.ClonedEntitySet;
25 import org.turro.erp.entity.AptitudeDegree;
26 import org.turro.erp.entity.PurchaseMode;
27 import org.turro.erp.entity.RequiredUsage;
28 import org.turro.hierarchy.Hierarchical;
29 
34 public class RequiredUsageClone extends ClonedEntity<RequiredUsage, Long> implements Hierarchical {
35 
36  private double units, cost, price, dedication, purchaseLag;
37  private long providerId, providerProductId, productId, lineTypeId, contractPreferenceId, viewId;
38  private boolean providerFixed, costMaximum, canChange, representHours;
39  private String productDescription;
40  private String description;
41  private TaskClone task;
42  private org.turro.erp.entity.HumanResource humanResource;
43  private org.turro.erp.entity.Resource resource;
44  private AptitudeDegree aptitudeDegree;
45  private AptitudeDegree aptitudeAssesment;
46  private PurchaseMode purchaseMode;
47  private Date purchaseDate;
48  private TaskClone purchaseTask;
49 
50  public RequiredUsageClone(RequiredUsage requiredUsage, ClonedEntitySet entities) {
51  super(requiredUsage.getId(), requiredUsage, entities);
52  units = requiredUsage.getUnits();
53  cost = requiredUsage.getCost();
54  price = requiredUsage.getPrice();
55  dedication = requiredUsage.getDedication();
56  purchaseLag = requiredUsage.getPurchaseLag();
57  providerId = requiredUsage.getProviderId();
58  providerProductId = requiredUsage.getProviderProductId();
59  productId = requiredUsage.getProductId();
60  lineTypeId = requiredUsage.getLineTypeId();
61  contractPreferenceId = requiredUsage.getContractPreferenceId();
62  viewId = requiredUsage.getViewId();
63  providerFixed = requiredUsage.isProviderFixed();
64  costMaximum = requiredUsage.isCostMaximum();
65  canChange = requiredUsage.isCanChange();
66  representHours = requiredUsage.isRepresentHours();
67  productDescription = requiredUsage.getProductDescription();
68  description = requiredUsage.getDescription();
69  humanResource = requiredUsage.getHumanResource();
70  resource = requiredUsage.getResource();
71  aptitudeDegree = requiredUsage.getAptitudeDegree();
72  aptitudeAssesment = requiredUsage.getAptitudeAssesment();
73  purchaseMode = requiredUsage.getPurchaseMode();
74  purchaseDate = requiredUsage.getPurchaseDate();
75  }
76 
77  public void setTask(TaskClone task) {
78  this.task = task;
79  }
80 
81  public void setUnitRatio(double ratio) {
82  units = units * ratio;
83  }
84 
85  @Override
86  protected RequiredUsage createClone() {
87  RequiredUsage requiredUsage = new RequiredUsage();
88  applyData(requiredUsage);
89  return requiredUsage;
90  }
91 
92  @Override
93  protected void applyData(RequiredUsage entity) {
94  entity.setUnits(units);
95  entity.setCost(cost);
96  entity.setPrice(price);
97  entity.setDedication(dedication);
98  entity.setPurchaseLag(purchaseLag);
99  entity.setProviderId(providerId);
100  entity.setProviderProductId(providerProductId);
101  entity.setProductId(productId);
102  entity.setLineTypeId(lineTypeId);
103  entity.setContractPreferenceId(contractPreferenceId);
104  entity.setViewId(viewId);
105  entity.setProviderFixed(providerFixed);
106  entity.setCostMaximum(costMaximum);
107  entity.setCanChange(canChange);
108  entity.setRepresentHours(representHours);
109  entity.setProductDescription(productDescription);
110  entity.setDescription(description);
111  entity.setHumanResource(humanResource);
112  entity.setResource(resource);
113  entity.setAptitudeDegree(aptitudeDegree);
114  entity.setAptitudeAssesment(aptitudeAssesment);
115  entity.setPurchaseMode(purchaseMode);
116  entity.setPurchaseDate(purchaseDate);
117  }
118 
119  @Override
120  protected void applyChildren(RequiredUsage entity) {
121  }
122 
123  @Override
124  protected void assignEntities() {
125  if(purchaseTask == null) {
126  purchaseTask = new TaskClone(entity.getPurchaseTask(), entities);
127  } else if(getClone() != null) {
128  getClone().setPurchaseTask(purchaseTask.getClone());
129  }
130  }
131 
132  /* Hierarchical */
133 
134  @Override
135  public Collection children() {
136  return null;
137  }
138 
139  @Override
140  public Object parent() {
141  return task;
142  }
143 
144 }
RequiredUsageClone(RequiredUsage requiredUsage, ClonedEntitySet entities)
void setHumanResource(HumanResource resource)
void setResource(Resource resource)
void setCostMaximum(boolean costMaximum)
void setProviderFixed(boolean providerFixed)
void setPurchaseDate(Date purchaseDate)
void setPurchaseMode(PurchaseMode purchaseMode)
void setAptitudeAssesment(AptitudeDegree aptitudeAssesment)
void setProductDescription(String productDescription)
void setProviderProductId(long providerProductId)
void setProviderId(long providerId)
void setDedication(double dedication)
void setPurchaseLag(double purchaseLag)
void setDescription(String description)
void setContractPreferenceId(long contractPreferenceId)
void setAptitudeDegree(AptitudeDegree aptitudeDegree)
void setLineTypeId(long lineTypeId)
void setRepresentHours(boolean representHours)
void setCanChange(boolean canChange)