Java Code Examples for net.sf.mpxj.ProjectFile#getResourceAssignments()
The following examples show how to use
net.sf.mpxj.ProjectFile#getResourceAssignments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectTreeController.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Add assignments to the tree. * * @param parentNode parent tree node * @param file assignments container */ private void addAssignments(MpxjTreeNode parentNode, ProjectFile file) { for (ResourceAssignment assignment : file.getResourceAssignments()) { final ResourceAssignment a = assignment; MpxjTreeNode childNode = new MpxjTreeNode(a) { @Override public String toString() { Resource resource = a.getResource(); String resourceName = resource == null ? "(unknown resource)" : resource.getName(); Task task = a.getTask(); String taskName = task == null ? "(unknown task)" : task.getName(); return resourceName + "->" + taskName; } }; parentNode.add(childNode); } }
Example 2
Source File: MpxjQuery.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method lists all resource assignments defined in the file. * * @param file MPX file */ private static void listAssignments(ProjectFile file) { Task task; Resource resource; String taskName; String resourceName; for (ResourceAssignment assignment : file.getResourceAssignments()) { task = assignment.getTask(); if (task == null) { taskName = "(null task)"; } else { taskName = task.getName(); } resource = assignment.getResource(); if (resource == null) { resourceName = "(null resource)"; } else { resourceName = resource.getName(); } System.out.println("Assignment: Task=" + taskName + " Resource=" + resourceName); if (task != null) { listTimephasedWork(assignment); } } System.out.println(); }
Example 3
Source File: DeletedAssignmentTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test to exercise the test case provided for SourceForge bug #248. * https://sourceforge.net/p/mpxj/bugs/248/ */ @Test public void testSourceForge248() throws Exception { ProjectFile file = new MPPReader().read(MpxjTestData.filePath("assignment/assignment-deletion/sf248.mpp")); List<ResourceAssignment> assignments = file.getResourceAssignments(); assertEquals(2, assignments.size()); testAssignment(assignments, 0, "Task2", "Vijay"); testAssignment(assignments, 1, "Task1", "Anil"); }
Example 4
Source File: DeletedAssignmentTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test a project file to ensure that deleted resource assignments are not included. * * @param file project file to test */ private void testDeletedResourceAssignments(File file) throws MPXJException { MPPReader reader = new MPPReader(); ProjectFile mpp = reader.read(file); List<ResourceAssignment> assignments = mpp.getResourceAssignments(); assertEquals(file.getName() + " does not contain 5 resource assignments", 5, assignments.size()); testAssignment(assignments, 0, "Task 1", "Resource 1"); testAssignment(assignments, 1, "Task 1", "Resource 3"); testAssignment(assignments, 2, "Task 1", "Resource 5"); testAssignment(assignments, 3, "Task 1", "Resource 7"); testAssignment(assignments, 4, "Task 1", "Resource 9"); }
Example 5
Source File: MppResourceTest.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Tests fields related to Resource Assignments. * * @param mpp The ProjectFile being tested. */ private void testResourceAssignments(ProjectFile mpp) { Integer intOne = Integer.valueOf(1); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); List<ResourceAssignment> listResourceAssignments = mpp.getResourceAssignments(); ResourceAssignment ra = listResourceAssignments.get(0); // id assertEquals(intOne, ra.getResource().getID()); assertEquals(intOne, ra.getResourceUniqueID()); // start and finish assertEquals("25/08/2006", df.format(ra.getStart())); assertEquals("29/08/2006", df.format(ra.getFinish())); // task Task task = ra.getTask(); assertEquals(intOne, task.getID()); assertEquals(Integer.valueOf(2), task.getUniqueID()); assertEquals("Task A", task.getName()); // units assertEquals(Double.valueOf(100), ra.getUnits()); // work and remaining work Duration dur24Hours = Duration.getInstance(24, TimeUnit.HOURS); assertEquals(dur24Hours, ra.getWork()); assertEquals(dur24Hours, ra.getRemainingWork()); // // Baseline values // assertEquals("01/01/2006", df.format(ra.getBaselineStart())); assertEquals("02/01/2006", df.format(ra.getBaselineFinish())); assertEquals(1, ra.getBaselineCost().intValue()); assertEquals("2.0h", ra.getBaselineWork().toString()); // Task 2 // contour ResourceAssignment ra2 = listResourceAssignments.get(3); assertEquals(WorkContour.TURTLE, ra2.getWorkContour()); // Task 3 // completed task = mpp.getTaskByUniqueID(Integer.valueOf(4)); assertEquals("Completed Task", task.getName()); ResourceAssignment ra3 = task.getResourceAssignments().get(0); // // Actual values // // actual start 26/08/06 assertEquals("26/08/2006", df.format(ra3.getActualStart())); // actual finish 29/08/06 assertEquals("29/08/2006", df.format(ra3.getActualFinish())); // actual work 16h assertEquals("16.0h", ra3.getActualWork().toString()); // actual cost $800 assertEquals(800, ra3.getActualCost().intValue()); }