AllocationRow tracks the current calculated value
FEA: ItEr74S04BugFixing
This commit is contained in:
parent
3d48651458
commit
175f785f91
4 changed files with 64 additions and 24 deletions
|
|
@ -210,7 +210,9 @@ public abstract class AllocationRow {
|
|||
return result;
|
||||
}
|
||||
|
||||
private ResourceAllocation<?> origin;
|
||||
private final ResourceAllocation<?> origin;
|
||||
|
||||
private CalculatedValue currentCalculatedValue;
|
||||
|
||||
private ResourceAllocation<?> temporal;
|
||||
|
||||
|
|
@ -245,12 +247,24 @@ public abstract class AllocationRow {
|
|||
});
|
||||
}
|
||||
|
||||
public AllocationRow() {
|
||||
public AllocationRow(CalculatedValue calculatedValue) {
|
||||
this.currentCalculatedValue = calculatedValue;
|
||||
this.origin = null;
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AllocationRow(ResourceAllocation<?> origin) {
|
||||
this.origin = origin;
|
||||
this.currentCalculatedValue = origin.getTask().getCalculatedValue();
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
setNonConsolidatedResourcesPerDay(ResourcesPerDay.amount(0));
|
||||
initializeResourcesPerDayInput();
|
||||
hoursInput.setValue(0);
|
||||
hoursInput.setWidth("80px");
|
||||
hoursInput.setConstraint(constraintForHoursInput());
|
||||
loadHours();
|
||||
}
|
||||
|
||||
public abstract ResourcesPerDayModification toResourcesPerDayModification(
|
||||
|
|
@ -272,11 +286,6 @@ public abstract class AllocationRow {
|
|||
return origin;
|
||||
}
|
||||
|
||||
protected void setOrigin(ResourceAllocation<?> allocation) {
|
||||
this.origin = allocation;
|
||||
loadHours();
|
||||
}
|
||||
|
||||
public boolean hasDerivedAllocations() {
|
||||
return ! getDerivedAllocations().isEmpty();
|
||||
}
|
||||
|
|
@ -369,6 +378,7 @@ public abstract class AllocationRow {
|
|||
|
||||
public void applyDisabledRules(CalculatedValue calculatedValue,
|
||||
boolean recommendedAllocation) {
|
||||
this.currentCalculatedValue = calculatedValue;
|
||||
hoursInput
|
||||
.setDisabled(calculatedValue != CalculatedValue.RESOURCES_PER_DAY
|
||||
|| recommendedAllocation);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class AllocationRowsHandler {
|
|||
alreadyPresent.add(each);
|
||||
} else {
|
||||
SpecificAllocationRow specificAllocationRow = SpecificAllocationRow
|
||||
.forResource(each);
|
||||
.forResource(getCalculatedValue(), each);
|
||||
setupInitialHours(specificAllocationRow);
|
||||
currentRows.add(specificAllocationRow);
|
||||
formBinder.newAllocationAdded();
|
||||
|
|
@ -105,7 +105,8 @@ public class AllocationRowsHandler {
|
|||
return false;
|
||||
} else {
|
||||
GenericAllocationRow genericAllocationRow = GenericAllocationRow
|
||||
.create(resourceType, criteria, resourcesMatched);
|
||||
.create(getCalculatedValue(), resourceType, criteria,
|
||||
resourcesMatched);
|
||||
if (hours != null) {
|
||||
genericAllocationRow.setHoursToInput(hours);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
|
|
@ -49,21 +50,24 @@ import org.navalplanner.business.workingday.ResourcesPerDay;
|
|||
*/
|
||||
public class GenericAllocationRow extends AllocationRow {
|
||||
|
||||
private static GenericAllocationRow createDefault(ResourceEnum resourceType) {
|
||||
private static GenericAllocationRow initializeDefault(
|
||||
GenericAllocationRow result, ResourceEnum resourceType) {
|
||||
Validate.notNull(resourceType);
|
||||
GenericAllocationRow result = new GenericAllocationRow();
|
||||
result.setName(_("Generic"));
|
||||
result.setNonConsolidatedResourcesPerDay(ResourcesPerDay.amount(0));
|
||||
result.resourceType = resourceType;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static GenericAllocationRow create(ResourceEnum resourceType,
|
||||
public static GenericAllocationRow create(CalculatedValue calculatedValue,
|
||||
ResourceEnum resourceType,
|
||||
Collection<? extends Criterion> criterions,
|
||||
Collection<? extends Resource> resources) {
|
||||
|
||||
GenericAllocationRow result = new GenericAllocationRow(calculatedValue);
|
||||
Validate.isTrue(!resources.isEmpty());
|
||||
Validate.notNull(criterions);
|
||||
GenericAllocationRow result = createDefault(resourceType);
|
||||
initializeDefault(result, resourceType);
|
||||
result.criterions = new HashSet<Criterion>(criterions);
|
||||
result.resources = new ArrayList<Resource>(resources);
|
||||
result.setName(Criterion.getCaptionFor(resourceType, criterions));
|
||||
|
|
@ -73,9 +77,9 @@ public class GenericAllocationRow extends AllocationRow {
|
|||
public static GenericAllocationRow from(
|
||||
GenericResourceAllocation resourceAllocation,
|
||||
IResourcesSearcher searchModel) {
|
||||
GenericAllocationRow result = createDefault(resourceAllocation
|
||||
.getResourceType());
|
||||
result.setOrigin(resourceAllocation);
|
||||
GenericAllocationRow result = initializeDefault(
|
||||
new GenericAllocationRow(resourceAllocation),
|
||||
resourceAllocation.getResourceType());
|
||||
|
||||
result.setNonConsolidatedResourcesPerDay(resourceAllocation
|
||||
.getNonConsolidatedResourcePerDay());
|
||||
|
|
@ -98,6 +102,14 @@ public class GenericAllocationRow extends AllocationRow {
|
|||
private Set<Criterion> criterions;
|
||||
private List<Resource> resources;
|
||||
|
||||
private GenericAllocationRow(CalculatedValue calculatedValue) {
|
||||
super(calculatedValue);
|
||||
}
|
||||
|
||||
private GenericAllocationRow(GenericResourceAllocation origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGeneric() {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
|
|
@ -86,8 +87,8 @@ public class SpecificAllocationRow extends AllocationRow {
|
|||
}
|
||||
|
||||
public static SpecificAllocationRow from(SpecificResourceAllocation specific) {
|
||||
SpecificAllocationRow result = forResource(specific.getResource());
|
||||
result.setOrigin(specific);
|
||||
SpecificAllocationRow result = new SpecificAllocationRow(specific);
|
||||
setupResource(result, specific.getResource());
|
||||
|
||||
result.setNonConsolidatedResourcesPerDay(specific
|
||||
.getNonConsolidatedResourcePerDay());
|
||||
|
|
@ -95,16 +96,32 @@ public class SpecificAllocationRow extends AllocationRow {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static SpecificAllocationRow forResource(Resource resource) {
|
||||
SpecificAllocationRow result = new SpecificAllocationRow();
|
||||
result.setName(resource.getShortDescription());
|
||||
result.setResource(resource);
|
||||
result.setNonConsolidatedResourcesPerDay(ResourcesPerDay.amount(1));
|
||||
public static SpecificAllocationRow forResource(
|
||||
CalculatedValue calculatedValue, Resource resource) {
|
||||
SpecificAllocationRow result = new SpecificAllocationRow(
|
||||
calculatedValue);
|
||||
setupResource(result, resource);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void setupResource(SpecificAllocationRow specificRow,
|
||||
Resource resource) {
|
||||
specificRow.setName(resource.getShortDescription());
|
||||
specificRow.setResource(resource);
|
||||
specificRow
|
||||
.setNonConsolidatedResourcesPerDay(ResourcesPerDay.amount(1));
|
||||
}
|
||||
|
||||
private Resource resource;
|
||||
|
||||
private SpecificAllocationRow(CalculatedValue calculatedValue) {
|
||||
super(calculatedValue);
|
||||
}
|
||||
|
||||
private SpecificAllocationRow(SpecificResourceAllocation origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcesPerDayModification toResourcesPerDayModification(Task task,
|
||||
Collection<? extends ResourceAllocation<?>> requestedToRemove) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue