net.sf.mpxj.RelationType Java Examples
The following examples show how to use
net.sf.mpxj.RelationType.
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: SageReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Process an individual predecessor. * * @param line predecessor record */ private void processPredecessor(String line) { String[] columns = line.split("\t"); Task task = m_taskMap.get(parseID(columns, 0)); if (task == null) { return; } Task predecessor = m_taskMap.get(parseID(columns, 1)); if (predecessor == null) { return; } RelationType type = parseRelationType(columns, 2); Duration lag = parseDuration(columns, 3); // columns[4] - job // columns[5] - predecessor name // columns[6] - unknown // columns[7] - unknown task.addPredecessor(predecessor, type, lag); }
Example #2
Source File: GanttDesignerReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read predecessors from a Gantt Designer file. * * @param gantt Gantt Designer file */ private void processPredecessors(Gantt gantt) { for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask()) { String predecessors = ganttTask.getP(); if (predecessors != null && !predecessors.isEmpty()) { String wbs = ganttTask.getID(); Task task = m_taskMap.get(wbs); for (String predecessor : predecessors.split(";")) { Task predecessorTask = m_projectFile.getTaskByID(Integer.valueOf(predecessor)); task.addPredecessor(predecessorTask, RelationType.FINISH_START, ganttTask.getL()); } } } }
Example #3
Source File: RelationTypeUtility.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method takes the textual version of a relation type * and returns an appropriate class instance. Note that unrecognised * values will cause this method to return null. * * @param locale target locale * @param type text version of the relation type * @return RelationType instance */ public static RelationType getInstance(Locale locale, String type) { int index = -1; String[] relationTypes = LocaleData.getStringArray(locale, LocaleData.RELATION_TYPES); for (int loop = 0; loop < relationTypes.length; loop++) { if (relationTypes[loop].equalsIgnoreCase(type) == true) { index = loop; break; } } RelationType result = null; if (index != -1) { result = RelationType.getInstance(index); } return (result); }
Example #4
Source File: TaskLinksTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test a relationship between two tasks. * * @param project parent project * @param taskID1 first task * @param taskID2 second task * @param name1 expected task name 1 * @param name2 expected task name 1 * @param type expected relation type * @param lagDuration expected lag duration * @param lagUnits expected lag units */ private void testTaskLinks(ProjectFile project, int taskID1, int taskID2, String name1, String name2, RelationType type, double lagDuration, TimeUnit lagUnits) { Task task1 = project.getTaskByID(Integer.valueOf(taskID1)); Task task2 = project.getTaskByID(Integer.valueOf(taskID2)); assertEquals(name1, task1.getName()); assertEquals(name2, task2.getName()); List<Relation> relations = task2.getPredecessors(); assertEquals(1, relations.size()); Relation relation = relations.get(0); assertEquals(task2, relation.getSourceTask()); assertEquals(task1, relation.getTargetTask()); assertEquals(type, relation.getType()); assertEquals(lagUnits, relation.getLag().getUnits()); assertTrue(NumberHelper.equals(lagDuration, relation.getLag().getDuration(), 0.0001)); }
Example #5
Source File: P3DatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read task relationships. */ private void readRelationships() { for (MapRow row : m_tables.get("REL")) { Task predecessor = m_activityMap.get(row.getString("PREDECESSOR_ACTIVITY_ID")); Task successor = m_activityMap.get(row.getString("SUCCESSOR_ACTIVITY_ID")); if (predecessor != null && successor != null) { Duration lag = row.getDuration("LAG_VALUE"); RelationType type = row.getRelationType("LAG_TYPE"); successor.addPredecessor(predecessor, type, lag); } } }
Example #6
Source File: GanttProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Convert a GanttProject task relationship type into an MPXJ RelationType instance. * * @param gpType GanttProject task relation type * @return RelationType instance */ private RelationType getRelationType(Integer gpType) { RelationType result = null; if (gpType != null) { int index = NumberHelper.getInt(gpType); if (index > 0 && index < RELATION.length) { result = RELATION[index]; } } if (result == null) { result = RelationType.FINISH_START; } return result; }
Example #7
Source File: TurboProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read relationship data from a PEP file. */ private void readRelationships() { for (MapRow row : getTable("CONTAB")) { Task task1 = m_projectFile.getTaskByUniqueID(row.getInteger("TASK_ID_1")); Task task2 = m_projectFile.getTaskByUniqueID(row.getInteger("TASK_ID_2")); if (task1 != null && task2 != null) { RelationType type = row.getRelationType("TYPE"); Duration lag = row.getDuration("LAG"); Relation relation = task2.addPredecessor(task1, type, lag); m_eventManager.fireRelationReadEvent(relation); } } }
Example #8
Source File: ProjectCommanderReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read any relationships for a single task. * * @param task parent task * @param block relationship data */ private void readRelationships(Task task, Block block) { byte[] data = block.getData(); int successorTaskUniqueID = DatatypeConverter.getShort(data, 0); Task successor = m_projectFile.getTaskByUniqueID(Integer.valueOf(successorTaskUniqueID)); if (successor == null || task.isSucessor(successor) || task.isPredecessor(successor) || data.length == 14) { return; } Duration lag = DatatypeConverter.getDuration(data, 6); RelationType type = DatatypeConverter.getRelationType(data, 2); successor.addPredecessor(task, type, lag); }
Example #9
Source File: ExternalPredecessorRelation.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Default constructor. * * @param sourceUniqueID source task unique ID * @param targetTask target task instance * @param type relation type * @param lag relation lag */ public ExternalPredecessorRelation(Integer sourceUniqueID, Task targetTask, RelationType type, Duration lag) { m_sourceUniqueID = sourceUniqueID; m_targetTask = targetTask; m_type = type; m_lag = lag; if (m_type == null) { m_type = RelationType.FINISH_START; } if (m_lag == null) { m_lag = Duration.getInstance(0, TimeUnit.DAYS); } }
Example #10
Source File: PrimaveraPMFileReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Process predecessors. * * @param project xml container */ private void processPredecessors(ProjectType project) { for (RelationshipType row : project.getRelationship()) { Task currentTask = m_projectFile.getTaskByUniqueID(mapTaskID(row.getSuccessorActivityObjectId())); Task predecessorTask = m_projectFile.getTaskByUniqueID(mapTaskID(row.getPredecessorActivityObjectId())); if (currentTask != null && predecessorTask != null) { RelationType type = RELATION_TYPE_MAP.get(row.getType()); Duration lag = getDuration(row.getLag()); Relation relation = currentTask.addPredecessor(predecessorTask, type, lag); relation.setUniqueID(row.getObjectId()); m_eventManager.fireRelationReadEvent(relation); } } }
Example #11
Source File: SureTrakDatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read task relationships. */ private void readRelationships() { for (MapRow row : m_tables.get("REL")) { Task predecessor = m_activityMap.get(row.getString("PREDECESSOR_ACTIVITY_ID")); Task successor = m_activityMap.get(row.getString("SUCCESSOR_ACTIVITY_ID")); if (predecessor != null && successor != null) { Duration lag = row.getDuration("LAG"); RelationType type = row.getRelationType("TYPE"); successor.addPredecessor(predecessor, type, lag); } } }
Example #12
Source File: MapRow.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} */ @Override public RelationType getRelationType(String name) { RelationType result; int type = getInt(name); switch (type) { case 1: { result = RelationType.START_START; break; } case 2: { result = RelationType.FINISH_FINISH; break; } case 3: { result = RelationType.START_FINISH; break; } case 0: default: { result = RelationType.FINISH_START; break; } } return result; }
Example #13
Source File: TableCONTAB.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert an integer into a RelationType instance. * * @param value relation type as an integer * @return RelationType instance */ private RelationType getRelationType(int value) { RelationType result = null; if (value >= 0 || value < RELATION_TYPES.length) { result = RELATION_TYPES[value]; } if (result == null) { result = RelationType.FINISH_START; } return result; }
Example #14
Source File: RelationTypeColumn.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
@Override public RelationType read(int offset, byte[] data) { int result = data[m_offset + offset]; RelationType type = null; if (result >= 0 || result < TYPES.length) { type = TYPES[result]; } if (type == null) { type = RelationType.FINISH_START; } return type; }
Example #15
Source File: ProjectFileExporter.java From ganttproject with GNU General Public License v3.0 | 5 votes |
private RelationType convertConstraint(TaskDependency dep) { switch (dep.getConstraint().getType()) { case finishstart: return RelationType.FINISH_START; case startfinish: return RelationType.START_FINISH; case finishfinish: return RelationType.FINISH_FINISH; case startstart: return RelationType.START_START; default: assert false : "Should not be here"; return null; } }
Example #16
Source File: PhoenixReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read an individual Phoenix task relationship. * * @param relation Phoenix task relationship */ private void readRelation(Relationship relation) { Task predecessor = m_activityMap.get(relation.getPredecessor()); Task successor = m_activityMap.get(relation.getSuccessor()); if (predecessor != null && successor != null) { Duration lag = relation.getLag(); RelationType type = relation.getType(); successor.addPredecessor(predecessor, type, lag); } }
Example #17
Source File: SageReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Parse a relationship type value from a record. * * @param columns record * @param index field index * @return relationship type value */ private RelationType parseRelationType(String[] columns, int index) { RelationType result = null; String text = getText(columns, index); if (text != null) { result = RELATION_TYPE_MAP.get(text); } if (result == null) { result = RelationType.FINISH_START; } return result; }
Example #18
Source File: MpxjQuery.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Internal utility to dump relationship lists in a structured format * that can easily be compared with the tabular data in MS Project. * * @param relations relation list */ private static void dumpRelationList(List<Relation> relations) { if (relations != null && relations.isEmpty() == false) { if (relations.size() > 1) { System.out.print('"'); } boolean first = true; for (Relation relation : relations) { if (!first) { System.out.print(','); } first = false; System.out.print(relation.getTargetTask().getID()); Duration lag = relation.getLag(); if (relation.getType() != RelationType.FINISH_START || lag.getDuration() != 0) { System.out.print(relation.getType()); } if (lag.getDuration() != 0) { if (lag.getDuration() > 0) { System.out.print("+"); } System.out.print(lag); } } if (relations.size() > 1) { System.out.print('"'); } } }
Example #19
Source File: MPD9AbstractReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process a relationship between two tasks. * * @param row relationship data */ protected void processLink(Row row) { Task predecessorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_PRED_UID")); Task successorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_SUCC_UID")); if (predecessorTask != null && successorTask != null) { RelationType type = RelationType.getInstance(row.getInt("LINK_TYPE")); TimeUnit durationUnits = MPDUtility.getDurationTimeUnits(row.getInt("LINK_LAG_FMT")); Duration duration = MPDUtility.getDuration(row.getDouble("LINK_LAG").doubleValue(), durationUnits); Relation relation = successorTask.addPredecessor(predecessorTask, type, duration); relation.setUniqueID(row.getInteger("LINK_UID")); m_eventManager.fireRelationReadEvent(relation); } }
Example #20
Source File: MerlinReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read relation data. */ private void processDependencies() throws SQLException { List<Row> rows = getRows("select * from zdependency where zproject=?", m_projectID); for (Row row : rows) { Task nextTask = m_project.getTaskByUniqueID(row.getInteger("ZNEXTACTIVITY_")); Task prevTask = m_project.getTaskByUniqueID(row.getInteger("ZPREVIOUSACTIVITY_")); Duration lag = row.getDuration("ZLAG_"); RelationType type = row.getRelationType("ZTYPE"); Relation relation = nextTask.addPredecessor(prevTask, type, lag); relation.setUniqueID(row.getInteger("Z_PK")); } }
Example #21
Source File: RelationTypeColumn.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
@Override public RelationType read(int offset, byte[] data) { int result = readShort(offset, data); RelationType type = null; if (result >= 0 && result < TYPES.length) { type = TYPES[result]; } if (type == null) { type = RelationType.START_FINISH; } return type; }
Example #22
Source File: AstaReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert an integer into a RelationType instance. * * @param index integer value * @return RelationType instance */ private RelationType getRelationType(int index) { if (index < 0 || index > RELATION_TYPES.length) { index = 0; } return RELATION_TYPES[index]; }
Example #23
Source File: DatatypeConverter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Retrieve a RelationType from the byte array. * * @param data byte array * @param offset offset into byte array * @return RelationType instance */ public static final RelationType getRelationType(byte[] data, int offset) { RelationType result; int value = getByte(data, offset); switch (value) { case 5: { result = RelationType.START_FINISH; break; } case 6: { result = RelationType.START_START; break; } case 7: { result = RelationType.FINISH_FINISH; break; } case 8: default: { result = RelationType.FINISH_START; break; } } return result; }
Example #24
Source File: PredecessorReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Convert an integer to a RelationType instance. * * @param type integer value * @return RelationType instance */ private RelationType getRelationType(int type) { RelationType result; if (type > 0 && type < RELATION_TYPES.length) { result = RELATION_TYPES[type]; } else { result = RelationType.FINISH_START; } return result; }
Example #25
Source File: TaskLinksTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test an individual project. * * @param file project file */ private void testTaskLinks(File file) throws MPXJException { ProjectReader reader = ProjectReaderUtility.getProjectReader(file.getName()); if (reader instanceof MPDDatabaseReader) { assumeJvm(); } ProjectFile project = reader.read(file); // // Test different durations and time units // testTaskLinks(project, 1, 2, "Task 1", "Task 2", RelationType.FINISH_START, 0, TimeUnit.DAYS); testTaskLinks(project, 3, 4, "Task 1", "Task 2", RelationType.FINISH_START, 1, TimeUnit.DAYS); testTaskLinks(project, 5, 6, "Task 1", "Task 2", RelationType.FINISH_START, 2, TimeUnit.DAYS); testTaskLinks(project, 7, 8, "Task 1", "Task 2", RelationType.FINISH_START, 1, TimeUnit.WEEKS); testTaskLinks(project, 9, 10, "Task 1", "Task 2", RelationType.FINISH_START, 2, TimeUnit.WEEKS); // // Test different relation types // testTaskLinks(project, 11, 12, "Task 1", "Task 2", RelationType.START_FINISH, 2, TimeUnit.DAYS); testTaskLinks(project, 13, 14, "Task 1", "Task 2", RelationType.START_START, 2, TimeUnit.DAYS); testTaskLinks(project, 15, 16, "Task 1", "Task 2", RelationType.FINISH_FINISH, 2, TimeUnit.DAYS); }
Example #26
Source File: ConceptDrawProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read a task relationship. * * @param link ConceptDraw PROJECT task link */ private void readRelationship(Link link) { Task sourceTask = m_taskIdMap.get(link.getSourceTaskID()); Task destinationTask = m_taskIdMap.get(link.getDestinationTaskID()); if (sourceTask != null && destinationTask != null) { Duration lag = getDuration(link.getLagUnit(), link.getLag()); RelationType type = link.getType(); Relation relation = destinationTask.addPredecessor(sourceTask, type, lag); relation.setUniqueID(link.getID()); } }
Example #27
Source File: MPXWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method is called to format a relation. * * @param relation relation instance * @return formatted relation instance */ private String formatRelation(Relation relation) { String result = null; if (relation != null) { StringBuilder sb = new StringBuilder(relation.getTargetTask().getID().toString()); Duration duration = relation.getLag(); RelationType type = relation.getType(); double durationValue = duration.getDuration(); if ((durationValue != 0) || (type != RelationType.FINISH_START)) { String[] typeNames = LocaleData.getStringArray(m_locale, LocaleData.RELATION_TYPES); sb.append(typeNames[type.getValue()]); } if (durationValue != 0) { if (durationValue > 0) { sb.append('+'); } sb.append(formatDuration(duration)); } result = sb.toString(); } m_eventManager.fireRelationWrittenEvent(relation); return (result); }
Example #28
Source File: MSPDIWriter.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method writes a single predecessor link to the MSPDI file. * * @param taskID The task UID * @param type The predecessor type * @param lag The lag duration * @return A new link to be added to the MSPDI file */ private Project.Tasks.Task.PredecessorLink writePredecessor(Integer taskID, RelationType type, Duration lag) { Project.Tasks.Task.PredecessorLink link = m_factory.createProjectTasksTaskPredecessorLink(); link.setPredecessorUID(NumberHelper.getBigInteger(taskID)); link.setType(BigInteger.valueOf(type.getValue())); link.setCrossProject(Boolean.FALSE); // SF-300: required to keep P6 happy when importing MSPDI files if (lag != null && lag.getDuration() != 0) { double linkLag = lag.getDuration(); if (lag.getUnits() != TimeUnit.PERCENT && lag.getUnits() != TimeUnit.ELAPSED_PERCENT) { linkLag = 10.0 * Duration.convertUnits(linkLag, lag.getUnits(), TimeUnit.MINUTES, m_projectFile.getProjectProperties()).getDuration(); } link.setLinkLag(BigInteger.valueOf((long) linkLag)); link.setLagFormat(DatatypeConverter.printDurationTimeUnits(lag.getUnits(), false)); } else { // SF-329: default required to keep Powerproject happy when importing MSPDI files link.setLinkLag(BIGINTEGER_ZERO); link.setLagFormat(DatatypeConverter.printDurationTimeUnits(m_projectFile.getProjectProperties().getDefaultDurationUnits(), false)); } return (link); }
Example #29
Source File: ExportMSProject.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
private static RelationType getRelationType(final GanttRelationType type) { if (type == null || type == GanttRelationType.FINISH_START) { return RelationType.FINISH_START; } else if (type == GanttRelationType.FINISH_FINISH) { return RelationType.FINISH_FINISH; } else if (type == GanttRelationType.START_START) { return RelationType.START_START; } else if (type == GanttRelationType.START_FINISH) { return RelationType.START_FINISH; } else { log.error("Unsupported relation type: " + type); return RelationType.FINISH_START; } }
Example #30
Source File: Adapter7.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
@Override public String marshal(RelationType value) { return (net.sf.mpxj.phoenix.DatatypeConverter.printRelationType(value)); }