id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
157,600
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleByteOrderMark
private ProjectFile handleByteOrderMark(InputStream stream, int length, Charset charset) throws Exception { UniversalProjectReader reader = new UniversalProjectReader(); reader.setSkipBytes(length); reader.setCharset(charset); return reader.read(stream); }
java
private ProjectFile handleByteOrderMark(InputStream stream, int length, Charset charset) throws Exception { UniversalProjectReader reader = new UniversalProjectReader(); reader.setSkipBytes(length); reader.setCharset(charset); return reader.read(stream); }
[ "private", "ProjectFile", "handleByteOrderMark", "(", "InputStream", "stream", ",", "int", "length", ",", "Charset", "charset", ")", "throws", "Exception", "{", "UniversalProjectReader", "reader", "=", "new", "UniversalProjectReader", "(", ")", ";", "reader", ".", "setSkipBytes", "(", "length", ")", ";", "reader", ".", "setCharset", "(", "charset", ")", ";", "return", "reader", ".", "read", "(", "stream", ")", ";", "}" ]
The file we are working with has a byte order mark. Skip this and try again to read the file. @param stream schedule data @param length length of the byte order mark @param charset charset indicated by byte order mark @return ProjectFile instance
[ "The", "file", "we", "are", "working", "with", "has", "a", "byte", "order", "mark", ".", "Skip", "this", "and", "try", "again", "to", "read", "the", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L674-L680
157,601
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleDosExeFile
private ProjectFile handleDosExeFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".tmp"); InputStream is = null; try { is = new FileInputStream(file); if (is.available() > 1350) { StreamHelper.skip(is, 1024); // Bytes at offset 1024 byte[] data = new byte[2]; is.read(data); if (matchesFingerprint(data, WINDOWS_NE_EXE_FINGERPRINT)) { StreamHelper.skip(is, 286); // Bytes at offset 1312 data = new byte[34]; is.read(data); if (matchesFingerprint(data, PRX_FINGERPRINT)) { is.close(); is = null; return readProjectFile(new P3PRXFileReader(), file); } } if (matchesFingerprint(data, STX_FINGERPRINT)) { StreamHelper.skip(is, 31742); // Bytes at offset 32768 data = new byte[4]; is.read(data); if (matchesFingerprint(data, PRX3_FINGERPRINT)) { is.close(); is = null; return readProjectFile(new SureTrakSTXFileReader(), file); } } } return null; } finally { StreamHelper.closeQuietly(is); FileHelper.deleteQuietly(file); } }
java
private ProjectFile handleDosExeFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".tmp"); InputStream is = null; try { is = new FileInputStream(file); if (is.available() > 1350) { StreamHelper.skip(is, 1024); // Bytes at offset 1024 byte[] data = new byte[2]; is.read(data); if (matchesFingerprint(data, WINDOWS_NE_EXE_FINGERPRINT)) { StreamHelper.skip(is, 286); // Bytes at offset 1312 data = new byte[34]; is.read(data); if (matchesFingerprint(data, PRX_FINGERPRINT)) { is.close(); is = null; return readProjectFile(new P3PRXFileReader(), file); } } if (matchesFingerprint(data, STX_FINGERPRINT)) { StreamHelper.skip(is, 31742); // Bytes at offset 32768 data = new byte[4]; is.read(data); if (matchesFingerprint(data, PRX3_FINGERPRINT)) { is.close(); is = null; return readProjectFile(new SureTrakSTXFileReader(), file); } } } return null; } finally { StreamHelper.closeQuietly(is); FileHelper.deleteQuietly(file); } }
[ "private", "ProjectFile", "handleDosExeFile", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "File", "file", "=", "InputStreamHelper", ".", "writeStreamToTempFile", "(", "stream", ",", "\".tmp\"", ")", ";", "InputStream", "is", "=", "null", ";", "try", "{", "is", "=", "new", "FileInputStream", "(", "file", ")", ";", "if", "(", "is", ".", "available", "(", ")", ">", "1350", ")", "{", "StreamHelper", ".", "skip", "(", "is", ",", "1024", ")", ";", "// Bytes at offset 1024", "byte", "[", "]", "data", "=", "new", "byte", "[", "2", "]", ";", "is", ".", "read", "(", "data", ")", ";", "if", "(", "matchesFingerprint", "(", "data", ",", "WINDOWS_NE_EXE_FINGERPRINT", ")", ")", "{", "StreamHelper", ".", "skip", "(", "is", ",", "286", ")", ";", "// Bytes at offset 1312", "data", "=", "new", "byte", "[", "34", "]", ";", "is", ".", "read", "(", "data", ")", ";", "if", "(", "matchesFingerprint", "(", "data", ",", "PRX_FINGERPRINT", ")", ")", "{", "is", ".", "close", "(", ")", ";", "is", "=", "null", ";", "return", "readProjectFile", "(", "new", "P3PRXFileReader", "(", ")", ",", "file", ")", ";", "}", "}", "if", "(", "matchesFingerprint", "(", "data", ",", "STX_FINGERPRINT", ")", ")", "{", "StreamHelper", ".", "skip", "(", "is", ",", "31742", ")", ";", "// Bytes at offset 32768", "data", "=", "new", "byte", "[", "4", "]", ";", "is", ".", "read", "(", "data", ")", ";", "if", "(", "matchesFingerprint", "(", "data", ",", "PRX3_FINGERPRINT", ")", ")", "{", "is", ".", "close", "(", ")", ";", "is", "=", "null", ";", "return", "readProjectFile", "(", "new", "SureTrakSTXFileReader", "(", ")", ",", "file", ")", ";", "}", "}", "}", "return", "null", ";", "}", "finally", "{", "StreamHelper", ".", "closeQuietly", "(", "is", ")", ";", "FileHelper", ".", "deleteQuietly", "(", "file", ")", ";", "}", "}" ]
This could be a self-extracting archive. If we understand the format, expand it and check the content for files we can read. @param stream schedule data @return ProjectFile instance
[ "This", "could", "be", "a", "self", "-", "extracting", "archive", ".", "If", "we", "understand", "the", "format", "expand", "it", "and", "check", "the", "content", "for", "files", "we", "can", "read", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L689-L742
157,602
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleXerFile
private ProjectFile handleXerFile(InputStream stream) throws Exception { PrimaveraXERFileReader reader = new PrimaveraXERFileReader(); reader.setCharset(m_charset); List<ProjectFile> projects = reader.readAll(stream); ProjectFile project = null; for (ProjectFile file : projects) { if (file.getProjectProperties().getExportFlag()) { project = file; break; } } if (project == null && !projects.isEmpty()) { project = projects.get(0); } return project; }
java
private ProjectFile handleXerFile(InputStream stream) throws Exception { PrimaveraXERFileReader reader = new PrimaveraXERFileReader(); reader.setCharset(m_charset); List<ProjectFile> projects = reader.readAll(stream); ProjectFile project = null; for (ProjectFile file : projects) { if (file.getProjectProperties().getExportFlag()) { project = file; break; } } if (project == null && !projects.isEmpty()) { project = projects.get(0); } return project; }
[ "private", "ProjectFile", "handleXerFile", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "PrimaveraXERFileReader", "reader", "=", "new", "PrimaveraXERFileReader", "(", ")", ";", "reader", ".", "setCharset", "(", "m_charset", ")", ";", "List", "<", "ProjectFile", ">", "projects", "=", "reader", ".", "readAll", "(", "stream", ")", ";", "ProjectFile", "project", "=", "null", ";", "for", "(", "ProjectFile", "file", ":", "projects", ")", "{", "if", "(", "file", ".", "getProjectProperties", "(", ")", ".", "getExportFlag", "(", ")", ")", "{", "project", "=", "file", ";", "break", ";", "}", "}", "if", "(", "project", "==", "null", "&&", "!", "projects", ".", "isEmpty", "(", ")", ")", "{", "project", "=", "projects", ".", "get", "(", "0", ")", ";", "}", "return", "project", ";", "}" ]
XER files can contain multiple projects when there are cross-project dependencies. As the UniversalProjectReader is designed just to read a single project, we need to select one project from those available in the XER file. The original project selected for export by the user will have its "export flag" set to true. We'll return the first project we find where the export flag is set to true, otherwise we'll just return the first project we find in the file. @param stream schedule data @return ProjectFile instance
[ "XER", "files", "can", "contain", "multiple", "projects", "when", "there", "are", "cross", "-", "project", "dependencies", ".", "As", "the", "UniversalProjectReader", "is", "designed", "just", "to", "read", "a", "single", "project", "we", "need", "to", "select", "one", "project", "from", "those", "available", "in", "the", "XER", "file", ".", "The", "original", "project", "selected", "for", "export", "by", "the", "user", "will", "have", "its", "export", "flag", "set", "to", "true", ".", "We", "ll", "return", "the", "first", "project", "we", "find", "where", "the", "export", "flag", "is", "set", "to", "true", "otherwise", "we", "ll", "just", "return", "the", "first", "project", "we", "find", "in", "the", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L755-L774
157,603
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.populateTableNames
private Set<String> populateTableNames(String url) throws SQLException { Set<String> tableNames = new HashSet<String>(); Connection connection = null; ResultSet rs = null; try { connection = DriverManager.getConnection(url); DatabaseMetaData dmd = connection.getMetaData(); rs = dmd.getTables(null, null, null, null); while (rs.next()) { tableNames.add(rs.getString("TABLE_NAME").toUpperCase()); } } finally { if (rs != null) { rs.close(); } if (connection != null) { connection.close(); } } return tableNames; }
java
private Set<String> populateTableNames(String url) throws SQLException { Set<String> tableNames = new HashSet<String>(); Connection connection = null; ResultSet rs = null; try { connection = DriverManager.getConnection(url); DatabaseMetaData dmd = connection.getMetaData(); rs = dmd.getTables(null, null, null, null); while (rs.next()) { tableNames.add(rs.getString("TABLE_NAME").toUpperCase()); } } finally { if (rs != null) { rs.close(); } if (connection != null) { connection.close(); } } return tableNames; }
[ "private", "Set", "<", "String", ">", "populateTableNames", "(", "String", "url", ")", "throws", "SQLException", "{", "Set", "<", "String", ">", "tableNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "Connection", "connection", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "try", "{", "connection", "=", "DriverManager", ".", "getConnection", "(", "url", ")", ";", "DatabaseMetaData", "dmd", "=", "connection", ".", "getMetaData", "(", ")", ";", "rs", "=", "dmd", ".", "getTables", "(", "null", ",", "null", ",", "null", ",", "null", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "tableNames", ".", "add", "(", "rs", ".", "getString", "(", "\"TABLE_NAME\"", ")", ".", "toUpperCase", "(", ")", ")", ";", "}", "}", "finally", "{", "if", "(", "rs", "!=", "null", ")", "{", "rs", ".", "close", "(", ")", ";", "}", "if", "(", "connection", "!=", "null", ")", "{", "connection", ".", "close", "(", ")", ";", "}", "}", "return", "tableNames", ";", "}" ]
Open a database and build a set of table names. @param url database URL @return set containing table names
[ "Open", "a", "database", "and", "build", "a", "set", "of", "table", "names", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L782-L813
157,604
joniles/mpxj
src/main/java/net/sf/mpxj/common/StreamHelper.java
StreamHelper.skip
public static void skip(InputStream stream, long skip) throws IOException { long count = skip; while (count > 0) { count -= stream.skip(count); } }
java
public static void skip(InputStream stream, long skip) throws IOException { long count = skip; while (count > 0) { count -= stream.skip(count); } }
[ "public", "static", "void", "skip", "(", "InputStream", "stream", ",", "long", "skip", ")", "throws", "IOException", "{", "long", "count", "=", "skip", ";", "while", "(", "count", ">", "0", ")", "{", "count", "-=", "stream", ".", "skip", "(", "count", ")", ";", "}", "}" ]
The documentation for InputStream.skip indicates that it can bail out early, and not skip the requested number of bytes. I've encountered this in practice, hence this helper method. @param stream InputStream instance @param skip number of bytes to skip
[ "The", "documentation", "for", "InputStream", ".", "skip", "indicates", "that", "it", "can", "bail", "out", "early", "and", "not", "skip", "the", "requested", "number", "of", "bytes", ".", "I", "ve", "encountered", "this", "in", "practice", "hence", "this", "helper", "method", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/StreamHelper.java#L41-L48
157,605
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPP9Reader.java
MPP9Reader.processCustomValueLists
private void processCustomValueLists() throws IOException { CustomFieldValueReader9 reader = new CustomFieldValueReader9(m_projectDir, m_file.getProjectProperties(), m_projectProps, m_file.getCustomFields()); reader.process(); }
java
private void processCustomValueLists() throws IOException { CustomFieldValueReader9 reader = new CustomFieldValueReader9(m_projectDir, m_file.getProjectProperties(), m_projectProps, m_file.getCustomFields()); reader.process(); }
[ "private", "void", "processCustomValueLists", "(", ")", "throws", "IOException", "{", "CustomFieldValueReader9", "reader", "=", "new", "CustomFieldValueReader9", "(", "m_projectDir", ",", "m_file", ".", "getProjectProperties", "(", ")", ",", "m_projectProps", ",", "m_file", ".", "getCustomFields", "(", ")", ")", ";", "reader", ".", "process", "(", ")", ";", "}" ]
Retrieve any task field value lists defined in the MPP file.
[ "Retrieve", "any", "task", "field", "value", "lists", "defined", "in", "the", "MPP", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP9Reader.java#L750-L754
157,606
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPP9Reader.java
MPP9Reader.processFieldNameAliases
private void processFieldNameAliases(Map<Integer, FieldType> map, byte[] data) { if (data != null) { int offset = 0; int index = 0; CustomFieldContainer fields = m_file.getCustomFields(); while (offset < data.length) { String alias = MPPUtility.getUnicodeString(data, offset); if (!alias.isEmpty()) { FieldType field = map.get(Integer.valueOf(index)); if (field != null) { fields.getCustomField(field).setAlias(alias); } } offset += (alias.length() + 1) * 2; index++; } } }
java
private void processFieldNameAliases(Map<Integer, FieldType> map, byte[] data) { if (data != null) { int offset = 0; int index = 0; CustomFieldContainer fields = m_file.getCustomFields(); while (offset < data.length) { String alias = MPPUtility.getUnicodeString(data, offset); if (!alias.isEmpty()) { FieldType field = map.get(Integer.valueOf(index)); if (field != null) { fields.getCustomField(field).setAlias(alias); } } offset += (alias.length() + 1) * 2; index++; } } }
[ "private", "void", "processFieldNameAliases", "(", "Map", "<", "Integer", ",", "FieldType", ">", "map", ",", "byte", "[", "]", "data", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "int", "offset", "=", "0", ";", "int", "index", "=", "0", ";", "CustomFieldContainer", "fields", "=", "m_file", ".", "getCustomFields", "(", ")", ";", "while", "(", "offset", "<", "data", ".", "length", ")", "{", "String", "alias", "=", "MPPUtility", ".", "getUnicodeString", "(", "data", ",", "offset", ")", ";", "if", "(", "!", "alias", ".", "isEmpty", "(", ")", ")", "{", "FieldType", "field", "=", "map", ".", "get", "(", "Integer", ".", "valueOf", "(", "index", ")", ")", ";", "if", "(", "field", "!=", "null", ")", "{", "fields", ".", "getCustomField", "(", "field", ")", ".", "setAlias", "(", "alias", ")", ";", "}", "}", "offset", "+=", "(", "alias", ".", "length", "(", ")", "+", "1", ")", "*", "2", ";", "index", "++", ";", "}", "}", "}" ]
Retrieve any resource field aliases defined in the MPP file. @param map index to field map @param data resource field name alias data
[ "Retrieve", "any", "resource", "field", "aliases", "defined", "in", "the", "MPP", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP9Reader.java#L864-L886
157,607
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPP9Reader.java
MPP9Reader.createResourceMap
private TreeMap<Integer, Integer> createResourceMap(FieldMap fieldMap, FixedMeta rscFixedMeta, FixedData rscFixedData) { TreeMap<Integer, Integer> resourceMap = new TreeMap<Integer, Integer>(); int itemCount = rscFixedMeta.getAdjustedItemCount(); for (int loop = 0; loop < itemCount; loop++) { byte[] data = rscFixedData.getByteArrayValue(loop); if (data == null || data.length < fieldMap.getMaxFixedDataSize(0)) { continue; } Integer uniqueID = Integer.valueOf(MPPUtility.getShort(data, 0)); resourceMap.put(uniqueID, Integer.valueOf(loop)); } return (resourceMap); }
java
private TreeMap<Integer, Integer> createResourceMap(FieldMap fieldMap, FixedMeta rscFixedMeta, FixedData rscFixedData) { TreeMap<Integer, Integer> resourceMap = new TreeMap<Integer, Integer>(); int itemCount = rscFixedMeta.getAdjustedItemCount(); for (int loop = 0; loop < itemCount; loop++) { byte[] data = rscFixedData.getByteArrayValue(loop); if (data == null || data.length < fieldMap.getMaxFixedDataSize(0)) { continue; } Integer uniqueID = Integer.valueOf(MPPUtility.getShort(data, 0)); resourceMap.put(uniqueID, Integer.valueOf(loop)); } return (resourceMap); }
[ "private", "TreeMap", "<", "Integer", ",", "Integer", ">", "createResourceMap", "(", "FieldMap", "fieldMap", ",", "FixedMeta", "rscFixedMeta", ",", "FixedData", "rscFixedData", ")", "{", "TreeMap", "<", "Integer", ",", "Integer", ">", "resourceMap", "=", "new", "TreeMap", "<", "Integer", ",", "Integer", ">", "(", ")", ";", "int", "itemCount", "=", "rscFixedMeta", ".", "getAdjustedItemCount", "(", ")", ";", "for", "(", "int", "loop", "=", "0", ";", "loop", "<", "itemCount", ";", "loop", "++", ")", "{", "byte", "[", "]", "data", "=", "rscFixedData", ".", "getByteArrayValue", "(", "loop", ")", ";", "if", "(", "data", "==", "null", "||", "data", ".", "length", "<", "fieldMap", ".", "getMaxFixedDataSize", "(", "0", ")", ")", "{", "continue", ";", "}", "Integer", "uniqueID", "=", "Integer", ".", "valueOf", "(", "MPPUtility", ".", "getShort", "(", "data", ",", "0", ")", ")", ";", "resourceMap", ".", "put", "(", "uniqueID", ",", "Integer", ".", "valueOf", "(", "loop", ")", ")", ";", "}", "return", "(", "resourceMap", ")", ";", "}" ]
This method maps the resource unique identifiers to their index number within the FixedData block. @param fieldMap field map @param rscFixedMeta resource fixed meta data @param rscFixedData resource fixed data @return map of resource IDs to resource data
[ "This", "method", "maps", "the", "resource", "unique", "identifiers", "to", "their", "index", "number", "within", "the", "FixedData", "block", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP9Reader.java#L986-L1004
157,608
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPP9Reader.java
MPP9Reader.postProcessTasks
private void postProcessTasks() { List<Task> allTasks = m_file.getTasks(); if (allTasks.size() > 1) { Collections.sort(allTasks); int taskID = -1; int lastTaskID = -1; for (int i = 0; i < allTasks.size(); i++) { Task task = allTasks.get(i); taskID = NumberHelper.getInt(task.getID()); // In Project the tasks IDs are always contiguous so we can spot invalid tasks by making sure all // IDs are represented. if (!task.getNull() && lastTaskID != -1 && taskID > lastTaskID + 1) { // This task looks to be invalid. task.setNull(true); } else { lastTaskID = taskID; } } } }
java
private void postProcessTasks() { List<Task> allTasks = m_file.getTasks(); if (allTasks.size() > 1) { Collections.sort(allTasks); int taskID = -1; int lastTaskID = -1; for (int i = 0; i < allTasks.size(); i++) { Task task = allTasks.get(i); taskID = NumberHelper.getInt(task.getID()); // In Project the tasks IDs are always contiguous so we can spot invalid tasks by making sure all // IDs are represented. if (!task.getNull() && lastTaskID != -1 && taskID > lastTaskID + 1) { // This task looks to be invalid. task.setNull(true); } else { lastTaskID = taskID; } } } }
[ "private", "void", "postProcessTasks", "(", ")", "{", "List", "<", "Task", ">", "allTasks", "=", "m_file", ".", "getTasks", "(", ")", ";", "if", "(", "allTasks", ".", "size", "(", ")", ">", "1", ")", "{", "Collections", ".", "sort", "(", "allTasks", ")", ";", "int", "taskID", "=", "-", "1", ";", "int", "lastTaskID", "=", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "allTasks", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Task", "task", "=", "allTasks", ".", "get", "(", "i", ")", ";", "taskID", "=", "NumberHelper", ".", "getInt", "(", "task", ".", "getID", "(", ")", ")", ";", "// In Project the tasks IDs are always contiguous so we can spot invalid tasks by making sure all", "// IDs are represented.", "if", "(", "!", "task", ".", "getNull", "(", ")", "&&", "lastTaskID", "!=", "-", "1", "&&", "taskID", ">", "lastTaskID", "+", "1", ")", "{", "// This task looks to be invalid.", "task", ".", "setNull", "(", "true", ")", ";", "}", "else", "{", "lastTaskID", "=", "taskID", ";", "}", "}", "}", "}" ]
This method is called to try to catch any invalid tasks that may have sneaked past all our other checks. This is done by validating the tasks by task ID.
[ "This", "method", "is", "called", "to", "try", "to", "catch", "any", "invalid", "tasks", "that", "may", "have", "sneaked", "past", "all", "our", "other", "checks", ".", "This", "is", "done", "by", "validating", "the", "tasks", "by", "task", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP9Reader.java#L2050-L2077
157,609
joniles/mpxj
src/main/java/net/sf/mpxj/sample/TaskDateDump.java
TaskDateDump.process
public void process(String name) throws Exception { ProjectFile file = new UniversalProjectReader().read(name); for (Task task : file.getTasks()) { if (!task.getSummary()) { System.out.print(task.getWBS()); System.out.print("\t"); System.out.print(task.getName()); System.out.print("\t"); System.out.print(format(task.getStart())); System.out.print("\t"); System.out.print(format(task.getActualStart())); System.out.print("\t"); System.out.print(format(task.getFinish())); System.out.print("\t"); System.out.print(format(task.getActualFinish())); System.out.println(); } } }
java
public void process(String name) throws Exception { ProjectFile file = new UniversalProjectReader().read(name); for (Task task : file.getTasks()) { if (!task.getSummary()) { System.out.print(task.getWBS()); System.out.print("\t"); System.out.print(task.getName()); System.out.print("\t"); System.out.print(format(task.getStart())); System.out.print("\t"); System.out.print(format(task.getActualStart())); System.out.print("\t"); System.out.print(format(task.getFinish())); System.out.print("\t"); System.out.print(format(task.getActualFinish())); System.out.println(); } } }
[ "public", "void", "process", "(", "String", "name", ")", "throws", "Exception", "{", "ProjectFile", "file", "=", "new", "UniversalProjectReader", "(", ")", ".", "read", "(", "name", ")", ";", "for", "(", "Task", "task", ":", "file", ".", "getTasks", "(", ")", ")", "{", "if", "(", "!", "task", ".", "getSummary", "(", ")", ")", "{", "System", ".", "out", ".", "print", "(", "task", ".", "getWBS", "(", ")", ")", ";", "System", ".", "out", ".", "print", "(", "\"\\t\"", ")", ";", "System", ".", "out", ".", "print", "(", "task", ".", "getName", "(", ")", ")", ";", "System", ".", "out", ".", "print", "(", "\"\\t\"", ")", ";", "System", ".", "out", ".", "print", "(", "format", "(", "task", ".", "getStart", "(", ")", ")", ")", ";", "System", ".", "out", ".", "print", "(", "\"\\t\"", ")", ";", "System", ".", "out", ".", "print", "(", "format", "(", "task", ".", "getActualStart", "(", ")", ")", ")", ";", "System", ".", "out", ".", "print", "(", "\"\\t\"", ")", ";", "System", ".", "out", ".", "print", "(", "format", "(", "task", ".", "getFinish", "(", ")", ")", ")", ";", "System", ".", "out", ".", "print", "(", "\"\\t\"", ")", ";", "System", ".", "out", ".", "print", "(", "format", "(", "task", ".", "getActualFinish", "(", ")", ")", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "}", "}", "}" ]
Dump data for all non-summary tasks to stdout. @param name file name
[ "Dump", "data", "for", "all", "non", "-", "summary", "tasks", "to", "stdout", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/sample/TaskDateDump.java#L73-L94
157,610
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readProjectProperties
private void readProjectProperties(Document cdp) { WorkspaceProperties props = cdp.getWorkspaceProperties(); ProjectProperties mpxjProps = m_projectFile.getProjectProperties(); mpxjProps.setSymbolPosition(props.getCurrencyPosition()); mpxjProps.setCurrencyDigits(props.getCurrencyDigits()); mpxjProps.setCurrencySymbol(props.getCurrencySymbol()); mpxjProps.setDaysPerMonth(props.getDaysPerMonth()); mpxjProps.setMinutesPerDay(props.getHoursPerDay()); mpxjProps.setMinutesPerWeek(props.getHoursPerWeek()); m_workHoursPerDay = mpxjProps.getMinutesPerDay().doubleValue() / 60.0; }
java
private void readProjectProperties(Document cdp) { WorkspaceProperties props = cdp.getWorkspaceProperties(); ProjectProperties mpxjProps = m_projectFile.getProjectProperties(); mpxjProps.setSymbolPosition(props.getCurrencyPosition()); mpxjProps.setCurrencyDigits(props.getCurrencyDigits()); mpxjProps.setCurrencySymbol(props.getCurrencySymbol()); mpxjProps.setDaysPerMonth(props.getDaysPerMonth()); mpxjProps.setMinutesPerDay(props.getHoursPerDay()); mpxjProps.setMinutesPerWeek(props.getHoursPerWeek()); m_workHoursPerDay = mpxjProps.getMinutesPerDay().doubleValue() / 60.0; }
[ "private", "void", "readProjectProperties", "(", "Document", "cdp", ")", "{", "WorkspaceProperties", "props", "=", "cdp", ".", "getWorkspaceProperties", "(", ")", ";", "ProjectProperties", "mpxjProps", "=", "m_projectFile", ".", "getProjectProperties", "(", ")", ";", "mpxjProps", ".", "setSymbolPosition", "(", "props", ".", "getCurrencyPosition", "(", ")", ")", ";", "mpxjProps", ".", "setCurrencyDigits", "(", "props", ".", "getCurrencyDigits", "(", ")", ")", ";", "mpxjProps", ".", "setCurrencySymbol", "(", "props", ".", "getCurrencySymbol", "(", ")", ")", ";", "mpxjProps", ".", "setDaysPerMonth", "(", "props", ".", "getDaysPerMonth", "(", ")", ")", ";", "mpxjProps", ".", "setMinutesPerDay", "(", "props", ".", "getHoursPerDay", "(", ")", ")", ";", "mpxjProps", ".", "setMinutesPerWeek", "(", "props", ".", "getHoursPerWeek", "(", ")", ")", ";", "m_workHoursPerDay", "=", "mpxjProps", ".", "getMinutesPerDay", "(", ")", ".", "doubleValue", "(", ")", "/", "60.0", ";", "}" ]
Extracts project properties from a ConceptDraw PROJECT file. @param cdp ConceptDraw PROJECT file
[ "Extracts", "project", "properties", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L184-L196
157,611
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readCalendars
private void readCalendars(Document cdp) { for (Calendar calendar : cdp.getCalendars().getCalendar()) { readCalendar(calendar); } for (Calendar calendar : cdp.getCalendars().getCalendar()) { ProjectCalendar child = m_calendarMap.get(calendar.getID()); ProjectCalendar parent = m_calendarMap.get(calendar.getBaseCalendarID()); if (parent == null) { m_projectFile.setDefaultCalendar(child); } else { child.setParent(parent); } } }
java
private void readCalendars(Document cdp) { for (Calendar calendar : cdp.getCalendars().getCalendar()) { readCalendar(calendar); } for (Calendar calendar : cdp.getCalendars().getCalendar()) { ProjectCalendar child = m_calendarMap.get(calendar.getID()); ProjectCalendar parent = m_calendarMap.get(calendar.getBaseCalendarID()); if (parent == null) { m_projectFile.setDefaultCalendar(child); } else { child.setParent(parent); } } }
[ "private", "void", "readCalendars", "(", "Document", "cdp", ")", "{", "for", "(", "Calendar", "calendar", ":", "cdp", ".", "getCalendars", "(", ")", ".", "getCalendar", "(", ")", ")", "{", "readCalendar", "(", "calendar", ")", ";", "}", "for", "(", "Calendar", "calendar", ":", "cdp", ".", "getCalendars", "(", ")", ".", "getCalendar", "(", ")", ")", "{", "ProjectCalendar", "child", "=", "m_calendarMap", ".", "get", "(", "calendar", ".", "getID", "(", ")", ")", ";", "ProjectCalendar", "parent", "=", "m_calendarMap", ".", "get", "(", "calendar", ".", "getBaseCalendarID", "(", ")", ")", ";", "if", "(", "parent", "==", "null", ")", "{", "m_projectFile", ".", "setDefaultCalendar", "(", "child", ")", ";", "}", "else", "{", "child", ".", "setParent", "(", "parent", ")", ";", "}", "}", "}" ]
Extracts calendar data from a ConceptDraw PROJECT file. @param cdp ConceptDraw PROJECT file
[ "Extracts", "calendar", "data", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L203-L223
157,612
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readWeekDay
private void readWeekDay(ProjectCalendar mpxjCalendar, WeekDay day) { if (day.isIsDayWorking()) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day.getDay()); for (Document.Calendars.Calendar.WeekDays.WeekDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { hours.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
java
private void readWeekDay(ProjectCalendar mpxjCalendar, WeekDay day) { if (day.isIsDayWorking()) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day.getDay()); for (Document.Calendars.Calendar.WeekDays.WeekDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { hours.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
[ "private", "void", "readWeekDay", "(", "ProjectCalendar", "mpxjCalendar", ",", "WeekDay", "day", ")", "{", "if", "(", "day", ".", "isIsDayWorking", "(", ")", ")", "{", "ProjectCalendarHours", "hours", "=", "mpxjCalendar", ".", "addCalendarHours", "(", "day", ".", "getDay", "(", ")", ")", ";", "for", "(", "Document", ".", "Calendars", ".", "Calendar", ".", "WeekDays", ".", "WeekDay", ".", "TimePeriods", ".", "TimePeriod", "period", ":", "day", ".", "getTimePeriods", "(", ")", ".", "getTimePeriod", "(", ")", ")", "{", "hours", ".", "addRange", "(", "new", "DateRange", "(", "period", ".", "getFrom", "(", ")", ",", "period", ".", "getTo", "(", ")", ")", ")", ";", "}", "}", "}" ]
Reads a single day for a calendar. @param mpxjCalendar ProjectCalendar instance @param day ConceptDraw PROJECT week day
[ "Reads", "a", "single", "day", "for", "a", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L253-L263
157,613
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readExceptionDay
private void readExceptionDay(ProjectCalendar mpxjCalendar, ExceptedDay day) { ProjectCalendarException mpxjException = mpxjCalendar.addCalendarException(day.getDate(), day.getDate()); if (day.isIsDayWorking()) { for (Document.Calendars.Calendar.ExceptedDays.ExceptedDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { mpxjException.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
java
private void readExceptionDay(ProjectCalendar mpxjCalendar, ExceptedDay day) { ProjectCalendarException mpxjException = mpxjCalendar.addCalendarException(day.getDate(), day.getDate()); if (day.isIsDayWorking()) { for (Document.Calendars.Calendar.ExceptedDays.ExceptedDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod()) { mpxjException.addRange(new DateRange(period.getFrom(), period.getTo())); } } }
[ "private", "void", "readExceptionDay", "(", "ProjectCalendar", "mpxjCalendar", ",", "ExceptedDay", "day", ")", "{", "ProjectCalendarException", "mpxjException", "=", "mpxjCalendar", ".", "addCalendarException", "(", "day", ".", "getDate", "(", ")", ",", "day", ".", "getDate", "(", ")", ")", ";", "if", "(", "day", ".", "isIsDayWorking", "(", ")", ")", "{", "for", "(", "Document", ".", "Calendars", ".", "Calendar", ".", "ExceptedDays", ".", "ExceptedDay", ".", "TimePeriods", ".", "TimePeriod", "period", ":", "day", ".", "getTimePeriods", "(", ")", ".", "getTimePeriod", "(", ")", ")", "{", "mpxjException", ".", "addRange", "(", "new", "DateRange", "(", "period", ".", "getFrom", "(", ")", ",", "period", ".", "getTo", "(", ")", ")", ")", ";", "}", "}", "}" ]
Read an exception day for a calendar. @param mpxjCalendar ProjectCalendar instance @param day ConceptDraw PROJECT exception day
[ "Read", "an", "exception", "day", "for", "a", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L271-L281
157,614
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readResources
private void readResources(Document cdp) { for (Document.Resources.Resource resource : cdp.getResources().getResource()) { readResource(resource); } }
java
private void readResources(Document cdp) { for (Document.Resources.Resource resource : cdp.getResources().getResource()) { readResource(resource); } }
[ "private", "void", "readResources", "(", "Document", "cdp", ")", "{", "for", "(", "Document", ".", "Resources", ".", "Resource", "resource", ":", "cdp", ".", "getResources", "(", ")", ".", "getResource", "(", ")", ")", "{", "readResource", "(", "resource", ")", ";", "}", "}" ]
Reads resource data from a ConceptDraw PROJECT file. @param cdp ConceptDraw PROJECT file
[ "Reads", "resource", "data", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L288-L294
157,615
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readResource
private void readResource(Document.Resources.Resource resource) { Resource mpxjResource = m_projectFile.addResource(); mpxjResource.setName(resource.getName()); mpxjResource.setResourceCalendar(m_calendarMap.get(resource.getCalendarID())); mpxjResource.setStandardRate(new Rate(resource.getCost(), resource.getCostTimeUnit())); mpxjResource.setEmailAddress(resource.getEMail()); mpxjResource.setGroup(resource.getGroup()); //resource.getHyperlinks() mpxjResource.setUniqueID(resource.getID()); //resource.getMarkerID() mpxjResource.setNotes(resource.getNote()); mpxjResource.setID(Integer.valueOf(resource.getOutlineNumber())); //resource.getStyleProject() mpxjResource.setType(resource.getSubType() == null ? resource.getType() : resource.getSubType()); }
java
private void readResource(Document.Resources.Resource resource) { Resource mpxjResource = m_projectFile.addResource(); mpxjResource.setName(resource.getName()); mpxjResource.setResourceCalendar(m_calendarMap.get(resource.getCalendarID())); mpxjResource.setStandardRate(new Rate(resource.getCost(), resource.getCostTimeUnit())); mpxjResource.setEmailAddress(resource.getEMail()); mpxjResource.setGroup(resource.getGroup()); //resource.getHyperlinks() mpxjResource.setUniqueID(resource.getID()); //resource.getMarkerID() mpxjResource.setNotes(resource.getNote()); mpxjResource.setID(Integer.valueOf(resource.getOutlineNumber())); //resource.getStyleProject() mpxjResource.setType(resource.getSubType() == null ? resource.getType() : resource.getSubType()); }
[ "private", "void", "readResource", "(", "Document", ".", "Resources", ".", "Resource", "resource", ")", "{", "Resource", "mpxjResource", "=", "m_projectFile", ".", "addResource", "(", ")", ";", "mpxjResource", ".", "setName", "(", "resource", ".", "getName", "(", ")", ")", ";", "mpxjResource", ".", "setResourceCalendar", "(", "m_calendarMap", ".", "get", "(", "resource", ".", "getCalendarID", "(", ")", ")", ")", ";", "mpxjResource", ".", "setStandardRate", "(", "new", "Rate", "(", "resource", ".", "getCost", "(", ")", ",", "resource", ".", "getCostTimeUnit", "(", ")", ")", ")", ";", "mpxjResource", ".", "setEmailAddress", "(", "resource", ".", "getEMail", "(", ")", ")", ";", "mpxjResource", ".", "setGroup", "(", "resource", ".", "getGroup", "(", ")", ")", ";", "//resource.getHyperlinks()", "mpxjResource", ".", "setUniqueID", "(", "resource", ".", "getID", "(", ")", ")", ";", "//resource.getMarkerID()", "mpxjResource", ".", "setNotes", "(", "resource", ".", "getNote", "(", ")", ")", ";", "mpxjResource", ".", "setID", "(", "Integer", ".", "valueOf", "(", "resource", ".", "getOutlineNumber", "(", ")", ")", ")", ";", "//resource.getStyleProject()", "mpxjResource", ".", "setType", "(", "resource", ".", "getSubType", "(", ")", "==", "null", "?", "resource", ".", "getType", "(", ")", ":", "resource", ".", "getSubType", "(", ")", ")", ";", "}" ]
Reads a single resource from a ConceptDraw PROJECT file. @param resource ConceptDraw PROJECT resource
[ "Reads", "a", "single", "resource", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L301-L316
157,616
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readTasks
private void readTasks(Document cdp) { // // Sort the projects into the correct order // List<Project> projects = new ArrayList<Project>(cdp.getProjects().getProject()); final AlphanumComparator comparator = new AlphanumComparator(); Collections.sort(projects, new Comparator<Project>() { @Override public int compare(Project o1, Project o2) { return comparator.compare(o1.getOutlineNumber(), o2.getOutlineNumber()); } }); for (Project project : cdp.getProjects().getProject()) { readProject(project); } }
java
private void readTasks(Document cdp) { // // Sort the projects into the correct order // List<Project> projects = new ArrayList<Project>(cdp.getProjects().getProject()); final AlphanumComparator comparator = new AlphanumComparator(); Collections.sort(projects, new Comparator<Project>() { @Override public int compare(Project o1, Project o2) { return comparator.compare(o1.getOutlineNumber(), o2.getOutlineNumber()); } }); for (Project project : cdp.getProjects().getProject()) { readProject(project); } }
[ "private", "void", "readTasks", "(", "Document", "cdp", ")", "{", "//", "// Sort the projects into the correct order", "//", "List", "<", "Project", ">", "projects", "=", "new", "ArrayList", "<", "Project", ">", "(", "cdp", ".", "getProjects", "(", ")", ".", "getProject", "(", ")", ")", ";", "final", "AlphanumComparator", "comparator", "=", "new", "AlphanumComparator", "(", ")", ";", "Collections", ".", "sort", "(", "projects", ",", "new", "Comparator", "<", "Project", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "Project", "o1", ",", "Project", "o2", ")", "{", "return", "comparator", ".", "compare", "(", "o1", ".", "getOutlineNumber", "(", ")", ",", "o2", ".", "getOutlineNumber", "(", ")", ")", ";", "}", "}", ")", ";", "for", "(", "Project", "project", ":", "cdp", ".", "getProjects", "(", ")", ".", "getProject", "(", ")", ")", "{", "readProject", "(", "project", ")", ";", "}", "}" ]
Read the projects from a ConceptDraw PROJECT file as top level tasks. @param cdp ConceptDraw PROJECT file
[ "Read", "the", "projects", "from", "a", "ConceptDraw", "PROJECT", "file", "as", "top", "level", "tasks", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L323-L343
157,617
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readProject
private void readProject(Project project) { Task mpxjTask = m_projectFile.addTask(); //project.getAuthor() mpxjTask.setBaselineCost(project.getBaselineCost()); mpxjTask.setBaselineFinish(project.getBaselineFinishDate()); mpxjTask.setBaselineStart(project.getBaselineStartDate()); //project.getBudget(); //project.getCompany() mpxjTask.setFinish(project.getFinishDate()); //project.getGoal() //project.getHyperlinks() //project.getMarkerID() mpxjTask.setName(project.getName()); mpxjTask.setNotes(project.getNote()); mpxjTask.setPriority(project.getPriority()); // project.getSite() mpxjTask.setStart(project.getStartDate()); // project.getStyleProject() // project.getTask() // project.getTimeScale() // project.getViewProperties() String projectIdentifier = project.getID().toString(); mpxjTask.setGUID(UUID.nameUUIDFromBytes(projectIdentifier.getBytes())); // // Sort the tasks into the correct order // List<Document.Projects.Project.Task> tasks = new ArrayList<Document.Projects.Project.Task>(project.getTask()); final AlphanumComparator comparator = new AlphanumComparator(); Collections.sort(tasks, new Comparator<Document.Projects.Project.Task>() { @Override public int compare(Document.Projects.Project.Task o1, Document.Projects.Project.Task o2) { return comparator.compare(o1.getOutlineNumber(), o2.getOutlineNumber()); } }); Map<String, Task> map = new HashMap<String, Task>(); map.put("", mpxjTask); for (Document.Projects.Project.Task task : tasks) { readTask(projectIdentifier, map, task); } }
java
private void readProject(Project project) { Task mpxjTask = m_projectFile.addTask(); //project.getAuthor() mpxjTask.setBaselineCost(project.getBaselineCost()); mpxjTask.setBaselineFinish(project.getBaselineFinishDate()); mpxjTask.setBaselineStart(project.getBaselineStartDate()); //project.getBudget(); //project.getCompany() mpxjTask.setFinish(project.getFinishDate()); //project.getGoal() //project.getHyperlinks() //project.getMarkerID() mpxjTask.setName(project.getName()); mpxjTask.setNotes(project.getNote()); mpxjTask.setPriority(project.getPriority()); // project.getSite() mpxjTask.setStart(project.getStartDate()); // project.getStyleProject() // project.getTask() // project.getTimeScale() // project.getViewProperties() String projectIdentifier = project.getID().toString(); mpxjTask.setGUID(UUID.nameUUIDFromBytes(projectIdentifier.getBytes())); // // Sort the tasks into the correct order // List<Document.Projects.Project.Task> tasks = new ArrayList<Document.Projects.Project.Task>(project.getTask()); final AlphanumComparator comparator = new AlphanumComparator(); Collections.sort(tasks, new Comparator<Document.Projects.Project.Task>() { @Override public int compare(Document.Projects.Project.Task o1, Document.Projects.Project.Task o2) { return comparator.compare(o1.getOutlineNumber(), o2.getOutlineNumber()); } }); Map<String, Task> map = new HashMap<String, Task>(); map.put("", mpxjTask); for (Document.Projects.Project.Task task : tasks) { readTask(projectIdentifier, map, task); } }
[ "private", "void", "readProject", "(", "Project", "project", ")", "{", "Task", "mpxjTask", "=", "m_projectFile", ".", "addTask", "(", ")", ";", "//project.getAuthor()", "mpxjTask", ".", "setBaselineCost", "(", "project", ".", "getBaselineCost", "(", ")", ")", ";", "mpxjTask", ".", "setBaselineFinish", "(", "project", ".", "getBaselineFinishDate", "(", ")", ")", ";", "mpxjTask", ".", "setBaselineStart", "(", "project", ".", "getBaselineStartDate", "(", ")", ")", ";", "//project.getBudget();", "//project.getCompany()", "mpxjTask", ".", "setFinish", "(", "project", ".", "getFinishDate", "(", ")", ")", ";", "//project.getGoal()", "//project.getHyperlinks()", "//project.getMarkerID()", "mpxjTask", ".", "setName", "(", "project", ".", "getName", "(", ")", ")", ";", "mpxjTask", ".", "setNotes", "(", "project", ".", "getNote", "(", ")", ")", ";", "mpxjTask", ".", "setPriority", "(", "project", ".", "getPriority", "(", ")", ")", ";", "// project.getSite()", "mpxjTask", ".", "setStart", "(", "project", ".", "getStartDate", "(", ")", ")", ";", "// project.getStyleProject()", "// project.getTask()", "// project.getTimeScale()", "// project.getViewProperties()", "String", "projectIdentifier", "=", "project", ".", "getID", "(", ")", ".", "toString", "(", ")", ";", "mpxjTask", ".", "setGUID", "(", "UUID", ".", "nameUUIDFromBytes", "(", "projectIdentifier", ".", "getBytes", "(", ")", ")", ")", ";", "//", "// Sort the tasks into the correct order", "//", "List", "<", "Document", ".", "Projects", ".", "Project", ".", "Task", ">", "tasks", "=", "new", "ArrayList", "<", "Document", ".", "Projects", ".", "Project", ".", "Task", ">", "(", "project", ".", "getTask", "(", ")", ")", ";", "final", "AlphanumComparator", "comparator", "=", "new", "AlphanumComparator", "(", ")", ";", "Collections", ".", "sort", "(", "tasks", ",", "new", "Comparator", "<", "Document", ".", "Projects", ".", "Project", ".", "Task", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "Document", ".", "Projects", ".", "Project", ".", "Task", "o1", ",", "Document", ".", "Projects", ".", "Project", ".", "Task", "o2", ")", "{", "return", "comparator", ".", "compare", "(", "o1", ".", "getOutlineNumber", "(", ")", ",", "o2", ".", "getOutlineNumber", "(", ")", ")", ";", "}", "}", ")", ";", "Map", "<", "String", ",", "Task", ">", "map", "=", "new", "HashMap", "<", "String", ",", "Task", ">", "(", ")", ";", "map", ".", "put", "(", "\"\"", ",", "mpxjTask", ")", ";", "for", "(", "Document", ".", "Projects", ".", "Project", ".", "Task", "task", ":", "tasks", ")", "{", "readTask", "(", "projectIdentifier", ",", "map", ",", "task", ")", ";", "}", "}" ]
Read a project from a ConceptDraw PROJECT file. @param project ConceptDraw PROJECT project
[ "Read", "a", "project", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L350-L397
157,618
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readTask
private void readTask(String projectIdentifier, Map<String, Task> map, Document.Projects.Project.Task task) { Task parentTask = map.get(getParentOutlineNumber(task.getOutlineNumber())); Task mpxjTask = parentTask.addTask(); TimeUnit units = task.getBaseDurationTimeUnit(); mpxjTask.setCost(task.getActualCost()); mpxjTask.setDuration(getDuration(units, task.getActualDuration())); mpxjTask.setFinish(task.getActualFinishDate()); mpxjTask.setStart(task.getActualStartDate()); mpxjTask.setBaselineDuration(getDuration(units, task.getBaseDuration())); mpxjTask.setBaselineFinish(task.getBaseFinishDate()); mpxjTask.setBaselineCost(task.getBaselineCost()); // task.getBaselineFinishDate() // task.getBaselineFinishTemplateOffset() // task.getBaselineStartDate() // task.getBaselineStartTemplateOffset() mpxjTask.setBaselineStart(task.getBaseStartDate()); // task.getCallouts() mpxjTask.setPercentageComplete(task.getComplete()); mpxjTask.setDeadline(task.getDeadlineDate()); // task.getDeadlineTemplateOffset() // task.getHyperlinks() // task.getMarkerID() mpxjTask.setName(task.getName()); mpxjTask.setNotes(task.getNote()); mpxjTask.setPriority(task.getPriority()); // task.getRecalcBase1() // task.getRecalcBase2() mpxjTask.setType(task.getSchedulingType()); // task.getStyleProject() // task.getTemplateOffset() // task.getValidatedByProject() if (task.isIsMilestone()) { mpxjTask.setMilestone(true); mpxjTask.setDuration(Duration.getInstance(0, TimeUnit.HOURS)); mpxjTask.setBaselineDuration(Duration.getInstance(0, TimeUnit.HOURS)); } String taskIdentifier = projectIdentifier + "." + task.getID(); m_taskIdMap.put(task.getID(), mpxjTask); mpxjTask.setGUID(UUID.nameUUIDFromBytes(taskIdentifier.getBytes())); map.put(task.getOutlineNumber(), mpxjTask); for (Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment : task.getResourceAssignments().getResourceAssignment()) { readResourceAssignment(mpxjTask, assignment); } }
java
private void readTask(String projectIdentifier, Map<String, Task> map, Document.Projects.Project.Task task) { Task parentTask = map.get(getParentOutlineNumber(task.getOutlineNumber())); Task mpxjTask = parentTask.addTask(); TimeUnit units = task.getBaseDurationTimeUnit(); mpxjTask.setCost(task.getActualCost()); mpxjTask.setDuration(getDuration(units, task.getActualDuration())); mpxjTask.setFinish(task.getActualFinishDate()); mpxjTask.setStart(task.getActualStartDate()); mpxjTask.setBaselineDuration(getDuration(units, task.getBaseDuration())); mpxjTask.setBaselineFinish(task.getBaseFinishDate()); mpxjTask.setBaselineCost(task.getBaselineCost()); // task.getBaselineFinishDate() // task.getBaselineFinishTemplateOffset() // task.getBaselineStartDate() // task.getBaselineStartTemplateOffset() mpxjTask.setBaselineStart(task.getBaseStartDate()); // task.getCallouts() mpxjTask.setPercentageComplete(task.getComplete()); mpxjTask.setDeadline(task.getDeadlineDate()); // task.getDeadlineTemplateOffset() // task.getHyperlinks() // task.getMarkerID() mpxjTask.setName(task.getName()); mpxjTask.setNotes(task.getNote()); mpxjTask.setPriority(task.getPriority()); // task.getRecalcBase1() // task.getRecalcBase2() mpxjTask.setType(task.getSchedulingType()); // task.getStyleProject() // task.getTemplateOffset() // task.getValidatedByProject() if (task.isIsMilestone()) { mpxjTask.setMilestone(true); mpxjTask.setDuration(Duration.getInstance(0, TimeUnit.HOURS)); mpxjTask.setBaselineDuration(Duration.getInstance(0, TimeUnit.HOURS)); } String taskIdentifier = projectIdentifier + "." + task.getID(); m_taskIdMap.put(task.getID(), mpxjTask); mpxjTask.setGUID(UUID.nameUUIDFromBytes(taskIdentifier.getBytes())); map.put(task.getOutlineNumber(), mpxjTask); for (Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment : task.getResourceAssignments().getResourceAssignment()) { readResourceAssignment(mpxjTask, assignment); } }
[ "private", "void", "readTask", "(", "String", "projectIdentifier", ",", "Map", "<", "String", ",", "Task", ">", "map", ",", "Document", ".", "Projects", ".", "Project", ".", "Task", "task", ")", "{", "Task", "parentTask", "=", "map", ".", "get", "(", "getParentOutlineNumber", "(", "task", ".", "getOutlineNumber", "(", ")", ")", ")", ";", "Task", "mpxjTask", "=", "parentTask", ".", "addTask", "(", ")", ";", "TimeUnit", "units", "=", "task", ".", "getBaseDurationTimeUnit", "(", ")", ";", "mpxjTask", ".", "setCost", "(", "task", ".", "getActualCost", "(", ")", ")", ";", "mpxjTask", ".", "setDuration", "(", "getDuration", "(", "units", ",", "task", ".", "getActualDuration", "(", ")", ")", ")", ";", "mpxjTask", ".", "setFinish", "(", "task", ".", "getActualFinishDate", "(", ")", ")", ";", "mpxjTask", ".", "setStart", "(", "task", ".", "getActualStartDate", "(", ")", ")", ";", "mpxjTask", ".", "setBaselineDuration", "(", "getDuration", "(", "units", ",", "task", ".", "getBaseDuration", "(", ")", ")", ")", ";", "mpxjTask", ".", "setBaselineFinish", "(", "task", ".", "getBaseFinishDate", "(", ")", ")", ";", "mpxjTask", ".", "setBaselineCost", "(", "task", ".", "getBaselineCost", "(", ")", ")", ";", "// task.getBaselineFinishDate()", "// task.getBaselineFinishTemplateOffset()", "// task.getBaselineStartDate()", "// task.getBaselineStartTemplateOffset()", "mpxjTask", ".", "setBaselineStart", "(", "task", ".", "getBaseStartDate", "(", ")", ")", ";", "// task.getCallouts()", "mpxjTask", ".", "setPercentageComplete", "(", "task", ".", "getComplete", "(", ")", ")", ";", "mpxjTask", ".", "setDeadline", "(", "task", ".", "getDeadlineDate", "(", ")", ")", ";", "// task.getDeadlineTemplateOffset()", "// task.getHyperlinks()", "// task.getMarkerID()", "mpxjTask", ".", "setName", "(", "task", ".", "getName", "(", ")", ")", ";", "mpxjTask", ".", "setNotes", "(", "task", ".", "getNote", "(", ")", ")", ";", "mpxjTask", ".", "setPriority", "(", "task", ".", "getPriority", "(", ")", ")", ";", "// task.getRecalcBase1()", "// task.getRecalcBase2()", "mpxjTask", ".", "setType", "(", "task", ".", "getSchedulingType", "(", ")", ")", ";", "// task.getStyleProject()", "// task.getTemplateOffset()", "// task.getValidatedByProject()", "if", "(", "task", ".", "isIsMilestone", "(", ")", ")", "{", "mpxjTask", ".", "setMilestone", "(", "true", ")", ";", "mpxjTask", ".", "setDuration", "(", "Duration", ".", "getInstance", "(", "0", ",", "TimeUnit", ".", "HOURS", ")", ")", ";", "mpxjTask", ".", "setBaselineDuration", "(", "Duration", ".", "getInstance", "(", "0", ",", "TimeUnit", ".", "HOURS", ")", ")", ";", "}", "String", "taskIdentifier", "=", "projectIdentifier", "+", "\".\"", "+", "task", ".", "getID", "(", ")", ";", "m_taskIdMap", ".", "put", "(", "task", ".", "getID", "(", ")", ",", "mpxjTask", ")", ";", "mpxjTask", ".", "setGUID", "(", "UUID", ".", "nameUUIDFromBytes", "(", "taskIdentifier", ".", "getBytes", "(", ")", ")", ")", ";", "map", ".", "put", "(", "task", ".", "getOutlineNumber", "(", ")", ",", "mpxjTask", ")", ";", "for", "(", "Document", ".", "Projects", ".", "Project", ".", "Task", ".", "ResourceAssignments", ".", "ResourceAssignment", "assignment", ":", "task", ".", "getResourceAssignments", "(", ")", ".", "getResourceAssignment", "(", ")", ")", "{", "readResourceAssignment", "(", "mpxjTask", ",", "assignment", ")", ";", "}", "}" ]
Read a task from a ConceptDraw PROJECT file. @param projectIdentifier parent project identifier @param map outline number to task map @param task ConceptDraw PROJECT task
[ "Read", "a", "task", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L406-L458
157,619
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readRelationships
private void readRelationships(Document cdp) { for (Link link : cdp.getLinks().getLink()) { readRelationship(link); } }
java
private void readRelationships(Document cdp) { for (Link link : cdp.getLinks().getLink()) { readRelationship(link); } }
[ "private", "void", "readRelationships", "(", "Document", "cdp", ")", "{", "for", "(", "Link", "link", ":", "cdp", ".", "getLinks", "(", ")", ".", "getLink", "(", ")", ")", "{", "readRelationship", "(", "link", ")", ";", "}", "}" ]
Read all task relationships from a ConceptDraw PROJECT file. @param cdp ConceptDraw PROJECT file
[ "Read", "all", "task", "relationships", "from", "a", "ConceptDraw", "PROJECT", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L483-L489
157,620
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.readRelationship
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()); } }
java
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()); } }
[ "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", "(", ")", ")", ";", "}", "}" ]
Read a task relationship. @param link ConceptDraw PROJECT task link
[ "Read", "a", "task", "relationship", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L496-L507
157,621
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.getDuration
private Duration getDuration(TimeUnit units, Double duration) { Duration result = null; if (duration != null) { double durationValue = duration.doubleValue() * 100.0; switch (units) { case MINUTES: { durationValue *= MINUTES_PER_DAY; break; } case HOURS: { durationValue *= HOURS_PER_DAY; break; } case DAYS: { durationValue *= 3.0; break; } case WEEKS: { durationValue *= 0.6; break; } case MONTHS: { durationValue *= 0.15; break; } default: { throw new IllegalArgumentException("Unsupported time units " + units); } } durationValue = Math.round(durationValue) / 100.0; result = Duration.getInstance(durationValue, units); } return result; }
java
private Duration getDuration(TimeUnit units, Double duration) { Duration result = null; if (duration != null) { double durationValue = duration.doubleValue() * 100.0; switch (units) { case MINUTES: { durationValue *= MINUTES_PER_DAY; break; } case HOURS: { durationValue *= HOURS_PER_DAY; break; } case DAYS: { durationValue *= 3.0; break; } case WEEKS: { durationValue *= 0.6; break; } case MONTHS: { durationValue *= 0.15; break; } default: { throw new IllegalArgumentException("Unsupported time units " + units); } } durationValue = Math.round(durationValue) / 100.0; result = Duration.getInstance(durationValue, units); } return result; }
[ "private", "Duration", "getDuration", "(", "TimeUnit", "units", ",", "Double", "duration", ")", "{", "Duration", "result", "=", "null", ";", "if", "(", "duration", "!=", "null", ")", "{", "double", "durationValue", "=", "duration", ".", "doubleValue", "(", ")", "*", "100.0", ";", "switch", "(", "units", ")", "{", "case", "MINUTES", ":", "{", "durationValue", "*=", "MINUTES_PER_DAY", ";", "break", ";", "}", "case", "HOURS", ":", "{", "durationValue", "*=", "HOURS_PER_DAY", ";", "break", ";", "}", "case", "DAYS", ":", "{", "durationValue", "*=", "3.0", ";", "break", ";", "}", "case", "WEEKS", ":", "{", "durationValue", "*=", "0.6", ";", "break", ";", "}", "case", "MONTHS", ":", "{", "durationValue", "*=", "0.15", ";", "break", ";", "}", "default", ":", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported time units \"", "+", "units", ")", ";", "}", "}", "durationValue", "=", "Math", ".", "round", "(", "durationValue", ")", "/", "100.0", ";", "result", "=", "Duration", ".", "getInstance", "(", "durationValue", ",", "units", ")", ";", "}", "return", "result", ";", "}" ]
Read a duration. @param units duration units @param duration duration value @return Duration instance
[ "Read", "a", "duration", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L516-L567
157,622
joniles/mpxj
src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java
ConceptDrawProjectReader.getParentOutlineNumber
private String getParentOutlineNumber(String outlineNumber) { String result; int index = outlineNumber.lastIndexOf('.'); if (index == -1) { result = ""; } else { result = outlineNumber.substring(0, index); } return result; }
java
private String getParentOutlineNumber(String outlineNumber) { String result; int index = outlineNumber.lastIndexOf('.'); if (index == -1) { result = ""; } else { result = outlineNumber.substring(0, index); } return result; }
[ "private", "String", "getParentOutlineNumber", "(", "String", "outlineNumber", ")", "{", "String", "result", ";", "int", "index", "=", "outlineNumber", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "result", "=", "\"\"", ";", "}", "else", "{", "result", "=", "outlineNumber", ".", "substring", "(", "0", ",", "index", ")", ";", "}", "return", "result", ";", "}" ]
Return the parent outline number, or an empty string if we have a root task. @param outlineNumber child outline number @return parent outline number
[ "Return", "the", "parent", "outline", "number", "or", "an", "empty", "string", "if", "we", "have", "a", "root", "task", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L576-L589
157,623
joniles/mpxj
src/main/java/net/sf/mpxj/common/MPPConstraintField.java
MPPConstraintField.getInstance
public static ConstraintField getInstance(int value) { ConstraintField result = null; if (value >= 0 && value < FIELD_ARRAY.length) { result = FIELD_ARRAY[value]; } return (result); }
java
public static ConstraintField getInstance(int value) { ConstraintField result = null; if (value >= 0 && value < FIELD_ARRAY.length) { result = FIELD_ARRAY[value]; } return (result); }
[ "public", "static", "ConstraintField", "getInstance", "(", "int", "value", ")", "{", "ConstraintField", "result", "=", "null", ";", "if", "(", "value", ">=", "0", "&&", "value", "<", "FIELD_ARRAY", ".", "length", ")", "{", "result", "=", "FIELD_ARRAY", "[", "value", "]", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieve an instance of the ConstraintField class based on the data read from an MS Project file. @param value value from an MS Project file @return ConstraintField instance
[ "Retrieve", "an", "instance", "of", "the", "ConstraintField", "class", "based", "on", "the", "data", "read", "from", "an", "MS", "Project", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/MPPConstraintField.java#L44-L54
157,624
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.update
public void update() { ProjectProperties properties = m_projectFile.getProjectProperties(); char decimalSeparator = properties.getDecimalSeparator(); char thousandsSeparator = properties.getThousandsSeparator(); m_unitsDecimalFormat.applyPattern("#.##", null, decimalSeparator, thousandsSeparator); m_decimalFormat.applyPattern("0.00#", null, decimalSeparator, thousandsSeparator); m_durationDecimalFormat.applyPattern("#.##", null, decimalSeparator, thousandsSeparator); m_percentageDecimalFormat.applyPattern("##0.##", null, decimalSeparator, thousandsSeparator); updateCurrencyFormats(properties, decimalSeparator, thousandsSeparator); updateDateTimeFormats(properties); }
java
public void update() { ProjectProperties properties = m_projectFile.getProjectProperties(); char decimalSeparator = properties.getDecimalSeparator(); char thousandsSeparator = properties.getThousandsSeparator(); m_unitsDecimalFormat.applyPattern("#.##", null, decimalSeparator, thousandsSeparator); m_decimalFormat.applyPattern("0.00#", null, decimalSeparator, thousandsSeparator); m_durationDecimalFormat.applyPattern("#.##", null, decimalSeparator, thousandsSeparator); m_percentageDecimalFormat.applyPattern("##0.##", null, decimalSeparator, thousandsSeparator); updateCurrencyFormats(properties, decimalSeparator, thousandsSeparator); updateDateTimeFormats(properties); }
[ "public", "void", "update", "(", ")", "{", "ProjectProperties", "properties", "=", "m_projectFile", ".", "getProjectProperties", "(", ")", ";", "char", "decimalSeparator", "=", "properties", ".", "getDecimalSeparator", "(", ")", ";", "char", "thousandsSeparator", "=", "properties", ".", "getThousandsSeparator", "(", ")", ";", "m_unitsDecimalFormat", ".", "applyPattern", "(", "\"#.##\"", ",", "null", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "m_decimalFormat", ".", "applyPattern", "(", "\"0.00#\"", ",", "null", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "m_durationDecimalFormat", ".", "applyPattern", "(", "\"#.##\"", ",", "null", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "m_percentageDecimalFormat", ".", "applyPattern", "(", "\"##0.##\"", ",", "null", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "updateCurrencyFormats", "(", "properties", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "updateDateTimeFormats", "(", "properties", ")", ";", "}" ]
Called to update the cached formats when something changes.
[ "Called", "to", "update", "the", "cached", "formats", "when", "something", "changes", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L62-L73
157,625
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.updateCurrencyFormats
private void updateCurrencyFormats(ProjectProperties properties, char decimalSeparator, char thousandsSeparator) { String prefix = ""; String suffix = ""; String currencySymbol = quoteFormatCharacters(properties.getCurrencySymbol()); switch (properties.getSymbolPosition()) { case AFTER: { suffix = currencySymbol; break; } case BEFORE: { prefix = currencySymbol; break; } case AFTER_WITH_SPACE: { suffix = " " + currencySymbol; break; } case BEFORE_WITH_SPACE: { prefix = currencySymbol + " "; break; } } StringBuilder pattern = new StringBuilder(prefix); pattern.append("#0"); int digits = properties.getCurrencyDigits().intValue(); if (digits > 0) { pattern.append('.'); for (int i = 0; i < digits; i++) { pattern.append("0"); } } pattern.append(suffix); String primaryPattern = pattern.toString(); String[] alternativePatterns = new String[7]; alternativePatterns[0] = primaryPattern + ";(" + primaryPattern + ")"; pattern.insert(prefix.length(), "#,#"); String secondaryPattern = pattern.toString(); alternativePatterns[1] = secondaryPattern; alternativePatterns[2] = secondaryPattern + ";(" + secondaryPattern + ")"; pattern.setLength(0); pattern.append("#0"); if (digits > 0) { pattern.append('.'); for (int i = 0; i < digits; i++) { pattern.append("0"); } } String noSymbolPrimaryPattern = pattern.toString(); alternativePatterns[3] = noSymbolPrimaryPattern; alternativePatterns[4] = noSymbolPrimaryPattern + ";(" + noSymbolPrimaryPattern + ")"; pattern.insert(0, "#,#"); String noSymbolSecondaryPattern = pattern.toString(); alternativePatterns[5] = noSymbolSecondaryPattern; alternativePatterns[6] = noSymbolSecondaryPattern + ";(" + noSymbolSecondaryPattern + ")"; m_currencyFormat.applyPattern(primaryPattern, alternativePatterns, decimalSeparator, thousandsSeparator); }
java
private void updateCurrencyFormats(ProjectProperties properties, char decimalSeparator, char thousandsSeparator) { String prefix = ""; String suffix = ""; String currencySymbol = quoteFormatCharacters(properties.getCurrencySymbol()); switch (properties.getSymbolPosition()) { case AFTER: { suffix = currencySymbol; break; } case BEFORE: { prefix = currencySymbol; break; } case AFTER_WITH_SPACE: { suffix = " " + currencySymbol; break; } case BEFORE_WITH_SPACE: { prefix = currencySymbol + " "; break; } } StringBuilder pattern = new StringBuilder(prefix); pattern.append("#0"); int digits = properties.getCurrencyDigits().intValue(); if (digits > 0) { pattern.append('.'); for (int i = 0; i < digits; i++) { pattern.append("0"); } } pattern.append(suffix); String primaryPattern = pattern.toString(); String[] alternativePatterns = new String[7]; alternativePatterns[0] = primaryPattern + ";(" + primaryPattern + ")"; pattern.insert(prefix.length(), "#,#"); String secondaryPattern = pattern.toString(); alternativePatterns[1] = secondaryPattern; alternativePatterns[2] = secondaryPattern + ";(" + secondaryPattern + ")"; pattern.setLength(0); pattern.append("#0"); if (digits > 0) { pattern.append('.'); for (int i = 0; i < digits; i++) { pattern.append("0"); } } String noSymbolPrimaryPattern = pattern.toString(); alternativePatterns[3] = noSymbolPrimaryPattern; alternativePatterns[4] = noSymbolPrimaryPattern + ";(" + noSymbolPrimaryPattern + ")"; pattern.insert(0, "#,#"); String noSymbolSecondaryPattern = pattern.toString(); alternativePatterns[5] = noSymbolSecondaryPattern; alternativePatterns[6] = noSymbolSecondaryPattern + ";(" + noSymbolSecondaryPattern + ")"; m_currencyFormat.applyPattern(primaryPattern, alternativePatterns, decimalSeparator, thousandsSeparator); }
[ "private", "void", "updateCurrencyFormats", "(", "ProjectProperties", "properties", ",", "char", "decimalSeparator", ",", "char", "thousandsSeparator", ")", "{", "String", "prefix", "=", "\"\"", ";", "String", "suffix", "=", "\"\"", ";", "String", "currencySymbol", "=", "quoteFormatCharacters", "(", "properties", ".", "getCurrencySymbol", "(", ")", ")", ";", "switch", "(", "properties", ".", "getSymbolPosition", "(", ")", ")", "{", "case", "AFTER", ":", "{", "suffix", "=", "currencySymbol", ";", "break", ";", "}", "case", "BEFORE", ":", "{", "prefix", "=", "currencySymbol", ";", "break", ";", "}", "case", "AFTER_WITH_SPACE", ":", "{", "suffix", "=", "\" \"", "+", "currencySymbol", ";", "break", ";", "}", "case", "BEFORE_WITH_SPACE", ":", "{", "prefix", "=", "currencySymbol", "+", "\" \"", ";", "break", ";", "}", "}", "StringBuilder", "pattern", "=", "new", "StringBuilder", "(", "prefix", ")", ";", "pattern", ".", "append", "(", "\"#0\"", ")", ";", "int", "digits", "=", "properties", ".", "getCurrencyDigits", "(", ")", ".", "intValue", "(", ")", ";", "if", "(", "digits", ">", "0", ")", "{", "pattern", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "digits", ";", "i", "++", ")", "{", "pattern", ".", "append", "(", "\"0\"", ")", ";", "}", "}", "pattern", ".", "append", "(", "suffix", ")", ";", "String", "primaryPattern", "=", "pattern", ".", "toString", "(", ")", ";", "String", "[", "]", "alternativePatterns", "=", "new", "String", "[", "7", "]", ";", "alternativePatterns", "[", "0", "]", "=", "primaryPattern", "+", "\";(\"", "+", "primaryPattern", "+", "\")\"", ";", "pattern", ".", "insert", "(", "prefix", ".", "length", "(", ")", ",", "\"#,#\"", ")", ";", "String", "secondaryPattern", "=", "pattern", ".", "toString", "(", ")", ";", "alternativePatterns", "[", "1", "]", "=", "secondaryPattern", ";", "alternativePatterns", "[", "2", "]", "=", "secondaryPattern", "+", "\";(\"", "+", "secondaryPattern", "+", "\")\"", ";", "pattern", ".", "setLength", "(", "0", ")", ";", "pattern", ".", "append", "(", "\"#0\"", ")", ";", "if", "(", "digits", ">", "0", ")", "{", "pattern", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "digits", ";", "i", "++", ")", "{", "pattern", ".", "append", "(", "\"0\"", ")", ";", "}", "}", "String", "noSymbolPrimaryPattern", "=", "pattern", ".", "toString", "(", ")", ";", "alternativePatterns", "[", "3", "]", "=", "noSymbolPrimaryPattern", ";", "alternativePatterns", "[", "4", "]", "=", "noSymbolPrimaryPattern", "+", "\";(\"", "+", "noSymbolPrimaryPattern", "+", "\")\"", ";", "pattern", ".", "insert", "(", "0", ",", "\"#,#\"", ")", ";", "String", "noSymbolSecondaryPattern", "=", "pattern", ".", "toString", "(", ")", ";", "alternativePatterns", "[", "5", "]", "=", "noSymbolSecondaryPattern", ";", "alternativePatterns", "[", "6", "]", "=", "noSymbolSecondaryPattern", "+", "\";(\"", "+", "noSymbolSecondaryPattern", "+", "\")\"", ";", "m_currencyFormat", ".", "applyPattern", "(", "primaryPattern", ",", "alternativePatterns", ",", "decimalSeparator", ",", "thousandsSeparator", ")", ";", "}" ]
Update the currency format. @param properties project properties @param decimalSeparator decimal separator @param thousandsSeparator thousands separator
[ "Update", "the", "currency", "format", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L82-L160
157,626
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.quoteFormatCharacters
private String quoteFormatCharacters(String literal) { StringBuilder sb = new StringBuilder(); int length = literal.length(); char c; for (int loop = 0; loop < length; loop++) { c = literal.charAt(loop); switch (c) { case '0': case '#': case '.': case '-': case ',': case 'E': case ';': case '%': { sb.append("'"); sb.append(c); sb.append("'"); break; } default: { sb.append(c); break; } } } return (sb.toString()); }
java
private String quoteFormatCharacters(String literal) { StringBuilder sb = new StringBuilder(); int length = literal.length(); char c; for (int loop = 0; loop < length; loop++) { c = literal.charAt(loop); switch (c) { case '0': case '#': case '.': case '-': case ',': case 'E': case ';': case '%': { sb.append("'"); sb.append(c); sb.append("'"); break; } default: { sb.append(c); break; } } } return (sb.toString()); }
[ "private", "String", "quoteFormatCharacters", "(", "String", "literal", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "length", "=", "literal", ".", "length", "(", ")", ";", "char", "c", ";", "for", "(", "int", "loop", "=", "0", ";", "loop", "<", "length", ";", "loop", "++", ")", "{", "c", "=", "literal", ".", "charAt", "(", "loop", ")", ";", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "case", "'", "'", ":", "{", "sb", ".", "append", "(", "\"'\"", ")", ";", "sb", ".", "append", "(", "c", ")", ";", "sb", ".", "append", "(", "\"'\"", ")", ";", "break", ";", "}", "default", ":", "{", "sb", ".", "append", "(", "c", ")", ";", "break", ";", "}", "}", "}", "return", "(", "sb", ".", "toString", "(", ")", ")", ";", "}" ]
This method is used to quote any special characters that appear in literal text that is required as part of the currency format. @param literal Literal text @return literal text with special characters in quotes
[ "This", "method", "is", "used", "to", "quote", "any", "special", "characters", "that", "appear", "in", "literal", "text", "that", "is", "required", "as", "part", "of", "the", "currency", "format", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L169-L204
157,627
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.updateDateTimeFormats
private void updateDateTimeFormats(ProjectProperties properties) { String[] timePatterns = getTimePatterns(properties); String[] datePatterns = getDatePatterns(properties); String[] dateTimePatterns = getDateTimePatterns(properties, timePatterns); m_dateTimeFormat.applyPatterns(dateTimePatterns); m_dateFormat.applyPatterns(datePatterns); m_timeFormat.applyPatterns(timePatterns); m_dateTimeFormat.setLocale(m_locale); m_dateFormat.setLocale(m_locale); m_dateTimeFormat.setNullText(m_nullText); m_dateFormat.setNullText(m_nullText); m_timeFormat.setNullText(m_nullText); m_dateTimeFormat.setAmPmText(properties.getAMText(), properties.getPMText()); m_timeFormat.setAmPmText(properties.getAMText(), properties.getPMText()); }
java
private void updateDateTimeFormats(ProjectProperties properties) { String[] timePatterns = getTimePatterns(properties); String[] datePatterns = getDatePatterns(properties); String[] dateTimePatterns = getDateTimePatterns(properties, timePatterns); m_dateTimeFormat.applyPatterns(dateTimePatterns); m_dateFormat.applyPatterns(datePatterns); m_timeFormat.applyPatterns(timePatterns); m_dateTimeFormat.setLocale(m_locale); m_dateFormat.setLocale(m_locale); m_dateTimeFormat.setNullText(m_nullText); m_dateFormat.setNullText(m_nullText); m_timeFormat.setNullText(m_nullText); m_dateTimeFormat.setAmPmText(properties.getAMText(), properties.getPMText()); m_timeFormat.setAmPmText(properties.getAMText(), properties.getPMText()); }
[ "private", "void", "updateDateTimeFormats", "(", "ProjectProperties", "properties", ")", "{", "String", "[", "]", "timePatterns", "=", "getTimePatterns", "(", "properties", ")", ";", "String", "[", "]", "datePatterns", "=", "getDatePatterns", "(", "properties", ")", ";", "String", "[", "]", "dateTimePatterns", "=", "getDateTimePatterns", "(", "properties", ",", "timePatterns", ")", ";", "m_dateTimeFormat", ".", "applyPatterns", "(", "dateTimePatterns", ")", ";", "m_dateFormat", ".", "applyPatterns", "(", "datePatterns", ")", ";", "m_timeFormat", ".", "applyPatterns", "(", "timePatterns", ")", ";", "m_dateTimeFormat", ".", "setLocale", "(", "m_locale", ")", ";", "m_dateFormat", ".", "setLocale", "(", "m_locale", ")", ";", "m_dateTimeFormat", ".", "setNullText", "(", "m_nullText", ")", ";", "m_dateFormat", ".", "setNullText", "(", "m_nullText", ")", ";", "m_timeFormat", ".", "setNullText", "(", "m_nullText", ")", ";", "m_dateTimeFormat", ".", "setAmPmText", "(", "properties", ".", "getAMText", "(", ")", ",", "properties", ".", "getPMText", "(", ")", ")", ";", "m_timeFormat", ".", "setAmPmText", "(", "properties", ".", "getAMText", "(", ")", ",", "properties", ".", "getPMText", "(", ")", ")", ";", "}" ]
Updates the date and time formats. @param properties project properties
[ "Updates", "the", "date", "and", "time", "formats", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L211-L230
157,628
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.getDatePatterns
private String[] getDatePatterns(ProjectProperties properties) { String pattern = ""; char datesep = properties.getDateSeparator(); DateOrder dateOrder = properties.getDateOrder(); switch (dateOrder) { case DMY: { pattern = "dd" + datesep + "MM" + datesep + "yy"; break; } case MDY: { pattern = "MM" + datesep + "dd" + datesep + "yy"; break; } case YMD: { pattern = "yy" + datesep + "MM" + datesep + "dd"; break; } } return new String[] { pattern }; }
java
private String[] getDatePatterns(ProjectProperties properties) { String pattern = ""; char datesep = properties.getDateSeparator(); DateOrder dateOrder = properties.getDateOrder(); switch (dateOrder) { case DMY: { pattern = "dd" + datesep + "MM" + datesep + "yy"; break; } case MDY: { pattern = "MM" + datesep + "dd" + datesep + "yy"; break; } case YMD: { pattern = "yy" + datesep + "MM" + datesep + "dd"; break; } } return new String[] { pattern }; }
[ "private", "String", "[", "]", "getDatePatterns", "(", "ProjectProperties", "properties", ")", "{", "String", "pattern", "=", "\"\"", ";", "char", "datesep", "=", "properties", ".", "getDateSeparator", "(", ")", ";", "DateOrder", "dateOrder", "=", "properties", ".", "getDateOrder", "(", ")", ";", "switch", "(", "dateOrder", ")", "{", "case", "DMY", ":", "{", "pattern", "=", "\"dd\"", "+", "datesep", "+", "\"MM\"", "+", "datesep", "+", "\"yy\"", ";", "break", ";", "}", "case", "MDY", ":", "{", "pattern", "=", "\"MM\"", "+", "datesep", "+", "\"dd\"", "+", "datesep", "+", "\"yy\"", ";", "break", ";", "}", "case", "YMD", ":", "{", "pattern", "=", "\"yy\"", "+", "datesep", "+", "\"MM\"", "+", "datesep", "+", "\"dd\"", ";", "break", ";", "}", "}", "return", "new", "String", "[", "]", "{", "pattern", "}", ";", "}" ]
Generate date patterns based on the project configuration. @param properties project properties @return date patterns
[ "Generate", "date", "patterns", "based", "on", "the", "project", "configuration", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L238-L270
157,629
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/MPXJFormats.java
MPXJFormats.generateDateTimePatterns
private List<String> generateDateTimePatterns(String datePattern, String[] timePatterns) { List<String> patterns = new ArrayList<String>(); for (String timePattern : timePatterns) { patterns.add(datePattern + " " + timePattern); } // Always fall back on the date-only pattern patterns.add(datePattern); return patterns; }
java
private List<String> generateDateTimePatterns(String datePattern, String[] timePatterns) { List<String> patterns = new ArrayList<String>(); for (String timePattern : timePatterns) { patterns.add(datePattern + " " + timePattern); } // Always fall back on the date-only pattern patterns.add(datePattern); return patterns; }
[ "private", "List", "<", "String", ">", "generateDateTimePatterns", "(", "String", "datePattern", ",", "String", "[", "]", "timePatterns", ")", "{", "List", "<", "String", ">", "patterns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "timePattern", ":", "timePatterns", ")", "{", "patterns", ".", "add", "(", "datePattern", "+", "\" \"", "+", "timePattern", ")", ";", "}", "// Always fall back on the date-only pattern", "patterns", ".", "add", "(", "datePattern", ")", ";", "return", "patterns", ";", "}" ]
Generate a set of datetime patterns to accommodate variations in MPX files. @param datePattern date pattern element @param timePatterns time patterns @return datetime patterns
[ "Generate", "a", "set", "of", "datetime", "patterns", "to", "accommodate", "variations", "in", "MPX", "files", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXJFormats.java#L680-L692
157,630
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/AbstractVarMeta.java
AbstractVarMeta.getUniqueIdentifierArray
@Override public Integer[] getUniqueIdentifierArray() { Integer[] result = new Integer[m_table.size()]; int index = 0; for (Integer value : m_table.keySet()) { result[index] = value; ++index; } return (result); }
java
@Override public Integer[] getUniqueIdentifierArray() { Integer[] result = new Integer[m_table.size()]; int index = 0; for (Integer value : m_table.keySet()) { result[index] = value; ++index; } return (result); }
[ "@", "Override", "public", "Integer", "[", "]", "getUniqueIdentifierArray", "(", ")", "{", "Integer", "[", "]", "result", "=", "new", "Integer", "[", "m_table", ".", "size", "(", ")", "]", ";", "int", "index", "=", "0", ";", "for", "(", "Integer", "value", ":", "m_table", ".", "keySet", "(", ")", ")", "{", "result", "[", "index", "]", "=", "value", ";", "++", "index", ";", "}", "return", "(", "result", ")", ";", "}" ]
This method returns an array containing all of the unique identifiers for which data has been stored in the Var2Data block. @return array of unique identifiers
[ "This", "method", "returns", "an", "array", "containing", "all", "of", "the", "unique", "identifiers", "for", "which", "data", "has", "been", "stored", "in", "the", "Var2Data", "block", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/AbstractVarMeta.java#L70-L80
157,631
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/AbstractVarMeta.java
AbstractVarMeta.getOffset
@Override public Integer getOffset(Integer id, Integer type) { Integer result = null; Map<Integer, Integer> map = m_table.get(id); if (map != null && type != null) { result = map.get(type); } return (result); }
java
@Override public Integer getOffset(Integer id, Integer type) { Integer result = null; Map<Integer, Integer> map = m_table.get(id); if (map != null && type != null) { result = map.get(type); } return (result); }
[ "@", "Override", "public", "Integer", "getOffset", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "Integer", "result", "=", "null", ";", "Map", "<", "Integer", ",", "Integer", ">", "map", "=", "m_table", ".", "get", "(", "id", ")", ";", "if", "(", "map", "!=", "null", "&&", "type", "!=", "null", ")", "{", "result", "=", "map", ".", "get", "(", "type", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
This method retrieves the offset of a given entry in the Var2Data block. Each entry can be uniquely located by the identifier of the object to which the data belongs, and the type of the data. @param id unique identifier of an entity @param type data type identifier @return offset of requested item
[ "This", "method", "retrieves", "the", "offset", "of", "a", "given", "entry", "in", "the", "Var2Data", "block", ".", "Each", "entry", "can", "be", "uniquely", "located", "by", "the", "identifier", "of", "the", "object", "to", "which", "the", "data", "belongs", "and", "the", "type", "of", "the", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/AbstractVarMeta.java#L102-L113
157,632
joniles/mpxj
src/main/java/net/sf/mpxj/GenericCriteria.java
GenericCriteria.setRightValue
public void setRightValue(int index, Object value) { m_definedRightValues[index] = value; if (value instanceof FieldType) { m_symbolicValues = true; } else { if (value instanceof Duration) { if (((Duration) value).getUnits() != TimeUnit.HOURS) { value = ((Duration) value).convertUnits(TimeUnit.HOURS, m_properties); } } } m_workingRightValues[index] = value; }
java
public void setRightValue(int index, Object value) { m_definedRightValues[index] = value; if (value instanceof FieldType) { m_symbolicValues = true; } else { if (value instanceof Duration) { if (((Duration) value).getUnits() != TimeUnit.HOURS) { value = ((Duration) value).convertUnits(TimeUnit.HOURS, m_properties); } } } m_workingRightValues[index] = value; }
[ "public", "void", "setRightValue", "(", "int", "index", ",", "Object", "value", ")", "{", "m_definedRightValues", "[", "index", "]", "=", "value", ";", "if", "(", "value", "instanceof", "FieldType", ")", "{", "m_symbolicValues", "=", "true", ";", "}", "else", "{", "if", "(", "value", "instanceof", "Duration", ")", "{", "if", "(", "(", "(", "Duration", ")", "value", ")", ".", "getUnits", "(", ")", "!=", "TimeUnit", ".", "HOURS", ")", "{", "value", "=", "(", "(", "Duration", ")", "value", ")", ".", "convertUnits", "(", "TimeUnit", ".", "HOURS", ",", "m_properties", ")", ";", "}", "}", "}", "m_workingRightValues", "[", "index", "]", "=", "value", ";", "}" ]
Add the value to list of values to be used as part of the evaluation of this indicator. @param index position in the list @param value evaluation value
[ "Add", "the", "value", "to", "list", "of", "values", "to", "be", "used", "as", "part", "of", "the", "evaluation", "of", "this", "indicator", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/GenericCriteria.java#L95-L115
157,633
joniles/mpxj
src/main/java/net/sf/mpxj/GenericCriteria.java
GenericCriteria.evaluate
public boolean evaluate(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues) { // // Retrieve the LHS value // FieldType field = m_leftValue; Object lhs; if (field == null) { lhs = null; } else { lhs = container.getCurrentValue(field); switch (field.getDataType()) { case DATE: { if (lhs != null) { lhs = DateHelper.getDayStartDate((Date) lhs); } break; } case DURATION: { if (lhs != null) { Duration dur = (Duration) lhs; lhs = dur.convertUnits(TimeUnit.HOURS, m_properties); } else { lhs = Duration.getInstance(0, TimeUnit.HOURS); } break; } case STRING: { lhs = lhs == null ? "" : lhs; break; } default: { break; } } } // // Retrieve the RHS values // Object[] rhs; if (m_symbolicValues == true) { rhs = processSymbolicValues(m_workingRightValues, container, promptValues); } else { rhs = m_workingRightValues; } // // Evaluate // boolean result; switch (m_operator) { case AND: case OR: { result = evaluateLogicalOperator(container, promptValues); break; } default: { result = m_operator.evaluate(lhs, rhs); break; } } return result; }
java
public boolean evaluate(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues) { // // Retrieve the LHS value // FieldType field = m_leftValue; Object lhs; if (field == null) { lhs = null; } else { lhs = container.getCurrentValue(field); switch (field.getDataType()) { case DATE: { if (lhs != null) { lhs = DateHelper.getDayStartDate((Date) lhs); } break; } case DURATION: { if (lhs != null) { Duration dur = (Duration) lhs; lhs = dur.convertUnits(TimeUnit.HOURS, m_properties); } else { lhs = Duration.getInstance(0, TimeUnit.HOURS); } break; } case STRING: { lhs = lhs == null ? "" : lhs; break; } default: { break; } } } // // Retrieve the RHS values // Object[] rhs; if (m_symbolicValues == true) { rhs = processSymbolicValues(m_workingRightValues, container, promptValues); } else { rhs = m_workingRightValues; } // // Evaluate // boolean result; switch (m_operator) { case AND: case OR: { result = evaluateLogicalOperator(container, promptValues); break; } default: { result = m_operator.evaluate(lhs, rhs); break; } } return result; }
[ "public", "boolean", "evaluate", "(", "FieldContainer", "container", ",", "Map", "<", "GenericCriteriaPrompt", ",", "Object", ">", "promptValues", ")", "{", "//", "// Retrieve the LHS value", "//", "FieldType", "field", "=", "m_leftValue", ";", "Object", "lhs", ";", "if", "(", "field", "==", "null", ")", "{", "lhs", "=", "null", ";", "}", "else", "{", "lhs", "=", "container", ".", "getCurrentValue", "(", "field", ")", ";", "switch", "(", "field", ".", "getDataType", "(", ")", ")", "{", "case", "DATE", ":", "{", "if", "(", "lhs", "!=", "null", ")", "{", "lhs", "=", "DateHelper", ".", "getDayStartDate", "(", "(", "Date", ")", "lhs", ")", ";", "}", "break", ";", "}", "case", "DURATION", ":", "{", "if", "(", "lhs", "!=", "null", ")", "{", "Duration", "dur", "=", "(", "Duration", ")", "lhs", ";", "lhs", "=", "dur", ".", "convertUnits", "(", "TimeUnit", ".", "HOURS", ",", "m_properties", ")", ";", "}", "else", "{", "lhs", "=", "Duration", ".", "getInstance", "(", "0", ",", "TimeUnit", ".", "HOURS", ")", ";", "}", "break", ";", "}", "case", "STRING", ":", "{", "lhs", "=", "lhs", "==", "null", "?", "\"\"", ":", "lhs", ";", "break", ";", "}", "default", ":", "{", "break", ";", "}", "}", "}", "//", "// Retrieve the RHS values", "//", "Object", "[", "]", "rhs", ";", "if", "(", "m_symbolicValues", "==", "true", ")", "{", "rhs", "=", "processSymbolicValues", "(", "m_workingRightValues", ",", "container", ",", "promptValues", ")", ";", "}", "else", "{", "rhs", "=", "m_workingRightValues", ";", "}", "//", "// Evaluate", "//", "boolean", "result", ";", "switch", "(", "m_operator", ")", "{", "case", "AND", ":", "case", "OR", ":", "{", "result", "=", "evaluateLogicalOperator", "(", "container", ",", "promptValues", ")", ";", "break", ";", "}", "default", ":", "{", "result", "=", "m_operator", ".", "evaluate", "(", "lhs", ",", "rhs", ")", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Evaluate the criteria and return a boolean result. @param container field container @param promptValues responses to prompts @return boolean flag
[ "Evaluate", "the", "criteria", "and", "return", "a", "boolean", "result", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/GenericCriteria.java#L135-L222
157,634
joniles/mpxj
src/main/java/net/sf/mpxj/GenericCriteria.java
GenericCriteria.evaluateLogicalOperator
private boolean evaluateLogicalOperator(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues) { boolean result = false; if (m_criteriaList.size() == 0) { result = true; } else { for (GenericCriteria criteria : m_criteriaList) { result = criteria.evaluate(container, promptValues); if ((m_operator == TestOperator.AND && !result) || (m_operator == TestOperator.OR && result)) { break; } } } return result; }
java
private boolean evaluateLogicalOperator(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues) { boolean result = false; if (m_criteriaList.size() == 0) { result = true; } else { for (GenericCriteria criteria : m_criteriaList) { result = criteria.evaluate(container, promptValues); if ((m_operator == TestOperator.AND && !result) || (m_operator == TestOperator.OR && result)) { break; } } } return result; }
[ "private", "boolean", "evaluateLogicalOperator", "(", "FieldContainer", "container", ",", "Map", "<", "GenericCriteriaPrompt", ",", "Object", ">", "promptValues", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "m_criteriaList", ".", "size", "(", ")", "==", "0", ")", "{", "result", "=", "true", ";", "}", "else", "{", "for", "(", "GenericCriteria", "criteria", ":", "m_criteriaList", ")", "{", "result", "=", "criteria", ".", "evaluate", "(", "container", ",", "promptValues", ")", ";", "if", "(", "(", "m_operator", "==", "TestOperator", ".", "AND", "&&", "!", "result", ")", "||", "(", "m_operator", "==", "TestOperator", ".", "OR", "&&", "result", ")", ")", "{", "break", ";", "}", "}", "}", "return", "result", ";", "}" ]
Evalutes AND and OR operators. @param container data context @param promptValues responses to prompts @return operator result
[ "Evalutes", "AND", "and", "OR", "operators", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/GenericCriteria.java#L231-L252
157,635
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.read
private ProjectFile read() throws Exception { m_project = new ProjectFile(); m_eventManager = m_project.getEventManager(); m_project.getProjectProperties().setFileApplication("Synchro"); m_project.getProjectProperties().setFileType("SP"); CustomFieldContainer fields = m_project.getCustomFields(); fields.getCustomField(TaskField.TEXT1).setAlias("Code"); m_eventManager.addProjectListeners(m_projectListeners); processCalendars(); processResources(); processTasks(); processPredecessors(); return m_project; }
java
private ProjectFile read() throws Exception { m_project = new ProjectFile(); m_eventManager = m_project.getEventManager(); m_project.getProjectProperties().setFileApplication("Synchro"); m_project.getProjectProperties().setFileType("SP"); CustomFieldContainer fields = m_project.getCustomFields(); fields.getCustomField(TaskField.TEXT1).setAlias("Code"); m_eventManager.addProjectListeners(m_projectListeners); processCalendars(); processResources(); processTasks(); processPredecessors(); return m_project; }
[ "private", "ProjectFile", "read", "(", ")", "throws", "Exception", "{", "m_project", "=", "new", "ProjectFile", "(", ")", ";", "m_eventManager", "=", "m_project", ".", "getEventManager", "(", ")", ";", "m_project", ".", "getProjectProperties", "(", ")", ".", "setFileApplication", "(", "\"Synchro\"", ")", ";", "m_project", ".", "getProjectProperties", "(", ")", ".", "setFileType", "(", "\"SP\"", ")", ";", "CustomFieldContainer", "fields", "=", "m_project", ".", "getCustomFields", "(", ")", ";", "fields", ".", "getCustomField", "(", "TaskField", ".", "TEXT1", ")", ".", "setAlias", "(", "\"Code\"", ")", ";", "m_eventManager", ".", "addProjectListeners", "(", "m_projectListeners", ")", ";", "processCalendars", "(", ")", ";", "processResources", "(", ")", ";", "processTasks", "(", ")", ";", "processPredecessors", "(", ")", ";", "return", "m_project", ";", "}" ]
Reads data from the SP file. @return Project File instance
[ "Reads", "data", "from", "the", "SP", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L114-L133
157,636
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processCalendars
private void processCalendars() throws IOException { CalendarReader reader = new CalendarReader(m_data.getTableData("Calendars")); reader.read(); for (MapRow row : reader.getRows()) { processCalendar(row); } m_project.setDefaultCalendar(m_calendarMap.get(reader.getDefaultCalendarUUID())); }
java
private void processCalendars() throws IOException { CalendarReader reader = new CalendarReader(m_data.getTableData("Calendars")); reader.read(); for (MapRow row : reader.getRows()) { processCalendar(row); } m_project.setDefaultCalendar(m_calendarMap.get(reader.getDefaultCalendarUUID())); }
[ "private", "void", "processCalendars", "(", ")", "throws", "IOException", "{", "CalendarReader", "reader", "=", "new", "CalendarReader", "(", "m_data", ".", "getTableData", "(", "\"Calendars\"", ")", ")", ";", "reader", ".", "read", "(", ")", ";", "for", "(", "MapRow", "row", ":", "reader", ".", "getRows", "(", ")", ")", "{", "processCalendar", "(", "row", ")", ";", "}", "m_project", ".", "setDefaultCalendar", "(", "m_calendarMap", ".", "get", "(", "reader", ".", "getDefaultCalendarUUID", "(", ")", ")", ")", ";", "}" ]
Extract calendar data.
[ "Extract", "calendar", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L138-L149
157,637
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processCalendar
private void processCalendar(MapRow row) { ProjectCalendar calendar = m_project.addCalendar(); Map<UUID, List<DateRange>> dayTypeMap = processDayTypes(row.getRows("DAY_TYPES")); calendar.setName(row.getString("NAME")); processRanges(dayTypeMap.get(row.getUUID("SUNDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SUNDAY)); processRanges(dayTypeMap.get(row.getUUID("MONDAY_DAY_TYPE")), calendar.addCalendarHours(Day.MONDAY)); processRanges(dayTypeMap.get(row.getUUID("TUESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.TUESDAY)); processRanges(dayTypeMap.get(row.getUUID("WEDNESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.WEDNESDAY)); processRanges(dayTypeMap.get(row.getUUID("THURSDAY_DAY_TYPE")), calendar.addCalendarHours(Day.THURSDAY)); processRanges(dayTypeMap.get(row.getUUID("FRIDAY_DAY_TYPE")), calendar.addCalendarHours(Day.FRIDAY)); processRanges(dayTypeMap.get(row.getUUID("SATURDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SATURDAY)); for (MapRow assignment : row.getRows("DAY_TYPE_ASSIGNMENTS")) { Date date = assignment.getDate("DATE"); processRanges(dayTypeMap.get(assignment.getUUID("DAY_TYPE_UUID")), calendar.addCalendarException(date, date)); } m_calendarMap.put(row.getUUID("UUID"), calendar); }
java
private void processCalendar(MapRow row) { ProjectCalendar calendar = m_project.addCalendar(); Map<UUID, List<DateRange>> dayTypeMap = processDayTypes(row.getRows("DAY_TYPES")); calendar.setName(row.getString("NAME")); processRanges(dayTypeMap.get(row.getUUID("SUNDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SUNDAY)); processRanges(dayTypeMap.get(row.getUUID("MONDAY_DAY_TYPE")), calendar.addCalendarHours(Day.MONDAY)); processRanges(dayTypeMap.get(row.getUUID("TUESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.TUESDAY)); processRanges(dayTypeMap.get(row.getUUID("WEDNESDAY_DAY_TYPE")), calendar.addCalendarHours(Day.WEDNESDAY)); processRanges(dayTypeMap.get(row.getUUID("THURSDAY_DAY_TYPE")), calendar.addCalendarHours(Day.THURSDAY)); processRanges(dayTypeMap.get(row.getUUID("FRIDAY_DAY_TYPE")), calendar.addCalendarHours(Day.FRIDAY)); processRanges(dayTypeMap.get(row.getUUID("SATURDAY_DAY_TYPE")), calendar.addCalendarHours(Day.SATURDAY)); for (MapRow assignment : row.getRows("DAY_TYPE_ASSIGNMENTS")) { Date date = assignment.getDate("DATE"); processRanges(dayTypeMap.get(assignment.getUUID("DAY_TYPE_UUID")), calendar.addCalendarException(date, date)); } m_calendarMap.put(row.getUUID("UUID"), calendar); }
[ "private", "void", "processCalendar", "(", "MapRow", "row", ")", "{", "ProjectCalendar", "calendar", "=", "m_project", ".", "addCalendar", "(", ")", ";", "Map", "<", "UUID", ",", "List", "<", "DateRange", ">", ">", "dayTypeMap", "=", "processDayTypes", "(", "row", ".", "getRows", "(", "\"DAY_TYPES\"", ")", ")", ";", "calendar", ".", "setName", "(", "row", ".", "getString", "(", "\"NAME\"", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"SUNDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "SUNDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"MONDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "MONDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"TUESDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "TUESDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"WEDNESDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "WEDNESDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"THURSDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "THURSDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"FRIDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "FRIDAY", ")", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"SATURDAY_DAY_TYPE\"", ")", ")", ",", "calendar", ".", "addCalendarHours", "(", "Day", ".", "SATURDAY", ")", ")", ";", "for", "(", "MapRow", "assignment", ":", "row", ".", "getRows", "(", "\"DAY_TYPE_ASSIGNMENTS\"", ")", ")", "{", "Date", "date", "=", "assignment", ".", "getDate", "(", "\"DATE\"", ")", ";", "processRanges", "(", "dayTypeMap", ".", "get", "(", "assignment", ".", "getUUID", "(", "\"DAY_TYPE_UUID\"", ")", ")", ",", "calendar", ".", "addCalendarException", "(", "date", ",", "date", ")", ")", ";", "}", "m_calendarMap", ".", "put", "(", "row", ".", "getUUID", "(", "\"UUID\"", ")", ",", "calendar", ")", ";", "}" ]
Extract data for a single calendar. @param row calendar data
[ "Extract", "data", "for", "a", "single", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L156-L179
157,638
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processRanges
private void processRanges(List<DateRange> ranges, ProjectCalendarDateRanges container) { if (ranges != null) { for (DateRange range : ranges) { container.addRange(range); } } }
java
private void processRanges(List<DateRange> ranges, ProjectCalendarDateRanges container) { if (ranges != null) { for (DateRange range : ranges) { container.addRange(range); } } }
[ "private", "void", "processRanges", "(", "List", "<", "DateRange", ">", "ranges", ",", "ProjectCalendarDateRanges", "container", ")", "{", "if", "(", "ranges", "!=", "null", ")", "{", "for", "(", "DateRange", "range", ":", "ranges", ")", "{", "container", ".", "addRange", "(", "range", ")", ";", "}", "}", "}" ]
Populate time ranges. @param ranges time ranges from a Synchro table @param container time range container
[ "Populate", "time", "ranges", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L187-L196
157,639
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processDayTypes
private Map<UUID, List<DateRange>> processDayTypes(List<MapRow> types) { Map<UUID, List<DateRange>> map = new HashMap<UUID, List<DateRange>>(); for (MapRow row : types) { List<DateRange> ranges = new ArrayList<DateRange>(); for (MapRow range : row.getRows("TIME_RANGES")) { ranges.add(new DateRange(range.getDate("START"), range.getDate("END"))); } map.put(row.getUUID("UUID"), ranges); } return map; }
java
private Map<UUID, List<DateRange>> processDayTypes(List<MapRow> types) { Map<UUID, List<DateRange>> map = new HashMap<UUID, List<DateRange>>(); for (MapRow row : types) { List<DateRange> ranges = new ArrayList<DateRange>(); for (MapRow range : row.getRows("TIME_RANGES")) { ranges.add(new DateRange(range.getDate("START"), range.getDate("END"))); } map.put(row.getUUID("UUID"), ranges); } return map; }
[ "private", "Map", "<", "UUID", ",", "List", "<", "DateRange", ">", ">", "processDayTypes", "(", "List", "<", "MapRow", ">", "types", ")", "{", "Map", "<", "UUID", ",", "List", "<", "DateRange", ">", ">", "map", "=", "new", "HashMap", "<", "UUID", ",", "List", "<", "DateRange", ">", ">", "(", ")", ";", "for", "(", "MapRow", "row", ":", "types", ")", "{", "List", "<", "DateRange", ">", "ranges", "=", "new", "ArrayList", "<", "DateRange", ">", "(", ")", ";", "for", "(", "MapRow", "range", ":", "row", ".", "getRows", "(", "\"TIME_RANGES\"", ")", ")", "{", "ranges", ".", "add", "(", "new", "DateRange", "(", "range", ".", "getDate", "(", "\"START\"", ")", ",", "range", ".", "getDate", "(", "\"END\"", ")", ")", ")", ";", "}", "map", ".", "put", "(", "row", ".", "getUUID", "(", "\"UUID\"", ")", ",", "ranges", ")", ";", "}", "return", "map", ";", "}" ]
Extract day type definitions. @param types Synchro day type rows @return Map of day types by UUID
[ "Extract", "day", "type", "definitions", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L204-L218
157,640
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processResources
private void processResources() throws IOException { CompanyReader reader = new CompanyReader(m_data.getTableData("Companies")); reader.read(); for (MapRow companyRow : reader.getRows()) { // TODO: need to sort by type as well as by name! for (MapRow resourceRow : sort(companyRow.getRows("RESOURCES"), "NAME")) { processResource(resourceRow); } } }
java
private void processResources() throws IOException { CompanyReader reader = new CompanyReader(m_data.getTableData("Companies")); reader.read(); for (MapRow companyRow : reader.getRows()) { // TODO: need to sort by type as well as by name! for (MapRow resourceRow : sort(companyRow.getRows("RESOURCES"), "NAME")) { processResource(resourceRow); } } }
[ "private", "void", "processResources", "(", ")", "throws", "IOException", "{", "CompanyReader", "reader", "=", "new", "CompanyReader", "(", "m_data", ".", "getTableData", "(", "\"Companies\"", ")", ")", ";", "reader", ".", "read", "(", ")", ";", "for", "(", "MapRow", "companyRow", ":", "reader", ".", "getRows", "(", ")", ")", "{", "// TODO: need to sort by type as well as by name!", "for", "(", "MapRow", "resourceRow", ":", "sort", "(", "companyRow", ".", "getRows", "(", "\"RESOURCES\"", ")", ",", "\"NAME\"", ")", ")", "{", "processResource", "(", "resourceRow", ")", ";", "}", "}", "}" ]
Extract resource data.
[ "Extract", "resource", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L223-L235
157,641
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processResource
private void processResource(MapRow row) throws IOException { Resource resource = m_project.addResource(); resource.setName(row.getString("NAME")); resource.setGUID(row.getUUID("UUID")); resource.setEmailAddress(row.getString("EMAIL")); resource.setHyperlink(row.getString("URL")); resource.setNotes(getNotes(row.getRows("COMMENTARY"))); resource.setText(1, row.getString("DESCRIPTION")); resource.setText(2, row.getString("SUPPLY_REFERENCE")); resource.setActive(true); List<MapRow> resources = row.getRows("RESOURCES"); if (resources != null) { for (MapRow childResource : sort(resources, "NAME")) { processResource(childResource); } } m_resourceMap.put(resource.getGUID(), resource); }
java
private void processResource(MapRow row) throws IOException { Resource resource = m_project.addResource(); resource.setName(row.getString("NAME")); resource.setGUID(row.getUUID("UUID")); resource.setEmailAddress(row.getString("EMAIL")); resource.setHyperlink(row.getString("URL")); resource.setNotes(getNotes(row.getRows("COMMENTARY"))); resource.setText(1, row.getString("DESCRIPTION")); resource.setText(2, row.getString("SUPPLY_REFERENCE")); resource.setActive(true); List<MapRow> resources = row.getRows("RESOURCES"); if (resources != null) { for (MapRow childResource : sort(resources, "NAME")) { processResource(childResource); } } m_resourceMap.put(resource.getGUID(), resource); }
[ "private", "void", "processResource", "(", "MapRow", "row", ")", "throws", "IOException", "{", "Resource", "resource", "=", "m_project", ".", "addResource", "(", ")", ";", "resource", ".", "setName", "(", "row", ".", "getString", "(", "\"NAME\"", ")", ")", ";", "resource", ".", "setGUID", "(", "row", ".", "getUUID", "(", "\"UUID\"", ")", ")", ";", "resource", ".", "setEmailAddress", "(", "row", ".", "getString", "(", "\"EMAIL\"", ")", ")", ";", "resource", ".", "setHyperlink", "(", "row", ".", "getString", "(", "\"URL\"", ")", ")", ";", "resource", ".", "setNotes", "(", "getNotes", "(", "row", ".", "getRows", "(", "\"COMMENTARY\"", ")", ")", ")", ";", "resource", ".", "setText", "(", "1", ",", "row", ".", "getString", "(", "\"DESCRIPTION\"", ")", ")", ";", "resource", ".", "setText", "(", "2", ",", "row", ".", "getString", "(", "\"SUPPLY_REFERENCE\"", ")", ")", ";", "resource", ".", "setActive", "(", "true", ")", ";", "List", "<", "MapRow", ">", "resources", "=", "row", ".", "getRows", "(", "\"RESOURCES\"", ")", ";", "if", "(", "resources", "!=", "null", ")", "{", "for", "(", "MapRow", "childResource", ":", "sort", "(", "resources", ",", "\"NAME\"", ")", ")", "{", "processResource", "(", "childResource", ")", ";", "}", "}", "m_resourceMap", ".", "put", "(", "resource", ".", "getGUID", "(", ")", ",", "resource", ")", ";", "}" ]
Extract data for a single resource. @param row Synchro resource data
[ "Extract", "data", "for", "a", "single", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L242-L264
157,642
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processTasks
private void processTasks() throws IOException { TaskReader reader = new TaskReader(m_data.getTableData("Tasks")); reader.read(); for (MapRow row : reader.getRows()) { processTask(m_project, row); } updateDates(); }
java
private void processTasks() throws IOException { TaskReader reader = new TaskReader(m_data.getTableData("Tasks")); reader.read(); for (MapRow row : reader.getRows()) { processTask(m_project, row); } updateDates(); }
[ "private", "void", "processTasks", "(", ")", "throws", "IOException", "{", "TaskReader", "reader", "=", "new", "TaskReader", "(", "m_data", ".", "getTableData", "(", "\"Tasks\"", ")", ")", ";", "reader", ".", "read", "(", ")", ";", "for", "(", "MapRow", "row", ":", "reader", ".", "getRows", "(", ")", ")", "{", "processTask", "(", "m_project", ",", "row", ")", ";", "}", "updateDates", "(", ")", ";", "}" ]
Extract task data.
[ "Extract", "task", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L269-L278
157,643
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processTask
private void processTask(ChildTaskContainer parent, MapRow row) throws IOException { Task task = parent.addTask(); task.setName(row.getString("NAME")); task.setGUID(row.getUUID("UUID")); task.setText(1, row.getString("ID")); task.setDuration(row.getDuration("PLANNED_DURATION")); task.setRemainingDuration(row.getDuration("REMAINING_DURATION")); task.setHyperlink(row.getString("URL")); task.setPercentageComplete(row.getDouble("PERCENT_COMPLETE")); task.setNotes(getNotes(row.getRows("COMMENTARY"))); task.setMilestone(task.getDuration().getDuration() == 0); ProjectCalendar calendar = m_calendarMap.get(row.getUUID("CALENDAR_UUID")); if (calendar != m_project.getDefaultCalendar()) { task.setCalendar(calendar); } switch (row.getInteger("STATUS").intValue()) { case 1: // Planned { task.setStart(row.getDate("PLANNED_START")); task.setFinish(task.getEffectiveCalendar().getDate(task.getStart(), task.getDuration(), false)); break; } case 2: // Started { task.setActualStart(row.getDate("ACTUAL_START")); task.setStart(task.getActualStart()); task.setFinish(row.getDate("ESTIMATED_FINISH")); if (task.getFinish() == null) { task.setFinish(row.getDate("PLANNED_FINISH")); } break; } case 3: // Finished { task.setActualStart(row.getDate("ACTUAL_START")); task.setActualFinish(row.getDate("ACTUAL_FINISH")); task.setPercentageComplete(Double.valueOf(100.0)); task.setStart(task.getActualStart()); task.setFinish(task.getActualFinish()); break; } } setConstraints(task, row); processChildTasks(task, row); m_taskMap.put(task.getGUID(), task); List<MapRow> predecessors = row.getRows("PREDECESSORS"); if (predecessors != null && !predecessors.isEmpty()) { m_predecessorMap.put(task, predecessors); } List<MapRow> resourceAssignmnets = row.getRows("RESOURCE_ASSIGNMENTS"); if (resourceAssignmnets != null && !resourceAssignmnets.isEmpty()) { processResourceAssignments(task, resourceAssignmnets); } }
java
private void processTask(ChildTaskContainer parent, MapRow row) throws IOException { Task task = parent.addTask(); task.setName(row.getString("NAME")); task.setGUID(row.getUUID("UUID")); task.setText(1, row.getString("ID")); task.setDuration(row.getDuration("PLANNED_DURATION")); task.setRemainingDuration(row.getDuration("REMAINING_DURATION")); task.setHyperlink(row.getString("URL")); task.setPercentageComplete(row.getDouble("PERCENT_COMPLETE")); task.setNotes(getNotes(row.getRows("COMMENTARY"))); task.setMilestone(task.getDuration().getDuration() == 0); ProjectCalendar calendar = m_calendarMap.get(row.getUUID("CALENDAR_UUID")); if (calendar != m_project.getDefaultCalendar()) { task.setCalendar(calendar); } switch (row.getInteger("STATUS").intValue()) { case 1: // Planned { task.setStart(row.getDate("PLANNED_START")); task.setFinish(task.getEffectiveCalendar().getDate(task.getStart(), task.getDuration(), false)); break; } case 2: // Started { task.setActualStart(row.getDate("ACTUAL_START")); task.setStart(task.getActualStart()); task.setFinish(row.getDate("ESTIMATED_FINISH")); if (task.getFinish() == null) { task.setFinish(row.getDate("PLANNED_FINISH")); } break; } case 3: // Finished { task.setActualStart(row.getDate("ACTUAL_START")); task.setActualFinish(row.getDate("ACTUAL_FINISH")); task.setPercentageComplete(Double.valueOf(100.0)); task.setStart(task.getActualStart()); task.setFinish(task.getActualFinish()); break; } } setConstraints(task, row); processChildTasks(task, row); m_taskMap.put(task.getGUID(), task); List<MapRow> predecessors = row.getRows("PREDECESSORS"); if (predecessors != null && !predecessors.isEmpty()) { m_predecessorMap.put(task, predecessors); } List<MapRow> resourceAssignmnets = row.getRows("RESOURCE_ASSIGNMENTS"); if (resourceAssignmnets != null && !resourceAssignmnets.isEmpty()) { processResourceAssignments(task, resourceAssignmnets); } }
[ "private", "void", "processTask", "(", "ChildTaskContainer", "parent", ",", "MapRow", "row", ")", "throws", "IOException", "{", "Task", "task", "=", "parent", ".", "addTask", "(", ")", ";", "task", ".", "setName", "(", "row", ".", "getString", "(", "\"NAME\"", ")", ")", ";", "task", ".", "setGUID", "(", "row", ".", "getUUID", "(", "\"UUID\"", ")", ")", ";", "task", ".", "setText", "(", "1", ",", "row", ".", "getString", "(", "\"ID\"", ")", ")", ";", "task", ".", "setDuration", "(", "row", ".", "getDuration", "(", "\"PLANNED_DURATION\"", ")", ")", ";", "task", ".", "setRemainingDuration", "(", "row", ".", "getDuration", "(", "\"REMAINING_DURATION\"", ")", ")", ";", "task", ".", "setHyperlink", "(", "row", ".", "getString", "(", "\"URL\"", ")", ")", ";", "task", ".", "setPercentageComplete", "(", "row", ".", "getDouble", "(", "\"PERCENT_COMPLETE\"", ")", ")", ";", "task", ".", "setNotes", "(", "getNotes", "(", "row", ".", "getRows", "(", "\"COMMENTARY\"", ")", ")", ")", ";", "task", ".", "setMilestone", "(", "task", ".", "getDuration", "(", ")", ".", "getDuration", "(", ")", "==", "0", ")", ";", "ProjectCalendar", "calendar", "=", "m_calendarMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"CALENDAR_UUID\"", ")", ")", ";", "if", "(", "calendar", "!=", "m_project", ".", "getDefaultCalendar", "(", ")", ")", "{", "task", ".", "setCalendar", "(", "calendar", ")", ";", "}", "switch", "(", "row", ".", "getInteger", "(", "\"STATUS\"", ")", ".", "intValue", "(", ")", ")", "{", "case", "1", ":", "// Planned", "{", "task", ".", "setStart", "(", "row", ".", "getDate", "(", "\"PLANNED_START\"", ")", ")", ";", "task", ".", "setFinish", "(", "task", ".", "getEffectiveCalendar", "(", ")", ".", "getDate", "(", "task", ".", "getStart", "(", ")", ",", "task", ".", "getDuration", "(", ")", ",", "false", ")", ")", ";", "break", ";", "}", "case", "2", ":", "// Started", "{", "task", ".", "setActualStart", "(", "row", ".", "getDate", "(", "\"ACTUAL_START\"", ")", ")", ";", "task", ".", "setStart", "(", "task", ".", "getActualStart", "(", ")", ")", ";", "task", ".", "setFinish", "(", "row", ".", "getDate", "(", "\"ESTIMATED_FINISH\"", ")", ")", ";", "if", "(", "task", ".", "getFinish", "(", ")", "==", "null", ")", "{", "task", ".", "setFinish", "(", "row", ".", "getDate", "(", "\"PLANNED_FINISH\"", ")", ")", ";", "}", "break", ";", "}", "case", "3", ":", "// Finished", "{", "task", ".", "setActualStart", "(", "row", ".", "getDate", "(", "\"ACTUAL_START\"", ")", ")", ";", "task", ".", "setActualFinish", "(", "row", ".", "getDate", "(", "\"ACTUAL_FINISH\"", ")", ")", ";", "task", ".", "setPercentageComplete", "(", "Double", ".", "valueOf", "(", "100.0", ")", ")", ";", "task", ".", "setStart", "(", "task", ".", "getActualStart", "(", ")", ")", ";", "task", ".", "setFinish", "(", "task", ".", "getActualFinish", "(", ")", ")", ";", "break", ";", "}", "}", "setConstraints", "(", "task", ",", "row", ")", ";", "processChildTasks", "(", "task", ",", "row", ")", ";", "m_taskMap", ".", "put", "(", "task", ".", "getGUID", "(", ")", ",", "task", ")", ";", "List", "<", "MapRow", ">", "predecessors", "=", "row", ".", "getRows", "(", "\"PREDECESSORS\"", ")", ";", "if", "(", "predecessors", "!=", "null", "&&", "!", "predecessors", ".", "isEmpty", "(", ")", ")", "{", "m_predecessorMap", ".", "put", "(", "task", ",", "predecessors", ")", ";", "}", "List", "<", "MapRow", ">", "resourceAssignmnets", "=", "row", ".", "getRows", "(", "\"RESOURCE_ASSIGNMENTS\"", ")", ";", "if", "(", "resourceAssignmnets", "!=", "null", "&&", "!", "resourceAssignmnets", ".", "isEmpty", "(", ")", ")", "{", "processResourceAssignments", "(", "task", ",", "resourceAssignmnets", ")", ";", "}", "}" ]
Extract data for a single task. @param parent task parent @param row Synchro task data
[ "Extract", "data", "for", "a", "single", "task", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L286-L354
157,644
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processChildTasks
private void processChildTasks(Task task, MapRow row) throws IOException { List<MapRow> tasks = row.getRows("TASKS"); if (tasks != null) { for (MapRow childTask : tasks) { processTask(task, childTask); } } }
java
private void processChildTasks(Task task, MapRow row) throws IOException { List<MapRow> tasks = row.getRows("TASKS"); if (tasks != null) { for (MapRow childTask : tasks) { processTask(task, childTask); } } }
[ "private", "void", "processChildTasks", "(", "Task", "task", ",", "MapRow", "row", ")", "throws", "IOException", "{", "List", "<", "MapRow", ">", "tasks", "=", "row", ".", "getRows", "(", "\"TASKS\"", ")", ";", "if", "(", "tasks", "!=", "null", ")", "{", "for", "(", "MapRow", "childTask", ":", "tasks", ")", "{", "processTask", "(", "task", ",", "childTask", ")", ";", "}", "}", "}" ]
Extract child task data. @param task MPXJ task @param row Synchro task data
[ "Extract", "child", "task", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L362-L372
157,645
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processPredecessors
private void processPredecessors() { for (Map.Entry<Task, List<MapRow>> entry : m_predecessorMap.entrySet()) { Task task = entry.getKey(); List<MapRow> predecessors = entry.getValue(); for (MapRow predecessor : predecessors) { processPredecessor(task, predecessor); } } }
java
private void processPredecessors() { for (Map.Entry<Task, List<MapRow>> entry : m_predecessorMap.entrySet()) { Task task = entry.getKey(); List<MapRow> predecessors = entry.getValue(); for (MapRow predecessor : predecessors) { processPredecessor(task, predecessor); } } }
[ "private", "void", "processPredecessors", "(", ")", "{", "for", "(", "Map", ".", "Entry", "<", "Task", ",", "List", "<", "MapRow", ">", ">", "entry", ":", "m_predecessorMap", ".", "entrySet", "(", ")", ")", "{", "Task", "task", "=", "entry", ".", "getKey", "(", ")", ";", "List", "<", "MapRow", ">", "predecessors", "=", "entry", ".", "getValue", "(", ")", ";", "for", "(", "MapRow", "predecessor", ":", "predecessors", ")", "{", "processPredecessor", "(", "task", ",", "predecessor", ")", ";", "}", "}", "}" ]
Extract predecessor data.
[ "Extract", "predecessor", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L377-L388
157,646
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processPredecessor
private void processPredecessor(Task task, MapRow row) { Task predecessor = m_taskMap.get(row.getUUID("PREDECESSOR_UUID")); if (predecessor != null) { task.addPredecessor(predecessor, row.getRelationType("RELATION_TYPE"), row.getDuration("LAG")); } }
java
private void processPredecessor(Task task, MapRow row) { Task predecessor = m_taskMap.get(row.getUUID("PREDECESSOR_UUID")); if (predecessor != null) { task.addPredecessor(predecessor, row.getRelationType("RELATION_TYPE"), row.getDuration("LAG")); } }
[ "private", "void", "processPredecessor", "(", "Task", "task", ",", "MapRow", "row", ")", "{", "Task", "predecessor", "=", "m_taskMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"PREDECESSOR_UUID\"", ")", ")", ";", "if", "(", "predecessor", "!=", "null", ")", "{", "task", ".", "addPredecessor", "(", "predecessor", ",", "row", ".", "getRelationType", "(", "\"RELATION_TYPE\"", ")", ",", "row", ".", "getDuration", "(", "\"LAG\"", ")", ")", ";", "}", "}" ]
Extract data for a single predecessor. @param task parent task @param row Synchro predecessor data
[ "Extract", "data", "for", "a", "single", "predecessor", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L396-L403
157,647
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processResourceAssignments
private void processResourceAssignments(Task task, List<MapRow> assignments) { for (MapRow row : assignments) { processResourceAssignment(task, row); } }
java
private void processResourceAssignments(Task task, List<MapRow> assignments) { for (MapRow row : assignments) { processResourceAssignment(task, row); } }
[ "private", "void", "processResourceAssignments", "(", "Task", "task", ",", "List", "<", "MapRow", ">", "assignments", ")", "{", "for", "(", "MapRow", "row", ":", "assignments", ")", "{", "processResourceAssignment", "(", "task", ",", "row", ")", ";", "}", "}" ]
Extract resource assignments for a task. @param task parent task @param assignments list of Synchro resource assignment data
[ "Extract", "resource", "assignments", "for", "a", "task", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L411-L417
157,648
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.processResourceAssignment
private void processResourceAssignment(Task task, MapRow row) { Resource resource = m_resourceMap.get(row.getUUID("RESOURCE_UUID")); task.addResourceAssignment(resource); }
java
private void processResourceAssignment(Task task, MapRow row) { Resource resource = m_resourceMap.get(row.getUUID("RESOURCE_UUID")); task.addResourceAssignment(resource); }
[ "private", "void", "processResourceAssignment", "(", "Task", "task", ",", "MapRow", "row", ")", "{", "Resource", "resource", "=", "m_resourceMap", ".", "get", "(", "row", ".", "getUUID", "(", "\"RESOURCE_UUID\"", ")", ")", ";", "task", ".", "addResourceAssignment", "(", "resource", ")", ";", "}" ]
Extract data for a single resource assignment. @param task parent task @param row Synchro resource assignment
[ "Extract", "data", "for", "a", "single", "resource", "assignment", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L425-L429
157,649
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.setConstraints
private void setConstraints(Task task, MapRow row) { ConstraintType constraintType = null; Date constraintDate = null; Date lateDate = row.getDate("CONSTRAINT_LATE_DATE"); Date earlyDate = row.getDate("CONSTRAINT_EARLY_DATE"); switch (row.getInteger("CONSTRAINT_TYPE").intValue()) { case 2: // Cannot Reschedule { constraintType = ConstraintType.MUST_START_ON; constraintDate = task.getStart(); break; } case 12: //Finish Between { constraintType = ConstraintType.MUST_FINISH_ON; constraintDate = lateDate; break; } case 10: // Finish On or After { constraintType = ConstraintType.FINISH_NO_EARLIER_THAN; constraintDate = earlyDate; break; } case 11: // Finish On or Before { constraintType = ConstraintType.FINISH_NO_LATER_THAN; constraintDate = lateDate; break; } case 13: // Mandatory Start case 5: // Start On case 9: // Finish On { constraintType = ConstraintType.MUST_START_ON; constraintDate = earlyDate; break; } case 14: // Mandatory Finish { constraintType = ConstraintType.MUST_FINISH_ON; constraintDate = earlyDate; break; } case 4: // Start As Late As Possible { constraintType = ConstraintType.AS_LATE_AS_POSSIBLE; break; } case 3: // Start As Soon As Possible { constraintType = ConstraintType.AS_SOON_AS_POSSIBLE; break; } case 8: // Start Between { constraintType = ConstraintType.AS_SOON_AS_POSSIBLE; constraintDate = earlyDate; break; } case 6: // Start On or Before { constraintType = ConstraintType.START_NO_LATER_THAN; constraintDate = earlyDate; break; } case 15: // Work Between { constraintType = ConstraintType.START_NO_EARLIER_THAN; constraintDate = earlyDate; break; } } task.setConstraintType(constraintType); task.setConstraintDate(constraintDate); }
java
private void setConstraints(Task task, MapRow row) { ConstraintType constraintType = null; Date constraintDate = null; Date lateDate = row.getDate("CONSTRAINT_LATE_DATE"); Date earlyDate = row.getDate("CONSTRAINT_EARLY_DATE"); switch (row.getInteger("CONSTRAINT_TYPE").intValue()) { case 2: // Cannot Reschedule { constraintType = ConstraintType.MUST_START_ON; constraintDate = task.getStart(); break; } case 12: //Finish Between { constraintType = ConstraintType.MUST_FINISH_ON; constraintDate = lateDate; break; } case 10: // Finish On or After { constraintType = ConstraintType.FINISH_NO_EARLIER_THAN; constraintDate = earlyDate; break; } case 11: // Finish On or Before { constraintType = ConstraintType.FINISH_NO_LATER_THAN; constraintDate = lateDate; break; } case 13: // Mandatory Start case 5: // Start On case 9: // Finish On { constraintType = ConstraintType.MUST_START_ON; constraintDate = earlyDate; break; } case 14: // Mandatory Finish { constraintType = ConstraintType.MUST_FINISH_ON; constraintDate = earlyDate; break; } case 4: // Start As Late As Possible { constraintType = ConstraintType.AS_LATE_AS_POSSIBLE; break; } case 3: // Start As Soon As Possible { constraintType = ConstraintType.AS_SOON_AS_POSSIBLE; break; } case 8: // Start Between { constraintType = ConstraintType.AS_SOON_AS_POSSIBLE; constraintDate = earlyDate; break; } case 6: // Start On or Before { constraintType = ConstraintType.START_NO_LATER_THAN; constraintDate = earlyDate; break; } case 15: // Work Between { constraintType = ConstraintType.START_NO_EARLIER_THAN; constraintDate = earlyDate; break; } } task.setConstraintType(constraintType); task.setConstraintDate(constraintDate); }
[ "private", "void", "setConstraints", "(", "Task", "task", ",", "MapRow", "row", ")", "{", "ConstraintType", "constraintType", "=", "null", ";", "Date", "constraintDate", "=", "null", ";", "Date", "lateDate", "=", "row", ".", "getDate", "(", "\"CONSTRAINT_LATE_DATE\"", ")", ";", "Date", "earlyDate", "=", "row", ".", "getDate", "(", "\"CONSTRAINT_EARLY_DATE\"", ")", ";", "switch", "(", "row", ".", "getInteger", "(", "\"CONSTRAINT_TYPE\"", ")", ".", "intValue", "(", ")", ")", "{", "case", "2", ":", "// Cannot Reschedule", "{", "constraintType", "=", "ConstraintType", ".", "MUST_START_ON", ";", "constraintDate", "=", "task", ".", "getStart", "(", ")", ";", "break", ";", "}", "case", "12", ":", "//Finish Between", "{", "constraintType", "=", "ConstraintType", ".", "MUST_FINISH_ON", ";", "constraintDate", "=", "lateDate", ";", "break", ";", "}", "case", "10", ":", "// Finish On or After", "{", "constraintType", "=", "ConstraintType", ".", "FINISH_NO_EARLIER_THAN", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "case", "11", ":", "// Finish On or Before", "{", "constraintType", "=", "ConstraintType", ".", "FINISH_NO_LATER_THAN", ";", "constraintDate", "=", "lateDate", ";", "break", ";", "}", "case", "13", ":", "// Mandatory Start", "case", "5", ":", "// Start On", "case", "9", ":", "// Finish On", "{", "constraintType", "=", "ConstraintType", ".", "MUST_START_ON", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "case", "14", ":", "// Mandatory Finish", "{", "constraintType", "=", "ConstraintType", ".", "MUST_FINISH_ON", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "case", "4", ":", "// Start As Late As Possible", "{", "constraintType", "=", "ConstraintType", ".", "AS_LATE_AS_POSSIBLE", ";", "break", ";", "}", "case", "3", ":", "// Start As Soon As Possible", "{", "constraintType", "=", "ConstraintType", ".", "AS_SOON_AS_POSSIBLE", ";", "break", ";", "}", "case", "8", ":", "// Start Between", "{", "constraintType", "=", "ConstraintType", ".", "AS_SOON_AS_POSSIBLE", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "case", "6", ":", "// Start On or Before", "{", "constraintType", "=", "ConstraintType", ".", "START_NO_LATER_THAN", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "case", "15", ":", "// Work Between", "{", "constraintType", "=", "ConstraintType", ".", "START_NO_EARLIER_THAN", ";", "constraintDate", "=", "earlyDate", ";", "break", ";", "}", "}", "task", ".", "setConstraintType", "(", "constraintType", ")", ";", "task", ".", "setConstraintDate", "(", "constraintDate", ")", ";", "}" ]
Map Synchro constraints to MPXJ constraints. @param task task @param row Synchro constraint data
[ "Map", "Synchro", "constraints", "to", "MPXJ", "constraints", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L437-L525
157,650
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.getNotes
private String getNotes(List<MapRow> rows) { String result = null; if (rows != null && !rows.isEmpty()) { StringBuilder sb = new StringBuilder(); for (MapRow row : rows) { sb.append(row.getString("TITLE")); sb.append('\n'); sb.append(row.getString("TEXT")); sb.append("\n\n"); } result = sb.toString(); } return result; }
java
private String getNotes(List<MapRow> rows) { String result = null; if (rows != null && !rows.isEmpty()) { StringBuilder sb = new StringBuilder(); for (MapRow row : rows) { sb.append(row.getString("TITLE")); sb.append('\n'); sb.append(row.getString("TEXT")); sb.append("\n\n"); } result = sb.toString(); } return result; }
[ "private", "String", "getNotes", "(", "List", "<", "MapRow", ">", "rows", ")", "{", "String", "result", "=", "null", ";", "if", "(", "rows", "!=", "null", "&&", "!", "rows", ".", "isEmpty", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "MapRow", "row", ":", "rows", ")", "{", "sb", ".", "append", "(", "row", ".", "getString", "(", "\"TITLE\"", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "row", ".", "getString", "(", "\"TEXT\"", ")", ")", ";", "sb", ".", "append", "(", "\"\\n\\n\"", ")", ";", "}", "result", "=", "sb", ".", "toString", "(", ")", ";", "}", "return", "result", ";", "}" ]
Common mechanism to convert Synchro commentary recorss into notes. @param rows commentary table rows @return note text
[ "Common", "mechanism", "to", "convert", "Synchro", "commentary", "recorss", "into", "notes", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L533-L549
157,651
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.sort
private List<MapRow> sort(List<MapRow> rows, final String attribute) { Collections.sort(rows, new Comparator<MapRow>() { @Override public int compare(MapRow o1, MapRow o2) { String value1 = o1.getString(attribute); String value2 = o2.getString(attribute); return value1.compareTo(value2); } }); return rows; }
java
private List<MapRow> sort(List<MapRow> rows, final String attribute) { Collections.sort(rows, new Comparator<MapRow>() { @Override public int compare(MapRow o1, MapRow o2) { String value1 = o1.getString(attribute); String value2 = o2.getString(attribute); return value1.compareTo(value2); } }); return rows; }
[ "private", "List", "<", "MapRow", ">", "sort", "(", "List", "<", "MapRow", ">", "rows", ",", "final", "String", "attribute", ")", "{", "Collections", ".", "sort", "(", "rows", ",", "new", "Comparator", "<", "MapRow", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "MapRow", "o1", ",", "MapRow", "o2", ")", "{", "String", "value1", "=", "o1", ".", "getString", "(", "attribute", ")", ";", "String", "value2", "=", "o2", ".", "getString", "(", "attribute", ")", ";", "return", "value1", ".", "compareTo", "(", "value2", ")", ";", "}", "}", ")", ";", "return", "rows", ";", "}" ]
Sort MapRows based on a named attribute. @param rows map rows to sort @param attribute attribute to sort on @return list argument (allows method chaining)
[ "Sort", "MapRows", "based", "on", "a", "named", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L558-L570
157,652
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/SynchroReader.java
SynchroReader.updateDates
private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { Date plannedStartDate = null; Date plannedFinishDate = null; for (Task task : parentTask.getChildTasks()) { updateDates(task); plannedStartDate = DateHelper.min(plannedStartDate, task.getStart()); plannedFinishDate = DateHelper.max(plannedFinishDate, task.getFinish()); } parentTask.setStart(plannedStartDate); parentTask.setFinish(plannedFinishDate); } }
java
private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { Date plannedStartDate = null; Date plannedFinishDate = null; for (Task task : parentTask.getChildTasks()) { updateDates(task); plannedStartDate = DateHelper.min(plannedStartDate, task.getStart()); plannedFinishDate = DateHelper.max(plannedFinishDate, task.getFinish()); } parentTask.setStart(plannedStartDate); parentTask.setFinish(plannedFinishDate); } }
[ "private", "void", "updateDates", "(", "Task", "parentTask", ")", "{", "if", "(", "parentTask", ".", "hasChildTasks", "(", ")", ")", "{", "Date", "plannedStartDate", "=", "null", ";", "Date", "plannedFinishDate", "=", "null", ";", "for", "(", "Task", "task", ":", "parentTask", ".", "getChildTasks", "(", ")", ")", "{", "updateDates", "(", "task", ")", ";", "plannedStartDate", "=", "DateHelper", ".", "min", "(", "plannedStartDate", ",", "task", ".", "getStart", "(", ")", ")", ";", "plannedFinishDate", "=", "DateHelper", ".", "max", "(", "plannedFinishDate", ",", "task", ".", "getFinish", "(", ")", ")", ";", "}", "parentTask", ".", "setStart", "(", "plannedStartDate", ")", ";", "parentTask", ".", "setFinish", "(", "plannedFinishDate", ")", ";", "}", "}" ]
Recursively update parent task dates. @param parentTask parent task
[ "Recursively", "update", "parent", "task", "dates", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroReader.java#L588-L605
157,653
joniles/mpxj
src/main/java/net/sf/mpxj/common/MultiDateFormat.java
MultiDateFormat.parseNonNullDate
protected Date parseNonNullDate(String str, ParsePosition pos) { Date result = null; for (int index = 0; index < m_formats.length; index++) { result = m_formats[index].parse(str, pos); if (pos.getIndex() != 0) { break; } result = null; } return result; }
java
protected Date parseNonNullDate(String str, ParsePosition pos) { Date result = null; for (int index = 0; index < m_formats.length; index++) { result = m_formats[index].parse(str, pos); if (pos.getIndex() != 0) { break; } result = null; } return result; }
[ "protected", "Date", "parseNonNullDate", "(", "String", "str", ",", "ParsePosition", "pos", ")", "{", "Date", "result", "=", "null", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "m_formats", ".", "length", ";", "index", "++", ")", "{", "result", "=", "m_formats", "[", "index", "]", ".", "parse", "(", "str", ",", "pos", ")", ";", "if", "(", "pos", ".", "getIndex", "(", ")", "!=", "0", ")", "{", "break", ";", "}", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
We have a non-null date, try each format in turn to see if it can be parsed. @param str date to parse @param pos position at which to start parsing @return Date instance
[ "We", "have", "a", "non", "-", "null", "date", "try", "each", "format", "in", "turn", "to", "see", "if", "it", "can", "be", "parsed", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/MultiDateFormat.java#L79-L92
157,654
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectEntityWithIDContainer.java
ProjectEntityWithIDContainer.renumberIDs
public void renumberIDs() { if (!isEmpty()) { Collections.sort(this); T firstEntity = get(0); int id = NumberHelper.getInt(firstEntity.getID()); if (id != 0) { id = 1; } for (T entity : this) { entity.setID(Integer.valueOf(id++)); } } }
java
public void renumberIDs() { if (!isEmpty()) { Collections.sort(this); T firstEntity = get(0); int id = NumberHelper.getInt(firstEntity.getID()); if (id != 0) { id = 1; } for (T entity : this) { entity.setID(Integer.valueOf(id++)); } } }
[ "public", "void", "renumberIDs", "(", ")", "{", "if", "(", "!", "isEmpty", "(", ")", ")", "{", "Collections", ".", "sort", "(", "this", ")", ";", "T", "firstEntity", "=", "get", "(", "0", ")", ";", "int", "id", "=", "NumberHelper", ".", "getInt", "(", "firstEntity", ".", "getID", "(", ")", ")", ";", "if", "(", "id", "!=", "0", ")", "{", "id", "=", "1", ";", "}", "for", "(", "T", "entity", ":", "this", ")", "{", "entity", ".", "setID", "(", "Integer", ".", "valueOf", "(", "id", "++", ")", ")", ";", "}", "}", "}" ]
This method can be called to ensure that the IDs of all entities are sequential, and start from an appropriate point. If entities are added to and removed from this list, then the project is loaded into Microsoft project, if the ID values have gaps in the sequence, there will be blank rows shown.
[ "This", "method", "can", "be", "called", "to", "ensure", "that", "the", "IDs", "of", "all", "entities", "are", "sequential", "and", "start", "from", "an", "appropriate", "point", ".", "If", "entities", "are", "added", "to", "and", "removed", "from", "this", "list", "then", "the", "project", "is", "loaded", "into", "Microsoft", "project", "if", "the", "ID", "values", "have", "gaps", "in", "the", "sequence", "there", "will", "be", "blank", "rows", "shown", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectEntityWithIDContainer.java#L57-L74
157,655
joniles/mpxj
src/main/java/net/sf/mpxj/Priority.java
Priority.getInstance
public static Priority getInstance(int priority) { Priority result; if (priority >= LOWEST && priority <= DO_NOT_LEVEL && (priority % 100 == 0)) { result = VALUE[(priority / 100) - 1]; } else { result = new Priority(priority); } return (result); }
java
public static Priority getInstance(int priority) { Priority result; if (priority >= LOWEST && priority <= DO_NOT_LEVEL && (priority % 100 == 0)) { result = VALUE[(priority / 100) - 1]; } else { result = new Priority(priority); } return (result); }
[ "public", "static", "Priority", "getInstance", "(", "int", "priority", ")", "{", "Priority", "result", ";", "if", "(", "priority", ">=", "LOWEST", "&&", "priority", "<=", "DO_NOT_LEVEL", "&&", "(", "priority", "%", "100", "==", "0", ")", ")", "{", "result", "=", "VALUE", "[", "(", "priority", "/", "100", ")", "-", "1", "]", ";", "}", "else", "{", "result", "=", "new", "Priority", "(", "priority", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
This method takes an integer enumeration of a priority and returns an appropriate instance of this class. Note that unrecognised values are treated as medium priority. @param priority int version of the priority @return Priority class instance
[ "This", "method", "takes", "an", "integer", "enumeration", "of", "a", "priority", "and", "returns", "an", "appropriate", "instance", "of", "this", "class", ".", "Note", "that", "unrecognised", "values", "are", "treated", "as", "medium", "priority", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Priority.java#L61-L75
157,656
joniles/mpxj
src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java
AstaTextFileReader.processFile
private void processFile(InputStream is) throws MPXJException { try { InputStreamReader reader = new InputStreamReader(is, CharsetHelper.UTF8); Tokenizer tk = new ReaderTokenizer(reader) { @Override protected boolean startQuotedIsValid(StringBuilder buffer) { return buffer.length() == 1 && buffer.charAt(0) == '<'; } }; tk.setDelimiter(DELIMITER); ArrayList<String> columns = new ArrayList<String>(); String nextTokenPrefix = null; while (tk.getType() != Tokenizer.TT_EOF) { columns.clear(); TableDefinition table = null; while (tk.nextToken() == Tokenizer.TT_WORD) { String token = tk.getToken(); if (columns.size() == 0) { if (token.charAt(0) == '#') { int index = token.lastIndexOf(':'); if (index != -1) { String headerToken; if (token.endsWith("-") || token.endsWith("=")) { headerToken = token; token = null; } else { headerToken = token.substring(0, index); token = token.substring(index + 1); } RowHeader header = new RowHeader(headerToken); table = m_tableDefinitions.get(header.getType()); columns.add(header.getID()); } } else { if (token.charAt(0) == 0) { processFileType(token); } } } if (table != null && token != null) { if (token.startsWith("<\"") && !token.endsWith("\">")) { nextTokenPrefix = token; } else { if (nextTokenPrefix != null) { token = nextTokenPrefix + DELIMITER + token; nextTokenPrefix = null; } columns.add(token); } } } if (table != null && columns.size() > 1) { // System.out.println(table.getName() + " " + columns.size()); // ColumnDefinition[] columnDefs = table.getColumns(); // int unknownIndex = 1; // for (int xx = 0; xx < columns.size(); xx++) // { // String x = columns.get(xx); // String columnName = xx < columnDefs.length ? (columnDefs[xx] == null ? "UNKNOWN" + (unknownIndex++) : columnDefs[xx].getName()) : "?"; // System.out.println(columnName + ": " + x + ", "); // } // System.out.println(); TextFileRow row = new TextFileRow(table, columns, m_epochDateFormat); List<Row> rows = m_tables.get(table.getName()); if (rows == null) { rows = new LinkedList<Row>(); m_tables.put(table.getName(), rows); } rows.add(row); } } } catch (Exception ex) { throw new MPXJException(MPXJException.READ_ERROR, ex); } }
java
private void processFile(InputStream is) throws MPXJException { try { InputStreamReader reader = new InputStreamReader(is, CharsetHelper.UTF8); Tokenizer tk = new ReaderTokenizer(reader) { @Override protected boolean startQuotedIsValid(StringBuilder buffer) { return buffer.length() == 1 && buffer.charAt(0) == '<'; } }; tk.setDelimiter(DELIMITER); ArrayList<String> columns = new ArrayList<String>(); String nextTokenPrefix = null; while (tk.getType() != Tokenizer.TT_EOF) { columns.clear(); TableDefinition table = null; while (tk.nextToken() == Tokenizer.TT_WORD) { String token = tk.getToken(); if (columns.size() == 0) { if (token.charAt(0) == '#') { int index = token.lastIndexOf(':'); if (index != -1) { String headerToken; if (token.endsWith("-") || token.endsWith("=")) { headerToken = token; token = null; } else { headerToken = token.substring(0, index); token = token.substring(index + 1); } RowHeader header = new RowHeader(headerToken); table = m_tableDefinitions.get(header.getType()); columns.add(header.getID()); } } else { if (token.charAt(0) == 0) { processFileType(token); } } } if (table != null && token != null) { if (token.startsWith("<\"") && !token.endsWith("\">")) { nextTokenPrefix = token; } else { if (nextTokenPrefix != null) { token = nextTokenPrefix + DELIMITER + token; nextTokenPrefix = null; } columns.add(token); } } } if (table != null && columns.size() > 1) { // System.out.println(table.getName() + " " + columns.size()); // ColumnDefinition[] columnDefs = table.getColumns(); // int unknownIndex = 1; // for (int xx = 0; xx < columns.size(); xx++) // { // String x = columns.get(xx); // String columnName = xx < columnDefs.length ? (columnDefs[xx] == null ? "UNKNOWN" + (unknownIndex++) : columnDefs[xx].getName()) : "?"; // System.out.println(columnName + ": " + x + ", "); // } // System.out.println(); TextFileRow row = new TextFileRow(table, columns, m_epochDateFormat); List<Row> rows = m_tables.get(table.getName()); if (rows == null) { rows = new LinkedList<Row>(); m_tables.put(table.getName(), rows); } rows.add(row); } } } catch (Exception ex) { throw new MPXJException(MPXJException.READ_ERROR, ex); } }
[ "private", "void", "processFile", "(", "InputStream", "is", ")", "throws", "MPXJException", "{", "try", "{", "InputStreamReader", "reader", "=", "new", "InputStreamReader", "(", "is", ",", "CharsetHelper", ".", "UTF8", ")", ";", "Tokenizer", "tk", "=", "new", "ReaderTokenizer", "(", "reader", ")", "{", "@", "Override", "protected", "boolean", "startQuotedIsValid", "(", "StringBuilder", "buffer", ")", "{", "return", "buffer", ".", "length", "(", ")", "==", "1", "&&", "buffer", ".", "charAt", "(", "0", ")", "==", "'", "'", ";", "}", "}", ";", "tk", ".", "setDelimiter", "(", "DELIMITER", ")", ";", "ArrayList", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "nextTokenPrefix", "=", "null", ";", "while", "(", "tk", ".", "getType", "(", ")", "!=", "Tokenizer", ".", "TT_EOF", ")", "{", "columns", ".", "clear", "(", ")", ";", "TableDefinition", "table", "=", "null", ";", "while", "(", "tk", ".", "nextToken", "(", ")", "==", "Tokenizer", ".", "TT_WORD", ")", "{", "String", "token", "=", "tk", ".", "getToken", "(", ")", ";", "if", "(", "columns", ".", "size", "(", ")", "==", "0", ")", "{", "if", "(", "token", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "int", "index", "=", "token", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "String", "headerToken", ";", "if", "(", "token", ".", "endsWith", "(", "\"-\"", ")", "||", "token", ".", "endsWith", "(", "\"=\"", ")", ")", "{", "headerToken", "=", "token", ";", "token", "=", "null", ";", "}", "else", "{", "headerToken", "=", "token", ".", "substring", "(", "0", ",", "index", ")", ";", "token", "=", "token", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "RowHeader", "header", "=", "new", "RowHeader", "(", "headerToken", ")", ";", "table", "=", "m_tableDefinitions", ".", "get", "(", "header", ".", "getType", "(", ")", ")", ";", "columns", ".", "add", "(", "header", ".", "getID", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "token", ".", "charAt", "(", "0", ")", "==", "0", ")", "{", "processFileType", "(", "token", ")", ";", "}", "}", "}", "if", "(", "table", "!=", "null", "&&", "token", "!=", "null", ")", "{", "if", "(", "token", ".", "startsWith", "(", "\"<\\\"\"", ")", "&&", "!", "token", ".", "endsWith", "(", "\"\\\">\"", ")", ")", "{", "nextTokenPrefix", "=", "token", ";", "}", "else", "{", "if", "(", "nextTokenPrefix", "!=", "null", ")", "{", "token", "=", "nextTokenPrefix", "+", "DELIMITER", "+", "token", ";", "nextTokenPrefix", "=", "null", ";", "}", "columns", ".", "add", "(", "token", ")", ";", "}", "}", "}", "if", "(", "table", "!=", "null", "&&", "columns", ".", "size", "(", ")", ">", "1", ")", "{", "// System.out.println(table.getName() + \" \" + columns.size());", "// ColumnDefinition[] columnDefs = table.getColumns();", "// int unknownIndex = 1;", "// for (int xx = 0; xx < columns.size(); xx++)", "// {", "// String x = columns.get(xx);", "// String columnName = xx < columnDefs.length ? (columnDefs[xx] == null ? \"UNKNOWN\" + (unknownIndex++) : columnDefs[xx].getName()) : \"?\";", "// System.out.println(columnName + \": \" + x + \", \");", "// }", "// System.out.println();", "TextFileRow", "row", "=", "new", "TextFileRow", "(", "table", ",", "columns", ",", "m_epochDateFormat", ")", ";", "List", "<", "Row", ">", "rows", "=", "m_tables", ".", "get", "(", "table", ".", "getName", "(", ")", ")", ";", "if", "(", "rows", "==", "null", ")", "{", "rows", "=", "new", "LinkedList", "<", "Row", ">", "(", ")", ";", "m_tables", ".", "put", "(", "table", ".", "getName", "(", ")", ",", "rows", ")", ";", "}", "rows", ".", "add", "(", "row", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "MPXJException", "(", "MPXJException", ".", "READ_ERROR", ",", "ex", ")", ";", "}", "}" ]
Tokenizes the input file and extracts the required data. @param is input stream @throws MPXJException
[ "Tokenizes", "the", "input", "file", "and", "extracts", "the", "required", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java#L107-L213
157,657
joniles/mpxj
src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java
AstaTextFileReader.processFileType
private void processFileType(String token) throws MPXJException { String version = token.substring(2).split(" ")[0]; //System.out.println(version); Class<? extends AbstractFileFormat> fileFormatClass = FILE_VERSION_MAP.get(Integer.valueOf(version)); if (fileFormatClass == null) { throw new MPXJException("Unsupported PP file format version " + version); } try { AbstractFileFormat format = fileFormatClass.newInstance(); m_tableDefinitions = format.tableDefinitions(); m_epochDateFormat = format.epochDateFormat(); } catch (Exception ex) { throw new MPXJException("Failed to configure file format", ex); } }
java
private void processFileType(String token) throws MPXJException { String version = token.substring(2).split(" ")[0]; //System.out.println(version); Class<? extends AbstractFileFormat> fileFormatClass = FILE_VERSION_MAP.get(Integer.valueOf(version)); if (fileFormatClass == null) { throw new MPXJException("Unsupported PP file format version " + version); } try { AbstractFileFormat format = fileFormatClass.newInstance(); m_tableDefinitions = format.tableDefinitions(); m_epochDateFormat = format.epochDateFormat(); } catch (Exception ex) { throw new MPXJException("Failed to configure file format", ex); } }
[ "private", "void", "processFileType", "(", "String", "token", ")", "throws", "MPXJException", "{", "String", "version", "=", "token", ".", "substring", "(", "2", ")", ".", "split", "(", "\" \"", ")", "[", "0", "]", ";", "//System.out.println(version);", "Class", "<", "?", "extends", "AbstractFileFormat", ">", "fileFormatClass", "=", "FILE_VERSION_MAP", ".", "get", "(", "Integer", ".", "valueOf", "(", "version", ")", ")", ";", "if", "(", "fileFormatClass", "==", "null", ")", "{", "throw", "new", "MPXJException", "(", "\"Unsupported PP file format version \"", "+", "version", ")", ";", "}", "try", "{", "AbstractFileFormat", "format", "=", "fileFormatClass", ".", "newInstance", "(", ")", ";", "m_tableDefinitions", "=", "format", ".", "tableDefinitions", "(", ")", ";", "m_epochDateFormat", "=", "format", ".", "epochDateFormat", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "MPXJException", "(", "\"Failed to configure file format\"", ",", "ex", ")", ";", "}", "}" ]
Reads the file version and configures the expected file format. @param token token containing the file version @throws MPXJException
[ "Reads", "the", "file", "version", "and", "configures", "the", "expected", "file", "format", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java#L221-L241
157,658
joniles/mpxj
src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java
AstaTextFileReader.processCalendars
private void processCalendars() throws SQLException { List<Row> rows = getTable("EXCEPTIONN"); Map<Integer, DayType> exceptionMap = m_reader.createExceptionTypeMap(rows); rows = getTable("WORK_PATTERN"); Map<Integer, Row> workPatternMap = m_reader.createWorkPatternMap(rows); rows = new LinkedList<Row>();// getTable("WORK_PATTERN_ASSIGNMENT"); // Need to generate an example Map<Integer, List<Row>> workPatternAssignmentMap = m_reader.createWorkPatternAssignmentMap(rows); rows = getTable("EXCEPTION_ASSIGNMENT"); Map<Integer, List<Row>> exceptionAssignmentMap = m_reader.createExceptionAssignmentMap(rows); rows = getTable("TIME_ENTRY"); Map<Integer, List<Row>> timeEntryMap = m_reader.createTimeEntryMap(rows); rows = getTable("CALENDAR"); Collections.sort(rows, CALENDAR_COMPARATOR); for (Row row : rows) { m_reader.processCalendar(row, workPatternMap, workPatternAssignmentMap, exceptionAssignmentMap, timeEntryMap, exceptionMap); } // // Update unique counters at this point as we will be generating // resource calendars, and will need to auto generate IDs // m_reader.getProject().getProjectConfig().updateUniqueCounters(); }
java
private void processCalendars() throws SQLException { List<Row> rows = getTable("EXCEPTIONN"); Map<Integer, DayType> exceptionMap = m_reader.createExceptionTypeMap(rows); rows = getTable("WORK_PATTERN"); Map<Integer, Row> workPatternMap = m_reader.createWorkPatternMap(rows); rows = new LinkedList<Row>();// getTable("WORK_PATTERN_ASSIGNMENT"); // Need to generate an example Map<Integer, List<Row>> workPatternAssignmentMap = m_reader.createWorkPatternAssignmentMap(rows); rows = getTable("EXCEPTION_ASSIGNMENT"); Map<Integer, List<Row>> exceptionAssignmentMap = m_reader.createExceptionAssignmentMap(rows); rows = getTable("TIME_ENTRY"); Map<Integer, List<Row>> timeEntryMap = m_reader.createTimeEntryMap(rows); rows = getTable("CALENDAR"); Collections.sort(rows, CALENDAR_COMPARATOR); for (Row row : rows) { m_reader.processCalendar(row, workPatternMap, workPatternAssignmentMap, exceptionAssignmentMap, timeEntryMap, exceptionMap); } // // Update unique counters at this point as we will be generating // resource calendars, and will need to auto generate IDs // m_reader.getProject().getProjectConfig().updateUniqueCounters(); }
[ "private", "void", "processCalendars", "(", ")", "throws", "SQLException", "{", "List", "<", "Row", ">", "rows", "=", "getTable", "(", "\"EXCEPTIONN\"", ")", ";", "Map", "<", "Integer", ",", "DayType", ">", "exceptionMap", "=", "m_reader", ".", "createExceptionTypeMap", "(", "rows", ")", ";", "rows", "=", "getTable", "(", "\"WORK_PATTERN\"", ")", ";", "Map", "<", "Integer", ",", "Row", ">", "workPatternMap", "=", "m_reader", ".", "createWorkPatternMap", "(", "rows", ")", ";", "rows", "=", "new", "LinkedList", "<", "Row", ">", "(", ")", ";", "// getTable(\"WORK_PATTERN_ASSIGNMENT\"); // Need to generate an example", "Map", "<", "Integer", ",", "List", "<", "Row", ">", ">", "workPatternAssignmentMap", "=", "m_reader", ".", "createWorkPatternAssignmentMap", "(", "rows", ")", ";", "rows", "=", "getTable", "(", "\"EXCEPTION_ASSIGNMENT\"", ")", ";", "Map", "<", "Integer", ",", "List", "<", "Row", ">", ">", "exceptionAssignmentMap", "=", "m_reader", ".", "createExceptionAssignmentMap", "(", "rows", ")", ";", "rows", "=", "getTable", "(", "\"TIME_ENTRY\"", ")", ";", "Map", "<", "Integer", ",", "List", "<", "Row", ">", ">", "timeEntryMap", "=", "m_reader", ".", "createTimeEntryMap", "(", "rows", ")", ";", "rows", "=", "getTable", "(", "\"CALENDAR\"", ")", ";", "Collections", ".", "sort", "(", "rows", ",", "CALENDAR_COMPARATOR", ")", ";", "for", "(", "Row", "row", ":", "rows", ")", "{", "m_reader", ".", "processCalendar", "(", "row", ",", "workPatternMap", ",", "workPatternAssignmentMap", ",", "exceptionAssignmentMap", ",", "timeEntryMap", ",", "exceptionMap", ")", ";", "}", "//", "// Update unique counters at this point as we will be generating", "// resource calendars, and will need to auto generate IDs", "//", "m_reader", ".", "getProject", "(", ")", ".", "getProjectConfig", "(", ")", ".", "updateUniqueCounters", "(", ")", ";", "}" ]
Extract calendar data from the file. @throws SQLException
[ "Extract", "calendar", "data", "from", "the", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java#L262-L291
157,659
joniles/mpxj
src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java
AstaTextFileReader.join
private List<Row> join(List<Row> leftRows, String leftColumn, String rightTable, List<Row> rightRows, String rightColumn) { List<Row> result = new LinkedList<Row>(); RowComparator leftComparator = new RowComparator(new String[] { leftColumn }); RowComparator rightComparator = new RowComparator(new String[] { rightColumn }); Collections.sort(leftRows, leftComparator); Collections.sort(rightRows, rightComparator); ListIterator<Row> rightIterator = rightRows.listIterator(); Row rightRow = rightIterator.hasNext() ? rightIterator.next() : null; for (Row leftRow : leftRows) { Integer leftValue = leftRow.getInteger(leftColumn); boolean match = false; while (rightRow != null) { Integer rightValue = rightRow.getInteger(rightColumn); int comparison = leftValue.compareTo(rightValue); if (comparison == 0) { match = true; break; } if (comparison < 0) { if (rightIterator.hasPrevious()) { rightRow = rightIterator.previous(); } break; } rightRow = rightIterator.next(); } if (match && rightRow != null) { Map<String, Object> newMap = new HashMap<String, Object>(((MapRow) leftRow).getMap()); for (Entry<String, Object> entry : ((MapRow) rightRow).getMap().entrySet()) { String key = entry.getKey(); if (newMap.containsKey(key)) { key = rightTable + "." + key; } newMap.put(key, entry.getValue()); } result.add(new MapRow(newMap)); } } return result; }
java
private List<Row> join(List<Row> leftRows, String leftColumn, String rightTable, List<Row> rightRows, String rightColumn) { List<Row> result = new LinkedList<Row>(); RowComparator leftComparator = new RowComparator(new String[] { leftColumn }); RowComparator rightComparator = new RowComparator(new String[] { rightColumn }); Collections.sort(leftRows, leftComparator); Collections.sort(rightRows, rightComparator); ListIterator<Row> rightIterator = rightRows.listIterator(); Row rightRow = rightIterator.hasNext() ? rightIterator.next() : null; for (Row leftRow : leftRows) { Integer leftValue = leftRow.getInteger(leftColumn); boolean match = false; while (rightRow != null) { Integer rightValue = rightRow.getInteger(rightColumn); int comparison = leftValue.compareTo(rightValue); if (comparison == 0) { match = true; break; } if (comparison < 0) { if (rightIterator.hasPrevious()) { rightRow = rightIterator.previous(); } break; } rightRow = rightIterator.next(); } if (match && rightRow != null) { Map<String, Object> newMap = new HashMap<String, Object>(((MapRow) leftRow).getMap()); for (Entry<String, Object> entry : ((MapRow) rightRow).getMap().entrySet()) { String key = entry.getKey(); if (newMap.containsKey(key)) { key = rightTable + "." + key; } newMap.put(key, entry.getValue()); } result.add(new MapRow(newMap)); } } return result; }
[ "private", "List", "<", "Row", ">", "join", "(", "List", "<", "Row", ">", "leftRows", ",", "String", "leftColumn", ",", "String", "rightTable", ",", "List", "<", "Row", ">", "rightRows", ",", "String", "rightColumn", ")", "{", "List", "<", "Row", ">", "result", "=", "new", "LinkedList", "<", "Row", ">", "(", ")", ";", "RowComparator", "leftComparator", "=", "new", "RowComparator", "(", "new", "String", "[", "]", "{", "leftColumn", "}", ")", ";", "RowComparator", "rightComparator", "=", "new", "RowComparator", "(", "new", "String", "[", "]", "{", "rightColumn", "}", ")", ";", "Collections", ".", "sort", "(", "leftRows", ",", "leftComparator", ")", ";", "Collections", ".", "sort", "(", "rightRows", ",", "rightComparator", ")", ";", "ListIterator", "<", "Row", ">", "rightIterator", "=", "rightRows", ".", "listIterator", "(", ")", ";", "Row", "rightRow", "=", "rightIterator", ".", "hasNext", "(", ")", "?", "rightIterator", ".", "next", "(", ")", ":", "null", ";", "for", "(", "Row", "leftRow", ":", "leftRows", ")", "{", "Integer", "leftValue", "=", "leftRow", ".", "getInteger", "(", "leftColumn", ")", ";", "boolean", "match", "=", "false", ";", "while", "(", "rightRow", "!=", "null", ")", "{", "Integer", "rightValue", "=", "rightRow", ".", "getInteger", "(", "rightColumn", ")", ";", "int", "comparison", "=", "leftValue", ".", "compareTo", "(", "rightValue", ")", ";", "if", "(", "comparison", "==", "0", ")", "{", "match", "=", "true", ";", "break", ";", "}", "if", "(", "comparison", "<", "0", ")", "{", "if", "(", "rightIterator", ".", "hasPrevious", "(", ")", ")", "{", "rightRow", "=", "rightIterator", ".", "previous", "(", ")", ";", "}", "break", ";", "}", "rightRow", "=", "rightIterator", ".", "next", "(", ")", ";", "}", "if", "(", "match", "&&", "rightRow", "!=", "null", ")", "{", "Map", "<", "String", ",", "Object", ">", "newMap", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", "(", "(", "MapRow", ")", "leftRow", ")", ".", "getMap", "(", ")", ")", ";", "for", "(", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "(", "(", "MapRow", ")", "rightRow", ")", ".", "getMap", "(", ")", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "if", "(", "newMap", ".", "containsKey", "(", "key", ")", ")", "{", "key", "=", "rightTable", "+", "\".\"", "+", "key", ";", "}", "newMap", ".", "put", "(", "key", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "result", ".", "add", "(", "new", "MapRow", "(", "newMap", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Very basic implementation of an inner join between two result sets. @param leftRows left result set @param leftColumn left foreign key column @param rightTable right table name @param rightRows right result set @param rightColumn right primary key column @return joined result set
[ "Very", "basic", "implementation", "of", "an", "inner", "join", "between", "two", "result", "sets", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java#L361-L425
157,660
joniles/mpxj
src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java
AstaTextFileReader.getTable
private List<Row> getTable(String name) { List<Row> result = m_tables.get(name); if (result == null) { result = Collections.emptyList(); } return result; }
java
private List<Row> getTable(String name) { List<Row> result = m_tables.get(name); if (result == null) { result = Collections.emptyList(); } return result; }
[ "private", "List", "<", "Row", ">", "getTable", "(", "String", "name", ")", "{", "List", "<", "Row", ">", "result", "=", "m_tables", ".", "get", "(", "name", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "result", ";", "}" ]
Retrieve table data, return an empty result set if no table data is present. @param name table name @return table data
[ "Retrieve", "table", "data", "return", "an", "empty", "result", "set", "if", "no", "table", "data", "is", "present", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaTextFileReader.java#L433-L441
157,661
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readProjectProperties
private void readProjectProperties(Project ganttProject) { ProjectProperties mpxjProperties = m_projectFile.getProjectProperties(); mpxjProperties.setName(ganttProject.getName()); mpxjProperties.setCompany(ganttProject.getCompany()); mpxjProperties.setDefaultDurationUnits(TimeUnit.DAYS); String locale = ganttProject.getLocale(); if (locale == null) { locale = "en_US"; } m_localeDateFormat = DateFormat.getDateInstance(DateFormat.SHORT, new Locale(locale)); }
java
private void readProjectProperties(Project ganttProject) { ProjectProperties mpxjProperties = m_projectFile.getProjectProperties(); mpxjProperties.setName(ganttProject.getName()); mpxjProperties.setCompany(ganttProject.getCompany()); mpxjProperties.setDefaultDurationUnits(TimeUnit.DAYS); String locale = ganttProject.getLocale(); if (locale == null) { locale = "en_US"; } m_localeDateFormat = DateFormat.getDateInstance(DateFormat.SHORT, new Locale(locale)); }
[ "private", "void", "readProjectProperties", "(", "Project", "ganttProject", ")", "{", "ProjectProperties", "mpxjProperties", "=", "m_projectFile", ".", "getProjectProperties", "(", ")", ";", "mpxjProperties", ".", "setName", "(", "ganttProject", ".", "getName", "(", ")", ")", ";", "mpxjProperties", ".", "setCompany", "(", "ganttProject", ".", "getCompany", "(", ")", ")", ";", "mpxjProperties", ".", "setDefaultDurationUnits", "(", "TimeUnit", ".", "DAYS", ")", ";", "String", "locale", "=", "ganttProject", ".", "getLocale", "(", ")", ";", "if", "(", "locale", "==", "null", ")", "{", "locale", "=", "\"en_US\"", ";", "}", "m_localeDateFormat", "=", "DateFormat", ".", "getDateInstance", "(", "DateFormat", ".", "SHORT", ",", "new", "Locale", "(", "locale", ")", ")", ";", "}" ]
This method extracts project properties from a GanttProject file. @param ganttProject GanttProject file
[ "This", "method", "extracts", "project", "properties", "from", "a", "GanttProject", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L202-L215
157,662
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readCalendars
private void readCalendars(Project ganttProject) { m_mpxjCalendar = m_projectFile.addCalendar(); m_mpxjCalendar.setName(ProjectCalendar.DEFAULT_BASE_CALENDAR_NAME); Calendars gpCalendar = ganttProject.getCalendars(); setWorkingDays(m_mpxjCalendar, gpCalendar); setExceptions(m_mpxjCalendar, gpCalendar); m_eventManager.fireCalendarReadEvent(m_mpxjCalendar); }
java
private void readCalendars(Project ganttProject) { m_mpxjCalendar = m_projectFile.addCalendar(); m_mpxjCalendar.setName(ProjectCalendar.DEFAULT_BASE_CALENDAR_NAME); Calendars gpCalendar = ganttProject.getCalendars(); setWorkingDays(m_mpxjCalendar, gpCalendar); setExceptions(m_mpxjCalendar, gpCalendar); m_eventManager.fireCalendarReadEvent(m_mpxjCalendar); }
[ "private", "void", "readCalendars", "(", "Project", "ganttProject", ")", "{", "m_mpxjCalendar", "=", "m_projectFile", ".", "addCalendar", "(", ")", ";", "m_mpxjCalendar", ".", "setName", "(", "ProjectCalendar", ".", "DEFAULT_BASE_CALENDAR_NAME", ")", ";", "Calendars", "gpCalendar", "=", "ganttProject", ".", "getCalendars", "(", ")", ";", "setWorkingDays", "(", "m_mpxjCalendar", ",", "gpCalendar", ")", ";", "setExceptions", "(", "m_mpxjCalendar", ",", "gpCalendar", ")", ";", "m_eventManager", ".", "fireCalendarReadEvent", "(", "m_mpxjCalendar", ")", ";", "}" ]
This method extracts calendar data from a GanttProject file. @param ganttProject Root node of the GanttProject file
[ "This", "method", "extracts", "calendar", "data", "from", "a", "GanttProject", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L222-L231
157,663
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.setWorkingDays
private void setWorkingDays(ProjectCalendar mpxjCalendar, Calendars gpCalendar) { DayTypes dayTypes = gpCalendar.getDayTypes(); DefaultWeek defaultWeek = dayTypes.getDefaultWeek(); if (defaultWeek == null) { mpxjCalendar.setWorkingDay(Day.SUNDAY, false); mpxjCalendar.setWorkingDay(Day.MONDAY, true); mpxjCalendar.setWorkingDay(Day.TUESDAY, true); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, true); mpxjCalendar.setWorkingDay(Day.THURSDAY, true); mpxjCalendar.setWorkingDay(Day.FRIDAY, true); mpxjCalendar.setWorkingDay(Day.SATURDAY, false); } else { mpxjCalendar.setWorkingDay(Day.MONDAY, isWorkingDay(defaultWeek.getMon())); mpxjCalendar.setWorkingDay(Day.TUESDAY, isWorkingDay(defaultWeek.getTue())); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, isWorkingDay(defaultWeek.getWed())); mpxjCalendar.setWorkingDay(Day.THURSDAY, isWorkingDay(defaultWeek.getThu())); mpxjCalendar.setWorkingDay(Day.FRIDAY, isWorkingDay(defaultWeek.getFri())); mpxjCalendar.setWorkingDay(Day.SATURDAY, isWorkingDay(defaultWeek.getSat())); mpxjCalendar.setWorkingDay(Day.SUNDAY, isWorkingDay(defaultWeek.getSun())); } for (Day day : Day.values()) { if (mpxjCalendar.isWorkingDay(day)) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }
java
private void setWorkingDays(ProjectCalendar mpxjCalendar, Calendars gpCalendar) { DayTypes dayTypes = gpCalendar.getDayTypes(); DefaultWeek defaultWeek = dayTypes.getDefaultWeek(); if (defaultWeek == null) { mpxjCalendar.setWorkingDay(Day.SUNDAY, false); mpxjCalendar.setWorkingDay(Day.MONDAY, true); mpxjCalendar.setWorkingDay(Day.TUESDAY, true); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, true); mpxjCalendar.setWorkingDay(Day.THURSDAY, true); mpxjCalendar.setWorkingDay(Day.FRIDAY, true); mpxjCalendar.setWorkingDay(Day.SATURDAY, false); } else { mpxjCalendar.setWorkingDay(Day.MONDAY, isWorkingDay(defaultWeek.getMon())); mpxjCalendar.setWorkingDay(Day.TUESDAY, isWorkingDay(defaultWeek.getTue())); mpxjCalendar.setWorkingDay(Day.WEDNESDAY, isWorkingDay(defaultWeek.getWed())); mpxjCalendar.setWorkingDay(Day.THURSDAY, isWorkingDay(defaultWeek.getThu())); mpxjCalendar.setWorkingDay(Day.FRIDAY, isWorkingDay(defaultWeek.getFri())); mpxjCalendar.setWorkingDay(Day.SATURDAY, isWorkingDay(defaultWeek.getSat())); mpxjCalendar.setWorkingDay(Day.SUNDAY, isWorkingDay(defaultWeek.getSun())); } for (Day day : Day.values()) { if (mpxjCalendar.isWorkingDay(day)) { ProjectCalendarHours hours = mpxjCalendar.addCalendarHours(day); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }
[ "private", "void", "setWorkingDays", "(", "ProjectCalendar", "mpxjCalendar", ",", "Calendars", "gpCalendar", ")", "{", "DayTypes", "dayTypes", "=", "gpCalendar", ".", "getDayTypes", "(", ")", ";", "DefaultWeek", "defaultWeek", "=", "dayTypes", ".", "getDefaultWeek", "(", ")", ";", "if", "(", "defaultWeek", "==", "null", ")", "{", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "SUNDAY", ",", "false", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "MONDAY", ",", "true", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "TUESDAY", ",", "true", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "WEDNESDAY", ",", "true", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "THURSDAY", ",", "true", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "FRIDAY", ",", "true", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "SATURDAY", ",", "false", ")", ";", "}", "else", "{", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "MONDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getMon", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "TUESDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getTue", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "WEDNESDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getWed", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "THURSDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getThu", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "FRIDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getFri", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "SATURDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getSat", "(", ")", ")", ")", ";", "mpxjCalendar", ".", "setWorkingDay", "(", "Day", ".", "SUNDAY", ",", "isWorkingDay", "(", "defaultWeek", ".", "getSun", "(", ")", ")", ")", ";", "}", "for", "(", "Day", "day", ":", "Day", ".", "values", "(", ")", ")", "{", "if", "(", "mpxjCalendar", ".", "isWorkingDay", "(", "day", ")", ")", "{", "ProjectCalendarHours", "hours", "=", "mpxjCalendar", ".", "addCalendarHours", "(", "day", ")", ";", "hours", ".", "addRange", "(", "ProjectCalendarWeek", ".", "DEFAULT_WORKING_MORNING", ")", ";", "hours", ".", "addRange", "(", "ProjectCalendarWeek", ".", "DEFAULT_WORKING_AFTERNOON", ")", ";", "}", "}", "}" ]
Add working days and working time to a calendar. @param mpxjCalendar MPXJ calendar @param gpCalendar GanttProject calendar
[ "Add", "working", "days", "and", "working", "time", "to", "a", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L239-L273
157,664
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.setExceptions
private void setExceptions(ProjectCalendar mpxjCalendar, Calendars gpCalendar) { List<net.sf.mpxj.ganttproject.schema.Date> dates = gpCalendar.getDate(); for (net.sf.mpxj.ganttproject.schema.Date date : dates) { addException(mpxjCalendar, date); } }
java
private void setExceptions(ProjectCalendar mpxjCalendar, Calendars gpCalendar) { List<net.sf.mpxj.ganttproject.schema.Date> dates = gpCalendar.getDate(); for (net.sf.mpxj.ganttproject.schema.Date date : dates) { addException(mpxjCalendar, date); } }
[ "private", "void", "setExceptions", "(", "ProjectCalendar", "mpxjCalendar", ",", "Calendars", "gpCalendar", ")", "{", "List", "<", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Date", ">", "dates", "=", "gpCalendar", ".", "getDate", "(", ")", ";", "for", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Date", "date", ":", "dates", ")", "{", "addException", "(", "mpxjCalendar", ",", "date", ")", ";", "}", "}" ]
Add exceptions to the calendar. @param mpxjCalendar MPXJ calendar @param gpCalendar GanttProject calendar
[ "Add", "exceptions", "to", "the", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L292-L299
157,665
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.addException
private void addException(ProjectCalendar mpxjCalendar, net.sf.mpxj.ganttproject.schema.Date date) { String year = date.getYear(); if (year == null || year.isEmpty()) { // In order to process recurring exceptions using MPXJ, we need a start and end date // to constrain the number of dates we generate. // May need to pre-process the tasks in order to calculate a start and finish date. // TODO: handle recurring exceptions } else { Calendar calendar = DateHelper.popCalendar(); calendar.set(Calendar.YEAR, Integer.parseInt(year)); calendar.set(Calendar.MONTH, NumberHelper.getInt(date.getMonth())); calendar.set(Calendar.DAY_OF_MONTH, NumberHelper.getInt(date.getDate())); Date exceptionDate = calendar.getTime(); DateHelper.pushCalendar(calendar); ProjectCalendarException exception = mpxjCalendar.addCalendarException(exceptionDate, exceptionDate); // TODO: not sure how NEUTRAL should be handled if ("WORKING_DAY".equals(date.getType())) { exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }
java
private void addException(ProjectCalendar mpxjCalendar, net.sf.mpxj.ganttproject.schema.Date date) { String year = date.getYear(); if (year == null || year.isEmpty()) { // In order to process recurring exceptions using MPXJ, we need a start and end date // to constrain the number of dates we generate. // May need to pre-process the tasks in order to calculate a start and finish date. // TODO: handle recurring exceptions } else { Calendar calendar = DateHelper.popCalendar(); calendar.set(Calendar.YEAR, Integer.parseInt(year)); calendar.set(Calendar.MONTH, NumberHelper.getInt(date.getMonth())); calendar.set(Calendar.DAY_OF_MONTH, NumberHelper.getInt(date.getDate())); Date exceptionDate = calendar.getTime(); DateHelper.pushCalendar(calendar); ProjectCalendarException exception = mpxjCalendar.addCalendarException(exceptionDate, exceptionDate); // TODO: not sure how NEUTRAL should be handled if ("WORKING_DAY".equals(date.getType())) { exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING); exception.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON); } } }
[ "private", "void", "addException", "(", "ProjectCalendar", "mpxjCalendar", ",", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Date", "date", ")", "{", "String", "year", "=", "date", ".", "getYear", "(", ")", ";", "if", "(", "year", "==", "null", "||", "year", ".", "isEmpty", "(", ")", ")", "{", "// In order to process recurring exceptions using MPXJ, we need a start and end date", "// to constrain the number of dates we generate.", "// May need to pre-process the tasks in order to calculate a start and finish date.", "// TODO: handle recurring exceptions", "}", "else", "{", "Calendar", "calendar", "=", "DateHelper", ".", "popCalendar", "(", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "YEAR", ",", "Integer", ".", "parseInt", "(", "year", ")", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "MONTH", ",", "NumberHelper", ".", "getInt", "(", "date", ".", "getMonth", "(", ")", ")", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "NumberHelper", ".", "getInt", "(", "date", ".", "getDate", "(", ")", ")", ")", ";", "Date", "exceptionDate", "=", "calendar", ".", "getTime", "(", ")", ";", "DateHelper", ".", "pushCalendar", "(", "calendar", ")", ";", "ProjectCalendarException", "exception", "=", "mpxjCalendar", ".", "addCalendarException", "(", "exceptionDate", ",", "exceptionDate", ")", ";", "// TODO: not sure how NEUTRAL should be handled", "if", "(", "\"WORKING_DAY\"", ".", "equals", "(", "date", ".", "getType", "(", ")", ")", ")", "{", "exception", ".", "addRange", "(", "ProjectCalendarWeek", ".", "DEFAULT_WORKING_MORNING", ")", ";", "exception", ".", "addRange", "(", "ProjectCalendarWeek", ".", "DEFAULT_WORKING_AFTERNOON", ")", ";", "}", "}", "}" ]
Add a single exception to a calendar. @param mpxjCalendar MPXJ calendar @param date calendar exception
[ "Add", "a", "single", "exception", "to", "a", "calendar", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L307-L334
157,666
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResources
private void readResources(Project ganttProject) { Resources resources = ganttProject.getResources(); readResourceCustomPropertyDefinitions(resources); readRoleDefinitions(ganttProject); for (net.sf.mpxj.ganttproject.schema.Resource gpResource : resources.getResource()) { readResource(gpResource); } }
java
private void readResources(Project ganttProject) { Resources resources = ganttProject.getResources(); readResourceCustomPropertyDefinitions(resources); readRoleDefinitions(ganttProject); for (net.sf.mpxj.ganttproject.schema.Resource gpResource : resources.getResource()) { readResource(gpResource); } }
[ "private", "void", "readResources", "(", "Project", "ganttProject", ")", "{", "Resources", "resources", "=", "ganttProject", ".", "getResources", "(", ")", ";", "readResourceCustomPropertyDefinitions", "(", "resources", ")", ";", "readRoleDefinitions", "(", "ganttProject", ")", ";", "for", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Resource", "gpResource", ":", "resources", ".", "getResource", "(", ")", ")", "{", "readResource", "(", "gpResource", ")", ";", "}", "}" ]
This method extracts resource data from a GanttProject file. @param ganttProject parent node for resources
[ "This", "method", "extracts", "resource", "data", "from", "a", "GanttProject", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L341-L351
157,667
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResourceCustomPropertyDefinitions
private void readResourceCustomPropertyDefinitions(Resources gpResources) { CustomField field = m_projectFile.getCustomFields().getCustomField(ResourceField.TEXT1); field.setAlias("Phone"); for (CustomPropertyDefinition definition : gpResources.getCustomPropertyDefinition()) { // // Find the next available field of the correct type. // String type = definition.getType(); FieldType fieldType = RESOURCE_PROPERTY_TYPES.get(type).getField(); // // If we have run out of fields of the right type, try using a text field. // if (fieldType == null) { fieldType = RESOURCE_PROPERTY_TYPES.get("text").getField(); } // // If we actually have a field available, set the alias to match // the name used in GanttProject. // if (fieldType != null) { field = m_projectFile.getCustomFields().getCustomField(fieldType); field.setAlias(definition.getName()); String defaultValue = definition.getDefaultValue(); if (defaultValue != null && defaultValue.isEmpty()) { defaultValue = null; } m_resourcePropertyDefinitions.put(definition.getId(), new Pair<FieldType, String>(fieldType, defaultValue)); } } }
java
private void readResourceCustomPropertyDefinitions(Resources gpResources) { CustomField field = m_projectFile.getCustomFields().getCustomField(ResourceField.TEXT1); field.setAlias("Phone"); for (CustomPropertyDefinition definition : gpResources.getCustomPropertyDefinition()) { // // Find the next available field of the correct type. // String type = definition.getType(); FieldType fieldType = RESOURCE_PROPERTY_TYPES.get(type).getField(); // // If we have run out of fields of the right type, try using a text field. // if (fieldType == null) { fieldType = RESOURCE_PROPERTY_TYPES.get("text").getField(); } // // If we actually have a field available, set the alias to match // the name used in GanttProject. // if (fieldType != null) { field = m_projectFile.getCustomFields().getCustomField(fieldType); field.setAlias(definition.getName()); String defaultValue = definition.getDefaultValue(); if (defaultValue != null && defaultValue.isEmpty()) { defaultValue = null; } m_resourcePropertyDefinitions.put(definition.getId(), new Pair<FieldType, String>(fieldType, defaultValue)); } } }
[ "private", "void", "readResourceCustomPropertyDefinitions", "(", "Resources", "gpResources", ")", "{", "CustomField", "field", "=", "m_projectFile", ".", "getCustomFields", "(", ")", ".", "getCustomField", "(", "ResourceField", ".", "TEXT1", ")", ";", "field", ".", "setAlias", "(", "\"Phone\"", ")", ";", "for", "(", "CustomPropertyDefinition", "definition", ":", "gpResources", ".", "getCustomPropertyDefinition", "(", ")", ")", "{", "//", "// Find the next available field of the correct type.", "//", "String", "type", "=", "definition", ".", "getType", "(", ")", ";", "FieldType", "fieldType", "=", "RESOURCE_PROPERTY_TYPES", ".", "get", "(", "type", ")", ".", "getField", "(", ")", ";", "//", "// If we have run out of fields of the right type, try using a text field.", "//", "if", "(", "fieldType", "==", "null", ")", "{", "fieldType", "=", "RESOURCE_PROPERTY_TYPES", ".", "get", "(", "\"text\"", ")", ".", "getField", "(", ")", ";", "}", "//", "// If we actually have a field available, set the alias to match", "// the name used in GanttProject.", "//", "if", "(", "fieldType", "!=", "null", ")", "{", "field", "=", "m_projectFile", ".", "getCustomFields", "(", ")", ".", "getCustomField", "(", "fieldType", ")", ";", "field", ".", "setAlias", "(", "definition", ".", "getName", "(", ")", ")", ";", "String", "defaultValue", "=", "definition", ".", "getDefaultValue", "(", ")", ";", "if", "(", "defaultValue", "!=", "null", "&&", "defaultValue", ".", "isEmpty", "(", ")", ")", "{", "defaultValue", "=", "null", ";", "}", "m_resourcePropertyDefinitions", ".", "put", "(", "definition", ".", "getId", "(", ")", ",", "new", "Pair", "<", "FieldType", ",", "String", ">", "(", "fieldType", ",", "defaultValue", ")", ")", ";", "}", "}", "}" ]
Read custom property definitions for resources. @param gpResources GanttProject resources
[ "Read", "custom", "property", "definitions", "for", "resources", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L358-L395
157,668
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readTaskCustomPropertyDefinitions
private void readTaskCustomPropertyDefinitions(Tasks gpTasks) { for (Taskproperty definition : gpTasks.getTaskproperties().getTaskproperty()) { // // Ignore everything but custom values // if (!"custom".equals(definition.getType())) { continue; } // // Find the next available field of the correct type. // String type = definition.getValuetype(); FieldType fieldType = TASK_PROPERTY_TYPES.get(type).getField(); // // If we have run out of fields of the right type, try using a text field. // if (fieldType == null) { fieldType = TASK_PROPERTY_TYPES.get("text").getField(); } // // If we actually have a field available, set the alias to match // the name used in GanttProject. // if (fieldType != null) { CustomField field = m_projectFile.getCustomFields().getCustomField(fieldType); field.setAlias(definition.getName()); String defaultValue = definition.getDefaultvalue(); if (defaultValue != null && defaultValue.isEmpty()) { defaultValue = null; } m_taskPropertyDefinitions.put(definition.getId(), new Pair<FieldType, String>(fieldType, defaultValue)); } } }
java
private void readTaskCustomPropertyDefinitions(Tasks gpTasks) { for (Taskproperty definition : gpTasks.getTaskproperties().getTaskproperty()) { // // Ignore everything but custom values // if (!"custom".equals(definition.getType())) { continue; } // // Find the next available field of the correct type. // String type = definition.getValuetype(); FieldType fieldType = TASK_PROPERTY_TYPES.get(type).getField(); // // If we have run out of fields of the right type, try using a text field. // if (fieldType == null) { fieldType = TASK_PROPERTY_TYPES.get("text").getField(); } // // If we actually have a field available, set the alias to match // the name used in GanttProject. // if (fieldType != null) { CustomField field = m_projectFile.getCustomFields().getCustomField(fieldType); field.setAlias(definition.getName()); String defaultValue = definition.getDefaultvalue(); if (defaultValue != null && defaultValue.isEmpty()) { defaultValue = null; } m_taskPropertyDefinitions.put(definition.getId(), new Pair<FieldType, String>(fieldType, defaultValue)); } } }
[ "private", "void", "readTaskCustomPropertyDefinitions", "(", "Tasks", "gpTasks", ")", "{", "for", "(", "Taskproperty", "definition", ":", "gpTasks", ".", "getTaskproperties", "(", ")", ".", "getTaskproperty", "(", ")", ")", "{", "//", "// Ignore everything but custom values", "//", "if", "(", "!", "\"custom\"", ".", "equals", "(", "definition", ".", "getType", "(", ")", ")", ")", "{", "continue", ";", "}", "//", "// Find the next available field of the correct type.", "//", "String", "type", "=", "definition", ".", "getValuetype", "(", ")", ";", "FieldType", "fieldType", "=", "TASK_PROPERTY_TYPES", ".", "get", "(", "type", ")", ".", "getField", "(", ")", ";", "//", "// If we have run out of fields of the right type, try using a text field.", "//", "if", "(", "fieldType", "==", "null", ")", "{", "fieldType", "=", "TASK_PROPERTY_TYPES", ".", "get", "(", "\"text\"", ")", ".", "getField", "(", ")", ";", "}", "//", "// If we actually have a field available, set the alias to match", "// the name used in GanttProject.", "//", "if", "(", "fieldType", "!=", "null", ")", "{", "CustomField", "field", "=", "m_projectFile", ".", "getCustomFields", "(", ")", ".", "getCustomField", "(", "fieldType", ")", ";", "field", ".", "setAlias", "(", "definition", ".", "getName", "(", ")", ")", ";", "String", "defaultValue", "=", "definition", ".", "getDefaultvalue", "(", ")", ";", "if", "(", "defaultValue", "!=", "null", "&&", "defaultValue", ".", "isEmpty", "(", ")", ")", "{", "defaultValue", "=", "null", ";", "}", "m_taskPropertyDefinitions", ".", "put", "(", "definition", ".", "getId", "(", ")", ",", "new", "Pair", "<", "FieldType", ",", "String", ">", "(", "fieldType", ",", "defaultValue", ")", ")", ";", "}", "}", "}" ]
Read custom property definitions for tasks. @param gpTasks GanttProject tasks
[ "Read", "custom", "property", "definitions", "for", "tasks", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L402-L444
157,669
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readRoleDefinitions
private void readRoleDefinitions(Project gpProject) { m_roleDefinitions.put("Default:1", "project manager"); for (Roles roles : gpProject.getRoles()) { if ("Default".equals(roles.getRolesetName())) { continue; } for (Role role : roles.getRole()) { m_roleDefinitions.put(role.getId(), role.getName()); } } }
java
private void readRoleDefinitions(Project gpProject) { m_roleDefinitions.put("Default:1", "project manager"); for (Roles roles : gpProject.getRoles()) { if ("Default".equals(roles.getRolesetName())) { continue; } for (Role role : roles.getRole()) { m_roleDefinitions.put(role.getId(), role.getName()); } } }
[ "private", "void", "readRoleDefinitions", "(", "Project", "gpProject", ")", "{", "m_roleDefinitions", ".", "put", "(", "\"Default:1\"", ",", "\"project manager\"", ")", ";", "for", "(", "Roles", "roles", ":", "gpProject", ".", "getRoles", "(", ")", ")", "{", "if", "(", "\"Default\"", ".", "equals", "(", "roles", ".", "getRolesetName", "(", ")", ")", ")", "{", "continue", ";", "}", "for", "(", "Role", "role", ":", "roles", ".", "getRole", "(", ")", ")", "{", "m_roleDefinitions", ".", "put", "(", "role", ".", "getId", "(", ")", ",", "role", ".", "getName", "(", ")", ")", ";", "}", "}", "}" ]
Read the role definitions from a GanttProject project. @param gpProject GanttProject project
[ "Read", "the", "role", "definitions", "from", "a", "GanttProject", "project", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L451-L467
157,670
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResource
private void readResource(net.sf.mpxj.ganttproject.schema.Resource gpResource) { Resource mpxjResource = m_projectFile.addResource(); mpxjResource.setUniqueID(Integer.valueOf(NumberHelper.getInt(gpResource.getId()) + 1)); mpxjResource.setName(gpResource.getName()); mpxjResource.setEmailAddress(gpResource.getContacts()); mpxjResource.setText(1, gpResource.getPhone()); mpxjResource.setGroup(m_roleDefinitions.get(gpResource.getFunction())); net.sf.mpxj.ganttproject.schema.Rate gpRate = gpResource.getRate(); if (gpRate != null) { mpxjResource.setStandardRate(new Rate(gpRate.getValueAttribute(), TimeUnit.DAYS)); } readResourceCustomFields(gpResource, mpxjResource); m_eventManager.fireResourceReadEvent(mpxjResource); }
java
private void readResource(net.sf.mpxj.ganttproject.schema.Resource gpResource) { Resource mpxjResource = m_projectFile.addResource(); mpxjResource.setUniqueID(Integer.valueOf(NumberHelper.getInt(gpResource.getId()) + 1)); mpxjResource.setName(gpResource.getName()); mpxjResource.setEmailAddress(gpResource.getContacts()); mpxjResource.setText(1, gpResource.getPhone()); mpxjResource.setGroup(m_roleDefinitions.get(gpResource.getFunction())); net.sf.mpxj.ganttproject.schema.Rate gpRate = gpResource.getRate(); if (gpRate != null) { mpxjResource.setStandardRate(new Rate(gpRate.getValueAttribute(), TimeUnit.DAYS)); } readResourceCustomFields(gpResource, mpxjResource); m_eventManager.fireResourceReadEvent(mpxjResource); }
[ "private", "void", "readResource", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Resource", "gpResource", ")", "{", "Resource", "mpxjResource", "=", "m_projectFile", ".", "addResource", "(", ")", ";", "mpxjResource", ".", "setUniqueID", "(", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "gpResource", ".", "getId", "(", ")", ")", "+", "1", ")", ")", ";", "mpxjResource", ".", "setName", "(", "gpResource", ".", "getName", "(", ")", ")", ";", "mpxjResource", ".", "setEmailAddress", "(", "gpResource", ".", "getContacts", "(", ")", ")", ";", "mpxjResource", ".", "setText", "(", "1", ",", "gpResource", ".", "getPhone", "(", ")", ")", ";", "mpxjResource", ".", "setGroup", "(", "m_roleDefinitions", ".", "get", "(", "gpResource", ".", "getFunction", "(", ")", ")", ")", ";", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Rate", "gpRate", "=", "gpResource", ".", "getRate", "(", ")", ";", "if", "(", "gpRate", "!=", "null", ")", "{", "mpxjResource", ".", "setStandardRate", "(", "new", "Rate", "(", "gpRate", ".", "getValueAttribute", "(", ")", ",", "TimeUnit", ".", "DAYS", ")", ")", ";", "}", "readResourceCustomFields", "(", "gpResource", ",", "mpxjResource", ")", ";", "m_eventManager", ".", "fireResourceReadEvent", "(", "mpxjResource", ")", ";", "}" ]
This method extracts data for a single resource from a GanttProject file. @param gpResource resource data
[ "This", "method", "extracts", "data", "for", "a", "single", "resource", "from", "a", "GanttProject", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L474-L490
157,671
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResourceCustomFields
private void readResourceCustomFields(net.sf.mpxj.ganttproject.schema.Resource gpResource, Resource mpxjResource) { // // Populate custom field default values // Map<FieldType, Object> customFields = new HashMap<FieldType, Object>(); for (Pair<FieldType, String> definition : m_resourcePropertyDefinitions.values()) { customFields.put(definition.getFirst(), definition.getSecond()); } // // Update with custom field actual values // for (CustomResourceProperty property : gpResource.getCustomProperty()) { Pair<FieldType, String> definition = m_resourcePropertyDefinitions.get(property.getDefinitionId()); if (definition != null) { // // Retrieve the value. If it is empty, use the default. // String value = property.getValueAttribute(); if (value.isEmpty()) { value = null; } // // If we have a value,convert it to the correct type // if (value != null) { Object result; switch (definition.getFirst().getDataType()) { case NUMERIC: { if (value.indexOf('.') == -1) { result = Integer.valueOf(value); } else { result = Double.valueOf(value); } break; } case DATE: { try { result = m_localeDateFormat.parse(value); } catch (ParseException ex) { result = null; } break; } case BOOLEAN: { result = Boolean.valueOf(value.equals("true")); break; } default: { result = value; break; } } if (result != null) { customFields.put(definition.getFirst(), result); } } } } for (Map.Entry<FieldType, Object> item : customFields.entrySet()) { if (item.getValue() != null) { mpxjResource.set(item.getKey(), item.getValue()); } } }
java
private void readResourceCustomFields(net.sf.mpxj.ganttproject.schema.Resource gpResource, Resource mpxjResource) { // // Populate custom field default values // Map<FieldType, Object> customFields = new HashMap<FieldType, Object>(); for (Pair<FieldType, String> definition : m_resourcePropertyDefinitions.values()) { customFields.put(definition.getFirst(), definition.getSecond()); } // // Update with custom field actual values // for (CustomResourceProperty property : gpResource.getCustomProperty()) { Pair<FieldType, String> definition = m_resourcePropertyDefinitions.get(property.getDefinitionId()); if (definition != null) { // // Retrieve the value. If it is empty, use the default. // String value = property.getValueAttribute(); if (value.isEmpty()) { value = null; } // // If we have a value,convert it to the correct type // if (value != null) { Object result; switch (definition.getFirst().getDataType()) { case NUMERIC: { if (value.indexOf('.') == -1) { result = Integer.valueOf(value); } else { result = Double.valueOf(value); } break; } case DATE: { try { result = m_localeDateFormat.parse(value); } catch (ParseException ex) { result = null; } break; } case BOOLEAN: { result = Boolean.valueOf(value.equals("true")); break; } default: { result = value; break; } } if (result != null) { customFields.put(definition.getFirst(), result); } } } } for (Map.Entry<FieldType, Object> item : customFields.entrySet()) { if (item.getValue() != null) { mpxjResource.set(item.getKey(), item.getValue()); } } }
[ "private", "void", "readResourceCustomFields", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Resource", "gpResource", ",", "Resource", "mpxjResource", ")", "{", "//", "// Populate custom field default values", "//", "Map", "<", "FieldType", ",", "Object", ">", "customFields", "=", "new", "HashMap", "<", "FieldType", ",", "Object", ">", "(", ")", ";", "for", "(", "Pair", "<", "FieldType", ",", "String", ">", "definition", ":", "m_resourcePropertyDefinitions", ".", "values", "(", ")", ")", "{", "customFields", ".", "put", "(", "definition", ".", "getFirst", "(", ")", ",", "definition", ".", "getSecond", "(", ")", ")", ";", "}", "//", "// Update with custom field actual values", "//", "for", "(", "CustomResourceProperty", "property", ":", "gpResource", ".", "getCustomProperty", "(", ")", ")", "{", "Pair", "<", "FieldType", ",", "String", ">", "definition", "=", "m_resourcePropertyDefinitions", ".", "get", "(", "property", ".", "getDefinitionId", "(", ")", ")", ";", "if", "(", "definition", "!=", "null", ")", "{", "//", "// Retrieve the value. If it is empty, use the default.", "//", "String", "value", "=", "property", ".", "getValueAttribute", "(", ")", ";", "if", "(", "value", ".", "isEmpty", "(", ")", ")", "{", "value", "=", "null", ";", "}", "//", "// If we have a value,convert it to the correct type", "//", "if", "(", "value", "!=", "null", ")", "{", "Object", "result", ";", "switch", "(", "definition", ".", "getFirst", "(", ")", ".", "getDataType", "(", ")", ")", "{", "case", "NUMERIC", ":", "{", "if", "(", "value", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "result", "=", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "else", "{", "result", "=", "Double", ".", "valueOf", "(", "value", ")", ";", "}", "break", ";", "}", "case", "DATE", ":", "{", "try", "{", "result", "=", "m_localeDateFormat", ".", "parse", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "result", "=", "null", ";", "}", "break", ";", "}", "case", "BOOLEAN", ":", "{", "result", "=", "Boolean", ".", "valueOf", "(", "value", ".", "equals", "(", "\"true\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "result", "=", "value", ";", "break", ";", "}", "}", "if", "(", "result", "!=", "null", ")", "{", "customFields", ".", "put", "(", "definition", ".", "getFirst", "(", ")", ",", "result", ")", ";", "}", "}", "}", "}", "for", "(", "Map", ".", "Entry", "<", "FieldType", ",", "Object", ">", "item", ":", "customFields", ".", "entrySet", "(", ")", ")", "{", "if", "(", "item", ".", "getValue", "(", ")", "!=", "null", ")", "{", "mpxjResource", ".", "set", "(", "item", ".", "getKey", "(", ")", ",", "item", ".", "getValue", "(", ")", ")", ";", "}", "}", "}" ]
Read custom fields for a GanttProject resource. @param gpResource GanttProject resource @param mpxjResource MPXJ Resource instance
[ "Read", "custom", "fields", "for", "a", "GanttProject", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L498-L589
157,672
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readTaskCustomFields
private void readTaskCustomFields(net.sf.mpxj.ganttproject.schema.Task gpTask, Task mpxjTask) { // // Populate custom field default values // Map<FieldType, Object> customFields = new HashMap<FieldType, Object>(); for (Pair<FieldType, String> definition : m_taskPropertyDefinitions.values()) { customFields.put(definition.getFirst(), definition.getSecond()); } // // Update with custom field actual values // for (CustomTaskProperty property : gpTask.getCustomproperty()) { Pair<FieldType, String> definition = m_taskPropertyDefinitions.get(property.getTaskpropertyId()); if (definition != null) { // // Retrieve the value. If it is empty, use the default. // String value = property.getValueAttribute(); if (value.isEmpty()) { value = null; } // // If we have a value,convert it to the correct type // if (value != null) { Object result; switch (definition.getFirst().getDataType()) { case NUMERIC: { if (value.indexOf('.') == -1) { result = Integer.valueOf(value); } else { result = Double.valueOf(value); } break; } case DATE: { try { result = m_dateFormat.parse(value); } catch (ParseException ex) { result = null; } break; } case BOOLEAN: { result = Boolean.valueOf(value.equals("true")); break; } default: { result = value; break; } } if (result != null) { customFields.put(definition.getFirst(), result); } } } } for (Map.Entry<FieldType, Object> item : customFields.entrySet()) { if (item.getValue() != null) { mpxjTask.set(item.getKey(), item.getValue()); } } }
java
private void readTaskCustomFields(net.sf.mpxj.ganttproject.schema.Task gpTask, Task mpxjTask) { // // Populate custom field default values // Map<FieldType, Object> customFields = new HashMap<FieldType, Object>(); for (Pair<FieldType, String> definition : m_taskPropertyDefinitions.values()) { customFields.put(definition.getFirst(), definition.getSecond()); } // // Update with custom field actual values // for (CustomTaskProperty property : gpTask.getCustomproperty()) { Pair<FieldType, String> definition = m_taskPropertyDefinitions.get(property.getTaskpropertyId()); if (definition != null) { // // Retrieve the value. If it is empty, use the default. // String value = property.getValueAttribute(); if (value.isEmpty()) { value = null; } // // If we have a value,convert it to the correct type // if (value != null) { Object result; switch (definition.getFirst().getDataType()) { case NUMERIC: { if (value.indexOf('.') == -1) { result = Integer.valueOf(value); } else { result = Double.valueOf(value); } break; } case DATE: { try { result = m_dateFormat.parse(value); } catch (ParseException ex) { result = null; } break; } case BOOLEAN: { result = Boolean.valueOf(value.equals("true")); break; } default: { result = value; break; } } if (result != null) { customFields.put(definition.getFirst(), result); } } } } for (Map.Entry<FieldType, Object> item : customFields.entrySet()) { if (item.getValue() != null) { mpxjTask.set(item.getKey(), item.getValue()); } } }
[ "private", "void", "readTaskCustomFields", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "gpTask", ",", "Task", "mpxjTask", ")", "{", "//", "// Populate custom field default values", "//", "Map", "<", "FieldType", ",", "Object", ">", "customFields", "=", "new", "HashMap", "<", "FieldType", ",", "Object", ">", "(", ")", ";", "for", "(", "Pair", "<", "FieldType", ",", "String", ">", "definition", ":", "m_taskPropertyDefinitions", ".", "values", "(", ")", ")", "{", "customFields", ".", "put", "(", "definition", ".", "getFirst", "(", ")", ",", "definition", ".", "getSecond", "(", ")", ")", ";", "}", "//", "// Update with custom field actual values", "//", "for", "(", "CustomTaskProperty", "property", ":", "gpTask", ".", "getCustomproperty", "(", ")", ")", "{", "Pair", "<", "FieldType", ",", "String", ">", "definition", "=", "m_taskPropertyDefinitions", ".", "get", "(", "property", ".", "getTaskpropertyId", "(", ")", ")", ";", "if", "(", "definition", "!=", "null", ")", "{", "//", "// Retrieve the value. If it is empty, use the default.", "//", "String", "value", "=", "property", ".", "getValueAttribute", "(", ")", ";", "if", "(", "value", ".", "isEmpty", "(", ")", ")", "{", "value", "=", "null", ";", "}", "//", "// If we have a value,convert it to the correct type", "//", "if", "(", "value", "!=", "null", ")", "{", "Object", "result", ";", "switch", "(", "definition", ".", "getFirst", "(", ")", ".", "getDataType", "(", ")", ")", "{", "case", "NUMERIC", ":", "{", "if", "(", "value", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "result", "=", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "else", "{", "result", "=", "Double", ".", "valueOf", "(", "value", ")", ";", "}", "break", ";", "}", "case", "DATE", ":", "{", "try", "{", "result", "=", "m_dateFormat", ".", "parse", "(", "value", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "result", "=", "null", ";", "}", "break", ";", "}", "case", "BOOLEAN", ":", "{", "result", "=", "Boolean", ".", "valueOf", "(", "value", ".", "equals", "(", "\"true\"", ")", ")", ";", "break", ";", "}", "default", ":", "{", "result", "=", "value", ";", "break", ";", "}", "}", "if", "(", "result", "!=", "null", ")", "{", "customFields", ".", "put", "(", "definition", ".", "getFirst", "(", ")", ",", "result", ")", ";", "}", "}", "}", "}", "for", "(", "Map", ".", "Entry", "<", "FieldType", ",", "Object", ">", "item", ":", "customFields", ".", "entrySet", "(", ")", ")", "{", "if", "(", "item", ".", "getValue", "(", ")", "!=", "null", ")", "{", "mpxjTask", ".", "set", "(", "item", ".", "getKey", "(", ")", ",", "item", ".", "getValue", "(", ")", ")", ";", "}", "}", "}" ]
Read custom fields for a GanttProject task. @param gpTask GanttProject task @param mpxjTask MPXJ Task instance
[ "Read", "custom", "fields", "for", "a", "GanttProject", "task", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L597-L688
157,673
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readTasks
private void readTasks(Project gpProject) { Tasks tasks = gpProject.getTasks(); readTaskCustomPropertyDefinitions(tasks); for (net.sf.mpxj.ganttproject.schema.Task task : tasks.getTask()) { readTask(m_projectFile, task); } }
java
private void readTasks(Project gpProject) { Tasks tasks = gpProject.getTasks(); readTaskCustomPropertyDefinitions(tasks); for (net.sf.mpxj.ganttproject.schema.Task task : tasks.getTask()) { readTask(m_projectFile, task); } }
[ "private", "void", "readTasks", "(", "Project", "gpProject", ")", "{", "Tasks", "tasks", "=", "gpProject", ".", "getTasks", "(", ")", ";", "readTaskCustomPropertyDefinitions", "(", "tasks", ")", ";", "for", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "task", ":", "tasks", ".", "getTask", "(", ")", ")", "{", "readTask", "(", "m_projectFile", ",", "task", ")", ";", "}", "}" ]
Read the top level tasks from GanttProject. @param gpProject GanttProject project
[ "Read", "the", "top", "level", "tasks", "from", "GanttProject", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L695-L703
157,674
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readTask
private void readTask(ChildTaskContainer mpxjParent, net.sf.mpxj.ganttproject.schema.Task gpTask) { Task mpxjTask = mpxjParent.addTask(); mpxjTask.setUniqueID(Integer.valueOf(NumberHelper.getInt(gpTask.getId()) + 1)); mpxjTask.setName(gpTask.getName()); mpxjTask.setPercentageComplete(gpTask.getComplete()); mpxjTask.setPriority(getPriority(gpTask.getPriority())); mpxjTask.setHyperlink(gpTask.getWebLink()); Duration duration = Duration.getInstance(NumberHelper.getDouble(gpTask.getDuration()), TimeUnit.DAYS); mpxjTask.setDuration(duration); if (duration.getDuration() == 0) { mpxjTask.setMilestone(true); } else { mpxjTask.setStart(gpTask.getStart()); mpxjTask.setFinish(m_mpxjCalendar.getDate(gpTask.getStart(), mpxjTask.getDuration(), false)); } mpxjTask.setConstraintDate(gpTask.getThirdDate()); if (mpxjTask.getConstraintDate() != null) { // TODO: you don't appear to be able to change this setting in GanttProject // task.getThirdDateConstraint() mpxjTask.setConstraintType(ConstraintType.START_NO_EARLIER_THAN); } readTaskCustomFields(gpTask, mpxjTask); m_eventManager.fireTaskReadEvent(mpxjTask); // TODO: read custom values // // Process child tasks // for (net.sf.mpxj.ganttproject.schema.Task childTask : gpTask.getTask()) { readTask(mpxjTask, childTask); } }
java
private void readTask(ChildTaskContainer mpxjParent, net.sf.mpxj.ganttproject.schema.Task gpTask) { Task mpxjTask = mpxjParent.addTask(); mpxjTask.setUniqueID(Integer.valueOf(NumberHelper.getInt(gpTask.getId()) + 1)); mpxjTask.setName(gpTask.getName()); mpxjTask.setPercentageComplete(gpTask.getComplete()); mpxjTask.setPriority(getPriority(gpTask.getPriority())); mpxjTask.setHyperlink(gpTask.getWebLink()); Duration duration = Duration.getInstance(NumberHelper.getDouble(gpTask.getDuration()), TimeUnit.DAYS); mpxjTask.setDuration(duration); if (duration.getDuration() == 0) { mpxjTask.setMilestone(true); } else { mpxjTask.setStart(gpTask.getStart()); mpxjTask.setFinish(m_mpxjCalendar.getDate(gpTask.getStart(), mpxjTask.getDuration(), false)); } mpxjTask.setConstraintDate(gpTask.getThirdDate()); if (mpxjTask.getConstraintDate() != null) { // TODO: you don't appear to be able to change this setting in GanttProject // task.getThirdDateConstraint() mpxjTask.setConstraintType(ConstraintType.START_NO_EARLIER_THAN); } readTaskCustomFields(gpTask, mpxjTask); m_eventManager.fireTaskReadEvent(mpxjTask); // TODO: read custom values // // Process child tasks // for (net.sf.mpxj.ganttproject.schema.Task childTask : gpTask.getTask()) { readTask(mpxjTask, childTask); } }
[ "private", "void", "readTask", "(", "ChildTaskContainer", "mpxjParent", ",", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "gpTask", ")", "{", "Task", "mpxjTask", "=", "mpxjParent", ".", "addTask", "(", ")", ";", "mpxjTask", ".", "setUniqueID", "(", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "gpTask", ".", "getId", "(", ")", ")", "+", "1", ")", ")", ";", "mpxjTask", ".", "setName", "(", "gpTask", ".", "getName", "(", ")", ")", ";", "mpxjTask", ".", "setPercentageComplete", "(", "gpTask", ".", "getComplete", "(", ")", ")", ";", "mpxjTask", ".", "setPriority", "(", "getPriority", "(", "gpTask", ".", "getPriority", "(", ")", ")", ")", ";", "mpxjTask", ".", "setHyperlink", "(", "gpTask", ".", "getWebLink", "(", ")", ")", ";", "Duration", "duration", "=", "Duration", ".", "getInstance", "(", "NumberHelper", ".", "getDouble", "(", "gpTask", ".", "getDuration", "(", ")", ")", ",", "TimeUnit", ".", "DAYS", ")", ";", "mpxjTask", ".", "setDuration", "(", "duration", ")", ";", "if", "(", "duration", ".", "getDuration", "(", ")", "==", "0", ")", "{", "mpxjTask", ".", "setMilestone", "(", "true", ")", ";", "}", "else", "{", "mpxjTask", ".", "setStart", "(", "gpTask", ".", "getStart", "(", ")", ")", ";", "mpxjTask", ".", "setFinish", "(", "m_mpxjCalendar", ".", "getDate", "(", "gpTask", ".", "getStart", "(", ")", ",", "mpxjTask", ".", "getDuration", "(", ")", ",", "false", ")", ")", ";", "}", "mpxjTask", ".", "setConstraintDate", "(", "gpTask", ".", "getThirdDate", "(", ")", ")", ";", "if", "(", "mpxjTask", ".", "getConstraintDate", "(", ")", "!=", "null", ")", "{", "// TODO: you don't appear to be able to change this setting in GanttProject", "// task.getThirdDateConstraint()", "mpxjTask", ".", "setConstraintType", "(", "ConstraintType", ".", "START_NO_EARLIER_THAN", ")", ";", "}", "readTaskCustomFields", "(", "gpTask", ",", "mpxjTask", ")", ";", "m_eventManager", ".", "fireTaskReadEvent", "(", "mpxjTask", ")", ";", "// TODO: read custom values", "//", "// Process child tasks", "//", "for", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "childTask", ":", "gpTask", ".", "getTask", "(", ")", ")", "{", "readTask", "(", "mpxjTask", ",", "childTask", ")", ";", "}", "}" ]
Recursively read a task, and any sub tasks. @param mpxjParent Parent for the MPXJ tasks @param gpTask GanttProject task
[ "Recursively", "read", "a", "task", "and", "any", "sub", "tasks", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L711-L754
157,675
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.getPriority
private Priority getPriority(Integer gpPriority) { int result; if (gpPriority == null) { result = Priority.MEDIUM; } else { int index = gpPriority.intValue(); if (index < 0 || index >= PRIORITY.length) { result = Priority.MEDIUM; } else { result = PRIORITY[index]; } } return Priority.getInstance(result); }
java
private Priority getPriority(Integer gpPriority) { int result; if (gpPriority == null) { result = Priority.MEDIUM; } else { int index = gpPriority.intValue(); if (index < 0 || index >= PRIORITY.length) { result = Priority.MEDIUM; } else { result = PRIORITY[index]; } } return Priority.getInstance(result); }
[ "private", "Priority", "getPriority", "(", "Integer", "gpPriority", ")", "{", "int", "result", ";", "if", "(", "gpPriority", "==", "null", ")", "{", "result", "=", "Priority", ".", "MEDIUM", ";", "}", "else", "{", "int", "index", "=", "gpPriority", ".", "intValue", "(", ")", ";", "if", "(", "index", "<", "0", "||", "index", ">=", "PRIORITY", ".", "length", ")", "{", "result", "=", "Priority", ".", "MEDIUM", ";", "}", "else", "{", "result", "=", "PRIORITY", "[", "index", "]", ";", "}", "}", "return", "Priority", ".", "getInstance", "(", "result", ")", ";", "}" ]
Given a GanttProject priority value, turn this into an MPXJ Priority instance. @param gpPriority GanttProject priority @return Priority instance
[ "Given", "a", "GanttProject", "priority", "value", "turn", "this", "into", "an", "MPXJ", "Priority", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L762-L782
157,676
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readRelationships
private void readRelationships(Project gpProject) { for (net.sf.mpxj.ganttproject.schema.Task gpTask : gpProject.getTasks().getTask()) { readRelationships(gpTask); } }
java
private void readRelationships(Project gpProject) { for (net.sf.mpxj.ganttproject.schema.Task gpTask : gpProject.getTasks().getTask()) { readRelationships(gpTask); } }
[ "private", "void", "readRelationships", "(", "Project", "gpProject", ")", "{", "for", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "gpTask", ":", "gpProject", ".", "getTasks", "(", ")", ".", "getTask", "(", ")", ")", "{", "readRelationships", "(", "gpTask", ")", ";", "}", "}" ]
Read all task relationships from a GanttProject. @param gpProject GanttProject project
[ "Read", "all", "task", "relationships", "from", "a", "GanttProject", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L789-L795
157,677
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readRelationships
private void readRelationships(net.sf.mpxj.ganttproject.schema.Task gpTask) { for (Depend depend : gpTask.getDepend()) { Task task1 = m_projectFile.getTaskByUniqueID(Integer.valueOf(NumberHelper.getInt(gpTask.getId()) + 1)); Task task2 = m_projectFile.getTaskByUniqueID(Integer.valueOf(NumberHelper.getInt(depend.getId()) + 1)); if (task1 != null && task2 != null) { Duration lag = Duration.getInstance(NumberHelper.getInt(depend.getDifference()), TimeUnit.DAYS); Relation relation = task2.addPredecessor(task1, getRelationType(depend.getType()), lag); m_eventManager.fireRelationReadEvent(relation); } } }
java
private void readRelationships(net.sf.mpxj.ganttproject.schema.Task gpTask) { for (Depend depend : gpTask.getDepend()) { Task task1 = m_projectFile.getTaskByUniqueID(Integer.valueOf(NumberHelper.getInt(gpTask.getId()) + 1)); Task task2 = m_projectFile.getTaskByUniqueID(Integer.valueOf(NumberHelper.getInt(depend.getId()) + 1)); if (task1 != null && task2 != null) { Duration lag = Duration.getInstance(NumberHelper.getInt(depend.getDifference()), TimeUnit.DAYS); Relation relation = task2.addPredecessor(task1, getRelationType(depend.getType()), lag); m_eventManager.fireRelationReadEvent(relation); } } }
[ "private", "void", "readRelationships", "(", "net", ".", "sf", ".", "mpxj", ".", "ganttproject", ".", "schema", ".", "Task", "gpTask", ")", "{", "for", "(", "Depend", "depend", ":", "gpTask", ".", "getDepend", "(", ")", ")", "{", "Task", "task1", "=", "m_projectFile", ".", "getTaskByUniqueID", "(", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "gpTask", ".", "getId", "(", ")", ")", "+", "1", ")", ")", ";", "Task", "task2", "=", "m_projectFile", ".", "getTaskByUniqueID", "(", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "depend", ".", "getId", "(", ")", ")", "+", "1", ")", ")", ";", "if", "(", "task1", "!=", "null", "&&", "task2", "!=", "null", ")", "{", "Duration", "lag", "=", "Duration", ".", "getInstance", "(", "NumberHelper", ".", "getInt", "(", "depend", ".", "getDifference", "(", ")", ")", ",", "TimeUnit", ".", "DAYS", ")", ";", "Relation", "relation", "=", "task2", ".", "addPredecessor", "(", "task1", ",", "getRelationType", "(", "depend", ".", "getType", "(", ")", ")", ",", "lag", ")", ";", "m_eventManager", ".", "fireRelationReadEvent", "(", "relation", ")", ";", "}", "}", "}" ]
Read the relationships for an individual GanttProject task. @param gpTask GanttProject task
[ "Read", "the", "relationships", "for", "an", "individual", "GanttProject", "task", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L802-L815
157,678
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.getRelationType
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; }
java
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; }
[ "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", ";", "}" ]
Convert a GanttProject task relationship type into an MPXJ RelationType instance. @param gpType GanttProject task relation type @return RelationType instance
[ "Convert", "a", "GanttProject", "task", "relationship", "type", "into", "an", "MPXJ", "RelationType", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L823-L841
157,679
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResourceAssignments
private void readResourceAssignments(Project gpProject) { Allocations allocations = gpProject.getAllocations(); if (allocations != null) { for (Allocation allocation : allocations.getAllocation()) { readResourceAssignment(allocation); } } }
java
private void readResourceAssignments(Project gpProject) { Allocations allocations = gpProject.getAllocations(); if (allocations != null) { for (Allocation allocation : allocations.getAllocation()) { readResourceAssignment(allocation); } } }
[ "private", "void", "readResourceAssignments", "(", "Project", "gpProject", ")", "{", "Allocations", "allocations", "=", "gpProject", ".", "getAllocations", "(", ")", ";", "if", "(", "allocations", "!=", "null", ")", "{", "for", "(", "Allocation", "allocation", ":", "allocations", ".", "getAllocation", "(", ")", ")", "{", "readResourceAssignment", "(", "allocation", ")", ";", "}", "}", "}" ]
Read all resource assignments from a GanttProject project. @param gpProject GanttProject project
[ "Read", "all", "resource", "assignments", "from", "a", "GanttProject", "project", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L848-L858
157,680
joniles/mpxj
src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java
GanttProjectReader.readResourceAssignment
private void readResourceAssignment(Allocation gpAllocation) { Integer taskID = Integer.valueOf(NumberHelper.getInt(gpAllocation.getTaskId()) + 1); Integer resourceID = Integer.valueOf(NumberHelper.getInt(gpAllocation.getResourceId()) + 1); Task task = m_projectFile.getTaskByUniqueID(taskID); Resource resource = m_projectFile.getResourceByUniqueID(resourceID); if (task != null && resource != null) { ResourceAssignment mpxjAssignment = task.addResourceAssignment(resource); mpxjAssignment.setUnits(gpAllocation.getLoad()); m_eventManager.fireAssignmentReadEvent(mpxjAssignment); } }
java
private void readResourceAssignment(Allocation gpAllocation) { Integer taskID = Integer.valueOf(NumberHelper.getInt(gpAllocation.getTaskId()) + 1); Integer resourceID = Integer.valueOf(NumberHelper.getInt(gpAllocation.getResourceId()) + 1); Task task = m_projectFile.getTaskByUniqueID(taskID); Resource resource = m_projectFile.getResourceByUniqueID(resourceID); if (task != null && resource != null) { ResourceAssignment mpxjAssignment = task.addResourceAssignment(resource); mpxjAssignment.setUnits(gpAllocation.getLoad()); m_eventManager.fireAssignmentReadEvent(mpxjAssignment); } }
[ "private", "void", "readResourceAssignment", "(", "Allocation", "gpAllocation", ")", "{", "Integer", "taskID", "=", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "gpAllocation", ".", "getTaskId", "(", ")", ")", "+", "1", ")", ";", "Integer", "resourceID", "=", "Integer", ".", "valueOf", "(", "NumberHelper", ".", "getInt", "(", "gpAllocation", ".", "getResourceId", "(", ")", ")", "+", "1", ")", ";", "Task", "task", "=", "m_projectFile", ".", "getTaskByUniqueID", "(", "taskID", ")", ";", "Resource", "resource", "=", "m_projectFile", ".", "getResourceByUniqueID", "(", "resourceID", ")", ";", "if", "(", "task", "!=", "null", "&&", "resource", "!=", "null", ")", "{", "ResourceAssignment", "mpxjAssignment", "=", "task", ".", "addResourceAssignment", "(", "resource", ")", ";", "mpxjAssignment", ".", "setUnits", "(", "gpAllocation", ".", "getLoad", "(", ")", ")", ";", "m_eventManager", ".", "fireAssignmentReadEvent", "(", "mpxjAssignment", ")", ";", "}", "}" ]
Read an individual GanttProject resource assignment. @param gpAllocation GanttProject resource assignment.
[ "Read", "an", "individual", "GanttProject", "resource", "assignment", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttproject/GanttProjectReader.java#L865-L877
157,681
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeCustomFields
private void writeCustomFields() throws IOException { m_writer.writeStartList("custom_fields"); for (CustomField field : m_projectFile.getCustomFields()) { writeCustomField(field); } m_writer.writeEndList(); }
java
private void writeCustomFields() throws IOException { m_writer.writeStartList("custom_fields"); for (CustomField field : m_projectFile.getCustomFields()) { writeCustomField(field); } m_writer.writeEndList(); }
[ "private", "void", "writeCustomFields", "(", ")", "throws", "IOException", "{", "m_writer", ".", "writeStartList", "(", "\"custom_fields\"", ")", ";", "for", "(", "CustomField", "field", ":", "m_projectFile", ".", "getCustomFields", "(", ")", ")", "{", "writeCustomField", "(", "field", ")", ";", "}", "m_writer", ".", "writeEndList", "(", ")", ";", "}" ]
Write a list of custom field attributes.
[ "Write", "a", "list", "of", "custom", "field", "attributes", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L130-L138
157,682
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeCustomField
private void writeCustomField(CustomField field) throws IOException { if (field.getAlias() != null) { m_writer.writeStartObject(null); m_writer.writeNameValuePair("field_type_class", field.getFieldType().getFieldTypeClass().name().toLowerCase()); m_writer.writeNameValuePair("field_type", field.getFieldType().name().toLowerCase()); m_writer.writeNameValuePair("field_alias", field.getAlias()); m_writer.writeEndObject(); } }
java
private void writeCustomField(CustomField field) throws IOException { if (field.getAlias() != null) { m_writer.writeStartObject(null); m_writer.writeNameValuePair("field_type_class", field.getFieldType().getFieldTypeClass().name().toLowerCase()); m_writer.writeNameValuePair("field_type", field.getFieldType().name().toLowerCase()); m_writer.writeNameValuePair("field_alias", field.getAlias()); m_writer.writeEndObject(); } }
[ "private", "void", "writeCustomField", "(", "CustomField", "field", ")", "throws", "IOException", "{", "if", "(", "field", ".", "getAlias", "(", ")", "!=", "null", ")", "{", "m_writer", ".", "writeStartObject", "(", "null", ")", ";", "m_writer", ".", "writeNameValuePair", "(", "\"field_type_class\"", ",", "field", ".", "getFieldType", "(", ")", ".", "getFieldTypeClass", "(", ")", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "m_writer", ".", "writeNameValuePair", "(", "\"field_type\"", ",", "field", ".", "getFieldType", "(", ")", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", ")", ";", "m_writer", ".", "writeNameValuePair", "(", "\"field_alias\"", ",", "field", ".", "getAlias", "(", ")", ")", ";", "m_writer", ".", "writeEndObject", "(", ")", ";", "}", "}" ]
Write attributes for an individual custom field. Note that at present we are only writing a subset of the available data... in this instance the field alias. If the field does not have an alias we won't write an entry. @param field custom field to write @throws IOException
[ "Write", "attributes", "for", "an", "individual", "custom", "field", ".", "Note", "that", "at", "present", "we", "are", "only", "writing", "a", "subset", "of", "the", "available", "data", "...", "in", "this", "instance", "the", "field", "alias", ".", "If", "the", "field", "does", "not", "have", "an", "alias", "we", "won", "t", "write", "an", "entry", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L150-L160
157,683
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeProperties
private void writeProperties() throws IOException { writeAttributeTypes("property_types", ProjectField.values()); writeFields("property_values", m_projectFile.getProjectProperties(), ProjectField.values()); }
java
private void writeProperties() throws IOException { writeAttributeTypes("property_types", ProjectField.values()); writeFields("property_values", m_projectFile.getProjectProperties(), ProjectField.values()); }
[ "private", "void", "writeProperties", "(", ")", "throws", "IOException", "{", "writeAttributeTypes", "(", "\"property_types\"", ",", "ProjectField", ".", "values", "(", ")", ")", ";", "writeFields", "(", "\"property_values\"", ",", "m_projectFile", ".", "getProjectProperties", "(", ")", ",", "ProjectField", ".", "values", "(", ")", ")", ";", "}" ]
This method writes project property data to a JSON file.
[ "This", "method", "writes", "project", "property", "data", "to", "a", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L165-L169
157,684
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeResources
private void writeResources() throws IOException { writeAttributeTypes("resource_types", ResourceField.values()); m_writer.writeStartList("resources"); for (Resource resource : m_projectFile.getResources()) { writeFields(null, resource, ResourceField.values()); } m_writer.writeEndList(); }
java
private void writeResources() throws IOException { writeAttributeTypes("resource_types", ResourceField.values()); m_writer.writeStartList("resources"); for (Resource resource : m_projectFile.getResources()) { writeFields(null, resource, ResourceField.values()); } m_writer.writeEndList(); }
[ "private", "void", "writeResources", "(", ")", "throws", "IOException", "{", "writeAttributeTypes", "(", "\"resource_types\"", ",", "ResourceField", ".", "values", "(", ")", ")", ";", "m_writer", ".", "writeStartList", "(", "\"resources\"", ")", ";", "for", "(", "Resource", "resource", ":", "m_projectFile", ".", "getResources", "(", ")", ")", "{", "writeFields", "(", "null", ",", "resource", ",", "ResourceField", ".", "values", "(", ")", ")", ";", "}", "m_writer", ".", "writeEndList", "(", ")", ";", "}" ]
This method writes resource data to a JSON file.
[ "This", "method", "writes", "resource", "data", "to", "a", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L174-L184
157,685
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeTasks
private void writeTasks() throws IOException { writeAttributeTypes("task_types", TaskField.values()); m_writer.writeStartList("tasks"); for (Task task : m_projectFile.getChildTasks()) { writeTask(task); } m_writer.writeEndList(); }
java
private void writeTasks() throws IOException { writeAttributeTypes("task_types", TaskField.values()); m_writer.writeStartList("tasks"); for (Task task : m_projectFile.getChildTasks()) { writeTask(task); } m_writer.writeEndList(); }
[ "private", "void", "writeTasks", "(", ")", "throws", "IOException", "{", "writeAttributeTypes", "(", "\"task_types\"", ",", "TaskField", ".", "values", "(", ")", ")", ";", "m_writer", ".", "writeStartList", "(", "\"tasks\"", ")", ";", "for", "(", "Task", "task", ":", "m_projectFile", ".", "getChildTasks", "(", ")", ")", "{", "writeTask", "(", "task", ")", ";", "}", "m_writer", ".", "writeEndList", "(", ")", ";", "}" ]
This method writes task data to a JSON file. Note that we write the task hierarchy in order to make rebuilding the hierarchy easier.
[ "This", "method", "writes", "task", "data", "to", "a", "JSON", "file", ".", "Note", "that", "we", "write", "the", "task", "hierarchy", "in", "order", "to", "make", "rebuilding", "the", "hierarchy", "easier", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L190-L200
157,686
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeTask
private void writeTask(Task task) throws IOException { writeFields(null, task, TaskField.values()); for (Task child : task.getChildTasks()) { writeTask(child); } }
java
private void writeTask(Task task) throws IOException { writeFields(null, task, TaskField.values()); for (Task child : task.getChildTasks()) { writeTask(child); } }
[ "private", "void", "writeTask", "(", "Task", "task", ")", "throws", "IOException", "{", "writeFields", "(", "null", ",", "task", ",", "TaskField", ".", "values", "(", ")", ")", ";", "for", "(", "Task", "child", ":", "task", ".", "getChildTasks", "(", ")", ")", "{", "writeTask", "(", "child", ")", ";", "}", "}" ]
This method is called recursively to write a task and its child tasks to the JSON file. @param task task to write
[ "This", "method", "is", "called", "recursively", "to", "write", "a", "task", "and", "its", "child", "tasks", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L208-L215
157,687
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeAssignments
private void writeAssignments() throws IOException { writeAttributeTypes("assignment_types", AssignmentField.values()); m_writer.writeStartList("assignments"); for (ResourceAssignment assignment : m_projectFile.getResourceAssignments()) { writeFields(null, assignment, AssignmentField.values()); } m_writer.writeEndList(); }
java
private void writeAssignments() throws IOException { writeAttributeTypes("assignment_types", AssignmentField.values()); m_writer.writeStartList("assignments"); for (ResourceAssignment assignment : m_projectFile.getResourceAssignments()) { writeFields(null, assignment, AssignmentField.values()); } m_writer.writeEndList(); }
[ "private", "void", "writeAssignments", "(", ")", "throws", "IOException", "{", "writeAttributeTypes", "(", "\"assignment_types\"", ",", "AssignmentField", ".", "values", "(", ")", ")", ";", "m_writer", ".", "writeStartList", "(", "\"assignments\"", ")", ";", "for", "(", "ResourceAssignment", "assignment", ":", "m_projectFile", ".", "getResourceAssignments", "(", ")", ")", "{", "writeFields", "(", "null", ",", "assignment", ",", "AssignmentField", ".", "values", "(", ")", ")", ";", "}", "m_writer", ".", "writeEndList", "(", ")", ";", "}" ]
This method writes assignment data to a JSON file.
[ "This", "method", "writes", "assignment", "data", "to", "a", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L220-L231
157,688
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeAttributeTypes
private void writeAttributeTypes(String name, FieldType[] types) throws IOException { m_writer.writeStartObject(name); for (FieldType field : types) { m_writer.writeNameValuePair(field.name().toLowerCase(), field.getDataType().getValue()); } m_writer.writeEndObject(); }
java
private void writeAttributeTypes(String name, FieldType[] types) throws IOException { m_writer.writeStartObject(name); for (FieldType field : types) { m_writer.writeNameValuePair(field.name().toLowerCase(), field.getDataType().getValue()); } m_writer.writeEndObject(); }
[ "private", "void", "writeAttributeTypes", "(", "String", "name", ",", "FieldType", "[", "]", "types", ")", "throws", "IOException", "{", "m_writer", ".", "writeStartObject", "(", "name", ")", ";", "for", "(", "FieldType", "field", ":", "types", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "field", ".", "name", "(", ")", ".", "toLowerCase", "(", ")", ",", "field", ".", "getDataType", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "m_writer", ".", "writeEndObject", "(", ")", ";", "}" ]
Generates a mapping between attribute names and data types. @param name name of the map @param types types to write
[ "Generates", "a", "mapping", "between", "attribute", "names", "and", "data", "types", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L239-L247
157,689
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeFields
private void writeFields(String objectName, FieldContainer container, FieldType[] fields) throws IOException { m_writer.writeStartObject(objectName); for (FieldType field : fields) { Object value = container.getCurrentValue(field); if (value != null) { writeField(field, value); } } m_writer.writeEndObject(); }
java
private void writeFields(String objectName, FieldContainer container, FieldType[] fields) throws IOException { m_writer.writeStartObject(objectName); for (FieldType field : fields) { Object value = container.getCurrentValue(field); if (value != null) { writeField(field, value); } } m_writer.writeEndObject(); }
[ "private", "void", "writeFields", "(", "String", "objectName", ",", "FieldContainer", "container", ",", "FieldType", "[", "]", "fields", ")", "throws", "IOException", "{", "m_writer", ".", "writeStartObject", "(", "objectName", ")", ";", "for", "(", "FieldType", "field", ":", "fields", ")", "{", "Object", "value", "=", "container", ".", "getCurrentValue", "(", "field", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "writeField", "(", "field", ",", "value", ")", ";", "}", "}", "m_writer", ".", "writeEndObject", "(", ")", ";", "}" ]
Write a set of fields from a field container to a JSON file. @param objectName name of the object, or null if no name required @param container field container @param fields fields to write
[ "Write", "a", "set", "of", "fields", "from", "a", "field", "container", "to", "a", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L255-L267
157,690
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeIntegerField
private void writeIntegerField(String fieldName, Object value) throws IOException { int val = ((Number) value).intValue(); if (val != 0) { m_writer.writeNameValuePair(fieldName, val); } }
java
private void writeIntegerField(String fieldName, Object value) throws IOException { int val = ((Number) value).intValue(); if (val != 0) { m_writer.writeNameValuePair(fieldName, val); } }
[ "private", "void", "writeIntegerField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "int", "val", "=", "(", "(", "Number", ")", "value", ")", ".", "intValue", "(", ")", ";", "if", "(", "val", "!=", "0", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ")", ";", "}", "}" ]
Write an integer field to the JSON file. @param fieldName field name @param value field value
[ "Write", "an", "integer", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L370-L377
157,691
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeDoubleField
private void writeDoubleField(String fieldName, Object value) throws IOException { double val = ((Number) value).doubleValue(); if (val != 0) { m_writer.writeNameValuePair(fieldName, val); } }
java
private void writeDoubleField(String fieldName, Object value) throws IOException { double val = ((Number) value).doubleValue(); if (val != 0) { m_writer.writeNameValuePair(fieldName, val); } }
[ "private", "void", "writeDoubleField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "double", "val", "=", "(", "(", "Number", ")", "value", ")", ".", "doubleValue", "(", ")", ";", "if", "(", "val", "!=", "0", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ")", ";", "}", "}" ]
Write an double field to the JSON file. @param fieldName field name @param value field value
[ "Write", "an", "double", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L385-L392
157,692
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeBooleanField
private void writeBooleanField(String fieldName, Object value) throws IOException { boolean val = ((Boolean) value).booleanValue(); if (val) { m_writer.writeNameValuePair(fieldName, val); } }
java
private void writeBooleanField(String fieldName, Object value) throws IOException { boolean val = ((Boolean) value).booleanValue(); if (val) { m_writer.writeNameValuePair(fieldName, val); } }
[ "private", "void", "writeBooleanField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "boolean", "val", "=", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ";", "if", "(", "val", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ")", ";", "}", "}" ]
Write a boolean field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "boolean", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L400-L407
157,693
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeDurationField
private void writeDurationField(String fieldName, Object value) throws IOException { if (value instanceof String) { m_writer.writeNameValuePair(fieldName + "_text", (String) value); } else { Duration val = (Duration) value; if (val.getDuration() != 0) { Duration minutes = val.convertUnits(TimeUnit.MINUTES, m_projectFile.getProjectProperties()); long seconds = (long) (minutes.getDuration() * 60.0); m_writer.writeNameValuePair(fieldName, seconds); } } }
java
private void writeDurationField(String fieldName, Object value) throws IOException { if (value instanceof String) { m_writer.writeNameValuePair(fieldName + "_text", (String) value); } else { Duration val = (Duration) value; if (val.getDuration() != 0) { Duration minutes = val.convertUnits(TimeUnit.MINUTES, m_projectFile.getProjectProperties()); long seconds = (long) (minutes.getDuration() * 60.0); m_writer.writeNameValuePair(fieldName, seconds); } } }
[ "private", "void", "writeDurationField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "if", "(", "value", "instanceof", "String", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", "+", "\"_text\"", ",", "(", "String", ")", "value", ")", ";", "}", "else", "{", "Duration", "val", "=", "(", "Duration", ")", "value", ";", "if", "(", "val", ".", "getDuration", "(", ")", "!=", "0", ")", "{", "Duration", "minutes", "=", "val", ".", "convertUnits", "(", "TimeUnit", ".", "MINUTES", ",", "m_projectFile", ".", "getProjectProperties", "(", ")", ")", ";", "long", "seconds", "=", "(", "long", ")", "(", "minutes", ".", "getDuration", "(", ")", "*", "60.0", ")", ";", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "seconds", ")", ";", "}", "}", "}" ]
Write a duration field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "duration", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L415-L431
157,694
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeDateField
private void writeDateField(String fieldName, Object value) throws IOException { if (value instanceof String) { m_writer.writeNameValuePair(fieldName + "_text", (String) value); } else { Date val = (Date) value; m_writer.writeNameValuePair(fieldName, val); } }
java
private void writeDateField(String fieldName, Object value) throws IOException { if (value instanceof String) { m_writer.writeNameValuePair(fieldName + "_text", (String) value); } else { Date val = (Date) value; m_writer.writeNameValuePair(fieldName, val); } }
[ "private", "void", "writeDateField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "if", "(", "value", "instanceof", "String", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", "+", "\"_text\"", ",", "(", "String", ")", "value", ")", ";", "}", "else", "{", "Date", "val", "=", "(", "Date", ")", "value", ";", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ")", ";", "}", "}" ]
Write a date field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "date", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L439-L450
157,695
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeTimeUnitsField
private void writeTimeUnitsField(String fieldName, Object value) throws IOException { TimeUnit val = (TimeUnit) value; if (val != m_projectFile.getProjectProperties().getDefaultDurationUnits()) { m_writer.writeNameValuePair(fieldName, val.toString()); } }
java
private void writeTimeUnitsField(String fieldName, Object value) throws IOException { TimeUnit val = (TimeUnit) value; if (val != m_projectFile.getProjectProperties().getDefaultDurationUnits()) { m_writer.writeNameValuePair(fieldName, val.toString()); } }
[ "private", "void", "writeTimeUnitsField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "TimeUnit", "val", "=", "(", "TimeUnit", ")", "value", ";", "if", "(", "val", "!=", "m_projectFile", ".", "getProjectProperties", "(", ")", ".", "getDefaultDurationUnits", "(", ")", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Write a time units field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "time", "units", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L458-L465
157,696
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writePriorityField
private void writePriorityField(String fieldName, Object value) throws IOException { m_writer.writeNameValuePair(fieldName, ((Priority) value).getValue()); }
java
private void writePriorityField(String fieldName, Object value) throws IOException { m_writer.writeNameValuePair(fieldName, ((Priority) value).getValue()); }
[ "private", "void", "writePriorityField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "(", "(", "Priority", ")", "value", ")", ".", "getValue", "(", ")", ")", ";", "}" ]
Write a priority field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "priority", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L473-L476
157,697
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeMap
private void writeMap(String fieldName, Object value) throws IOException { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) value; m_writer.writeStartObject(fieldName); for (Map.Entry<String, Object> entry : map.entrySet()) { Object entryValue = entry.getValue(); if (entryValue != null) { DataType type = TYPE_MAP.get(entryValue.getClass().getName()); if (type == null) { type = DataType.STRING; entryValue = entryValue.toString(); } writeField(entry.getKey(), type, entryValue); } } m_writer.writeEndObject(); }
java
private void writeMap(String fieldName, Object value) throws IOException { @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) value; m_writer.writeStartObject(fieldName); for (Map.Entry<String, Object> entry : map.entrySet()) { Object entryValue = entry.getValue(); if (entryValue != null) { DataType type = TYPE_MAP.get(entryValue.getClass().getName()); if (type == null) { type = DataType.STRING; entryValue = entryValue.toString(); } writeField(entry.getKey(), type, entryValue); } } m_writer.writeEndObject(); }
[ "private", "void", "writeMap", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Object", ">", "map", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "value", ";", "m_writer", ".", "writeStartObject", "(", "fieldName", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "map", ".", "entrySet", "(", ")", ")", "{", "Object", "entryValue", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "entryValue", "!=", "null", ")", "{", "DataType", "type", "=", "TYPE_MAP", ".", "get", "(", "entryValue", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "if", "(", "type", "==", "null", ")", "{", "type", "=", "DataType", ".", "STRING", ";", "entryValue", "=", "entryValue", ".", "toString", "(", ")", ";", "}", "writeField", "(", "entry", ".", "getKey", "(", ")", ",", "type", ",", "entryValue", ")", ";", "}", "}", "m_writer", ".", "writeEndObject", "(", ")", ";", "}" ]
Write a map field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "map", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L484-L504
157,698
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeStringField
private void writeStringField(String fieldName, Object value) throws IOException { String val = value.toString(); if (!val.isEmpty()) { m_writer.writeNameValuePair(fieldName, val); } }
java
private void writeStringField(String fieldName, Object value) throws IOException { String val = value.toString(); if (!val.isEmpty()) { m_writer.writeNameValuePair(fieldName, val); } }
[ "private", "void", "writeStringField", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "String", "val", "=", "value", ".", "toString", "(", ")", ";", "if", "(", "!", "val", ".", "isEmpty", "(", ")", ")", "{", "m_writer", ".", "writeNameValuePair", "(", "fieldName", ",", "val", ")", ";", "}", "}" ]
Write a string field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "string", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L512-L519
157,699
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonWriter.java
JsonWriter.writeRelationList
private void writeRelationList(String fieldName, Object value) throws IOException { @SuppressWarnings("unchecked") List<Relation> list = (List<Relation>) value; if (!list.isEmpty()) { m_writer.writeStartList(fieldName); for (Relation relation : list) { m_writer.writeStartObject(null); writeIntegerField("task_unique_id", relation.getTargetTask().getUniqueID()); writeDurationField("lag", relation.getLag()); writeStringField("type", relation.getType()); m_writer.writeEndObject(); } m_writer.writeEndList(); } }
java
private void writeRelationList(String fieldName, Object value) throws IOException { @SuppressWarnings("unchecked") List<Relation> list = (List<Relation>) value; if (!list.isEmpty()) { m_writer.writeStartList(fieldName); for (Relation relation : list) { m_writer.writeStartObject(null); writeIntegerField("task_unique_id", relation.getTargetTask().getUniqueID()); writeDurationField("lag", relation.getLag()); writeStringField("type", relation.getType()); m_writer.writeEndObject(); } m_writer.writeEndList(); } }
[ "private", "void", "writeRelationList", "(", "String", "fieldName", ",", "Object", "value", ")", "throws", "IOException", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Relation", ">", "list", "=", "(", "List", "<", "Relation", ">", ")", "value", ";", "if", "(", "!", "list", ".", "isEmpty", "(", ")", ")", "{", "m_writer", ".", "writeStartList", "(", "fieldName", ")", ";", "for", "(", "Relation", "relation", ":", "list", ")", "{", "m_writer", ".", "writeStartObject", "(", "null", ")", ";", "writeIntegerField", "(", "\"task_unique_id\"", ",", "relation", ".", "getTargetTask", "(", ")", ".", "getUniqueID", "(", ")", ")", ";", "writeDurationField", "(", "\"lag\"", ",", "relation", ".", "getLag", "(", ")", ")", ";", "writeStringField", "(", "\"type\"", ",", "relation", ".", "getType", "(", ")", ")", ";", "m_writer", ".", "writeEndObject", "(", ")", ";", "}", "m_writer", ".", "writeEndList", "(", ")", ";", "}", "}" ]
Write a relation list field to the JSON file. @param fieldName field name @param value field value
[ "Write", "a", "relation", "list", "field", "to", "the", "JSON", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L527-L544