Exemplo n.º 1
0
 private String getAvailableActCategoriesJson() {
   StringBuilder sb = new StringBuilder();
   List<DictionaryItem> actTypes = dictionaryItemService.getTypesOfActivity();
   List<ProjectRole> projectRoles = projectRoleService.getProjectRoles();
   sb.append("[");
   for (int i = 0; i < actTypes.size(); i++) {
     for (ProjectRole projectRole : projectRoles) {
       sb.append("{actType:'").append(actTypes.get(i).getId()).append("', ");
       sb.append("projRole:'").append(projectRole.getId()).append("', ");
       List<AvailableActivityCategory> avActCats =
           availableActivityCategoryService.getAvailableActivityCategories(
               actTypes.get(i), projectRole);
       sb.append("avActCats:[");
       for (int k = 0; k < avActCats.size(); k++) {
         sb.append("'").append(avActCats.get(k).getActCat().getId()).append("'");
         if (k < (avActCats.size() - 1)) {
           sb.append(", ");
         }
       }
       sb.append("]}");
       if (i < (actTypes.size())) {
         sb.append(", ");
       }
     }
   }
   return sb.toString().substring(0, (sb.toString().length() - 2)) + "]";
 }
Exemplo n.º 2
0
  /*
   * Возвращает HashMap со значениями для заполнения списков сотрудников,
   * проектов, пресейлов, проектных задач, типов и категорий активности на
   * форме приложения.
   */
  private Map<String, Object> getListsToMAV() {
    Map<String, Object> result = new HashMap<String, Object>();

    List<DictionaryItem> typesOfActivity = dictionaryItemService.getTypesOfActivity();
    result.put("actTypeList", typesOfActivity);

    String typesOfActivityJson = getDictionaryItemsInJson(typesOfActivity);
    result.put("actTypeJson", typesOfActivityJson);

    String workplacesJson = getDictionaryItemsInJson(dictionaryItemService.getWorkplaces());
    result.put("workplaceJson", workplacesJson);

    result.put(
        "overtimeCauseJson", getDictionaryItemsInJson(dictionaryItemService.getOvertimeCauses()));
    result.put(
        "unfinishedDayCauseJson",
        getDictionaryItemsInJson(dictionaryItemService.getUnfinishedDayCauses()));
    result.put("overtimeThreshold", propertyProvider.getOvertimeThreshold());

    List<Division> divisions = divisionService.getDivisions();
    result.put("divisionList", divisions);

    result.put(
        "employeeListJson",
        employeeHelper.getEmployeeListJson(divisions, employeeService.isShowAll(request)));

    List<DictionaryItem> categoryOfActivity = dictionaryItemService.getCategoryOfActivity();
    result.put("actCategoryList", categoryOfActivity);

    String actCategoryListJson = getDictionaryItemsInJson(categoryOfActivity);
    result.put("actCategoryListJson", actCategoryListJson);

    result.put("availableActCategoriesJson", getAvailableActCategoriesJson());

    result.put("projectListJson", projectService.getProjectListJson(divisions));
    result.put("projectTaskListJson", getProjectTaskListJson(projectService.getProjectsWithCq()));

    List<ProjectRole> projectRoleList = projectRoleService.getProjectRoles();

    for (int i = 0; i < projectRoleList.size(); i++) {
      if (projectRoleList
          .get(i)
          .getCode()
          .equals("ND")) { // Убираем из списка роль "Не определена" APLANATS-270
        projectRoleList.remove(i);
        break;
      }
    }

    result.put("projectRoleList", projectRoleList);
    StringBuilder projectRoleListJson = new StringBuilder();
    projectRoleListJson.append("[");
    for (ProjectRole item : projectRoleList) {
      projectRoleListJson.append("{id:'");
      projectRoleListJson.append(item.getId().toString());
      projectRoleListJson.append("', value:'");
      projectRoleListJson.append(item.getName());
      projectRoleListJson.append("'},");
    }
    result.put(
        "projectRoleListJson",
        projectRoleListJson.toString().substring(0, (projectRoleListJson.toString().length() - 1))
            + "]");

    return result;
  }