diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java index 854927967..97be5b68f 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java @@ -31,7 +31,7 @@ public class Task extends TaskElement { private Boolean fixedDuration = false; - private Set resourceAllocations = new HashSet(); + private Set> resourceAllocations = new HashSet>(); /** * Constructor for hibernate. Do not use! @@ -67,11 +67,11 @@ public class Task extends TaskElement { throw new UnsupportedOperationException(); } - public Set getResourceAllocations() { + public Set> getResourceAllocations() { return Collections.unmodifiableSet(resourceAllocations); } - public void addResourceAllocation(ResourceAllocation resourceAllocation) { + public void addResourceAllocation(ResourceAllocation resourceAllocation) { if (!resourceAllocation.getTask().equals(this)) { throw new IllegalArgumentException( "the resourceAllocation's task must be this task"); @@ -79,7 +79,8 @@ public class Task extends TaskElement { resourceAllocations.add(resourceAllocation); } - public void removeResourceAllocation(ResourceAllocation resourceAllocation) { + public void removeResourceAllocation( + ResourceAllocation resourceAllocation) { resourceAllocations.remove(resourceAllocation); } @@ -121,7 +122,7 @@ public class Task extends TaskElement { public boolean isValidResourceAllocationWorkers() { Set workers = new HashSet(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof SpecificResourceAllocation) { Resource resource = ((SpecificResourceAllocation) resourceAllocation) .getResource(); @@ -173,8 +174,8 @@ public class Task extends TaskElement { public Set getGenericResourceAllocations() { Set result = new HashSet(); - Set resourceAllocations = getResourceAllocations(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + Set> resourceAllocations = getResourceAllocations(); + for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof GenericResourceAllocation) { result.add((GenericResourceAllocation) resourceAllocation); } @@ -186,8 +187,8 @@ public class Task extends TaskElement { public Set getSpecificResourceAllocations() { Set result = new HashSet(); - Set resourceAllocations = getResourceAllocations(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + Set> resourceAllocations = getResourceAllocations(); + for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof SpecificResourceAllocation) { result.add((SpecificResourceAllocation) resourceAllocation); } diff --git a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/daos/ResourceAllocationDAOTest.java b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/daos/ResourceAllocationDAOTest.java index 318a105e3..f768ab390 100644 --- a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/daos/ResourceAllocationDAOTest.java +++ b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/daos/ResourceAllocationDAOTest.java @@ -81,7 +81,7 @@ public class ResourceAllocationDAOTest { return worker; } - private ResourceAllocation createValidResourceAllocation( + private ResourceAllocation createValidResourceAllocation( ResourceAllocationType type) { OrderLine orderLine = createValidOrderLine(); orderElementDAO.save(orderLine); @@ -168,7 +168,7 @@ public class ResourceAllocationDAOTest { SpecificResourceAllocation resourceAllocation1 = createValidSpecificResourceAllocation(); resourceAllocationDAO.save(resourceAllocation1); - ResourceAllocation resourceAllocation2 = createValidSpecificResourceAllocation(); + ResourceAllocation resourceAllocation2 = createValidSpecificResourceAllocation(); resourceAllocationDAO.save(resourceAllocation1); resourceAllocationDAO.save(resourceAllocation2); @@ -184,7 +184,7 @@ public class ResourceAllocationDAOTest { GenericResourceAllocation resourceAllocation1 = createValidGenericResourceAllocation(); resourceAllocationDAO.save(resourceAllocation1); - ResourceAllocation resourceAllocation2 = createValidGenericResourceAllocation(); + ResourceAllocation resourceAllocation2 = createValidGenericResourceAllocation(); resourceAllocationDAO.save(resourceAllocation1); resourceAllocationDAO.save(resourceAllocation2); diff --git a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/DayAssignmentMatchers.java b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/DayAssignmentMatchers.java index 57765f006..6468f964c 100644 --- a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/DayAssignmentMatchers.java +++ b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/DayAssignmentMatchers.java @@ -126,7 +126,7 @@ public class DayAssignmentMatchers { } public static ListDayAssignmentsMatcher haveResourceAllocation( - final ResourceAllocation allocation) { + final ResourceAllocation allocation) { return new ListDayAssignmentsMatcher() { @Override diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/SaveCommand.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/SaveCommand.java index 42ca9480c..c9d7d59b9 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/SaveCommand.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/SaveCommand.java @@ -47,7 +47,7 @@ public class SaveCommand implements ISaveCommand { throw new RuntimeException(_("The task '{0}' has some repeated Worker assigned", taskElement.getName())); } - for (ResourceAllocation resourceAllocation : ((Task) taskElement) + for (ResourceAllocation resourceAllocation : ((Task) taskElement) .getResourceAllocations()) { resourceAllocation.dontPoseAsTransientObjectAnymore(); for (DayAssignment dayAssignment : (List) resourceAllocation diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationDTO.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationDTO.java index 19a0e14b8..81aaa5209 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationDTO.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationDTO.java @@ -25,7 +25,7 @@ public abstract class AllocationDTO { return result; } - private ResourceAllocation origin; + private ResourceAllocation origin; private String name; @@ -39,11 +39,11 @@ public abstract class AllocationDTO { return origin != null; } - public ResourceAllocation getOrigin() { + public ResourceAllocation getOrigin() { return origin; } - protected void setOrigin(ResourceAllocation allocation) { + protected void setOrigin(ResourceAllocation allocation) { this.origin = allocation; } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java index c7ff5771b..21cff8f6b 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java @@ -155,17 +155,17 @@ public class ResourceAllocationModel implements IResourceAllocationModel { return resourceDAO.getAllByCriterions(getCriterions()); } - private ResourceAllocation createOrModify(AllocationDTO allocation) { + private ResourceAllocation createOrModify(AllocationDTO allocation) { if (allocation.isModifying()) { return allocation.getOrigin(); } else { - ResourceAllocation result = createAllocation(allocation); + ResourceAllocation result = createAllocation(allocation); task.addResourceAllocation(result); return result; } } - private ResourceAllocation createAllocation(AllocationDTO allocation) { + private ResourceAllocation createAllocation(AllocationDTO allocation) { if (allocation instanceof SpecificAllocationDTO) { SpecificAllocationDTO specific = (SpecificAllocationDTO) allocation; return createSpecific(specific.getResource()); @@ -174,7 +174,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { } } - private void doAllocationForFixedTask(ResourceAllocation allocation, + private void doAllocationForFixedTask(ResourceAllocation allocation, ResourcesPerDay resourcesPerDay) { if (allocation instanceof GenericResourceAllocation) { doAllocation((GenericResourceAllocation) allocation, @@ -196,7 +196,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { resourcesPerDay); } - private ResourceAllocation createSpecific(Resource resource) { + private ResourceAllocation createSpecific(Resource resource) { SpecificResourceAllocation result = SpecificResourceAllocation .create(task); result.setResource(resource); @@ -219,9 +219,9 @@ public class ResourceAllocationModel implements IResourceAllocationModel { } private void reattachResourceAllocations( - Set resourceAllocations) { + Set> resourceAllocations) { resourceAllocations.size(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + for (ResourceAllocation resourceAllocation : resourceAllocations) { resourceAllocation.getResourcesPerDay(); if (resourceAllocation instanceof SpecificResourceAllocation) { reattachSpecificResourceAllocation((SpecificResourceAllocation) resourceAllocation); @@ -282,7 +282,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { } private List asDTOs( - Collection resourceAllocations) { + Collection> resourceAllocations) { List result = new ArrayList(); result.addAll(toGenericAllocations(resourceAllocations)); result.addAll(toSpecificAllocations(resourceAllocations)); @@ -290,9 +290,9 @@ public class ResourceAllocationModel implements IResourceAllocationModel { } private List toSpecificAllocations( - Collection resourceAllocations) { + Collection> resourceAllocations) { List result = new ArrayList(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof SpecificResourceAllocation) { SpecificResourceAllocation specific = (SpecificResourceAllocation) resourceAllocation; result.add(SpecificAllocationDTO.from(specific)); @@ -302,9 +302,9 @@ public class ResourceAllocationModel implements IResourceAllocationModel { } private Collection toGenericAllocations( - Collection resourceAllocations) { + Collection> resourceAllocations) { ArrayList result = new ArrayList(); - for (ResourceAllocation resourceAllocation : resourceAllocations) { + for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof GenericResourceAllocation) { result.add(GenericAllocationDTO .from((GenericResourceAllocation) resourceAllocation));