ItEr56S09RFAspectosGraficosRecursoLimitantesItEr55S11: Removed children elements if LimitingResource Queues
This commit is contained in:
parent
b58750d830
commit
47853c5934
9 changed files with 37 additions and 150 deletions
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
package org.zkoss.ganttz.data.limitingresource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -32,25 +30,21 @@ import org.zkoss.ganttz.util.Interval;
|
|||
|
||||
public class LimitingResourceQueue {
|
||||
|
||||
private final String conceptName;
|
||||
private final List<QueueTask> loadPeriods;
|
||||
private final String resourcetName;
|
||||
private final List<QueueTask> queueTask;
|
||||
|
||||
private final TimeLineRole<?> timeLineRole;
|
||||
private final String type;
|
||||
|
||||
private final List<LimitingResourceQueue> children;
|
||||
|
||||
public LimitingResourceQueue(String conceptName,
|
||||
List<QueueTask> loadPeriods,
|
||||
TimeLineRole<?> role) {
|
||||
Validate.notEmpty(conceptName);
|
||||
Validate.notNull(loadPeriods);
|
||||
this.loadPeriods = QueueTask.sort(loadPeriods);
|
||||
this.conceptName = conceptName;
|
||||
this.queueTask = QueueTask.sort(loadPeriods);
|
||||
this.resourcetName = conceptName;
|
||||
this.type = "";
|
||||
this.timeLineRole = role;
|
||||
this.children = Collections
|
||||
.unmodifiableList(new ArrayList<LimitingResourceQueue>());
|
||||
}
|
||||
|
||||
public LimitingResourceQueue(String conceptName,
|
||||
|
|
@ -58,34 +52,27 @@ public class LimitingResourceQueue {
|
|||
String type, TimeLineRole<?> role) {
|
||||
Validate.notEmpty(conceptName);
|
||||
Validate.notNull(loadPeriods);
|
||||
this.loadPeriods = QueueTask.sort(loadPeriods);
|
||||
this.conceptName = conceptName;
|
||||
this.queueTask = QueueTask.sort(loadPeriods);
|
||||
this.resourcetName = conceptName;
|
||||
this.timeLineRole = role;
|
||||
this.type = type;
|
||||
this.children = Collections
|
||||
.unmodifiableList(new ArrayList<LimitingResourceQueue>());
|
||||
}
|
||||
|
||||
public LimitingResourceQueue(LimitingResourceQueue principal, List<LimitingResourceQueue> children) {
|
||||
Validate.notEmpty(principal.getConceptName());
|
||||
public LimitingResourceQueue(LimitingResourceQueue principal) {
|
||||
Validate.notEmpty(principal.getResourceName());
|
||||
Validate.notNull(principal.getQueueTasks());
|
||||
this.loadPeriods = QueueTask.sort(principal.getQueueTasks());
|
||||
this.conceptName = principal.getConceptName();
|
||||
this.queueTask = QueueTask.sort(principal.getQueueTasks());
|
||||
this.resourcetName = principal.getResourceName();
|
||||
this.timeLineRole = principal.getRole();
|
||||
this.type = principal.getType();
|
||||
Validate.notNull(children);
|
||||
allChildrenAreNotEmpty(children);
|
||||
this.children = Collections
|
||||
.unmodifiableList(new ArrayList<LimitingResourceQueue>(children));
|
||||
|
||||
}
|
||||
|
||||
public List<QueueTask> getQueueTasks() {
|
||||
return loadPeriods;
|
||||
return queueTask;
|
||||
}
|
||||
|
||||
public String getConceptName() {
|
||||
return conceptName;
|
||||
public String getResourceName() {
|
||||
return resourcetName;
|
||||
}
|
||||
|
||||
public TimeLineRole<?> getRole() {
|
||||
|
|
@ -93,11 +80,11 @@ public class LimitingResourceQueue {
|
|||
}
|
||||
|
||||
private QueueTask getFirst() {
|
||||
return loadPeriods.get(0);
|
||||
return queueTask.get(0);
|
||||
}
|
||||
|
||||
private QueueTask getLast() {
|
||||
return loadPeriods.get(loadPeriods.size() - 1);
|
||||
return queueTask.get(queueTask.size() - 1);
|
||||
}
|
||||
|
||||
public LocalDate getStartPeriod() {
|
||||
|
|
@ -108,7 +95,7 @@ public class LimitingResourceQueue {
|
|||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return loadPeriods.isEmpty();
|
||||
return queueTask.isEmpty();
|
||||
}
|
||||
|
||||
public LocalDate getEndPeriod() {
|
||||
|
|
@ -159,55 +146,12 @@ public class LimitingResourceQueue {
|
|||
return one.compareTo(other) < 0 ? one : other;
|
||||
}
|
||||
|
||||
private static void allChildrenAreNotEmpty(List<LimitingResourceQueue> lines) {
|
||||
for (LimitingResourceQueue l : lines) {
|
||||
if (l.isEmpty()) {
|
||||
throw new IllegalArgumentException(l + " is empty");
|
||||
}
|
||||
if (l.hasChildren()) {
|
||||
allChildrenAreNotEmpty(l.getChildren());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasChildren() {
|
||||
return (!children.isEmpty());
|
||||
}
|
||||
|
||||
public List<LimitingResourceQueue> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public List<LimitingResourceQueue> getAllChildren() {
|
||||
List<LimitingResourceQueue> result = new ArrayList<LimitingResourceQueue>();
|
||||
for (LimitingResourceQueue child : children) {
|
||||
result.addAll(child.getAllChildren());
|
||||
result.add(child);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public LocalDate getStart() {
|
||||
LocalDate result = getStartPeriod();
|
||||
for (LimitingResourceQueue loadTimeLine : getChildren()) {
|
||||
LocalDate start = loadTimeLine.getStart();
|
||||
if (start != null) {
|
||||
result = result == null || result.compareTo(start) > 0 ? start
|
||||
: result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return getStartPeriod();
|
||||
}
|
||||
|
||||
public LocalDate getEnd() {
|
||||
LocalDate result = getEndPeriod();
|
||||
for (LimitingResourceQueue loadTimeLine : getChildren()) {
|
||||
LocalDate end = loadTimeLine.getEnd();
|
||||
if (end != null) {
|
||||
result = result == null || result.compareTo(end) < 0 ? end : result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return getEndPeriod();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class LimitingResourcesComponent extends XulElement {
|
|||
}
|
||||
|
||||
public String getResourceLoadName() {
|
||||
return loadLine.getConceptName();
|
||||
return loadLine.getResourceName();
|
||||
}
|
||||
|
||||
public String getResourceLoadType() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
package org.zkoss.ganttz.limitingresources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -32,7 +31,6 @@ import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener;
|
|||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.MutableTreeModel;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
||||
|
|
@ -87,17 +85,13 @@ public class LimitingResourcesList extends HtmlMacroComponent implements
|
|||
List<LimitingResourceQueue> children) {
|
||||
for (LimitingResourceQueue LimitingResourceQueue : children) {
|
||||
LimitingResourcesComponent component = LimitingResourcesComponent
|
||||
.create(
|
||||
timetracker, LimitingResourceQueue);
|
||||
.create(timetracker, LimitingResourceQueue);
|
||||
appendChild(component);
|
||||
fromTimeLineToComponent.put(LimitingResourceQueue, component);
|
||||
}
|
||||
}
|
||||
|
||||
public void collapse(LimitingResourceQueue line) {
|
||||
for (LimitingResourceQueue l : line.getAllChildren()) {
|
||||
getComponentFor(l).detach();
|
||||
}
|
||||
}
|
||||
|
||||
private LimitingResourcesComponent getComponentFor(LimitingResourceQueue l) {
|
||||
|
|
@ -108,25 +102,6 @@ timetracker, LimitingResourceQueue);
|
|||
|
||||
public void expand(LimitingResourceQueue line,
|
||||
List<LimitingResourceQueue> closed) {
|
||||
LimitingResourcesComponent parentComponent = getComponentFor(line);
|
||||
Component nextSibling = parentComponent.getNextSibling();
|
||||
|
||||
List<LimitingResourceQueue> childrenToOpen = getChildrenReverseOrderFor(line);
|
||||
childrenToOpen.removeAll(closed);
|
||||
|
||||
for (LimitingResourceQueue LimitingResourceQueue : childrenToOpen) {
|
||||
LimitingResourcesComponent child = getComponentFor(LimitingResourceQueue);
|
||||
insertBefore(child, nextSibling);
|
||||
nextSibling = child;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<LimitingResourceQueue> getChildrenReverseOrderFor(
|
||||
LimitingResourceQueue line) {
|
||||
List<LimitingResourceQueue> childrenOf = line.getAllChildren();
|
||||
Collections.reverse(childrenOf);
|
||||
return childrenOf;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -195,25 +195,11 @@ public class LimitingResourcesPanel extends HtmlMacroComponent {
|
|||
.create(LimitingResourceQueue.class);
|
||||
for (LimitingResourceQueue LimitingResourceQueue : this.groups) {
|
||||
result.addToRoot(LimitingResourceQueue);
|
||||
result = addNodes(result, LimitingResourceQueue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private MutableTreeModel<LimitingResourceQueue> addNodes(
|
||||
MutableTreeModel<LimitingResourceQueue> tree,
|
||||
LimitingResourceQueue parent) {
|
||||
if (!parent.getChildren().isEmpty()) {
|
||||
tree.add(parent, parent.getChildren());
|
||||
for (LimitingResourceQueue LimitingResourceQueue : parent
|
||||
.getChildren()) {
|
||||
tree = addNodes(tree, LimitingResourceQueue);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
private TimeTrackerComponent timeTrackerForResourcesLoadPanel(
|
||||
TimeTracker timeTracker) {
|
||||
return new TimeTrackerComponent(timeTracker) {
|
||||
|
|
|
|||
|
|
@ -49,12 +49,6 @@
|
|||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<component-name>LimitingResourcesPanel</component-name>
|
||||
<component-class>org.zkoss.ganttz.limitingresources.LimitingResourcesPanel</component-class>
|
||||
<macro-uri>~./ganttz/zul/limitingResourcesLayout.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>LimitingResourcesList</component-name>
|
||||
<component-class>org.zkoss.ganttz.limitingresources.LimitingResourcesList</component-class>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import org.navalplanner.business.orders.daos.IOrderElementDAO;
|
|||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.planner.daos.IResourceAllocationDAO;
|
||||
import org.navalplanner.business.planner.daos.ITaskElementDAO;
|
||||
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
|
||||
|
|
@ -84,9 +83,6 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
@Autowired
|
||||
private ITaskElementDAO taskElementDAO;
|
||||
|
||||
@Autowired
|
||||
private IResourceAllocationDAO resourceAllocationDAO;
|
||||
|
||||
|
|
@ -173,27 +169,6 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
private Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion() {
|
||||
if (filter()) {
|
||||
List<Criterion> criterions = new ArrayList<Criterion>();
|
||||
List<GenericResourceAllocation> generics = new ArrayList<GenericResourceAllocation>();
|
||||
List<Task> tasks = justTasks(filterBy
|
||||
.getAllChildrenAssociatedTaskElements());
|
||||
for (Task task : tasks) {
|
||||
|
||||
List<ResourceAllocation<?>> listAllocations = new ArrayList<ResourceAllocation<?>>(
|
||||
task.getSatisfiedResourceAllocations());
|
||||
for (GenericResourceAllocation generic : (onlyGeneric(listAllocations))) {
|
||||
criterions.addAll(generic.getCriterions());
|
||||
}
|
||||
}
|
||||
return resourceAllocationDAO
|
||||
.findGenericAllocationsBySomeCriterion(criterions);
|
||||
} else {
|
||||
return resourceAllocationDAO.findGenericAllocationsByCriterion();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Resource> resourcesToShow() {
|
||||
if (filter()) {
|
||||
return resourcesForActiveTasks();
|
||||
|
|
@ -234,7 +209,7 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
List<LimitingResourceQueue> result = new ArrayList<LimitingResourceQueue>();
|
||||
for (Resource resource : allResources) {
|
||||
LimitingResourceQueue group = buildGroup(resource);
|
||||
if (!group.isEmpty()) {
|
||||
if (false || !group.isEmpty()) {
|
||||
result.add(group);
|
||||
}
|
||||
}
|
||||
|
|
@ -245,11 +220,17 @@ public class LimitingResourceQueueModel implements ILimitingResourceQueueModel {
|
|||
List<ResourceAllocation<?>> sortedByStartDate = ResourceAllocation
|
||||
.sortedByStartDate(resourceAllocationDAO
|
||||
.findAllocationsRelatedTo(resource));
|
||||
|
||||
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(resource);
|
||||
|
||||
// Create ganttzk limitingResourceQueues
|
||||
LimitingResourceQueue result = new LimitingResourceQueue(buildTimeLine(
|
||||
resource, resource.getShortDescription(), sortedByStartDate,
|
||||
"resource", role),
|
||||
buildSecondLevel(resource, sortedByStartDate));
|
||||
"resource", role));
|
||||
|
||||
System.out.println("Allocations " + resource.getName() + " - "
|
||||
+ sortedByStartDate.size() + result.getResourceName());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class LimitingResourcesController implements Composer {
|
|||
@Override
|
||||
public void doAfterCompose(org.zkoss.zk.ui.Component comp) throws Exception {
|
||||
this.parent = comp;
|
||||
reload();
|
||||
// reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
|
|
|
|||
|
|
@ -82,4 +82,11 @@
|
|||
<macro-uri>/common/components/templateFinder.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>LimitingResourcesPanel</component-name>
|
||||
<component-class>org.zkoss.ganttz.limitingresources.LimitingResourcesPanel</component-class>
|
||||
<macro-uri>/limitingresources/limitingResourcesLayout.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
|
||||
</language-addon>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue