ItEr25S07CUAsignacionGrupoRecursosAPlanificacionItEr24S08: Adding missing generic types for ResourceAllocation.

This commit is contained in:
Óscar González Fernández 2009-09-19 22:08:34 +02:00
parent daa99a9f34
commit b565641b7d
6 changed files with 30 additions and 29 deletions

View file

@ -31,7 +31,7 @@ public class Task extends TaskElement {
private Boolean fixedDuration = false;
private Set<ResourceAllocation> resourceAllocations = new HashSet<ResourceAllocation>();
private Set<ResourceAllocation<?>> resourceAllocations = new HashSet<ResourceAllocation<?>>();
/**
* Constructor for hibernate. Do not use!
@ -67,11 +67,11 @@ public class Task extends TaskElement {
throw new UnsupportedOperationException();
}
public Set<ResourceAllocation> getResourceAllocations() {
public Set<ResourceAllocation<?>> 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<Long> workers = new HashSet<Long>();
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<GenericResourceAllocation> getGenericResourceAllocations() {
Set<GenericResourceAllocation> result = new HashSet<GenericResourceAllocation>();
Set<ResourceAllocation> resourceAllocations = getResourceAllocations();
for (ResourceAllocation resourceAllocation : resourceAllocations) {
Set<ResourceAllocation<?>> 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<SpecificResourceAllocation> getSpecificResourceAllocations() {
Set<SpecificResourceAllocation> result = new HashSet<SpecificResourceAllocation>();
Set<ResourceAllocation> resourceAllocations = getResourceAllocations();
for (ResourceAllocation resourceAllocation : resourceAllocations) {
Set<ResourceAllocation<?>> resourceAllocations = getResourceAllocations();
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
if (resourceAllocation instanceof SpecificResourceAllocation) {
result.add((SpecificResourceAllocation) resourceAllocation);
}

View file

@ -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);

View file

@ -126,7 +126,7 @@ public class DayAssignmentMatchers {
}
public static ListDayAssignmentsMatcher haveResourceAllocation(
final ResourceAllocation allocation) {
final ResourceAllocation<?> allocation) {
return new ListDayAssignmentsMatcher() {
@Override

View file

@ -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<? extends DayAssignment>) resourceAllocation

View file

@ -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;
}

View file

@ -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<ResourceAllocation> resourceAllocations) {
Set<ResourceAllocation<?>> 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<AllocationDTO> asDTOs(
Collection<? extends ResourceAllocation> resourceAllocations) {
Collection<? extends ResourceAllocation<?>> resourceAllocations) {
List<AllocationDTO> result = new ArrayList<AllocationDTO>();
result.addAll(toGenericAllocations(resourceAllocations));
result.addAll(toSpecificAllocations(resourceAllocations));
@ -290,9 +290,9 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
}
private List<SpecificAllocationDTO> toSpecificAllocations(
Collection<? extends ResourceAllocation> resourceAllocations) {
Collection<? extends ResourceAllocation<?>> resourceAllocations) {
List<SpecificAllocationDTO> result = new ArrayList<SpecificAllocationDTO>();
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<GenericAllocationDTO> toGenericAllocations(
Collection<? extends ResourceAllocation> resourceAllocations) {
Collection<? extends ResourceAllocation<?>> resourceAllocations) {
ArrayList<GenericAllocationDTO> result = new ArrayList<GenericAllocationDTO>();
for (ResourceAllocation resourceAllocation : resourceAllocations) {
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
if (resourceAllocation instanceof GenericResourceAllocation) {
result.add(GenericAllocationDTO
.from((GenericResourceAllocation) resourceAllocation));