ItEr54S12CUVistaRecursosTempoPorProxectoItEr53S14: Adds link to resource allocation from the resource load screen.

This commit is contained in:
Susana Montes Pedreira 2010-04-16 14:43:03 +02:00 committed by Javier Moran Rua
parent caad232fe9
commit e510a566fe
20 changed files with 520 additions and 37 deletions

View file

@ -84,6 +84,10 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
return fromDomainToTask.get(domainObject); return fromDomainToTask.get(domainObject);
} }
public Map<T, Task> getMapDomainToTask() {
return fromDomainToTask;
}
/** /**
* @param insertionPositionForTop * @param insertionPositionForTop
* the position in which to insert the task at the top level, * the position in which to insert the task at the top level,

View file

@ -20,6 +20,8 @@
package org.zkoss.ganttz.adapters; package org.zkoss.ganttz.adapters;
import java.util.Map;
import org.zkoss.ganttz.data.Position; import org.zkoss.ganttz.data.Position;
import org.zkoss.ganttz.data.Task; import org.zkoss.ganttz.data.Task;
@ -60,4 +62,5 @@ public interface IDomainAndBeansMapper<T> {
*/ */
Task findAssociatedBean(T domainObject) throws IllegalArgumentException; Task findAssociatedBean(T domainObject) throws IllegalArgumentException;
public Map<T, Task> getMapDomainToTask();
} }

View file

@ -34,26 +34,30 @@ public class LoadTimeLine {
private final String conceptName; private final String conceptName;
private final List<LoadPeriod> loadPeriods; private final List<LoadPeriod> loadPeriods;
private final TimeLineRole<?> timeLineRole;
private final String type; private final String type;
private final List<LoadTimeLine> children; private final List<LoadTimeLine> children;
public LoadTimeLine(String conceptName, List<LoadPeriod> loadPeriods) { public LoadTimeLine(String conceptName, List<LoadPeriod> loadPeriods,
TimeLineRole<?> role) {
Validate.notEmpty(conceptName); Validate.notEmpty(conceptName);
Validate.notNull(loadPeriods); Validate.notNull(loadPeriods);
this.loadPeriods = LoadPeriod.sort(loadPeriods); this.loadPeriods = LoadPeriod.sort(loadPeriods);
this.conceptName = conceptName; this.conceptName = conceptName;
this.type = ""; this.type = "";
this.timeLineRole = role;
this.children = Collections this.children = Collections
.unmodifiableList(new ArrayList<LoadTimeLine>()); .unmodifiableList(new ArrayList<LoadTimeLine>());
} }
public LoadTimeLine(String conceptName, List<LoadPeriod> loadPeriods, public LoadTimeLine(String conceptName, List<LoadPeriod> loadPeriods,
String type) { String type, TimeLineRole<?> role) {
Validate.notEmpty(conceptName); Validate.notEmpty(conceptName);
Validate.notNull(loadPeriods); Validate.notNull(loadPeriods);
this.loadPeriods = LoadPeriod.sort(loadPeriods); this.loadPeriods = LoadPeriod.sort(loadPeriods);
this.conceptName = conceptName; this.conceptName = conceptName;
this.timeLineRole = role;
this.type = type; this.type = type;
this.children = Collections this.children = Collections
.unmodifiableList(new ArrayList<LoadTimeLine>()); .unmodifiableList(new ArrayList<LoadTimeLine>());
@ -64,6 +68,7 @@ public class LoadTimeLine {
Validate.notNull(principal.getLoadPeriods()); Validate.notNull(principal.getLoadPeriods());
this.loadPeriods = LoadPeriod.sort(principal.getLoadPeriods()); this.loadPeriods = LoadPeriod.sort(principal.getLoadPeriods());
this.conceptName = principal.getConceptName(); this.conceptName = principal.getConceptName();
this.timeLineRole = principal.getRole();
this.type = principal.getType(); this.type = principal.getType();
Validate.notNull(children); Validate.notNull(children);
allChildrenAreNotEmpty(children); allChildrenAreNotEmpty(children);
@ -80,6 +85,10 @@ public class LoadTimeLine {
return conceptName; return conceptName;
} }
public TimeLineRole<?> getRole() {
return timeLineRole;
}
private LoadPeriod getFirst() { private LoadPeriod getFirst() {
return loadPeriods.get(0); return loadPeriods.get(0);
} }

View file

@ -0,0 +1,92 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zkoss.ganttz.data.resourceload;
import static org.zkoss.ganttz.i18n.I18nHelper._;
/**
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
*/
public class TimeLineRole<T> {
private T entity;
private TimeLineRoleEnum type;
public TimeLineRole(T entity) {
this.entity = entity;
this.type = TimeLineRoleEnum.create(getClassName(entity));
}
public boolean isVisibleScheduled() {
return type != null ? type.isVisibleScheduled() : false;
}
public T getEntity() {
return entity;
}
private String getClassName(T entity) {
return entity != null ? entity.getClass().getSimpleName() : null;
}
/**
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
*/
public enum TimeLineRoleEnum {
NONE(_("None")), WORKER(_("Worker")), ORDER(_("Order")), TASK(_("Task")) {
@Override
public boolean isVisibleScheduled() {
return true;
}
},
CRITERION(_("Criterion"));
private String name;
private TimeLineRoleEnum(String name) {
this.name = name;
}
public static TimeLineRoleEnum create(String name) {
TimeLineRoleEnum requiredTimeLineRole = TimeLineRoleEnum.NONE;
if (name != null) {
for (TimeLineRoleEnum role : TimeLineRoleEnum.values()) {
if (name.contains(role.name)) {
requiredTimeLineRole = role;
}
}
}
return requiredTimeLineRole;
}
public String toString() {
return this.name;
}
public boolean isVisibleScheduled() {
return false;
}
}
}

View file

@ -0,0 +1,29 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.zkoss.ganttz.resourceload;
import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
public interface ISeeScheduledOfListener {
public void seeScheduleOf(LoadTimeLine taskLine);
}

View file

@ -20,17 +20,22 @@
package org.zkoss.ganttz.resourceload; package org.zkoss.ganttz.resourceload;
import static org.zkoss.ganttz.i18n.I18nHelper._;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.zkoss.ganttz.data.resourceload.LoadTimeLine; import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
import org.zkoss.ganttz.util.MutableTreeModel; import org.zkoss.ganttz.util.MutableTreeModel;
import org.zkoss.ganttz.util.WeakReferencedListeners;
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlMacroComponent; import org.zkoss.zk.ui.HtmlMacroComponent;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.OpenEvent; import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zul.Button;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Label; import org.zkoss.zul.Label;
import org.zkoss.zul.Popup; import org.zkoss.zul.Popup;
@ -46,6 +51,9 @@ public class ResourceLoadLeftPane extends HtmlMacroComponent {
private MutableTreeModel<LoadTimeLine> modelForTree; private MutableTreeModel<LoadTimeLine> modelForTree;
private final ResourceLoadList resourceLoadList; private final ResourceLoadList resourceLoadList;
private WeakReferencedListeners<ISeeScheduledOfListener> scheduleListeners = WeakReferencedListeners
.create();
public ResourceLoadLeftPane( public ResourceLoadLeftPane(
MutableTreeModel<LoadTimeLine> modelForTree, MutableTreeModel<LoadTimeLine> modelForTree,
ResourceLoadList resourceLoadList) { ResourceLoadList resourceLoadList) {
@ -76,10 +84,52 @@ MutableTreeModel<LoadTimeLine> modelForTree,
item.appendChild(row); item.appendChild(row);
row.appendChild(cell); row.appendChild(cell);
cell.appendChild(component); cell.appendChild(component);
appendOperations(row, line);
collapse(line); collapse(line);
addExpandedListener(item, line); addExpandedListener(item, line);
} }
private void appendOperations(final Treerow row,
final LoadTimeLine line) {
if (line.getRole().isVisibleScheduled()) {
Treecell cell = new Treecell();
appendButtonPlan(cell, line);
row.appendChild(cell);
}
}
private void appendButtonPlan(final Treecell cell,
final LoadTimeLine taskLine) {
Button buttonPlan = new Button();
buttonPlan.setWidth("5px");
buttonPlan.setHeight("5px");
buttonPlan.setSclass("icono");
buttonPlan.setImage("/common/img/ico_planificador1.png");
buttonPlan.setHoverImage("/common/img/ico_planificador.png");
buttonPlan.setTooltiptext(_("See scheduling"));
buttonPlan.addEventListener("onClick", new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
schedule(taskLine);
}
});
cell.appendChild(buttonPlan);
}
public void schedule(final LoadTimeLine taskLine) {
scheduleListeners
.fireEvent(new IListenerNotification<ISeeScheduledOfListener>() {
@Override
public void doNotify(
ISeeScheduledOfListener listener) {
listener.seeScheduleOf(taskLine);
}
});
}
private void addExpandedListener(final Treeitem item, private void addExpandedListener(final Treeitem item,
final LoadTimeLine line) { final LoadTimeLine line) {
item.addEventListener("onOpen", new EventListener() { item.addEventListener("onOpen", new EventListener() {
@ -195,4 +245,9 @@ MutableTreeModel<LoadTimeLine> modelForTree,
parent.appendChild(result); parent.appendChild(result);
return result; return result;
} }
public void addSeeScheduledOfListener(
ISeeScheduledOfListener seeScheduledOfListener) {
scheduleListeners.addListener(seeScheduledOfListener);
}
} }

View file

@ -266,4 +266,8 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
}; };
} }
public void addSeeScheduledOfListener(
ISeeScheduledOfListener seeScheduledOfListener) {
leftPane.addSeeScheduledOfListener(seeScheduledOfListener);
}
} }

View file

@ -39,17 +39,17 @@ public class LoadTimelineTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void aLoadTimelineMustHaveANotNullName() { public void aLoadTimelineMustHaveANotNullName() {
new LoadTimeLine(null, Collections.<LoadPeriod> emptyList()); new LoadTimeLine(null, Collections.<LoadPeriod> emptyList(), null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void aLoadTimelineMustHaveANotEmptyName() { public void aLoadTimelineMustHaveANotEmptyName() {
new LoadTimeLine("", Collections.<LoadPeriod> emptyList()); new LoadTimeLine("", Collections.<LoadPeriod> emptyList(), null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void aLoadTimelineCannotHaveNullLoadPeriods() { public void aLoadTimelineCannotHaveNullLoadPeriods() {
new LoadTimeLine("bla", null); new LoadTimeLine("bla", null, null);
} }
@Test @Test
@ -63,13 +63,13 @@ public class LoadTimelineTest {
loadTimeLine = new LoadTimeLine(conceptName, Arrays loadTimeLine = new LoadTimeLine(conceptName, Arrays
.asList(new LoadPeriod(new LocalDate(2009, 10, 5), .asList(new LoadPeriod(new LocalDate(2009, 10, 5),
new LocalDate(2009, 10, 11), 100, 20, new LocalDate(2009, 10, 11), 100, 20,
new LoadLevel(20)))); new LoadLevel(20))), null);
} }
@Test @Test
public void aLoadTimelineWithZeroLoadPeriodsIsEmpty() { public void aLoadTimelineWithZeroLoadPeriodsIsEmpty() {
LoadTimeLine timeline = new LoadTimeLine("bla", Collections LoadTimeLine timeline = new LoadTimeLine("bla", Collections
.<LoadPeriod> emptyList()); .<LoadPeriod> emptyList(), null);
assertTrue(timeline.isEmpty()); assertTrue(timeline.isEmpty());
} }
@ -79,7 +79,8 @@ public class LoadTimelineTest {
new LocalDate(2009, 10, 11), 100, 20, new LoadLevel(20)); new LocalDate(2009, 10, 11), 100, 20, new LoadLevel(20));
LoadPeriod l2 = new LoadPeriod(new LocalDate(2009, 5, 3), LoadPeriod l2 = new LoadPeriod(new LocalDate(2009, 5, 3),
new LocalDate(2009, 6, 3), 100, 20, new LoadLevel(20)); new LocalDate(2009, 6, 3), 100, 20, new LoadLevel(20));
LoadTimeLine loadTimeLine = new LoadTimeLine("bla", Arrays.asList(l1, l2)); LoadTimeLine loadTimeLine = new LoadTimeLine("bla", Arrays.asList(l1,
l2), null);
List<LoadPeriod> loadPeriods = loadTimeLine.getLoadPeriods(); List<LoadPeriod> loadPeriods = loadTimeLine.getLoadPeriods();
assertThat(loadPeriods.get(0), sameInstance(l2)); assertThat(loadPeriods.get(0), sameInstance(l2));
@ -92,7 +93,7 @@ public class LoadTimelineTest {
new LocalDate(2009, 10, 11), 100, 20, new LoadLevel(20)); new LocalDate(2009, 10, 11), 100, 20, new LoadLevel(20));
LoadPeriod l2 = new LoadPeriod(new LocalDate(2009, 5, 3), LoadPeriod l2 = new LoadPeriod(new LocalDate(2009, 5, 3),
new LocalDate(2009, 10, 10), 100, 20, new LoadLevel(20)); new LocalDate(2009, 10, 10), 100, 20, new LoadLevel(20));
new LoadTimeLine("bla", Arrays.asList(l1, l2)); new LoadTimeLine("bla", Arrays.asList(l1, l2), null);
} }
} }

View file

@ -40,6 +40,7 @@ import org.navalplanner.business.materials.daos.IUnitTypeDAO;
import org.navalplanner.business.orders.daos.IHoursGroupDAO; import org.navalplanner.business.orders.daos.IHoursGroupDAO;
import org.navalplanner.business.orders.daos.IOrderDAO; import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.daos.IOrderElementDAO; import org.navalplanner.business.orders.daos.IOrderElementDAO;
import org.navalplanner.business.planner.daos.ITaskElementDAO;
import org.navalplanner.business.qualityforms.daos.IQualityFormDAO; import org.navalplanner.business.qualityforms.daos.IQualityFormDAO;
import org.navalplanner.business.resources.daos.ICriterionDAO; import org.navalplanner.business.resources.daos.ICriterionDAO;
import org.navalplanner.business.resources.daos.ICriterionSatisfactionDAO; import org.navalplanner.business.resources.daos.ICriterionSatisfactionDAO;
@ -173,6 +174,9 @@ public class Registry {
@Autowired @Autowired
private ICalendarAvailabilityDAO calendarAvailabilityDAO; private ICalendarAvailabilityDAO calendarAvailabilityDAO;
@Autowired
private ITaskElementDAO taskElementDAO;
private Registry() { private Registry() {
} }
@ -313,4 +317,9 @@ public class Registry {
public static ICalendarAvailabilityDAO getCalendarAvailabilityDAO() { public static ICalendarAvailabilityDAO getCalendarAvailabilityDAO() {
return getInstance().calendarAvailabilityDAO; return getInstance().calendarAvailabilityDAO;
} }
public static ITaskElementDAO getTaskElementDAO() {
return getInstance().taskElementDAO;
}
} }

View file

@ -24,6 +24,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import org.navalplanner.business.common.daos.IIntegrationEntityDAO; import org.navalplanner.business.common.daos.IIntegrationEntityDAO;
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.reports.dtos.OrderCostsPerResourceDTO; import org.navalplanner.business.reports.dtos.OrderCostsPerResourceDTO;
@ -75,4 +76,14 @@ public interface IOrderDAO extends IIntegrationEntityDAO<Order> {
*/ */
List<Order> getOrdersByWriteAuthorization(User user); List<Order> getOrdersByWriteAuthorization(User user);
/**
* Returns the order filtered by the name. If name is blank (whitespace,
* empty ("") or null, it throws <code>InstanceNotFoundException</code>.
* @param name
* String
* @return order Order
*/
public Order findByNameAnotherTransaction(String name)
throws InstanceNotFoundException;
} }

View file

@ -27,6 +27,7 @@ import java.util.List;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.navalplanner.business.common.daos.IntegrationEntityDAO; import org.navalplanner.business.common.daos.IntegrationEntityDAO;
@ -49,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**
* Dao for {@link Order} * Dao for {@link Order}
@ -259,4 +261,36 @@ public class OrderDAO extends IntegrationEntityDAO<Order> implements
} }
} }
@Override
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public Order findByNameAnotherTransaction(String name)
throws InstanceNotFoundException {
return findByName(name);
}
@SuppressWarnings("unchecked")
private Order findByName(String name) throws InstanceNotFoundException {
if (StringUtils.isBlank(name)) {
throw new InstanceNotFoundException(null,
getEntityClass().getName());
}
Order order = (Order) getSession().createCriteria(getEntityClass())
.add(
Restrictions.ilike("infoComponent.name", name,
MatchMode.EXACT))
.uniqueResult();
if (order == null) {
throw new InstanceNotFoundException(
name, getEntityClass().getName());
} else {
return order;
}
}
} }

View file

@ -21,6 +21,7 @@
package org.navalplanner.web.planner.order; package org.navalplanner.web.planner.order;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.TaskElement;
/** /**
* This interface allows to go to the schedule and the details of an * This interface allows to go to the schedule and the details of an
@ -30,6 +31,8 @@ import org.navalplanner.business.orders.entities.Order;
*/ */
public interface IOrderPlanningGate { public interface IOrderPlanningGate {
void goToTaskResourceAllocation(Order order, TaskElement task);
void goToScheduleOf(Order order); void goToScheduleOf(Order order);
void goToOrderDetails(Order order); void goToOrderDetails(Order order);

View file

@ -43,6 +43,8 @@ public interface IOrderPlanningModel {
Order getOrder(); Order getOrder();
PlanningState getPlanningState();
void forceLoadLabelsAndCriterionRequirements(); void forceLoadLabelsAndCriterionRequirements();
} }

View file

@ -28,6 +28,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
@ -47,8 +48,10 @@ import org.springframework.stereotype.Component;
import org.zkoss.ganttz.FilterAndParentExpandedPredicates; import org.zkoss.ganttz.FilterAndParentExpandedPredicates;
import org.zkoss.ganttz.Planner; import org.zkoss.ganttz.Planner;
import org.zkoss.ganttz.data.Task; import org.zkoss.ganttz.data.Task;
import org.zkoss.ganttz.extensions.ContextWithPlannerTask;
import org.zkoss.ganttz.extensions.ICommand; import org.zkoss.ganttz.extensions.ICommand;
import org.zkoss.ganttz.extensions.IContext; import org.zkoss.ganttz.extensions.IContext;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
import org.zkoss.ganttz.resourceload.ScriptsRequiredByResourceLoadPanel; import org.zkoss.ganttz.resourceload.ScriptsRequiredByResourceLoadPanel;
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
import org.zkoss.ganttz.util.LongOperationFeedback; import org.zkoss.ganttz.util.LongOperationFeedback;
@ -91,6 +94,8 @@ public class OrderPlanningController implements Composer {
private Order order; private Order order;
private TaskElement task;
private List<ICommand<TaskElement>> additional = new ArrayList<ICommand<TaskElement>>(); private List<ICommand<TaskElement>> additional = new ArrayList<ICommand<TaskElement>>();
private Vbox orderElementFilter; private Vbox orderElementFilter;
@ -120,6 +125,10 @@ public class OrderPlanningController implements Composer {
} }
} }
public void setShowedTask(TaskElement task) {
this.task = task;
}
public CalendarAllocationController getCalendarAllocationController() { public CalendarAllocationController getCalendarAllocationController() {
return calendarAllocationController; return calendarAllocationController;
} }
@ -158,7 +167,6 @@ public class OrderPlanningController implements Composer {
filterNameOrderElement = (Textbox) filterComponent filterNameOrderElement = (Textbox) filterComponent
.getFellow("filterNameOrderElement"); .getFellow("filterNameOrderElement");
filterComponent.setVisible(true); filterComponent.setVisible(true);
updateConfiguration(); updateConfiguration();
} }
@ -168,6 +176,7 @@ public class OrderPlanningController implements Composer {
editTaskController, calendarAllocationController, editTaskController, calendarAllocationController,
additional); additional);
planner.updateSelectedZoomLevel(); planner.updateSelectedZoomLevel();
showResorceAllocationIfIsNeeded();
} }
} }
@ -280,4 +289,35 @@ public class OrderPlanningController implements Composer {
}; };
} }
public void showResorceAllocationIfIsNeeded() {
if ((task != null) && (planner != null)) {
planner.expandAll();
Task foundTask = null;
TaskElement foundTaskElement = null;
IContext<TaskElement> context = (IContext<TaskElement>) planner
.getContext();
Map<TaskElement, Task> map = context.getMapper()
.getMapDomainToTask();
for (Entry<TaskElement, Task> entry : map.entrySet()) {
if (task.getId().equals(entry.getKey().getId())) {
foundTaskElement = entry.getKey();
foundTask = entry.getValue();
}
}
if ((foundTask != null) && (foundTaskElement != null)) {
IContextWithPlannerTask<TaskElement> contextTask = ContextWithPlannerTask
.create(context, foundTask);
this.editTaskController
.showEditFormResourceAllocation(contextTask,
foundTaskElement, model.getPlanningState());
}
}
this.task = null;
}
} }

View file

@ -1237,6 +1237,11 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
return orderReloaded; return orderReloaded;
} }
@Override
public PlanningState getPlanningState() {
return planningState;
}
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public void forceLoadLabelsAndCriterionRequirements() { public void forceLoadLabelsAndCriterionRequirements() {

View file

@ -29,6 +29,7 @@ import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement; import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.daos.ITaskElementDAO; import org.navalplanner.business.planner.daos.ITaskElementDAO;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.resources.daos.IResourceDAO; import org.navalplanner.business.resources.daos.IResourceDAO;
import org.navalplanner.web.common.entrypoints.URLHandler; import org.navalplanner.web.common.entrypoints.URLHandler;
import org.navalplanner.web.common.entrypoints.URLHandlerRegistry; import org.navalplanner.web.common.entrypoints.URLHandlerRegistry;
@ -170,8 +171,28 @@ public class MultipleTabsPlannerController implements Composer,
resourceLoadTab = ResourcesLoadTabCreator.create(mode, resourceLoadTab = ResourcesLoadTabCreator.create(mode,
resourceLoadController, upCommand(), resourceLoadController, upCommand(),
resourceLoadControllerGlobal, resourceLoadControllerGlobal, new IOrderPlanningGate() {
breadcrumbs);
@Override
public void goToScheduleOf(Order order) {
mode.goToOrderMode(order);
getTabsRegistry().show(planningTab);
}
@Override
public void goToOrderDetails(Order order) {
// it do nothing
}
@Override
public void goToTaskResourceAllocation(Order order,
TaskElement task) {
orderPlanningController.setShowedTask(task);
mode.goToOrderMode(order);
getTabsRegistry().show(planningTab);
}
}, breadcrumbs);
ordersTab = OrdersTabCreator.create(mode, orderCRUDController, ordersTab = OrdersTabCreator.create(mode, orderCRUDController,
breadcrumbs, new IOrderPlanningGate() { breadcrumbs, new IOrderPlanningGate() {
@ -187,6 +208,11 @@ public class MultipleTabsPlannerController implements Composer,
getTabsRegistry().show(ordersTab); getTabsRegistry().show(ordersTab);
} }
@Override
public void goToTaskResourceAllocation(Order order,
TaskElement task) {
// do nothing
}
}, parameters); }, parameters);
final State<Void> typeChanged = typeChangedState(); final State<Void> typeChanged = typeChangedState();

View file

@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.web.planner.order.IOrderPlanningGate;
import org.navalplanner.web.planner.tabs.CreatedOnDemandTab.IComponentCreator; import org.navalplanner.web.planner.tabs.CreatedOnDemandTab.IComponentCreator;
import org.navalplanner.web.resourceload.ResourceLoadController; import org.navalplanner.web.resourceload.ResourceLoadController;
import org.zkoss.ganttz.extensions.ITab; import org.zkoss.ganttz.extensions.ITab;
@ -46,13 +47,17 @@ public class ResourcesLoadTabCreator {
private static final String ORDER_RESOURCE_LOAD_VIEW = _("Resources Load"); private static final String ORDER_RESOURCE_LOAD_VIEW = _("Resources Load");
private final IOrderPlanningGate orderPlanningGate;
public static ITab create(Mode mode, public static ITab create(Mode mode,
ResourceLoadController resourceLoadController, ResourceLoadController resourceLoadController,
IToolbarCommand upCommand, IToolbarCommand upCommand,
ResourceLoadController resourceLoadControllerGlobal, ResourceLoadController resourceLoadControllerGlobal,
IOrderPlanningGate orderPlanningGate,
Component breadcrumbs) { Component breadcrumbs) {
return new ResourcesLoadTabCreator(mode, resourceLoadController, return new ResourcesLoadTabCreator(mode, resourceLoadController,
upCommand, resourceLoadControllerGlobal, breadcrumbs) upCommand, resourceLoadControllerGlobal, orderPlanningGate,
breadcrumbs)
.build(); .build();
} }
@ -68,11 +73,13 @@ public class ResourcesLoadTabCreator {
ResourceLoadController resourceLoadController, ResourceLoadController resourceLoadController,
IToolbarCommand upCommand, IToolbarCommand upCommand,
ResourceLoadController resourceLoadControllerGlobal, ResourceLoadController resourceLoadControllerGlobal,
IOrderPlanningGate orderPlanningGate,
Component breadcrumbs) { Component breadcrumbs) {
this.mode = mode; this.mode = mode;
this.resourceLoadController = resourceLoadController; this.resourceLoadController = resourceLoadController;
this.upCommand = upCommand; this.upCommand = upCommand;
this.resourceLoadControllerGlobal = resourceLoadControllerGlobal; this.resourceLoadControllerGlobal = resourceLoadControllerGlobal;
this.orderPlanningGate = orderPlanningGate;
this.breadcrumbs = breadcrumbs; this.breadcrumbs = breadcrumbs;
} }
@ -110,6 +117,8 @@ public class ResourcesLoadTabCreator {
breadcrumbs.appendChild(new Label(ORDER_RESOURCE_LOAD_VIEW)); breadcrumbs.appendChild(new Label(ORDER_RESOURCE_LOAD_VIEW));
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR)); breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
Order currentOrder = mode.getOrder(); Order currentOrder = mode.getOrder();
resourceLoadController
.setPlanningControllerEntryPoints(orderPlanningGate);
resourceLoadController.filterBy(currentOrder); resourceLoadController.filterBy(currentOrder);
resourceLoadController.reload(); resourceLoadController.reload();
breadcrumbs.appendChild(new Label(currentOrder.getName())); breadcrumbs.appendChild(new Label(currentOrder.getName()));
@ -136,6 +145,8 @@ public class ResourcesLoadTabCreator {
componentCreator) { componentCreator) {
@Override @Override
protected void afterShowAction() { protected void afterShowAction() {
resourceLoadControllerGlobal
.setPlanningControllerEntryPoints(orderPlanningGate);
resourceLoadControllerGlobal.filterBy(null); resourceLoadControllerGlobal.filterBy(null);
resourceLoadControllerGlobal.reload(); resourceLoadControllerGlobal.reload();
if (breadcrumbs.getChildren() != null) { if (breadcrumbs.getChildren() != null) {

View file

@ -23,6 +23,7 @@ package org.navalplanner.web.resourceload;
import java.util.List; import java.util.List;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.TaskElement;
import org.zkoss.ganttz.data.resourceload.LoadTimeLine; import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
import org.zkoss.ganttz.util.Interval; import org.zkoss.ganttz.util.Interval;
@ -38,4 +39,8 @@ public interface IResourceLoadModel {
Interval getViewInterval(); Interval getViewInterval();
ZoomLevel calculateInitialZoomLevel(); ZoomLevel calculateInitialZoomLevel();
Order getOrderByTask(TaskElement task);
boolean userCanRead(Order order, String loginName);
} }

View file

@ -28,12 +28,17 @@ import java.util.List;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.web.planner.order.BankHolidaysMarker; import org.navalplanner.web.planner.order.BankHolidaysMarker;
import org.navalplanner.web.planner.order.IOrderPlanningGate;
import org.navalplanner.web.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
import org.zkoss.ganttz.resourceload.IFilterChangedListener; import org.zkoss.ganttz.resourceload.IFilterChangedListener;
import org.zkoss.ganttz.resourceload.ISeeScheduledOfListener;
import org.zkoss.ganttz.resourceload.ResourcesLoadPanel; import org.zkoss.ganttz.resourceload.ResourcesLoadPanel;
import org.zkoss.ganttz.resourceload.ResourcesLoadPanel.IToolbarCommand; import org.zkoss.ganttz.resourceload.ResourcesLoadPanel.IToolbarCommand;
import org.zkoss.ganttz.timetracker.TimeTracker; import org.zkoss.ganttz.timetracker.TimeTracker;
@ -65,6 +70,10 @@ public class ResourceLoadController implements Composer {
private transient IFilterChangedListener filterChangedListener; private transient IFilterChangedListener filterChangedListener;
private transient ISeeScheduledOfListener seeScheduledOfListener;
private IOrderPlanningGate planningControllerEntryPoints;
public ResourceLoadController() { public ResourceLoadController() {
} }
@ -101,8 +110,8 @@ public class ResourceLoadController implements Composer {
this.parent.appendChild(resourcesLoadPanel); this.parent.appendChild(resourcesLoadPanel);
resourcesLoadPanel.afterCompose(); resourcesLoadPanel.afterCompose();
addListeners();
addCommands(resourcesLoadPanel); addCommands(resourcesLoadPanel);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
try { try {
Messagebox Messagebox
@ -116,6 +125,7 @@ public class ResourceLoadController implements Composer {
} }
private void addListeners() { private void addListeners() {
/* Listener to filter */
filterChangedListener = new IFilterChangedListener() { filterChangedListener = new IFilterChangedListener() {
@Override @Override
@ -123,7 +133,17 @@ public class ResourceLoadController implements Composer {
onApplyFilter(filter); onApplyFilter(filter);
} }
}; };
this.resourcesLoadPanel.addFilterListener(filterChangedListener); resourcesLoadPanel.addFilterListener(filterChangedListener);
/* Listener to show the scheduling screen */
seeScheduledOfListener = new ISeeScheduledOfListener() {
@Override
public void seeScheduleOf(LoadTimeLine taskLine) {
onSeeScheduleOf(taskLine);
}
};
resourcesLoadPanel.addSeeScheduledOfListener(seeScheduledOfListener);
} }
public void onApplyFilter(boolean filterByResources) { public void onApplyFilter(boolean filterByResources) {
@ -131,7 +151,6 @@ public class ResourceLoadController implements Composer {
} }
private void addCommands(ResourcesLoadPanel resourcesLoadPanel) { private void addCommands(ResourcesLoadPanel resourcesLoadPanel) {
resourcesLoadPanel.add(commands.toArray(new IToolbarCommand[0])); resourcesLoadPanel.add(commands.toArray(new IToolbarCommand[0]));
} }
@ -150,11 +169,51 @@ public class ResourceLoadController implements Composer {
} else { } else {
resourcesLoadPanel = new ResourcesLoadPanel(resourceLoadModel resourcesLoadPanel = new ResourcesLoadPanel(resourceLoadModel
.getLoadTimeLines(), timeTracker); .getLoadTimeLines(), timeTracker);
addListeners();
} }
} }
public void filterBy(Order order) { public void filterBy(Order order) {
this.filterBy = order; this.filterBy = order;
} }
public void setPlanningControllerEntryPoints(
IOrderPlanningGate planningControllerEntryPoints) {
this.planningControllerEntryPoints = planningControllerEntryPoints;
}
public IOrderPlanningGate getPlanningControllerEntryPoints() {
return this.planningControllerEntryPoints;
}
private void onSeeScheduleOf(LoadTimeLine taskLine) {
TaskElement task = (TaskElement) taskLine.getRole().getEntity();
Order order = resourceLoadModel.getOrderByTask(task);
if (resourceLoadModel.userCanRead(order, SecurityUtils
.getSessionUserLoginName())) {
if (order.isScheduled()) {
planningControllerEntryPoints.goToTaskResourceAllocation(order,
task);
} else {
try {
Messagebox.show(_("The order has no scheduled elements"),
_("Information"), Messagebox.OK,
Messagebox.INFORMATION);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} else {
try {
Messagebox
.show(_("You don't have read access to this order"),
_("Information"), Messagebox.OK,
Messagebox.INFORMATION);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
} }

View file

@ -36,11 +36,14 @@ import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.navalplanner.business.common.BaseEntity;
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
import org.navalplanner.business.orders.daos.IOrderDAO; import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.daos.IOrderElementDAO; import org.navalplanner.business.orders.daos.IOrderElementDAO;
import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement; import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.daos.IResourceAllocationDAO; 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.GenericResourceAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation; import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
@ -50,6 +53,13 @@ import org.navalplanner.business.resources.daos.IResourceDAO;
import org.navalplanner.business.resources.entities.Criterion; import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.CriterionSatisfaction; import org.navalplanner.business.resources.entities.CriterionSatisfaction;
import org.navalplanner.business.resources.entities.Resource; import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.users.daos.IOrderAuthorizationDAO;
import org.navalplanner.business.users.daos.IUserDAO;
import org.navalplanner.business.users.entities.OrderAuthorization;
import org.navalplanner.business.users.entities.OrderAuthorizationType;
import org.navalplanner.business.users.entities.User;
import org.navalplanner.business.users.entities.UserRole;
import org.navalplanner.web.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
@ -57,6 +67,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.data.resourceload.LoadPeriod; import org.zkoss.ganttz.data.resourceload.LoadPeriod;
import org.zkoss.ganttz.data.resourceload.LoadTimeLine; import org.zkoss.ganttz.data.resourceload.LoadTimeLine;
import org.zkoss.ganttz.data.resourceload.TimeLineRole;
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
import org.zkoss.ganttz.util.Interval; import org.zkoss.ganttz.util.Interval;
@ -73,9 +84,18 @@ public class ResourceLoadModel implements IResourceLoadModel {
@Autowired @Autowired
private IOrderDAO orderDAO; private IOrderDAO orderDAO;
@Autowired
private ITaskElementDAO taskElementDAO;
@Autowired @Autowired
private IResourceAllocationDAO resourceAllocationDAO; private IResourceAllocationDAO resourceAllocationDAO;
@Autowired
private IUserDAO userDAO;
@Autowired
private IOrderAuthorizationDAO orderAuthorizationDAO;
private List<LoadTimeLine> loadTimeLines; private List<LoadTimeLine> loadTimeLines;
private Interval viewInterval; private Interval viewInterval;
@ -99,6 +119,37 @@ public class ResourceLoadModel implements IResourceLoadModel {
doGlobalView(); doGlobalView();
} }
@Override
@Transactional(readOnly = true)
public Order getOrderByTask(TaskElement task) {
return orderElementDAO
.loadOrderAvoidingProxyFor(task.getOrderElement());
}
@Override
@Transactional(readOnly = true)
public boolean userCanRead(Order order, String loginName) {
if (SecurityUtils.isUserInRole(UserRole.ROLE_READ_ALL_ORDERS)
|| SecurityUtils.isUserInRole(UserRole.ROLE_EDIT_ALL_ORDERS)) {
return true;
}
try {
User user = userDAO.findByLoginName(loginName);
for (OrderAuthorization authorization : orderAuthorizationDAO
.listByOrderUserAndItsProfiles(order, user)) {
if (authorization.getAuthorizationType() == OrderAuthorizationType.READ_AUTHORIZATION
|| authorization.getAuthorizationType() == OrderAuthorizationType.WRITE_AUTHORIZATION) {
return true;
}
}
} catch (InstanceNotFoundException e) {
// this case shouldn't happen, because it would mean that there
// isn't a logged user
// anyway, if it happenned we don't allow the user to pass
}
return false;
}
private void doGlobalView() { private void doGlobalView() {
loadTimeLines = calculateLoadTimeLines(); loadTimeLines = calculateLoadTimeLines();
if (!loadTimeLines.isEmpty()) { if (!loadTimeLines.isEmpty()) {
@ -177,6 +228,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
return resourcesDAO.list(Resource.class); return resourcesDAO.list(Resource.class);
} }
private TimeLineRole<BaseEntity> getCurrentTimeLineRole(BaseEntity entity) {
return new TimeLineRole<BaseEntity>(entity);
}
/** /**
* @param genericAllocationsByCriterion * @param genericAllocationsByCriterion
* @return * @return
@ -188,8 +243,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
.entrySet()) { .entrySet()) {
List<GenericResourceAllocation> allocations = ResourceAllocation List<GenericResourceAllocation> allocations = ResourceAllocation
.sortedByStartDate(entry.getValue()); .sortedByStartDate(entry.getValue());
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(entry
.getKey());
LoadTimeLine group = new LoadTimeLine(createPrincipal(entry LoadTimeLine group = new LoadTimeLine(createPrincipal(entry
.getKey(), allocations), buildSecondLevel(entry.getKey(), .getKey(), allocations,role), buildSecondLevel(entry.getKey(),
allocations)); allocations));
if (!group.isEmpty()) { if (!group.isEmpty()) {
result.add(group); result.add(group);
@ -236,8 +293,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
if (allocations.isEmpty()) { if (allocations.isEmpty()) {
return null; return null;
} }
LoadTimeLine group = new LoadTimeLine(buildTimeLine(criterion, LoadTimeLine group = new LoadTimeLine(buildTimeLine(criterion,
"Others ordes", allocations), buildTimeLinesGroupForOrder( "Others ordes", allocations, getCurrentTimeLineRole(null)),
buildTimeLinesGroupForOrder(
criterion, byOrder)); criterion, byOrder));
return group; return group;
} }
@ -246,8 +305,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
Map<Order, List<ResourceAllocation<?>>> byOrder) { Map<Order, List<ResourceAllocation<?>>> byOrder) {
List<LoadTimeLine> result = new ArrayList<LoadTimeLine>(); List<LoadTimeLine> result = new ArrayList<LoadTimeLine>();
for (Order order : byOrder.keySet()) { for (Order order : byOrder.keySet()) {
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(order);
result.add(new LoadTimeLine(buildTimeLine(criterion, order result.add(new LoadTimeLine(buildTimeLine(criterion, order
.getName(), byOrder.get(order)), buildTimeLinesForOrder( .getName(), byOrder.get(order), role),
buildTimeLinesForOrder(
criterion, byOrder.get(order)))); criterion, byOrder.get(order))));
} }
return result; return result;
@ -262,8 +323,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
for (Entry<Task, List<ResourceAllocation<?>>> entry : byTask.entrySet()) { for (Entry<Task, List<ResourceAllocation<?>>> entry : byTask.entrySet()) {
Task task = entry.getKey(); Task task = entry.getKey();
Set<Criterion> criterions = task.getCriterions(); Set<Criterion> criterions = task.getCriterions();
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(task);
LoadTimeLine timeLine = new LoadTimeLine(buildTimeLine(criterions, LoadTimeLine timeLine = new LoadTimeLine(buildTimeLine(criterions,
task, criterion, entry.getValue()), task, criterion, entry.getValue(), role),
buildTimeLinesForEachResource(criterion, onlyGeneric(entry buildTimeLinesForEachResource(criterion, onlyGeneric(entry
.getValue()))); .getValue())));
if (!timeLine.isEmpty()) { if (!timeLine.isEmpty()) {
@ -287,8 +349,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
.getValue(); .getValue();
String descriptionTimeLine = getDescriptionResourceWithCriterions(resource); String descriptionTimeLine = getDescriptionResourceWithCriterions(resource);
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(resource);
LoadTimeLine timeLine = buildTimeLine(resource, LoadTimeLine timeLine = buildTimeLine(resource,
descriptionTimeLine, resourceAllocations, "resource"); descriptionTimeLine, resourceAllocations, role);
if (!timeLine.isEmpty()) { if (!timeLine.isEmpty()) {
secondLevel.add(timeLine); secondLevel.add(timeLine);
} }
@ -317,9 +380,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
} }
private LoadTimeLine createPrincipal(Criterion criterion, private LoadTimeLine createPrincipal(Criterion criterion,
List<GenericResourceAllocation> orderedAllocations) { List<GenericResourceAllocation> orderedAllocations,
TimeLineRole<BaseEntity> role) {
return new LoadTimeLine(criterion.getName(), createPeriods(criterion, return new LoadTimeLine(criterion.getName(), createPeriods(criterion,
orderedAllocations), "global-generic"); orderedAllocations), "global-generic", role);
} }
private List<LoadPeriod> createPeriods(Criterion criterion, private List<LoadPeriod> createPeriods(Criterion criterion,
@ -343,8 +407,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
List<ResourceAllocation<?>> sortedByStartDate = ResourceAllocation List<ResourceAllocation<?>> sortedByStartDate = ResourceAllocation
.sortedByStartDate(resourceAllocationDAO .sortedByStartDate(resourceAllocationDAO
.findAllocationsRelatedTo(resource)); .findAllocationsRelatedTo(resource));
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(resource);
LoadTimeLine result = new LoadTimeLine(buildTimeLine(resource, resource LoadTimeLine result = new LoadTimeLine(buildTimeLine(resource, resource
.getShortDescription(), sortedByStartDate, "resource"), .getShortDescription(), sortedByStartDate, role),
buildSecondLevel(resource, sortedByStartDate)); buildSecondLevel(resource, sortedByStartDate));
return result; return result;
@ -378,8 +443,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
if (resourceAllocations.isEmpty()) { if (resourceAllocations.isEmpty()) {
return null; return null;
} }
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(null);
LoadTimeLine group = new LoadTimeLine(buildTimeLine(resource, LoadTimeLine group = new LoadTimeLine(buildTimeLine(resource,
_("Others ordes"), resourceAllocations, "resource"), _("Others ordes"), resourceAllocations, role),
buildTimeLinesGroupForOrder(resource, byOrder)); buildTimeLinesGroupForOrder(resource, byOrder));
return group; return group;
} }
@ -388,8 +454,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
Map<Order, List<ResourceAllocation<?>>> byOrder) { Map<Order, List<ResourceAllocation<?>>> byOrder) {
List<LoadTimeLine> result = new ArrayList<LoadTimeLine>(); List<LoadTimeLine> result = new ArrayList<LoadTimeLine>();
for (Order order : byOrder.keySet()) { for (Order order : byOrder.keySet()) {
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(order);
result.add(new LoadTimeLine(buildTimeLine(resource, result.add(new LoadTimeLine(buildTimeLine(resource,
order.getName(), byOrder.get(order), "resource"), order.getName(), byOrder.get(order), role),
buildTimeLinesForOrder(resource, byOrder.get(order)))); buildTimeLinesForOrder(resource, byOrder.get(order))));
} }
return result; return result;
@ -470,8 +537,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
Task task = entryTask.getKey(); Task task = entryTask.getKey();
List<GenericResourceAllocation> resouceAllocations = onlyGeneric(entryTask List<GenericResourceAllocation> resouceAllocations = onlyGeneric(entryTask
.getValue()); .getValue());
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(task);
LoadTimeLine timeLine = buildTimeLine(entry.getKey(), task, LoadTimeLine timeLine = buildTimeLine(entry.getKey(), task,
resource, resouceAllocations); resource, resouceAllocations, role);
if (!timeLine.isEmpty()) { if (!timeLine.isEmpty()) {
result.add(timeLine); result.add(timeLine);
} }
@ -492,8 +560,9 @@ public class ResourceLoadModel implements IResourceLoadModel {
List<LoadTimeLine> secondLevel = new ArrayList<LoadTimeLine>(); List<LoadTimeLine> secondLevel = new ArrayList<LoadTimeLine>();
for (Entry<Task, List<ResourceAllocation<?>>> entry : byTask.entrySet()) { for (Entry<Task, List<ResourceAllocation<?>>> entry : byTask.entrySet()) {
Task task = entry.getKey(); Task task = entry.getKey();
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(task);
LoadTimeLine timeLine = buildTimeLine(resource, task.getName(), LoadTimeLine timeLine = buildTimeLine(resource, task.getName(),
entry.getValue(), "specific"); entry.getValue(), "specific", role);
if (!timeLine.isEmpty()) { if (!timeLine.isEmpty()) {
secondLevel.add(timeLine); secondLevel.add(timeLine);
} }
@ -521,32 +590,44 @@ public class ResourceLoadModel implements IResourceLoadModel {
} }
private LoadTimeLine buildTimeLine(Resource resource, String name, private LoadTimeLine buildTimeLine(Resource resource, String name,
List<? extends ResourceAllocation<?>> sortedByStartDate, String type) { List<? extends ResourceAllocation<?>> sortedByStartDate,
TimeLineRole<BaseEntity> role) {
return new LoadTimeLine(name, PeriodsBuilder.build(LoadPeriodGenerator return new LoadTimeLine(name, PeriodsBuilder.build(LoadPeriodGenerator
.onResource(resource), sortedByStartDate), type); .onResource(resource), sortedByStartDate), role);
} }
private LoadTimeLine buildTimeLine(Criterion criterion, String name, private LoadTimeLine buildTimeLine(Criterion criterion, String name,
List<ResourceAllocation<?>> allocations) { List<ResourceAllocation<?>> allocations,
TimeLineRole<BaseEntity> role) {
List<GenericResourceAllocation> generics = onlyGeneric(allocations); List<GenericResourceAllocation> generics = onlyGeneric(allocations);
return new LoadTimeLine(name, createPeriods(criterion, generics), return new LoadTimeLine(name, createPeriods(criterion, generics),
"global-generic"); "global-generic", role);
} }
private LoadTimeLine buildTimeLine(Collection<Criterion> criterions, private LoadTimeLine buildTimeLine(Collection<Criterion> criterions,
Task task, Criterion criterion, Task task, Criterion criterion,
List<ResourceAllocation<?>> allocations) { List<ResourceAllocation<?>> allocations,
return buildTimeLine(criterion, getName(criterions, task), allocations); TimeLineRole<BaseEntity> role) {
return buildTimeLine(criterion, getName(criterions, task), allocations,
role);
}
private LoadTimeLine buildTimeLine(Resource resource, String name,
List<ResourceAllocation<?>> sortedByStartDate, String type,
TimeLineRole<BaseEntity> role) {
return new LoadTimeLine(name, PeriodsBuilder.build(LoadPeriodGenerator
.onResource(resource), sortedByStartDate), type, role);
} }
private LoadTimeLine buildTimeLine(Collection<Criterion> criterions, private LoadTimeLine buildTimeLine(Collection<Criterion> criterions,
Task task, Resource resource, Task task, Resource resource,
List<GenericResourceAllocation> allocationsSortedByStartDate) { List<GenericResourceAllocation> allocationsSortedByStartDate,
TimeLineRole<BaseEntity> role) {
LoadPeriodGeneratorFactory periodGeneratorFactory = LoadPeriodGenerator LoadPeriodGeneratorFactory periodGeneratorFactory = LoadPeriodGenerator
.onResourceSatisfying(resource, criterions); .onResourceSatisfying(resource, criterions);
return new LoadTimeLine(getName(criterions, task), PeriodsBuilder return new LoadTimeLine(getName(criterions, task), PeriodsBuilder
.build(periodGeneratorFactory, allocationsSortedByStartDate), .build(periodGeneratorFactory, allocationsSortedByStartDate),
"generic"); "generic", role);
} }
@Override @Override