Java Code Examples for net.sf.mpxj.RelationType#FINISH_START
The following examples show how to use
net.sf.mpxj.RelationType#FINISH_START .
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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * This method extracts data for a single predecessor from an MSPDI file. * * @param currTask Current task object * @param link Predecessor data */ private void readPredecessor(Task currTask, Project.Tasks.Task.PredecessorLink link) { BigInteger uid = link.getPredecessorUID(); if (uid != null) { Task prevTask = m_projectFile.getTaskByUniqueID(Integer.valueOf(uid.intValue())); if (prevTask != null) { RelationType type; if (link.getType() != null) { type = RelationType.getInstance(link.getType().intValue()); } else { type = RelationType.FINISH_START; } TimeUnit lagUnits = DatatypeConverter.parseDurationTimeUnits(link.getLagFormat()); Duration lagDuration; int lag = NumberHelper.getInt(link.getLinkLag()); if (lag == 0) { lagDuration = Duration.getInstance(0, lagUnits); } else { if (lagUnits == TimeUnit.PERCENT || lagUnits == TimeUnit.ELAPSED_PERCENT) { lagDuration = Duration.getInstance(lag, lagUnits); } else { lagDuration = Duration.convertUnits(lag / 10.0, TimeUnit.MINUTES, lagUnits, m_projectFile.getProjectProperties()); } } Relation relation = currTask.addPredecessor(prevTask, type, lagDuration); m_eventManager.fireRelationReadEvent(relation); } } }
Example 13
Source File: MPXReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates and populates a new task relationship. * * @param field which task field source of data * @param sourceTask relationship source task * @param relationship relationship string * @throws MPXJException */ private void populateRelation(TaskField field, Task sourceTask, String relationship) throws MPXJException { int index = 0; int length = relationship.length(); // // Extract the identifier // while ((index < length) && (Character.isDigit(relationship.charAt(index)) == true)) { ++index; } Integer taskID; try { taskID = Integer.valueOf(relationship.substring(0, index)); } catch (NumberFormatException ex) { throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'"); } // // Now find the task, so we can extract the unique ID // Task targetTask; if (field == TaskField.PREDECESSORS) { targetTask = m_projectFile.getTaskByID(taskID); } else { targetTask = m_projectFile.getTaskByUniqueID(taskID); } // // If we haven't reached the end, we next expect to find // SF, SS, FS, FF // RelationType type = null; Duration lag = null; if (index == length) { type = RelationType.FINISH_START; lag = Duration.getInstance(0, TimeUnit.DAYS); } else { if ((index + 1) == length) { throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'"); } type = RelationTypeUtility.getInstance(m_locale, relationship.substring(index, index + 2)); index += 2; if (index == length) { lag = Duration.getInstance(0, TimeUnit.DAYS); } else { if (relationship.charAt(index) == '+') { ++index; } lag = DurationUtility.getInstance(relationship.substring(index), m_formats.getDurationDecimalFormat(), m_locale); } } if (type == null) { throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'"); } // We have seen at least one example MPX file where an invalid task ID // is present. We'll ignore this as the schedule is otherwise valid. if (targetTask != null) { Relation relation = sourceTask.addPredecessor(targetTask, type, lag); m_eventManager.fireRelationReadEvent(relation); } }