Package org.projectforge.task

Examples of org.projectforge.task.TaskTree


      }
      if (access == GanttAccess.ALL) {
        // User has task access:
        return true;
      }
      final TaskTree taskTree = UserRights.getAccessChecker().getTaskTree();
      final ProjektDO project = taskTree.getProjekt(obj.getTaskId());
      if (project == null) {
        // Project manager group not found:
        return UserRights.getAccessChecker().isUserMemberOfGroup(user, ProjectForgeGroup.PROJECT_MANAGER);
      }
      // Users of the project manager group have access:
View Full Code Here


   * @param obj
   * @return The root object of the read xml data.
   */
  public GanttChartData readGanttObjects(final GanttChartDO obj)
  {
    final TaskTree taskTree = taskDao.getTaskTree();
    final GanttChartData ganttChartData = Task2GanttTaskConverter.convertToGanttObjectTree(taskTree, obj.getTask());
    final XmlObjectReader reader = new XmlObjectReader() {
      @Override
      protected Object newInstance(final Class< ? > clazz, final Element el, final String attrName, final String attrValue)
      {
        if ("predecessor".equals(attrName) == true && XmlConstants.NULL_IDENTIFIER.equals(attrValue) == true) {
          // Field should set to null.
          return Status.IGNORE;
        }
        if (GanttTask.class.isAssignableFrom(clazz) == true) {
          final GanttTask ganttObject = getGanttObject(taskTree, ganttChartData, el);
          if (ganttObject == null) {
            return new GanttTaskImpl(); // Gantt task not related to a ProjectForge task.
          }
          return ganttObject;
        } else if (Collection.class.isAssignableFrom(clazz) == true) {
          final GanttTask ganttObject = getGanttObject(taskTree, ganttChartData, el.getParent());
          if (ganttObject != null && ganttObject.getChildren() != null) {
            return ganttObject.getChildren();
          }
        }
        return null;
      }

      @Override
      protected boolean addCollectionEntry(final Collection< ? > col, final Object obj, final Element el)
      {
        if (obj instanceof GanttTask == false) {
          return false;
        }
        final GanttTask ganttTask = (GanttTask)obj;
        if (ganttChartData.findById(ganttTask.getId()) != null) {
          // GanttTask already added to the Gantt object tree.
          return true;
        }
        if (taskTree.getTaskById((Integer)ganttTask.getId()) != null) {
          // External task, so ignore it:
          return true;
        }
        return false;
      }
View Full Code Here

      {
        if (super.ignoreField(obj, field) == true) {
          return true;
        }
        if (obj instanceof GanttTask) {
          final TaskTree taskTree = taskDao.getTaskTree();
          final String fieldName = field.getName();
          if ("id".equals(fieldName) == true) {
            // Id should always be equals and needed in output for the identification of the gantt object.
            return false;
          }
          if ("description".equals(fieldName) == true) {
            return true;
          }
          final GanttTask ganttObject = (GanttTask) obj;
          final TaskDO task = taskTree.getTaskById((Integer) ganttObject.getId());
          if (task != null) {
            if ("predecessor".equals(field.getName()) == true) {
              // Predecessor unmodified?
              return NumberHelper.isEqual((Integer) ganttObject.getPredecessorId(), task.getGanttPredecessorId());
            }
            String taskFieldname = fieldMapping.get(fieldName);
            if (taskFieldname == null) {
              taskFieldname = fieldName;
            }
            for (final Field taskField : taskFields) {
              if (taskFieldname.equals(taskField.getName()) == true) {
                final Object value = BeanHelper.getFieldValue(obj, field);
                final Object taskValue = BeanHelper.getFieldValue(task, taskField);
                if (value instanceof BigDecimal) {
                  // Needed, because 10.0 is not equal to 10.000 (if scale is different).
                  return NumberHelper.isEqual((BigDecimal) value, (BigDecimal) taskValue);
                }
                return ObjectUtils.equals(value, taskValue) == true;
              }
            }
          }
        }
        return false;
      }

      @Override
      protected void writeField(final Field field, final Object obj, final Object fieldValue, final XmlField annotation,
          final Element element)
      {
        if (GanttTask.class.isAssignableFrom(field.getDeclaringClass()) == true) {
          final String fieldName = field.getName();
          if ("id".equals(fieldName) == false) {
            final TaskTree taskTree = taskDao.getTaskTree();
            final GanttTask ganttObject = (GanttTask) obj;
            final TaskDO task = taskTree.getTaskById((Integer) ganttObject.getId());
            if (task != null) {
              String taskFieldname = fieldMapping.get(fieldName);
              if (taskFieldname == null) {
                taskFieldname = fieldName;
              }
View Full Code Here

   * @return
   */
  @SuppressWarnings("serial")
  private List<IColumn<TaskNode, String>> createColumns()
  {
    final TaskTree taskTree = getTaskTree();
    final CellItemListener<TaskNode> cellItemListener = new CellItemListener<TaskNode>() {
      public void populateItem(final Item<ICellPopulator<TaskNode>> item, final String componentId, final IModel<TaskNode> rowModel)
      {
        final TaskNode taskNode = rowModel.getObject();
        TaskListPage.appendCssClasses(item, taskNode.getTask(), highlightedTaskNodeId);
      }
    };
    final List<IColumn<TaskNode, String>> columns = new ArrayList<IColumn<TaskNode, String>>();

    columns.add(new TreeColumn<TaskNode, String>(new ResourceModel("task")) {
      @Override
      public void populateItem(final Item<ICellPopulator<TaskNode>> cellItem, final String componentId, final IModel<TaskNode> rowModel)
      {
        final RepeatingView view = new RepeatingView(componentId);
        cellItem.add(view);
        final TaskNode taskNode = rowModel.getObject();
        if (selectMode == false) {
          view.add(new ListSelectActionPanel(view.newChildId(), rowModel, TaskEditPage.class, taskNode.getId(), parentPage, ""));
        } else {
          view.add(new ListSelectActionPanel(view.newChildId(), rowModel, caller, selectProperty, taskNode.getId(), ""));
        }
        AbstractListPage.addRowClick(cellItem);
        final NodeModel<TaskNode> nodeModel = (NodeModel<TaskNode>) rowModel;
        final Component nodeComponent = getTree().newNodeComponent(view.newChildId(), nodeModel.getWrappedModel());
        nodeComponent.add(new NodeBorder(nodeModel.getBranches()));
        view.add(nodeComponent);
        cellItemListener.populateItem(cellItem, componentId, rowModel);
      }
    });
    columns.add(new CellItemListenerPropertyColumn<TaskNode>(new ResourceModel("task.consumption"), null, "task", cellItemListener) {
      @Override
      public void populateItem(final Item<ICellPopulator<TaskNode>> item, final String componentId, final IModel<TaskNode> rowModel)
      {
        final TaskNode node = rowModel.getObject();
        item.add(TaskListPage.getConsumptionBarPanel(tree, componentId, getTaskTree(), selectMode, node));
        cellItemListener.populateItem(item, componentId, rowModel);
      }
    });
    if (showCost == true) {
      columns.add(new CellItemListenerPropertyColumn<TaskNode>(new ResourceModel("fibu.kost2"), null, "task.kost2", cellItemListener) {
        @Override
        public void populateItem(final Item<ICellPopulator<TaskNode>> item, final String componentId, final IModel<TaskNode> rowModel)
        {
          final Label label = TaskListPage.getKostLabel(componentId, getTaskTree(), rowModel.getObject().getTask());
          item.add(label);
          cellItemListener.populateItem(item, componentId, rowModel);
        }
      });
    }
    if (taskTree.hasOrderPositionsEntries() == true && showOrders == true) {
      columns.add(new CellItemListenerPropertyColumn<TaskNode>(new ResourceModel("fibu.auftrag.auftraege"), null, null, cellItemListener) {
        @Override
        public void populateItem(final Item<ICellPopulator<TaskNode>> item, final String componentId, final IModel<TaskNode> rowModel)
        {
          final TaskNode taskNode = rowModel.getObject();
          final Set<AuftragsPositionVO> orderPositions = taskTree.getOrderPositionEntries(taskNode.getId());
          if (CollectionUtils.isEmpty(orderPositions) == true) {
            final Label label = new Label(componentId, ""); // Empty label.
            item.add(label);
          } else {
            final OrderPositionsPanel orderPositionsPanel = new OrderPositionsPanel(componentId) {
View Full Code Here

  @Override
  protected void onBeforeRender()
  {
    super.onBeforeRender();
    final TaskTree taskTree = taskDao.getTaskTree();
    final List<GanttTreeTableNode> treeList = getTreeList();
    for (int i = 0; i < NUMBER_OF_REJECT_SAVE_COLS; i++) {
      rejectSaveColumnVisible[i] = false;
    }
    if (treeList != null) {
      for (final GanttTreeTableNode node : treeList) {
        final GanttTask ganttObject = node.getGanttObject();
        final TaskDO task = taskTree.getTaskById((Integer) ganttObject.getId());
        if (task != null) {
          int col = 0;
          if (rejectSaveColumnVisible[col] == false && isTitleModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isStartDateModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isDurationModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isEndDateModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isProgressModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isPredecessorModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isPredecessorOffsetModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isRelationTypeModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
          if (rejectSaveColumnVisible[++col] == false && isTypeModified(ganttObject, task) == true) {
            rejectSaveColumnVisible[col] = true;
          }
        }
      }
    }
    for (int i = 0; i < NUMBER_OF_REJECT_SAVE_COLS; i++) {
      rejectSaveColHeads[i].setVisible(rejectSaveColumnVisible[i]);
    }
    createTreeRows();
    final Iterator<Item<GanttTreeTableNode>> it = refreshingView.getItems();
    while (it.hasNext() == true) {
      final Item<GanttTreeTableNode> row = it.next();
      final GanttTask ganttObject = row.getModelObject().getGanttObject();
      boolean visible = true;
      if (form.getSettings().isShowOnlyVisibles() == true) {
        final GanttTaskImpl root = (GanttTaskImpl) ganttChartData.getRootObject();
        GanttTask current = ganttObject;
        int i = 10;
        while (current != null && current != root) {
          if (i-- < 0) {
            break; // Endless loop protection.
          }
          if (current.isVisible() == false) {
            visible = false;
            break;
          }
          current = root.findParent(current.getId());
        }
      }
      row.setVisible(visible);
      if (visible == true) {
        final TaskDO task = taskTree.getTaskById((Integer) ganttObject.getId());
        int col = 0;
        setRejectSaveLinksFragmentVisibility("rejectSaveTitle", row, col++, isTitleModified(ganttObject, task));
        setRejectSaveLinksFragmentVisibility("rejectSaveStartDate", row, col++, isStartDateModified(ganttObject, task));
        setRejectSaveLinksFragmentVisibility("rejectSaveDuration", row, col++, isDurationModified(ganttObject, task));
        setRejectSaveLinksFragmentVisibility("rejectSaveEndDate", row, col++, isEndDateModified(ganttObject, task));
View Full Code Here

  {
    final List<TaskObject> topLevelTasks = new ArrayList<TaskObject>();
    if (tasks == null || tasks.isEmpty() == true) {
      return topLevelTasks;
    }
    final TaskTree taskTree = taskDao.getTaskTree();
    final Map<Integer, TaskObject> rtaskMap = new HashMap<Integer, TaskObject>();
    for (final TaskDO task : tasks) {
      final TaskObject rtask = createRTask(task);
      rtaskMap.put(task.getId(), rtask);
    }
View Full Code Here

  {
    final List<TaskObject> topLevelTasks = new ArrayList<TaskObject>();
    if (tasks == null || tasks.isEmpty() == true) {
      return topLevelTasks;
    }
    final TaskTree taskTree = taskDao.getTaskTree();
    final Map<Integer, TaskObject> rtaskMap = new HashMap<Integer, TaskObject>();
    for (final TaskDO task : tasks) {
      final TaskObject rtask = createRTask(task);
      rtaskMap.put(task.getId(), rtask);
    }
View Full Code Here

  @Test
  public void testReadWriteGanttObjects()
  {
    logon(TEST_ADMIN_USER);
    final String prefix = "GantChartTest";
    final TaskTree taskTree = taskDao.getTaskTree();
    final TaskDO rootTask = initTestDB.addTask(prefix, "root");
    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 3);
    taskDao.update(initTestDB.addTask(prefix + "1", prefix).setStartDate(dh.getDate()).setDuration(BigDecimal.TEN));
    initTestDB.addTask(prefix + "1.1", prefix + "1");
View Full Code Here

  @Test
  public void testIgnoringOfNumberFields()
  {
    logon(TEST_ADMIN_USER);
    final String prefix = "GanttTest3";
    final TaskTree taskTree = taskDao.getTaskTree();
    final TaskDO rootTask = initTestDB.addTask(prefix, "root");
    final Integer id1 = addTask(prefix + "1", null, null);
    final Integer id2 = addTask(prefix + "2", null, null);
    final Integer id3 = addTask(prefix + "3", BigDecimal.TEN, 10);
    final Integer id4 = addTask(prefix + "4", BigDecimal.TEN, 10);
View Full Code Here

TOP

Related Classes of org.projectforge.task.TaskTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.