Esempio n. 1
0
  public HashMap<SecuredUserBean, Long> getParticipants(SecuredTaskBean securedTaskBean)
      throws GranException {
    SessionContext sc = securedTaskBean.getSecure();
    ArrayList<SecuredUserBean> userList =
        AdapterManager.getInstance()
            .getSecuredAclAdapterManager()
            .getUserList(sc, securedTaskBean.getId());
    Collections.sort(userList);
    HashMap<SecuredUserBean, Long> ret = new HashMap<SecuredUserBean, Long>();
    for (SecuredUserBean u : userList) {
      ArrayList<SecuredPrstatusBean> statuses =
          AdapterManager.getInstance()
              .getSecuredAclAdapterManager()
              .getAllowedPrstatusList(sc, securedTaskBean.getId(), u.getId());
      for (SecuredPrstatusBean b : statuses) {
        if (sc.canActionPrstatus(Action.editTaskActualBudget, b.getId())) {
          ret.put(u, 0L);
          break;
        }
      }
    }

    return ret;
  }
Esempio n. 2
0
  public Object calculate(SecuredTaskBean securedTaskBean) throws GranException {

    ArrayList<SecuredTaskBean> children = securedTaskBean.getChildren();
    if (children == null || children.isEmpty()) return null;
    HashMap<SecuredUserBean, Long> participants = getParticipants(securedTaskBean);
    for (SecuredTaskBean task : children) {

      for (SecuredMessageBean msg : task.getMessages()) {
        if (msg.getHrs() != null) {
          if (participants.containsKey(msg.getSubmitter())) {
            Long spentTime = participants.get(msg.getSubmitter());
            participants.put(msg.getSubmitter(), spentTime + msg.getHrs());
          }
        }
      }
    }
    StringBuffer s = new StringBuffer();

    s.append("<div id=\"barchart_div").append(securedTaskBean.getId()).append("\"></div>\n");
    s.append("<script type=\"text/javascript\">\n");
    s.append("google.load(\'visualization\', \'1.0\', {\'packages\':[\'corechart\']});\n");
    s.append("google.setOnLoadCallback(drawChart").append(securedTaskBean.getId()).append(");\n");
    s.append("function drawChart").append(securedTaskBean.getId()).append("() {\n");
    s.append("var data = new google.visualization.DataTable();\n");
    s.append("data.addColumn(\'string\', \'Участники\');\n");
    s.append("data.addColumn(\'number\', \'Рабочие часы\');\n");
    for (SecuredUserBean u : participants.keySet()) {
      s.append("data.addRow([\'")
          .append(u.getName())
          .append("\', ")
          .append((float) participants.get(u) / 3600f)
          .append("]);\n");
    }
    s.append("var options = {\'title\':\'Рабочие часы\',\n");
    s.append("\'backgroundColor\': \'transparent\',\n");
    s.append("\'legend\': \'none\'};\n");

    s.append(
            "		      var chart = new google.visualization.BarChart(document.getElementById(\'barchart_div")
        .append(securedTaskBean.getId())
        .append("\'));\n");
    s.append(" data.sort({column: 0});");
    s.append("chart.draw(data, options);\n");
    s.append("}\n");
    s.append("</script>\n");

    return s.toString();
  }
Esempio n. 3
0
  public SecuredMessageTriggerBean execute(SecuredMessageTriggerBean message) throws GranException {
    SecuredTaskBean task1 = message.getTask();
    HashMap udf = new HashMap();
    udf.put("Спринт", task1.getName() + " [#" + task1.getNumber() + "]");
    String readyState = SCRUM_ITEM_STATE_READY;
    String planOperation = SCRUM_ITEM_OPERATION_RUN;

    KernelManager.getFind().findMstatus(planOperation);
    Long budget = task1.getBudget();
    Long calculatedBudget = 0L;
    for (SecuredTaskBean task : message.getTask().getChildren()) {
      calculatedBudget += task.getBudget();
    }
    if (budget > 0) {
      if (budget >= calculatedBudget) {

        for (SecuredTaskBean task : message.getTask().getChildren()) {
          if (task.getStatusId().equals(readyState))
            TriggerManager.getInstance()
                .createMessage(
                    message.getSecure(),
                    task.getId(),
                    planOperation,
                    message.getDescription(),
                    0L,
                    task.getHandlerUserId(),
                    task.getHandlerGroupId(),
                    null,
                    null,
                    message.getDeadline() == null ? task1.getDeadline() : message.getDeadline(),
                    task.getBudget(),
                    udf,
                    false,
                    null);
        }
        return message;
      } else {
        throw new UserException(
            "Бюджет спринта меньше бюджета входящих в него задач. Переопределите бюджет или состав спринта",
            true);
      }
    } else throw new UserException("Сначала определите бюджет спринта", true);
  }