コード例 #1
0
  public void createResourceForm(Long categoryId) {
    resourceCategorySelected = this.projectMgmtService.getResourceCategoryById(categoryId);
    this.clearResourceForm();
    SelectedResource selectedResource;
    ResourceRow resourceRow;
    ProjectResource projectResourceFound = getProjectResource(categoryId);
    for (Resource resource : resourceCategorySelected.getResourceList()) {
      resourceRow = new ResourceRow(resource);
      rowsResourceList.getChildren().add(resourceRow);
      // Sets selected recources
      if (projectResourceFound == null) {
        continue;
      } else {
        for (int j = 0; j < projectResourceFound.getSelectedResourceList().size(); j++) {
          selectedResource = projectResourceFound.getSelectedResourceList().get(j);
          if (selectedResource.getResource().getId().compareTo(resource.getId()) == 0) {
            resourceRow.selectedResource();
            resourceRow.setSelectedValue(selectedResource.getSelectedValue());
          }
        }
      }
    }
    // Sets selected recources

    grdEditResource.setVisible(true);
    btnSaveResource.setVisible(true);
  }
コード例 #2
0
 private void saveProjectResources(List componenttList, ProjectResource projectResource)
     throws WrongValueException {
   ResourceRow resourceRow;
   // Determina si hay recursos seleccionados
   boolean isSelectedtResources = false;
   SelectedResource selectedResource;
   for (Iterator iterator = componenttList.iterator(); iterator.hasNext(); ) {
     resourceRow = (ResourceRow) iterator.next();
     if (resourceRow.isSelectedResource()) {
       String selectedValue = resourceRow.getSelectedValue();
       if (selectedValue == null || Strings.isBlank(selectedValue)) {
         throw new WrongValueException(resourceRow.getComponentValue(), "Value is requeried");
       }
       selectedResource = new SelectedResource();
       selectedResource.setResource(resourceRow.getResource());
       selectedResource.setSelectedValue(selectedValue);
       projectResource.getSelectedResourceList().add(selectedResource);
       isSelectedtResources = true;
     }
   }
   if (isSelectedtResources) {
     this.project.getProjectResourceList().add(projectResource);
     this.projectMgmtService.projectUpdate(this.project);
   }
 }