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,100
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createFieldMap
|
private void createFieldMap(byte[] data)
{
int index = 0;
int lastDataBlockOffset = 0;
int dataBlockIndex = 0;
while (index < data.length)
{
long mask = MPPUtility.getInt(data, index + 0);
//mask = mask << 4;
int dataBlockOffset = MPPUtility.getShort(data, index + 4);
//int metaFlags = MPPUtility.getByte(data, index + 8);
FieldType type = getFieldType(MPPUtility.getInt(data, index + 12));
int category = MPPUtility.getShort(data, index + 20);
//int sizeInBytes = MPPUtility.getShort(data, index + 22);
//int metaIndex = MPPUtility.getInt(data, index + 24);
//
// Categories
//
// 02 - Short values [RATE_UNITS, WORKGROUP, ACCRUE, TIME_UNITS, PRIORITY, TASK_TYPE, CONSTRAINT, ACCRUE, PERCENTAGE, SHORT, WORK_UNITS] - BOOKING_TYPE, EARNED_VALUE_METHOD, DELIVERABLE_TYPE, RESOURCE_REQUEST_TYPE - we have as string in MPXJ????
// 03 - Int values [DURATION, INTEGER] - Recalc outline codes as Boolean?
// 05 - Rate, Number [RATE, NUMERIC]
// 08 - String (and some durations!!!) [STRING, DURATION]
// 0B - Boolean (meta block 0?) - [BOOLEAN]
// 13 - Date - [DATE]
// 48 - GUID - [GUID]
// 64 - Boolean (meta block 1?)- [BOOLEAN]
// 65 - Work, Currency [WORK, CURRENCY]
// 66 - Units [UNITS]
// 1D - Raw bytes [BINARY, ASCII_STRING] - Exception: outline code indexes, they are integers, but stored as part of a binary block
int varDataKey;
if (useTypeAsVarDataKey())
{
Integer substitute = substituteVarDataKey(type);
if (substitute == null)
{
varDataKey = (MPPUtility.getInt(data, index + 12) & 0x0000FFFF);
}
else
{
varDataKey = substitute.intValue();
}
}
else
{
varDataKey = MPPUtility.getByte(data, index + 6);
}
FieldLocation location;
int metaBlock;
switch (category)
{
case 0x0B:
{
location = FieldLocation.META_DATA;
metaBlock = 0;
break;
}
case 0x64:
{
location = FieldLocation.META_DATA;
metaBlock = 1;
break;
}
default:
{
metaBlock = 0;
if (dataBlockOffset != 65535)
{
location = FieldLocation.FIXED_DATA;
if (dataBlockOffset < lastDataBlockOffset)
{
++dataBlockIndex;
}
lastDataBlockOffset = dataBlockOffset;
int typeSize = getFixedDataFieldSize(type);
if (dataBlockOffset + typeSize > m_maxFixedDataSize[dataBlockIndex])
{
m_maxFixedDataSize[dataBlockIndex] = dataBlockOffset + typeSize;
}
}
else
{
if (varDataKey != 0)
{
location = FieldLocation.VAR_DATA;
}
else
{
location = FieldLocation.UNKNOWN;
}
}
break;
}
}
FieldItem item = new FieldItem(type, location, dataBlockIndex, dataBlockOffset, varDataKey, mask, metaBlock);
if (m_debug)
{
System.out.println(ByteArrayHelper.hexdump(data, index, 28, false) + " " + item + " mpxjDataType=" + item.getType().getDataType() + " index=" + index);
}
m_map.put(type, item);
index += 28;
}
}
|
java
|
private void createFieldMap(byte[] data)
{
int index = 0;
int lastDataBlockOffset = 0;
int dataBlockIndex = 0;
while (index < data.length)
{
long mask = MPPUtility.getInt(data, index + 0);
//mask = mask << 4;
int dataBlockOffset = MPPUtility.getShort(data, index + 4);
//int metaFlags = MPPUtility.getByte(data, index + 8);
FieldType type = getFieldType(MPPUtility.getInt(data, index + 12));
int category = MPPUtility.getShort(data, index + 20);
//int sizeInBytes = MPPUtility.getShort(data, index + 22);
//int metaIndex = MPPUtility.getInt(data, index + 24);
//
// Categories
//
// 02 - Short values [RATE_UNITS, WORKGROUP, ACCRUE, TIME_UNITS, PRIORITY, TASK_TYPE, CONSTRAINT, ACCRUE, PERCENTAGE, SHORT, WORK_UNITS] - BOOKING_TYPE, EARNED_VALUE_METHOD, DELIVERABLE_TYPE, RESOURCE_REQUEST_TYPE - we have as string in MPXJ????
// 03 - Int values [DURATION, INTEGER] - Recalc outline codes as Boolean?
// 05 - Rate, Number [RATE, NUMERIC]
// 08 - String (and some durations!!!) [STRING, DURATION]
// 0B - Boolean (meta block 0?) - [BOOLEAN]
// 13 - Date - [DATE]
// 48 - GUID - [GUID]
// 64 - Boolean (meta block 1?)- [BOOLEAN]
// 65 - Work, Currency [WORK, CURRENCY]
// 66 - Units [UNITS]
// 1D - Raw bytes [BINARY, ASCII_STRING] - Exception: outline code indexes, they are integers, but stored as part of a binary block
int varDataKey;
if (useTypeAsVarDataKey())
{
Integer substitute = substituteVarDataKey(type);
if (substitute == null)
{
varDataKey = (MPPUtility.getInt(data, index + 12) & 0x0000FFFF);
}
else
{
varDataKey = substitute.intValue();
}
}
else
{
varDataKey = MPPUtility.getByte(data, index + 6);
}
FieldLocation location;
int metaBlock;
switch (category)
{
case 0x0B:
{
location = FieldLocation.META_DATA;
metaBlock = 0;
break;
}
case 0x64:
{
location = FieldLocation.META_DATA;
metaBlock = 1;
break;
}
default:
{
metaBlock = 0;
if (dataBlockOffset != 65535)
{
location = FieldLocation.FIXED_DATA;
if (dataBlockOffset < lastDataBlockOffset)
{
++dataBlockIndex;
}
lastDataBlockOffset = dataBlockOffset;
int typeSize = getFixedDataFieldSize(type);
if (dataBlockOffset + typeSize > m_maxFixedDataSize[dataBlockIndex])
{
m_maxFixedDataSize[dataBlockIndex] = dataBlockOffset + typeSize;
}
}
else
{
if (varDataKey != 0)
{
location = FieldLocation.VAR_DATA;
}
else
{
location = FieldLocation.UNKNOWN;
}
}
break;
}
}
FieldItem item = new FieldItem(type, location, dataBlockIndex, dataBlockOffset, varDataKey, mask, metaBlock);
if (m_debug)
{
System.out.println(ByteArrayHelper.hexdump(data, index, 28, false) + " " + item + " mpxjDataType=" + item.getType().getDataType() + " index=" + index);
}
m_map.put(type, item);
index += 28;
}
}
|
[
"private",
"void",
"createFieldMap",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"int",
"index",
"=",
"0",
";",
"int",
"lastDataBlockOffset",
"=",
"0",
";",
"int",
"dataBlockIndex",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"data",
".",
"length",
")",
"{",
"long",
"mask",
"=",
"MPPUtility",
".",
"getInt",
"(",
"data",
",",
"index",
"+",
"0",
")",
";",
"//mask = mask << 4;",
"int",
"dataBlockOffset",
"=",
"MPPUtility",
".",
"getShort",
"(",
"data",
",",
"index",
"+",
"4",
")",
";",
"//int metaFlags = MPPUtility.getByte(data, index + 8);",
"FieldType",
"type",
"=",
"getFieldType",
"(",
"MPPUtility",
".",
"getInt",
"(",
"data",
",",
"index",
"+",
"12",
")",
")",
";",
"int",
"category",
"=",
"MPPUtility",
".",
"getShort",
"(",
"data",
",",
"index",
"+",
"20",
")",
";",
"//int sizeInBytes = MPPUtility.getShort(data, index + 22);",
"//int metaIndex = MPPUtility.getInt(data, index + 24);",
"//",
"// Categories",
"//",
"// 02 - Short values [RATE_UNITS, WORKGROUP, ACCRUE, TIME_UNITS, PRIORITY, TASK_TYPE, CONSTRAINT, ACCRUE, PERCENTAGE, SHORT, WORK_UNITS] - BOOKING_TYPE, EARNED_VALUE_METHOD, DELIVERABLE_TYPE, RESOURCE_REQUEST_TYPE - we have as string in MPXJ????",
"// 03 - Int values [DURATION, INTEGER] - Recalc outline codes as Boolean?",
"// 05 - Rate, Number [RATE, NUMERIC]",
"// 08 - String (and some durations!!!) [STRING, DURATION]",
"// 0B - Boolean (meta block 0?) - [BOOLEAN]",
"// 13 - Date - [DATE]",
"// 48 - GUID - [GUID]",
"// 64 - Boolean (meta block 1?)- [BOOLEAN]",
"// 65 - Work, Currency [WORK, CURRENCY]",
"// 66 - Units [UNITS]",
"// 1D - Raw bytes [BINARY, ASCII_STRING] - Exception: outline code indexes, they are integers, but stored as part of a binary block",
"int",
"varDataKey",
";",
"if",
"(",
"useTypeAsVarDataKey",
"(",
")",
")",
"{",
"Integer",
"substitute",
"=",
"substituteVarDataKey",
"(",
"type",
")",
";",
"if",
"(",
"substitute",
"==",
"null",
")",
"{",
"varDataKey",
"=",
"(",
"MPPUtility",
".",
"getInt",
"(",
"data",
",",
"index",
"+",
"12",
")",
"&",
"0x0000FFFF",
")",
";",
"}",
"else",
"{",
"varDataKey",
"=",
"substitute",
".",
"intValue",
"(",
")",
";",
"}",
"}",
"else",
"{",
"varDataKey",
"=",
"MPPUtility",
".",
"getByte",
"(",
"data",
",",
"index",
"+",
"6",
")",
";",
"}",
"FieldLocation",
"location",
";",
"int",
"metaBlock",
";",
"switch",
"(",
"category",
")",
"{",
"case",
"0x0B",
":",
"{",
"location",
"=",
"FieldLocation",
".",
"META_DATA",
";",
"metaBlock",
"=",
"0",
";",
"break",
";",
"}",
"case",
"0x64",
":",
"{",
"location",
"=",
"FieldLocation",
".",
"META_DATA",
";",
"metaBlock",
"=",
"1",
";",
"break",
";",
"}",
"default",
":",
"{",
"metaBlock",
"=",
"0",
";",
"if",
"(",
"dataBlockOffset",
"!=",
"65535",
")",
"{",
"location",
"=",
"FieldLocation",
".",
"FIXED_DATA",
";",
"if",
"(",
"dataBlockOffset",
"<",
"lastDataBlockOffset",
")",
"{",
"++",
"dataBlockIndex",
";",
"}",
"lastDataBlockOffset",
"=",
"dataBlockOffset",
";",
"int",
"typeSize",
"=",
"getFixedDataFieldSize",
"(",
"type",
")",
";",
"if",
"(",
"dataBlockOffset",
"+",
"typeSize",
">",
"m_maxFixedDataSize",
"[",
"dataBlockIndex",
"]",
")",
"{",
"m_maxFixedDataSize",
"[",
"dataBlockIndex",
"]",
"=",
"dataBlockOffset",
"+",
"typeSize",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"varDataKey",
"!=",
"0",
")",
"{",
"location",
"=",
"FieldLocation",
".",
"VAR_DATA",
";",
"}",
"else",
"{",
"location",
"=",
"FieldLocation",
".",
"UNKNOWN",
";",
"}",
"}",
"break",
";",
"}",
"}",
"FieldItem",
"item",
"=",
"new",
"FieldItem",
"(",
"type",
",",
"location",
",",
"dataBlockIndex",
",",
"dataBlockOffset",
",",
"varDataKey",
",",
"mask",
",",
"metaBlock",
")",
";",
"if",
"(",
"m_debug",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"ByteArrayHelper",
".",
"hexdump",
"(",
"data",
",",
"index",
",",
"28",
",",
"false",
")",
"+",
"\" \"",
"+",
"item",
"+",
"\" mpxjDataType=\"",
"+",
"item",
".",
"getType",
"(",
")",
".",
"getDataType",
"(",
")",
"+",
"\" index=\"",
"+",
"index",
")",
";",
"}",
"m_map",
".",
"put",
"(",
"type",
",",
"item",
")",
";",
"index",
"+=",
"28",
";",
"}",
"}"
] |
Generic method used to create a field map from a block of data.
@param data field map data
|
[
"Generic",
"method",
"used",
"to",
"create",
"a",
"field",
"map",
"from",
"a",
"block",
"of",
"data",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L88-L200
|
157,101
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createTaskFieldMap
|
public void createTaskFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : TASK_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultTaskData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
java
|
public void createTaskFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : TASK_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultTaskData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
[
"public",
"void",
"createTaskFieldMap",
"(",
"Props",
"props",
")",
"{",
"byte",
"[",
"]",
"fieldMapData",
"=",
"null",
";",
"for",
"(",
"Integer",
"key",
":",
"TASK_KEYS",
")",
"{",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"key",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"fieldMapData",
"==",
"null",
")",
"{",
"populateDefaultData",
"(",
"getDefaultTaskData",
"(",
")",
")",
";",
"}",
"else",
"{",
"createFieldMap",
"(",
"fieldMapData",
")",
";",
"}",
"}"
] |
Creates a field map for tasks.
@param props props data
|
[
"Creates",
"a",
"field",
"map",
"for",
"tasks",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L261-L281
|
157,102
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createRelationFieldMap
|
public void createRelationFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : RELATION_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultRelationData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
java
|
public void createRelationFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : RELATION_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultRelationData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
[
"public",
"void",
"createRelationFieldMap",
"(",
"Props",
"props",
")",
"{",
"byte",
"[",
"]",
"fieldMapData",
"=",
"null",
";",
"for",
"(",
"Integer",
"key",
":",
"RELATION_KEYS",
")",
"{",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"key",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"fieldMapData",
"==",
"null",
")",
"{",
"populateDefaultData",
"(",
"getDefaultRelationData",
"(",
")",
")",
";",
"}",
"else",
"{",
"createFieldMap",
"(",
"fieldMapData",
")",
";",
"}",
"}"
] |
Creates a field map for relations.
@param props props data
|
[
"Creates",
"a",
"field",
"map",
"for",
"relations",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L288-L308
|
157,103
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createEnterpriseCustomFieldMap
|
public void createEnterpriseCustomFieldMap(Props props, Class<?> c)
{
byte[] fieldMapData = null;
for (Integer key : ENTERPRISE_CUSTOM_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData != null)
{
int index = 4;
while (index < fieldMapData.length)
{
//Looks like the custom fields have varying types, it may be that the last byte of the four represents the type?
//System.out.println(ByteArrayHelper.hexdump(fieldMapData, index, 4, false));
int typeValue = MPPUtility.getInt(fieldMapData, index);
FieldType type = getFieldType(typeValue);
if (type != null && type.getClass() == c && type.toString().startsWith("Enterprise Custom Field"))
{
int varDataKey = (typeValue & 0xFFFF);
FieldItem item = new FieldItem(type, FieldLocation.VAR_DATA, 0, 0, varDataKey, 0, 0);
m_map.put(type, item);
//System.out.println(item);
}
//System.out.println((type == null ? "?" : type.getClass().getSimpleName() + "." + type) + " " + Integer.toHexString(typeValue));
index += 4;
}
}
}
|
java
|
public void createEnterpriseCustomFieldMap(Props props, Class<?> c)
{
byte[] fieldMapData = null;
for (Integer key : ENTERPRISE_CUSTOM_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData != null)
{
int index = 4;
while (index < fieldMapData.length)
{
//Looks like the custom fields have varying types, it may be that the last byte of the four represents the type?
//System.out.println(ByteArrayHelper.hexdump(fieldMapData, index, 4, false));
int typeValue = MPPUtility.getInt(fieldMapData, index);
FieldType type = getFieldType(typeValue);
if (type != null && type.getClass() == c && type.toString().startsWith("Enterprise Custom Field"))
{
int varDataKey = (typeValue & 0xFFFF);
FieldItem item = new FieldItem(type, FieldLocation.VAR_DATA, 0, 0, varDataKey, 0, 0);
m_map.put(type, item);
//System.out.println(item);
}
//System.out.println((type == null ? "?" : type.getClass().getSimpleName() + "." + type) + " " + Integer.toHexString(typeValue));
index += 4;
}
}
}
|
[
"public",
"void",
"createEnterpriseCustomFieldMap",
"(",
"Props",
"props",
",",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"byte",
"[",
"]",
"fieldMapData",
"=",
"null",
";",
"for",
"(",
"Integer",
"key",
":",
"ENTERPRISE_CUSTOM_KEYS",
")",
"{",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"key",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"int",
"index",
"=",
"4",
";",
"while",
"(",
"index",
"<",
"fieldMapData",
".",
"length",
")",
"{",
"//Looks like the custom fields have varying types, it may be that the last byte of the four represents the type?",
"//System.out.println(ByteArrayHelper.hexdump(fieldMapData, index, 4, false));",
"int",
"typeValue",
"=",
"MPPUtility",
".",
"getInt",
"(",
"fieldMapData",
",",
"index",
")",
";",
"FieldType",
"type",
"=",
"getFieldType",
"(",
"typeValue",
")",
";",
"if",
"(",
"type",
"!=",
"null",
"&&",
"type",
".",
"getClass",
"(",
")",
"==",
"c",
"&&",
"type",
".",
"toString",
"(",
")",
".",
"startsWith",
"(",
"\"Enterprise Custom Field\"",
")",
")",
"{",
"int",
"varDataKey",
"=",
"(",
"typeValue",
"&",
"0xFFFF",
")",
";",
"FieldItem",
"item",
"=",
"new",
"FieldItem",
"(",
"type",
",",
"FieldLocation",
".",
"VAR_DATA",
",",
"0",
",",
"0",
",",
"varDataKey",
",",
"0",
",",
"0",
")",
";",
"m_map",
".",
"put",
"(",
"type",
",",
"item",
")",
";",
"//System.out.println(item);",
"}",
"//System.out.println((type == null ? \"?\" : type.getClass().getSimpleName() + \".\" + type) + \" \" + Integer.toHexString(typeValue));",
"index",
"+=",
"4",
";",
"}",
"}",
"}"
] |
Create a field map for enterprise custom fields.
@param props props data
@param c target class
|
[
"Create",
"a",
"field",
"map",
"for",
"enterprise",
"custom",
"fields",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L316-L349
|
157,104
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createResourceFieldMap
|
public void createResourceFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : RESOURCE_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultResourceData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
java
|
public void createResourceFieldMap(Props props)
{
byte[] fieldMapData = null;
for (Integer key : RESOURCE_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultResourceData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
[
"public",
"void",
"createResourceFieldMap",
"(",
"Props",
"props",
")",
"{",
"byte",
"[",
"]",
"fieldMapData",
"=",
"null",
";",
"for",
"(",
"Integer",
"key",
":",
"RESOURCE_KEYS",
")",
"{",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"key",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"fieldMapData",
"==",
"null",
")",
"{",
"populateDefaultData",
"(",
"getDefaultResourceData",
"(",
")",
")",
";",
"}",
"else",
"{",
"createFieldMap",
"(",
"fieldMapData",
")",
";",
"}",
"}"
] |
Creates a field map for resources.
@param props props data
|
[
"Creates",
"a",
"field",
"map",
"for",
"resources",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L356-L376
|
157,105
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.createAssignmentFieldMap
|
public void createAssignmentFieldMap(Props props)
{
//System.out.println("ASSIGN");
byte[] fieldMapData = null;
for (Integer key : ASSIGNMENT_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultAssignmentData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
java
|
public void createAssignmentFieldMap(Props props)
{
//System.out.println("ASSIGN");
byte[] fieldMapData = null;
for (Integer key : ASSIGNMENT_KEYS)
{
fieldMapData = props.getByteArray(key);
if (fieldMapData != null)
{
break;
}
}
if (fieldMapData == null)
{
populateDefaultData(getDefaultAssignmentData());
}
else
{
createFieldMap(fieldMapData);
}
}
|
[
"public",
"void",
"createAssignmentFieldMap",
"(",
"Props",
"props",
")",
"{",
"//System.out.println(\"ASSIGN\");",
"byte",
"[",
"]",
"fieldMapData",
"=",
"null",
";",
"for",
"(",
"Integer",
"key",
":",
"ASSIGNMENT_KEYS",
")",
"{",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"key",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"fieldMapData",
"==",
"null",
")",
"{",
"populateDefaultData",
"(",
"getDefaultAssignmentData",
"(",
")",
")",
";",
"}",
"else",
"{",
"createFieldMap",
"(",
"fieldMapData",
")",
";",
"}",
"}"
] |
Creates a field map for assignments.
@param props props data
|
[
"Creates",
"a",
"field",
"map",
"for",
"assignments",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L383-L404
|
157,106
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.populateDefaultData
|
private void populateDefaultData(FieldItem[] defaultData)
{
for (FieldItem item : defaultData)
{
m_map.put(item.getType(), item);
}
}
|
java
|
private void populateDefaultData(FieldItem[] defaultData)
{
for (FieldItem item : defaultData)
{
m_map.put(item.getType(), item);
}
}
|
[
"private",
"void",
"populateDefaultData",
"(",
"FieldItem",
"[",
"]",
"defaultData",
")",
"{",
"for",
"(",
"FieldItem",
"item",
":",
"defaultData",
")",
"{",
"m_map",
".",
"put",
"(",
"item",
".",
"getType",
"(",
")",
",",
"item",
")",
";",
"}",
"}"
] |
This method takes an array of data and uses this to populate the
field map.
@param defaultData field map default data
|
[
"This",
"method",
"takes",
"an",
"array",
"of",
"data",
"and",
"uses",
"this",
"to",
"populate",
"the",
"field",
"map",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L412-L418
|
157,107
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.populateContainer
|
public void populateContainer(Class<? extends FieldType> type, FieldContainer container, Integer id, byte[][] fixedData, Var2Data varData)
{
//System.out.println(container.getClass().getSimpleName()+": " + id);
for (FieldItem item : m_map.values())
{
if (item.getType().getClass().equals(type))
{
//System.out.println(item.m_type);
Object value = item.read(id, fixedData, varData);
//System.out.println(item.m_type.getClass().getSimpleName() + "." + item.m_type + ": " + value);
container.set(item.getType(), value);
}
}
}
|
java
|
public void populateContainer(Class<? extends FieldType> type, FieldContainer container, Integer id, byte[][] fixedData, Var2Data varData)
{
//System.out.println(container.getClass().getSimpleName()+": " + id);
for (FieldItem item : m_map.values())
{
if (item.getType().getClass().equals(type))
{
//System.out.println(item.m_type);
Object value = item.read(id, fixedData, varData);
//System.out.println(item.m_type.getClass().getSimpleName() + "." + item.m_type + ": " + value);
container.set(item.getType(), value);
}
}
}
|
[
"public",
"void",
"populateContainer",
"(",
"Class",
"<",
"?",
"extends",
"FieldType",
">",
"type",
",",
"FieldContainer",
"container",
",",
"Integer",
"id",
",",
"byte",
"[",
"]",
"[",
"]",
"fixedData",
",",
"Var2Data",
"varData",
")",
"{",
"//System.out.println(container.getClass().getSimpleName()+\": \" + id);",
"for",
"(",
"FieldItem",
"item",
":",
"m_map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"item",
".",
"getType",
"(",
")",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"//System.out.println(item.m_type);",
"Object",
"value",
"=",
"item",
".",
"read",
"(",
"id",
",",
"fixedData",
",",
"varData",
")",
";",
"//System.out.println(item.m_type.getClass().getSimpleName() + \".\" + item.m_type + \": \" + value);",
"container",
".",
"set",
"(",
"item",
".",
"getType",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"}"
] |
Given a container, and a set of raw data blocks, this method extracts
the field data and writes it into the container.
@param type expected type
@param container field container
@param id entity ID
@param fixedData fixed data block
@param varData var data block
|
[
"Given",
"a",
"container",
"and",
"a",
"set",
"of",
"raw",
"data",
"blocks",
"this",
"method",
"extracts",
"the",
"field",
"data",
"and",
"writes",
"it",
"into",
"the",
"container",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L430-L443
|
157,108
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getFixedDataOffset
|
public int getFixedDataOffset(FieldType type)
{
int result;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getFixedDataOffset();
}
else
{
result = -1;
}
return result;
}
|
java
|
public int getFixedDataOffset(FieldType type)
{
int result;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getFixedDataOffset();
}
else
{
result = -1;
}
return result;
}
|
[
"public",
"int",
"getFixedDataOffset",
"(",
"FieldType",
"type",
")",
"{",
"int",
"result",
";",
"FieldItem",
"item",
"=",
"m_map",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"result",
"=",
"item",
".",
"getFixedDataOffset",
"(",
")",
";",
"}",
"else",
"{",
"result",
"=",
"-",
"1",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the fixed data offset for a specific field.
@param type field type
@return offset
|
[
"Retrieve",
"the",
"fixed",
"data",
"offset",
"for",
"a",
"specific",
"field",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L462-L475
|
157,109
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getVarDataKey
|
public Integer getVarDataKey(FieldType type)
{
Integer result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getVarDataKey();
}
return result;
}
|
java
|
public Integer getVarDataKey(FieldType type)
{
Integer result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getVarDataKey();
}
return result;
}
|
[
"public",
"Integer",
"getVarDataKey",
"(",
"FieldType",
"type",
")",
"{",
"Integer",
"result",
"=",
"null",
";",
"FieldItem",
"item",
"=",
"m_map",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"result",
"=",
"item",
".",
"getVarDataKey",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the var data key for a specific field.
@param type field type
@return var data key
|
[
"Retrieve",
"the",
"var",
"data",
"key",
"for",
"a",
"specific",
"field",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L483-L492
|
157,110
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getFieldTypeFromVarDataKey
|
public FieldType getFieldTypeFromVarDataKey(Integer key)
{
FieldType result = null;
for (Entry<FieldType, FieldMap.FieldItem> entry : m_map.entrySet())
{
if (entry.getValue().getFieldLocation() == FieldLocation.VAR_DATA && entry.getValue().getVarDataKey().equals(key))
{
result = entry.getKey();
break;
}
}
return result;
}
|
java
|
public FieldType getFieldTypeFromVarDataKey(Integer key)
{
FieldType result = null;
for (Entry<FieldType, FieldMap.FieldItem> entry : m_map.entrySet())
{
if (entry.getValue().getFieldLocation() == FieldLocation.VAR_DATA && entry.getValue().getVarDataKey().equals(key))
{
result = entry.getKey();
break;
}
}
return result;
}
|
[
"public",
"FieldType",
"getFieldTypeFromVarDataKey",
"(",
"Integer",
"key",
")",
"{",
"FieldType",
"result",
"=",
"null",
";",
"for",
"(",
"Entry",
"<",
"FieldType",
",",
"FieldMap",
".",
"FieldItem",
">",
"entry",
":",
"m_map",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getFieldLocation",
"(",
")",
"==",
"FieldLocation",
".",
"VAR_DATA",
"&&",
"entry",
".",
"getValue",
"(",
")",
".",
"getVarDataKey",
"(",
")",
".",
"equals",
"(",
"key",
")",
")",
"{",
"result",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"break",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Used to map from a var data key to a field type. Note this
is designed for diagnostic use only, and uses an inefficient search.
@param key var data key
@return field type
|
[
"Used",
"to",
"map",
"from",
"a",
"var",
"data",
"key",
"to",
"a",
"field",
"type",
".",
"Note",
"this",
"is",
"designed",
"for",
"diagnostic",
"use",
"only",
"and",
"uses",
"an",
"inefficient",
"search",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L501-L513
|
157,111
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getFieldLocation
|
public FieldLocation getFieldLocation(FieldType type)
{
FieldLocation result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getFieldLocation();
}
return result;
}
|
java
|
public FieldLocation getFieldLocation(FieldType type)
{
FieldLocation result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.getFieldLocation();
}
return result;
}
|
[
"public",
"FieldLocation",
"getFieldLocation",
"(",
"FieldType",
"type",
")",
"{",
"FieldLocation",
"result",
"=",
"null",
";",
"FieldItem",
"item",
"=",
"m_map",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"result",
"=",
"item",
".",
"getFieldLocation",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the field location for a specific field.
@param type field type
@return field location
|
[
"Retrieve",
"the",
"field",
"location",
"for",
"a",
"specific",
"field",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L521-L531
|
157,112
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getFieldData
|
protected Object getFieldData(Integer id, FieldType type, byte[][] fixedData, Var2Data varData)
{
Object result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.read(id, fixedData, varData);
}
return result;
}
|
java
|
protected Object getFieldData(Integer id, FieldType type, byte[][] fixedData, Var2Data varData)
{
Object result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.read(id, fixedData, varData);
}
return result;
}
|
[
"protected",
"Object",
"getFieldData",
"(",
"Integer",
"id",
",",
"FieldType",
"type",
",",
"byte",
"[",
"]",
"[",
"]",
"fixedData",
",",
"Var2Data",
"varData",
")",
"{",
"Object",
"result",
"=",
"null",
";",
"FieldItem",
"item",
"=",
"m_map",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"result",
"=",
"item",
".",
"read",
"(",
"id",
",",
"fixedData",
",",
"varData",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve a single field value.
@param id parent entity ID
@param type field type
@param fixedData fixed data block
@param varData var data block
@return field value
|
[
"Retrieve",
"a",
"single",
"field",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L542-L553
|
157,113
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.dumpKnownFieldMaps
|
public void dumpKnownFieldMaps(Props props)
{
//for (int key=131092; key < 131098; key++)
for (int key = 50331668; key < 50331674; key++)
{
byte[] fieldMapData = props.getByteArray(Integer.valueOf(key));
if (fieldMapData != null)
{
System.out.println("KEY: " + key);
createFieldMap(fieldMapData);
System.out.println(toString());
clear();
}
}
}
|
java
|
public void dumpKnownFieldMaps(Props props)
{
//for (int key=131092; key < 131098; key++)
for (int key = 50331668; key < 50331674; key++)
{
byte[] fieldMapData = props.getByteArray(Integer.valueOf(key));
if (fieldMapData != null)
{
System.out.println("KEY: " + key);
createFieldMap(fieldMapData);
System.out.println(toString());
clear();
}
}
}
|
[
"public",
"void",
"dumpKnownFieldMaps",
"(",
"Props",
"props",
")",
"{",
"//for (int key=131092; key < 131098; key++)",
"for",
"(",
"int",
"key",
"=",
"50331668",
";",
"key",
"<",
"50331674",
";",
"key",
"++",
")",
"{",
"byte",
"[",
"]",
"fieldMapData",
"=",
"props",
".",
"getByteArray",
"(",
"Integer",
".",
"valueOf",
"(",
"key",
")",
")",
";",
"if",
"(",
"fieldMapData",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"KEY: \"",
"+",
"key",
")",
";",
"createFieldMap",
"(",
"fieldMapData",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"toString",
"(",
")",
")",
";",
"clear",
"(",
")",
";",
"}",
"}",
"}"
] |
Diagnostic method used to dump known field map data.
@param props props block containing field map data
|
[
"Diagnostic",
"method",
"used",
"to",
"dump",
"known",
"field",
"map",
"data",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L579-L593
|
157,114
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpp/FieldMap.java
|
FieldMap.getFixedDataFieldSize
|
private int getFixedDataFieldSize(FieldType type)
{
int result = 0;
DataType dataType = type.getDataType();
if (dataType != null)
{
switch (dataType)
{
case DATE:
case INTEGER:
case DURATION:
{
result = 4;
break;
}
case TIME_UNITS:
case CONSTRAINT:
case PRIORITY:
case PERCENTAGE:
case TASK_TYPE:
case ACCRUE:
case SHORT:
case BOOLEAN:
case DELAY:
case WORKGROUP:
case RATE_UNITS:
case EARNED_VALUE_METHOD:
case RESOURCE_REQUEST_TYPE:
{
result = 2;
break;
}
case CURRENCY:
case UNITS:
case RATE:
case WORK:
{
result = 8;
break;
}
case WORK_UNITS:
{
result = 1;
break;
}
case GUID:
{
result = 16;
break;
}
default:
{
result = 0;
break;
}
}
}
return result;
}
|
java
|
private int getFixedDataFieldSize(FieldType type)
{
int result = 0;
DataType dataType = type.getDataType();
if (dataType != null)
{
switch (dataType)
{
case DATE:
case INTEGER:
case DURATION:
{
result = 4;
break;
}
case TIME_UNITS:
case CONSTRAINT:
case PRIORITY:
case PERCENTAGE:
case TASK_TYPE:
case ACCRUE:
case SHORT:
case BOOLEAN:
case DELAY:
case WORKGROUP:
case RATE_UNITS:
case EARNED_VALUE_METHOD:
case RESOURCE_REQUEST_TYPE:
{
result = 2;
break;
}
case CURRENCY:
case UNITS:
case RATE:
case WORK:
{
result = 8;
break;
}
case WORK_UNITS:
{
result = 1;
break;
}
case GUID:
{
result = 16;
break;
}
default:
{
result = 0;
break;
}
}
}
return result;
}
|
[
"private",
"int",
"getFixedDataFieldSize",
"(",
"FieldType",
"type",
")",
"{",
"int",
"result",
"=",
"0",
";",
"DataType",
"dataType",
"=",
"type",
".",
"getDataType",
"(",
")",
";",
"if",
"(",
"dataType",
"!=",
"null",
")",
"{",
"switch",
"(",
"dataType",
")",
"{",
"case",
"DATE",
":",
"case",
"INTEGER",
":",
"case",
"DURATION",
":",
"{",
"result",
"=",
"4",
";",
"break",
";",
"}",
"case",
"TIME_UNITS",
":",
"case",
"CONSTRAINT",
":",
"case",
"PRIORITY",
":",
"case",
"PERCENTAGE",
":",
"case",
"TASK_TYPE",
":",
"case",
"ACCRUE",
":",
"case",
"SHORT",
":",
"case",
"BOOLEAN",
":",
"case",
"DELAY",
":",
"case",
"WORKGROUP",
":",
"case",
"RATE_UNITS",
":",
"case",
"EARNED_VALUE_METHOD",
":",
"case",
"RESOURCE_REQUEST_TYPE",
":",
"{",
"result",
"=",
"2",
";",
"break",
";",
"}",
"case",
"CURRENCY",
":",
"case",
"UNITS",
":",
"case",
"RATE",
":",
"case",
"WORK",
":",
"{",
"result",
"=",
"8",
";",
"break",
";",
"}",
"case",
"WORK_UNITS",
":",
"{",
"result",
"=",
"1",
";",
"break",
";",
"}",
"case",
"GUID",
":",
"{",
"result",
"=",
"16",
";",
"break",
";",
"}",
"default",
":",
"{",
"result",
"=",
"0",
";",
"break",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Determine the size of a field in a fixed data block.
@param type field data type
@return field size in bytes
|
[
"Determine",
"the",
"size",
"of",
"a",
"field",
"in",
"a",
"fixed",
"data",
"block",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L601-L665
|
157,115
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.setParent
|
void setParent(ProjectCalendarWeek parent)
{
m_parent = parent;
for (int loop = 0; loop < m_days.length; loop++)
{
if (m_days[loop] == null)
{
m_days[loop] = DayType.DEFAULT;
}
}
}
|
java
|
void setParent(ProjectCalendarWeek parent)
{
m_parent = parent;
for (int loop = 0; loop < m_days.length; loop++)
{
if (m_days[loop] == null)
{
m_days[loop] = DayType.DEFAULT;
}
}
}
|
[
"void",
"setParent",
"(",
"ProjectCalendarWeek",
"parent",
")",
"{",
"m_parent",
"=",
"parent",
";",
"for",
"(",
"int",
"loop",
"=",
"0",
";",
"loop",
"<",
"m_days",
".",
"length",
";",
"loop",
"++",
")",
"{",
"if",
"(",
"m_days",
"[",
"loop",
"]",
"==",
"null",
")",
"{",
"m_days",
"[",
"loop",
"]",
"=",
"DayType",
".",
"DEFAULT",
";",
"}",
"}",
"}"
] |
Set the parent from which this week is derived.
@param parent parent week
|
[
"Set",
"the",
"parent",
"from",
"which",
"this",
"week",
"is",
"derived",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L94-L105
|
157,116
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.getHours
|
public ProjectCalendarHours getHours(Day day)
{
ProjectCalendarHours result = getCalendarHours(day);
if (result == null)
{
//
// If this is a base calendar and we have no hours, then we
// have a problem - so we add the default hours and try again
//
if (m_parent == null)
{
// Only add default hours for the day that is 'missing' to avoid overwriting real calendar hours
addDefaultCalendarHours(day);
result = getCalendarHours(day);
}
else
{
result = m_parent.getHours(day);
}
}
return result;
}
|
java
|
public ProjectCalendarHours getHours(Day day)
{
ProjectCalendarHours result = getCalendarHours(day);
if (result == null)
{
//
// If this is a base calendar and we have no hours, then we
// have a problem - so we add the default hours and try again
//
if (m_parent == null)
{
// Only add default hours for the day that is 'missing' to avoid overwriting real calendar hours
addDefaultCalendarHours(day);
result = getCalendarHours(day);
}
else
{
result = m_parent.getHours(day);
}
}
return result;
}
|
[
"public",
"ProjectCalendarHours",
"getHours",
"(",
"Day",
"day",
")",
"{",
"ProjectCalendarHours",
"result",
"=",
"getCalendarHours",
"(",
"day",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"//",
"// If this is a base calendar and we have no hours, then we",
"// have a problem - so we add the default hours and try again",
"//",
"if",
"(",
"m_parent",
"==",
"null",
")",
"{",
"// Only add default hours for the day that is 'missing' to avoid overwriting real calendar hours",
"addDefaultCalendarHours",
"(",
"day",
")",
";",
"result",
"=",
"getCalendarHours",
"(",
"day",
")",
";",
"}",
"else",
"{",
"result",
"=",
"m_parent",
".",
"getHours",
"(",
"day",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
This method retrieves the calendar hours for the specified day.
Note that if this is a derived calendar, then this method
will refer to the base calendar where no hours are specified
in the derived calendar.
@param day Day instance
@return calendar hours
|
[
"This",
"method",
"retrieves",
"the",
"calendar",
"hours",
"for",
"the",
"specified",
"day",
".",
"Note",
"that",
"if",
"this",
"is",
"a",
"derived",
"calendar",
"then",
"this",
"method",
"will",
"refer",
"to",
"the",
"base",
"calendar",
"where",
"no",
"hours",
"are",
"specified",
"in",
"the",
"derived",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L162-L183
|
157,117
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.addDefaultCalendarHours
|
public void addDefaultCalendarHours(Day day)
{
ProjectCalendarHours hours = addCalendarHours(day);
if (day != Day.SATURDAY && day != Day.SUNDAY)
{
hours.addRange(DEFAULT_WORKING_MORNING);
hours.addRange(DEFAULT_WORKING_AFTERNOON);
}
}
|
java
|
public void addDefaultCalendarHours(Day day)
{
ProjectCalendarHours hours = addCalendarHours(day);
if (day != Day.SATURDAY && day != Day.SUNDAY)
{
hours.addRange(DEFAULT_WORKING_MORNING);
hours.addRange(DEFAULT_WORKING_AFTERNOON);
}
}
|
[
"public",
"void",
"addDefaultCalendarHours",
"(",
"Day",
"day",
")",
"{",
"ProjectCalendarHours",
"hours",
"=",
"addCalendarHours",
"(",
"day",
")",
";",
"if",
"(",
"day",
"!=",
"Day",
".",
"SATURDAY",
"&&",
"day",
"!=",
"Day",
".",
"SUNDAY",
")",
"{",
"hours",
".",
"addRange",
"(",
"DEFAULT_WORKING_MORNING",
")",
";",
"hours",
".",
"addRange",
"(",
"DEFAULT_WORKING_AFTERNOON",
")",
";",
"}",
"}"
] |
This is a convenience method used to add a default set of calendar
hours to a calendar.
@param day Day for which to add default hours for
|
[
"This",
"is",
"a",
"convenience",
"method",
"used",
"to",
"add",
"a",
"default",
"set",
"of",
"calendar",
"hours",
"to",
"a",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L203-L212
|
157,118
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.addCalendarHours
|
public ProjectCalendarHours addCalendarHours(Day day)
{
ProjectCalendarHours bch = new ProjectCalendarHours(this);
bch.setDay(day);
m_hours[day.getValue() - 1] = bch;
return (bch);
}
|
java
|
public ProjectCalendarHours addCalendarHours(Day day)
{
ProjectCalendarHours bch = new ProjectCalendarHours(this);
bch.setDay(day);
m_hours[day.getValue() - 1] = bch;
return (bch);
}
|
[
"public",
"ProjectCalendarHours",
"addCalendarHours",
"(",
"Day",
"day",
")",
"{",
"ProjectCalendarHours",
"bch",
"=",
"new",
"ProjectCalendarHours",
"(",
"this",
")",
";",
"bch",
".",
"setDay",
"(",
"day",
")",
";",
"m_hours",
"[",
"day",
".",
"getValue",
"(",
")",
"-",
"1",
"]",
"=",
"bch",
";",
"return",
"(",
"bch",
")",
";",
"}"
] |
Used to add working hours to the calendar. Note that the MPX file
definition allows a maximum of 7 calendar hours records to be added to
a single calendar.
@param day day number
@return new ProjectCalendarHours instance
|
[
"Used",
"to",
"add",
"working",
"hours",
"to",
"the",
"calendar",
".",
"Note",
"that",
"the",
"MPX",
"file",
"definition",
"allows",
"a",
"maximum",
"of",
"7",
"calendar",
"hours",
"records",
"to",
"be",
"added",
"to",
"a",
"single",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L222-L228
|
157,119
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.attachHoursToDay
|
public void attachHoursToDay(ProjectCalendarHours hours)
{
if (hours.getParentCalendar() != this)
{
throw new IllegalArgumentException();
}
m_hours[hours.getDay().getValue() - 1] = hours;
}
|
java
|
public void attachHoursToDay(ProjectCalendarHours hours)
{
if (hours.getParentCalendar() != this)
{
throw new IllegalArgumentException();
}
m_hours[hours.getDay().getValue() - 1] = hours;
}
|
[
"public",
"void",
"attachHoursToDay",
"(",
"ProjectCalendarHours",
"hours",
")",
"{",
"if",
"(",
"hours",
".",
"getParentCalendar",
"(",
")",
"!=",
"this",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"m_hours",
"[",
"hours",
".",
"getDay",
"(",
")",
".",
"getValue",
"(",
")",
"-",
"1",
"]",
"=",
"hours",
";",
"}"
] |
Attaches a pre-existing set of hours to the correct
day within the calendar.
@param hours calendar hours instance
|
[
"Attaches",
"a",
"pre",
"-",
"existing",
"set",
"of",
"hours",
"to",
"the",
"correct",
"day",
"within",
"the",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L236-L243
|
157,120
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.removeHoursFromDay
|
public void removeHoursFromDay(ProjectCalendarHours hours)
{
if (hours.getParentCalendar() != this)
{
throw new IllegalArgumentException();
}
m_hours[hours.getDay().getValue() - 1] = null;
}
|
java
|
public void removeHoursFromDay(ProjectCalendarHours hours)
{
if (hours.getParentCalendar() != this)
{
throw new IllegalArgumentException();
}
m_hours[hours.getDay().getValue() - 1] = null;
}
|
[
"public",
"void",
"removeHoursFromDay",
"(",
"ProjectCalendarHours",
"hours",
")",
"{",
"if",
"(",
"hours",
".",
"getParentCalendar",
"(",
")",
"!=",
"this",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"m_hours",
"[",
"hours",
".",
"getDay",
"(",
")",
".",
"getValue",
"(",
")",
"-",
"1",
"]",
"=",
"null",
";",
"}"
] |
Removes a set of calendar hours from the day to which they
are currently attached.
@param hours calendar hours instance
|
[
"Removes",
"a",
"set",
"of",
"calendar",
"hours",
"from",
"the",
"day",
"to",
"which",
"they",
"are",
"currently",
"attached",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L251-L258
|
157,121
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.setWorkingDay
|
public void setWorkingDay(Day day, boolean working)
{
setWorkingDay(day, (working ? DayType.WORKING : DayType.NON_WORKING));
}
|
java
|
public void setWorkingDay(Day day, boolean working)
{
setWorkingDay(day, (working ? DayType.WORKING : DayType.NON_WORKING));
}
|
[
"public",
"void",
"setWorkingDay",
"(",
"Day",
"day",
",",
"boolean",
"working",
")",
"{",
"setWorkingDay",
"(",
"day",
",",
"(",
"working",
"?",
"DayType",
".",
"WORKING",
":",
"DayType",
".",
"NON_WORKING",
")",
")",
";",
"}"
] |
convenience method for setting working or non-working days.
@param day required day
@param working flag indicating if the day is a working day
|
[
"convenience",
"method",
"for",
"setting",
"working",
"or",
"non",
"-",
"working",
"days",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L294-L297
|
157,122
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendarWeek.java
|
ProjectCalendarWeek.setWorkingDay
|
public void setWorkingDay(Day day, DayType working)
{
DayType value;
if (working == null)
{
if (isDerived())
{
value = DayType.DEFAULT;
}
else
{
value = DayType.WORKING;
}
}
else
{
value = working;
}
m_days[day.getValue() - 1] = value;
}
|
java
|
public void setWorkingDay(Day day, DayType working)
{
DayType value;
if (working == null)
{
if (isDerived())
{
value = DayType.DEFAULT;
}
else
{
value = DayType.WORKING;
}
}
else
{
value = working;
}
m_days[day.getValue() - 1] = value;
}
|
[
"public",
"void",
"setWorkingDay",
"(",
"Day",
"day",
",",
"DayType",
"working",
")",
"{",
"DayType",
"value",
";",
"if",
"(",
"working",
"==",
"null",
")",
"{",
"if",
"(",
"isDerived",
"(",
")",
")",
"{",
"value",
"=",
"DayType",
".",
"DEFAULT",
";",
"}",
"else",
"{",
"value",
"=",
"DayType",
".",
"WORKING",
";",
"}",
"}",
"else",
"{",
"value",
"=",
"working",
";",
"}",
"m_days",
"[",
"day",
".",
"getValue",
"(",
")",
"-",
"1",
"]",
"=",
"value",
";",
"}"
] |
This is a convenience method provided to allow a day to be set
as working or non-working, by using the day number to
identify the required day.
@param day required day
@param working flag indicating if the day is a working day
|
[
"This",
"is",
"a",
"convenience",
"method",
"provided",
"to",
"allow",
"a",
"day",
"to",
"be",
"set",
"as",
"working",
"or",
"non",
"-",
"working",
"by",
"using",
"the",
"day",
"number",
"to",
"identify",
"the",
"required",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarWeek.java#L307-L328
|
157,123
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.readCalendar
|
private void readCalendar(Gantt gantt)
{
Gantt.Calendar ganttCalendar = gantt.getCalendar();
m_projectFile.getProjectProperties().setWeekStartDay(ganttCalendar.getWeekStart());
ProjectCalendar calendar = m_projectFile.addCalendar();
calendar.setName("Standard");
m_projectFile.setDefaultCalendar(calendar);
String workingDays = ganttCalendar.getWorkDays();
calendar.setWorkingDay(Day.SUNDAY, workingDays.charAt(0) == '1');
calendar.setWorkingDay(Day.MONDAY, workingDays.charAt(1) == '1');
calendar.setWorkingDay(Day.TUESDAY, workingDays.charAt(2) == '1');
calendar.setWorkingDay(Day.WEDNESDAY, workingDays.charAt(3) == '1');
calendar.setWorkingDay(Day.THURSDAY, workingDays.charAt(4) == '1');
calendar.setWorkingDay(Day.FRIDAY, workingDays.charAt(5) == '1');
calendar.setWorkingDay(Day.SATURDAY, workingDays.charAt(6) == '1');
for (int i = 1; i <= 7; i++)
{
Day day = Day.getInstance(i);
ProjectCalendarHours hours = calendar.addCalendarHours(day);
if (calendar.isWorkingDay(day))
{
hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING);
hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON);
}
}
for (Gantt.Holidays.Holiday holiday : gantt.getHolidays().getHoliday())
{
ProjectCalendarException exception = calendar.addCalendarException(holiday.getDate(), holiday.getDate());
exception.setName(holiday.getContent());
}
}
|
java
|
private void readCalendar(Gantt gantt)
{
Gantt.Calendar ganttCalendar = gantt.getCalendar();
m_projectFile.getProjectProperties().setWeekStartDay(ganttCalendar.getWeekStart());
ProjectCalendar calendar = m_projectFile.addCalendar();
calendar.setName("Standard");
m_projectFile.setDefaultCalendar(calendar);
String workingDays = ganttCalendar.getWorkDays();
calendar.setWorkingDay(Day.SUNDAY, workingDays.charAt(0) == '1');
calendar.setWorkingDay(Day.MONDAY, workingDays.charAt(1) == '1');
calendar.setWorkingDay(Day.TUESDAY, workingDays.charAt(2) == '1');
calendar.setWorkingDay(Day.WEDNESDAY, workingDays.charAt(3) == '1');
calendar.setWorkingDay(Day.THURSDAY, workingDays.charAt(4) == '1');
calendar.setWorkingDay(Day.FRIDAY, workingDays.charAt(5) == '1');
calendar.setWorkingDay(Day.SATURDAY, workingDays.charAt(6) == '1');
for (int i = 1; i <= 7; i++)
{
Day day = Day.getInstance(i);
ProjectCalendarHours hours = calendar.addCalendarHours(day);
if (calendar.isWorkingDay(day))
{
hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_MORNING);
hours.addRange(ProjectCalendarWeek.DEFAULT_WORKING_AFTERNOON);
}
}
for (Gantt.Holidays.Holiday holiday : gantt.getHolidays().getHoliday())
{
ProjectCalendarException exception = calendar.addCalendarException(holiday.getDate(), holiday.getDate());
exception.setName(holiday.getContent());
}
}
|
[
"private",
"void",
"readCalendar",
"(",
"Gantt",
"gantt",
")",
"{",
"Gantt",
".",
"Calendar",
"ganttCalendar",
"=",
"gantt",
".",
"getCalendar",
"(",
")",
";",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"setWeekStartDay",
"(",
"ganttCalendar",
".",
"getWeekStart",
"(",
")",
")",
";",
"ProjectCalendar",
"calendar",
"=",
"m_projectFile",
".",
"addCalendar",
"(",
")",
";",
"calendar",
".",
"setName",
"(",
"\"Standard\"",
")",
";",
"m_projectFile",
".",
"setDefaultCalendar",
"(",
"calendar",
")",
";",
"String",
"workingDays",
"=",
"ganttCalendar",
".",
"getWorkDays",
"(",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"SUNDAY",
",",
"workingDays",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"MONDAY",
",",
"workingDays",
".",
"charAt",
"(",
"1",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"TUESDAY",
",",
"workingDays",
".",
"charAt",
"(",
"2",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"WEDNESDAY",
",",
"workingDays",
".",
"charAt",
"(",
"3",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"THURSDAY",
",",
"workingDays",
".",
"charAt",
"(",
"4",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"FRIDAY",
",",
"workingDays",
".",
"charAt",
"(",
"5",
")",
"==",
"'",
"'",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"SATURDAY",
",",
"workingDays",
".",
"charAt",
"(",
"6",
")",
"==",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"7",
";",
"i",
"++",
")",
"{",
"Day",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"i",
")",
";",
"ProjectCalendarHours",
"hours",
"=",
"calendar",
".",
"addCalendarHours",
"(",
"day",
")",
";",
"if",
"(",
"calendar",
".",
"isWorkingDay",
"(",
"day",
")",
")",
"{",
"hours",
".",
"addRange",
"(",
"ProjectCalendarWeek",
".",
"DEFAULT_WORKING_MORNING",
")",
";",
"hours",
".",
"addRange",
"(",
"ProjectCalendarWeek",
".",
"DEFAULT_WORKING_AFTERNOON",
")",
";",
"}",
"}",
"for",
"(",
"Gantt",
".",
"Holidays",
".",
"Holiday",
"holiday",
":",
"gantt",
".",
"getHolidays",
"(",
")",
".",
"getHoliday",
"(",
")",
")",
"{",
"ProjectCalendarException",
"exception",
"=",
"calendar",
".",
"addCalendarException",
"(",
"holiday",
".",
"getDate",
"(",
")",
",",
"holiday",
".",
"getDate",
"(",
")",
")",
";",
"exception",
".",
"setName",
"(",
"holiday",
".",
"getContent",
"(",
")",
")",
";",
"}",
"}"
] |
Read the calendar data from a Gantt Designer file.
@param gantt Gantt Designer file.
|
[
"Read",
"the",
"calendar",
"data",
"from",
"a",
"Gantt",
"Designer",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L162-L196
|
157,124
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.processTasks
|
private void processTasks(Gantt gantt)
{
ProjectCalendar calendar = m_projectFile.getDefaultCalendar();
for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask())
{
String wbs = ganttTask.getID();
ChildTaskContainer parentTask = getParentTask(wbs);
Task task = parentTask.addTask();
//ganttTask.getB() // bar type
//ganttTask.getBC() // bar color
task.setCost(ganttTask.getC());
task.setName(ganttTask.getContent());
task.setDuration(ganttTask.getD());
task.setDeadline(ganttTask.getDL());
//ganttTask.getH() // height
//ganttTask.getIn(); // indent
task.setWBS(wbs);
task.setPercentageComplete(ganttTask.getPC());
task.setStart(ganttTask.getS());
//ganttTask.getU(); // Unknown
//ganttTask.getVA(); // Valign
task.setFinish(calendar.getDate(task.getStart(), task.getDuration(), false));
m_taskMap.put(wbs, task);
}
}
|
java
|
private void processTasks(Gantt gantt)
{
ProjectCalendar calendar = m_projectFile.getDefaultCalendar();
for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask())
{
String wbs = ganttTask.getID();
ChildTaskContainer parentTask = getParentTask(wbs);
Task task = parentTask.addTask();
//ganttTask.getB() // bar type
//ganttTask.getBC() // bar color
task.setCost(ganttTask.getC());
task.setName(ganttTask.getContent());
task.setDuration(ganttTask.getD());
task.setDeadline(ganttTask.getDL());
//ganttTask.getH() // height
//ganttTask.getIn(); // indent
task.setWBS(wbs);
task.setPercentageComplete(ganttTask.getPC());
task.setStart(ganttTask.getS());
//ganttTask.getU(); // Unknown
//ganttTask.getVA(); // Valign
task.setFinish(calendar.getDate(task.getStart(), task.getDuration(), false));
m_taskMap.put(wbs, task);
}
}
|
[
"private",
"void",
"processTasks",
"(",
"Gantt",
"gantt",
")",
"{",
"ProjectCalendar",
"calendar",
"=",
"m_projectFile",
".",
"getDefaultCalendar",
"(",
")",
";",
"for",
"(",
"Gantt",
".",
"Tasks",
".",
"Task",
"ganttTask",
":",
"gantt",
".",
"getTasks",
"(",
")",
".",
"getTask",
"(",
")",
")",
"{",
"String",
"wbs",
"=",
"ganttTask",
".",
"getID",
"(",
")",
";",
"ChildTaskContainer",
"parentTask",
"=",
"getParentTask",
"(",
"wbs",
")",
";",
"Task",
"task",
"=",
"parentTask",
".",
"addTask",
"(",
")",
";",
"//ganttTask.getB() // bar type",
"//ganttTask.getBC() // bar color",
"task",
".",
"setCost",
"(",
"ganttTask",
".",
"getC",
"(",
")",
")",
";",
"task",
".",
"setName",
"(",
"ganttTask",
".",
"getContent",
"(",
")",
")",
";",
"task",
".",
"setDuration",
"(",
"ganttTask",
".",
"getD",
"(",
")",
")",
";",
"task",
".",
"setDeadline",
"(",
"ganttTask",
".",
"getDL",
"(",
")",
")",
";",
"//ganttTask.getH() // height",
"//ganttTask.getIn(); // indent",
"task",
".",
"setWBS",
"(",
"wbs",
")",
";",
"task",
".",
"setPercentageComplete",
"(",
"ganttTask",
".",
"getPC",
"(",
")",
")",
";",
"task",
".",
"setStart",
"(",
"ganttTask",
".",
"getS",
"(",
")",
")",
";",
"//ganttTask.getU(); // Unknown",
"//ganttTask.getVA(); // Valign",
"task",
".",
"setFinish",
"(",
"calendar",
".",
"getDate",
"(",
"task",
".",
"getStart",
"(",
")",
",",
"task",
".",
"getDuration",
"(",
")",
",",
"false",
")",
")",
";",
"m_taskMap",
".",
"put",
"(",
"wbs",
",",
"task",
")",
";",
"}",
"}"
] |
Read task data from a Gantt Designer file.
@param gantt Gantt Designer file
|
[
"Read",
"task",
"data",
"from",
"a",
"Gantt",
"Designer",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L215-L242
|
157,125
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.processPredecessors
|
private void processPredecessors(Gantt gantt)
{
for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask())
{
String predecessors = ganttTask.getP();
if (predecessors != null && !predecessors.isEmpty())
{
String wbs = ganttTask.getID();
Task task = m_taskMap.get(wbs);
for (String predecessor : predecessors.split(";"))
{
Task predecessorTask = m_projectFile.getTaskByID(Integer.valueOf(predecessor));
task.addPredecessor(predecessorTask, RelationType.FINISH_START, ganttTask.getL());
}
}
}
}
|
java
|
private void processPredecessors(Gantt gantt)
{
for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask())
{
String predecessors = ganttTask.getP();
if (predecessors != null && !predecessors.isEmpty())
{
String wbs = ganttTask.getID();
Task task = m_taskMap.get(wbs);
for (String predecessor : predecessors.split(";"))
{
Task predecessorTask = m_projectFile.getTaskByID(Integer.valueOf(predecessor));
task.addPredecessor(predecessorTask, RelationType.FINISH_START, ganttTask.getL());
}
}
}
}
|
[
"private",
"void",
"processPredecessors",
"(",
"Gantt",
"gantt",
")",
"{",
"for",
"(",
"Gantt",
".",
"Tasks",
".",
"Task",
"ganttTask",
":",
"gantt",
".",
"getTasks",
"(",
")",
".",
"getTask",
"(",
")",
")",
"{",
"String",
"predecessors",
"=",
"ganttTask",
".",
"getP",
"(",
")",
";",
"if",
"(",
"predecessors",
"!=",
"null",
"&&",
"!",
"predecessors",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"wbs",
"=",
"ganttTask",
".",
"getID",
"(",
")",
";",
"Task",
"task",
"=",
"m_taskMap",
".",
"get",
"(",
"wbs",
")",
";",
"for",
"(",
"String",
"predecessor",
":",
"predecessors",
".",
"split",
"(",
"\";\"",
")",
")",
"{",
"Task",
"predecessorTask",
"=",
"m_projectFile",
".",
"getTaskByID",
"(",
"Integer",
".",
"valueOf",
"(",
"predecessor",
")",
")",
";",
"task",
".",
"addPredecessor",
"(",
"predecessorTask",
",",
"RelationType",
".",
"FINISH_START",
",",
"ganttTask",
".",
"getL",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Read predecessors from a Gantt Designer file.
@param gantt Gantt Designer file
|
[
"Read",
"predecessors",
"from",
"a",
"Gantt",
"Designer",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L249-L265
|
157,126
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.processRemarks
|
private void processRemarks(Gantt gantt)
{
processRemarks(gantt.getRemarks());
processRemarks(gantt.getRemarks1());
processRemarks(gantt.getRemarks2());
processRemarks(gantt.getRemarks3());
processRemarks(gantt.getRemarks4());
}
|
java
|
private void processRemarks(Gantt gantt)
{
processRemarks(gantt.getRemarks());
processRemarks(gantt.getRemarks1());
processRemarks(gantt.getRemarks2());
processRemarks(gantt.getRemarks3());
processRemarks(gantt.getRemarks4());
}
|
[
"private",
"void",
"processRemarks",
"(",
"Gantt",
"gantt",
")",
"{",
"processRemarks",
"(",
"gantt",
".",
"getRemarks",
"(",
")",
")",
";",
"processRemarks",
"(",
"gantt",
".",
"getRemarks1",
"(",
")",
")",
";",
"processRemarks",
"(",
"gantt",
".",
"getRemarks2",
"(",
")",
")",
";",
"processRemarks",
"(",
"gantt",
".",
"getRemarks3",
"(",
")",
")",
";",
"processRemarks",
"(",
"gantt",
".",
"getRemarks4",
"(",
")",
")",
";",
"}"
] |
Read remarks from a Gantt Designer file.
@param gantt Gantt Designer file
|
[
"Read",
"remarks",
"from",
"a",
"Gantt",
"Designer",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L272-L279
|
157,127
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.processRemarks
|
private void processRemarks(GanttDesignerRemark remark)
{
for (GanttDesignerRemark.Task remarkTask : remark.getTask())
{
Integer id = remarkTask.getRow();
Task task = m_projectFile.getTaskByID(id);
String notes = task.getNotes();
if (notes.isEmpty())
{
notes = remarkTask.getContent();
}
else
{
notes = notes + '\n' + remarkTask.getContent();
}
task.setNotes(notes);
}
}
|
java
|
private void processRemarks(GanttDesignerRemark remark)
{
for (GanttDesignerRemark.Task remarkTask : remark.getTask())
{
Integer id = remarkTask.getRow();
Task task = m_projectFile.getTaskByID(id);
String notes = task.getNotes();
if (notes.isEmpty())
{
notes = remarkTask.getContent();
}
else
{
notes = notes + '\n' + remarkTask.getContent();
}
task.setNotes(notes);
}
}
|
[
"private",
"void",
"processRemarks",
"(",
"GanttDesignerRemark",
"remark",
")",
"{",
"for",
"(",
"GanttDesignerRemark",
".",
"Task",
"remarkTask",
":",
"remark",
".",
"getTask",
"(",
")",
")",
"{",
"Integer",
"id",
"=",
"remarkTask",
".",
"getRow",
"(",
")",
";",
"Task",
"task",
"=",
"m_projectFile",
".",
"getTaskByID",
"(",
"id",
")",
";",
"String",
"notes",
"=",
"task",
".",
"getNotes",
"(",
")",
";",
"if",
"(",
"notes",
".",
"isEmpty",
"(",
")",
")",
"{",
"notes",
"=",
"remarkTask",
".",
"getContent",
"(",
")",
";",
"}",
"else",
"{",
"notes",
"=",
"notes",
"+",
"'",
"'",
"+",
"remarkTask",
".",
"getContent",
"(",
")",
";",
"}",
"task",
".",
"setNotes",
"(",
"notes",
")",
";",
"}",
"}"
] |
Read an individual remark type from a Gantt Designer file.
@param remark remark type
|
[
"Read",
"an",
"individual",
"remark",
"type",
"from",
"a",
"Gantt",
"Designer",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L286-L303
|
157,128
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.getParentWBS
|
private String getParentWBS(String wbs)
{
String result;
int index = wbs.lastIndexOf('.');
if (index == -1)
{
result = null;
}
else
{
result = wbs.substring(0, index);
}
return result;
}
|
java
|
private String getParentWBS(String wbs)
{
String result;
int index = wbs.lastIndexOf('.');
if (index == -1)
{
result = null;
}
else
{
result = wbs.substring(0, index);
}
return result;
}
|
[
"private",
"String",
"getParentWBS",
"(",
"String",
"wbs",
")",
"{",
"String",
"result",
";",
"int",
"index",
"=",
"wbs",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"result",
"=",
"null",
";",
"}",
"else",
"{",
"result",
"=",
"wbs",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Extract the parent WBS from a WBS.
@param wbs current WBS
@return parent WBS
|
[
"Extract",
"the",
"parent",
"WBS",
"from",
"a",
"WBS",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L311-L324
|
157,129
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java
|
GanttDesignerReader.getParentTask
|
private ChildTaskContainer getParentTask(String wbs)
{
ChildTaskContainer result;
String parentWbs = getParentWBS(wbs);
if (parentWbs == null)
{
result = m_projectFile;
}
else
{
result = m_taskMap.get(parentWbs);
}
return result;
}
|
java
|
private ChildTaskContainer getParentTask(String wbs)
{
ChildTaskContainer result;
String parentWbs = getParentWBS(wbs);
if (parentWbs == null)
{
result = m_projectFile;
}
else
{
result = m_taskMap.get(parentWbs);
}
return result;
}
|
[
"private",
"ChildTaskContainer",
"getParentTask",
"(",
"String",
"wbs",
")",
"{",
"ChildTaskContainer",
"result",
";",
"String",
"parentWbs",
"=",
"getParentWBS",
"(",
"wbs",
")",
";",
"if",
"(",
"parentWbs",
"==",
"null",
")",
"{",
"result",
"=",
"m_projectFile",
";",
"}",
"else",
"{",
"result",
"=",
"m_taskMap",
".",
"get",
"(",
"parentWbs",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the parent task based on its WBS.
@param wbs parent WBS
@return parent task
|
[
"Retrieve",
"the",
"parent",
"task",
"based",
"on",
"its",
"WBS",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ganttdesigner/GanttDesignerReader.java#L332-L345
|
157,130
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/PoiTreeModel.java
|
PoiTreeModel.getChildNodes
|
private List<Entry> getChildNodes(DirectoryEntry parent)
{
List<Entry> result = new ArrayList<Entry>();
Iterator<Entry> entries = parent.getEntries();
while (entries.hasNext())
{
result.add(entries.next());
}
return result;
}
|
java
|
private List<Entry> getChildNodes(DirectoryEntry parent)
{
List<Entry> result = new ArrayList<Entry>();
Iterator<Entry> entries = parent.getEntries();
while (entries.hasNext())
{
result.add(entries.next());
}
return result;
}
|
[
"private",
"List",
"<",
"Entry",
">",
"getChildNodes",
"(",
"DirectoryEntry",
"parent",
")",
"{",
"List",
"<",
"Entry",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Entry",
">",
"(",
")",
";",
"Iterator",
"<",
"Entry",
">",
"entries",
"=",
"parent",
".",
"getEntries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasNext",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"entries",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieves child nodes from a directory entry.
@param parent parent directory entry
@return list of child nodes
|
[
"Retrieves",
"child",
"nodes",
"from",
"a",
"directory",
"entry",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/PoiTreeModel.java#L136-L145
|
157,131
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/PoiTreeModel.java
|
PoiTreeModel.fireTreeStructureChanged
|
private void fireTreeStructureChanged()
{
// Guaranteed to return a non-null array
Object[] listeners = m_listenerList.getListenerList();
TreeModelEvent e = null;
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2)
{
if (listeners[i] == TreeModelListener.class)
{
// Lazily create the event:
if (e == null)
{
e = new TreeModelEvent(getRoot(), new Object[]
{
getRoot()
}, null, null);
}
((TreeModelListener) listeners[i + 1]).treeStructureChanged(e);
}
}
}
|
java
|
private void fireTreeStructureChanged()
{
// Guaranteed to return a non-null array
Object[] listeners = m_listenerList.getListenerList();
TreeModelEvent e = null;
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2)
{
if (listeners[i] == TreeModelListener.class)
{
// Lazily create the event:
if (e == null)
{
e = new TreeModelEvent(getRoot(), new Object[]
{
getRoot()
}, null, null);
}
((TreeModelListener) listeners[i + 1]).treeStructureChanged(e);
}
}
}
|
[
"private",
"void",
"fireTreeStructureChanged",
"(",
")",
"{",
"// Guaranteed to return a non-null array",
"Object",
"[",
"]",
"listeners",
"=",
"m_listenerList",
".",
"getListenerList",
"(",
")",
";",
"TreeModelEvent",
"e",
"=",
"null",
";",
"// Process the listeners last to first, notifying",
"// those that are interested in this event",
"for",
"(",
"int",
"i",
"=",
"listeners",
".",
"length",
"-",
"2",
";",
"i",
">=",
"0",
";",
"i",
"-=",
"2",
")",
"{",
"if",
"(",
"listeners",
"[",
"i",
"]",
"==",
"TreeModelListener",
".",
"class",
")",
"{",
"// Lazily create the event:",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"e",
"=",
"new",
"TreeModelEvent",
"(",
"getRoot",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"getRoot",
"(",
")",
"}",
",",
"null",
",",
"null",
")",
";",
"}",
"(",
"(",
"TreeModelListener",
")",
"listeners",
"[",
"i",
"+",
"1",
"]",
")",
".",
"treeStructureChanged",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Notify listeners that the tree structure has changed.
|
[
"Notify",
"listeners",
"that",
"the",
"tree",
"structure",
"has",
"changed",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/PoiTreeModel.java#L150-L172
|
157,132
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getMinutesPerDay
|
public int getMinutesPerDay()
{
return m_minutesPerDay == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerDay()) : m_minutesPerDay.intValue();
}
|
java
|
public int getMinutesPerDay()
{
return m_minutesPerDay == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerDay()) : m_minutesPerDay.intValue();
}
|
[
"public",
"int",
"getMinutesPerDay",
"(",
")",
"{",
"return",
"m_minutesPerDay",
"==",
"null",
"?",
"NumberHelper",
".",
"getInt",
"(",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerDay",
"(",
")",
")",
":",
"m_minutesPerDay",
".",
"intValue",
"(",
")",
";",
"}"
] |
Retrieve the number of minutes per day for this calendar.
@return minutes per day
|
[
"Retrieve",
"the",
"number",
"of",
"minutes",
"per",
"day",
"for",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L67-L70
|
157,133
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getMinutesPerWeek
|
public int getMinutesPerWeek()
{
return m_minutesPerWeek == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerWeek()) : m_minutesPerWeek.intValue();
}
|
java
|
public int getMinutesPerWeek()
{
return m_minutesPerWeek == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerWeek()) : m_minutesPerWeek.intValue();
}
|
[
"public",
"int",
"getMinutesPerWeek",
"(",
")",
"{",
"return",
"m_minutesPerWeek",
"==",
"null",
"?",
"NumberHelper",
".",
"getInt",
"(",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerWeek",
"(",
")",
")",
":",
"m_minutesPerWeek",
".",
"intValue",
"(",
")",
";",
"}"
] |
Retrieve the number of minutes per week for this calendar.
@return minutes per week
|
[
"Retrieve",
"the",
"number",
"of",
"minutes",
"per",
"week",
"for",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L77-L80
|
157,134
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getMinutesPerMonth
|
public int getMinutesPerMonth()
{
return m_minutesPerMonth == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerMonth()) : m_minutesPerMonth.intValue();
}
|
java
|
public int getMinutesPerMonth()
{
return m_minutesPerMonth == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerMonth()) : m_minutesPerMonth.intValue();
}
|
[
"public",
"int",
"getMinutesPerMonth",
"(",
")",
"{",
"return",
"m_minutesPerMonth",
"==",
"null",
"?",
"NumberHelper",
".",
"getInt",
"(",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerMonth",
"(",
")",
")",
":",
"m_minutesPerMonth",
".",
"intValue",
"(",
")",
";",
"}"
] |
Retrieve the number of minutes per month for this calendar.
@return minutes per month
|
[
"Retrieve",
"the",
"number",
"of",
"minutes",
"per",
"month",
"for",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L87-L90
|
157,135
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getMinutesPerYear
|
public int getMinutesPerYear()
{
return m_minutesPerYear == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerYear()) : m_minutesPerYear.intValue();
}
|
java
|
public int getMinutesPerYear()
{
return m_minutesPerYear == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerYear()) : m_minutesPerYear.intValue();
}
|
[
"public",
"int",
"getMinutesPerYear",
"(",
")",
"{",
"return",
"m_minutesPerYear",
"==",
"null",
"?",
"NumberHelper",
".",
"getInt",
"(",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerYear",
"(",
")",
")",
":",
"m_minutesPerYear",
".",
"intValue",
"(",
")",
";",
"}"
] |
Retrieve the number of minutes per year for this calendar.
@return minutes per year
|
[
"Retrieve",
"the",
"number",
"of",
"minutes",
"per",
"year",
"for",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L97-L100
|
157,136
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.addWorkWeek
|
public ProjectCalendarWeek addWorkWeek()
{
ProjectCalendarWeek week = new ProjectCalendarWeek();
week.setParent(this);
m_workWeeks.add(week);
m_weeksSorted = false;
clearWorkingDateCache();
return week;
}
|
java
|
public ProjectCalendarWeek addWorkWeek()
{
ProjectCalendarWeek week = new ProjectCalendarWeek();
week.setParent(this);
m_workWeeks.add(week);
m_weeksSorted = false;
clearWorkingDateCache();
return week;
}
|
[
"public",
"ProjectCalendarWeek",
"addWorkWeek",
"(",
")",
"{",
"ProjectCalendarWeek",
"week",
"=",
"new",
"ProjectCalendarWeek",
"(",
")",
";",
"week",
".",
"setParent",
"(",
"this",
")",
";",
"m_workWeeks",
".",
"add",
"(",
"week",
")",
";",
"m_weeksSorted",
"=",
"false",
";",
"clearWorkingDateCache",
"(",
")",
";",
"return",
"week",
";",
"}"
] |
Add an empty work week.
@return new work week
|
[
"Add",
"an",
"empty",
"work",
"week",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L147-L155
|
157,137
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.addCalendarException
|
public ProjectCalendarException addCalendarException(Date fromDate, Date toDate)
{
ProjectCalendarException bce = new ProjectCalendarException(fromDate, toDate);
m_exceptions.add(bce);
m_expandedExceptions.clear();
m_exceptionsSorted = false;
clearWorkingDateCache();
return bce;
}
|
java
|
public ProjectCalendarException addCalendarException(Date fromDate, Date toDate)
{
ProjectCalendarException bce = new ProjectCalendarException(fromDate, toDate);
m_exceptions.add(bce);
m_expandedExceptions.clear();
m_exceptionsSorted = false;
clearWorkingDateCache();
return bce;
}
|
[
"public",
"ProjectCalendarException",
"addCalendarException",
"(",
"Date",
"fromDate",
",",
"Date",
"toDate",
")",
"{",
"ProjectCalendarException",
"bce",
"=",
"new",
"ProjectCalendarException",
"(",
"fromDate",
",",
"toDate",
")",
";",
"m_exceptions",
".",
"add",
"(",
"bce",
")",
";",
"m_expandedExceptions",
".",
"clear",
"(",
")",
";",
"m_exceptionsSorted",
"=",
"false",
";",
"clearWorkingDateCache",
"(",
")",
";",
"return",
"bce",
";",
"}"
] |
Used to add exceptions to the calendar. The MPX standard defines
a limit of 250 exceptions per calendar.
@param fromDate exception start date
@param toDate exception end date
@return ProjectCalendarException instance
|
[
"Used",
"to",
"add",
"exceptions",
"to",
"the",
"calendar",
".",
"The",
"MPX",
"standard",
"defines",
"a",
"limit",
"of",
"250",
"exceptions",
"per",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L185-L193
|
157,138
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.setParent
|
public void setParent(ProjectCalendar calendar)
{
// I've seen a malformed MSPDI file which sets the parent calendar to itself.
// Silently ignore this here.
if (calendar != this)
{
if (getParent() != null)
{
getParent().removeDerivedCalendar(this);
}
super.setParent(calendar);
if (calendar != null)
{
calendar.addDerivedCalendar(this);
}
clearWorkingDateCache();
}
}
|
java
|
public void setParent(ProjectCalendar calendar)
{
// I've seen a malformed MSPDI file which sets the parent calendar to itself.
// Silently ignore this here.
if (calendar != this)
{
if (getParent() != null)
{
getParent().removeDerivedCalendar(this);
}
super.setParent(calendar);
if (calendar != null)
{
calendar.addDerivedCalendar(this);
}
clearWorkingDateCache();
}
}
|
[
"public",
"void",
"setParent",
"(",
"ProjectCalendar",
"calendar",
")",
"{",
"// I've seen a malformed MSPDI file which sets the parent calendar to itself.",
"// Silently ignore this here.",
"if",
"(",
"calendar",
"!=",
"this",
")",
"{",
"if",
"(",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"getParent",
"(",
")",
".",
"removeDerivedCalendar",
"(",
"this",
")",
";",
"}",
"super",
".",
"setParent",
"(",
"calendar",
")",
";",
"if",
"(",
"calendar",
"!=",
"null",
")",
"{",
"calendar",
".",
"addDerivedCalendar",
"(",
"this",
")",
";",
"}",
"clearWorkingDateCache",
"(",
")",
";",
"}",
"}"
] |
Sets the ProjectCalendar instance from which this calendar is derived.
@param calendar base calendar instance
|
[
"Sets",
"the",
"ProjectCalendar",
"instance",
"from",
"which",
"this",
"calendar",
"is",
"derived",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L260-L279
|
157,139
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.isWorkingDay
|
public boolean isWorkingDay(Day day)
{
DayType value = getWorkingDay(day);
boolean result;
if (value == DayType.DEFAULT)
{
ProjectCalendar cal = getParent();
if (cal != null)
{
result = cal.isWorkingDay(day);
}
else
{
result = (day != Day.SATURDAY && day != Day.SUNDAY);
}
}
else
{
result = (value == DayType.WORKING);
}
return (result);
}
|
java
|
public boolean isWorkingDay(Day day)
{
DayType value = getWorkingDay(day);
boolean result;
if (value == DayType.DEFAULT)
{
ProjectCalendar cal = getParent();
if (cal != null)
{
result = cal.isWorkingDay(day);
}
else
{
result = (day != Day.SATURDAY && day != Day.SUNDAY);
}
}
else
{
result = (value == DayType.WORKING);
}
return (result);
}
|
[
"public",
"boolean",
"isWorkingDay",
"(",
"Day",
"day",
")",
"{",
"DayType",
"value",
"=",
"getWorkingDay",
"(",
"day",
")",
";",
"boolean",
"result",
";",
"if",
"(",
"value",
"==",
"DayType",
".",
"DEFAULT",
")",
"{",
"ProjectCalendar",
"cal",
"=",
"getParent",
"(",
")",
";",
"if",
"(",
"cal",
"!=",
"null",
")",
"{",
"result",
"=",
"cal",
".",
"isWorkingDay",
"(",
"day",
")",
";",
"}",
"else",
"{",
"result",
"=",
"(",
"day",
"!=",
"Day",
".",
"SATURDAY",
"&&",
"day",
"!=",
"Day",
".",
"SUNDAY",
")",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"(",
"value",
"==",
"DayType",
".",
"WORKING",
")",
";",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Method indicating whether a day is a working or non-working day.
@param day required day
@return true if this is a working day
|
[
"Method",
"indicating",
"whether",
"a",
"day",
"is",
"a",
"working",
"or",
"non",
"-",
"working",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L292-L315
|
157,140
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getDuration
|
public Duration getDuration(Date startDate, Date endDate)
{
Calendar cal = DateHelper.popCalendar(startDate);
int days = getDaysInRange(startDate, endDate);
int duration = 0;
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (days > 0)
{
if (isWorkingDate(cal.getTime(), day) == true)
{
++duration;
}
--days;
day = day.getNextDay();
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
}
DateHelper.pushCalendar(cal);
return (Duration.getInstance(duration, TimeUnit.DAYS));
}
|
java
|
public Duration getDuration(Date startDate, Date endDate)
{
Calendar cal = DateHelper.popCalendar(startDate);
int days = getDaysInRange(startDate, endDate);
int duration = 0;
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (days > 0)
{
if (isWorkingDate(cal.getTime(), day) == true)
{
++duration;
}
--days;
day = day.getNextDay();
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
}
DateHelper.pushCalendar(cal);
return (Duration.getInstance(duration, TimeUnit.DAYS));
}
|
[
"public",
"Duration",
"getDuration",
"(",
"Date",
"startDate",
",",
"Date",
"endDate",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"startDate",
")",
";",
"int",
"days",
"=",
"getDaysInRange",
"(",
"startDate",
",",
"endDate",
")",
";",
"int",
"duration",
"=",
"0",
";",
"Day",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
")",
";",
"while",
"(",
"days",
">",
"0",
")",
"{",
"if",
"(",
"isWorkingDate",
"(",
"cal",
".",
"getTime",
"(",
")",
",",
"day",
")",
"==",
"true",
")",
"{",
"++",
"duration",
";",
"}",
"--",
"days",
";",
"day",
"=",
"day",
".",
"getNextDay",
"(",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
"+",
"1",
")",
";",
"}",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"return",
"(",
"Duration",
".",
"getInstance",
"(",
"duration",
",",
"TimeUnit",
".",
"DAYS",
")",
")",
";",
"}"
] |
This method is provided to allow an absolute period of time
represented by start and end dates into a duration in working
days based on this calendar instance. This method takes account
of any exceptions defined for this calendar.
@param startDate start of the period
@param endDate end of the period
@return new Duration object
|
[
"This",
"method",
"is",
"provided",
"to",
"allow",
"an",
"absolute",
"period",
"of",
"time",
"represented",
"by",
"start",
"and",
"end",
"dates",
"into",
"a",
"duration",
"in",
"working",
"days",
"based",
"on",
"this",
"calendar",
"instance",
".",
"This",
"method",
"takes",
"account",
"of",
"any",
"exceptions",
"defined",
"for",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L327-L348
|
157,141
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getStartTime
|
public Date getStartTime(Date date)
{
Date result = m_startTimeCache.get(date);
if (result == null)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
if (ranges == null)
{
result = getParentFile().getProjectProperties().getDefaultStartTime();
}
else
{
result = ranges.getRange(0).getStart();
}
result = DateHelper.getCanonicalTime(result);
m_startTimeCache.put(new Date(date.getTime()), result);
}
return result;
}
|
java
|
public Date getStartTime(Date date)
{
Date result = m_startTimeCache.get(date);
if (result == null)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
if (ranges == null)
{
result = getParentFile().getProjectProperties().getDefaultStartTime();
}
else
{
result = ranges.getRange(0).getStart();
}
result = DateHelper.getCanonicalTime(result);
m_startTimeCache.put(new Date(date.getTime()), result);
}
return result;
}
|
[
"public",
"Date",
"getStartTime",
"(",
"Date",
"date",
")",
"{",
"Date",
"result",
"=",
"m_startTimeCache",
".",
"get",
"(",
"date",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"date",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"ranges",
"==",
"null",
")",
"{",
"result",
"=",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getDefaultStartTime",
"(",
")",
";",
"}",
"else",
"{",
"result",
"=",
"ranges",
".",
"getRange",
"(",
"0",
")",
".",
"getStart",
"(",
")",
";",
"}",
"result",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"result",
")",
";",
"m_startTimeCache",
".",
"put",
"(",
"new",
"Date",
"(",
"date",
".",
"getTime",
"(",
")",
")",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieves the time at which work starts on the given date, or returns
null if this is a non-working day.
@param date Date instance
@return start time, or null for non-working day
|
[
"Retrieves",
"the",
"time",
"at",
"which",
"work",
"starts",
"on",
"the",
"given",
"date",
"or",
"returns",
"null",
"if",
"this",
"is",
"a",
"non",
"-",
"working",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L357-L375
|
157,142
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getFinishTime
|
public Date getFinishTime(Date date)
{
Date result = null;
if (date != null)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
if (ranges == null)
{
result = getParentFile().getProjectProperties().getDefaultEndTime();
result = DateHelper.getCanonicalTime(result);
}
else
{
Date rangeStart = result = ranges.getRange(0).getStart();
Date rangeFinish = ranges.getRange(ranges.getRangeCount() - 1).getEnd();
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeFinish);
result = DateHelper.getCanonicalTime(rangeFinish);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay != null && finishDay != null && startDay.getTime() != finishDay.getTime())
{
result = DateHelper.addDays(result, 1);
}
}
}
return result;
}
|
java
|
public Date getFinishTime(Date date)
{
Date result = null;
if (date != null)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
if (ranges == null)
{
result = getParentFile().getProjectProperties().getDefaultEndTime();
result = DateHelper.getCanonicalTime(result);
}
else
{
Date rangeStart = result = ranges.getRange(0).getStart();
Date rangeFinish = ranges.getRange(ranges.getRangeCount() - 1).getEnd();
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeFinish);
result = DateHelper.getCanonicalTime(rangeFinish);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay != null && finishDay != null && startDay.getTime() != finishDay.getTime())
{
result = DateHelper.addDays(result, 1);
}
}
}
return result;
}
|
[
"public",
"Date",
"getFinishTime",
"(",
"Date",
"date",
")",
"{",
"Date",
"result",
"=",
"null",
";",
"if",
"(",
"date",
"!=",
"null",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"date",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"ranges",
"==",
"null",
")",
"{",
"result",
"=",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getDefaultEndTime",
"(",
")",
";",
"result",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"result",
")",
";",
"}",
"else",
"{",
"Date",
"rangeStart",
"=",
"result",
"=",
"ranges",
".",
"getRange",
"(",
"0",
")",
".",
"getStart",
"(",
")",
";",
"Date",
"rangeFinish",
"=",
"ranges",
".",
"getRange",
"(",
"ranges",
".",
"getRangeCount",
"(",
")",
"-",
"1",
")",
".",
"getEnd",
"(",
")",
";",
"Date",
"startDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeStart",
")",
";",
"Date",
"finishDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeFinish",
")",
";",
"result",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"rangeFinish",
")",
";",
"//",
"// Handle the case where the end of the range is at midnight -",
"// this will show up as the start and end days not matching",
"//",
"if",
"(",
"startDay",
"!=",
"null",
"&&",
"finishDay",
"!=",
"null",
"&&",
"startDay",
".",
"getTime",
"(",
")",
"!=",
"finishDay",
".",
"getTime",
"(",
")",
")",
"{",
"result",
"=",
"DateHelper",
".",
"addDays",
"(",
"result",
",",
"1",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Retrieves the time at which work finishes on the given date, or returns
null if this is a non-working day.
@param date Date instance
@return finish time, or null for non-working day
|
[
"Retrieves",
"the",
"time",
"at",
"which",
"work",
"finishes",
"on",
"the",
"given",
"date",
"or",
"returns",
"null",
"if",
"this",
"is",
"a",
"non",
"-",
"working",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L384-L416
|
157,143
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.updateToNextWorkStart
|
private void updateToNextWorkStart(Calendar cal)
{
Date originalDate = cal.getTime();
//
// Find the date ranges for the current day
//
ProjectCalendarDateRanges ranges = getRanges(originalDate, cal, null);
if (ranges != null)
{
//
// Do we have a start time today?
//
Date calTime = DateHelper.getCanonicalTime(cal.getTime());
Date startTime = null;
for (DateRange range : ranges)
{
Date rangeStart = DateHelper.getCanonicalTime(range.getStart());
Date rangeEnd = DateHelper.getCanonicalTime(range.getEnd());
Date rangeStartDay = DateHelper.getDayStartDate(range.getStart());
Date rangeEndDay = DateHelper.getDayStartDate(range.getEnd());
if (rangeStartDay.getTime() != rangeEndDay.getTime())
{
rangeEnd = DateHelper.addDays(rangeEnd, 1);
}
if (calTime.getTime() < rangeEnd.getTime())
{
if (calTime.getTime() > rangeStart.getTime())
{
startTime = calTime;
}
else
{
startTime = rangeStart;
}
break;
}
}
//
// If we don't have a start time today - find the next working day
// then retrieve the start time.
//
if (startTime == null)
{
Day day;
int nonWorkingDayCount = 0;
do
{
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
++nonWorkingDayCount;
if (nonWorkingDayCount > MAX_NONWORKING_DAYS)
{
cal.setTime(originalDate);
break;
}
}
while (!isWorkingDate(cal.getTime(), day));
startTime = getStartTime(cal.getTime());
}
DateHelper.setTime(cal, startTime);
}
}
|
java
|
private void updateToNextWorkStart(Calendar cal)
{
Date originalDate = cal.getTime();
//
// Find the date ranges for the current day
//
ProjectCalendarDateRanges ranges = getRanges(originalDate, cal, null);
if (ranges != null)
{
//
// Do we have a start time today?
//
Date calTime = DateHelper.getCanonicalTime(cal.getTime());
Date startTime = null;
for (DateRange range : ranges)
{
Date rangeStart = DateHelper.getCanonicalTime(range.getStart());
Date rangeEnd = DateHelper.getCanonicalTime(range.getEnd());
Date rangeStartDay = DateHelper.getDayStartDate(range.getStart());
Date rangeEndDay = DateHelper.getDayStartDate(range.getEnd());
if (rangeStartDay.getTime() != rangeEndDay.getTime())
{
rangeEnd = DateHelper.addDays(rangeEnd, 1);
}
if (calTime.getTime() < rangeEnd.getTime())
{
if (calTime.getTime() > rangeStart.getTime())
{
startTime = calTime;
}
else
{
startTime = rangeStart;
}
break;
}
}
//
// If we don't have a start time today - find the next working day
// then retrieve the start time.
//
if (startTime == null)
{
Day day;
int nonWorkingDayCount = 0;
do
{
cal.set(Calendar.DAY_OF_YEAR, cal.get(Calendar.DAY_OF_YEAR) + 1);
day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
++nonWorkingDayCount;
if (nonWorkingDayCount > MAX_NONWORKING_DAYS)
{
cal.setTime(originalDate);
break;
}
}
while (!isWorkingDate(cal.getTime(), day));
startTime = getStartTime(cal.getTime());
}
DateHelper.setTime(cal, startTime);
}
}
|
[
"private",
"void",
"updateToNextWorkStart",
"(",
"Calendar",
"cal",
")",
"{",
"Date",
"originalDate",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"//",
"// Find the date ranges for the current day",
"//",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"originalDate",
",",
"cal",
",",
"null",
")",
";",
"if",
"(",
"ranges",
"!=",
"null",
")",
"{",
"//",
"// Do we have a start time today?",
"//",
"Date",
"calTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"cal",
".",
"getTime",
"(",
")",
")",
";",
"Date",
"startTime",
"=",
"null",
";",
"for",
"(",
"DateRange",
"range",
":",
"ranges",
")",
"{",
"Date",
"rangeStart",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"range",
".",
"getStart",
"(",
")",
")",
";",
"Date",
"rangeEnd",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"range",
".",
"getEnd",
"(",
")",
")",
";",
"Date",
"rangeStartDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"range",
".",
"getStart",
"(",
")",
")",
";",
"Date",
"rangeEndDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"range",
".",
"getEnd",
"(",
")",
")",
";",
"if",
"(",
"rangeStartDay",
".",
"getTime",
"(",
")",
"!=",
"rangeEndDay",
".",
"getTime",
"(",
")",
")",
"{",
"rangeEnd",
"=",
"DateHelper",
".",
"addDays",
"(",
"rangeEnd",
",",
"1",
")",
";",
"}",
"if",
"(",
"calTime",
".",
"getTime",
"(",
")",
"<",
"rangeEnd",
".",
"getTime",
"(",
")",
")",
"{",
"if",
"(",
"calTime",
".",
"getTime",
"(",
")",
">",
"rangeStart",
".",
"getTime",
"(",
")",
")",
"{",
"startTime",
"=",
"calTime",
";",
"}",
"else",
"{",
"startTime",
"=",
"rangeStart",
";",
"}",
"break",
";",
"}",
"}",
"//",
"// If we don't have a start time today - find the next working day",
"// then retrieve the start time.",
"//",
"if",
"(",
"startTime",
"==",
"null",
")",
"{",
"Day",
"day",
";",
"int",
"nonWorkingDayCount",
"=",
"0",
";",
"do",
"{",
"cal",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
"+",
"1",
")",
";",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
")",
";",
"++",
"nonWorkingDayCount",
";",
"if",
"(",
"nonWorkingDayCount",
">",
"MAX_NONWORKING_DAYS",
")",
"{",
"cal",
".",
"setTime",
"(",
"originalDate",
")",
";",
"break",
";",
"}",
"}",
"while",
"(",
"!",
"isWorkingDate",
"(",
"cal",
".",
"getTime",
"(",
")",
",",
"day",
")",
")",
";",
"startTime",
"=",
"getStartTime",
"(",
"cal",
".",
"getTime",
"(",
")",
")",
";",
"}",
"DateHelper",
".",
"setTime",
"(",
"cal",
",",
"startTime",
")",
";",
"}",
"}"
] |
This method finds the start of the next working period.
@param cal current Calendar instance
|
[
"This",
"method",
"finds",
"the",
"start",
"of",
"the",
"next",
"working",
"period",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L770-L838
|
157,144
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getNextWorkStart
|
public Date getNextWorkStart(Date date)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
updateToNextWorkStart(cal);
return cal.getTime();
}
|
java
|
public Date getNextWorkStart(Date date)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
updateToNextWorkStart(cal);
return cal.getTime();
}
|
[
"public",
"Date",
"getNextWorkStart",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"date",
")",
";",
"updateToNextWorkStart",
"(",
"cal",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] |
Utility method to retrieve the next working date start time, given
a date and time as a starting point.
@param date date and time start point
@return date and time of next work start
|
[
"Utility",
"method",
"to",
"retrieve",
"the",
"next",
"working",
"date",
"start",
"time",
"given",
"a",
"date",
"and",
"time",
"as",
"a",
"starting",
"point",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L913-L919
|
157,145
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getPreviousWorkFinish
|
public Date getPreviousWorkFinish(Date date)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
updateToPreviousWorkFinish(cal);
return cal.getTime();
}
|
java
|
public Date getPreviousWorkFinish(Date date)
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
updateToPreviousWorkFinish(cal);
return cal.getTime();
}
|
[
"public",
"Date",
"getPreviousWorkFinish",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"date",
")",
";",
"updateToPreviousWorkFinish",
"(",
"cal",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] |
Utility method to retrieve the previous working date finish time, given
a date and time as a starting point.
@param date date and time start point
@return date and time of previous work finish
|
[
"Utility",
"method",
"to",
"retrieve",
"the",
"previous",
"working",
"date",
"finish",
"time",
"given",
"a",
"date",
"and",
"time",
"as",
"a",
"starting",
"point",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L928-L934
|
157,146
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.isWorkingDate
|
public boolean isWorkingDate(Date date)
{
Calendar cal = DateHelper.popCalendar(date);
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
DateHelper.pushCalendar(cal);
return isWorkingDate(date, day);
}
|
java
|
public boolean isWorkingDate(Date date)
{
Calendar cal = DateHelper.popCalendar(date);
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
DateHelper.pushCalendar(cal);
return isWorkingDate(date, day);
}
|
[
"public",
"boolean",
"isWorkingDate",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"date",
")",
";",
"Day",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"return",
"isWorkingDate",
"(",
"date",
",",
"day",
")",
";",
"}"
] |
This method allows the caller to determine if a given date is a
working day. This method takes account of calendar exceptions.
@param date Date to be tested
@return boolean value
|
[
"This",
"method",
"allows",
"the",
"caller",
"to",
"determine",
"if",
"a",
"given",
"date",
"is",
"a",
"working",
"day",
".",
"This",
"method",
"takes",
"account",
"of",
"calendar",
"exceptions",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L943-L949
|
157,147
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.isWorkingDate
|
private boolean isWorkingDate(Date date, Day day)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, day);
return ranges.getRangeCount() != 0;
}
|
java
|
private boolean isWorkingDate(Date date, Day day)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, day);
return ranges.getRangeCount() != 0;
}
|
[
"private",
"boolean",
"isWorkingDate",
"(",
"Date",
"date",
",",
"Day",
"day",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"date",
",",
"null",
",",
"day",
")",
";",
"return",
"ranges",
".",
"getRangeCount",
"(",
")",
"!=",
"0",
";",
"}"
] |
This private method allows the caller to determine if a given date is a
working day. This method takes account of calendar exceptions. It assumes
that the caller has already calculated the day of the week on which
the given day falls.
@param date Date to be tested
@param day Day of the week for the date under test
@return boolean flag
|
[
"This",
"private",
"method",
"allows",
"the",
"caller",
"to",
"determine",
"if",
"a",
"given",
"date",
"is",
"a",
"working",
"day",
".",
"This",
"method",
"takes",
"account",
"of",
"calendar",
"exceptions",
".",
"It",
"assumes",
"that",
"the",
"caller",
"has",
"already",
"calculated",
"the",
"day",
"of",
"the",
"week",
"on",
"which",
"the",
"given",
"day",
"falls",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L961-L965
|
157,148
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getDaysInRange
|
private int getDaysInRange(Date startDate, Date endDate)
{
int result;
Calendar cal = DateHelper.popCalendar(endDate);
int endDateYear = cal.get(Calendar.YEAR);
int endDateDayOfYear = cal.get(Calendar.DAY_OF_YEAR);
cal.setTime(startDate);
if (endDateYear == cal.get(Calendar.YEAR))
{
result = (endDateDayOfYear - cal.get(Calendar.DAY_OF_YEAR)) + 1;
}
else
{
result = 0;
do
{
result += (cal.getActualMaximum(Calendar.DAY_OF_YEAR) - cal.get(Calendar.DAY_OF_YEAR)) + 1;
cal.roll(Calendar.YEAR, 1);
cal.set(Calendar.DAY_OF_YEAR, 1);
}
while (cal.get(Calendar.YEAR) < endDateYear);
result += endDateDayOfYear;
}
DateHelper.pushCalendar(cal);
return result;
}
|
java
|
private int getDaysInRange(Date startDate, Date endDate)
{
int result;
Calendar cal = DateHelper.popCalendar(endDate);
int endDateYear = cal.get(Calendar.YEAR);
int endDateDayOfYear = cal.get(Calendar.DAY_OF_YEAR);
cal.setTime(startDate);
if (endDateYear == cal.get(Calendar.YEAR))
{
result = (endDateDayOfYear - cal.get(Calendar.DAY_OF_YEAR)) + 1;
}
else
{
result = 0;
do
{
result += (cal.getActualMaximum(Calendar.DAY_OF_YEAR) - cal.get(Calendar.DAY_OF_YEAR)) + 1;
cal.roll(Calendar.YEAR, 1);
cal.set(Calendar.DAY_OF_YEAR, 1);
}
while (cal.get(Calendar.YEAR) < endDateYear);
result += endDateDayOfYear;
}
DateHelper.pushCalendar(cal);
return result;
}
|
[
"private",
"int",
"getDaysInRange",
"(",
"Date",
"startDate",
",",
"Date",
"endDate",
")",
"{",
"int",
"result",
";",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"endDate",
")",
";",
"int",
"endDateYear",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"int",
"endDateDayOfYear",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
";",
"cal",
".",
"setTime",
"(",
"startDate",
")",
";",
"if",
"(",
"endDateYear",
"==",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
")",
"{",
"result",
"=",
"(",
"endDateDayOfYear",
"-",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
")",
"+",
"1",
";",
"}",
"else",
"{",
"result",
"=",
"0",
";",
"do",
"{",
"result",
"+=",
"(",
"cal",
".",
"getActualMaximum",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
"-",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
")",
")",
"+",
"1",
";",
"cal",
".",
"roll",
"(",
"Calendar",
".",
"YEAR",
",",
"1",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"1",
")",
";",
"}",
"while",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"<",
"endDateYear",
")",
";",
"result",
"+=",
"endDateDayOfYear",
";",
"}",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"return",
"result",
";",
"}"
] |
This method calculates the absolute number of days between two dates.
Note that where two date objects are provided that fall on the same
day, this method will return one not zero. Note also that this method
assumes that the dates are passed in the correct order, i.e.
startDate < endDate.
@param startDate Start date
@param endDate End date
@return number of days in the date range
|
[
"This",
"method",
"calculates",
"the",
"absolute",
"number",
"of",
"days",
"between",
"two",
"dates",
".",
"Note",
"that",
"where",
"two",
"date",
"objects",
"are",
"provided",
"that",
"fall",
"on",
"the",
"same",
"day",
"this",
"method",
"will",
"return",
"one",
"not",
"zero",
".",
"Note",
"also",
"that",
"this",
"method",
"assumes",
"that",
"the",
"dates",
"are",
"passed",
"in",
"the",
"correct",
"order",
"i",
".",
"e",
".",
"startDate",
"<",
"endDate",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L978-L1006
|
157,149
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.setUniqueID
|
@Override public void setUniqueID(Integer uniqueID)
{
ProjectFile parent = getParentFile();
if (m_uniqueID != null)
{
parent.getCalendars().unmapUniqueID(m_uniqueID);
}
parent.getCalendars().mapUniqueID(uniqueID, this);
m_uniqueID = uniqueID;
}
|
java
|
@Override public void setUniqueID(Integer uniqueID)
{
ProjectFile parent = getParentFile();
if (m_uniqueID != null)
{
parent.getCalendars().unmapUniqueID(m_uniqueID);
}
parent.getCalendars().mapUniqueID(uniqueID, this);
m_uniqueID = uniqueID;
}
|
[
"@",
"Override",
"public",
"void",
"setUniqueID",
"(",
"Integer",
"uniqueID",
")",
"{",
"ProjectFile",
"parent",
"=",
"getParentFile",
"(",
")",
";",
"if",
"(",
"m_uniqueID",
"!=",
"null",
")",
"{",
"parent",
".",
"getCalendars",
"(",
")",
".",
"unmapUniqueID",
"(",
"m_uniqueID",
")",
";",
"}",
"parent",
".",
"getCalendars",
"(",
")",
".",
"mapUniqueID",
"(",
"uniqueID",
",",
"this",
")",
";",
"m_uniqueID",
"=",
"uniqueID",
";",
"}"
] |
Modifier method to set the unique ID of this calendar.
@param uniqueID unique identifier
|
[
"Modifier",
"method",
"to",
"set",
"the",
"unique",
"ID",
"of",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1013-L1025
|
157,150
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.setResource
|
public void setResource(Resource resource)
{
m_resource = resource;
String name = m_resource.getName();
if (name == null || name.length() == 0)
{
name = "Unnamed Resource";
}
setName(name);
}
|
java
|
public void setResource(Resource resource)
{
m_resource = resource;
String name = m_resource.getName();
if (name == null || name.length() == 0)
{
name = "Unnamed Resource";
}
setName(name);
}
|
[
"public",
"void",
"setResource",
"(",
"Resource",
"resource",
")",
"{",
"m_resource",
"=",
"resource",
";",
"String",
"name",
"=",
"m_resource",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"name",
"=",
"\"Unnamed Resource\"",
";",
"}",
"setName",
"(",
"name",
")",
";",
"}"
] |
Sets the resource to which this calendar is linked. Note that this
method updates the calendar's name to be the same as the resource name.
If the resource does not yet have a name, then the calendar is given
a default name.
@param resource resource instance
|
[
"Sets",
"the",
"resource",
"to",
"which",
"this",
"calendar",
"is",
"linked",
".",
"Note",
"that",
"this",
"method",
"updates",
"the",
"calendar",
"s",
"name",
"to",
"be",
"the",
"same",
"as",
"the",
"resource",
"name",
".",
"If",
"the",
"resource",
"does",
"not",
"yet",
"have",
"a",
"name",
"then",
"the",
"calendar",
"is",
"given",
"a",
"default",
"name",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1055-L1064
|
157,151
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getException
|
public ProjectCalendarException getException(Date date)
{
ProjectCalendarException exception = null;
// We're working with expanded exceptions, which includes any recurring exceptions
// expanded into individual entries.
populateExpandedExceptions();
if (!m_expandedExceptions.isEmpty())
{
sortExceptions();
int low = 0;
int high = m_expandedExceptions.size() - 1;
long targetDate = date.getTime();
while (low <= high)
{
int mid = (low + high) >>> 1;
ProjectCalendarException midVal = m_expandedExceptions.get(mid);
int cmp = 0 - DateHelper.compare(midVal.getFromDate(), midVal.getToDate(), targetDate);
if (cmp < 0)
{
low = mid + 1;
}
else
{
if (cmp > 0)
{
high = mid - 1;
}
else
{
exception = midVal;
break;
}
}
}
}
if (exception == null && getParent() != null)
{
// Check base calendar as well for an exception.
exception = getParent().getException(date);
}
return (exception);
}
|
java
|
public ProjectCalendarException getException(Date date)
{
ProjectCalendarException exception = null;
// We're working with expanded exceptions, which includes any recurring exceptions
// expanded into individual entries.
populateExpandedExceptions();
if (!m_expandedExceptions.isEmpty())
{
sortExceptions();
int low = 0;
int high = m_expandedExceptions.size() - 1;
long targetDate = date.getTime();
while (low <= high)
{
int mid = (low + high) >>> 1;
ProjectCalendarException midVal = m_expandedExceptions.get(mid);
int cmp = 0 - DateHelper.compare(midVal.getFromDate(), midVal.getToDate(), targetDate);
if (cmp < 0)
{
low = mid + 1;
}
else
{
if (cmp > 0)
{
high = mid - 1;
}
else
{
exception = midVal;
break;
}
}
}
}
if (exception == null && getParent() != null)
{
// Check base calendar as well for an exception.
exception = getParent().getException(date);
}
return (exception);
}
|
[
"public",
"ProjectCalendarException",
"getException",
"(",
"Date",
"date",
")",
"{",
"ProjectCalendarException",
"exception",
"=",
"null",
";",
"// We're working with expanded exceptions, which includes any recurring exceptions",
"// expanded into individual entries.",
"populateExpandedExceptions",
"(",
")",
";",
"if",
"(",
"!",
"m_expandedExceptions",
".",
"isEmpty",
"(",
")",
")",
"{",
"sortExceptions",
"(",
")",
";",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"m_expandedExceptions",
".",
"size",
"(",
")",
"-",
"1",
";",
"long",
"targetDate",
"=",
"date",
".",
"getTime",
"(",
")",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"int",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
">>>",
"1",
";",
"ProjectCalendarException",
"midVal",
"=",
"m_expandedExceptions",
".",
"get",
"(",
"mid",
")",
";",
"int",
"cmp",
"=",
"0",
"-",
"DateHelper",
".",
"compare",
"(",
"midVal",
".",
"getFromDate",
"(",
")",
",",
"midVal",
".",
"getToDate",
"(",
")",
",",
"targetDate",
")",
";",
"if",
"(",
"cmp",
"<",
"0",
")",
"{",
"low",
"=",
"mid",
"+",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"cmp",
">",
"0",
")",
"{",
"high",
"=",
"mid",
"-",
"1",
";",
"}",
"else",
"{",
"exception",
"=",
"midVal",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"exception",
"==",
"null",
"&&",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"// Check base calendar as well for an exception.",
"exception",
"=",
"getParent",
"(",
")",
".",
"getException",
"(",
"date",
")",
";",
"}",
"return",
"(",
"exception",
")",
";",
"}"
] |
Retrieve a calendar exception which applies to this date.
@param date target date
@return calendar exception, or null if none match this date
|
[
"Retrieve",
"a",
"calendar",
"exception",
"which",
"applies",
"to",
"this",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1080-L1126
|
157,152
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getWorkWeek
|
public ProjectCalendarWeek getWorkWeek(Date date)
{
ProjectCalendarWeek week = null;
if (!m_workWeeks.isEmpty())
{
sortWorkWeeks();
int low = 0;
int high = m_workWeeks.size() - 1;
long targetDate = date.getTime();
while (low <= high)
{
int mid = (low + high) >>> 1;
ProjectCalendarWeek midVal = m_workWeeks.get(mid);
int cmp = 0 - DateHelper.compare(midVal.getDateRange().getStart(), midVal.getDateRange().getEnd(), targetDate);
if (cmp < 0)
{
low = mid + 1;
}
else
{
if (cmp > 0)
{
high = mid - 1;
}
else
{
week = midVal;
break;
}
}
}
}
if (week == null && getParent() != null)
{
// Check base calendar as well for a work week.
week = getParent().getWorkWeek(date);
}
return (week);
}
|
java
|
public ProjectCalendarWeek getWorkWeek(Date date)
{
ProjectCalendarWeek week = null;
if (!m_workWeeks.isEmpty())
{
sortWorkWeeks();
int low = 0;
int high = m_workWeeks.size() - 1;
long targetDate = date.getTime();
while (low <= high)
{
int mid = (low + high) >>> 1;
ProjectCalendarWeek midVal = m_workWeeks.get(mid);
int cmp = 0 - DateHelper.compare(midVal.getDateRange().getStart(), midVal.getDateRange().getEnd(), targetDate);
if (cmp < 0)
{
low = mid + 1;
}
else
{
if (cmp > 0)
{
high = mid - 1;
}
else
{
week = midVal;
break;
}
}
}
}
if (week == null && getParent() != null)
{
// Check base calendar as well for a work week.
week = getParent().getWorkWeek(date);
}
return (week);
}
|
[
"public",
"ProjectCalendarWeek",
"getWorkWeek",
"(",
"Date",
"date",
")",
"{",
"ProjectCalendarWeek",
"week",
"=",
"null",
";",
"if",
"(",
"!",
"m_workWeeks",
".",
"isEmpty",
"(",
")",
")",
"{",
"sortWorkWeeks",
"(",
")",
";",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"m_workWeeks",
".",
"size",
"(",
")",
"-",
"1",
";",
"long",
"targetDate",
"=",
"date",
".",
"getTime",
"(",
")",
";",
"while",
"(",
"low",
"<=",
"high",
")",
"{",
"int",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
">>>",
"1",
";",
"ProjectCalendarWeek",
"midVal",
"=",
"m_workWeeks",
".",
"get",
"(",
"mid",
")",
";",
"int",
"cmp",
"=",
"0",
"-",
"DateHelper",
".",
"compare",
"(",
"midVal",
".",
"getDateRange",
"(",
")",
".",
"getStart",
"(",
")",
",",
"midVal",
".",
"getDateRange",
"(",
")",
".",
"getEnd",
"(",
")",
",",
"targetDate",
")",
";",
"if",
"(",
"cmp",
"<",
"0",
")",
"{",
"low",
"=",
"mid",
"+",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"cmp",
">",
"0",
")",
"{",
"high",
"=",
"mid",
"-",
"1",
";",
"}",
"else",
"{",
"week",
"=",
"midVal",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"week",
"==",
"null",
"&&",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"// Check base calendar as well for a work week.",
"week",
"=",
"getParent",
"(",
")",
".",
"getWorkWeek",
"(",
"date",
")",
";",
"}",
"return",
"(",
"week",
")",
";",
"}"
] |
Retrieve a work week which applies to this date.
@param date target date
@return work week, or null if none match this date
|
[
"Retrieve",
"a",
"work",
"week",
"which",
"applies",
"to",
"this",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1134-L1176
|
157,153
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getWork
|
public Duration getWork(Date date, TimeUnit format)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
long time = getTotalTime(ranges);
return convertFormat(time, format);
}
|
java
|
public Duration getWork(Date date, TimeUnit format)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, null);
long time = getTotalTime(ranges);
return convertFormat(time, format);
}
|
[
"public",
"Duration",
"getWork",
"(",
"Date",
"date",
",",
"TimeUnit",
"format",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"date",
",",
"null",
",",
"null",
")",
";",
"long",
"time",
"=",
"getTotalTime",
"(",
"ranges",
")",
";",
"return",
"convertFormat",
"(",
"time",
",",
"format",
")",
";",
"}"
] |
Retrieves the amount of work on a given day, and
returns it in the specified format.
@param date target date
@param format required format
@return work duration
|
[
"Retrieves",
"the",
"amount",
"of",
"work",
"on",
"a",
"given",
"day",
"and",
"returns",
"it",
"in",
"the",
"specified",
"format",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1186-L1191
|
157,154
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getWork
|
public Duration getWork(Date startDate, Date endDate, TimeUnit format)
{
DateRange range = new DateRange(startDate, endDate);
Long cachedResult = m_workingDateCache.get(range);
long totalTime = 0;
if (cachedResult == null)
{
//
// We want the start date to be the earliest date, and the end date
// to be the latest date. Set a flag here to indicate if we have swapped
// the order of the supplied date.
//
boolean invert = false;
if (startDate.getTime() > endDate.getTime())
{
invert = true;
Date temp = startDate;
startDate = endDate;
endDate = temp;
}
Date canonicalStartDate = DateHelper.getDayStartDate(startDate);
Date canonicalEndDate = DateHelper.getDayStartDate(endDate);
if (canonicalStartDate.getTime() == canonicalEndDate.getTime())
{
ProjectCalendarDateRanges ranges = getRanges(startDate, null, null);
if (ranges.getRangeCount() != 0)
{
totalTime = getTotalTime(ranges, startDate, endDate);
}
}
else
{
//
// Find the first working day in the range
//
Date currentDate = startDate;
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (isWorkingDate(currentDate, day) == false && currentDate.getTime() < canonicalEndDate.getTime())
{
cal.add(Calendar.DAY_OF_YEAR, 1);
currentDate = cal.getTime();
day = day.getNextDay();
}
if (currentDate.getTime() < canonicalEndDate.getTime())
{
//
// Calculate the amount of working time for this day
//
totalTime += getTotalTime(getRanges(currentDate, null, day), currentDate, true);
//
// Process each working day until we reach the last day
//
while (true)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
currentDate = cal.getTime();
day = day.getNextDay();
//
// We have reached the last day
//
if (currentDate.getTime() >= canonicalEndDate.getTime())
{
break;
}
//
// Skip this day if it has no working time
//
ProjectCalendarDateRanges ranges = getRanges(currentDate, null, day);
if (ranges.getRangeCount() == 0)
{
continue;
}
//
// Add the working time for the whole day
//
totalTime += getTotalTime(ranges);
}
}
//
// We are now at the last day
//
ProjectCalendarDateRanges ranges = getRanges(endDate, null, day);
if (ranges.getRangeCount() != 0)
{
totalTime += getTotalTime(ranges, DateHelper.getDayStartDate(endDate), endDate);
}
}
if (invert)
{
totalTime = -totalTime;
}
m_workingDateCache.put(range, Long.valueOf(totalTime));
}
else
{
totalTime = cachedResult.longValue();
}
return convertFormat(totalTime, format);
}
|
java
|
public Duration getWork(Date startDate, Date endDate, TimeUnit format)
{
DateRange range = new DateRange(startDate, endDate);
Long cachedResult = m_workingDateCache.get(range);
long totalTime = 0;
if (cachedResult == null)
{
//
// We want the start date to be the earliest date, and the end date
// to be the latest date. Set a flag here to indicate if we have swapped
// the order of the supplied date.
//
boolean invert = false;
if (startDate.getTime() > endDate.getTime())
{
invert = true;
Date temp = startDate;
startDate = endDate;
endDate = temp;
}
Date canonicalStartDate = DateHelper.getDayStartDate(startDate);
Date canonicalEndDate = DateHelper.getDayStartDate(endDate);
if (canonicalStartDate.getTime() == canonicalEndDate.getTime())
{
ProjectCalendarDateRanges ranges = getRanges(startDate, null, null);
if (ranges.getRangeCount() != 0)
{
totalTime = getTotalTime(ranges, startDate, endDate);
}
}
else
{
//
// Find the first working day in the range
//
Date currentDate = startDate;
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
Day day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
while (isWorkingDate(currentDate, day) == false && currentDate.getTime() < canonicalEndDate.getTime())
{
cal.add(Calendar.DAY_OF_YEAR, 1);
currentDate = cal.getTime();
day = day.getNextDay();
}
if (currentDate.getTime() < canonicalEndDate.getTime())
{
//
// Calculate the amount of working time for this day
//
totalTime += getTotalTime(getRanges(currentDate, null, day), currentDate, true);
//
// Process each working day until we reach the last day
//
while (true)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
currentDate = cal.getTime();
day = day.getNextDay();
//
// We have reached the last day
//
if (currentDate.getTime() >= canonicalEndDate.getTime())
{
break;
}
//
// Skip this day if it has no working time
//
ProjectCalendarDateRanges ranges = getRanges(currentDate, null, day);
if (ranges.getRangeCount() == 0)
{
continue;
}
//
// Add the working time for the whole day
//
totalTime += getTotalTime(ranges);
}
}
//
// We are now at the last day
//
ProjectCalendarDateRanges ranges = getRanges(endDate, null, day);
if (ranges.getRangeCount() != 0)
{
totalTime += getTotalTime(ranges, DateHelper.getDayStartDate(endDate), endDate);
}
}
if (invert)
{
totalTime = -totalTime;
}
m_workingDateCache.put(range, Long.valueOf(totalTime));
}
else
{
totalTime = cachedResult.longValue();
}
return convertFormat(totalTime, format);
}
|
[
"public",
"Duration",
"getWork",
"(",
"Date",
"startDate",
",",
"Date",
"endDate",
",",
"TimeUnit",
"format",
")",
"{",
"DateRange",
"range",
"=",
"new",
"DateRange",
"(",
"startDate",
",",
"endDate",
")",
";",
"Long",
"cachedResult",
"=",
"m_workingDateCache",
".",
"get",
"(",
"range",
")",
";",
"long",
"totalTime",
"=",
"0",
";",
"if",
"(",
"cachedResult",
"==",
"null",
")",
"{",
"//",
"// We want the start date to be the earliest date, and the end date",
"// to be the latest date. Set a flag here to indicate if we have swapped",
"// the order of the supplied date.",
"//",
"boolean",
"invert",
"=",
"false",
";",
"if",
"(",
"startDate",
".",
"getTime",
"(",
")",
">",
"endDate",
".",
"getTime",
"(",
")",
")",
"{",
"invert",
"=",
"true",
";",
"Date",
"temp",
"=",
"startDate",
";",
"startDate",
"=",
"endDate",
";",
"endDate",
"=",
"temp",
";",
"}",
"Date",
"canonicalStartDate",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"startDate",
")",
";",
"Date",
"canonicalEndDate",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"endDate",
")",
";",
"if",
"(",
"canonicalStartDate",
".",
"getTime",
"(",
")",
"==",
"canonicalEndDate",
".",
"getTime",
"(",
")",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"startDate",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"ranges",
".",
"getRangeCount",
"(",
")",
"!=",
"0",
")",
"{",
"totalTime",
"=",
"getTotalTime",
"(",
"ranges",
",",
"startDate",
",",
"endDate",
")",
";",
"}",
"}",
"else",
"{",
"//",
"// Find the first working day in the range",
"//",
"Date",
"currentDate",
"=",
"startDate",
";",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"startDate",
")",
";",
"Day",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
")",
";",
"while",
"(",
"isWorkingDate",
"(",
"currentDate",
",",
"day",
")",
"==",
"false",
"&&",
"currentDate",
".",
"getTime",
"(",
")",
"<",
"canonicalEndDate",
".",
"getTime",
"(",
")",
")",
"{",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"1",
")",
";",
"currentDate",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"day",
"=",
"day",
".",
"getNextDay",
"(",
")",
";",
"}",
"if",
"(",
"currentDate",
".",
"getTime",
"(",
")",
"<",
"canonicalEndDate",
".",
"getTime",
"(",
")",
")",
"{",
"//",
"// Calculate the amount of working time for this day",
"//",
"totalTime",
"+=",
"getTotalTime",
"(",
"getRanges",
"(",
"currentDate",
",",
"null",
",",
"day",
")",
",",
"currentDate",
",",
"true",
")",
";",
"//",
"// Process each working day until we reach the last day",
"//",
"while",
"(",
"true",
")",
"{",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"1",
")",
";",
"currentDate",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"day",
"=",
"day",
".",
"getNextDay",
"(",
")",
";",
"//",
"// We have reached the last day",
"//",
"if",
"(",
"currentDate",
".",
"getTime",
"(",
")",
">=",
"canonicalEndDate",
".",
"getTime",
"(",
")",
")",
"{",
"break",
";",
"}",
"//",
"// Skip this day if it has no working time",
"//",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"currentDate",
",",
"null",
",",
"day",
")",
";",
"if",
"(",
"ranges",
".",
"getRangeCount",
"(",
")",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"//",
"// Add the working time for the whole day",
"//",
"totalTime",
"+=",
"getTotalTime",
"(",
"ranges",
")",
";",
"}",
"}",
"//",
"// We are now at the last day",
"//",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"endDate",
",",
"null",
",",
"day",
")",
";",
"if",
"(",
"ranges",
".",
"getRangeCount",
"(",
")",
"!=",
"0",
")",
"{",
"totalTime",
"+=",
"getTotalTime",
"(",
"ranges",
",",
"DateHelper",
".",
"getDayStartDate",
"(",
"endDate",
")",
",",
"endDate",
")",
";",
"}",
"}",
"if",
"(",
"invert",
")",
"{",
"totalTime",
"=",
"-",
"totalTime",
";",
"}",
"m_workingDateCache",
".",
"put",
"(",
"range",
",",
"Long",
".",
"valueOf",
"(",
"totalTime",
")",
")",
";",
"}",
"else",
"{",
"totalTime",
"=",
"cachedResult",
".",
"longValue",
"(",
")",
";",
"}",
"return",
"convertFormat",
"(",
"totalTime",
",",
"format",
")",
";",
"}"
] |
This method retrieves a Duration instance representing the amount of
work between two dates based on this calendar.
@param startDate start date
@param endDate end date
@param format required duration format
@return amount of work
|
[
"This",
"method",
"retrieves",
"a",
"Duration",
"instance",
"representing",
"the",
"amount",
"of",
"work",
"between",
"two",
"dates",
"based",
"on",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1202-L1314
|
157,155
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.convertFormat
|
private Duration convertFormat(long totalTime, TimeUnit format)
{
double duration = totalTime;
switch (format)
{
case MINUTES:
case ELAPSED_MINUTES:
{
duration /= (60 * 1000);
break;
}
case HOURS:
case ELAPSED_HOURS:
{
duration /= (60 * 60 * 1000);
break;
}
case DAYS:
{
double minutesPerDay = getMinutesPerDay();
if (minutesPerDay != 0)
{
duration /= (minutesPerDay * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case WEEKS:
{
double minutesPerWeek = getMinutesPerWeek();
if (minutesPerWeek != 0)
{
duration /= (minutesPerWeek * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case MONTHS:
{
double daysPerMonth = getParentFile().getProjectProperties().getDaysPerMonth().doubleValue();
double minutesPerDay = getMinutesPerDay();
if (daysPerMonth != 0 && minutesPerDay != 0)
{
duration /= (daysPerMonth * minutesPerDay * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case ELAPSED_DAYS:
{
duration /= (24 * 60 * 60 * 1000);
break;
}
case ELAPSED_WEEKS:
{
duration /= (7 * 24 * 60 * 60 * 1000);
break;
}
case ELAPSED_MONTHS:
{
duration /= (30 * 24 * 60 * 60 * 1000);
break;
}
default:
{
throw new IllegalArgumentException("TimeUnit " + format + " not supported");
}
}
return (Duration.getInstance(duration, format));
}
|
java
|
private Duration convertFormat(long totalTime, TimeUnit format)
{
double duration = totalTime;
switch (format)
{
case MINUTES:
case ELAPSED_MINUTES:
{
duration /= (60 * 1000);
break;
}
case HOURS:
case ELAPSED_HOURS:
{
duration /= (60 * 60 * 1000);
break;
}
case DAYS:
{
double minutesPerDay = getMinutesPerDay();
if (minutesPerDay != 0)
{
duration /= (minutesPerDay * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case WEEKS:
{
double minutesPerWeek = getMinutesPerWeek();
if (minutesPerWeek != 0)
{
duration /= (minutesPerWeek * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case MONTHS:
{
double daysPerMonth = getParentFile().getProjectProperties().getDaysPerMonth().doubleValue();
double minutesPerDay = getMinutesPerDay();
if (daysPerMonth != 0 && minutesPerDay != 0)
{
duration /= (daysPerMonth * minutesPerDay * 60 * 1000);
}
else
{
duration = 0;
}
break;
}
case ELAPSED_DAYS:
{
duration /= (24 * 60 * 60 * 1000);
break;
}
case ELAPSED_WEEKS:
{
duration /= (7 * 24 * 60 * 60 * 1000);
break;
}
case ELAPSED_MONTHS:
{
duration /= (30 * 24 * 60 * 60 * 1000);
break;
}
default:
{
throw new IllegalArgumentException("TimeUnit " + format + " not supported");
}
}
return (Duration.getInstance(duration, format));
}
|
[
"private",
"Duration",
"convertFormat",
"(",
"long",
"totalTime",
",",
"TimeUnit",
"format",
")",
"{",
"double",
"duration",
"=",
"totalTime",
";",
"switch",
"(",
"format",
")",
"{",
"case",
"MINUTES",
":",
"case",
"ELAPSED_MINUTES",
":",
"{",
"duration",
"/=",
"(",
"60",
"*",
"1000",
")",
";",
"break",
";",
"}",
"case",
"HOURS",
":",
"case",
"ELAPSED_HOURS",
":",
"{",
"duration",
"/=",
"(",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"break",
";",
"}",
"case",
"DAYS",
":",
"{",
"double",
"minutesPerDay",
"=",
"getMinutesPerDay",
"(",
")",
";",
"if",
"(",
"minutesPerDay",
"!=",
"0",
")",
"{",
"duration",
"/=",
"(",
"minutesPerDay",
"*",
"60",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"duration",
"=",
"0",
";",
"}",
"break",
";",
"}",
"case",
"WEEKS",
":",
"{",
"double",
"minutesPerWeek",
"=",
"getMinutesPerWeek",
"(",
")",
";",
"if",
"(",
"minutesPerWeek",
"!=",
"0",
")",
"{",
"duration",
"/=",
"(",
"minutesPerWeek",
"*",
"60",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"duration",
"=",
"0",
";",
"}",
"break",
";",
"}",
"case",
"MONTHS",
":",
"{",
"double",
"daysPerMonth",
"=",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
".",
"getDaysPerMonth",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"minutesPerDay",
"=",
"getMinutesPerDay",
"(",
")",
";",
"if",
"(",
"daysPerMonth",
"!=",
"0",
"&&",
"minutesPerDay",
"!=",
"0",
")",
"{",
"duration",
"/=",
"(",
"daysPerMonth",
"*",
"minutesPerDay",
"*",
"60",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"duration",
"=",
"0",
";",
"}",
"break",
";",
"}",
"case",
"ELAPSED_DAYS",
":",
"{",
"duration",
"/=",
"(",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_WEEKS",
":",
"{",
"duration",
"/=",
"(",
"7",
"*",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_MONTHS",
":",
"{",
"duration",
"/=",
"(",
"30",
"*",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"TimeUnit \"",
"+",
"format",
"+",
"\" not supported\"",
")",
";",
"}",
"}",
"return",
"(",
"Duration",
".",
"getInstance",
"(",
"duration",
",",
"format",
")",
")",
";",
"}"
] |
Utility method used to convert an integer time representation into a
Duration instance.
@param totalTime integer time representation
@param format required time format
@return new Duration instance
|
[
"Utility",
"method",
"used",
"to",
"convert",
"an",
"integer",
"time",
"representation",
"into",
"a",
"Duration",
"instance",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1324-L1412
|
157,156
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTotalTime
|
private long getTotalTime(ProjectCalendarDateRanges exception, Date date, boolean after)
{
long currentTime = DateHelper.getCanonicalTime(date).getTime();
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd(), currentTime, after);
}
return (total);
}
|
java
|
private long getTotalTime(ProjectCalendarDateRanges exception, Date date, boolean after)
{
long currentTime = DateHelper.getCanonicalTime(date).getTime();
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd(), currentTime, after);
}
return (total);
}
|
[
"private",
"long",
"getTotalTime",
"(",
"ProjectCalendarDateRanges",
"exception",
",",
"Date",
"date",
",",
"boolean",
"after",
")",
"{",
"long",
"currentTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"date",
")",
".",
"getTime",
"(",
")",
";",
"long",
"total",
"=",
"0",
";",
"for",
"(",
"DateRange",
"range",
":",
"exception",
")",
"{",
"total",
"+=",
"getTime",
"(",
"range",
".",
"getStart",
"(",
")",
",",
"range",
".",
"getEnd",
"(",
")",
",",
"currentTime",
",",
"after",
")",
";",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
Retrieves the amount of time represented by a calendar exception
before or after an intersection point.
@param exception calendar exception
@param date intersection time
@param after true to report time after intersection, false to report time before
@return length of time in milliseconds
|
[
"Retrieves",
"the",
"amount",
"of",
"time",
"represented",
"by",
"a",
"calendar",
"exception",
"before",
"or",
"after",
"an",
"intersection",
"point",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1423-L1432
|
157,157
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTotalTime
|
private long getTotalTime(ProjectCalendarDateRanges exception)
{
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd());
}
return (total);
}
|
java
|
private long getTotalTime(ProjectCalendarDateRanges exception)
{
long total = 0;
for (DateRange range : exception)
{
total += getTime(range.getStart(), range.getEnd());
}
return (total);
}
|
[
"private",
"long",
"getTotalTime",
"(",
"ProjectCalendarDateRanges",
"exception",
")",
"{",
"long",
"total",
"=",
"0",
";",
"for",
"(",
"DateRange",
"range",
":",
"exception",
")",
"{",
"total",
"+=",
"getTime",
"(",
"range",
".",
"getStart",
"(",
")",
",",
"range",
".",
"getEnd",
"(",
")",
")",
";",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
Retrieves the amount of working time represented by
a calendar exception.
@param exception calendar exception
@return length of time in milliseconds
|
[
"Retrieves",
"the",
"amount",
"of",
"working",
"time",
"represented",
"by",
"a",
"calendar",
"exception",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1441-L1449
|
157,158
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTotalTime
|
private long getTotalTime(ProjectCalendarDateRanges hours, Date startDate, Date endDate)
{
long total = 0;
if (startDate.getTime() != endDate.getTime())
{
Date start = DateHelper.getCanonicalTime(startDate);
Date end = DateHelper.getCanonicalTime(endDate);
for (DateRange range : hours)
{
Date rangeStart = range.getStart();
Date rangeEnd = range.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Date canoncialRangeStart = DateHelper.getCanonicalTime(rangeStart);
Date canonicalRangeEnd = DateHelper.getCanonicalTime(rangeEnd);
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeEnd);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
canonicalRangeEnd = DateHelper.addDays(canonicalRangeEnd, 1);
}
if (canoncialRangeStart.getTime() == canonicalRangeEnd.getTime() && rangeEnd.getTime() > rangeStart.getTime())
{
total += (24 * 60 * 60 * 1000);
}
else
{
total += getTime(start, end, canoncialRangeStart, canonicalRangeEnd);
}
}
}
}
return (total);
}
|
java
|
private long getTotalTime(ProjectCalendarDateRanges hours, Date startDate, Date endDate)
{
long total = 0;
if (startDate.getTime() != endDate.getTime())
{
Date start = DateHelper.getCanonicalTime(startDate);
Date end = DateHelper.getCanonicalTime(endDate);
for (DateRange range : hours)
{
Date rangeStart = range.getStart();
Date rangeEnd = range.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Date canoncialRangeStart = DateHelper.getCanonicalTime(rangeStart);
Date canonicalRangeEnd = DateHelper.getCanonicalTime(rangeEnd);
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeEnd);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
canonicalRangeEnd = DateHelper.addDays(canonicalRangeEnd, 1);
}
if (canoncialRangeStart.getTime() == canonicalRangeEnd.getTime() && rangeEnd.getTime() > rangeStart.getTime())
{
total += (24 * 60 * 60 * 1000);
}
else
{
total += getTime(start, end, canoncialRangeStart, canonicalRangeEnd);
}
}
}
}
return (total);
}
|
[
"private",
"long",
"getTotalTime",
"(",
"ProjectCalendarDateRanges",
"hours",
",",
"Date",
"startDate",
",",
"Date",
"endDate",
")",
"{",
"long",
"total",
"=",
"0",
";",
"if",
"(",
"startDate",
".",
"getTime",
"(",
")",
"!=",
"endDate",
".",
"getTime",
"(",
")",
")",
"{",
"Date",
"start",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"startDate",
")",
";",
"Date",
"end",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"endDate",
")",
";",
"for",
"(",
"DateRange",
"range",
":",
"hours",
")",
"{",
"Date",
"rangeStart",
"=",
"range",
".",
"getStart",
"(",
")",
";",
"Date",
"rangeEnd",
"=",
"range",
".",
"getEnd",
"(",
")",
";",
"if",
"(",
"rangeStart",
"!=",
"null",
"&&",
"rangeEnd",
"!=",
"null",
")",
"{",
"Date",
"canoncialRangeStart",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"rangeStart",
")",
";",
"Date",
"canonicalRangeEnd",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"rangeEnd",
")",
";",
"Date",
"startDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeStart",
")",
";",
"Date",
"finishDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeEnd",
")",
";",
"//",
"// Handle the case where the end of the range is at midnight -",
"// this will show up as the start and end days not matching",
"//",
"if",
"(",
"startDay",
".",
"getTime",
"(",
")",
"!=",
"finishDay",
".",
"getTime",
"(",
")",
")",
"{",
"canonicalRangeEnd",
"=",
"DateHelper",
".",
"addDays",
"(",
"canonicalRangeEnd",
",",
"1",
")",
";",
"}",
"if",
"(",
"canoncialRangeStart",
".",
"getTime",
"(",
")",
"==",
"canonicalRangeEnd",
".",
"getTime",
"(",
")",
"&&",
"rangeEnd",
".",
"getTime",
"(",
")",
">",
"rangeStart",
".",
"getTime",
"(",
")",
")",
"{",
"total",
"+=",
"(",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"total",
"+=",
"getTime",
"(",
"start",
",",
"end",
",",
"canoncialRangeStart",
",",
"canonicalRangeEnd",
")",
";",
"}",
"}",
"}",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
This method calculates the total amount of working time in a single
day, which intersects with the supplied time range.
@param hours collection of working hours in a day
@param startDate time range start
@param endDate time range end
@return length of time in milliseconds
|
[
"This",
"method",
"calculates",
"the",
"total",
"amount",
"of",
"working",
"time",
"in",
"a",
"single",
"day",
"which",
"intersects",
"with",
"the",
"supplied",
"time",
"range",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1460-L1502
|
157,159
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTime
|
private long getTime(Date start, Date end, long target, boolean after)
{
long total = 0;
if (start != null && end != null)
{
Date startTime = DateHelper.getCanonicalTime(start);
Date endTime = DateHelper.getCanonicalTime(end);
Date startDay = DateHelper.getDayStartDate(start);
Date finishDay = DateHelper.getDayStartDate(end);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
int diff = DateHelper.compare(startTime, endTime, target);
if (diff == 0)
{
if (after == true)
{
total = (endTime.getTime() - target);
}
else
{
total = (target - startTime.getTime());
}
}
else
{
if ((after == true && diff < 0) || (after == false && diff > 0))
{
total = (endTime.getTime() - startTime.getTime());
}
}
}
return (total);
}
|
java
|
private long getTime(Date start, Date end, long target, boolean after)
{
long total = 0;
if (start != null && end != null)
{
Date startTime = DateHelper.getCanonicalTime(start);
Date endTime = DateHelper.getCanonicalTime(end);
Date startDay = DateHelper.getDayStartDate(start);
Date finishDay = DateHelper.getDayStartDate(end);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
int diff = DateHelper.compare(startTime, endTime, target);
if (diff == 0)
{
if (after == true)
{
total = (endTime.getTime() - target);
}
else
{
total = (target - startTime.getTime());
}
}
else
{
if ((after == true && diff < 0) || (after == false && diff > 0))
{
total = (endTime.getTime() - startTime.getTime());
}
}
}
return (total);
}
|
[
"private",
"long",
"getTime",
"(",
"Date",
"start",
",",
"Date",
"end",
",",
"long",
"target",
",",
"boolean",
"after",
")",
"{",
"long",
"total",
"=",
"0",
";",
"if",
"(",
"start",
"!=",
"null",
"&&",
"end",
"!=",
"null",
")",
"{",
"Date",
"startTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"start",
")",
";",
"Date",
"endTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"end",
")",
";",
"Date",
"startDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"start",
")",
";",
"Date",
"finishDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"end",
")",
";",
"//",
"// Handle the case where the end of the range is at midnight -",
"// this will show up as the start and end days not matching",
"//",
"if",
"(",
"startDay",
".",
"getTime",
"(",
")",
"!=",
"finishDay",
".",
"getTime",
"(",
")",
")",
"{",
"endTime",
"=",
"DateHelper",
".",
"addDays",
"(",
"endTime",
",",
"1",
")",
";",
"}",
"int",
"diff",
"=",
"DateHelper",
".",
"compare",
"(",
"startTime",
",",
"endTime",
",",
"target",
")",
";",
"if",
"(",
"diff",
"==",
"0",
")",
"{",
"if",
"(",
"after",
"==",
"true",
")",
"{",
"total",
"=",
"(",
"endTime",
".",
"getTime",
"(",
")",
"-",
"target",
")",
";",
"}",
"else",
"{",
"total",
"=",
"(",
"target",
"-",
"startTime",
".",
"getTime",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"(",
"after",
"==",
"true",
"&&",
"diff",
"<",
"0",
")",
"||",
"(",
"after",
"==",
"false",
"&&",
"diff",
">",
"0",
")",
")",
"{",
"total",
"=",
"(",
"endTime",
".",
"getTime",
"(",
")",
"-",
"startTime",
".",
"getTime",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
Calculates how much of a time range is before or after a
target intersection point.
@param start time range start
@param end time range end
@param target target intersection point
@param after true if time after target required, false for time before
@return length of time in milliseconds
|
[
"Calculates",
"how",
"much",
"of",
"a",
"time",
"range",
"is",
"before",
"or",
"after",
"a",
"target",
"intersection",
"point",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1514-L1555
|
157,160
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTime
|
private long getTime(Date start, Date end)
{
long total = 0;
if (start != null && end != null)
{
Date startTime = DateHelper.getCanonicalTime(start);
Date endTime = DateHelper.getCanonicalTime(end);
Date startDay = DateHelper.getDayStartDate(start);
Date finishDay = DateHelper.getDayStartDate(end);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
total = (endTime.getTime() - startTime.getTime());
}
return (total);
}
|
java
|
private long getTime(Date start, Date end)
{
long total = 0;
if (start != null && end != null)
{
Date startTime = DateHelper.getCanonicalTime(start);
Date endTime = DateHelper.getCanonicalTime(end);
Date startDay = DateHelper.getDayStartDate(start);
Date finishDay = DateHelper.getDayStartDate(end);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
total = (endTime.getTime() - startTime.getTime());
}
return (total);
}
|
[
"private",
"long",
"getTime",
"(",
"Date",
"start",
",",
"Date",
"end",
")",
"{",
"long",
"total",
"=",
"0",
";",
"if",
"(",
"start",
"!=",
"null",
"&&",
"end",
"!=",
"null",
")",
"{",
"Date",
"startTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"start",
")",
";",
"Date",
"endTime",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"end",
")",
";",
"Date",
"startDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"start",
")",
";",
"Date",
"finishDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"end",
")",
";",
"//",
"// Handle the case where the end of the range is at midnight -",
"// this will show up as the start and end days not matching",
"//",
"if",
"(",
"startDay",
".",
"getTime",
"(",
")",
"!=",
"finishDay",
".",
"getTime",
"(",
")",
")",
"{",
"endTime",
"=",
"DateHelper",
".",
"addDays",
"(",
"endTime",
",",
"1",
")",
";",
"}",
"total",
"=",
"(",
"endTime",
".",
"getTime",
"(",
")",
"-",
"startTime",
".",
"getTime",
"(",
")",
")",
";",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
Retrieves the amount of time between two date time values. Note that
these values are converted into canonical values to remove the
date component.
@param start start time
@param end end time
@return length of time
|
[
"Retrieves",
"the",
"amount",
"of",
"time",
"between",
"two",
"date",
"time",
"values",
".",
"Note",
"that",
"these",
"values",
"are",
"converted",
"into",
"canonical",
"values",
"to",
"remove",
"the",
"date",
"component",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1566-L1589
|
157,161
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getTime
|
private long getTime(Date start1, Date end1, Date start2, Date end2)
{
long total = 0;
if (start1 != null && end1 != null && start2 != null && end2 != null)
{
long start;
long end;
if (start1.getTime() < start2.getTime())
{
start = start2.getTime();
}
else
{
start = start1.getTime();
}
if (end1.getTime() < end2.getTime())
{
end = end1.getTime();
}
else
{
end = end2.getTime();
}
if (start < end)
{
total = end - start;
}
}
return (total);
}
|
java
|
private long getTime(Date start1, Date end1, Date start2, Date end2)
{
long total = 0;
if (start1 != null && end1 != null && start2 != null && end2 != null)
{
long start;
long end;
if (start1.getTime() < start2.getTime())
{
start = start2.getTime();
}
else
{
start = start1.getTime();
}
if (end1.getTime() < end2.getTime())
{
end = end1.getTime();
}
else
{
end = end2.getTime();
}
if (start < end)
{
total = end - start;
}
}
return (total);
}
|
[
"private",
"long",
"getTime",
"(",
"Date",
"start1",
",",
"Date",
"end1",
",",
"Date",
"start2",
",",
"Date",
"end2",
")",
"{",
"long",
"total",
"=",
"0",
";",
"if",
"(",
"start1",
"!=",
"null",
"&&",
"end1",
"!=",
"null",
"&&",
"start2",
"!=",
"null",
"&&",
"end2",
"!=",
"null",
")",
"{",
"long",
"start",
";",
"long",
"end",
";",
"if",
"(",
"start1",
".",
"getTime",
"(",
")",
"<",
"start2",
".",
"getTime",
"(",
")",
")",
"{",
"start",
"=",
"start2",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"start",
"=",
"start1",
".",
"getTime",
"(",
")",
";",
"}",
"if",
"(",
"end1",
".",
"getTime",
"(",
")",
"<",
"end2",
".",
"getTime",
"(",
")",
")",
"{",
"end",
"=",
"end1",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"end",
"=",
"end2",
".",
"getTime",
"(",
")",
";",
"}",
"if",
"(",
"start",
"<",
"end",
")",
"{",
"total",
"=",
"end",
"-",
"start",
";",
"}",
"}",
"return",
"(",
"total",
")",
";",
"}"
] |
This method returns the length of overlapping time between two time
ranges.
@param start1 start of first range
@param end1 end of first range
@param start2 start start of second range
@param end2 end of second range
@return overlapping time in milliseconds
|
[
"This",
"method",
"returns",
"the",
"length",
"of",
"overlapping",
"time",
"between",
"two",
"time",
"ranges",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1601-L1635
|
157,162
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.copy
|
public void copy(ProjectCalendar cal)
{
setName(cal.getName());
setParent(cal.getParent());
System.arraycopy(cal.getDays(), 0, getDays(), 0, getDays().length);
for (ProjectCalendarException ex : cal.m_exceptions)
{
addCalendarException(ex.getFromDate(), ex.getToDate());
for (DateRange range : ex)
{
ex.addRange(new DateRange(range.getStart(), range.getEnd()));
}
}
for (ProjectCalendarHours hours : getHours())
{
if (hours != null)
{
ProjectCalendarHours copyHours = cal.addCalendarHours(hours.getDay());
for (DateRange range : hours)
{
copyHours.addRange(new DateRange(range.getStart(), range.getEnd()));
}
}
}
}
|
java
|
public void copy(ProjectCalendar cal)
{
setName(cal.getName());
setParent(cal.getParent());
System.arraycopy(cal.getDays(), 0, getDays(), 0, getDays().length);
for (ProjectCalendarException ex : cal.m_exceptions)
{
addCalendarException(ex.getFromDate(), ex.getToDate());
for (DateRange range : ex)
{
ex.addRange(new DateRange(range.getStart(), range.getEnd()));
}
}
for (ProjectCalendarHours hours : getHours())
{
if (hours != null)
{
ProjectCalendarHours copyHours = cal.addCalendarHours(hours.getDay());
for (DateRange range : hours)
{
copyHours.addRange(new DateRange(range.getStart(), range.getEnd()));
}
}
}
}
|
[
"public",
"void",
"copy",
"(",
"ProjectCalendar",
"cal",
")",
"{",
"setName",
"(",
"cal",
".",
"getName",
"(",
")",
")",
";",
"setParent",
"(",
"cal",
".",
"getParent",
"(",
")",
")",
";",
"System",
".",
"arraycopy",
"(",
"cal",
".",
"getDays",
"(",
")",
",",
"0",
",",
"getDays",
"(",
")",
",",
"0",
",",
"getDays",
"(",
")",
".",
"length",
")",
";",
"for",
"(",
"ProjectCalendarException",
"ex",
":",
"cal",
".",
"m_exceptions",
")",
"{",
"addCalendarException",
"(",
"ex",
".",
"getFromDate",
"(",
")",
",",
"ex",
".",
"getToDate",
"(",
")",
")",
";",
"for",
"(",
"DateRange",
"range",
":",
"ex",
")",
"{",
"ex",
".",
"addRange",
"(",
"new",
"DateRange",
"(",
"range",
".",
"getStart",
"(",
")",
",",
"range",
".",
"getEnd",
"(",
")",
")",
")",
";",
"}",
"}",
"for",
"(",
"ProjectCalendarHours",
"hours",
":",
"getHours",
"(",
")",
")",
"{",
"if",
"(",
"hours",
"!=",
"null",
")",
"{",
"ProjectCalendarHours",
"copyHours",
"=",
"cal",
".",
"addCalendarHours",
"(",
"hours",
".",
"getDay",
"(",
")",
")",
";",
"for",
"(",
"DateRange",
"range",
":",
"hours",
")",
"{",
"copyHours",
".",
"addRange",
"(",
"new",
"DateRange",
"(",
"range",
".",
"getStart",
"(",
")",
",",
"range",
".",
"getEnd",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Copy the settings from another calendar to this calendar.
@param cal calendar data source
|
[
"Copy",
"the",
"settings",
"from",
"another",
"calendar",
"to",
"this",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1837-L1862
|
157,163
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.clearWorkingDateCache
|
private void clearWorkingDateCache()
{
m_workingDateCache.clear();
m_startTimeCache.clear();
m_getDateLastResult = null;
for (ProjectCalendar calendar : m_derivedCalendars)
{
calendar.clearWorkingDateCache();
}
}
|
java
|
private void clearWorkingDateCache()
{
m_workingDateCache.clear();
m_startTimeCache.clear();
m_getDateLastResult = null;
for (ProjectCalendar calendar : m_derivedCalendars)
{
calendar.clearWorkingDateCache();
}
}
|
[
"private",
"void",
"clearWorkingDateCache",
"(",
")",
"{",
"m_workingDateCache",
".",
"clear",
"(",
")",
";",
"m_startTimeCache",
".",
"clear",
"(",
")",
";",
"m_getDateLastResult",
"=",
"null",
";",
"for",
"(",
"ProjectCalendar",
"calendar",
":",
"m_derivedCalendars",
")",
"{",
"calendar",
".",
"clearWorkingDateCache",
"(",
")",
";",
"}",
"}"
] |
Utility method to clear cached calendar data.
|
[
"Utility",
"method",
"to",
"clear",
"cached",
"calendar",
"data",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1867-L1876
|
157,164
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.getRanges
|
private ProjectCalendarDateRanges getRanges(Date date, Calendar cal, Day day)
{
ProjectCalendarDateRanges ranges = getException(date);
if (ranges == null)
{
ProjectCalendarWeek week = getWorkWeek(date);
if (week == null)
{
week = this;
}
if (day == null)
{
if (cal == null)
{
cal = Calendar.getInstance();
cal.setTime(date);
}
day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
}
ranges = week.getHours(day);
}
return ranges;
}
|
java
|
private ProjectCalendarDateRanges getRanges(Date date, Calendar cal, Day day)
{
ProjectCalendarDateRanges ranges = getException(date);
if (ranges == null)
{
ProjectCalendarWeek week = getWorkWeek(date);
if (week == null)
{
week = this;
}
if (day == null)
{
if (cal == null)
{
cal = Calendar.getInstance();
cal.setTime(date);
}
day = Day.getInstance(cal.get(Calendar.DAY_OF_WEEK));
}
ranges = week.getHours(day);
}
return ranges;
}
|
[
"private",
"ProjectCalendarDateRanges",
"getRanges",
"(",
"Date",
"date",
",",
"Calendar",
"cal",
",",
"Day",
"day",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getException",
"(",
"date",
")",
";",
"if",
"(",
"ranges",
"==",
"null",
")",
"{",
"ProjectCalendarWeek",
"week",
"=",
"getWorkWeek",
"(",
"date",
")",
";",
"if",
"(",
"week",
"==",
"null",
")",
"{",
"week",
"=",
"this",
";",
"}",
"if",
"(",
"day",
"==",
"null",
")",
"{",
"if",
"(",
"cal",
"==",
"null",
")",
"{",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"date",
")",
";",
"}",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
")",
";",
"}",
"ranges",
"=",
"week",
".",
"getHours",
"(",
"day",
")",
";",
"}",
"return",
"ranges",
";",
"}"
] |
Retrieves the working hours on the given date.
@param date required date
@param cal optional calendar instance
@param day optional day instance
@return working hours
|
[
"Retrieves",
"the",
"working",
"hours",
"on",
"the",
"given",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1886-L1910
|
157,165
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ProjectCalendar.java
|
ProjectCalendar.populateExpandedExceptions
|
private void populateExpandedExceptions()
{
if (!m_exceptions.isEmpty() && m_expandedExceptions.isEmpty())
{
for (ProjectCalendarException exception : m_exceptions)
{
RecurringData recurring = exception.getRecurring();
if (recurring == null)
{
m_expandedExceptions.add(exception);
}
else
{
for (Date date : recurring.getDates())
{
Date startDate = DateHelper.getDayStartDate(date);
Date endDate = DateHelper.getDayEndDate(date);
ProjectCalendarException newException = new ProjectCalendarException(startDate, endDate);
int rangeCount = exception.getRangeCount();
for (int rangeIndex = 0; rangeIndex < rangeCount; rangeIndex++)
{
newException.addRange(exception.getRange(rangeIndex));
}
m_expandedExceptions.add(newException);
}
}
}
Collections.sort(m_expandedExceptions);
}
}
|
java
|
private void populateExpandedExceptions()
{
if (!m_exceptions.isEmpty() && m_expandedExceptions.isEmpty())
{
for (ProjectCalendarException exception : m_exceptions)
{
RecurringData recurring = exception.getRecurring();
if (recurring == null)
{
m_expandedExceptions.add(exception);
}
else
{
for (Date date : recurring.getDates())
{
Date startDate = DateHelper.getDayStartDate(date);
Date endDate = DateHelper.getDayEndDate(date);
ProjectCalendarException newException = new ProjectCalendarException(startDate, endDate);
int rangeCount = exception.getRangeCount();
for (int rangeIndex = 0; rangeIndex < rangeCount; rangeIndex++)
{
newException.addRange(exception.getRange(rangeIndex));
}
m_expandedExceptions.add(newException);
}
}
}
Collections.sort(m_expandedExceptions);
}
}
|
[
"private",
"void",
"populateExpandedExceptions",
"(",
")",
"{",
"if",
"(",
"!",
"m_exceptions",
".",
"isEmpty",
"(",
")",
"&&",
"m_expandedExceptions",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"ProjectCalendarException",
"exception",
":",
"m_exceptions",
")",
"{",
"RecurringData",
"recurring",
"=",
"exception",
".",
"getRecurring",
"(",
")",
";",
"if",
"(",
"recurring",
"==",
"null",
")",
"{",
"m_expandedExceptions",
".",
"add",
"(",
"exception",
")",
";",
"}",
"else",
"{",
"for",
"(",
"Date",
"date",
":",
"recurring",
".",
"getDates",
"(",
")",
")",
"{",
"Date",
"startDate",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"date",
")",
";",
"Date",
"endDate",
"=",
"DateHelper",
".",
"getDayEndDate",
"(",
"date",
")",
";",
"ProjectCalendarException",
"newException",
"=",
"new",
"ProjectCalendarException",
"(",
"startDate",
",",
"endDate",
")",
";",
"int",
"rangeCount",
"=",
"exception",
".",
"getRangeCount",
"(",
")",
";",
"for",
"(",
"int",
"rangeIndex",
"=",
"0",
";",
"rangeIndex",
"<",
"rangeCount",
";",
"rangeIndex",
"++",
")",
"{",
"newException",
".",
"addRange",
"(",
"exception",
".",
"getRange",
"(",
"rangeIndex",
")",
")",
";",
"}",
"m_expandedExceptions",
".",
"add",
"(",
"newException",
")",
";",
"}",
"}",
"}",
"Collections",
".",
"sort",
"(",
"m_expandedExceptions",
")",
";",
"}",
"}"
] |
Populate the expanded exceptions list based on the main exceptions list.
Where we find recurring exception definitions, we generate individual
exceptions for each recurrence to ensure that we account for them correctly.
|
[
"Populate",
"the",
"expanded",
"exceptions",
"list",
"based",
"on",
"the",
"main",
"exceptions",
"list",
".",
"Where",
"we",
"find",
"recurring",
"exception",
"definitions",
"we",
"generate",
"individual",
"exceptions",
"for",
"each",
"recurrence",
"to",
"ensure",
"that",
"we",
"account",
"for",
"them",
"correctly",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1929-L1958
|
157,166
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/TableContainer.java
|
TableContainer.getIndex
|
private Map<String, Table> getIndex(Table table)
{
Map<String, Table> result;
if (!table.getResourceFlag())
{
result = m_taskTablesByName;
}
else
{
result = m_resourceTablesByName;
}
return result;
}
|
java
|
private Map<String, Table> getIndex(Table table)
{
Map<String, Table> result;
if (!table.getResourceFlag())
{
result = m_taskTablesByName;
}
else
{
result = m_resourceTablesByName;
}
return result;
}
|
[
"private",
"Map",
"<",
"String",
",",
"Table",
">",
"getIndex",
"(",
"Table",
"table",
")",
"{",
"Map",
"<",
"String",
",",
"Table",
">",
"result",
";",
"if",
"(",
"!",
"table",
".",
"getResourceFlag",
"(",
")",
")",
"{",
"result",
"=",
"m_taskTablesByName",
";",
"}",
"else",
"{",
"result",
"=",
"m_resourceTablesByName",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the correct index for the supplied Table instance.
@param table Table instance
@return index
|
[
"Retrieve",
"the",
"correct",
"index",
"for",
"the",
"supplied",
"Table",
"instance",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/TableContainer.java#L74-L87
|
157,167
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectFilePanel.java
|
ProjectFilePanel.saveFile
|
public void saveFile(File file, String type)
{
if (file != null)
{
m_treeController.saveFile(file, type);
}
}
|
java
|
public void saveFile(File file, String type)
{
if (file != null)
{
m_treeController.saveFile(file, type);
}
}
|
[
"public",
"void",
"saveFile",
"(",
"File",
"file",
",",
"String",
"type",
")",
"{",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"m_treeController",
".",
"saveFile",
"(",
"file",
",",
"type",
")",
";",
"}",
"}"
] |
Saves the project file displayed in this panel.
@param file target file
@param type file type
|
[
"Saves",
"the",
"project",
"file",
"displayed",
"in",
"this",
"panel",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectFilePanel.java#L104-L110
|
157,168
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/FilterContainer.java
|
FilterContainer.addFilter
|
public void addFilter(Filter filter)
{
if (filter.isTaskFilter())
{
m_taskFilters.add(filter);
}
if (filter.isResourceFilter())
{
m_resourceFilters.add(filter);
}
m_filtersByName.put(filter.getName(), filter);
m_filtersByID.put(filter.getID(), filter);
}
|
java
|
public void addFilter(Filter filter)
{
if (filter.isTaskFilter())
{
m_taskFilters.add(filter);
}
if (filter.isResourceFilter())
{
m_resourceFilters.add(filter);
}
m_filtersByName.put(filter.getName(), filter);
m_filtersByID.put(filter.getID(), filter);
}
|
[
"public",
"void",
"addFilter",
"(",
"Filter",
"filter",
")",
"{",
"if",
"(",
"filter",
".",
"isTaskFilter",
"(",
")",
")",
"{",
"m_taskFilters",
".",
"add",
"(",
"filter",
")",
";",
"}",
"if",
"(",
"filter",
".",
"isResourceFilter",
"(",
")",
")",
"{",
"m_resourceFilters",
".",
"add",
"(",
"filter",
")",
";",
"}",
"m_filtersByName",
".",
"put",
"(",
"filter",
".",
"getName",
"(",
")",
",",
"filter",
")",
";",
"m_filtersByID",
".",
"put",
"(",
"filter",
".",
"getID",
"(",
")",
",",
"filter",
")",
";",
"}"
] |
Adds a filter definition to this project file.
@param filter filter definition
|
[
"Adds",
"a",
"filter",
"definition",
"to",
"this",
"project",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/FilterContainer.java#L41-L55
|
157,169
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/FilterContainer.java
|
FilterContainer.removeFilter
|
public void removeFilter(String filterName)
{
Filter filter = getFilterByName(filterName);
if (filter != null)
{
if (filter.isTaskFilter())
{
m_taskFilters.remove(filter);
}
if (filter.isResourceFilter())
{
m_resourceFilters.remove(filter);
}
m_filtersByName.remove(filterName);
m_filtersByID.remove(filter.getID());
}
}
|
java
|
public void removeFilter(String filterName)
{
Filter filter = getFilterByName(filterName);
if (filter != null)
{
if (filter.isTaskFilter())
{
m_taskFilters.remove(filter);
}
if (filter.isResourceFilter())
{
m_resourceFilters.remove(filter);
}
m_filtersByName.remove(filterName);
m_filtersByID.remove(filter.getID());
}
}
|
[
"public",
"void",
"removeFilter",
"(",
"String",
"filterName",
")",
"{",
"Filter",
"filter",
"=",
"getFilterByName",
"(",
"filterName",
")",
";",
"if",
"(",
"filter",
"!=",
"null",
")",
"{",
"if",
"(",
"filter",
".",
"isTaskFilter",
"(",
")",
")",
"{",
"m_taskFilters",
".",
"remove",
"(",
"filter",
")",
";",
"}",
"if",
"(",
"filter",
".",
"isResourceFilter",
"(",
")",
")",
"{",
"m_resourceFilters",
".",
"remove",
"(",
"filter",
")",
";",
"}",
"m_filtersByName",
".",
"remove",
"(",
"filterName",
")",
";",
"m_filtersByID",
".",
"remove",
"(",
"filter",
".",
"getID",
"(",
")",
")",
";",
"}",
"}"
] |
Removes a filter from this project file.
@param filterName The name of the filter
|
[
"Removes",
"a",
"filter",
"from",
"this",
"project",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/FilterContainer.java#L62-L79
|
157,170
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeProjectProperties
|
private void writeProjectProperties()
{
ProjectProperties properties = m_projectFile.getProjectProperties();
m_plannerProject.setCompany(properties.getCompany());
m_plannerProject.setManager(properties.getManager());
m_plannerProject.setName(getString(properties.getName()));
m_plannerProject.setProjectStart(getDateTime(properties.getStartDate()));
m_plannerProject.setCalendar(getIntegerString(m_projectFile.getDefaultCalendar().getUniqueID()));
m_plannerProject.setMrprojectVersion("2");
}
|
java
|
private void writeProjectProperties()
{
ProjectProperties properties = m_projectFile.getProjectProperties();
m_plannerProject.setCompany(properties.getCompany());
m_plannerProject.setManager(properties.getManager());
m_plannerProject.setName(getString(properties.getName()));
m_plannerProject.setProjectStart(getDateTime(properties.getStartDate()));
m_plannerProject.setCalendar(getIntegerString(m_projectFile.getDefaultCalendar().getUniqueID()));
m_plannerProject.setMrprojectVersion("2");
}
|
[
"private",
"void",
"writeProjectProperties",
"(",
")",
"{",
"ProjectProperties",
"properties",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
";",
"m_plannerProject",
".",
"setCompany",
"(",
"properties",
".",
"getCompany",
"(",
")",
")",
";",
"m_plannerProject",
".",
"setManager",
"(",
"properties",
".",
"getManager",
"(",
")",
")",
";",
"m_plannerProject",
".",
"setName",
"(",
"getString",
"(",
"properties",
".",
"getName",
"(",
")",
")",
")",
";",
"m_plannerProject",
".",
"setProjectStart",
"(",
"getDateTime",
"(",
"properties",
".",
"getStartDate",
"(",
")",
")",
")",
";",
"m_plannerProject",
".",
"setCalendar",
"(",
"getIntegerString",
"(",
"m_projectFile",
".",
"getDefaultCalendar",
"(",
")",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"m_plannerProject",
".",
"setMrprojectVersion",
"(",
"\"2\"",
")",
";",
"}"
] |
This method writes project properties to a Planner file.
|
[
"This",
"method",
"writes",
"project",
"properties",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L141-L151
|
157,171
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeCalendars
|
private void writeCalendars() throws JAXBException
{
//
// Create the new Planner calendar list
//
Calendars calendars = m_factory.createCalendars();
m_plannerProject.setCalendars(calendars);
writeDayTypes(calendars);
List<net.sf.mpxj.planner.schema.Calendar> calendar = calendars.getCalendar();
//
// Process each calendar in turn
//
for (ProjectCalendar mpxjCalendar : m_projectFile.getCalendars())
{
net.sf.mpxj.planner.schema.Calendar plannerCalendar = m_factory.createCalendar();
calendar.add(plannerCalendar);
writeCalendar(mpxjCalendar, plannerCalendar);
}
}
|
java
|
private void writeCalendars() throws JAXBException
{
//
// Create the new Planner calendar list
//
Calendars calendars = m_factory.createCalendars();
m_plannerProject.setCalendars(calendars);
writeDayTypes(calendars);
List<net.sf.mpxj.planner.schema.Calendar> calendar = calendars.getCalendar();
//
// Process each calendar in turn
//
for (ProjectCalendar mpxjCalendar : m_projectFile.getCalendars())
{
net.sf.mpxj.planner.schema.Calendar plannerCalendar = m_factory.createCalendar();
calendar.add(plannerCalendar);
writeCalendar(mpxjCalendar, plannerCalendar);
}
}
|
[
"private",
"void",
"writeCalendars",
"(",
")",
"throws",
"JAXBException",
"{",
"//",
"// Create the new Planner calendar list",
"//",
"Calendars",
"calendars",
"=",
"m_factory",
".",
"createCalendars",
"(",
")",
";",
"m_plannerProject",
".",
"setCalendars",
"(",
"calendars",
")",
";",
"writeDayTypes",
"(",
"calendars",
")",
";",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
">",
"calendar",
"=",
"calendars",
".",
"getCalendar",
"(",
")",
";",
"//",
"// Process each calendar in turn",
"//",
"for",
"(",
"ProjectCalendar",
"mpxjCalendar",
":",
"m_projectFile",
".",
"getCalendars",
"(",
")",
")",
"{",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"plannerCalendar",
"=",
"m_factory",
".",
"createCalendar",
"(",
")",
";",
"calendar",
".",
"add",
"(",
"plannerCalendar",
")",
";",
"writeCalendar",
"(",
"mpxjCalendar",
",",
"plannerCalendar",
")",
";",
"}",
"}"
] |
This method writes calendar data to a Planner file.
@throws JAXBException on xml creation errors
|
[
"This",
"method",
"writes",
"calendar",
"data",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L158-L177
|
157,172
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeDayTypes
|
private void writeDayTypes(Calendars calendars)
{
DayTypes dayTypes = m_factory.createDayTypes();
calendars.setDayTypes(dayTypes);
List<DayType> typeList = dayTypes.getDayType();
DayType dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("0");
dayType.setName("Working");
dayType.setDescription("A default working day");
dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("1");
dayType.setName("Nonworking");
dayType.setDescription("A default non working day");
dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("2");
dayType.setName("Use base");
dayType.setDescription("Use day from base calendar");
}
|
java
|
private void writeDayTypes(Calendars calendars)
{
DayTypes dayTypes = m_factory.createDayTypes();
calendars.setDayTypes(dayTypes);
List<DayType> typeList = dayTypes.getDayType();
DayType dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("0");
dayType.setName("Working");
dayType.setDescription("A default working day");
dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("1");
dayType.setName("Nonworking");
dayType.setDescription("A default non working day");
dayType = m_factory.createDayType();
typeList.add(dayType);
dayType.setId("2");
dayType.setName("Use base");
dayType.setDescription("Use day from base calendar");
}
|
[
"private",
"void",
"writeDayTypes",
"(",
"Calendars",
"calendars",
")",
"{",
"DayTypes",
"dayTypes",
"=",
"m_factory",
".",
"createDayTypes",
"(",
")",
";",
"calendars",
".",
"setDayTypes",
"(",
"dayTypes",
")",
";",
"List",
"<",
"DayType",
">",
"typeList",
"=",
"dayTypes",
".",
"getDayType",
"(",
")",
";",
"DayType",
"dayType",
"=",
"m_factory",
".",
"createDayType",
"(",
")",
";",
"typeList",
".",
"add",
"(",
"dayType",
")",
";",
"dayType",
".",
"setId",
"(",
"\"0\"",
")",
";",
"dayType",
".",
"setName",
"(",
"\"Working\"",
")",
";",
"dayType",
".",
"setDescription",
"(",
"\"A default working day\"",
")",
";",
"dayType",
"=",
"m_factory",
".",
"createDayType",
"(",
")",
";",
"typeList",
".",
"add",
"(",
"dayType",
")",
";",
"dayType",
".",
"setId",
"(",
"\"1\"",
")",
";",
"dayType",
".",
"setName",
"(",
"\"Nonworking\"",
")",
";",
"dayType",
".",
"setDescription",
"(",
"\"A default non working day\"",
")",
";",
"dayType",
"=",
"m_factory",
".",
"createDayType",
"(",
")",
";",
"typeList",
".",
"add",
"(",
"dayType",
")",
";",
"dayType",
".",
"setId",
"(",
"\"2\"",
")",
";",
"dayType",
".",
"setName",
"(",
"\"Use base\"",
")",
";",
"dayType",
".",
"setDescription",
"(",
"\"Use day from base calendar\"",
")",
";",
"}"
] |
Write the standard set of day types.
@param calendars parent collection of calendars
|
[
"Write",
"the",
"standard",
"set",
"of",
"day",
"types",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L184-L207
|
157,173
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeCalendar
|
private void writeCalendar(ProjectCalendar mpxjCalendar, net.sf.mpxj.planner.schema.Calendar plannerCalendar) throws JAXBException
{
//
// Populate basic details
//
plannerCalendar.setId(getIntegerString(mpxjCalendar.getUniqueID()));
plannerCalendar.setName(getString(mpxjCalendar.getName()));
//
// Set working and non working days
//
DefaultWeek dw = m_factory.createDefaultWeek();
plannerCalendar.setDefaultWeek(dw);
dw.setMon(getWorkingDayString(mpxjCalendar, Day.MONDAY));
dw.setTue(getWorkingDayString(mpxjCalendar, Day.TUESDAY));
dw.setWed(getWorkingDayString(mpxjCalendar, Day.WEDNESDAY));
dw.setThu(getWorkingDayString(mpxjCalendar, Day.THURSDAY));
dw.setFri(getWorkingDayString(mpxjCalendar, Day.FRIDAY));
dw.setSat(getWorkingDayString(mpxjCalendar, Day.SATURDAY));
dw.setSun(getWorkingDayString(mpxjCalendar, Day.SUNDAY));
//
// Set working hours
//
OverriddenDayTypes odt = m_factory.createOverriddenDayTypes();
plannerCalendar.setOverriddenDayTypes(odt);
List<OverriddenDayType> typeList = odt.getOverriddenDayType();
Sequence uniqueID = new Sequence(0);
//
// This is a bit arbitrary, so not ideal, however...
// The idea here is that MS Project allows us to specify working hours
// for each day of the week individually. Planner doesn't do this,
// but instead allows us to specify working hours for each day type.
// What we are doing here is stepping through the days of the week to
// find the first working day, then using the hours for that day
// as the hours for the working day type in Planner.
//
for (int dayLoop = 1; dayLoop < 8; dayLoop++)
{
Day day = Day.getInstance(dayLoop);
if (mpxjCalendar.isWorkingDay(day))
{
processWorkingHours(mpxjCalendar, uniqueID, day, typeList);
break;
}
}
//
// Process exception days
//
Days plannerDays = m_factory.createDays();
plannerCalendar.setDays(plannerDays);
List<net.sf.mpxj.planner.schema.Day> dayList = plannerDays.getDay();
processExceptionDays(mpxjCalendar, dayList);
m_eventManager.fireCalendarWrittenEvent(mpxjCalendar);
//
// Process any derived calendars
//
List<net.sf.mpxj.planner.schema.Calendar> calendarList = plannerCalendar.getCalendar();
for (ProjectCalendar mpxjDerivedCalendar : mpxjCalendar.getDerivedCalendars())
{
net.sf.mpxj.planner.schema.Calendar plannerDerivedCalendar = m_factory.createCalendar();
calendarList.add(plannerDerivedCalendar);
writeCalendar(mpxjDerivedCalendar, plannerDerivedCalendar);
}
}
|
java
|
private void writeCalendar(ProjectCalendar mpxjCalendar, net.sf.mpxj.planner.schema.Calendar plannerCalendar) throws JAXBException
{
//
// Populate basic details
//
plannerCalendar.setId(getIntegerString(mpxjCalendar.getUniqueID()));
plannerCalendar.setName(getString(mpxjCalendar.getName()));
//
// Set working and non working days
//
DefaultWeek dw = m_factory.createDefaultWeek();
plannerCalendar.setDefaultWeek(dw);
dw.setMon(getWorkingDayString(mpxjCalendar, Day.MONDAY));
dw.setTue(getWorkingDayString(mpxjCalendar, Day.TUESDAY));
dw.setWed(getWorkingDayString(mpxjCalendar, Day.WEDNESDAY));
dw.setThu(getWorkingDayString(mpxjCalendar, Day.THURSDAY));
dw.setFri(getWorkingDayString(mpxjCalendar, Day.FRIDAY));
dw.setSat(getWorkingDayString(mpxjCalendar, Day.SATURDAY));
dw.setSun(getWorkingDayString(mpxjCalendar, Day.SUNDAY));
//
// Set working hours
//
OverriddenDayTypes odt = m_factory.createOverriddenDayTypes();
plannerCalendar.setOverriddenDayTypes(odt);
List<OverriddenDayType> typeList = odt.getOverriddenDayType();
Sequence uniqueID = new Sequence(0);
//
// This is a bit arbitrary, so not ideal, however...
// The idea here is that MS Project allows us to specify working hours
// for each day of the week individually. Planner doesn't do this,
// but instead allows us to specify working hours for each day type.
// What we are doing here is stepping through the days of the week to
// find the first working day, then using the hours for that day
// as the hours for the working day type in Planner.
//
for (int dayLoop = 1; dayLoop < 8; dayLoop++)
{
Day day = Day.getInstance(dayLoop);
if (mpxjCalendar.isWorkingDay(day))
{
processWorkingHours(mpxjCalendar, uniqueID, day, typeList);
break;
}
}
//
// Process exception days
//
Days plannerDays = m_factory.createDays();
plannerCalendar.setDays(plannerDays);
List<net.sf.mpxj.planner.schema.Day> dayList = plannerDays.getDay();
processExceptionDays(mpxjCalendar, dayList);
m_eventManager.fireCalendarWrittenEvent(mpxjCalendar);
//
// Process any derived calendars
//
List<net.sf.mpxj.planner.schema.Calendar> calendarList = plannerCalendar.getCalendar();
for (ProjectCalendar mpxjDerivedCalendar : mpxjCalendar.getDerivedCalendars())
{
net.sf.mpxj.planner.schema.Calendar plannerDerivedCalendar = m_factory.createCalendar();
calendarList.add(plannerDerivedCalendar);
writeCalendar(mpxjDerivedCalendar, plannerDerivedCalendar);
}
}
|
[
"private",
"void",
"writeCalendar",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"plannerCalendar",
")",
"throws",
"JAXBException",
"{",
"//",
"// Populate basic details",
"//",
"plannerCalendar",
".",
"setId",
"(",
"getIntegerString",
"(",
"mpxjCalendar",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"plannerCalendar",
".",
"setName",
"(",
"getString",
"(",
"mpxjCalendar",
".",
"getName",
"(",
")",
")",
")",
";",
"//",
"// Set working and non working days",
"//",
"DefaultWeek",
"dw",
"=",
"m_factory",
".",
"createDefaultWeek",
"(",
")",
";",
"plannerCalendar",
".",
"setDefaultWeek",
"(",
"dw",
")",
";",
"dw",
".",
"setMon",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"MONDAY",
")",
")",
";",
"dw",
".",
"setTue",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"TUESDAY",
")",
")",
";",
"dw",
".",
"setWed",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"WEDNESDAY",
")",
")",
";",
"dw",
".",
"setThu",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"THURSDAY",
")",
")",
";",
"dw",
".",
"setFri",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"FRIDAY",
")",
")",
";",
"dw",
".",
"setSat",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"SATURDAY",
")",
")",
";",
"dw",
".",
"setSun",
"(",
"getWorkingDayString",
"(",
"mpxjCalendar",
",",
"Day",
".",
"SUNDAY",
")",
")",
";",
"//",
"// Set working hours",
"//",
"OverriddenDayTypes",
"odt",
"=",
"m_factory",
".",
"createOverriddenDayTypes",
"(",
")",
";",
"plannerCalendar",
".",
"setOverriddenDayTypes",
"(",
"odt",
")",
";",
"List",
"<",
"OverriddenDayType",
">",
"typeList",
"=",
"odt",
".",
"getOverriddenDayType",
"(",
")",
";",
"Sequence",
"uniqueID",
"=",
"new",
"Sequence",
"(",
"0",
")",
";",
"//",
"// This is a bit arbitrary, so not ideal, however...",
"// The idea here is that MS Project allows us to specify working hours",
"// for each day of the week individually. Planner doesn't do this,",
"// but instead allows us to specify working hours for each day type.",
"// What we are doing here is stepping through the days of the week to",
"// find the first working day, then using the hours for that day",
"// as the hours for the working day type in Planner.",
"//",
"for",
"(",
"int",
"dayLoop",
"=",
"1",
";",
"dayLoop",
"<",
"8",
";",
"dayLoop",
"++",
")",
"{",
"Day",
"day",
"=",
"Day",
".",
"getInstance",
"(",
"dayLoop",
")",
";",
"if",
"(",
"mpxjCalendar",
".",
"isWorkingDay",
"(",
"day",
")",
")",
"{",
"processWorkingHours",
"(",
"mpxjCalendar",
",",
"uniqueID",
",",
"day",
",",
"typeList",
")",
";",
"break",
";",
"}",
"}",
"//",
"// Process exception days",
"//",
"Days",
"plannerDays",
"=",
"m_factory",
".",
"createDays",
"(",
")",
";",
"plannerCalendar",
".",
"setDays",
"(",
"plannerDays",
")",
";",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Day",
">",
"dayList",
"=",
"plannerDays",
".",
"getDay",
"(",
")",
";",
"processExceptionDays",
"(",
"mpxjCalendar",
",",
"dayList",
")",
";",
"m_eventManager",
".",
"fireCalendarWrittenEvent",
"(",
"mpxjCalendar",
")",
";",
"//",
"// Process any derived calendars",
"//",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
">",
"calendarList",
"=",
"plannerCalendar",
".",
"getCalendar",
"(",
")",
";",
"for",
"(",
"ProjectCalendar",
"mpxjDerivedCalendar",
":",
"mpxjCalendar",
".",
"getDerivedCalendars",
"(",
")",
")",
"{",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"plannerDerivedCalendar",
"=",
"m_factory",
".",
"createCalendar",
"(",
")",
";",
"calendarList",
".",
"add",
"(",
"plannerDerivedCalendar",
")",
";",
"writeCalendar",
"(",
"mpxjDerivedCalendar",
",",
"plannerDerivedCalendar",
")",
";",
"}",
"}"
] |
This method writes data for a single calendar to a Planner file.
@param mpxjCalendar MPXJ calendar instance
@param plannerCalendar Planner calendar instance
@throws JAXBException on xml creation errors
|
[
"This",
"method",
"writes",
"data",
"for",
"a",
"single",
"calendar",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L216-L285
|
157,174
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.processWorkingHours
|
private void processWorkingHours(ProjectCalendar mpxjCalendar, Sequence uniqueID, Day day, List<OverriddenDayType> typeList)
{
if (isWorkingDay(mpxjCalendar, day))
{
ProjectCalendarHours mpxjHours = mpxjCalendar.getCalendarHours(day);
if (mpxjHours != null)
{
OverriddenDayType odt = m_factory.createOverriddenDayType();
typeList.add(odt);
odt.setId(getIntegerString(uniqueID.next()));
List<Interval> intervalList = odt.getInterval();
for (DateRange mpxjRange : mpxjHours)
{
Date rangeStart = mpxjRange.getStart();
Date rangeEnd = mpxjRange.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Interval interval = m_factory.createInterval();
intervalList.add(interval);
interval.setStart(getTimeString(rangeStart));
interval.setEnd(getTimeString(rangeEnd));
}
}
}
}
}
|
java
|
private void processWorkingHours(ProjectCalendar mpxjCalendar, Sequence uniqueID, Day day, List<OverriddenDayType> typeList)
{
if (isWorkingDay(mpxjCalendar, day))
{
ProjectCalendarHours mpxjHours = mpxjCalendar.getCalendarHours(day);
if (mpxjHours != null)
{
OverriddenDayType odt = m_factory.createOverriddenDayType();
typeList.add(odt);
odt.setId(getIntegerString(uniqueID.next()));
List<Interval> intervalList = odt.getInterval();
for (DateRange mpxjRange : mpxjHours)
{
Date rangeStart = mpxjRange.getStart();
Date rangeEnd = mpxjRange.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Interval interval = m_factory.createInterval();
intervalList.add(interval);
interval.setStart(getTimeString(rangeStart));
interval.setEnd(getTimeString(rangeEnd));
}
}
}
}
}
|
[
"private",
"void",
"processWorkingHours",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"Sequence",
"uniqueID",
",",
"Day",
"day",
",",
"List",
"<",
"OverriddenDayType",
">",
"typeList",
")",
"{",
"if",
"(",
"isWorkingDay",
"(",
"mpxjCalendar",
",",
"day",
")",
")",
"{",
"ProjectCalendarHours",
"mpxjHours",
"=",
"mpxjCalendar",
".",
"getCalendarHours",
"(",
"day",
")",
";",
"if",
"(",
"mpxjHours",
"!=",
"null",
")",
"{",
"OverriddenDayType",
"odt",
"=",
"m_factory",
".",
"createOverriddenDayType",
"(",
")",
";",
"typeList",
".",
"add",
"(",
"odt",
")",
";",
"odt",
".",
"setId",
"(",
"getIntegerString",
"(",
"uniqueID",
".",
"next",
"(",
")",
")",
")",
";",
"List",
"<",
"Interval",
">",
"intervalList",
"=",
"odt",
".",
"getInterval",
"(",
")",
";",
"for",
"(",
"DateRange",
"mpxjRange",
":",
"mpxjHours",
")",
"{",
"Date",
"rangeStart",
"=",
"mpxjRange",
".",
"getStart",
"(",
")",
";",
"Date",
"rangeEnd",
"=",
"mpxjRange",
".",
"getEnd",
"(",
")",
";",
"if",
"(",
"rangeStart",
"!=",
"null",
"&&",
"rangeEnd",
"!=",
"null",
")",
"{",
"Interval",
"interval",
"=",
"m_factory",
".",
"createInterval",
"(",
")",
";",
"intervalList",
".",
"add",
"(",
"interval",
")",
";",
"interval",
".",
"setStart",
"(",
"getTimeString",
"(",
"rangeStart",
")",
")",
";",
"interval",
".",
"setEnd",
"(",
"getTimeString",
"(",
"rangeEnd",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Process the standard working hours for a given day.
@param mpxjCalendar MPXJ Calendar instance
@param uniqueID unique ID sequence generation
@param day Day instance
@param typeList Planner list of days
|
[
"Process",
"the",
"standard",
"working",
"hours",
"for",
"a",
"given",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L295-L321
|
157,175
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeResources
|
private void writeResources()
{
Resources resources = m_factory.createResources();
m_plannerProject.setResources(resources);
List<net.sf.mpxj.planner.schema.Resource> resourceList = resources.getResource();
for (Resource mpxjResource : m_projectFile.getResources())
{
net.sf.mpxj.planner.schema.Resource plannerResource = m_factory.createResource();
resourceList.add(plannerResource);
writeResource(mpxjResource, plannerResource);
}
}
|
java
|
private void writeResources()
{
Resources resources = m_factory.createResources();
m_plannerProject.setResources(resources);
List<net.sf.mpxj.planner.schema.Resource> resourceList = resources.getResource();
for (Resource mpxjResource : m_projectFile.getResources())
{
net.sf.mpxj.planner.schema.Resource plannerResource = m_factory.createResource();
resourceList.add(plannerResource);
writeResource(mpxjResource, plannerResource);
}
}
|
[
"private",
"void",
"writeResources",
"(",
")",
"{",
"Resources",
"resources",
"=",
"m_factory",
".",
"createResources",
"(",
")",
";",
"m_plannerProject",
".",
"setResources",
"(",
"resources",
")",
";",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Resource",
">",
"resourceList",
"=",
"resources",
".",
"getResource",
"(",
")",
";",
"for",
"(",
"Resource",
"mpxjResource",
":",
"m_projectFile",
".",
"getResources",
"(",
")",
")",
"{",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Resource",
"plannerResource",
"=",
"m_factory",
".",
"createResource",
"(",
")",
";",
"resourceList",
".",
"add",
"(",
"plannerResource",
")",
";",
"writeResource",
"(",
"mpxjResource",
",",
"plannerResource",
")",
";",
"}",
"}"
] |
This method writes resource data to a Planner file.
|
[
"This",
"method",
"writes",
"resource",
"data",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L375-L386
|
157,176
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeResource
|
private void writeResource(Resource mpxjResource, net.sf.mpxj.planner.schema.Resource plannerResource)
{
ProjectCalendar resourceCalendar = mpxjResource.getResourceCalendar();
if (resourceCalendar != null)
{
plannerResource.setCalendar(getIntegerString(resourceCalendar.getUniqueID()));
}
plannerResource.setEmail(mpxjResource.getEmailAddress());
plannerResource.setId(getIntegerString(mpxjResource.getUniqueID()));
plannerResource.setName(getString(mpxjResource.getName()));
plannerResource.setNote(mpxjResource.getNotes());
plannerResource.setShortName(mpxjResource.getInitials());
plannerResource.setType(mpxjResource.getType() == ResourceType.MATERIAL ? "2" : "1");
//plannerResource.setStdRate();
//plannerResource.setOvtRate();
plannerResource.setUnits("0");
//plannerResource.setProperties();
m_eventManager.fireResourceWrittenEvent(mpxjResource);
}
|
java
|
private void writeResource(Resource mpxjResource, net.sf.mpxj.planner.schema.Resource plannerResource)
{
ProjectCalendar resourceCalendar = mpxjResource.getResourceCalendar();
if (resourceCalendar != null)
{
plannerResource.setCalendar(getIntegerString(resourceCalendar.getUniqueID()));
}
plannerResource.setEmail(mpxjResource.getEmailAddress());
plannerResource.setId(getIntegerString(mpxjResource.getUniqueID()));
plannerResource.setName(getString(mpxjResource.getName()));
plannerResource.setNote(mpxjResource.getNotes());
plannerResource.setShortName(mpxjResource.getInitials());
plannerResource.setType(mpxjResource.getType() == ResourceType.MATERIAL ? "2" : "1");
//plannerResource.setStdRate();
//plannerResource.setOvtRate();
plannerResource.setUnits("0");
//plannerResource.setProperties();
m_eventManager.fireResourceWrittenEvent(mpxjResource);
}
|
[
"private",
"void",
"writeResource",
"(",
"Resource",
"mpxjResource",
",",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Resource",
"plannerResource",
")",
"{",
"ProjectCalendar",
"resourceCalendar",
"=",
"mpxjResource",
".",
"getResourceCalendar",
"(",
")",
";",
"if",
"(",
"resourceCalendar",
"!=",
"null",
")",
"{",
"plannerResource",
".",
"setCalendar",
"(",
"getIntegerString",
"(",
"resourceCalendar",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"}",
"plannerResource",
".",
"setEmail",
"(",
"mpxjResource",
".",
"getEmailAddress",
"(",
")",
")",
";",
"plannerResource",
".",
"setId",
"(",
"getIntegerString",
"(",
"mpxjResource",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"plannerResource",
".",
"setName",
"(",
"getString",
"(",
"mpxjResource",
".",
"getName",
"(",
")",
")",
")",
";",
"plannerResource",
".",
"setNote",
"(",
"mpxjResource",
".",
"getNotes",
"(",
")",
")",
";",
"plannerResource",
".",
"setShortName",
"(",
"mpxjResource",
".",
"getInitials",
"(",
")",
")",
";",
"plannerResource",
".",
"setType",
"(",
"mpxjResource",
".",
"getType",
"(",
")",
"==",
"ResourceType",
".",
"MATERIAL",
"?",
"\"2\"",
":",
"\"1\"",
")",
";",
"//plannerResource.setStdRate();",
"//plannerResource.setOvtRate();",
"plannerResource",
".",
"setUnits",
"(",
"\"0\"",
")",
";",
"//plannerResource.setProperties();",
"m_eventManager",
".",
"fireResourceWrittenEvent",
"(",
"mpxjResource",
")",
";",
"}"
] |
This method writes data for a single resource to a Planner file.
@param mpxjResource MPXJ Resource instance
@param plannerResource Planner Resource instance
|
[
"This",
"method",
"writes",
"data",
"for",
"a",
"single",
"resource",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L394-L413
|
157,177
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeTasks
|
private void writeTasks() throws JAXBException
{
Tasks tasks = m_factory.createTasks();
m_plannerProject.setTasks(tasks);
List<net.sf.mpxj.planner.schema.Task> taskList = tasks.getTask();
for (Task task : m_projectFile.getChildTasks())
{
writeTask(task, taskList);
}
}
|
java
|
private void writeTasks() throws JAXBException
{
Tasks tasks = m_factory.createTasks();
m_plannerProject.setTasks(tasks);
List<net.sf.mpxj.planner.schema.Task> taskList = tasks.getTask();
for (Task task : m_projectFile.getChildTasks())
{
writeTask(task, taskList);
}
}
|
[
"private",
"void",
"writeTasks",
"(",
")",
"throws",
"JAXBException",
"{",
"Tasks",
"tasks",
"=",
"m_factory",
".",
"createTasks",
"(",
")",
";",
"m_plannerProject",
".",
"setTasks",
"(",
"tasks",
")",
";",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
">",
"taskList",
"=",
"tasks",
".",
"getTask",
"(",
")",
";",
"for",
"(",
"Task",
"task",
":",
"m_projectFile",
".",
"getChildTasks",
"(",
")",
")",
"{",
"writeTask",
"(",
"task",
",",
"taskList",
")",
";",
"}",
"}"
] |
This method writes task data to a Planner file.
@throws JAXBException on xml creation errors
|
[
"This",
"method",
"writes",
"task",
"data",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L420-L429
|
157,178
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeTask
|
private void writeTask(Task mpxjTask, List<net.sf.mpxj.planner.schema.Task> taskList) throws JAXBException
{
net.sf.mpxj.planner.schema.Task plannerTask = m_factory.createTask();
taskList.add(plannerTask);
plannerTask.setEnd(getDateTimeString(mpxjTask.getFinish()));
plannerTask.setId(getIntegerString(mpxjTask.getUniqueID()));
plannerTask.setName(getString(mpxjTask.getName()));
plannerTask.setNote(mpxjTask.getNotes());
plannerTask.setPercentComplete(getIntegerString(mpxjTask.getPercentageWorkComplete()));
plannerTask.setPriority(mpxjTask.getPriority() == null ? null : getIntegerString(mpxjTask.getPriority().getValue() * 10));
plannerTask.setScheduling(getScheduling(mpxjTask.getType()));
plannerTask.setStart(getDateTimeString(DateHelper.getDayStartDate(mpxjTask.getStart())));
if (mpxjTask.getMilestone())
{
plannerTask.setType("milestone");
}
else
{
plannerTask.setType("normal");
}
plannerTask.setWork(getDurationString(mpxjTask.getWork()));
plannerTask.setWorkStart(getDateTimeString(mpxjTask.getStart()));
ConstraintType mpxjConstraintType = mpxjTask.getConstraintType();
if (mpxjConstraintType != ConstraintType.AS_SOON_AS_POSSIBLE)
{
Constraint plannerConstraint = m_factory.createConstraint();
plannerTask.setConstraint(plannerConstraint);
if (mpxjConstraintType == ConstraintType.START_NO_EARLIER_THAN)
{
plannerConstraint.setType("start-no-earlier-than");
}
else
{
if (mpxjConstraintType == ConstraintType.MUST_START_ON)
{
plannerConstraint.setType("must-start-on");
}
}
plannerConstraint.setTime(getDateTimeString(mpxjTask.getConstraintDate()));
}
//
// Write predecessors
//
writePredecessors(mpxjTask, plannerTask);
m_eventManager.fireTaskWrittenEvent(mpxjTask);
//
// Write child tasks
//
List<net.sf.mpxj.planner.schema.Task> childTaskList = plannerTask.getTask();
for (Task task : mpxjTask.getChildTasks())
{
writeTask(task, childTaskList);
}
}
|
java
|
private void writeTask(Task mpxjTask, List<net.sf.mpxj.planner.schema.Task> taskList) throws JAXBException
{
net.sf.mpxj.planner.schema.Task plannerTask = m_factory.createTask();
taskList.add(plannerTask);
plannerTask.setEnd(getDateTimeString(mpxjTask.getFinish()));
plannerTask.setId(getIntegerString(mpxjTask.getUniqueID()));
plannerTask.setName(getString(mpxjTask.getName()));
plannerTask.setNote(mpxjTask.getNotes());
plannerTask.setPercentComplete(getIntegerString(mpxjTask.getPercentageWorkComplete()));
plannerTask.setPriority(mpxjTask.getPriority() == null ? null : getIntegerString(mpxjTask.getPriority().getValue() * 10));
plannerTask.setScheduling(getScheduling(mpxjTask.getType()));
plannerTask.setStart(getDateTimeString(DateHelper.getDayStartDate(mpxjTask.getStart())));
if (mpxjTask.getMilestone())
{
plannerTask.setType("milestone");
}
else
{
plannerTask.setType("normal");
}
plannerTask.setWork(getDurationString(mpxjTask.getWork()));
plannerTask.setWorkStart(getDateTimeString(mpxjTask.getStart()));
ConstraintType mpxjConstraintType = mpxjTask.getConstraintType();
if (mpxjConstraintType != ConstraintType.AS_SOON_AS_POSSIBLE)
{
Constraint plannerConstraint = m_factory.createConstraint();
plannerTask.setConstraint(plannerConstraint);
if (mpxjConstraintType == ConstraintType.START_NO_EARLIER_THAN)
{
plannerConstraint.setType("start-no-earlier-than");
}
else
{
if (mpxjConstraintType == ConstraintType.MUST_START_ON)
{
plannerConstraint.setType("must-start-on");
}
}
plannerConstraint.setTime(getDateTimeString(mpxjTask.getConstraintDate()));
}
//
// Write predecessors
//
writePredecessors(mpxjTask, plannerTask);
m_eventManager.fireTaskWrittenEvent(mpxjTask);
//
// Write child tasks
//
List<net.sf.mpxj.planner.schema.Task> childTaskList = plannerTask.getTask();
for (Task task : mpxjTask.getChildTasks())
{
writeTask(task, childTaskList);
}
}
|
[
"private",
"void",
"writeTask",
"(",
"Task",
"mpxjTask",
",",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
">",
"taskList",
")",
"throws",
"JAXBException",
"{",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"plannerTask",
"=",
"m_factory",
".",
"createTask",
"(",
")",
";",
"taskList",
".",
"add",
"(",
"plannerTask",
")",
";",
"plannerTask",
".",
"setEnd",
"(",
"getDateTimeString",
"(",
"mpxjTask",
".",
"getFinish",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setId",
"(",
"getIntegerString",
"(",
"mpxjTask",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setName",
"(",
"getString",
"(",
"mpxjTask",
".",
"getName",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setNote",
"(",
"mpxjTask",
".",
"getNotes",
"(",
")",
")",
";",
"plannerTask",
".",
"setPercentComplete",
"(",
"getIntegerString",
"(",
"mpxjTask",
".",
"getPercentageWorkComplete",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setPriority",
"(",
"mpxjTask",
".",
"getPriority",
"(",
")",
"==",
"null",
"?",
"null",
":",
"getIntegerString",
"(",
"mpxjTask",
".",
"getPriority",
"(",
")",
".",
"getValue",
"(",
")",
"*",
"10",
")",
")",
";",
"plannerTask",
".",
"setScheduling",
"(",
"getScheduling",
"(",
"mpxjTask",
".",
"getType",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setStart",
"(",
"getDateTimeString",
"(",
"DateHelper",
".",
"getDayStartDate",
"(",
"mpxjTask",
".",
"getStart",
"(",
")",
")",
")",
")",
";",
"if",
"(",
"mpxjTask",
".",
"getMilestone",
"(",
")",
")",
"{",
"plannerTask",
".",
"setType",
"(",
"\"milestone\"",
")",
";",
"}",
"else",
"{",
"plannerTask",
".",
"setType",
"(",
"\"normal\"",
")",
";",
"}",
"plannerTask",
".",
"setWork",
"(",
"getDurationString",
"(",
"mpxjTask",
".",
"getWork",
"(",
")",
")",
")",
";",
"plannerTask",
".",
"setWorkStart",
"(",
"getDateTimeString",
"(",
"mpxjTask",
".",
"getStart",
"(",
")",
")",
")",
";",
"ConstraintType",
"mpxjConstraintType",
"=",
"mpxjTask",
".",
"getConstraintType",
"(",
")",
";",
"if",
"(",
"mpxjConstraintType",
"!=",
"ConstraintType",
".",
"AS_SOON_AS_POSSIBLE",
")",
"{",
"Constraint",
"plannerConstraint",
"=",
"m_factory",
".",
"createConstraint",
"(",
")",
";",
"plannerTask",
".",
"setConstraint",
"(",
"plannerConstraint",
")",
";",
"if",
"(",
"mpxjConstraintType",
"==",
"ConstraintType",
".",
"START_NO_EARLIER_THAN",
")",
"{",
"plannerConstraint",
".",
"setType",
"(",
"\"start-no-earlier-than\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"mpxjConstraintType",
"==",
"ConstraintType",
".",
"MUST_START_ON",
")",
"{",
"plannerConstraint",
".",
"setType",
"(",
"\"must-start-on\"",
")",
";",
"}",
"}",
"plannerConstraint",
".",
"setTime",
"(",
"getDateTimeString",
"(",
"mpxjTask",
".",
"getConstraintDate",
"(",
")",
")",
")",
";",
"}",
"//",
"// Write predecessors",
"//",
"writePredecessors",
"(",
"mpxjTask",
",",
"plannerTask",
")",
";",
"m_eventManager",
".",
"fireTaskWrittenEvent",
"(",
"mpxjTask",
")",
";",
"//",
"// Write child tasks",
"//",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
">",
"childTaskList",
"=",
"plannerTask",
".",
"getTask",
"(",
")",
";",
"for",
"(",
"Task",
"task",
":",
"mpxjTask",
".",
"getChildTasks",
"(",
")",
")",
"{",
"writeTask",
"(",
"task",
",",
"childTaskList",
")",
";",
"}",
"}"
] |
This method writes data for a single task to a Planner file.
@param mpxjTask MPXJ Task instance
@param taskList list of child tasks for current parent
|
[
"This",
"method",
"writes",
"data",
"for",
"a",
"single",
"task",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L437-L495
|
157,179
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writePredecessors
|
private void writePredecessors(Task mpxjTask, net.sf.mpxj.planner.schema.Task plannerTask)
{
Predecessors plannerPredecessors = m_factory.createPredecessors();
plannerTask.setPredecessors(plannerPredecessors);
List<Predecessor> predecessorList = plannerPredecessors.getPredecessor();
int id = 0;
List<Relation> predecessors = mpxjTask.getPredecessors();
for (Relation rel : predecessors)
{
Integer taskUniqueID = rel.getTargetTask().getUniqueID();
Predecessor plannerPredecessor = m_factory.createPredecessor();
plannerPredecessor.setId(getIntegerString(++id));
plannerPredecessor.setPredecessorId(getIntegerString(taskUniqueID));
plannerPredecessor.setLag(getDurationString(rel.getLag()));
plannerPredecessor.setType(RELATIONSHIP_TYPES.get(rel.getType()));
predecessorList.add(plannerPredecessor);
m_eventManager.fireRelationWrittenEvent(rel);
}
}
|
java
|
private void writePredecessors(Task mpxjTask, net.sf.mpxj.planner.schema.Task plannerTask)
{
Predecessors plannerPredecessors = m_factory.createPredecessors();
plannerTask.setPredecessors(plannerPredecessors);
List<Predecessor> predecessorList = plannerPredecessors.getPredecessor();
int id = 0;
List<Relation> predecessors = mpxjTask.getPredecessors();
for (Relation rel : predecessors)
{
Integer taskUniqueID = rel.getTargetTask().getUniqueID();
Predecessor plannerPredecessor = m_factory.createPredecessor();
plannerPredecessor.setId(getIntegerString(++id));
plannerPredecessor.setPredecessorId(getIntegerString(taskUniqueID));
plannerPredecessor.setLag(getDurationString(rel.getLag()));
plannerPredecessor.setType(RELATIONSHIP_TYPES.get(rel.getType()));
predecessorList.add(plannerPredecessor);
m_eventManager.fireRelationWrittenEvent(rel);
}
}
|
[
"private",
"void",
"writePredecessors",
"(",
"Task",
"mpxjTask",
",",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"plannerTask",
")",
"{",
"Predecessors",
"plannerPredecessors",
"=",
"m_factory",
".",
"createPredecessors",
"(",
")",
";",
"plannerTask",
".",
"setPredecessors",
"(",
"plannerPredecessors",
")",
";",
"List",
"<",
"Predecessor",
">",
"predecessorList",
"=",
"plannerPredecessors",
".",
"getPredecessor",
"(",
")",
";",
"int",
"id",
"=",
"0",
";",
"List",
"<",
"Relation",
">",
"predecessors",
"=",
"mpxjTask",
".",
"getPredecessors",
"(",
")",
";",
"for",
"(",
"Relation",
"rel",
":",
"predecessors",
")",
"{",
"Integer",
"taskUniqueID",
"=",
"rel",
".",
"getTargetTask",
"(",
")",
".",
"getUniqueID",
"(",
")",
";",
"Predecessor",
"plannerPredecessor",
"=",
"m_factory",
".",
"createPredecessor",
"(",
")",
";",
"plannerPredecessor",
".",
"setId",
"(",
"getIntegerString",
"(",
"++",
"id",
")",
")",
";",
"plannerPredecessor",
".",
"setPredecessorId",
"(",
"getIntegerString",
"(",
"taskUniqueID",
")",
")",
";",
"plannerPredecessor",
".",
"setLag",
"(",
"getDurationString",
"(",
"rel",
".",
"getLag",
"(",
")",
")",
")",
";",
"plannerPredecessor",
".",
"setType",
"(",
"RELATIONSHIP_TYPES",
".",
"get",
"(",
"rel",
".",
"getType",
"(",
")",
")",
")",
";",
"predecessorList",
".",
"add",
"(",
"plannerPredecessor",
")",
";",
"m_eventManager",
".",
"fireRelationWrittenEvent",
"(",
"rel",
")",
";",
"}",
"}"
] |
This method writes predecessor data to a Planner file.
We have to deal with a slight anomaly in this method that is introduced
by the MPX file format. It would be possible for someone to create an
MPX file with both the predecessor list and the unique ID predecessor
list populated... which means that we must process both and avoid adding
duplicate predecessors. Also interesting to note is that MSP98 populates
the predecessor list, not the unique ID predecessor list, as you might
expect.
@param mpxjTask MPXJ task instance
@param plannerTask planner task instance
|
[
"This",
"method",
"writes",
"predecessor",
"data",
"to",
"a",
"Planner",
"file",
".",
"We",
"have",
"to",
"deal",
"with",
"a",
"slight",
"anomaly",
"in",
"this",
"method",
"that",
"is",
"introduced",
"by",
"the",
"MPX",
"file",
"format",
".",
"It",
"would",
"be",
"possible",
"for",
"someone",
"to",
"create",
"an",
"MPX",
"file",
"with",
"both",
"the",
"predecessor",
"list",
"and",
"the",
"unique",
"ID",
"predecessor",
"list",
"populated",
"...",
"which",
"means",
"that",
"we",
"must",
"process",
"both",
"and",
"avoid",
"adding",
"duplicate",
"predecessors",
".",
"Also",
"interesting",
"to",
"note",
"is",
"that",
"MSP98",
"populates",
"the",
"predecessor",
"list",
"not",
"the",
"unique",
"ID",
"predecessor",
"list",
"as",
"you",
"might",
"expect",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L510-L529
|
157,180
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.writeAssignments
|
private void writeAssignments()
{
Allocations allocations = m_factory.createAllocations();
m_plannerProject.setAllocations(allocations);
List<Allocation> allocationList = allocations.getAllocation();
for (ResourceAssignment mpxjAssignment : m_projectFile.getResourceAssignments())
{
Allocation plannerAllocation = m_factory.createAllocation();
allocationList.add(plannerAllocation);
plannerAllocation.setTaskId(getIntegerString(mpxjAssignment.getTask().getUniqueID()));
plannerAllocation.setResourceId(getIntegerString(mpxjAssignment.getResourceUniqueID()));
plannerAllocation.setUnits(getIntegerString(mpxjAssignment.getUnits()));
m_eventManager.fireAssignmentWrittenEvent(mpxjAssignment);
}
}
|
java
|
private void writeAssignments()
{
Allocations allocations = m_factory.createAllocations();
m_plannerProject.setAllocations(allocations);
List<Allocation> allocationList = allocations.getAllocation();
for (ResourceAssignment mpxjAssignment : m_projectFile.getResourceAssignments())
{
Allocation plannerAllocation = m_factory.createAllocation();
allocationList.add(plannerAllocation);
plannerAllocation.setTaskId(getIntegerString(mpxjAssignment.getTask().getUniqueID()));
plannerAllocation.setResourceId(getIntegerString(mpxjAssignment.getResourceUniqueID()));
plannerAllocation.setUnits(getIntegerString(mpxjAssignment.getUnits()));
m_eventManager.fireAssignmentWrittenEvent(mpxjAssignment);
}
}
|
[
"private",
"void",
"writeAssignments",
"(",
")",
"{",
"Allocations",
"allocations",
"=",
"m_factory",
".",
"createAllocations",
"(",
")",
";",
"m_plannerProject",
".",
"setAllocations",
"(",
"allocations",
")",
";",
"List",
"<",
"Allocation",
">",
"allocationList",
"=",
"allocations",
".",
"getAllocation",
"(",
")",
";",
"for",
"(",
"ResourceAssignment",
"mpxjAssignment",
":",
"m_projectFile",
".",
"getResourceAssignments",
"(",
")",
")",
"{",
"Allocation",
"plannerAllocation",
"=",
"m_factory",
".",
"createAllocation",
"(",
")",
";",
"allocationList",
".",
"add",
"(",
"plannerAllocation",
")",
";",
"plannerAllocation",
".",
"setTaskId",
"(",
"getIntegerString",
"(",
"mpxjAssignment",
".",
"getTask",
"(",
")",
".",
"getUniqueID",
"(",
")",
")",
")",
";",
"plannerAllocation",
".",
"setResourceId",
"(",
"getIntegerString",
"(",
"mpxjAssignment",
".",
"getResourceUniqueID",
"(",
")",
")",
")",
";",
"plannerAllocation",
".",
"setUnits",
"(",
"getIntegerString",
"(",
"mpxjAssignment",
".",
"getUnits",
"(",
")",
")",
")",
";",
"m_eventManager",
".",
"fireAssignmentWrittenEvent",
"(",
"mpxjAssignment",
")",
";",
"}",
"}"
] |
This method writes assignment data to a Planner file.
|
[
"This",
"method",
"writes",
"assignment",
"data",
"to",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L535-L552
|
157,181
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getIntegerString
|
private String getIntegerString(Number value)
{
return (value == null ? null : Integer.toString(value.intValue()));
}
|
java
|
private String getIntegerString(Number value)
{
return (value == null ? null : Integer.toString(value.intValue()));
}
|
[
"private",
"String",
"getIntegerString",
"(",
"Number",
"value",
")",
"{",
"return",
"(",
"value",
"==",
"null",
"?",
"null",
":",
"Integer",
".",
"toString",
"(",
"value",
".",
"intValue",
"(",
")",
")",
")",
";",
"}"
] |
Convert an Integer value into a String.
@param value Integer value
@return String value
|
[
"Convert",
"an",
"Integer",
"value",
"into",
"a",
"String",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L589-L592
|
157,182
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.isWorkingDay
|
private boolean isWorkingDay(ProjectCalendar mpxjCalendar, Day day)
{
boolean result = false;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = true;
break;
}
case NON_WORKING:
{
result = false;
break;
}
case DEFAULT:
{
if (mpxjCalendar.getParent() == null)
{
result = false;
}
else
{
result = isWorkingDay(mpxjCalendar.getParent(), day);
}
break;
}
}
return (result);
}
|
java
|
private boolean isWorkingDay(ProjectCalendar mpxjCalendar, Day day)
{
boolean result = false;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = true;
break;
}
case NON_WORKING:
{
result = false;
break;
}
case DEFAULT:
{
if (mpxjCalendar.getParent() == null)
{
result = false;
}
else
{
result = isWorkingDay(mpxjCalendar.getParent(), day);
}
break;
}
}
return (result);
}
|
[
"private",
"boolean",
"isWorkingDay",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"Day",
"day",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
"type",
"=",
"mpxjCalendar",
".",
"getWorkingDay",
"(",
"day",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
".",
"DEFAULT",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"WORKING",
":",
"{",
"result",
"=",
"true",
";",
"break",
";",
"}",
"case",
"NON_WORKING",
":",
"{",
"result",
"=",
"false",
";",
"break",
";",
"}",
"case",
"DEFAULT",
":",
"{",
"if",
"(",
"mpxjCalendar",
".",
"getParent",
"(",
")",
"==",
"null",
")",
"{",
"result",
"=",
"false",
";",
"}",
"else",
"{",
"result",
"=",
"isWorkingDay",
"(",
"mpxjCalendar",
".",
"getParent",
"(",
")",
",",
"day",
")",
";",
"}",
"break",
";",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Used to determine if a particular day of the week is normally
a working day.
@param mpxjCalendar ProjectCalendar instance
@param day Day instance
@return boolean flag
|
[
"Used",
"to",
"determine",
"if",
"a",
"particular",
"day",
"of",
"the",
"week",
"is",
"normally",
"a",
"working",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L613-L651
|
157,183
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getWorkingDayString
|
private String getWorkingDayString(ProjectCalendar mpxjCalendar, Day day)
{
String result = null;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = "0";
break;
}
case NON_WORKING:
{
result = "1";
break;
}
case DEFAULT:
{
result = "2";
break;
}
}
return (result);
}
|
java
|
private String getWorkingDayString(ProjectCalendar mpxjCalendar, Day day)
{
String result = null;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = "0";
break;
}
case NON_WORKING:
{
result = "1";
break;
}
case DEFAULT:
{
result = "2";
break;
}
}
return (result);
}
|
[
"private",
"String",
"getWorkingDayString",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"Day",
"day",
")",
"{",
"String",
"result",
"=",
"null",
";",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
"type",
"=",
"mpxjCalendar",
".",
"getWorkingDay",
"(",
"day",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
".",
"DEFAULT",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"WORKING",
":",
"{",
"result",
"=",
"\"0\"",
";",
"break",
";",
"}",
"case",
"NON_WORKING",
":",
"{",
"result",
"=",
"\"1\"",
";",
"break",
";",
"}",
"case",
"DEFAULT",
":",
"{",
"result",
"=",
"\"2\"",
";",
"break",
";",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Returns a flag represented as a String, indicating if
the supplied day is a working day.
@param mpxjCalendar MPXJ ProjectCalendar instance
@param day Day instance
@return boolean flag as a string
|
[
"Returns",
"a",
"flag",
"represented",
"as",
"a",
"String",
"indicating",
"if",
"the",
"supplied",
"day",
"is",
"a",
"working",
"day",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L661-L692
|
157,184
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getTimeString
|
private String getTimeString(Date value)
{
Calendar cal = DateHelper.popCalendar(value);
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
DateHelper.pushCalendar(cal);
StringBuilder sb = new StringBuilder(4);
sb.append(m_twoDigitFormat.format(hours));
sb.append(m_twoDigitFormat.format(minutes));
return (sb.toString());
}
|
java
|
private String getTimeString(Date value)
{
Calendar cal = DateHelper.popCalendar(value);
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
DateHelper.pushCalendar(cal);
StringBuilder sb = new StringBuilder(4);
sb.append(m_twoDigitFormat.format(hours));
sb.append(m_twoDigitFormat.format(minutes));
return (sb.toString());
}
|
[
"private",
"String",
"getTimeString",
"(",
"Date",
"value",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"value",
")",
";",
"int",
"hours",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
")",
";",
"int",
"minutes",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MINUTE",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"4",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"hours",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"minutes",
")",
")",
";",
"return",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Convert a Java date into a Planner time.
0800
@param value Java Date instance
@return Planner time value
|
[
"Convert",
"a",
"Java",
"date",
"into",
"a",
"Planner",
"time",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L702-L714
|
157,185
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getDateString
|
private String getDateString(Date value)
{
Calendar cal = DateHelper.popCalendar(value);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
DateHelper.pushCalendar(cal);
StringBuilder sb = new StringBuilder(8);
sb.append(m_fourDigitFormat.format(year));
sb.append(m_twoDigitFormat.format(month));
sb.append(m_twoDigitFormat.format(day));
return (sb.toString());
}
|
java
|
private String getDateString(Date value)
{
Calendar cal = DateHelper.popCalendar(value);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
DateHelper.pushCalendar(cal);
StringBuilder sb = new StringBuilder(8);
sb.append(m_fourDigitFormat.format(year));
sb.append(m_twoDigitFormat.format(month));
sb.append(m_twoDigitFormat.format(day));
return (sb.toString());
}
|
[
"private",
"String",
"getDateString",
"(",
"Date",
"value",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"value",
")",
";",
"int",
"year",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"int",
"month",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
"+",
"1",
";",
"int",
"day",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"8",
")",
";",
"sb",
".",
"append",
"(",
"m_fourDigitFormat",
".",
"format",
"(",
"year",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"month",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"day",
")",
")",
";",
"return",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Convert a Java date into a Planner date.
20070222
@param value Java Date instance
@return Planner date
|
[
"Convert",
"a",
"Java",
"date",
"into",
"a",
"Planner",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L724-L738
|
157,186
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getDateTimeString
|
private String getDateTimeString(Date value)
{
String result = null;
if (value != null)
{
Calendar cal = DateHelper.popCalendar(value);
StringBuilder sb = new StringBuilder(16);
sb.append(m_fourDigitFormat.format(cal.get(Calendar.YEAR)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.MONTH) + 1));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.DAY_OF_MONTH)));
sb.append('T');
sb.append(m_twoDigitFormat.format(cal.get(Calendar.HOUR_OF_DAY)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.MINUTE)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.SECOND)));
sb.append('Z');
result = sb.toString();
DateHelper.pushCalendar(cal);
}
return result;
}
|
java
|
private String getDateTimeString(Date value)
{
String result = null;
if (value != null)
{
Calendar cal = DateHelper.popCalendar(value);
StringBuilder sb = new StringBuilder(16);
sb.append(m_fourDigitFormat.format(cal.get(Calendar.YEAR)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.MONTH) + 1));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.DAY_OF_MONTH)));
sb.append('T');
sb.append(m_twoDigitFormat.format(cal.get(Calendar.HOUR_OF_DAY)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.MINUTE)));
sb.append(m_twoDigitFormat.format(cal.get(Calendar.SECOND)));
sb.append('Z');
result = sb.toString();
DateHelper.pushCalendar(cal);
}
return result;
}
|
[
"private",
"String",
"getDateTimeString",
"(",
"Date",
"value",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"value",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"16",
")",
";",
"sb",
".",
"append",
"(",
"m_fourDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
"+",
"1",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MINUTE",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"m_twoDigitFormat",
".",
"format",
"(",
"cal",
".",
"get",
"(",
"Calendar",
".",
"SECOND",
")",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Convert a Java date into a Planner date-time string.
20070222T080000Z
@param value Java date
@return Planner date-time string
|
[
"Convert",
"a",
"Java",
"date",
"into",
"a",
"Planner",
"date",
"-",
"time",
"string",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L748-L767
|
157,187
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.getDurationString
|
private String getDurationString(Duration value)
{
String result = null;
if (value != null)
{
double seconds = 0;
switch (value.getUnits())
{
case MINUTES:
case ELAPSED_MINUTES:
{
seconds = value.getDuration() * 60;
break;
}
case HOURS:
case ELAPSED_HOURS:
{
seconds = value.getDuration() * (60 * 60);
break;
}
case DAYS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
seconds = value.getDuration() * (minutesPerDay * 60);
break;
}
case ELAPSED_DAYS:
{
seconds = value.getDuration() * (24 * 60 * 60);
break;
}
case WEEKS:
{
double minutesPerWeek = m_projectFile.getProjectProperties().getMinutesPerWeek().doubleValue();
seconds = value.getDuration() * (minutesPerWeek * 60);
break;
}
case ELAPSED_WEEKS:
{
seconds = value.getDuration() * (7 * 24 * 60 * 60);
break;
}
case MONTHS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
double daysPerMonth = m_projectFile.getProjectProperties().getDaysPerMonth().doubleValue();
seconds = value.getDuration() * (daysPerMonth * minutesPerDay * 60);
break;
}
case ELAPSED_MONTHS:
{
seconds = value.getDuration() * (30 * 24 * 60 * 60);
break;
}
case YEARS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
double daysPerMonth = m_projectFile.getProjectProperties().getDaysPerMonth().doubleValue();
seconds = value.getDuration() * (12 * daysPerMonth * minutesPerDay * 60);
break;
}
case ELAPSED_YEARS:
{
seconds = value.getDuration() * (365 * 24 * 60 * 60);
break;
}
default:
{
break;
}
}
result = Long.toString((long) seconds);
}
return (result);
}
|
java
|
private String getDurationString(Duration value)
{
String result = null;
if (value != null)
{
double seconds = 0;
switch (value.getUnits())
{
case MINUTES:
case ELAPSED_MINUTES:
{
seconds = value.getDuration() * 60;
break;
}
case HOURS:
case ELAPSED_HOURS:
{
seconds = value.getDuration() * (60 * 60);
break;
}
case DAYS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
seconds = value.getDuration() * (minutesPerDay * 60);
break;
}
case ELAPSED_DAYS:
{
seconds = value.getDuration() * (24 * 60 * 60);
break;
}
case WEEKS:
{
double minutesPerWeek = m_projectFile.getProjectProperties().getMinutesPerWeek().doubleValue();
seconds = value.getDuration() * (minutesPerWeek * 60);
break;
}
case ELAPSED_WEEKS:
{
seconds = value.getDuration() * (7 * 24 * 60 * 60);
break;
}
case MONTHS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
double daysPerMonth = m_projectFile.getProjectProperties().getDaysPerMonth().doubleValue();
seconds = value.getDuration() * (daysPerMonth * minutesPerDay * 60);
break;
}
case ELAPSED_MONTHS:
{
seconds = value.getDuration() * (30 * 24 * 60 * 60);
break;
}
case YEARS:
{
double minutesPerDay = m_projectFile.getProjectProperties().getMinutesPerDay().doubleValue();
double daysPerMonth = m_projectFile.getProjectProperties().getDaysPerMonth().doubleValue();
seconds = value.getDuration() * (12 * daysPerMonth * minutesPerDay * 60);
break;
}
case ELAPSED_YEARS:
{
seconds = value.getDuration() * (365 * 24 * 60 * 60);
break;
}
default:
{
break;
}
}
result = Long.toString((long) seconds);
}
return (result);
}
|
[
"private",
"String",
"getDurationString",
"(",
"Duration",
"value",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"double",
"seconds",
"=",
"0",
";",
"switch",
"(",
"value",
".",
"getUnits",
"(",
")",
")",
"{",
"case",
"MINUTES",
":",
"case",
"ELAPSED_MINUTES",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"60",
";",
"break",
";",
"}",
"case",
"HOURS",
":",
"case",
"ELAPSED_HOURS",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"60",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"DAYS",
":",
"{",
"double",
"minutesPerDay",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerDay",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"minutesPerDay",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_DAYS",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"24",
"*",
"60",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"WEEKS",
":",
"{",
"double",
"minutesPerWeek",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerWeek",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"minutesPerWeek",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_WEEKS",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"7",
"*",
"24",
"*",
"60",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"MONTHS",
":",
"{",
"double",
"minutesPerDay",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerDay",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"daysPerMonth",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getDaysPerMonth",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"daysPerMonth",
"*",
"minutesPerDay",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_MONTHS",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"30",
"*",
"24",
"*",
"60",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"YEARS",
":",
"{",
"double",
"minutesPerDay",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getMinutesPerDay",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"daysPerMonth",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"getDaysPerMonth",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"12",
"*",
"daysPerMonth",
"*",
"minutesPerDay",
"*",
"60",
")",
";",
"break",
";",
"}",
"case",
"ELAPSED_YEARS",
":",
"{",
"seconds",
"=",
"value",
".",
"getDuration",
"(",
")",
"*",
"(",
"365",
"*",
"24",
"*",
"60",
"*",
"60",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"break",
";",
"}",
"}",
"result",
"=",
"Long",
".",
"toString",
"(",
"(",
"long",
")",
"seconds",
")",
";",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Converts an MPXJ Duration instance into the string representation
of a Planner duration.
Planner represents durations as a number of seconds in its
file format, however it displays durations as days and hours,
and seems to assume that a working day is 8 hours.
@param value string representation of a duration
@return Duration instance
|
[
"Converts",
"an",
"MPXJ",
"Duration",
"instance",
"into",
"the",
"string",
"representation",
"of",
"a",
"Planner",
"duration",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L780-L868
|
157,188
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readProjectProperties
|
private void readProjectProperties(Project project) throws MPXJException
{
ProjectProperties properties = m_projectFile.getProjectProperties();
properties.setCompany(project.getCompany());
properties.setManager(project.getManager());
properties.setName(project.getName());
properties.setStartDate(getDateTime(project.getProjectStart()));
}
|
java
|
private void readProjectProperties(Project project) throws MPXJException
{
ProjectProperties properties = m_projectFile.getProjectProperties();
properties.setCompany(project.getCompany());
properties.setManager(project.getManager());
properties.setName(project.getName());
properties.setStartDate(getDateTime(project.getProjectStart()));
}
|
[
"private",
"void",
"readProjectProperties",
"(",
"Project",
"project",
")",
"throws",
"MPXJException",
"{",
"ProjectProperties",
"properties",
"=",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
";",
"properties",
".",
"setCompany",
"(",
"project",
".",
"getCompany",
"(",
")",
")",
";",
"properties",
".",
"setManager",
"(",
"project",
".",
"getManager",
"(",
")",
")",
";",
"properties",
".",
"setName",
"(",
"project",
".",
"getName",
"(",
")",
")",
";",
"properties",
".",
"setStartDate",
"(",
"getDateTime",
"(",
"project",
".",
"getProjectStart",
"(",
")",
")",
")",
";",
"}"
] |
This method extracts project properties from a Planner file.
@param project Root node of the Planner file
|
[
"This",
"method",
"extracts",
"project",
"properties",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L189-L197
|
157,189
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readCalendars
|
private void readCalendars(Project project) throws MPXJException
{
Calendars calendars = project.getCalendars();
if (calendars != null)
{
for (net.sf.mpxj.planner.schema.Calendar cal : calendars.getCalendar())
{
readCalendar(cal, null);
}
Integer defaultCalendarID = getInteger(project.getCalendar());
m_defaultCalendar = m_projectFile.getCalendarByUniqueID(defaultCalendarID);
if (m_defaultCalendar != null)
{
m_projectFile.getProjectProperties().setDefaultCalendarName(m_defaultCalendar.getName());
}
}
}
|
java
|
private void readCalendars(Project project) throws MPXJException
{
Calendars calendars = project.getCalendars();
if (calendars != null)
{
for (net.sf.mpxj.planner.schema.Calendar cal : calendars.getCalendar())
{
readCalendar(cal, null);
}
Integer defaultCalendarID = getInteger(project.getCalendar());
m_defaultCalendar = m_projectFile.getCalendarByUniqueID(defaultCalendarID);
if (m_defaultCalendar != null)
{
m_projectFile.getProjectProperties().setDefaultCalendarName(m_defaultCalendar.getName());
}
}
}
|
[
"private",
"void",
"readCalendars",
"(",
"Project",
"project",
")",
"throws",
"MPXJException",
"{",
"Calendars",
"calendars",
"=",
"project",
".",
"getCalendars",
"(",
")",
";",
"if",
"(",
"calendars",
"!=",
"null",
")",
"{",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"cal",
":",
"calendars",
".",
"getCalendar",
"(",
")",
")",
"{",
"readCalendar",
"(",
"cal",
",",
"null",
")",
";",
"}",
"Integer",
"defaultCalendarID",
"=",
"getInteger",
"(",
"project",
".",
"getCalendar",
"(",
")",
")",
";",
"m_defaultCalendar",
"=",
"m_projectFile",
".",
"getCalendarByUniqueID",
"(",
"defaultCalendarID",
")",
";",
"if",
"(",
"m_defaultCalendar",
"!=",
"null",
")",
"{",
"m_projectFile",
".",
"getProjectProperties",
"(",
")",
".",
"setDefaultCalendarName",
"(",
"m_defaultCalendar",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
This method extracts calendar data from a Planner file.
@param project Root node of the Planner file
|
[
"This",
"method",
"extracts",
"calendar",
"data",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L204-L221
|
157,190
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readCalendar
|
private void readCalendar(net.sf.mpxj.planner.schema.Calendar plannerCalendar, ProjectCalendar parentMpxjCalendar) throws MPXJException
{
//
// Create a calendar instance
//
ProjectCalendar mpxjCalendar = m_projectFile.addCalendar();
//
// Populate basic details
//
mpxjCalendar.setUniqueID(getInteger(plannerCalendar.getId()));
mpxjCalendar.setName(plannerCalendar.getName());
mpxjCalendar.setParent(parentMpxjCalendar);
//
// Set working and non working days
//
DefaultWeek dw = plannerCalendar.getDefaultWeek();
setWorkingDay(mpxjCalendar, Day.MONDAY, dw.getMon());
setWorkingDay(mpxjCalendar, Day.TUESDAY, dw.getTue());
setWorkingDay(mpxjCalendar, Day.WEDNESDAY, dw.getWed());
setWorkingDay(mpxjCalendar, Day.THURSDAY, dw.getThu());
setWorkingDay(mpxjCalendar, Day.FRIDAY, dw.getFri());
setWorkingDay(mpxjCalendar, Day.SATURDAY, dw.getSat());
setWorkingDay(mpxjCalendar, Day.SUNDAY, dw.getSun());
//
// Set working hours
//
processWorkingHours(mpxjCalendar, plannerCalendar);
//
// Process exception days
//
processExceptionDays(mpxjCalendar, plannerCalendar);
m_eventManager.fireCalendarReadEvent(mpxjCalendar);
//
// Process any derived calendars
//
List<net.sf.mpxj.planner.schema.Calendar> calendarList = plannerCalendar.getCalendar();
for (net.sf.mpxj.planner.schema.Calendar cal : calendarList)
{
readCalendar(cal, mpxjCalendar);
}
}
|
java
|
private void readCalendar(net.sf.mpxj.planner.schema.Calendar plannerCalendar, ProjectCalendar parentMpxjCalendar) throws MPXJException
{
//
// Create a calendar instance
//
ProjectCalendar mpxjCalendar = m_projectFile.addCalendar();
//
// Populate basic details
//
mpxjCalendar.setUniqueID(getInteger(plannerCalendar.getId()));
mpxjCalendar.setName(plannerCalendar.getName());
mpxjCalendar.setParent(parentMpxjCalendar);
//
// Set working and non working days
//
DefaultWeek dw = plannerCalendar.getDefaultWeek();
setWorkingDay(mpxjCalendar, Day.MONDAY, dw.getMon());
setWorkingDay(mpxjCalendar, Day.TUESDAY, dw.getTue());
setWorkingDay(mpxjCalendar, Day.WEDNESDAY, dw.getWed());
setWorkingDay(mpxjCalendar, Day.THURSDAY, dw.getThu());
setWorkingDay(mpxjCalendar, Day.FRIDAY, dw.getFri());
setWorkingDay(mpxjCalendar, Day.SATURDAY, dw.getSat());
setWorkingDay(mpxjCalendar, Day.SUNDAY, dw.getSun());
//
// Set working hours
//
processWorkingHours(mpxjCalendar, plannerCalendar);
//
// Process exception days
//
processExceptionDays(mpxjCalendar, plannerCalendar);
m_eventManager.fireCalendarReadEvent(mpxjCalendar);
//
// Process any derived calendars
//
List<net.sf.mpxj.planner.schema.Calendar> calendarList = plannerCalendar.getCalendar();
for (net.sf.mpxj.planner.schema.Calendar cal : calendarList)
{
readCalendar(cal, mpxjCalendar);
}
}
|
[
"private",
"void",
"readCalendar",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"plannerCalendar",
",",
"ProjectCalendar",
"parentMpxjCalendar",
")",
"throws",
"MPXJException",
"{",
"//",
"// Create a calendar instance",
"//",
"ProjectCalendar",
"mpxjCalendar",
"=",
"m_projectFile",
".",
"addCalendar",
"(",
")",
";",
"//",
"// Populate basic details",
"//",
"mpxjCalendar",
".",
"setUniqueID",
"(",
"getInteger",
"(",
"plannerCalendar",
".",
"getId",
"(",
")",
")",
")",
";",
"mpxjCalendar",
".",
"setName",
"(",
"plannerCalendar",
".",
"getName",
"(",
")",
")",
";",
"mpxjCalendar",
".",
"setParent",
"(",
"parentMpxjCalendar",
")",
";",
"//",
"// Set working and non working days",
"//",
"DefaultWeek",
"dw",
"=",
"plannerCalendar",
".",
"getDefaultWeek",
"(",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"MONDAY",
",",
"dw",
".",
"getMon",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"TUESDAY",
",",
"dw",
".",
"getTue",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"WEDNESDAY",
",",
"dw",
".",
"getWed",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"THURSDAY",
",",
"dw",
".",
"getThu",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"FRIDAY",
",",
"dw",
".",
"getFri",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"SATURDAY",
",",
"dw",
".",
"getSat",
"(",
")",
")",
";",
"setWorkingDay",
"(",
"mpxjCalendar",
",",
"Day",
".",
"SUNDAY",
",",
"dw",
".",
"getSun",
"(",
")",
")",
";",
"//",
"// Set working hours",
"//",
"processWorkingHours",
"(",
"mpxjCalendar",
",",
"plannerCalendar",
")",
";",
"//",
"// Process exception days",
"//",
"processExceptionDays",
"(",
"mpxjCalendar",
",",
"plannerCalendar",
")",
";",
"m_eventManager",
".",
"fireCalendarReadEvent",
"(",
"mpxjCalendar",
")",
";",
"//",
"// Process any derived calendars",
"//",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
">",
"calendarList",
"=",
"plannerCalendar",
".",
"getCalendar",
"(",
")",
";",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Calendar",
"cal",
":",
"calendarList",
")",
"{",
"readCalendar",
"(",
"cal",
",",
"mpxjCalendar",
")",
";",
"}",
"}"
] |
This method extracts data for a single calendar from a Planner file.
@param plannerCalendar Calendar data
@param parentMpxjCalendar parent of derived calendar
|
[
"This",
"method",
"extracts",
"data",
"for",
"a",
"single",
"calendar",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L229-L275
|
157,191
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readResources
|
private void readResources(Project plannerProject) throws MPXJException
{
Resources resources = plannerProject.getResources();
if (resources != null)
{
for (net.sf.mpxj.planner.schema.Resource res : resources.getResource())
{
readResource(res);
}
}
}
|
java
|
private void readResources(Project plannerProject) throws MPXJException
{
Resources resources = plannerProject.getResources();
if (resources != null)
{
for (net.sf.mpxj.planner.schema.Resource res : resources.getResource())
{
readResource(res);
}
}
}
|
[
"private",
"void",
"readResources",
"(",
"Project",
"plannerProject",
")",
"throws",
"MPXJException",
"{",
"Resources",
"resources",
"=",
"plannerProject",
".",
"getResources",
"(",
")",
";",
"if",
"(",
"resources",
"!=",
"null",
")",
"{",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Resource",
"res",
":",
"resources",
".",
"getResource",
"(",
")",
")",
"{",
"readResource",
"(",
"res",
")",
";",
"}",
"}",
"}"
] |
This method extracts resource data from a Planner file.
@param plannerProject Root node of the Planner file
|
[
"This",
"method",
"extracts",
"resource",
"data",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L463-L473
|
157,192
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readResource
|
private void readResource(net.sf.mpxj.planner.schema.Resource plannerResource) throws MPXJException
{
Resource mpxjResource = m_projectFile.addResource();
//mpxjResource.setResourceCalendar(m_projectFile.getBaseCalendarByUniqueID(getInteger(plannerResource.getCalendar())));
mpxjResource.setEmailAddress(plannerResource.getEmail());
mpxjResource.setUniqueID(getInteger(plannerResource.getId()));
mpxjResource.setName(plannerResource.getName());
mpxjResource.setNotes(plannerResource.getNote());
mpxjResource.setInitials(plannerResource.getShortName());
mpxjResource.setType(getInt(plannerResource.getType()) == 2 ? ResourceType.MATERIAL : ResourceType.WORK);
//plannerResource.getStdRate();
//plannerResource.getOvtRate();
//plannerResource.getUnits();
//plannerResource.getProperties();
ProjectCalendar calendar = mpxjResource.addResourceCalendar();
calendar.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);
ProjectCalendar baseCalendar = m_projectFile.getCalendarByUniqueID(getInteger(plannerResource.getCalendar()));
if (baseCalendar == null)
{
baseCalendar = m_defaultCalendar;
}
calendar.setParent(baseCalendar);
m_eventManager.fireResourceReadEvent(mpxjResource);
}
|
java
|
private void readResource(net.sf.mpxj.planner.schema.Resource plannerResource) throws MPXJException
{
Resource mpxjResource = m_projectFile.addResource();
//mpxjResource.setResourceCalendar(m_projectFile.getBaseCalendarByUniqueID(getInteger(plannerResource.getCalendar())));
mpxjResource.setEmailAddress(plannerResource.getEmail());
mpxjResource.setUniqueID(getInteger(plannerResource.getId()));
mpxjResource.setName(plannerResource.getName());
mpxjResource.setNotes(plannerResource.getNote());
mpxjResource.setInitials(plannerResource.getShortName());
mpxjResource.setType(getInt(plannerResource.getType()) == 2 ? ResourceType.MATERIAL : ResourceType.WORK);
//plannerResource.getStdRate();
//plannerResource.getOvtRate();
//plannerResource.getUnits();
//plannerResource.getProperties();
ProjectCalendar calendar = mpxjResource.addResourceCalendar();
calendar.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
calendar.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);
ProjectCalendar baseCalendar = m_projectFile.getCalendarByUniqueID(getInteger(plannerResource.getCalendar()));
if (baseCalendar == null)
{
baseCalendar = m_defaultCalendar;
}
calendar.setParent(baseCalendar);
m_eventManager.fireResourceReadEvent(mpxjResource);
}
|
[
"private",
"void",
"readResource",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Resource",
"plannerResource",
")",
"throws",
"MPXJException",
"{",
"Resource",
"mpxjResource",
"=",
"m_projectFile",
".",
"addResource",
"(",
")",
";",
"//mpxjResource.setResourceCalendar(m_projectFile.getBaseCalendarByUniqueID(getInteger(plannerResource.getCalendar())));",
"mpxjResource",
".",
"setEmailAddress",
"(",
"plannerResource",
".",
"getEmail",
"(",
")",
")",
";",
"mpxjResource",
".",
"setUniqueID",
"(",
"getInteger",
"(",
"plannerResource",
".",
"getId",
"(",
")",
")",
")",
";",
"mpxjResource",
".",
"setName",
"(",
"plannerResource",
".",
"getName",
"(",
")",
")",
";",
"mpxjResource",
".",
"setNotes",
"(",
"plannerResource",
".",
"getNote",
"(",
")",
")",
";",
"mpxjResource",
".",
"setInitials",
"(",
"plannerResource",
".",
"getShortName",
"(",
")",
")",
";",
"mpxjResource",
".",
"setType",
"(",
"getInt",
"(",
"plannerResource",
".",
"getType",
"(",
")",
")",
"==",
"2",
"?",
"ResourceType",
".",
"MATERIAL",
":",
"ResourceType",
".",
"WORK",
")",
";",
"//plannerResource.getStdRate();",
"//plannerResource.getOvtRate();",
"//plannerResource.getUnits();",
"//plannerResource.getProperties();",
"ProjectCalendar",
"calendar",
"=",
"mpxjResource",
".",
"addResourceCalendar",
"(",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"SUNDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"MONDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"TUESDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"WEDNESDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"THURSDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"FRIDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"calendar",
".",
"setWorkingDay",
"(",
"Day",
".",
"SATURDAY",
",",
"DayType",
".",
"DEFAULT",
")",
";",
"ProjectCalendar",
"baseCalendar",
"=",
"m_projectFile",
".",
"getCalendarByUniqueID",
"(",
"getInteger",
"(",
"plannerResource",
".",
"getCalendar",
"(",
")",
")",
")",
";",
"if",
"(",
"baseCalendar",
"==",
"null",
")",
"{",
"baseCalendar",
"=",
"m_defaultCalendar",
";",
"}",
"calendar",
".",
"setParent",
"(",
"baseCalendar",
")",
";",
"m_eventManager",
".",
"fireResourceReadEvent",
"(",
"mpxjResource",
")",
";",
"}"
] |
This method extracts data for a single resource from a Planner file.
@param plannerResource Resource data
|
[
"This",
"method",
"extracts",
"data",
"for",
"a",
"single",
"resource",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L480-L514
|
157,193
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readTasks
|
private void readTasks(Project plannerProject) throws MPXJException
{
Tasks tasks = plannerProject.getTasks();
if (tasks != null)
{
for (net.sf.mpxj.planner.schema.Task task : tasks.getTask())
{
readTask(null, task);
}
for (net.sf.mpxj.planner.schema.Task task : tasks.getTask())
{
readPredecessors(task);
}
}
m_projectFile.updateStructure();
}
|
java
|
private void readTasks(Project plannerProject) throws MPXJException
{
Tasks tasks = plannerProject.getTasks();
if (tasks != null)
{
for (net.sf.mpxj.planner.schema.Task task : tasks.getTask())
{
readTask(null, task);
}
for (net.sf.mpxj.planner.schema.Task task : tasks.getTask())
{
readPredecessors(task);
}
}
m_projectFile.updateStructure();
}
|
[
"private",
"void",
"readTasks",
"(",
"Project",
"plannerProject",
")",
"throws",
"MPXJException",
"{",
"Tasks",
"tasks",
"=",
"plannerProject",
".",
"getTasks",
"(",
")",
";",
"if",
"(",
"tasks",
"!=",
"null",
")",
"{",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"task",
":",
"tasks",
".",
"getTask",
"(",
")",
")",
"{",
"readTask",
"(",
"null",
",",
"task",
")",
";",
"}",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"task",
":",
"tasks",
".",
"getTask",
"(",
")",
")",
"{",
"readPredecessors",
"(",
"task",
")",
";",
"}",
"}",
"m_projectFile",
".",
"updateStructure",
"(",
")",
";",
"}"
] |
This method extracts task data from a Planner file.
@param plannerProject Root node of the Planner file
|
[
"This",
"method",
"extracts",
"task",
"data",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L521-L538
|
157,194
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readPredecessors
|
private void readPredecessors(net.sf.mpxj.planner.schema.Task plannerTask)
{
Task mpxjTask = m_projectFile.getTaskByUniqueID(getInteger(plannerTask.getId()));
Predecessors predecessors = plannerTask.getPredecessors();
if (predecessors != null)
{
List<Predecessor> predecessorList = predecessors.getPredecessor();
for (Predecessor predecessor : predecessorList)
{
Integer predecessorID = getInteger(predecessor.getPredecessorId());
Task predecessorTask = m_projectFile.getTaskByUniqueID(predecessorID);
if (predecessorTask != null)
{
Duration lag = getDuration(predecessor.getLag());
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.HOURS);
}
Relation relation = mpxjTask.addPredecessor(predecessorTask, RELATIONSHIP_TYPES.get(predecessor.getType()), lag);
m_eventManager.fireRelationReadEvent(relation);
}
}
}
//
// Process child tasks
//
List<net.sf.mpxj.planner.schema.Task> childTasks = plannerTask.getTask();
for (net.sf.mpxj.planner.schema.Task childTask : childTasks)
{
readPredecessors(childTask);
}
}
|
java
|
private void readPredecessors(net.sf.mpxj.planner.schema.Task plannerTask)
{
Task mpxjTask = m_projectFile.getTaskByUniqueID(getInteger(plannerTask.getId()));
Predecessors predecessors = plannerTask.getPredecessors();
if (predecessors != null)
{
List<Predecessor> predecessorList = predecessors.getPredecessor();
for (Predecessor predecessor : predecessorList)
{
Integer predecessorID = getInteger(predecessor.getPredecessorId());
Task predecessorTask = m_projectFile.getTaskByUniqueID(predecessorID);
if (predecessorTask != null)
{
Duration lag = getDuration(predecessor.getLag());
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.HOURS);
}
Relation relation = mpxjTask.addPredecessor(predecessorTask, RELATIONSHIP_TYPES.get(predecessor.getType()), lag);
m_eventManager.fireRelationReadEvent(relation);
}
}
}
//
// Process child tasks
//
List<net.sf.mpxj.planner.schema.Task> childTasks = plannerTask.getTask();
for (net.sf.mpxj.planner.schema.Task childTask : childTasks)
{
readPredecessors(childTask);
}
}
|
[
"private",
"void",
"readPredecessors",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"plannerTask",
")",
"{",
"Task",
"mpxjTask",
"=",
"m_projectFile",
".",
"getTaskByUniqueID",
"(",
"getInteger",
"(",
"plannerTask",
".",
"getId",
"(",
")",
")",
")",
";",
"Predecessors",
"predecessors",
"=",
"plannerTask",
".",
"getPredecessors",
"(",
")",
";",
"if",
"(",
"predecessors",
"!=",
"null",
")",
"{",
"List",
"<",
"Predecessor",
">",
"predecessorList",
"=",
"predecessors",
".",
"getPredecessor",
"(",
")",
";",
"for",
"(",
"Predecessor",
"predecessor",
":",
"predecessorList",
")",
"{",
"Integer",
"predecessorID",
"=",
"getInteger",
"(",
"predecessor",
".",
"getPredecessorId",
"(",
")",
")",
";",
"Task",
"predecessorTask",
"=",
"m_projectFile",
".",
"getTaskByUniqueID",
"(",
"predecessorID",
")",
";",
"if",
"(",
"predecessorTask",
"!=",
"null",
")",
"{",
"Duration",
"lag",
"=",
"getDuration",
"(",
"predecessor",
".",
"getLag",
"(",
")",
")",
";",
"if",
"(",
"lag",
"==",
"null",
")",
"{",
"lag",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"HOURS",
")",
";",
"}",
"Relation",
"relation",
"=",
"mpxjTask",
".",
"addPredecessor",
"(",
"predecessorTask",
",",
"RELATIONSHIP_TYPES",
".",
"get",
"(",
"predecessor",
".",
"getType",
"(",
")",
")",
",",
"lag",
")",
";",
"m_eventManager",
".",
"fireRelationReadEvent",
"(",
"relation",
")",
";",
"}",
"}",
"}",
"//",
"// Process child tasks",
"//",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
">",
"childTasks",
"=",
"plannerTask",
".",
"getTask",
"(",
")",
";",
"for",
"(",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Task",
"childTask",
":",
"childTasks",
")",
"{",
"readPredecessors",
"(",
"childTask",
")",
";",
"}",
"}"
] |
This method extracts predecessor data from a Planner file.
@param plannerTask Task data
|
[
"This",
"method",
"extracts",
"predecessor",
"data",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L660-L693
|
157,195
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.readAssignments
|
private void readAssignments(Project plannerProject)
{
Allocations allocations = plannerProject.getAllocations();
List<Allocation> allocationList = allocations.getAllocation();
Set<Task> tasksWithAssignments = new HashSet<Task>();
for (Allocation allocation : allocationList)
{
Integer taskID = getInteger(allocation.getTaskId());
Integer resourceID = getInteger(allocation.getResourceId());
Integer units = getInteger(allocation.getUnits());
Task task = m_projectFile.getTaskByUniqueID(taskID);
Resource resource = m_projectFile.getResourceByUniqueID(resourceID);
if (task != null && resource != null)
{
Duration work = task.getWork();
int percentComplete = NumberHelper.getInt(task.getPercentageComplete());
ResourceAssignment assignment = task.addResourceAssignment(resource);
assignment.setUnits(units);
assignment.setWork(work);
if (percentComplete != 0)
{
Duration actualWork = Duration.getInstance((work.getDuration() * percentComplete) / 100, work.getUnits());
assignment.setActualWork(actualWork);
assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
else
{
assignment.setRemainingWork(work);
}
assignment.setStart(task.getStart());
assignment.setFinish(task.getFinish());
tasksWithAssignments.add(task);
m_eventManager.fireAssignmentReadEvent(assignment);
}
}
//
// Adjust work per assignment for tasks with multiple assignments
//
for (Task task : tasksWithAssignments)
{
List<ResourceAssignment> assignments = task.getResourceAssignments();
if (assignments.size() > 1)
{
double maxUnits = 0;
for (ResourceAssignment assignment : assignments)
{
maxUnits += assignment.getUnits().doubleValue();
}
for (ResourceAssignment assignment : assignments)
{
Duration work = assignment.getWork();
double factor = assignment.getUnits().doubleValue() / maxUnits;
work = Duration.getInstance(work.getDuration() * factor, work.getUnits());
assignment.setWork(work);
Duration actualWork = assignment.getActualWork();
if (actualWork != null)
{
actualWork = Duration.getInstance(actualWork.getDuration() * factor, actualWork.getUnits());
assignment.setActualWork(actualWork);
}
Duration remainingWork = assignment.getRemainingWork();
if (remainingWork != null)
{
remainingWork = Duration.getInstance(remainingWork.getDuration() * factor, remainingWork.getUnits());
assignment.setRemainingWork(remainingWork);
}
}
}
}
}
|
java
|
private void readAssignments(Project plannerProject)
{
Allocations allocations = plannerProject.getAllocations();
List<Allocation> allocationList = allocations.getAllocation();
Set<Task> tasksWithAssignments = new HashSet<Task>();
for (Allocation allocation : allocationList)
{
Integer taskID = getInteger(allocation.getTaskId());
Integer resourceID = getInteger(allocation.getResourceId());
Integer units = getInteger(allocation.getUnits());
Task task = m_projectFile.getTaskByUniqueID(taskID);
Resource resource = m_projectFile.getResourceByUniqueID(resourceID);
if (task != null && resource != null)
{
Duration work = task.getWork();
int percentComplete = NumberHelper.getInt(task.getPercentageComplete());
ResourceAssignment assignment = task.addResourceAssignment(resource);
assignment.setUnits(units);
assignment.setWork(work);
if (percentComplete != 0)
{
Duration actualWork = Duration.getInstance((work.getDuration() * percentComplete) / 100, work.getUnits());
assignment.setActualWork(actualWork);
assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
else
{
assignment.setRemainingWork(work);
}
assignment.setStart(task.getStart());
assignment.setFinish(task.getFinish());
tasksWithAssignments.add(task);
m_eventManager.fireAssignmentReadEvent(assignment);
}
}
//
// Adjust work per assignment for tasks with multiple assignments
//
for (Task task : tasksWithAssignments)
{
List<ResourceAssignment> assignments = task.getResourceAssignments();
if (assignments.size() > 1)
{
double maxUnits = 0;
for (ResourceAssignment assignment : assignments)
{
maxUnits += assignment.getUnits().doubleValue();
}
for (ResourceAssignment assignment : assignments)
{
Duration work = assignment.getWork();
double factor = assignment.getUnits().doubleValue() / maxUnits;
work = Duration.getInstance(work.getDuration() * factor, work.getUnits());
assignment.setWork(work);
Duration actualWork = assignment.getActualWork();
if (actualWork != null)
{
actualWork = Duration.getInstance(actualWork.getDuration() * factor, actualWork.getUnits());
assignment.setActualWork(actualWork);
}
Duration remainingWork = assignment.getRemainingWork();
if (remainingWork != null)
{
remainingWork = Duration.getInstance(remainingWork.getDuration() * factor, remainingWork.getUnits());
assignment.setRemainingWork(remainingWork);
}
}
}
}
}
|
[
"private",
"void",
"readAssignments",
"(",
"Project",
"plannerProject",
")",
"{",
"Allocations",
"allocations",
"=",
"plannerProject",
".",
"getAllocations",
"(",
")",
";",
"List",
"<",
"Allocation",
">",
"allocationList",
"=",
"allocations",
".",
"getAllocation",
"(",
")",
";",
"Set",
"<",
"Task",
">",
"tasksWithAssignments",
"=",
"new",
"HashSet",
"<",
"Task",
">",
"(",
")",
";",
"for",
"(",
"Allocation",
"allocation",
":",
"allocationList",
")",
"{",
"Integer",
"taskID",
"=",
"getInteger",
"(",
"allocation",
".",
"getTaskId",
"(",
")",
")",
";",
"Integer",
"resourceID",
"=",
"getInteger",
"(",
"allocation",
".",
"getResourceId",
"(",
")",
")",
";",
"Integer",
"units",
"=",
"getInteger",
"(",
"allocation",
".",
"getUnits",
"(",
")",
")",
";",
"Task",
"task",
"=",
"m_projectFile",
".",
"getTaskByUniqueID",
"(",
"taskID",
")",
";",
"Resource",
"resource",
"=",
"m_projectFile",
".",
"getResourceByUniqueID",
"(",
"resourceID",
")",
";",
"if",
"(",
"task",
"!=",
"null",
"&&",
"resource",
"!=",
"null",
")",
"{",
"Duration",
"work",
"=",
"task",
".",
"getWork",
"(",
")",
";",
"int",
"percentComplete",
"=",
"NumberHelper",
".",
"getInt",
"(",
"task",
".",
"getPercentageComplete",
"(",
")",
")",
";",
"ResourceAssignment",
"assignment",
"=",
"task",
".",
"addResourceAssignment",
"(",
"resource",
")",
";",
"assignment",
".",
"setUnits",
"(",
"units",
")",
";",
"assignment",
".",
"setWork",
"(",
"work",
")",
";",
"if",
"(",
"percentComplete",
"!=",
"0",
")",
"{",
"Duration",
"actualWork",
"=",
"Duration",
".",
"getInstance",
"(",
"(",
"work",
".",
"getDuration",
"(",
")",
"*",
"percentComplete",
")",
"/",
"100",
",",
"work",
".",
"getUnits",
"(",
")",
")",
";",
"assignment",
".",
"setActualWork",
"(",
"actualWork",
")",
";",
"assignment",
".",
"setRemainingWork",
"(",
"Duration",
".",
"getInstance",
"(",
"work",
".",
"getDuration",
"(",
")",
"-",
"actualWork",
".",
"getDuration",
"(",
")",
",",
"work",
".",
"getUnits",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"assignment",
".",
"setRemainingWork",
"(",
"work",
")",
";",
"}",
"assignment",
".",
"setStart",
"(",
"task",
".",
"getStart",
"(",
")",
")",
";",
"assignment",
".",
"setFinish",
"(",
"task",
".",
"getFinish",
"(",
")",
")",
";",
"tasksWithAssignments",
".",
"add",
"(",
"task",
")",
";",
"m_eventManager",
".",
"fireAssignmentReadEvent",
"(",
"assignment",
")",
";",
"}",
"}",
"//",
"// Adjust work per assignment for tasks with multiple assignments",
"//",
"for",
"(",
"Task",
"task",
":",
"tasksWithAssignments",
")",
"{",
"List",
"<",
"ResourceAssignment",
">",
"assignments",
"=",
"task",
".",
"getResourceAssignments",
"(",
")",
";",
"if",
"(",
"assignments",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"double",
"maxUnits",
"=",
"0",
";",
"for",
"(",
"ResourceAssignment",
"assignment",
":",
"assignments",
")",
"{",
"maxUnits",
"+=",
"assignment",
".",
"getUnits",
"(",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"for",
"(",
"ResourceAssignment",
"assignment",
":",
"assignments",
")",
"{",
"Duration",
"work",
"=",
"assignment",
".",
"getWork",
"(",
")",
";",
"double",
"factor",
"=",
"assignment",
".",
"getUnits",
"(",
")",
".",
"doubleValue",
"(",
")",
"/",
"maxUnits",
";",
"work",
"=",
"Duration",
".",
"getInstance",
"(",
"work",
".",
"getDuration",
"(",
")",
"*",
"factor",
",",
"work",
".",
"getUnits",
"(",
")",
")",
";",
"assignment",
".",
"setWork",
"(",
"work",
")",
";",
"Duration",
"actualWork",
"=",
"assignment",
".",
"getActualWork",
"(",
")",
";",
"if",
"(",
"actualWork",
"!=",
"null",
")",
"{",
"actualWork",
"=",
"Duration",
".",
"getInstance",
"(",
"actualWork",
".",
"getDuration",
"(",
")",
"*",
"factor",
",",
"actualWork",
".",
"getUnits",
"(",
")",
")",
";",
"assignment",
".",
"setActualWork",
"(",
"actualWork",
")",
";",
"}",
"Duration",
"remainingWork",
"=",
"assignment",
".",
"getRemainingWork",
"(",
")",
";",
"if",
"(",
"remainingWork",
"!=",
"null",
")",
"{",
"remainingWork",
"=",
"Duration",
".",
"getInstance",
"(",
"remainingWork",
".",
"getDuration",
"(",
")",
"*",
"factor",
",",
"remainingWork",
".",
"getUnits",
"(",
")",
")",
";",
"assignment",
".",
"setRemainingWork",
"(",
"remainingWork",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
This method extracts assignment data from a Planner file.
@param plannerProject Root node of the Planner file
|
[
"This",
"method",
"extracts",
"assignment",
"data",
"from",
"a",
"Planner",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L700-L781
|
157,196
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.getDateTime
|
private Date getDateTime(String value) throws MPXJException
{
try
{
Number year = m_fourDigitFormat.parse(value.substring(0, 4));
Number month = m_twoDigitFormat.parse(value.substring(4, 6));
Number day = m_twoDigitFormat.parse(value.substring(6, 8));
Number hours = m_twoDigitFormat.parse(value.substring(9, 11));
Number minutes = m_twoDigitFormat.parse(value.substring(11, 13));
Calendar cal = DateHelper.popCalendar();
cal.set(Calendar.YEAR, year.intValue());
cal.set(Calendar.MONTH, month.intValue() - 1);
cal.set(Calendar.DAY_OF_MONTH, day.intValue());
cal.set(Calendar.HOUR_OF_DAY, hours.intValue());
cal.set(Calendar.MINUTE, minutes.intValue());
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date result = cal.getTime();
DateHelper.pushCalendar(cal);
return result;
}
catch (ParseException ex)
{
throw new MPXJException("Failed to parse date-time " + value, ex);
}
}
|
java
|
private Date getDateTime(String value) throws MPXJException
{
try
{
Number year = m_fourDigitFormat.parse(value.substring(0, 4));
Number month = m_twoDigitFormat.parse(value.substring(4, 6));
Number day = m_twoDigitFormat.parse(value.substring(6, 8));
Number hours = m_twoDigitFormat.parse(value.substring(9, 11));
Number minutes = m_twoDigitFormat.parse(value.substring(11, 13));
Calendar cal = DateHelper.popCalendar();
cal.set(Calendar.YEAR, year.intValue());
cal.set(Calendar.MONTH, month.intValue() - 1);
cal.set(Calendar.DAY_OF_MONTH, day.intValue());
cal.set(Calendar.HOUR_OF_DAY, hours.intValue());
cal.set(Calendar.MINUTE, minutes.intValue());
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date result = cal.getTime();
DateHelper.pushCalendar(cal);
return result;
}
catch (ParseException ex)
{
throw new MPXJException("Failed to parse date-time " + value, ex);
}
}
|
[
"private",
"Date",
"getDateTime",
"(",
"String",
"value",
")",
"throws",
"MPXJException",
"{",
"try",
"{",
"Number",
"year",
"=",
"m_fourDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"0",
",",
"4",
")",
")",
";",
"Number",
"month",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"4",
",",
"6",
")",
")",
";",
"Number",
"day",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"6",
",",
"8",
")",
")",
";",
"Number",
"hours",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"9",
",",
"11",
")",
")",
";",
"Number",
"minutes",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"11",
",",
"13",
")",
")",
";",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"YEAR",
",",
"year",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MONTH",
",",
"month",
".",
"intValue",
"(",
")",
"-",
"1",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"day",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hours",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"minutes",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"Date",
"result",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"ParseException",
"ex",
")",
"{",
"throw",
"new",
"MPXJException",
"(",
"\"Failed to parse date-time \"",
"+",
"value",
",",
"ex",
")",
";",
"}",
"}"
] |
Convert a Planner date-time value into a Java date.
20070222T080000Z
@param value Planner date-time
@return Java Date instance
|
[
"Convert",
"a",
"Planner",
"date",
"-",
"time",
"value",
"into",
"a",
"Java",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L791-L822
|
157,197
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.getTime
|
private Date getTime(String value) throws MPXJException
{
try
{
Number hours = m_twoDigitFormat.parse(value.substring(0, 2));
Number minutes = m_twoDigitFormat.parse(value.substring(2, 4));
Calendar cal = DateHelper.popCalendar();
cal.set(Calendar.HOUR_OF_DAY, hours.intValue());
cal.set(Calendar.MINUTE, minutes.intValue());
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date result = cal.getTime();
DateHelper.pushCalendar(cal);
return result;
}
catch (ParseException ex)
{
throw new MPXJException("Failed to parse time " + value, ex);
}
}
|
java
|
private Date getTime(String value) throws MPXJException
{
try
{
Number hours = m_twoDigitFormat.parse(value.substring(0, 2));
Number minutes = m_twoDigitFormat.parse(value.substring(2, 4));
Calendar cal = DateHelper.popCalendar();
cal.set(Calendar.HOUR_OF_DAY, hours.intValue());
cal.set(Calendar.MINUTE, minutes.intValue());
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date result = cal.getTime();
DateHelper.pushCalendar(cal);
return result;
}
catch (ParseException ex)
{
throw new MPXJException("Failed to parse time " + value, ex);
}
}
|
[
"private",
"Date",
"getTime",
"(",
"String",
"value",
")",
"throws",
"MPXJException",
"{",
"try",
"{",
"Number",
"hours",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"0",
",",
"2",
")",
")",
";",
"Number",
"minutes",
"=",
"m_twoDigitFormat",
".",
"parse",
"(",
"value",
".",
"substring",
"(",
"2",
",",
"4",
")",
")",
";",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hours",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"minutes",
".",
"intValue",
"(",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"Date",
"result",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"ParseException",
"ex",
")",
"{",
"throw",
"new",
"MPXJException",
"(",
"\"Failed to parse time \"",
"+",
"value",
",",
"ex",
")",
";",
"}",
"}"
] |
Convert a Planner time into a Java date.
0800
@param value Planner time
@return Java Date instance
|
[
"Convert",
"a",
"Planner",
"time",
"into",
"a",
"Java",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L869-L891
|
157,198
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerReader.java
|
PlannerReader.getDuration
|
private Duration getDuration(String value)
{
Duration result = null;
if (value != null && value.length() != 0)
{
double seconds = getLong(value);
double hours = seconds / (60 * 60);
double days = hours / 8;
if (days < 1)
{
result = Duration.getInstance(hours, TimeUnit.HOURS);
}
else
{
double durationDays = hours / 8;
result = Duration.getInstance(durationDays, TimeUnit.DAYS);
}
}
return (result);
}
|
java
|
private Duration getDuration(String value)
{
Duration result = null;
if (value != null && value.length() != 0)
{
double seconds = getLong(value);
double hours = seconds / (60 * 60);
double days = hours / 8;
if (days < 1)
{
result = Duration.getInstance(hours, TimeUnit.HOURS);
}
else
{
double durationDays = hours / 8;
result = Duration.getInstance(durationDays, TimeUnit.DAYS);
}
}
return (result);
}
|
[
"private",
"Duration",
"getDuration",
"(",
"String",
"value",
")",
"{",
"Duration",
"result",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"double",
"seconds",
"=",
"getLong",
"(",
"value",
")",
";",
"double",
"hours",
"=",
"seconds",
"/",
"(",
"60",
"*",
"60",
")",
";",
"double",
"days",
"=",
"hours",
"/",
"8",
";",
"if",
"(",
"days",
"<",
"1",
")",
"{",
"result",
"=",
"Duration",
".",
"getInstance",
"(",
"hours",
",",
"TimeUnit",
".",
"HOURS",
")",
";",
"}",
"else",
"{",
"double",
"durationDays",
"=",
"hours",
"/",
"8",
";",
"result",
"=",
"Duration",
".",
"getInstance",
"(",
"durationDays",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Converts the string representation of a Planner duration into
an MPXJ Duration instance.
Planner represents durations as a number of seconds in its
file format, however it displays durations as days and hours,
and seems to assume that a working day is 8 hours.
@param value string representation of a duration
@return Duration instance
|
[
"Converts",
"the",
"string",
"representation",
"of",
"a",
"Planner",
"duration",
"into",
"an",
"MPXJ",
"Duration",
"instance",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerReader.java#L954-L976
|
157,199
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/utility/TimephasedUtility.java
|
TimephasedUtility.segmentWork
|
public ArrayList<Duration> segmentWork(ProjectCalendar projectCalendar, List<TimephasedWork> work, TimescaleUnits rangeUnits, List<DateRange> dateList)
{
ArrayList<Duration> result = new ArrayList<Duration>(dateList.size());
int lastStartIndex = 0;
//
// Iterate through the list of dates range we are interested in.
// Each date range in this list corresponds to a column
// shown on the "timescale" view by MS Project
//
for (DateRange range : dateList)
{
//
// If the current date range does not intersect with any of the
// assignment date ranges in the list, then we show a zero
// duration for this date range.
//
int startIndex = lastStartIndex == -1 ? -1 : getStartIndex(range, work, lastStartIndex);
if (startIndex == -1)
{
result.add(Duration.getInstance(0, TimeUnit.HOURS));
}
else
{
//
// We have found an assignment which intersects with the current
// date range, call the method below to determine how
// much time from this resource assignment can be allocated
// to the current date range.
//
result.add(getRangeDuration(projectCalendar, rangeUnits, range, work, startIndex));
lastStartIndex = startIndex;
}
}
return result;
}
|
java
|
public ArrayList<Duration> segmentWork(ProjectCalendar projectCalendar, List<TimephasedWork> work, TimescaleUnits rangeUnits, List<DateRange> dateList)
{
ArrayList<Duration> result = new ArrayList<Duration>(dateList.size());
int lastStartIndex = 0;
//
// Iterate through the list of dates range we are interested in.
// Each date range in this list corresponds to a column
// shown on the "timescale" view by MS Project
//
for (DateRange range : dateList)
{
//
// If the current date range does not intersect with any of the
// assignment date ranges in the list, then we show a zero
// duration for this date range.
//
int startIndex = lastStartIndex == -1 ? -1 : getStartIndex(range, work, lastStartIndex);
if (startIndex == -1)
{
result.add(Duration.getInstance(0, TimeUnit.HOURS));
}
else
{
//
// We have found an assignment which intersects with the current
// date range, call the method below to determine how
// much time from this resource assignment can be allocated
// to the current date range.
//
result.add(getRangeDuration(projectCalendar, rangeUnits, range, work, startIndex));
lastStartIndex = startIndex;
}
}
return result;
}
|
[
"public",
"ArrayList",
"<",
"Duration",
">",
"segmentWork",
"(",
"ProjectCalendar",
"projectCalendar",
",",
"List",
"<",
"TimephasedWork",
">",
"work",
",",
"TimescaleUnits",
"rangeUnits",
",",
"List",
"<",
"DateRange",
">",
"dateList",
")",
"{",
"ArrayList",
"<",
"Duration",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Duration",
">",
"(",
"dateList",
".",
"size",
"(",
")",
")",
";",
"int",
"lastStartIndex",
"=",
"0",
";",
"//",
"// Iterate through the list of dates range we are interested in.",
"// Each date range in this list corresponds to a column",
"// shown on the \"timescale\" view by MS Project",
"//",
"for",
"(",
"DateRange",
"range",
":",
"dateList",
")",
"{",
"//",
"// If the current date range does not intersect with any of the",
"// assignment date ranges in the list, then we show a zero",
"// duration for this date range.",
"//",
"int",
"startIndex",
"=",
"lastStartIndex",
"==",
"-",
"1",
"?",
"-",
"1",
":",
"getStartIndex",
"(",
"range",
",",
"work",
",",
"lastStartIndex",
")",
";",
"if",
"(",
"startIndex",
"==",
"-",
"1",
")",
"{",
"result",
".",
"add",
"(",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"HOURS",
")",
")",
";",
"}",
"else",
"{",
"//",
"// We have found an assignment which intersects with the current",
"// date range, call the method below to determine how",
"// much time from this resource assignment can be allocated",
"// to the current date range.",
"//",
"result",
".",
"add",
"(",
"getRangeDuration",
"(",
"projectCalendar",
",",
"rangeUnits",
",",
"range",
",",
"work",
",",
"startIndex",
")",
")",
";",
"lastStartIndex",
"=",
"startIndex",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
This is the main entry point used to convert the internal representation
of timephased work into an external form which can
be displayed to the user.
@param projectCalendar calendar used by the resource assignment
@param work timephased resource assignment data
@param rangeUnits timescale units
@param dateList timescale date ranges
@return list of durations, one per timescale date range
|
[
"This",
"is",
"the",
"main",
"entry",
"point",
"used",
"to",
"convert",
"the",
"internal",
"representation",
"of",
"timephased",
"work",
"into",
"an",
"external",
"form",
"which",
"can",
"be",
"displayed",
"to",
"the",
"user",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/utility/TimephasedUtility.java#L59-L95
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.