ItEr26S07CUAsignacionGrupoRecursosAPlanificacionItEr25S07: Removing genericResourceAllocationPercentage
This commit is contained in:
parent
d42b3d670b
commit
7fe75ad88f
4 changed files with 0 additions and 131 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
|
||||
|
|
@ -49,14 +48,6 @@ public interface IResourceAllocationModel {
|
|||
*/
|
||||
Set<GenericResourceAllocation> getGenericResourceAllocations();
|
||||
|
||||
/**
|
||||
* Returns number of {@link ResourceAllocation} which are candidate to add
|
||||
* as {@link GenericResourceAllocation}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getNumberUnassignedResources();
|
||||
|
||||
/**
|
||||
* Returns the {@link Set} of {@link ResourceAllocation} of the current
|
||||
* {@link Task}.
|
||||
|
|
@ -65,22 +56,6 @@ public interface IResourceAllocationModel {
|
|||
*/
|
||||
Set<ResourceAllocation> getResourceAllocations();
|
||||
|
||||
/**
|
||||
* Return sum of percentages for current {@link Task}
|
||||
* {@link ResourceAllocation}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getSumPercentageResourceAllocations();
|
||||
|
||||
/**
|
||||
* Return sum of percentages for current {@link Task}
|
||||
* {@link SpecificResourceAllocation}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getSumPercentageSpecificResourceAllocations();
|
||||
|
||||
/**
|
||||
* Gets the current {@link Task} object.
|
||||
*
|
||||
|
|
@ -130,14 +105,6 @@ public interface IResourceAllocationModel {
|
|||
*/
|
||||
void updateGanttTaskDuration();
|
||||
|
||||
/**
|
||||
* Updates {@link GenericResourceAllocation} percentages of current
|
||||
* {@link Task}
|
||||
*
|
||||
* @param totalPercentage
|
||||
*/
|
||||
void updateGenericPercentages(BigDecimal totalPercentage);
|
||||
|
||||
/**
|
||||
* Cancel operation
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.InputEvent;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Decimalbox;
|
||||
|
|
@ -56,8 +55,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private Listbox resourcesList;
|
||||
|
||||
private Decimalbox genericResourceAllocationPercentage;
|
||||
|
||||
private Window window;
|
||||
|
||||
@Override
|
||||
|
|
@ -77,7 +74,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
resourceAllocationModel.setTask(task);
|
||||
resourceAllocationModel.setGanttTask(ganttTask);
|
||||
|
||||
updateGenericResourceAllocationPercentage();
|
||||
resourceAllocationModel
|
||||
.addGenericResourceAllocationIfNoAllocationExists();
|
||||
Util.reloadBindings(window);
|
||||
|
|
@ -90,17 +86,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GenericResourceAllocationPercentage initial value is the sum of all
|
||||
* {@link ResourceAllocation} percentages
|
||||
*/
|
||||
private void updateGenericResourceAllocationPercentage() {
|
||||
BigDecimal genericPercentage = resourceAllocationModel
|
||||
.getSumPercentageResourceAllocations();
|
||||
genericResourceAllocationPercentage.setValue(genericPercentage
|
||||
.scaleByPowerOfTen(2).setScale(2, BigDecimal.ROUND_HALF_EVEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows WorkerSearch window, add picked workers as
|
||||
* {@link SpecificResourceAllocation} to {@link ResourceAllocation} list
|
||||
|
|
@ -137,29 +122,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
for (Worker worker : workers) {
|
||||
addSpecificResourceAllocation(worker);
|
||||
}
|
||||
updateGenericPercentages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update percentages of {@link GenericResourceAllocation} items when
|
||||
* genericResourceAllocationPercentage box is changed
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
public void updateGenericPercentages(InputEvent e) {
|
||||
updateGenericPercentages(new BigDecimal((String) e.getValue()));
|
||||
}
|
||||
|
||||
public void updateGenericPercentages() {
|
||||
updateGenericPercentages(genericResourceAllocationPercentage.getValue());
|
||||
}
|
||||
|
||||
private void updateGenericPercentages(BigDecimal genericPercentage) {
|
||||
if (genericPercentage != null) {
|
||||
resourceAllocationModel.updateGenericPercentages(genericPercentage
|
||||
.divide(new BigDecimal(100)));
|
||||
}
|
||||
Util.reloadBindings(resourcesList);
|
||||
}
|
||||
|
||||
private void addSpecificResourceAllocation(Worker worker) {
|
||||
|
|
@ -233,7 +195,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void clear() {
|
||||
genericResourceAllocationPercentage.setValue(null);
|
||||
resourcesList.getItems().clear();
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +249,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
SpecificResourceAllocation resourceAllocation) {
|
||||
resourceAllocationModel
|
||||
.removeSpecificResourceAllocation(resourceAllocation);
|
||||
updateGenericPercentages();
|
||||
Util.reloadBindings(resourcesList);
|
||||
}
|
||||
|
||||
|
|
@ -386,7 +346,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
if (value != null) {
|
||||
value = value.setScale(2).divide(new BigDecimal(100),
|
||||
BigDecimal.ROUND_HALF_EVEN);
|
||||
updateGenericPercentages();
|
||||
decimalbox.setValue(value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
|
|
@ -22,7 +21,6 @@ import org.navalplanner.business.resources.daos.IWorkerDAO;
|
|||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.CriterionSatisfaction;
|
||||
import org.navalplanner.business.resources.entities.CriterionType;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -206,36 +204,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void updateGenericPercentages(BigDecimal totalPercentage) {
|
||||
Set<GenericResourceAllocation> genericResourceAllocations = getGenericResourceAllocations();
|
||||
BigDecimal percentagePerResource = totalPercentage;
|
||||
|
||||
percentagePerResource = percentagePerResource
|
||||
.subtract(getSumPercentageSpecificResourceAllocations());
|
||||
if (genericResourceAllocations.size() > 0) {
|
||||
percentagePerResource = percentagePerResource.setScale(8).divide(
|
||||
new BigDecimal(genericResourceAllocations.size()),
|
||||
BigDecimal.ROUND_HALF_EVEN);
|
||||
|
||||
// Percentage cannot be negative
|
||||
if (percentagePerResource.compareTo(new BigDecimal(0)) < 0) {
|
||||
percentagePerResource = new BigDecimal(0);
|
||||
}
|
||||
|
||||
for (ResourceAllocation resourceAllocation : genericResourceAllocations) {
|
||||
resourceAllocation.setPercentage(percentagePerResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public BigDecimal getSumPercentageSpecificResourceAllocations() {
|
||||
return getSumPercentage(task.getSpecificResourceAllocations());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private BigDecimal getSumPercentage(Set resourceAllocations) {
|
||||
BigDecimal result = new BigDecimal(0);
|
||||
|
|
@ -275,25 +243,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public BigDecimal getSumPercentageResourceAllocations() {
|
||||
return getSumPercentage(task.getResourceAllocations());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int getNumberUnassignedResources() {
|
||||
List<Resource> resources = resourceDAO
|
||||
.getAllByCriterions(getCriterions());
|
||||
Set<ResourceAllocation> resourceAllocations = task
|
||||
.getResourceAllocations();
|
||||
|
||||
return (resources.size() - resourceAllocations.size() > 0) ? resources
|
||||
.size()
|
||||
- resourceAllocations.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGanttTask(org.zkoss.ganttz.data.Task ganttTask) {
|
||||
this.ganttTask = ganttTask;
|
||||
|
|
|
|||
|
|
@ -84,12 +84,6 @@
|
|||
style="font-weight:bold" />
|
||||
<label value="@{allocationController.taskHours}" />
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${i18n:_('Generic allocation')}:"
|
||||
style="font-weight:bold" />
|
||||
<decimalbox id="genericResourceAllocationPercentage" width="48px"
|
||||
onChange="allocationController.updateGenericPercentages(event)" />
|
||||
</hbox>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue