Package net.sourceforge.ganttproject.task

Examples of net.sourceforge.ganttproject.task.ResourceAssignment


     */
    public Object getValueAt(int row, int col) {
        Object result;
        if (row >= 0) {
            if (row < myAssignments.size()) {
                ResourceAssignment assignment = (ResourceAssignment) myAssignments
                        .get(row);
                switch (col) {
                case 0:
                    result = String.valueOf(assignment.getResource().getId());
                    break;
                case 1:
                    result = assignment.getResource();
                    break;
                case 2:
                    result = String.valueOf(assignment.getLoad());
                    break;
                case 3:
                    result = new Boolean(assignment.isCoordinator());
                    break;
                case 4:
                    result = assignment.getRoleForAssignment();
                    break;
                default:
                    result = "";
                }
            } else {
View Full Code Here


        // fireTableCellUpdated(row, col);

    }

    private void updateAssignment(Object value, int row, int col) {
        ResourceAssignment updateTarget = (ResourceAssignment) myAssignments
                .get(row);
        switch (col) {
        case 4: {
            updateTarget.setRoleForAssignment((Role) value);
            break;
        }
        case 3: {
            updateTarget.setCoordinator(((Boolean) value).booleanValue());
            break;
        }
        case 2: {
            float loadAsFloat = Float.parseFloat(String.valueOf(value));
            updateTarget.setLoad(loadAsFloat);
            break;
        }
        case 1: {
            if (value == null) {
                updateTarget.delete();
                myAssignments.remove(row);
                fireTableRowsDeleted(row, row);
            } else if (value instanceof ProjectResource) {
                float load = updateTarget.getLoad();
                boolean coord = updateTarget.isCoordinator();
                updateTarget.delete();
                ResourceAssignment newAssignment = myMutator
                        .addAssignment((ProjectResource) value);
                newAssignment.setLoad(load);
                newAssignment.setCoordinator(coord);
                myAssignments.set(row, newAssignment);
            }
            break;

        }
View Full Code Here

        }
    }

    private void createAssignment(Object value) {
        if (value instanceof ProjectResource) {
            ResourceAssignment newAssignment = myMutator
                    .addAssignment((ProjectResource) value);
            newAssignment.setLoad(100);

            boolean coord = false;
            if (myAssignments.isEmpty())
                coord = true;
            newAssignment.setCoordinator(coord);

            if (newAssignment.getResource() instanceof HumanResource)
                newAssignment
                        .setRoleForAssignment(((HumanResource) newAssignment
                                .getResource()).getRole());

            myAssignments.add(newAssignment);
            fireTableRowsInserted(myAssignments.size(), myAssignments.size());
        }
View Full Code Here

        com.tapsterrock.mpx.ResourceAssignment assignment;
        int gTaskID;
        int gResourceID;
        GanttTask gTask;
        ProjectResource gResource;
        ResourceAssignment gAssignment;

        while (iter.hasNext() == true) {
            assignment = (com.tapsterrock.mpx.ResourceAssignment) iter.next();
            gTaskID = mapTaskNumber(assignment.getTask().getID());
            gResourceID = mapResourceNumber(assignment.getResource().getID());

            if ((gTaskID != -1) && (gResourceID != -1)) {
                gTask = tm.getTask(gTaskID);
                gResource = hrm.getById(gResourceID);

                gAssignment = gTask.getAssignmentCollection().addAssignment(
                        gResource);
                gAssignment.setLoad((float) assignment.getUnitsValue());
                gAssignment.setCoordinator(false);
                if (gResource instanceof HumanResource)
                    gAssignment
                            .setRoleForAssignment(((HumanResource) gResource)
                                    .getRole());
            }
        }
    }
View Full Code Here

        // TaskMutator mutator = task.createMutator();
        // ResourceAssignment assignment = mutator.addResource(human);
        // assignment.setLoad(load);
        // mutator.commit();

        ResourceAssignment assignment = task.getAssignmentCollection()
                .addAssignment(human);

        try {
            if (rolePersistendIDString != null)
                myLateAssigmnent2roleBinding.put(assignment,
                        rolePersistendIDString);
        } catch (NumberFormatException e) {
            System.out
                    .println("ERROR in parsing XML File function id is not numeric: "
                            + e.toString());
        }

        assignment.setLoad(load);
        assignment.setCoordinator(coordinator);
    }
View Full Code Here

        int yPos2 = ypos;
        Map/*<Task, List<Load>>*/ task2loads = distribution.getSeparatedTaskLoads();

        ResourceAssignment[] assignments = distribution.getResource().getAssignments();
        for (int i=0; i<assignments.length; i++) {
          ResourceAssignment assignment = assignments[i];
            List nextLoads = (List) task2loads.get(assignment.getTask());
            yPos2 += getConfig().getRowHeight();
            if (nextLoads==null) {
                continue;
            }
            buildTasksLoadsRectangles(nextLoads, yPos2);
View Full Code Here

    public void testResourceDisappearsFromListAfterAssignmentDeletion() {
        TaskManager taskManager = getTaskManager();
        Task task = taskManager.createTask();
        ProjectResource res1 = getResourceManager().getById(1);
        ProjectResource res2 = getResourceManager().getById(2);
        ResourceAssignment asgn1 = task.getAssignmentCollection()
                .addAssignment(res1);
        ResourceAssignment asgn2 = task.getAssignmentCollection()
                .addAssignment(res2);
        //
        asgn2.delete();
        //
        Set actualResources = extractResources(task);
        Set expectedResources = new HashSet(Arrays
                .asList(new Object[] { res1 }));
        assertEquals("Unexpected set of resources assigned to task=" + task,
View Full Code Here

    private Set extractResources(Task task) {
        Set result = new HashSet();
        ResourceAssignment[] assignments = task.getAssignments();
        for (int i = 0; i < assignments.length; i++) {
            ResourceAssignment next = assignments[i];
            result.add(next.getResource());
            assertEquals("Unexpected task is owning resource assignment="
                    + next, task, next.getTask());
        }
        return result;
    }
View Full Code Here

        for (int i = 0; i < tasks.length; i++) {
            Task task = tasks[i];
            ResourceAssignment[] assignments = task.getAssignments();
            for (int j = 0; j < assignments.length; j++) {
                int task_id = task.getTaskID();
                ResourceAssignment next = assignments[j];

                Role roleForAssignment = next.getRoleForAssignment();
                if (roleForAssignment == null) {
                    if (next.getResource() instanceof HumanResource) {
                        roleForAssignment = ((HumanResource) next
                                .getResource()).getRole();
                    }
                }
                addAttribute("task-id", String.valueOf(task_id), attrs);
                addAttribute("resource-id", String.valueOf(next.getResource().getId()), attrs);
                addAttribute("function", roleForAssignment.getPersistentID(), attrs);
                addAttribute("responsible", String.valueOf(next.isCoordinator()), attrs);
                addAttribute("load", String.valueOf(next.getLoad()), attrs);
                emptyElement("allocation", attrs, handler);
            }
        }
        endElement("allocations", handler);
    }
View Full Code Here

    public void setCustomFieldVal(String title, Object val) {
      this.customFields.put(title,val);
    }

    public ResourceAssignment createAssignment(ResourceAssignment assignmentToTask) {
        ResourceAssignment result = super.createAssignment(assignmentToTask);
        fireAssignmentsChanged();
        return result;
    }   
View Full Code Here

TOP

Related Classes of net.sourceforge.ganttproject.task.ResourceAssignment

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.