code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
private Layout getActiveLayout(Project phoenixProject)
{
//
// Start with the first layout we find
//
Layout activeLayout = phoenixProject.getLayouts().getLayout().get(0);
//
// If this isn't active, find one which is... and if none are,
// we'll just use the first.
//
if (!activeLayout.isActive().booleanValue())
{
for (Layout layout : phoenixProject.getLayouts().getLayout())
{
if (layout.isActive().booleanValue())
{
activeLayout = layout;
break;
}
}
}
return activeLayout;
} | java |
private void processActivities(Storepoint phoenixProject)
{
final AlphanumComparator comparator = new AlphanumComparator();
List<Activity> activities = phoenixProject.getActivities().getActivity();
Collections.sort(activities, new Comparator<Activity>()
{
@Override public int compare(Activity o1, Activity o2)
{
Map<UUID, UUID> codes1 = getActivityCodes(o1);
Map<UUID, UUID> codes2 = getActivityCodes(o2);
for (UUID code : m_codeSequence)
{
UUID codeValue1 = codes1.get(code);
UUID codeValue2 = codes2.get(code);
if (codeValue1 == null || codeValue2 == null)
{
if (codeValue1 == null && codeValue2 == null)
{
continue;
}
if (codeValue1 == null)
{
return -1;
}
if (codeValue2 == null)
{
return 1;
}
}
if (!codeValue1.equals(codeValue2))
{
Integer sequence1 = m_activityCodeSequence.get(codeValue1);
Integer sequence2 = m_activityCodeSequence.get(codeValue2);
return NumberHelper.compare(sequence1, sequence2);
}
}
return comparator.compare(o1.getId(), o2.getId());
}
});
for (Activity activity : activities)
{
processActivity(activity);
}
} | java |
private void processActivity(Activity activity)
{
Task task = getParentTask(activity).addTask();
task.setText(1, activity.getId());
task.setActualDuration(activity.getActualDuration());
task.setActualFinish(activity.getActualFinish());
task.setActualStart(activity.getActualStart());
//activity.getBaseunit()
//activity.getBilled()
//activity.getCalendar()
//activity.getCostAccount()
task.setCreateDate(activity.getCreationTime());
task.setFinish(activity.getCurrentFinish());
task.setStart(activity.getCurrentStart());
task.setName(activity.getDescription());
task.setDuration(activity.getDurationAtCompletion());
task.setEarlyFinish(activity.getEarlyFinish());
task.setEarlyStart(activity.getEarlyStart());
task.setFreeSlack(activity.getFreeFloat());
task.setLateFinish(activity.getLateFinish());
task.setLateStart(activity.getLateStart());
task.setNotes(activity.getNotes());
task.setBaselineDuration(activity.getOriginalDuration());
//activity.getPathFloat()
task.setPhysicalPercentComplete(activity.getPhysicalPercentComplete());
task.setRemainingDuration(activity.getRemainingDuration());
task.setCost(activity.getTotalCost());
task.setTotalSlack(activity.getTotalFloat());
task.setMilestone(activityIsMilestone(activity));
//activity.getUserDefined()
task.setGUID(activity.getUuid());
if (task.getMilestone())
{
if (activityIsStartMilestone(activity))
{
task.setFinish(task.getStart());
}
else
{
task.setStart(task.getFinish());
}
}
if (task.getActualStart() == null)
{
task.setPercentageComplete(Integer.valueOf(0));
}
else
{
if (task.getActualFinish() != null)
{
task.setPercentageComplete(Integer.valueOf(100));
}
else
{
Duration remaining = activity.getRemainingDuration();
Duration total = activity.getDurationAtCompletion();
if (remaining != null && total != null && total.getDuration() != 0)
{
double percentComplete = ((total.getDuration() - remaining.getDuration()) * 100.0) / total.getDuration();
task.setPercentageComplete(Double.valueOf(percentComplete));
}
}
}
m_activityMap.put(activity.getId(), task);
} | java |
private boolean activityIsMilestone(Activity activity)
{
String type = activity.getType();
return type != null && type.indexOf("Milestone") != -1;
} | java |
private boolean activityIsStartMilestone(Activity activity)
{
String type = activity.getType();
return type != null && type.indexOf("StartMilestone") != -1;
} | java |
private ChildTaskContainer getParentTask(Activity activity)
{
//
// Make a map of activity codes and their values for this activity
//
Map<UUID, UUID> map = getActivityCodes(activity);
//
// Work through the activity codes in sequence
//
ChildTaskContainer parent = m_projectFile;
StringBuilder uniqueIdentifier = new StringBuilder();
for (UUID activityCode : m_codeSequence)
{
UUID activityCodeValue = map.get(activityCode);
String activityCodeText = m_activityCodeValues.get(activityCodeValue);
if (activityCodeText != null)
{
if (uniqueIdentifier.length() != 0)
{
uniqueIdentifier.append('>');
}
uniqueIdentifier.append(activityCodeValue.toString());
UUID uuid = UUID.nameUUIDFromBytes(uniqueIdentifier.toString().getBytes());
Task newParent = findChildTaskByUUID(parent, uuid);
if (newParent == null)
{
newParent = parent.addTask();
newParent.setGUID(uuid);
newParent.setName(activityCodeText);
}
parent = newParent;
}
}
return parent;
} | java |
private Task findChildTaskByUUID(ChildTaskContainer parent, UUID uuid)
{
Task result = null;
for (Task task : parent.getChildTasks())
{
if (uuid.equals(task.getGUID()))
{
result = task;
break;
}
}
return result;
} | java |
private void readAssignments(Resource mpxjResource, net.sf.mpxj.phoenix.schema.Project.Storepoints.Storepoint.Resources.Resource res)
{
for (Assignment assignment : res.getAssignment())
{
readAssignment(mpxjResource, assignment);
}
} | java |
private void readAssignment(Resource resource, Assignment assignment)
{
Task task = m_activityMap.get(assignment.getActivity());
if (task != null)
{
task.addResourceAssignment(resource);
}
} | java |
private void readRelationships(Storepoint phoenixProject)
{
for (Relationship relation : phoenixProject.getRelationships().getRelationship())
{
readRelation(relation);
}
} | java |
private void readRelation(Relationship relation)
{
Task predecessor = m_activityMap.get(relation.getPredecessor());
Task successor = m_activityMap.get(relation.getSuccessor());
if (predecessor != null && successor != null)
{
Duration lag = relation.getLag();
RelationType type = relation.getType();
successor.addPredecessor(predecessor, type, lag);
}
} | java |
Map<UUID, UUID> getActivityCodes(Activity activity)
{
Map<UUID, UUID> map = m_activityCodeCache.get(activity);
if (map == null)
{
map = new HashMap<UUID, UUID>();
m_activityCodeCache.put(activity, map);
for (CodeAssignment ca : activity.getCodeAssignment())
{
UUID code = getUUID(ca.getCodeUuid(), ca.getCode());
UUID value = getUUID(ca.getValueUuid(), ca.getValue());
map.put(code, value);
}
}
return map;
} | java |
private Storepoint getCurrentStorepoint(Project phoenixProject)
{
List<Storepoint> storepoints = phoenixProject.getStorepoints().getStorepoint();
Collections.sort(storepoints, new Comparator<Storepoint>()
{
@Override public int compare(Storepoint o1, Storepoint o2)
{
return DateHelper.compare(o2.getCreationTime(), o1.getCreationTime());
}
});
return storepoints.get(0);
} | java |
public TableReader read() throws IOException
{
int tableHeader = m_stream.readInt();
if (tableHeader != 0x39AF547A)
{
throw new IllegalArgumentException("Unexpected file format");
}
int recordCount = m_stream.readInt();
for (int loop = 0; loop < recordCount; loop++)
{
int rowMagicNumber = m_stream.readInt();
if (rowMagicNumber != rowMagicNumber())
{
throw new IllegalArgumentException("Unexpected file format");
}
// We use a LinkedHashMap to preserve insertion order in iteration
// Useful when debugging the file format.
Map<String, Object> map = new LinkedHashMap<String, Object>();
if (hasUUID())
{
readUUID(m_stream, map);
}
readRow(m_stream, map);
SynchroLogger.log("READER", getClass(), map);
m_rows.add(new MapRow(map));
}
int tableTrailer = m_stream.readInt();
if (tableTrailer != 0x6F99E416)
{
throw new IllegalArgumentException("Unexpected file format");
}
postTrailer(m_stream);
return this;
} | java |
protected void readUUID(StreamReader stream, Map<String, Object> map) throws IOException
{
int unknown0Size = stream.getMajorVersion() > 5 ? 8 : 16;
map.put("UNKNOWN0", stream.readBytes(unknown0Size));
map.put("UUID", stream.readUUID());
} | java |
protected int readShort(int offset, byte[] data)
{
int result = 0;
int i = offset + m_offset;
for (int shiftBy = 0; shiftBy < 16; shiftBy += 8)
{
result |= ((data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} | java |
public void loadObject(Object object, Set<String> excludedMethods)
{
m_model.setTableModel(createTableModel(object, excludedMethods));
} | java |
private TableModel createTableModel(Object object, Set<String> excludedMethods)
{
List<Method> methods = new ArrayList<Method>();
for (Method method : object.getClass().getMethods())
{
if ((method.getParameterTypes().length == 0) || (method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == int.class))
{
String name = method.getName();
if (!excludedMethods.contains(name) && (name.startsWith("get") || name.startsWith("is")))
{
methods.add(method);
}
}
}
Map<String, String> map = new TreeMap<String, String>();
for (Method method : methods)
{
if (method.getParameterTypes().length == 0)
{
getSingleValue(method, object, map);
}
else
{
getMultipleValues(method, object, map);
}
}
String[] headings = new String[]
{
"Property",
"Value"
};
String[][] data = new String[map.size()][2];
int rowIndex = 0;
for (Entry<String, String> entry : map.entrySet())
{
data[rowIndex][0] = entry.getKey();
data[rowIndex][1] = entry.getValue();
++rowIndex;
}
TableModel tableModel = new DefaultTableModel(data, headings)
{
@Override public boolean isCellEditable(int r, int c)
{
return false;
}
};
return tableModel;
} | java |
private Object filterValue(Object value)
{
if (value instanceof Boolean && !((Boolean) value).booleanValue())
{
value = null;
}
if (value instanceof String && ((String) value).isEmpty())
{
value = null;
}
if (value instanceof Double && ((Double) value).doubleValue() == 0.0)
{
value = null;
}
if (value instanceof Integer && ((Integer) value).intValue() == 0)
{
value = null;
}
if (value instanceof Duration && ((Duration) value).getDuration() == 0.0)
{
value = null;
}
return value;
} | java |
private void getSingleValue(Method method, Object object, Map<String, String> map)
{
Object value;
try
{
value = filterValue(method.invoke(object));
}
catch (Exception ex)
{
value = ex.toString();
}
if (value != null)
{
map.put(getPropertyName(method), String.valueOf(value));
}
} | java |
private void getMultipleValues(Method method, Object object, Map<String, String> map)
{
try
{
int index = 1;
while (true)
{
Object value = filterValue(method.invoke(object, Integer.valueOf(index)));
if (value != null)
{
map.put(getPropertyName(method, index), String.valueOf(value));
}
++index;
}
}
catch (Exception ex)
{
// Reached the end of the valid indexes
}
} | java |
private String getPropertyName(Method method)
{
String result = method.getName();
if (result.startsWith("get"))
{
result = result.substring(3);
}
return result;
} | java |
public void setLocale(Locale locale)
{
List<SimpleDateFormat> formats = new ArrayList<SimpleDateFormat>();
for (SimpleDateFormat format : m_formats)
{
formats.add(new SimpleDateFormat(format.toPattern(), locale));
}
m_formats = formats.toArray(new SimpleDateFormat[formats.size()]);
} | java |
public Map<String, Table> process(File directory, String prefix) throws IOException
{
String filePrefix = prefix.toUpperCase();
Map<String, Table> tables = new HashMap<String, Table>();
File[] files = directory.listFiles();
if (files != null)
{
for (File file : files)
{
String name = file.getName().toUpperCase();
if (!name.startsWith(filePrefix))
{
continue;
}
int typeIndex = name.lastIndexOf('.') - 3;
String type = name.substring(typeIndex, typeIndex + 3);
TableDefinition definition = TABLE_DEFINITIONS.get(type);
if (definition != null)
{
Table table = new Table();
TableReader reader = new TableReader(definition);
reader.read(file, table);
tables.put(type, table);
//dumpCSV(type, definition, table);
}
}
}
return tables;
} | java |
public static void openLogFile() throws IOException
{
if (LOG_FILE != null)
{
System.out.println("SynchroLogger Configured");
LOG = new PrintWriter(new FileWriter(LOG_FILE));
}
} | java |
public static void log(String label, byte[] data)
{
if (LOG != null)
{
LOG.write(label);
LOG.write(": ");
LOG.println(ByteArrayHelper.hexdump(data, true));
LOG.flush();
}
} | java |
public static void log(String label, String data)
{
if (LOG != null)
{
LOG.write(label);
LOG.write(": ");
LOG.println(data);
LOG.flush();
}
} | java |
public static void log(byte[] data)
{
if (LOG != null)
{
LOG.println(ByteArrayHelper.hexdump(data, true, 16, ""));
LOG.flush();
}
} | java |
public static void log(String label, Class<?> klass, Map<String, Object> map)
{
if (LOG != null)
{
LOG.write(label);
LOG.write(": ");
LOG.println(klass.getSimpleName());
for (Map.Entry<String, Object> entry : map.entrySet())
{
LOG.println(entry.getKey() + ": " + entry.getValue());
}
LOG.println();
LOG.flush();
}
} | java |
public void setValue(FieldContainer container, byte[] data)
{
if (data != null)
{
container.set(m_type, ((MPPUtility.getInt(data, m_offset) & m_mask) == 0) ? m_zeroValue : m_nonZeroValue);
}
} | java |
private void setFieldType(FastTrackTableType tableType)
{
switch (tableType)
{
case ACTBARS:
{
m_type = ActBarField.getInstance(m_header.getColumnType());
break;
}
case ACTIVITIES:
{
m_type = ActivityField.getInstance(m_header.getColumnType());
break;
}
case RESOURCES:
{
m_type = ResourceField.getInstance(m_header.getColumnType());
break;
}
}
} | java |
public void process(File file) throws Exception
{
openLogFile();
int blockIndex = 0;
int length = (int) file.length();
m_buffer = new byte[length];
FileInputStream is = new FileInputStream(file);
try
{
int bytesRead = is.read(m_buffer);
if (bytesRead != length)
{
throw new RuntimeException("Read count different");
}
}
finally
{
is.close();
}
List<Integer> blocks = new ArrayList<Integer>();
for (int index = 64; index < m_buffer.length - 11; index++)
{
if (matchPattern(PARENT_BLOCK_PATTERNS, index))
{
blocks.add(Integer.valueOf(index));
}
}
int startIndex = 0;
for (int endIndex : blocks)
{
int blockLength = endIndex - startIndex;
readBlock(blockIndex, startIndex, blockLength);
startIndex = endIndex;
++blockIndex;
}
int blockLength = m_buffer.length - startIndex;
readBlock(blockIndex, startIndex, blockLength);
closeLogFile();
} | java |
public FastTrackTable getTable(FastTrackTableType type)
{
FastTrackTable result = m_tables.get(type);
if (result == null)
{
result = EMPTY_TABLE;
}
return result;
} | java |
private void readBlock(int blockIndex, int startIndex, int blockLength) throws Exception
{
logBlock(blockIndex, startIndex, blockLength);
if (blockLength < 128)
{
readTableBlock(startIndex, blockLength);
}
else
{
readColumnBlock(startIndex, blockLength);
}
} | java |
private void readTableBlock(int startIndex, int blockLength)
{
for (int index = startIndex; index < (startIndex + blockLength - 11); index++)
{
if (matchPattern(TABLE_BLOCK_PATTERNS, index))
{
int offset = index + 7;
int nameLength = FastTrackUtility.getInt(m_buffer, offset);
offset += 4;
String name = new String(m_buffer, offset, nameLength, CharsetHelper.UTF16LE).toUpperCase();
FastTrackTableType type = REQUIRED_TABLES.get(name);
if (type != null)
{
m_currentTable = new FastTrackTable(type, this);
m_tables.put(type, m_currentTable);
}
else
{
m_currentTable = null;
}
m_currentFields.clear();
break;
}
}
} | java |
private void readColumnBlock(int startIndex, int blockLength) throws Exception
{
int endIndex = startIndex + blockLength;
List<Integer> blocks = new ArrayList<Integer>();
for (int index = startIndex; index < endIndex - 11; index++)
{
if (matchChildBlock(index))
{
int childBlockStart = index - 2;
blocks.add(Integer.valueOf(childBlockStart));
}
}
blocks.add(Integer.valueOf(endIndex));
int childBlockStart = -1;
for (int childBlockEnd : blocks)
{
if (childBlockStart != -1)
{
int childblockLength = childBlockEnd - childBlockStart;
try
{
readColumn(childBlockStart, childblockLength);
}
catch (UnexpectedStructureException ex)
{
logUnexpectedStructure();
}
}
childBlockStart = childBlockEnd;
}
} | java |
private void readColumn(int startIndex, int length) throws Exception
{
if (m_currentTable != null)
{
int value = FastTrackUtility.getByte(m_buffer, startIndex);
Class<?> klass = COLUMN_MAP[value];
if (klass == null)
{
klass = UnknownColumn.class;
}
FastTrackColumn column = (FastTrackColumn) klass.newInstance();
m_currentColumn = column;
logColumnData(startIndex, length);
column.read(m_currentTable.getType(), m_buffer, startIndex, length);
FastTrackField type = column.getType();
//
// Don't try to add this data if:
// 1. We don't know what type it is
// 2. We have seen the type already
//
if (type != null && !m_currentFields.contains(type))
{
m_currentFields.add(type);
m_currentTable.addColumn(column);
updateDurationTimeUnit(column);
updateWorkTimeUnit(column);
logColumn(column);
}
}
} | java |
private final boolean matchPattern(byte[][] patterns, int bufferIndex)
{
boolean match = false;
for (byte[] pattern : patterns)
{
int index = 0;
match = true;
for (byte b : pattern)
{
if (b != m_buffer[bufferIndex + index])
{
match = false;
break;
}
++index;
}
if (match)
{
break;
}
}
return match;
} | java |
private final boolean matchChildBlock(int bufferIndex)
{
//
// Match the pattern we see at the start of the child block
//
int index = 0;
for (byte b : CHILD_BLOCK_PATTERN)
{
if (b != m_buffer[bufferIndex + index])
{
return false;
}
++index;
}
//
// The first step will produce false positives. To handle this, we should find
// the name of the block next, and check to ensure that the length
// of the name makes sense.
//
int nameLength = FastTrackUtility.getInt(m_buffer, bufferIndex + index);
// System.out.println("Name length: " + nameLength);
//
// if (nameLength > 0 && nameLength < 100)
// {
// String name = new String(m_buffer, bufferIndex+index+4, nameLength, CharsetHelper.UTF16LE);
// System.out.println("Name: " + name);
// }
return nameLength > 0 && nameLength < 100;
} | java |
private void updateDurationTimeUnit(FastTrackColumn column)
{
if (m_durationTimeUnit == null && isDurationColumn(column))
{
int value = ((DurationColumn) column).getTimeUnitValue();
if (value != 1)
{
m_durationTimeUnit = FastTrackUtility.getTimeUnit(value);
}
}
} | java |
private void updateWorkTimeUnit(FastTrackColumn column)
{
if (m_workTimeUnit == null && isWorkColumn(column))
{
int value = ((DurationColumn) column).getTimeUnitValue();
if (value != 1)
{
m_workTimeUnit = FastTrackUtility.getTimeUnit(value);
}
}
} | java |
private void logBlock(int blockIndex, int startIndex, int blockLength)
{
if (m_log != null)
{
m_log.println("Block Index: " + blockIndex);
m_log.println("Length: " + blockLength + " (" + Integer.toHexString(blockLength) + ")");
m_log.println();
m_log.println(FastTrackUtility.hexdump(m_buffer, startIndex, blockLength, true, 16, ""));
m_log.flush();
}
} | java |
private void logColumnData(int startIndex, int length)
{
if (m_log != null)
{
m_log.println();
m_log.println(FastTrackUtility.hexdump(m_buffer, startIndex, length, true, 16, ""));
m_log.println();
m_log.flush();
}
} | java |
private void logUnexpectedStructure()
{
if (m_log != null)
{
m_log.println("ABORTED COLUMN - unexpected structure: " + m_currentColumn.getClass().getSimpleName() + " " + m_currentColumn.getName());
}
} | java |
private void logColumn(FastTrackColumn column)
{
if (m_log != null)
{
m_log.println("TABLE: " + m_currentTable.getType());
m_log.println(column.toString());
m_log.flush();
}
} | java |
private void populateCurrencySettings(Record record, ProjectProperties properties)
{
properties.setCurrencySymbol(record.getString(0));
properties.setSymbolPosition(record.getCurrencySymbolPosition(1));
properties.setCurrencyDigits(record.getInteger(2));
Character c = record.getCharacter(3);
if (c != null)
{
properties.setThousandsSeparator(c.charValue());
}
c = record.getCharacter(4);
if (c != null)
{
properties.setDecimalSeparator(c.charValue());
}
} | java |
private void populateDefaultSettings(Record record, ProjectProperties properties) throws MPXJException
{
properties.setDefaultDurationUnits(record.getTimeUnit(0));
properties.setDefaultDurationIsFixed(record.getNumericBoolean(1));
properties.setDefaultWorkUnits(record.getTimeUnit(2));
properties.setMinutesPerDay(Double.valueOf(NumberHelper.getDouble(record.getFloat(3)) * 60));
properties.setMinutesPerWeek(Double.valueOf(NumberHelper.getDouble(record.getFloat(4)) * 60));
properties.setDefaultStandardRate(record.getRate(5));
properties.setDefaultOvertimeRate(record.getRate(6));
properties.setUpdatingTaskStatusUpdatesResourceStatus(record.getNumericBoolean(7));
properties.setSplitInProgressTasks(record.getNumericBoolean(8));
} | java |
private void populateDateTimeSettings(Record record, ProjectProperties properties)
{
properties.setDateOrder(record.getDateOrder(0));
properties.setTimeFormat(record.getTimeFormat(1));
Date time = getTimeFromInteger(record.getInteger(2));
if (time != null)
{
properties.setDefaultStartTime(time);
}
Character c = record.getCharacter(3);
if (c != null)
{
properties.setDateSeparator(c.charValue());
}
c = record.getCharacter(4);
if (c != null)
{
properties.setTimeSeparator(c.charValue());
}
properties.setAMText(record.getString(5));
properties.setPMText(record.getString(6));
properties.setDateFormat(record.getDateFormat(7));
properties.setBarTextDateFormat(record.getDateFormat(8));
} | java |
private Date getTimeFromInteger(Integer time)
{
Date result = null;
if (time != null)
{
int minutes = time.intValue();
int hours = minutes / 60;
minutes -= (hours * 60);
Calendar cal = DateHelper.popCalendar();
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, minutes);
cal.set(Calendar.HOUR_OF_DAY, hours);
result = cal.getTime();
DateHelper.pushCalendar(cal);
}
return (result);
} | java |
private void populateProjectHeader(Record record, ProjectProperties properties) throws MPXJException
{
properties.setProjectTitle(record.getString(0));
properties.setCompany(record.getString(1));
properties.setManager(record.getString(2));
properties.setDefaultCalendarName(record.getString(3));
properties.setStartDate(record.getDateTime(4));
properties.setFinishDate(record.getDateTime(5));
properties.setScheduleFrom(record.getScheduleFrom(6));
properties.setCurrentDate(record.getDateTime(7));
properties.setComments(record.getString(8));
properties.setCost(record.getCurrency(9));
properties.setBaselineCost(record.getCurrency(10));
properties.setActualCost(record.getCurrency(11));
properties.setWork(record.getDuration(12));
properties.setBaselineWork(record.getDuration(13));
properties.setActualWork(record.getDuration(14));
properties.setWork2(record.getPercentage(15));
properties.setDuration(record.getDuration(16));
properties.setBaselineDuration(record.getDuration(17));
properties.setActualDuration(record.getDuration(18));
properties.setPercentageComplete(record.getPercentage(19));
properties.setBaselineStart(record.getDateTime(20));
properties.setBaselineFinish(record.getDateTime(21));
properties.setActualStart(record.getDateTime(22));
properties.setActualFinish(record.getDateTime(23));
properties.setStartVariance(record.getDuration(24));
properties.setFinishVariance(record.getDuration(25));
properties.setSubject(record.getString(26));
properties.setAuthor(record.getString(27));
properties.setKeywords(record.getString(28));
} | java |
private void populateCalendarHours(Record record, ProjectCalendarHours hours) throws MPXJException
{
hours.setDay(Day.getInstance(NumberHelper.getInt(record.getInteger(0))));
addDateRange(hours, record.getTime(1), record.getTime(2));
addDateRange(hours, record.getTime(3), record.getTime(4));
addDateRange(hours, record.getTime(5), record.getTime(6));
} | java |
private void addDateRange(ProjectCalendarHours hours, Date start, Date end)
{
if (start != null && end != null)
{
Calendar cal = DateHelper.popCalendar(end);
// If the time ends on midnight, the date should be the next day. Otherwise problems occur.
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0 && cal.get(Calendar.SECOND) == 0 && cal.get(Calendar.MILLISECOND) == 0)
{
cal.add(Calendar.DAY_OF_YEAR, 1);
}
end = cal.getTime();
DateHelper.pushCalendar(cal);
hours.addRange(new DateRange(start, end));
}
} | java |
private void populateCalendarException(Record record, ProjectCalendar calendar) throws MPXJException
{
Date fromDate = record.getDate(0);
Date toDate = record.getDate(1);
boolean working = record.getNumericBoolean(2);
// I have found an example MPX file where a single day exception is expressed with just the start date set.
// If we find this for we assume that the end date is the same as the start date.
if (fromDate != null && toDate == null)
{
toDate = fromDate;
}
ProjectCalendarException exception = calendar.addCalendarException(fromDate, toDate);
if (working)
{
addExceptionRange(exception, record.getTime(3), record.getTime(4));
addExceptionRange(exception, record.getTime(5), record.getTime(6));
addExceptionRange(exception, record.getTime(7), record.getTime(8));
}
} | java |
private void addExceptionRange(ProjectCalendarException exception, Date start, Date finish)
{
if (start != null && finish != null)
{
exception.addRange(new DateRange(start, finish));
}
} | java |
private void populateCalendar(Record record, ProjectCalendar calendar, boolean isBaseCalendar)
{
if (isBaseCalendar == true)
{
calendar.setName(record.getString(0));
}
else
{
calendar.setParent(m_projectFile.getCalendarByName(record.getString(0)));
}
calendar.setWorkingDay(Day.SUNDAY, DayType.getInstance(record.getInteger(1)));
calendar.setWorkingDay(Day.MONDAY, DayType.getInstance(record.getInteger(2)));
calendar.setWorkingDay(Day.TUESDAY, DayType.getInstance(record.getInteger(3)));
calendar.setWorkingDay(Day.WEDNESDAY, DayType.getInstance(record.getInteger(4)));
calendar.setWorkingDay(Day.THURSDAY, DayType.getInstance(record.getInteger(5)));
calendar.setWorkingDay(Day.FRIDAY, DayType.getInstance(record.getInteger(6)));
calendar.setWorkingDay(Day.SATURDAY, DayType.getInstance(record.getInteger(7)));
m_eventManager.fireCalendarReadEvent(calendar);
} | java |
private void populateResource(Resource resource, Record record) throws MPXJException
{
String falseText = LocaleData.getString(m_locale, LocaleData.NO);
int length = record.getLength();
int[] model = m_resourceModel.getModel();
for (int i = 0; i < length; i++)
{
int mpxFieldType = model[i];
if (mpxFieldType == -1)
{
break;
}
String field = record.getString(i);
if (field == null || field.length() == 0)
{
continue;
}
ResourceField resourceField = MPXResourceField.getMpxjField(mpxFieldType);
switch (resourceField)
{
case OBJECTS:
{
resource.set(resourceField, record.getInteger(i));
break;
}
case ID:
{
resource.setID(record.getInteger(i));
break;
}
case UNIQUE_ID:
{
resource.setUniqueID(record.getInteger(i));
break;
}
case MAX_UNITS:
{
resource.set(resourceField, record.getUnits(i));
break;
}
case PERCENT_WORK_COMPLETE:
case PEAK:
{
resource.set(resourceField, record.getPercentage(i));
break;
}
case COST:
case COST_PER_USE:
case COST_VARIANCE:
case BASELINE_COST:
case ACTUAL_COST:
case REMAINING_COST:
{
resource.set(resourceField, record.getCurrency(i));
break;
}
case OVERTIME_RATE:
case STANDARD_RATE:
{
resource.set(resourceField, record.getRate(i));
break;
}
case REMAINING_WORK:
case OVERTIME_WORK:
case BASELINE_WORK:
case ACTUAL_WORK:
case WORK:
case WORK_VARIANCE:
{
resource.set(resourceField, record.getDuration(i));
break;
}
case ACCRUE_AT:
{
resource.set(resourceField, record.getAccrueType(i));
break;
}
case LINKED_FIELDS:
case OVERALLOCATED:
{
resource.set(resourceField, record.getBoolean(i, falseText));
break;
}
default:
{
resource.set(resourceField, field);
break;
}
}
}
if (m_projectConfig.getAutoResourceUniqueID() == true)
{
resource.setUniqueID(Integer.valueOf(m_projectConfig.getNextResourceUniqueID()));
}
if (m_projectConfig.getAutoResourceID() == true)
{
resource.setID(Integer.valueOf(m_projectConfig.getNextResourceID()));
}
//
// Handle malformed MPX files - ensure we have a unique ID
//
if (resource.getUniqueID() == null)
{
resource.setUniqueID(resource.getID());
}
} | java |
private void populateRelationList(Task task, TaskField field, String data)
{
DeferredRelationship dr = new DeferredRelationship();
dr.setTask(task);
dr.setField(field);
dr.setData(data);
m_deferredRelationships.add(dr);
} | java |
private void processDeferredRelationship(DeferredRelationship dr) throws MPXJException
{
String data = dr.getData();
Task task = dr.getTask();
int length = data.length();
if (length != 0)
{
int start = 0;
int end = 0;
while (end != length)
{
end = data.indexOf(m_delimiter, start);
if (end == -1)
{
end = length;
}
populateRelation(dr.getField(), task, data.substring(start, end).trim());
start = end + 1;
}
}
} | java |
private void populateRelation(TaskField field, Task sourceTask, String relationship) throws MPXJException
{
int index = 0;
int length = relationship.length();
//
// Extract the identifier
//
while ((index < length) && (Character.isDigit(relationship.charAt(index)) == true))
{
++index;
}
Integer taskID;
try
{
taskID = Integer.valueOf(relationship.substring(0, index));
}
catch (NumberFormatException ex)
{
throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'");
}
//
// Now find the task, so we can extract the unique ID
//
Task targetTask;
if (field == TaskField.PREDECESSORS)
{
targetTask = m_projectFile.getTaskByID(taskID);
}
else
{
targetTask = m_projectFile.getTaskByUniqueID(taskID);
}
//
// If we haven't reached the end, we next expect to find
// SF, SS, FS, FF
//
RelationType type = null;
Duration lag = null;
if (index == length)
{
type = RelationType.FINISH_START;
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
else
{
if ((index + 1) == length)
{
throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'");
}
type = RelationTypeUtility.getInstance(m_locale, relationship.substring(index, index + 2));
index += 2;
if (index == length)
{
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
else
{
if (relationship.charAt(index) == '+')
{
++index;
}
lag = DurationUtility.getInstance(relationship.substring(index), m_formats.getDurationDecimalFormat(), m_locale);
}
}
if (type == null)
{
throw new MPXJException(MPXJException.INVALID_FORMAT + " '" + relationship + "'");
}
// We have seen at least one example MPX file where an invalid task ID
// is present. We'll ignore this as the schedule is otherwise valid.
if (targetTask != null)
{
Relation relation = sourceTask.addPredecessor(targetTask, type, lag);
m_eventManager.fireRelationReadEvent(relation);
}
} | java |
private void populateRecurringTask(Record record, RecurringTask task) throws MPXJException
{
//System.out.println(record);
task.setStartDate(record.getDateTime(1));
task.setFinishDate(record.getDateTime(2));
task.setDuration(RecurrenceUtility.getDuration(m_projectFile.getProjectProperties(), record.getInteger(3), record.getInteger(4)));
task.setOccurrences(record.getInteger(5));
task.setRecurrenceType(RecurrenceUtility.getRecurrenceType(record.getInteger(6)));
task.setUseEndDate(NumberHelper.getInt(record.getInteger(8)) == 1);
task.setWorkingDaysOnly(NumberHelper.getInt(record.getInteger(9)) == 1);
task.setWeeklyDaysFromBitmap(RecurrenceUtility.getDays(record.getString(10)), RecurrenceUtility.RECURRING_TASK_DAY_MASKS);
RecurrenceType type = task.getRecurrenceType();
if (type != null)
{
switch (task.getRecurrenceType())
{
case DAILY:
{
task.setFrequency(record.getInteger(13));
break;
}
case WEEKLY:
{
task.setFrequency(record.getInteger(14));
break;
}
case MONTHLY:
{
task.setRelative(NumberHelper.getInt(record.getInteger(11)) == 1);
if (task.getRelative())
{
task.setFrequency(record.getInteger(17));
task.setDayNumber(record.getInteger(15));
task.setDayOfWeek(RecurrenceUtility.getDay(record.getInteger(16)));
}
else
{
task.setFrequency(record.getInteger(19));
task.setDayNumber(record.getInteger(18));
}
break;
}
case YEARLY:
{
task.setRelative(NumberHelper.getInt(record.getInteger(12)) != 1);
if (task.getRelative())
{
task.setDayNumber(record.getInteger(20));
task.setDayOfWeek(RecurrenceUtility.getDay(record.getInteger(21)));
task.setMonthNumber(record.getInteger(22));
}
else
{
task.setYearlyAbsoluteFromDate(record.getDateTime(23));
}
break;
}
}
}
//System.out.println(task);
} | java |
private void populateResourceAssignment(Record record, ResourceAssignment assignment) throws MPXJException
{
//
// Handle malformed MPX files - ensure that we can locate the resource
// using either the Unique ID attribute or the ID attribute.
//
Resource resource = m_projectFile.getResourceByUniqueID(record.getInteger(12));
if (resource == null)
{
resource = m_projectFile.getResourceByID(record.getInteger(0));
}
assignment.setUnits(record.getUnits(1));
assignment.setWork(record.getDuration(2));
assignment.setBaselineWork(record.getDuration(3));
assignment.setActualWork(record.getDuration(4));
assignment.setOvertimeWork(record.getDuration(5));
assignment.setCost(record.getCurrency(6));
assignment.setBaselineCost(record.getCurrency(7));
assignment.setActualCost(record.getCurrency(8));
assignment.setStart(record.getDateTime(9));
assignment.setFinish(record.getDateTime(10));
assignment.setDelay(record.getDuration(11));
//
// Calculate the remaining work
//
Duration work = assignment.getWork();
Duration actualWork = assignment.getActualWork();
if (work != null && actualWork != null)
{
if (work.getUnits() != actualWork.getUnits())
{
actualWork = actualWork.convertUnits(work.getUnits(), m_projectFile.getProjectProperties());
}
assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
if (resource != null)
{
assignment.setResourceUniqueID(resource.getUniqueID());
resource.addResourceAssignment(assignment);
}
m_eventManager.fireAssignmentReadEvent(assignment);
} | java |
private void populateResourceAssignmentWorkgroupFields(Record record, ResourceAssignmentWorkgroupFields workgroup) throws MPXJException
{
workgroup.setMessageUniqueID(record.getString(0));
workgroup.setConfirmed(NumberHelper.getInt(record.getInteger(1)) == 1);
workgroup.setResponsePending(NumberHelper.getInt(record.getInteger(1)) == 1);
workgroup.setUpdateStart(record.getDateTime(3));
workgroup.setUpdateFinish(record.getDateTime(4));
workgroup.setScheduleID(record.getString(5));
} | java |
static void populateFileCreationRecord(Record record, ProjectProperties properties)
{
properties.setMpxProgramName(record.getString(0));
properties.setMpxFileVersion(FileVersion.getInstance(record.getString(1)));
properties.setMpxCodePage(record.getCodePage(2));
} | java |
public static RelationType getInstance(Locale locale, String type)
{
int index = -1;
String[] relationTypes = LocaleData.getStringArray(locale, LocaleData.RELATION_TYPES);
for (int loop = 0; loop < relationTypes.length; loop++)
{
if (relationTypes[loop].equalsIgnoreCase(type) == true)
{
index = loop;
break;
}
}
RelationType result = null;
if (index != -1)
{
result = RelationType.getInstance(index);
}
return (result);
} | java |
public static final Duration parseDuration(String value)
{
Duration result = null;
if (value != null)
{
int split = value.indexOf(' ');
if (split != -1)
{
double durationValue = Double.parseDouble(value.substring(0, split));
TimeUnit durationUnits = parseTimeUnits(value.substring(split + 1));
result = Duration.getInstance(durationValue, durationUnits);
}
}
return result;
} | java |
public static final String printDuration(Duration duration)
{
String result = null;
if (duration != null)
{
result = duration.getDuration() + " " + printTimeUnits(duration.getUnits());
}
return result;
} | java |
public static final String printFinishDateTime(Date value)
{
if (value != null)
{
value = DateHelper.addDays(value, 1);
}
return (value == null ? null : DATE_FORMAT.get().format(value));
} | java |
public static final Date parseFinishDateTime(String value)
{
Date result = parseDateTime(value);
if (result != null)
{
result = DateHelper.addDays(result, -1);
}
return result;
} | java |
private FieldType getFieldType(byte[] data, int offset)
{
int fieldIndex = MPPUtility.getInt(data, offset);
return FieldTypeHelper.mapTextFields(FieldTypeHelper.getInstance14(fieldIndex));
} | java |
private ProjectFile readFile(File file) throws MPXJException
{
try
{
String url = "jdbc:sqlite:" + file.getAbsolutePath();
Properties props = new Properties();
m_connection = org.sqlite.JDBC.createConnection(url, props);
m_documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
m_dayTimeIntervals = xpath.compile("/array/dayTimeInterval");
m_entityMap = new HashMap<String, Integer>();
return read();
}
catch (Exception ex)
{
throw new MPXJException(MPXJException.INVALID_FORMAT, ex);
}
finally
{
if (m_connection != null)
{
try
{
m_connection.close();
}
catch (SQLException ex)
{
// silently ignore exceptions when closing connection
}
}
m_documentBuilder = null;
m_dayTimeIntervals = null;
m_entityMap = null;
}
} | java |
private ProjectFile read() throws Exception
{
m_project = new ProjectFile();
m_eventManager = m_project.getEventManager();
ProjectConfig config = m_project.getProjectConfig();
config.setAutoCalendarUniqueID(false);
config.setAutoTaskUniqueID(false);
config.setAutoResourceUniqueID(false);
m_project.getProjectProperties().setFileApplication("Merlin");
m_project.getProjectProperties().setFileType("SQLITE");
m_eventManager.addProjectListeners(m_projectListeners);
populateEntityMap();
processProject();
processCalendars();
processResources();
processTasks();
processAssignments();
processDependencies();
return m_project;
} | java |
private void populateEntityMap() throws SQLException
{
for (Row row : getRows("select * from z_primarykey"))
{
m_entityMap.put(row.getString("Z_NAME"), row.getInteger("Z_ENT"));
}
} | java |
private void processCalendars() throws Exception
{
List<Row> rows = getRows("select * from zcalendar where zproject=?", m_projectID);
for (Row row : rows)
{
ProjectCalendar calendar = m_project.addCalendar();
calendar.setUniqueID(row.getInteger("Z_PK"));
calendar.setName(row.getString("ZTITLE"));
processDays(calendar);
processExceptions(calendar);
m_eventManager.fireCalendarReadEvent(calendar);
}
} | java |
private void processDays(ProjectCalendar calendar) throws Exception
{
// Default all days to non-working
for (Day day : Day.values())
{
calendar.setWorkingDay(day, false);
}
List<Row> rows = getRows("select * from zcalendarrule where zcalendar1=? and z_ent=?", calendar.getUniqueID(), m_entityMap.get("CalendarWeekDayRule"));
for (Row row : rows)
{
Day day = row.getDay("ZWEEKDAY");
String timeIntervals = row.getString("ZTIMEINTERVALS");
if (timeIntervals == null)
{
calendar.setWorkingDay(day, false);
}
else
{
ProjectCalendarHours hours = calendar.addCalendarHours(day);
NodeList nodes = getNodeList(timeIntervals, m_dayTimeIntervals);
calendar.setWorkingDay(day, nodes.getLength() > 0);
for (int loop = 0; loop < nodes.getLength(); loop++)
{
NamedNodeMap attributes = nodes.item(loop).getAttributes();
Date startTime = m_calendarTimeFormat.parse(attributes.getNamedItem("startTime").getTextContent());
Date endTime = m_calendarTimeFormat.parse(attributes.getNamedItem("endTime").getTextContent());
if (startTime.getTime() >= endTime.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
hours.addRange(new DateRange(startTime, endTime));
}
}
}
} | java |
private void processResources() throws SQLException
{
List<Row> rows = getRows("select * from zresource where zproject=? order by zorderinproject", m_projectID);
for (Row row : rows)
{
Resource resource = m_project.addResource();
resource.setUniqueID(row.getInteger("Z_PK"));
resource.setEmailAddress(row.getString("ZEMAIL"));
resource.setInitials(row.getString("ZINITIALS"));
resource.setName(row.getString("ZTITLE_"));
resource.setGUID(row.getUUID("ZUNIQUEID"));
resource.setType(row.getResourceType("ZTYPE"));
resource.setMaterialLabel(row.getString("ZMATERIALUNIT"));
if (resource.getType() == ResourceType.WORK)
{
resource.setMaxUnits(Double.valueOf(NumberHelper.getDouble(row.getDouble("ZAVAILABLEUNITS_")) * 100.0));
}
Integer calendarID = row.getInteger("ZRESOURCECALENDAR");
if (calendarID != null)
{
ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);
if (calendar != null)
{
calendar.setName(resource.getName());
resource.setResourceCalendar(calendar);
}
}
m_eventManager.fireResourceReadEvent(resource);
}
} | java |
private void processTasks() throws SQLException
{
//
// Yes... we could probably read this in one query in the right order
// using a CTE... but life's too short.
//
List<Row> rows = getRows("select * from zscheduleitem where zproject=? and zparentactivity_ is null and z_ent=? order by zorderinparentactivity", m_projectID, m_entityMap.get("Activity"));
for (Row row : rows)
{
Task task = m_project.addTask();
populateTask(row, task);
processChildTasks(task);
}
} | java |
private void processChildTasks(Task parentTask) throws SQLException
{
List<Row> rows = getRows("select * from zscheduleitem where zparentactivity_=? and z_ent=? order by zorderinparentactivity", parentTask.getUniqueID(), m_entityMap.get("Activity"));
for (Row row : rows)
{
Task task = parentTask.addTask();
populateTask(row, task);
processChildTasks(task);
}
} | java |
private void populateTask(Row row, Task task)
{
task.setUniqueID(row.getInteger("Z_PK"));
task.setName(row.getString("ZTITLE"));
task.setPriority(Priority.getInstance(row.getInt("ZPRIORITY")));
task.setMilestone(row.getBoolean("ZISMILESTONE"));
task.setActualFinish(row.getTimestamp("ZGIVENACTUALENDDATE_"));
task.setActualStart(row.getTimestamp("ZGIVENACTUALSTARTDATE_"));
task.setNotes(row.getString("ZOBJECTDESCRIPTION"));
task.setDuration(row.getDuration("ZGIVENDURATION_"));
task.setOvertimeWork(row.getWork("ZGIVENWORKOVERTIME_"));
task.setWork(row.getWork("ZGIVENWORK_"));
task.setLevelingDelay(row.getDuration("ZLEVELINGDELAY_"));
task.setActualOvertimeWork(row.getWork("ZGIVENACTUALWORKOVERTIME_"));
task.setActualWork(row.getWork("ZGIVENACTUALWORK_"));
task.setRemainingWork(row.getWork("ZGIVENACTUALWORK_"));
task.setGUID(row.getUUID("ZUNIQUEID"));
Integer calendarID = row.getInteger("ZGIVENCALENDAR");
if (calendarID != null)
{
ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);
if (calendar != null)
{
task.setCalendar(calendar);
}
}
populateConstraints(row, task);
// Percent complete is calculated bottom up from assignments and actual work vs. planned work
m_eventManager.fireTaskReadEvent(task);
} | java |
private void populateConstraints(Row row, Task task)
{
Date endDateMax = row.getTimestamp("ZGIVENENDDATEMAX_");
Date endDateMin = row.getTimestamp("ZGIVENENDDATEMIN_");
Date startDateMax = row.getTimestamp("ZGIVENSTARTDATEMAX_");
Date startDateMin = row.getTimestamp("ZGIVENSTARTDATEMIN_");
ConstraintType constraintType = null;
Date constraintDate = null;
if (endDateMax != null)
{
constraintType = ConstraintType.FINISH_NO_LATER_THAN;
constraintDate = endDateMax;
}
if (endDateMin != null)
{
constraintType = ConstraintType.FINISH_NO_EARLIER_THAN;
constraintDate = endDateMin;
}
if (endDateMin != null && endDateMin == endDateMax)
{
constraintType = ConstraintType.MUST_FINISH_ON;
constraintDate = endDateMin;
}
if (startDateMax != null)
{
constraintType = ConstraintType.START_NO_LATER_THAN;
constraintDate = startDateMax;
}
if (startDateMin != null)
{
constraintType = ConstraintType.START_NO_EARLIER_THAN;
constraintDate = startDateMin;
}
if (startDateMin != null && startDateMin == endDateMax)
{
constraintType = ConstraintType.MUST_START_ON;
constraintDate = endDateMin;
}
task.setConstraintType(constraintType);
task.setConstraintDate(constraintDate);
} | java |
private void processAssignments() throws SQLException
{
List<Row> rows = getRows("select * from zscheduleitem where zproject=? and z_ent=? order by zorderinactivity", m_projectID, m_entityMap.get("Assignment"));
for (Row row : rows)
{
Task task = m_project.getTaskByUniqueID(row.getInteger("ZACTIVITY_"));
Resource resource = m_project.getResourceByUniqueID(row.getInteger("ZRESOURCE"));
if (task != null && resource != null)
{
ResourceAssignment assignment = task.addResourceAssignment(resource);
assignment.setGUID(row.getUUID("ZUNIQUEID"));
assignment.setActualFinish(row.getTimestamp("ZGIVENACTUALENDDATE_"));
assignment.setActualStart(row.getTimestamp("ZGIVENACTUALSTARTDATE_"));
assignment.setWork(assignmentDuration(task, row.getWork("ZGIVENWORK_")));
assignment.setOvertimeWork(assignmentDuration(task, row.getWork("ZGIVENWORKOVERTIME_")));
assignment.setActualWork(assignmentDuration(task, row.getWork("ZGIVENACTUALWORK_")));
assignment.setActualOvertimeWork(assignmentDuration(task, row.getWork("ZGIVENACTUALWORKOVERTIME_")));
assignment.setRemainingWork(assignmentDuration(task, row.getWork("ZGIVENREMAININGWORK_")));
assignment.setLevelingDelay(row.getDuration("ZLEVELINGDELAY_"));
if (assignment.getRemainingWork() == null)
{
assignment.setRemainingWork(assignment.getWork());
}
if (resource.getType() == ResourceType.WORK)
{
assignment.setUnits(Double.valueOf(NumberHelper.getDouble(row.getDouble("ZRESOURCEUNITS_")) * 100.0));
}
}
}
} | java |
private Duration assignmentDuration(Task task, Duration work)
{
Duration result = work;
if (result != null)
{
if (result.getUnits() == TimeUnit.PERCENT)
{
Duration taskWork = task.getWork();
if (taskWork != null)
{
result = Duration.getInstance(taskWork.getDuration() * result.getDuration(), taskWork.getUnits());
}
}
}
return result;
} | java |
private void processDependencies() throws SQLException
{
List<Row> rows = getRows("select * from zdependency where zproject=?", m_projectID);
for (Row row : rows)
{
Task nextTask = m_project.getTaskByUniqueID(row.getInteger("ZNEXTACTIVITY_"));
Task prevTask = m_project.getTaskByUniqueID(row.getInteger("ZPREVIOUSACTIVITY_"));
Duration lag = row.getDuration("ZLAG_");
RelationType type = row.getRelationType("ZTYPE");
Relation relation = nextTask.addPredecessor(prevTask, type, lag);
relation.setUniqueID(row.getInteger("Z_PK"));
}
} | java |
private NodeList getNodeList(String document, XPathExpression expression) throws Exception
{
Document doc = m_documentBuilder.parse(new InputSource(new StringReader(document)));
return (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
} | java |
public void process(ProjectProperties properties, FilterContainer filters, FixedData fixedData, Var2Data varData)
{
int filterCount = fixedData.getItemCount();
boolean[] criteriaType = new boolean[2];
CriteriaReader criteriaReader = getCriteriaReader();
for (int filterLoop = 0; filterLoop < filterCount; filterLoop++)
{
byte[] filterFixedData = fixedData.getByteArrayValue(filterLoop);
if (filterFixedData == null || filterFixedData.length < 4)
{
continue;
}
Filter filter = new Filter();
filter.setID(Integer.valueOf(MPPUtility.getInt(filterFixedData, 0)));
filter.setName(MPPUtility.removeAmpersands(MPPUtility.getUnicodeString(filterFixedData, 4)));
byte[] filterVarData = varData.getByteArray(filter.getID(), getVarDataType());
if (filterVarData == null)
{
continue;
}
//System.out.println(ByteArrayHelper.hexdump(filterVarData, true, 16, ""));
List<GenericCriteriaPrompt> prompts = new LinkedList<GenericCriteriaPrompt>();
filter.setShowRelatedSummaryRows(MPPUtility.getByte(filterVarData, 4) != 0);
filter.setCriteria(criteriaReader.process(properties, filterVarData, 0, -1, prompts, null, criteriaType));
filter.setIsTaskFilter(criteriaType[0]);
filter.setIsResourceFilter(criteriaType[1]);
filter.setPrompts(prompts);
filters.addFilter(filter);
//System.out.println(filter);
}
} | java |
@SuppressWarnings("unchecked") public static TimeUnit getInstance(String units, Locale locale) throws MPXJException
{
Map<String, Integer> map = LocaleData.getMap(locale, LocaleData.TIME_UNITS_MAP);
Integer result = map.get(units.toLowerCase());
if (result == null)
{
throw new MPXJException(MPXJException.INVALID_TIME_UNIT + " " + units);
}
return (TimeUnit.getInstance(result.intValue()));
} | java |
public BlockHeader read(byte[] buffer, int offset, int postHeaderSkipBytes)
{
m_offset = offset;
System.arraycopy(buffer, m_offset, m_header, 0, 8);
m_offset += 8;
int nameLength = FastTrackUtility.getInt(buffer, m_offset);
m_offset += 4;
if (nameLength < 1 || nameLength > 255)
{
throw new UnexpectedStructureException();
}
m_name = new String(buffer, m_offset, nameLength, CharsetHelper.UTF16LE);
m_offset += nameLength;
m_columnType = FastTrackUtility.getShort(buffer, m_offset);
m_offset += 2;
m_flags = FastTrackUtility.getShort(buffer, m_offset);
m_offset += 2;
m_skip = new byte[postHeaderSkipBytes];
System.arraycopy(buffer, m_offset, m_skip, 0, postHeaderSkipBytes);
m_offset += postHeaderSkipBytes;
return this;
} | java |
public void process(ProjectFile file, Var2Data varData, byte[] fixedData) throws IOException
{
Props props = getProps(varData);
//System.out.println(props);
if (props != null)
{
String viewName = MPPUtility.removeAmpersands(props.getUnicodeString(VIEW_NAME));
byte[] listData = props.getByteArray(VIEW_CONTENTS);
List<Integer> uniqueIdList = new LinkedList<Integer>();
if (listData != null)
{
for (int index = 0; index < listData.length; index += 4)
{
Integer uniqueID = Integer.valueOf(MPPUtility.getInt(listData, index));
//
// Ensure that we have a valid task, and that if we have and
// ID of zero, this is the first task shown.
//
if (file.getTaskByUniqueID(uniqueID) != null && (uniqueID.intValue() != 0 || index == 0))
{
uniqueIdList.add(uniqueID);
}
}
}
int filterID = MPPUtility.getShort(fixedData, 128);
ViewState state = new ViewState(file, viewName, uniqueIdList, filterID);
file.getViews().setViewState(state);
}
} | java |
@SuppressWarnings("unchecked") public final List<MapRow> getRows(String name)
{
return (List<MapRow>) getObject(name);
} | java |
public static String strip(String text)
{
String result = text;
if (text != null && !text.isEmpty())
{
try
{
boolean formalRTF = isFormalRTF(text);
StringTextConverter stc = new StringTextConverter();
stc.convert(new RtfStringSource(text));
result = stripExtraLineEnd(stc.getText(), formalRTF);
}
catch (IOException ex)
{
result = "";
}
}
return result;
} | java |
private static String stripExtraLineEnd(String text, boolean formalRTF)
{
if (formalRTF && text.endsWith("\n"))
{
text = text.substring(0, text.length() - 1);
}
return text;
} | java |
private void processWorkWeeks(byte[] data, int offset, ProjectCalendar cal)
{
// System.out.println("Calendar=" + cal.getName());
// System.out.println("Work week block start offset=" + offset);
// System.out.println(ByteArrayHelper.hexdump(data, true, 16, ""));
// skip 4 byte header
offset += 4;
while (data.length >= offset + ((7 * 60) + 2 + 2 + 8 + 4))
{
//System.out.println("Week start offset=" + offset);
ProjectCalendarWeek week = cal.addWorkWeek();
for (Day day : Day.values())
{
// 60 byte block per day
processWorkWeekDay(data, offset, week, day);
offset += 60;
}
Date startDate = DateHelper.getDayStartDate(MPPUtility.getDate(data, offset));
offset += 2;
Date finishDate = DateHelper.getDayEndDate(MPPUtility.getDate(data, offset));
offset += 2;
// skip unknown 8 bytes
//System.out.println(ByteArrayHelper.hexdump(data, offset, 8, false));
offset += 8;
//
// Extract the name length - ensure that it is aligned to a 4 byte boundary
//
int nameLength = MPPUtility.getInt(data, offset);
if (nameLength % 4 != 0)
{
nameLength = ((nameLength / 4) + 1) * 4;
}
offset += 4;
if (nameLength != 0)
{
String name = MPPUtility.getUnicodeString(data, offset, nameLength);
offset += nameLength;
week.setName(name);
}
week.setDateRange(new DateRange(startDate, finishDate));
// System.out.println(week);
}
} | java |
private void processWorkWeekDay(byte[] data, int offset, ProjectCalendarWeek week, Day day)
{
//System.out.println(ByteArrayHelper.hexdump(data, offset, 60, false));
int dayType = MPPUtility.getShort(data, offset + 0);
if (dayType == 1)
{
week.setWorkingDay(day, DayType.DEFAULT);
}
else
{
ProjectCalendarHours hours = week.addCalendarHours(day);
int rangeCount = MPPUtility.getShort(data, offset + 2);
if (rangeCount == 0)
{
week.setWorkingDay(day, DayType.NON_WORKING);
}
else
{
week.setWorkingDay(day, DayType.WORKING);
Calendar cal = DateHelper.popCalendar();
for (int index = 0; index < rangeCount; index++)
{
Date startTime = DateHelper.getCanonicalTime(MPPUtility.getTime(data, offset + 8 + (index * 2)));
int durationInSeconds = MPPUtility.getInt(data, offset + 20 + (index * 4)) * 6;
cal.setTime(startTime);
cal.add(Calendar.SECOND, durationInSeconds);
Date finishTime = DateHelper.getCanonicalTime(cal.getTime());
hours.addRange(new DateRange(startTime, finishTime));
}
DateHelper.pushCalendar(cal);
}
}
} | java |
private RecurrenceType getRecurrenceType(int value)
{
RecurrenceType result;
if (value < 0 || value >= RECURRENCE_TYPES.length)
{
result = null;
}
else
{
result = RECURRENCE_TYPES[value];
}
return result;
} | java |
private boolean getRelative(int value)
{
boolean result;
if (value < 0 || value >= RELATIVE_MAP.length)
{
result = false;
}
else
{
result = RELATIVE_MAP[value];
}
return result;
} | java |
public List<GanttDesignerRemark.Task> getTask()
{
if (task == null)
{
task = new ArrayList<GanttDesignerRemark.Task>();
}
return this.task;
} | java |
public void setLeftTableModel(TableModel model)
{
TableModel old = m_leftTable.getModel();
m_leftTable.setModel(model);
firePropertyChange("leftTableModel", old, model);
} | java |
public void setRightTableModel(TableModel model)
{
TableModel old = m_rightTable.getModel();
m_rightTable.setModel(model);
firePropertyChange("rightTableModel", old, model);
} | java |
public void process(InputStream is) throws Exception
{
readHeader(is);
readVersion(is);
readTableData(readTableHeaders(is), is);
} | java |
public StreamReader getTableData(String name) throws IOException
{
InputStream stream = new ByteArrayInputStream(m_tableData.get(name));
if (m_majorVersion > 5)
{
byte[] header = new byte[24];
stream.read(header);
SynchroLogger.log("TABLE HEADER", header);
}
return new StreamReader(m_majorVersion, stream);
} | java |
private List<SynchroTable> readTableHeaders(InputStream is) throws IOException
{
// Read the headers
List<SynchroTable> tables = new ArrayList<SynchroTable>();
byte[] header = new byte[48];
while (true)
{
is.read(header);
m_offset += 48;
SynchroTable table = readTableHeader(header);
if (table == null)
{
break;
}
tables.add(table);
}
// Ensure sorted by offset
Collections.sort(tables, new Comparator<SynchroTable>()
{
@Override public int compare(SynchroTable o1, SynchroTable o2)
{
return o1.getOffset() - o2.getOffset();
}
});
// Calculate lengths
SynchroTable previousTable = null;
for (SynchroTable table : tables)
{
if (previousTable != null)
{
previousTable.setLength(table.getOffset() - previousTable.getOffset());
}
previousTable = table;
}
for (SynchroTable table : tables)
{
SynchroLogger.log("TABLE", table);
}
return tables;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.