ItEr38S08CUAdministracionCategoriaCosteItEr37S12: interface to manage the relation of ResourcesCostCategorAssignment with Machine
Some fixes to the ResourcesCostCategoryAssignment Controller and Model were done to work correctly with Machines interface. It doesn't affect to Workers interface.
This commit is contained in:
parent
e7f13dfe39
commit
46fded8b0d
4 changed files with 52 additions and 12 deletions
|
|
@ -310,5 +310,6 @@ public class ResourcesCostCategoryAssignmentController extends GenericForwardCom
|
|||
|
||||
public void setResource(Resource resource) {
|
||||
resourcesCostCategoryAssignmentModel.setResource(resource);
|
||||
Util.reloadBindings(listResourcesCostCategoryAssignments);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@
|
|||
package org.navalplanner.web.costcategories;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.ResourcesCostCategoryAssignment;
|
||||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
|
@ -36,25 +38,32 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
* Model for UI operations related to {@link ResourcesCostCategoryAssignment}
|
||||
*
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*/
|
||||
@Service
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class ResourcesCostCategoryAssignmentModel implements
|
||||
IResourcesCostCategoryAssignmentModel {
|
||||
|
||||
Resource resource;
|
||||
private Resource resource;
|
||||
|
||||
@Autowired
|
||||
IResourceDAO resourceDAO;
|
||||
|
||||
private List<ResourcesCostCategoryAssignment> resourceCostCategoryAssignments =
|
||||
new ArrayList<ResourcesCostCategoryAssignment>();
|
||||
|
||||
@Override
|
||||
public List<ResourcesCostCategoryAssignment> getCostCategoryAssignments() {
|
||||
List<ResourcesCostCategoryAssignment> list =
|
||||
new ArrayList<ResourcesCostCategoryAssignment>();
|
||||
if (resource != null) {
|
||||
list.addAll(resource.getResourcesCostCategoryAssignments());
|
||||
loadCostCategoryAssignments();
|
||||
}
|
||||
return list;
|
||||
return resourceCostCategoryAssignments;
|
||||
}
|
||||
|
||||
private void loadCostCategoryAssignments() {
|
||||
resourceCostCategoryAssignments.clear();
|
||||
resourceCostCategoryAssignments.addAll(resource.getResourcesCostCategoryAssignments());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -67,19 +76,30 @@ public class ResourcesCostCategoryAssignmentModel implements
|
|||
public void removeCostCategoryAssignment(
|
||||
ResourcesCostCategoryAssignment assignment) {
|
||||
resource.removeResourcesCostCategoryAssignment(assignment);
|
||||
}
|
||||
|
||||
private void forceLoadCostCategoryAssignments(Resource resource) {
|
||||
for (ResourcesCostCategoryAssignment assignment : resource.getResourcesCostCategoryAssignments()) {
|
||||
assignment.getCostCategory().getName();
|
||||
}
|
||||
loadCostCategoryAssignments();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void setResource(Resource resource) {
|
||||
resourceDAO.reattach(resource);
|
||||
forceLoadCostCategoryAssignments(resource);
|
||||
initializeCostCategoryAssignments(resource.getResourcesCostCategoryAssignments());
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
private void initializeCostCategoryAssignments(Collection<ResourcesCostCategoryAssignment> resourceCostCategoryAssignments) {
|
||||
for (ResourcesCostCategoryAssignment each: resourceCostCategoryAssignments) {
|
||||
initializeCostCategoryAssignment(each);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeCostCategoryAssignment(ResourcesCostCategoryAssignment resourceCostCategoryAssignment) {
|
||||
resourceCostCategoryAssignment.getEndDate();
|
||||
initializeCostCategory(resourceCostCategoryAssignment.getCostCategory());
|
||||
}
|
||||
|
||||
private void initializeCostCategory(CostCategory costCategory) {
|
||||
costCategory.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.navalplanner.web.common.MessagesForUser;
|
|||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.entrypoints.IURLHandlerRegistry;
|
||||
import org.navalplanner.web.costcategories.ResourcesCostCategoryAssignmentController;
|
||||
import org.navalplanner.web.resources.worker.CriterionsController;
|
||||
import org.navalplanner.web.resources.worker.CriterionsMachineController;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
|
@ -78,6 +79,8 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
|
||||
private MachineConfigurationController configurationController;
|
||||
|
||||
private ResourcesCostCategoryAssignmentController resourcesCostCategoryAssignmentController;
|
||||
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(MachineCRUDController.class);
|
||||
|
||||
|
|
@ -102,6 +105,7 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
setupCriterionsController();
|
||||
setupConfigurationController();
|
||||
setupResourcesCostCategoryAssignmentController(comp);
|
||||
showListWindow();
|
||||
}
|
||||
|
||||
|
|
@ -128,10 +132,19 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
.getVariable("configurationController", true);
|
||||
}
|
||||
|
||||
private void setupResourcesCostCategoryAssignmentController(Component comp)
|
||||
throws Exception {
|
||||
Component costCategoryAssignmentContainer =
|
||||
editWindow.getFellowIfAny("costCategoryAssignmentContainer");
|
||||
resourcesCostCategoryAssignmentController = (ResourcesCostCategoryAssignmentController)
|
||||
costCategoryAssignmentContainer.getVariable("assignmentController", true);
|
||||
}
|
||||
|
||||
public void goToCreateForm() {
|
||||
machineModel.initCreate();
|
||||
criterionsController.prepareForCreate(machineModel.getMachine());
|
||||
configurationController.initConfigurationController(machineModel);
|
||||
resourcesCostCategoryAssignmentController.setResource(machineModel.getMachine());
|
||||
selectMachineDataTab();
|
||||
showEditWindow(_("Create machine"));
|
||||
}
|
||||
|
|
@ -159,6 +172,7 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
selectMachineDataTab();
|
||||
showEditWindow(_("Edit machine"));
|
||||
configurationController.initConfigurationController(machineModel);
|
||||
resourcesCostCategoryAssignmentController.setResource(machineModel.getMachine());
|
||||
}
|
||||
|
||||
private void selectMachineDataTab() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<?component name="criterions" inline="true" macroURI="_machineCriterions.zul"?>
|
||||
<?component name="resourceCalendar" inline="true" macroURI="_calendar.zul"?>
|
||||
<?component name="machineConfigurationUnits" inline="true" macroURI="_machineConfigurationUnits.zul"?>
|
||||
<?component name="costCategoryAssignment" inline="true" macroURI="../_costCategoryAssignment.zul"?>
|
||||
<window id="editWindow" >
|
||||
<tabbox>
|
||||
<tabs>
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
<tab label="${i18n:_('Assigned criteria')}"></tab>
|
||||
<tab label="${i18n:_('Calendar')}"></tab>
|
||||
<tab label="${i18n:_('Configuration')}"></tab>
|
||||
<tab label="${i18n:_('Cost category assignment')}"></tab>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
|
|
@ -67,6 +69,9 @@
|
|||
<!-- Configuration units -->
|
||||
<machineConfigurationUnits id="configurationUnits" />
|
||||
</tabpanel>
|
||||
<tabpanel>
|
||||
<costCategoryAssignment id="costCategoryAssignmentContainer" />
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
<button label="${i18n:_('Save')}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue