TimephasedDataFactory timephasedFactory = new TimephasedDataFactory();
SplitTaskFactory splitFactory = new SplitTaskFactory();
TimephasedWorkNormaliser normaliser = new MPPTimephasedWorkNormaliser();
TimephasedWorkNormaliser baselineWorkNormaliser = new MPPTimephasedBaselineWorkNormaliser();
TimephasedCostNormaliser baselineCostNormaliser = new MPPTimephasedBaselineCostNormaliser();
ProjectCalendar baselineCalendar = file.getBaselineCalendar();
RTFUtility rtf = new RTFUtility();
//System.out.println(assnFixedMeta);
//System.out.println(assnFixedData);
//System.out.println(assnVarMeta.toString(fieldMap));
//System.out.println(assnVarData);
for (int loop = 0; loop < count; loop++)
{
byte[] meta = assnFixedMeta.getByteArrayValue(loop);
if (meta[0] != 0)
{
continue;
}
int offset = MPPUtility.getInt(meta, 4);
byte[] data = assnFixedData.getByteArrayValue(assnFixedData.getIndexFromOffset(offset));
if (data == null)
{
continue;
}
if (data.length <= fieldMap.getMaxFixedDataOffset(0))
{
byte[] newData = new byte[fieldMap.getMaxFixedDataOffset(0) + 8];
System.arraycopy(data, 0, newData, 0, data.length);
data = newData;
}
int id = MPPUtility.getInt(data, fieldMap.getFixedDataOffset(AssignmentField.UNIQUE_ID));
final Integer varDataId = Integer.valueOf(id);
if (set.contains(varDataId) == false)
{
continue;
}
byte[] data2 = null;
if (assnFixedData2 != null)
{
data2 = assnFixedData2.getByteArrayValue(loop);
}
ResourceAssignment assignment = new ResourceAssignment(file);
assignment.disableEvents();
fieldMap.populateContainer(assignment, varDataId, new byte[][]
{
data,
data2
}, assnVarData);
assignment.enableEvents();
if (fieldMap.getFieldLocation(AssignmentField.FLAG1) != FieldMap.FieldLocation.VAR_DATA)
{
assignment.setFlag(1, (meta[28] & 0x80) != 0);
assignment.setFlag(2, (meta[29] & 0x01) != 0);
assignment.setFlag(3, (meta[29] & 0x02) != 0);
assignment.setFlag(4, (meta[29] & 0x04) != 0);
assignment.setFlag(5, (meta[29] & 0x08) != 0);
assignment.setFlag(6, (meta[29] & 0x10) != 0);
assignment.setFlag(7, (meta[29] & 0x20) != 0);
assignment.setFlag(8, (meta[29] & 0x40) != 0);
assignment.setFlag(9, (meta[29] & 0x80) != 0);
assignment.setFlag(10, (meta[30] & 0x01) != 0);
assignment.setFlag(11, (meta[30] & 0x02) != 0);
assignment.setFlag(12, (meta[30] & 0x04) != 0);
assignment.setFlag(13, (meta[30] & 0x08) != 0);
assignment.setFlag(14, (meta[30] & 0x10) != 0);
assignment.setFlag(15, (meta[30] & 0x20) != 0);
assignment.setFlag(16, (meta[30] & 0x40) != 0);
assignment.setFlag(17, (meta[30] & 0x80) != 0);
assignment.setFlag(18, (meta[31] & 0x01) != 0);
assignment.setFlag(19, (meta[31] & 0x02) != 0);
assignment.setFlag(20, (meta[31] & 0x04) != 0);
}
if (fieldMap.getFieldLocation(AssignmentField.CONFIRMED) != FieldMap.FieldLocation.VAR_DATA)
{
assignment.setConfirmed((meta[8] & 0x80) != 0);
}
if (fieldMap.getFieldLocation(AssignmentField.RESPONSE_PENDING) != FieldMap.FieldLocation.VAR_DATA)
{
assignment.setResponsePending((meta[9] & 0x01) != 0);
}
if (fieldMap.getFieldLocation(AssignmentField.TEAM_STATUS_PENDING) != FieldMap.FieldLocation.VAR_DATA)
{
assignment.setTeamStatusPending((meta[10] & 0x02) != 0);
}
processHyperlinkData(assignment, assnVarData.getByteArray(varDataId, fieldMap.getVarDataKey(AssignmentField.HYPERLINK_DATA)));
//
// Post processing
//
if (file.getMppFileType() == 9 && assignment.getCreateDate() == null)
{
byte[] creationData = assnVarData.getByteArray(varDataId, MPP9_CREATION_DATA);
if (creationData != null && creationData.length >= 28)
{
assignment.setCreateDate(MPPUtility.getTimestamp(creationData, 24));
}
}
String notes = assignment.getNotes();
if (notes != null)
{
if (!preserveNoteFormatting)
{
notes = rtf.strip(notes);
}
assignment.setNotes(notes);
}
Task task = file.getTaskByUniqueID(assignment.getTaskUniqueID());
if (task != null)
{
task.addResourceAssignment(assignment);
Resource resource = file.getResourceByUniqueID(assignment.getResourceUniqueID());
ProjectCalendar calendar = null;
if (resource != null)
{
calendar = resource.getResourceCalendar();
}