BrightSide Workbench Full Report + Source Code
PredecessorClone.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 org.turro.clone.ClonedEntity;
23 import org.turro.clone.ClonedEntitySet;
24 import org.turro.erp.entity.Predecessor;
25 import org.turro.erp.entity.PredecessorType;
26 import org.turro.hierarchy.Hierarchical;
27 
32 public class PredecessorClone extends ClonedEntity<Predecessor, Long> implements Hierarchical {
33 
34  private PredecessorType type;
35  private double lag;
36  private TaskClone task;
37  private TaskClone predecessor;
38 
39  public PredecessorClone(Predecessor predecessor, ClonedEntitySet entities) {
40  super(predecessor.getId(), predecessor, entities);
41  type = predecessor.getType();
42  lag = predecessor.getLag();
43  }
44 
45  public void setTask(TaskClone task) {
46  this.task = task;
47  }
48 
49  @Override
50  protected Predecessor createClone() {
51  Predecessor pred = new Predecessor();
52  applyData(pred);
53  return pred;
54  }
55 
56  @Override
57  protected void applyData(Predecessor entity) {
58  entity.setType(type);
59  entity.setLag(lag);
60  }
61 
62  @Override
63  protected void applyChildren(Predecessor entity) {
64  }
65 
66  @Override
67  protected void assignEntities() {
68  if(predecessor == null) {
69  predecessor = new TaskClone(entity.getPredecessor(), entities);
70  } else if(getClone() != null) {
71  getClone().setPredecessor(predecessor.getClone());
72  }
73  }
74 
75  /* Hierarchical */
76 
77  @Override
78  public Collection children() {
79  return null;
80  }
81 
82  @Override
83  public Object parent() {
84  return task;
85  }
86 
87 }
PredecessorClone(Predecessor predecessor, ClonedEntitySet entities)
void applyChildren(Predecessor entity)
void setType(PredecessorType type)