_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q800
|
MpxjQuery.listHierarchy
|
train
|
private static void listHierarchy(ProjectFile file)
{
for (Task task : file.getChildTasks())
{
System.out.println("Task: " + task.getName() + "\t" + task.getStart() + "\t" + task.getFinish());
listHierarchy(task, " ");
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q801
|
MpxjQuery.listHierarchy
|
train
|
private static void listHierarchy(Task task, String indent)
{
for (Task child : task.getChildTasks())
{
System.out.println(indent + "Task: " + child.getName() + "\t" + child.getStart() + "\t" + child.getFinish());
listHierarchy(child, indent + " ");
}
}
|
java
|
{
"resource": ""
}
|
q802
|
MpxjQuery.listAssignments
|
train
|
private static void listAssignments(ProjectFile file)
{
Task task;
Resource resource;
String taskName;
String resourceName;
for (ResourceAssignment assignment : file.getResourceAssignments())
{
task = assignment.getTask();
if (task == null)
{
taskName = "(null task)";
}
else
{
taskName = task.getName();
}
resource = assignment.getResource();
if (resource == null)
{
resourceName = "(null resource)";
}
else
{
resourceName = resource.getName();
}
System.out.println("Assignment: Task=" + taskName + " Resource=" + resourceName);
if (task != null)
{
listTimephasedWork(assignment);
}
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q803
|
MpxjQuery.listTimephasedWork
|
train
|
private static void listTimephasedWork(ResourceAssignment assignment)
{
Task task = assignment.getTask();
int days = (int) ((task.getFinish().getTime() - task.getStart().getTime()) / (1000 * 60 * 60 * 24)) + 1;
if (days > 1)
{
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy");
TimescaleUtility timescale = new TimescaleUtility();
ArrayList<DateRange> dates = timescale.createTimescale(task.getStart(), TimescaleUnits.DAYS, days);
TimephasedUtility timephased = new TimephasedUtility();
ArrayList<Duration> durations = timephased.segmentWork(assignment.getCalendar(), assignment.getTimephasedWork(), TimescaleUnits.DAYS, dates);
for (DateRange range : dates)
{
System.out.print(df.format(range.getStart()) + "\t");
}
System.out.println();
for (Duration duration : durations)
{
System.out.print(duration.toString() + " ".substring(0, 7) + "\t");
}
System.out.println();
}
}
|
java
|
{
"resource": ""
}
|
q804
|
MpxjQuery.listAssignmentsByTask
|
train
|
private static void listAssignmentsByTask(ProjectFile file)
{
for (Task task : file.getTasks())
{
System.out.println("Assignments for task " + task.getName() + ":");
for (ResourceAssignment assignment : task.getResourceAssignments())
{
Resource resource = assignment.getResource();
String resourceName;
if (resource == null)
{
resourceName = "(null resource)";
}
else
{
resourceName = resource.getName();
}
System.out.println(" " + resourceName);
}
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q805
|
MpxjQuery.listAssignmentsByResource
|
train
|
private static void listAssignmentsByResource(ProjectFile file)
{
for (Resource resource : file.getResources())
{
System.out.println("Assignments for resource " + resource.getName() + ":");
for (ResourceAssignment assignment : resource.getTaskAssignments())
{
Task task = assignment.getTask();
System.out.println(" " + task.getName());
}
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q806
|
MpxjQuery.listTaskNotes
|
train
|
private static void listTaskNotes(ProjectFile file)
{
for (Task task : file.getTasks())
{
String notes = task.getNotes();
if (notes.length() != 0)
{
System.out.println("Notes for " + task.getName() + ": " + notes);
}
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q807
|
MpxjQuery.listResourceNotes
|
train
|
private static void listResourceNotes(ProjectFile file)
{
for (Resource resource : file.getResources())
{
String notes = resource.getNotes();
if (notes.length() != 0)
{
System.out.println("Notes for " + resource.getName() + ": " + notes);
}
}
System.out.println();
}
|
java
|
{
"resource": ""
}
|
q808
|
MpxjQuery.listRelationships
|
train
|
private static void listRelationships(ProjectFile file)
{
for (Task task : file.getTasks())
{
System.out.print(task.getID());
System.out.print('\t');
System.out.print(task.getName());
System.out.print('\t');
dumpRelationList(task.getPredecessors());
System.out.print('\t');
dumpRelationList(task.getSuccessors());
System.out.println();
}
}
|
java
|
{
"resource": ""
}
|
q809
|
MpxjQuery.dumpRelationList
|
train
|
private static void dumpRelationList(List<Relation> relations)
{
if (relations != null && relations.isEmpty() == false)
{
if (relations.size() > 1)
{
System.out.print('"');
}
boolean first = true;
for (Relation relation : relations)
{
if (!first)
{
System.out.print(',');
}
first = false;
System.out.print(relation.getTargetTask().getID());
Duration lag = relation.getLag();
if (relation.getType() != RelationType.FINISH_START || lag.getDuration() != 0)
{
System.out.print(relation.getType());
}
if (lag.getDuration() != 0)
{
if (lag.getDuration() > 0)
{
System.out.print("+");
}
System.out.print(lag);
}
}
if (relations.size() > 1)
{
System.out.print('"');
}
}
}
|
java
|
{
"resource": ""
}
|
q810
|
MpxjQuery.listSlack
|
train
|
private static void listSlack(ProjectFile file)
{
for (Task task : file.getTasks())
{
System.out.println(task.getName() + " Total Slack=" + task.getTotalSlack() + " Start Slack=" + task.getStartSlack() + " Finish Slack=" + task.getFinishSlack());
}
}
|
java
|
{
"resource": ""
}
|
q811
|
MpxjQuery.listCalendars
|
train
|
private static void listCalendars(ProjectFile file)
{
for (ProjectCalendar cal : file.getCalendars())
{
System.out.println(cal.toString());
}
}
|
java
|
{
"resource": ""
}
|
q812
|
ProjectCalendarContainer.addDefaultBaseCalendar
|
train
|
public ProjectCalendar addDefaultBaseCalendar()
{
ProjectCalendar calendar = add();
calendar.setName(ProjectCalendar.DEFAULT_BASE_CALENDAR_NAME);
calendar.setWorkingDay(Day.SUNDAY, false);
calendar.setWorkingDay(Day.MONDAY, true);
calendar.setWorkingDay(Day.TUESDAY, true);
calendar.setWorkingDay(Day.WEDNESDAY, true);
calendar.setWorkingDay(Day.THURSDAY, true);
calendar.setWorkingDay(Day.FRIDAY, true);
calendar.setWorkingDay(Day.SATURDAY, false);
calendar.addDefaultCalendarHours();
return (calendar);
}
|
java
|
{
"resource": ""
}
|
q813
|
ProjectCalendarContainer.addDefaultDerivedCalendar
|
train
|
public ProjectCalendar addDefaultDerivedCalendar()
{
ProjectCalendar calendar = add();
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);
return (calendar);
}
|
java
|
{
"resource": ""
}
|
q814
|
ProjectCalendarContainer.getByName
|
train
|
public ProjectCalendar getByName(String calendarName)
{
ProjectCalendar calendar = null;
if (calendarName != null && calendarName.length() != 0)
{
Iterator<ProjectCalendar> iter = iterator();
while (iter.hasNext() == true)
{
calendar = iter.next();
String name = calendar.getName();
if ((name != null) && (name.equalsIgnoreCase(calendarName) == true))
{
break;
}
calendar = null;
}
}
return (calendar);
}
|
java
|
{
"resource": ""
}
|
q815
|
MPDDatabaseReader.read
|
train
|
public ProjectFile read() throws MPXJException
{
MPD9DatabaseReader reader = new MPD9DatabaseReader();
reader.setProjectID(m_projectID);
reader.setPreserveNoteFormatting(m_preserveNoteFormatting);
reader.setDataSource(m_dataSource);
reader.setConnection(m_connection);
ProjectFile project = reader.read();
return (project);
}
|
java
|
{
"resource": ""
}
|
q816
|
MPDDatabaseReader.read
|
train
|
@Override public ProjectFile read(String accessDatabaseFileName) throws MPXJException
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + accessDatabaseFileName;
m_connection = DriverManager.getConnection(url);
m_projectID = Integer.valueOf(1);
return (read());
}
catch (ClassNotFoundException ex)
{
throw new MPXJException("Failed to load JDBC driver", ex);
}
catch (SQLException ex)
{
throw new MPXJException("Failed to create connection", ex);
}
finally
{
if (m_connection != null)
{
try
{
m_connection.close();
}
catch (SQLException ex)
{
// silently ignore exceptions when closing connection
}
}
}
}
|
java
|
{
"resource": ""
}
|
q817
|
ProjectWriterUtility.getProjectWriter
|
train
|
public static ProjectWriter getProjectWriter(String name) throws InstantiationException, IllegalAccessException
{
int index = name.lastIndexOf('.');
if (index == -1)
{
throw new IllegalArgumentException("Filename has no extension: " + name);
}
String extension = name.substring(index + 1).toUpperCase();
Class<? extends ProjectWriter> fileClass = WRITER_MAP.get(extension);
if (fileClass == null)
{
throw new IllegalArgumentException("Cannot write files of type: " + name);
}
ProjectWriter file = fileClass.newInstance();
return (file);
}
|
java
|
{
"resource": ""
}
|
q818
|
CustomFieldValueReader9.processCustomFieldValues
|
train
|
private void processCustomFieldValues()
{
byte[] data = m_projectProps.getByteArray(Props.TASK_FIELD_ATTRIBUTES);
if (data != null)
{
int index = 0;
int offset = 0;
// First the length
int length = MPPUtility.getInt(data, offset);
offset += 4;
// Then the number of custom value lists
int numberOfValueLists = MPPUtility.getInt(data, offset);
offset += 4;
// Then the value lists themselves
FieldType field;
int valueListOffset = 0;
while (index < numberOfValueLists && offset < length)
{
// Each item consists of the Field ID (4 bytes) and the offset to the value list (4 bytes)
// Get the Field
field = FieldTypeHelper.getInstance(MPPUtility.getInt(data, offset));
offset += 4;
// Get the value list offset
valueListOffset = MPPUtility.getInt(data, offset);
offset += 4;
// Read the value list itself
if (valueListOffset < data.length)
{
int tempOffset = valueListOffset;
tempOffset += 8;
// Get the data offset
int dataOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;
tempOffset += 4;
// Get the end of the data offset
int endDataOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;
tempOffset += 4;
// Get the end of the description
int endDescriptionOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;
// Get the values themselves
int valuesLength = endDataOffset - dataOffset;
byte[] values = new byte[valuesLength];
MPPUtility.getByteArray(data, dataOffset, valuesLength, values, 0);
// Get the descriptions
int descriptionsLength = endDescriptionOffset - endDataOffset;
byte[] descriptions = new byte[descriptionsLength];
MPPUtility.getByteArray(data, endDataOffset, descriptionsLength, descriptions, 0);
populateContainer(field, values, descriptions);
}
index++;
}
}
}
|
java
|
{
"resource": ""
}
|
q819
|
CustomFieldValueReader9.processOutlineCodeValues
|
train
|
private void processOutlineCodeValues() throws IOException
{
DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
FixedMeta fm = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedMeta"))), 10);
FixedData fd = new FixedData(fm, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedData"))));
Map<Integer, FieldType> map = new HashMap<Integer, FieldType>();
int items = fm.getItemCount();
for (int loop = 0; loop < items; loop++)
{
byte[] data = fd.getByteArrayValue(loop);
if (data.length < 18)
{
continue;
}
int index = MPPUtility.getShort(data, 0);
int fieldID = MPPUtility.getInt(data, 12);
FieldType fieldType = FieldTypeHelper.getInstance(fieldID);
if (fieldType.getFieldTypeClass() != FieldTypeClass.UNKNOWN)
{
map.put(Integer.valueOf(index), fieldType);
}
}
VarMeta outlineCodeVarMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
Var2Data outlineCodeVarData = new Var2Data(outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
Map<FieldType, List<Pair<String, String>>> valueMap = new HashMap<FieldType, List<Pair<String, String>>>();
for (Integer id : outlineCodeVarMeta.getUniqueIdentifierArray())
{
FieldType fieldType = map.get(id);
String value = outlineCodeVarData.getUnicodeString(id, VALUE);
String description = outlineCodeVarData.getUnicodeString(id, DESCRIPTION);
List<Pair<String, String>> list = valueMap.get(fieldType);
if (list == null)
{
list = new ArrayList<Pair<String, String>>();
valueMap.put(fieldType, list);
}
list.add(new Pair<String, String>(value, description));
}
for (Entry<FieldType, List<Pair<String, String>>> entry : valueMap.entrySet())
{
populateContainer(entry.getKey(), entry.getValue());
}
}
|
java
|
{
"resource": ""
}
|
q820
|
CustomFieldValueReader9.populateContainer
|
train
|
private void populateContainer(FieldType field, byte[] values, byte[] descriptions)
{
CustomField config = m_container.getCustomField(field);
CustomFieldLookupTable table = config.getLookupTable();
List<Object> descriptionList = convertType(DataType.STRING, descriptions);
List<Object> valueList = convertType(field.getDataType(), values);
for (int index = 0; index < descriptionList.size(); index++)
{
CustomFieldValueItem item = new CustomFieldValueItem(Integer.valueOf(0));
item.setDescription((String) descriptionList.get(index));
if (index < valueList.size())
{
item.setValue(valueList.get(index));
}
table.add(item);
}
}
|
java
|
{
"resource": ""
}
|
q821
|
CustomFieldValueReader9.populateContainer
|
train
|
private void populateContainer(FieldType field, List<Pair<String, String>> items)
{
CustomField config = m_container.getCustomField(field);
CustomFieldLookupTable table = config.getLookupTable();
for (Pair<String, String> pair : items)
{
CustomFieldValueItem item = new CustomFieldValueItem(Integer.valueOf(0));
item.setValue(pair.getFirst());
item.setDescription(pair.getSecond());
table.add(item);
}
}
|
java
|
{
"resource": ""
}
|
q822
|
CustomFieldValueReader9.convertType
|
train
|
private List<Object> convertType(DataType type, byte[] data)
{
List<Object> result = new ArrayList<Object>();
int index = 0;
while (index < data.length)
{
switch (type)
{
case STRING:
{
String value = MPPUtility.getUnicodeString(data, index);
result.add(value);
index += ((value.length() + 1) * 2);
break;
}
case CURRENCY:
{
Double value = Double.valueOf(MPPUtility.getDouble(data, index) / 100);
result.add(value);
index += 8;
break;
}
case NUMERIC:
{
Double value = Double.valueOf(MPPUtility.getDouble(data, index));
result.add(value);
index += 8;
break;
}
case DATE:
{
Date value = MPPUtility.getTimestamp(data, index);
result.add(value);
index += 4;
break;
}
case DURATION:
{
TimeUnit units = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, index + 4), m_properties.getDefaultDurationUnits());
Duration value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(data, index), units);
result.add(value);
index += 6;
break;
}
case BOOLEAN:
{
Boolean value = Boolean.valueOf(MPPUtility.getShort(data, index) == 1);
result.add(value);
index += 2;
break;
}
default:
{
index = data.length;
break;
}
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q823
|
MapRow.getBoolean
|
train
|
public boolean getBoolean(FastTrackField type)
{
boolean result = false;
Object value = getObject(type);
if (value != null)
{
result = BooleanHelper.getBoolean((Boolean) value);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q824
|
MapRow.getTimestamp
|
train
|
public Date getTimestamp(FastTrackField dateName, FastTrackField timeName)
{
Date result = null;
Date date = getDate(dateName);
if (date != null)
{
Calendar dateCal = DateHelper.popCalendar(date);
Date time = getDate(timeName);
if (time != null)
{
Calendar timeCal = DateHelper.popCalendar(time);
dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY));
dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE));
dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND));
dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND));
DateHelper.pushCalendar(timeCal);
}
result = dateCal.getTime();
DateHelper.pushCalendar(dateCal);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q825
|
MapRow.getDuration
|
train
|
public Duration getDuration(FastTrackField type)
{
Double value = (Double) getObject(type);
return value == null ? null : Duration.getInstance(value.doubleValue(), m_table.getDurationTimeUnit());
}
|
java
|
{
"resource": ""
}
|
q826
|
MapRow.getWork
|
train
|
public Duration getWork(FastTrackField type)
{
Double value = (Double) getObject(type);
return value == null ? null : Duration.getInstance(value.doubleValue(), m_table.getWorkTimeUnit());
}
|
java
|
{
"resource": ""
}
|
q827
|
MapRow.getUUID
|
train
|
public UUID getUUID(FastTrackField type)
{
String value = getString(type);
UUID result = null;
if (value != null && !value.isEmpty() && value.length() >= 36)
{
if (value.startsWith("{"))
{
value = value.substring(1, value.length() - 1);
}
if (value.length() > 16)
{
value = value.substring(0, 36);
}
result = UUID.fromString(value);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q828
|
MPDUtility.getSymbolPosition
|
train
|
public static CurrencySymbolPosition getSymbolPosition(int value)
{
CurrencySymbolPosition result;
switch (value)
{
case 1:
{
result = CurrencySymbolPosition.AFTER;
break;
}
case 2:
{
result = CurrencySymbolPosition.BEFORE_WITH_SPACE;
break;
}
case 3:
{
result = CurrencySymbolPosition.AFTER_WITH_SPACE;
break;
}
case 0:
default:
{
result = CurrencySymbolPosition.BEFORE;
break;
}
}
return (result);
}
|
java
|
{
"resource": ""
}
|
q829
|
MPDUtility.getDuration
|
train
|
public static final Duration getDuration(double value, TimeUnit type)
{
double duration;
// Value is given in 1/10 of minute
switch (type)
{
case MINUTES:
case ELAPSED_MINUTES:
{
duration = value / 10;
break;
}
case HOURS:
case ELAPSED_HOURS:
{
duration = value / 600; // 60 * 10
break;
}
case DAYS:
{
duration = value / 4800; // 8 * 60 * 10
break;
}
case ELAPSED_DAYS:
{
duration = value / 14400; // 24 * 60 * 10
break;
}
case WEEKS:
{
duration = value / 24000; // 5 * 8 * 60 * 10
break;
}
case ELAPSED_WEEKS:
{
duration = value / 100800; // 7 * 24 * 60 * 10
break;
}
case MONTHS:
{
duration = value / 96000; // 4 * 5 * 8 * 60 * 10
break;
}
case ELAPSED_MONTHS:
{
duration = value / 432000; // 30 * 24 * 60 * 10
break;
}
default:
{
duration = value;
break;
}
}
return (Duration.getInstance(duration, type));
}
|
java
|
{
"resource": ""
}
|
q830
|
MPDUtility.dumpRow
|
train
|
public static void dumpRow(Map<String, Object> row)
{
for (Entry<String, Object> entry : row.entrySet())
{
Object value = entry.getValue();
System.out.println(entry.getKey() + " = " + value + " ( " + (value == null ? "" : value.getClass().getName()) + ")");
}
}
|
java
|
{
"resource": ""
}
|
q831
|
MapFileGenerator.generateMapFile
|
train
|
public void generateMapFile(File jarFile, String mapFileName, boolean mapClassMethods) throws XMLStreamException, IOException, ClassNotFoundException, IntrospectionException
{
m_responseList = new LinkedList<String>();
writeMapFile(mapFileName, jarFile, mapClassMethods);
}
|
java
|
{
"resource": ""
}
|
q832
|
MapFileGenerator.writeMapFile
|
train
|
private void writeMapFile(String mapFileName, File jarFile, boolean mapClassMethods) throws IOException, XMLStreamException, ClassNotFoundException, IntrospectionException
{
FileWriter fw = new FileWriter(mapFileName);
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLStreamWriter writer = xof.createXMLStreamWriter(fw);
//XMLStreamWriter writer = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(fw));
writer.writeStartDocument();
writer.writeStartElement("root");
writer.writeStartElement("assembly");
addClasses(writer, jarFile, mapClassMethods);
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndDocument();
writer.flush();
writer.close();
fw.flush();
fw.close();
}
|
java
|
{
"resource": ""
}
|
q833
|
MapFileGenerator.addClasses
|
train
|
private void addClasses(XMLStreamWriter writer, File jarFile, boolean mapClassMethods) throws IOException, ClassNotFoundException, XMLStreamException, IntrospectionException
{
ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
URLClassLoader loader = new URLClassLoader(new URL[]
{
jarFile.toURI().toURL()
}, currentThreadClassLoader);
JarFile jar = new JarFile(jarFile);
Enumeration<JarEntry> enumeration = jar.entries();
while (enumeration.hasMoreElements())
{
JarEntry jarEntry = enumeration.nextElement();
if (!jarEntry.isDirectory() && jarEntry.getName().endsWith(".class"))
{
addClass(loader, jarEntry, writer, mapClassMethods);
}
}
jar.close();
}
|
java
|
{
"resource": ""
}
|
q834
|
MapFileGenerator.addClass
|
train
|
private void addClass(URLClassLoader loader, JarEntry jarEntry, XMLStreamWriter writer, boolean mapClassMethods) throws ClassNotFoundException, XMLStreamException, IntrospectionException
{
String className = jarEntry.getName().replaceAll("\\.class", "").replaceAll("/", ".");
writer.writeStartElement("class");
writer.writeAttribute("name", className);
Set<Method> methodSet = new HashSet<Method>();
Class<?> aClass = loader.loadClass(className);
processProperties(writer, methodSet, aClass);
if (mapClassMethods && !Modifier.isInterface(aClass.getModifiers()))
{
processClassMethods(writer, aClass, methodSet);
}
writer.writeEndElement();
}
|
java
|
{
"resource": ""
}
|
q835
|
MapFileGenerator.processProperties
|
train
|
private void processProperties(XMLStreamWriter writer, Set<Method> methodSet, Class<?> aClass) throws IntrospectionException, XMLStreamException
{
BeanInfo beanInfo = Introspector.getBeanInfo(aClass, aClass.getSuperclass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (int i = 0; i < propertyDescriptors.length; i++)
{
PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
if (propertyDescriptor.getPropertyType() != null)
{
String name = propertyDescriptor.getName();
Method readMethod = propertyDescriptor.getReadMethod();
Method writeMethod = propertyDescriptor.getWriteMethod();
String readMethodName = readMethod == null ? null : readMethod.getName();
String writeMethodName = writeMethod == null ? null : writeMethod.getName();
addProperty(writer, name, propertyDescriptor.getPropertyType(), readMethodName, writeMethodName);
if (readMethod != null)
{
methodSet.add(readMethod);
}
if (writeMethod != null)
{
methodSet.add(writeMethod);
}
}
else
{
processAmbiguousProperty(writer, methodSet, aClass, propertyDescriptor);
}
}
}
|
java
|
{
"resource": ""
}
|
q836
|
MapFileGenerator.addProperty
|
train
|
private void addProperty(XMLStreamWriter writer, String name, Class<?> propertyType, String readMethod, String writeMethod) throws XMLStreamException
{
if (name.length() != 0)
{
writer.writeStartElement("property");
// convert property name to .NET style (i.e. first letter uppercase)
String propertyName = name.substring(0, 1).toUpperCase() + name.substring(1);
writer.writeAttribute("name", propertyName);
String type = getTypeString(propertyType);
writer.writeAttribute("sig", "()" + type);
if (readMethod != null)
{
writer.writeStartElement("getter");
writer.writeAttribute("name", readMethod);
writer.writeAttribute("sig", "()" + type);
writer.writeEndElement();
}
if (writeMethod != null)
{
writer.writeStartElement("setter");
writer.writeAttribute("name", writeMethod);
writer.writeAttribute("sig", "(" + type + ")V");
writer.writeEndElement();
}
writer.writeEndElement();
}
}
|
java
|
{
"resource": ""
}
|
q837
|
MapFileGenerator.getTypeString
|
train
|
private String getTypeString(Class<?> c)
{
String result = TYPE_MAP.get(c);
if (result == null)
{
result = c.getName();
if (!result.endsWith(";") && !result.startsWith("["))
{
result = "L" + result + ";";
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q838
|
MapFileGenerator.processClassMethods
|
train
|
private void processClassMethods(XMLStreamWriter writer, Class<?> aClass, Set<Method> methodSet) throws XMLStreamException
{
Method[] methods = aClass.getDeclaredMethods();
for (Method method : methods)
{
if (!methodSet.contains(method) && Modifier.isPublic(method.getModifiers()) && !Modifier.isInterface(method.getModifiers()))
{
if (Modifier.isStatic(method.getModifiers()))
{
// TODO Handle static methods here
}
else
{
String name = method.getName();
String methodSignature = createMethodSignature(method);
String fullJavaName = aClass.getCanonicalName() + "." + name + methodSignature;
if (!ignoreMethod(fullJavaName))
{
//
// Hide the original method
//
writer.writeStartElement("method");
writer.writeAttribute("name", name);
writer.writeAttribute("sig", methodSignature);
writer.writeStartElement("attribute");
writer.writeAttribute("type", "System.ComponentModel.EditorBrowsableAttribute");
writer.writeAttribute("sig", "(Lcli.System.ComponentModel.EditorBrowsableState;)V");
writer.writeStartElement("parameter");
writer.writeCharacters("Never");
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndElement();
//
// Create a wrapper method
//
name = name.toUpperCase().charAt(0) + name.substring(1);
writer.writeStartElement("method");
writer.writeAttribute("name", name);
writer.writeAttribute("sig", methodSignature);
writer.writeAttribute("modifiers", "public");
writer.writeStartElement("body");
for (int index = 0; index <= method.getParameterTypes().length; index++)
{
if (index < 4)
{
writer.writeEmptyElement("ldarg_" + index);
}
else
{
writer.writeStartElement("ldarg_s");
writer.writeAttribute("argNum", Integer.toString(index));
writer.writeEndElement();
}
}
writer.writeStartElement("callvirt");
writer.writeAttribute("class", aClass.getName());
writer.writeAttribute("name", method.getName());
writer.writeAttribute("sig", methodSignature);
writer.writeEndElement();
if (!method.getReturnType().getName().equals("void"))
{
writer.writeEmptyElement("ldnull");
writer.writeEmptyElement("pop");
}
writer.writeEmptyElement("ret");
writer.writeEndElement();
writer.writeEndElement();
/*
* The private method approach doesn't work... so
* 3. Add EditorBrowsableAttribute (Never) to original methods
* 4. Generate C Sharp and VB variants of the DLL to avid case-sensitivity issues
* 5. Implement static method support?
<attribute type="System.ComponentModel.EditorBrowsableAttribute" sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
914 <parameter>Never</parameter>
915 </attribute>
*/
m_responseList.add(fullJavaName);
}
}
}
}
}
|
java
|
{
"resource": ""
}
|
q839
|
MapFileGenerator.ignoreMethod
|
train
|
private boolean ignoreMethod(String name)
{
boolean result = false;
for (String ignoredName : IGNORED_METHODS)
{
if (name.matches(ignoredName))
{
result = true;
break;
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q840
|
MapFileGenerator.createMethodSignature
|
train
|
private String createMethodSignature(Method method)
{
StringBuilder sb = new StringBuilder();
sb.append("(");
for (Class<?> type : method.getParameterTypes())
{
sb.append(getTypeString(type));
}
sb.append(")");
Class<?> type = method.getReturnType();
if (type.getName().equals("void"))
{
sb.append("V");
}
else
{
sb.append(getTypeString(type));
}
return sb.toString();
}
|
java
|
{
"resource": ""
}
|
q841
|
ProjectCalendarException.contains
|
train
|
public boolean contains(Date date)
{
boolean result = false;
if (date != null)
{
result = (DateHelper.compare(getFromDate(), getToDate(), date) == 0);
}
return (result);
}
|
java
|
{
"resource": ""
}
|
q842
|
JTableExtra.setModel
|
train
|
@Override public void setModel(TableModel model)
{
super.setModel(model);
int columns = model.getColumnCount();
TableColumnModel tableColumnModel = getColumnModel();
for (int index = 0; index < columns; index++)
{
tableColumnModel.getColumn(index).setPreferredWidth(m_columnWidth);
}
}
|
java
|
{
"resource": ""
}
|
q843
|
MPP14Reader.process
|
train
|
@Override public void process(MPPReader reader, ProjectFile file, DirectoryEntry root) throws MPXJException, IOException
{
try
{
populateMemberData(reader, file, root);
processProjectProperties();
if (!reader.getReadPropertiesOnly())
{
processSubProjectData();
processGraphicalIndicators();
processCustomValueLists();
processCalendarData();
processResourceData();
processTaskData();
processConstraintData();
processAssignmentData();
postProcessTasks();
if (reader.getReadPresentationData())
{
processViewPropertyData();
processTableData();
processViewData();
processFilterData();
processGroupData();
processSavedViewState();
}
}
}
finally
{
clearMemberData();
}
}
|
java
|
{
"resource": ""
}
|
q844
|
MPP14Reader.processGraphicalIndicators
|
train
|
private void processGraphicalIndicators()
{
GraphicalIndicatorReader graphicalIndicatorReader = new GraphicalIndicatorReader();
graphicalIndicatorReader.process(m_file.getCustomFields(), m_file.getProjectProperties(), m_projectProps);
}
|
java
|
{
"resource": ""
}
|
q845
|
MPP14Reader.readSubProjects
|
train
|
private void readSubProjects(byte[] data, int uniqueIDOffset, int filePathOffset, int fileNameOffset, int subprojectIndex)
{
while (uniqueIDOffset < filePathOffset)
{
readSubProject(data, uniqueIDOffset, filePathOffset, fileNameOffset, subprojectIndex++);
uniqueIDOffset += 4;
}
}
|
java
|
{
"resource": ""
}
|
q846
|
MPP14Reader.processBaseFonts
|
train
|
private void processBaseFonts(byte[] data)
{
int offset = 0;
int blockCount = MPPUtility.getShort(data, 0);
offset += 2;
int size;
String name;
for (int loop = 0; loop < blockCount; loop++)
{
/*unknownAttribute = MPPUtility.getShort(data, offset);*/
offset += 2;
size = MPPUtility.getShort(data, offset);
offset += 2;
name = MPPUtility.getUnicodeString(data, offset);
offset += 64;
if (name.length() != 0)
{
FontBase fontBase = new FontBase(Integer.valueOf(loop), name, size);
m_fontBases.put(fontBase.getIndex(), fontBase);
}
}
}
|
java
|
{
"resource": ""
}
|
q847
|
MPP14Reader.createTaskMap
|
train
|
private TreeMap<Integer, Integer> createTaskMap(FieldMap fieldMap, FixedMeta taskFixedMeta, FixedData taskFixedData, Var2Data taskVarData)
{
TreeMap<Integer, Integer> taskMap = new TreeMap<Integer, Integer>();
int uniqueIdOffset = fieldMap.getFixedDataOffset(TaskField.UNIQUE_ID);
Integer taskNameKey = fieldMap.getVarDataKey(TaskField.NAME);
int itemCount = taskFixedMeta.getAdjustedItemCount();
int uniqueID;
Integer key;
//
// First three items are not tasks, so let's skip them
//
for (int loop = 3; loop < itemCount; loop++)
{
byte[] data = taskFixedData.getByteArrayValue(loop);
if (data != null)
{
byte[] metaData = taskFixedMeta.getByteArrayValue(loop);
//
// Check for the deleted task flag
//
int flags = MPPUtility.getInt(metaData, 0);
if ((flags & 0x02) != 0)
{
// Project stores the deleted tasks unique id's into the fixed data as well
// and at least in one case the deleted task was listed twice in the list
// the second time with data with it causing a phantom task to be shown.
// See CalendarErrorPhantomTasks.mpp
//
// So let's add the unique id for the deleted task into the map so we don't
// accidentally include the task later.
//
uniqueID = MPPUtility.getShort(data, TASK_UNIQUE_ID_FIXED_OFFSET); // Only a short stored for deleted tasks?
key = Integer.valueOf(uniqueID);
if (taskMap.containsKey(key) == false)
{
taskMap.put(key, null); // use null so we can easily ignore this later
}
}
else
{
//
// Do we have a null task?
//
if (data.length == NULL_TASK_BLOCK_SIZE)
{
uniqueID = MPPUtility.getInt(data, TASK_UNIQUE_ID_FIXED_OFFSET);
key = Integer.valueOf(uniqueID);
if (taskMap.containsKey(key) == false)
{
taskMap.put(key, Integer.valueOf(loop));
}
}
else
{
//
// We apply a heuristic here - if we have more than 75% of the data, we assume
// the task is valid.
//
int maxSize = fieldMap.getMaxFixedDataSize(0);
if (maxSize == 0 || ((data.length * 100) / maxSize) > 75)
{
uniqueID = MPPUtility.getInt(data, uniqueIdOffset);
key = Integer.valueOf(uniqueID);
// Accept this task if it does not have a deleted unique ID or it has a deleted unique ID but the name is not null
if (!taskMap.containsKey(key) || taskVarData.getUnicodeString(key, taskNameKey) != null)
{
taskMap.put(key, Integer.valueOf(loop));
}
}
}
}
}
}
return (taskMap);
}
|
java
|
{
"resource": ""
}
|
q848
|
MPP14Reader.postProcessTasks
|
train
|
private void postProcessTasks() throws MPXJException
{
//
// Renumber ID values using a large increment to allow
// space for later inserts.
//
TreeMap<Integer, Integer> taskMap = new TreeMap<Integer, Integer>();
// I've found a pathological case of an MPP file with around 102k blank tasks...
int nextIDIncrement = 102000;
int nextID = (m_file.getTaskByUniqueID(Integer.valueOf(0)) == null ? nextIDIncrement : 0);
for (Map.Entry<Long, Integer> entry : m_taskOrder.entrySet())
{
taskMap.put(Integer.valueOf(nextID), entry.getValue());
nextID += nextIDIncrement;
}
//
// Insert any null tasks into the correct location
//
int insertionCount = 0;
Map<Integer, Integer> offsetMap = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : m_nullTaskOrder.entrySet())
{
int idValue = entry.getKey().intValue();
int baseTargetIdValue = (idValue - insertionCount) * nextIDIncrement;
int targetIDValue = baseTargetIdValue;
Integer previousOffsetKey = Integer.valueOf(baseTargetIdValue);
Integer previousOffset = offsetMap.get(previousOffsetKey);
int offset = previousOffset == null ? 0 : previousOffset.intValue() + 1;
++insertionCount;
while (taskMap.containsKey(Integer.valueOf(targetIDValue)))
{
++offset;
if (offset == nextIDIncrement)
{
throw new MPXJException("Unable to fix task order");
}
targetIDValue = baseTargetIdValue - (nextIDIncrement - offset);
}
offsetMap.put(previousOffsetKey, Integer.valueOf(offset));
taskMap.put(Integer.valueOf(targetIDValue), entry.getValue());
}
//
// Finally, we can renumber the tasks
//
nextID = (m_file.getTaskByUniqueID(Integer.valueOf(0)) == null ? 1 : 0);
for (Map.Entry<Integer, Integer> entry : taskMap.entrySet())
{
Task task = m_file.getTaskByUniqueID(entry.getValue());
if (task != null)
{
task.setID(Integer.valueOf(nextID));
}
nextID++;
}
}
|
java
|
{
"resource": ""
}
|
q849
|
MPP14Reader.processHyperlinkData
|
train
|
private void processHyperlinkData(Resource resource, byte[] data)
{
if (data != null)
{
int offset = 12;
String hyperlink;
String address;
String subaddress;
offset += 12;
hyperlink = MPPUtility.getUnicodeString(data, offset);
offset += ((hyperlink.length() + 1) * 2);
offset += 12;
address = MPPUtility.getUnicodeString(data, offset);
offset += ((address.length() + 1) * 2);
offset += 12;
subaddress = MPPUtility.getUnicodeString(data, offset);
resource.setHyperlink(hyperlink);
resource.setHyperlinkAddress(address);
resource.setHyperlinkSubAddress(subaddress);
}
}
|
java
|
{
"resource": ""
}
|
q850
|
MPP14Reader.readBitFields
|
train
|
private void readBitFields(MppBitFlag[] flags, FieldContainer container, byte[] data)
{
for (MppBitFlag flag : flags)
{
flag.setValue(container, data);
}
}
|
java
|
{
"resource": ""
}
|
q851
|
Table.read
|
train
|
public void read(InputStream is) throws IOException
{
byte[] headerBlock = new byte[20];
is.read(headerBlock);
int headerLength = PEPUtility.getShort(headerBlock, 8);
int recordCount = PEPUtility.getInt(headerBlock, 10);
int recordLength = PEPUtility.getInt(headerBlock, 16);
StreamHelper.skip(is, headerLength - headerBlock.length);
byte[] record = new byte[recordLength];
for (int recordIndex = 1; recordIndex <= recordCount; recordIndex++)
{
is.read(record);
readRow(recordIndex, record);
}
}
|
java
|
{
"resource": ""
}
|
q852
|
Table.addRow
|
train
|
protected void addRow(int uniqueID, Map<String, Object> map)
{
m_rows.put(Integer.valueOf(uniqueID), new MapRow(map));
}
|
java
|
{
"resource": ""
}
|
q853
|
TimephasedDataFactory.getCompleteWork
|
train
|
public List<TimephasedWork> getCompleteWork(ProjectCalendar calendar, ResourceAssignment resourceAssignment, byte[] data)
{
LinkedList<TimephasedWork> list = new LinkedList<TimephasedWork>();
if (calendar != null && data != null && data.length > 2 && MPPUtility.getShort(data, 0) > 0)
{
Date startDate = resourceAssignment.getStart();
double finishTime = MPPUtility.getInt(data, 24);
int blockCount = MPPUtility.getShort(data, 0);
double previousCumulativeWork = 0;
TimephasedWork previousAssignment = null;
int index = 32;
int currentBlock = 0;
while (currentBlock < blockCount && index + 20 <= data.length)
{
double time = MPPUtility.getInt(data, index + 0);
// If the start of this block is before the start of the assignment, or after the end of the assignment
// the values don't make sense, so we'll just set the start of this block to be the start of the assignment.
// This deals with an issue where odd timephased data like this was causing an MPP file to be read
// extremely slowly.
if (time < 0 || time > finishTime)
{
time = 0;
}
else
{
time /= 80;
}
Duration startWork = Duration.getInstance(time, TimeUnit.MINUTES);
double currentCumulativeWork = (long) MPPUtility.getDouble(data, index + 4);
double assignmentDuration = currentCumulativeWork - previousCumulativeWork;
previousCumulativeWork = currentCumulativeWork;
assignmentDuration /= 1000;
Duration totalWork = Duration.getInstance(assignmentDuration, TimeUnit.MINUTES);
time = (long) MPPUtility.getDouble(data, index + 12);
time /= 125;
time *= 6;
Duration workPerDay = Duration.getInstance(time, TimeUnit.MINUTES);
Date start;
if (startWork.getDuration() == 0)
{
start = startDate;
}
else
{
start = calendar.getDate(startDate, startWork, true);
}
TimephasedWork assignment = new TimephasedWork();
assignment.setStart(start);
assignment.setAmountPerDay(workPerDay);
assignment.setTotalAmount(totalWork);
if (previousAssignment != null)
{
Date finish = calendar.getDate(startDate, startWork, false);
previousAssignment.setFinish(finish);
if (previousAssignment.getStart().getTime() == previousAssignment.getFinish().getTime())
{
list.removeLast();
}
}
list.add(assignment);
previousAssignment = assignment;
index += 20;
++currentBlock;
}
if (previousAssignment != null)
{
Duration finishWork = Duration.getInstance(finishTime / 80, TimeUnit.MINUTES);
Date finish = calendar.getDate(startDate, finishWork, false);
previousAssignment.setFinish(finish);
if (previousAssignment.getStart().getTime() == previousAssignment.getFinish().getTime())
{
list.removeLast();
}
}
}
return list;
}
|
java
|
{
"resource": ""
}
|
q854
|
TimephasedDataFactory.getWorkModified
|
train
|
public boolean getWorkModified(List<TimephasedWork> list)
{
boolean result = false;
for (TimephasedWork assignment : list)
{
result = assignment.getModified();
if (result)
{
break;
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q855
|
TimephasedDataFactory.getBaselineWork
|
train
|
public TimephasedWorkContainer getBaselineWork(ResourceAssignment assignment, ProjectCalendar calendar, TimephasedWorkNormaliser normaliser, byte[] data, boolean raw)
{
TimephasedWorkContainer result = null;
if (data != null && data.length > 0)
{
LinkedList<TimephasedWork> list = null;
//System.out.println(ByteArrayHelper.hexdump(data, false));
int index = 8; // 8 byte header
int blockSize = 40;
double previousCumulativeWorkPerformedInMinutes = 0;
Date blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 36);
index += blockSize;
TimephasedWork work = null;
while (index + blockSize <= data.length)
{
double cumulativeWorkInMinutes = (double) ((long) MPPUtility.getDouble(data, index + 20)) / 1000;
if (!Duration.durationValueEquals(cumulativeWorkInMinutes, previousCumulativeWorkPerformedInMinutes))
{
//double unknownWorkThisPeriodInMinutes = ((long) MPPUtility.getDouble(data, index + 0)) / 1000;
double normalActualWorkThisPeriodInMinutes = ((double) MPPUtility.getInt(data, index + 8)) / 10;
double normalRemainingWorkThisPeriodInMinutes = ((double) MPPUtility.getInt(data, index + 28)) / 10;
double workThisPeriodInMinutes = cumulativeWorkInMinutes - previousCumulativeWorkPerformedInMinutes;
double overtimeWorkThisPeriodInMinutes = workThisPeriodInMinutes - (normalActualWorkThisPeriodInMinutes + normalRemainingWorkThisPeriodInMinutes);
double overtimeFactor = overtimeWorkThisPeriodInMinutes / (normalActualWorkThisPeriodInMinutes + normalRemainingWorkThisPeriodInMinutes);
double normalWorkPerDayInMinutes = 480;
double overtimeWorkPerDayInMinutes = normalWorkPerDayInMinutes * overtimeFactor;
work = new TimephasedWork();
work.setFinish(MPPUtility.getTimestampFromTenths(data, index + 16));
work.setStart(blockStartDate);
work.setTotalAmount(Duration.getInstance(workThisPeriodInMinutes, TimeUnit.MINUTES));
work.setAmountPerDay(Duration.getInstance(normalWorkPerDayInMinutes + overtimeWorkPerDayInMinutes, TimeUnit.MINUTES));
previousCumulativeWorkPerformedInMinutes = cumulativeWorkInMinutes;
if (list == null)
{
list = new LinkedList<TimephasedWork>();
}
list.add(work);
//System.out.println(work);
}
blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 36);
index += blockSize;
}
if (list != null)
{
if (work != null)
{
work.setFinish(assignment.getFinish());
}
result = new DefaultTimephasedWorkContainer(calendar, normaliser, list, raw);
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q856
|
TimephasedDataFactory.getBaselineCost
|
train
|
public TimephasedCostContainer getBaselineCost(ProjectCalendar calendar, TimephasedCostNormaliser normaliser, byte[] data, boolean raw)
{
TimephasedCostContainer result = null;
if (data != null && data.length > 0)
{
LinkedList<TimephasedCost> list = null;
//System.out.println(ByteArrayHelper.hexdump(data, false));
int index = 16; // 16 byte header
int blockSize = 20;
double previousTotalCost = 0;
Date blockStartDate = MPPUtility.getTimestampFromTenths(data, index + 16);
index += blockSize;
while (index + blockSize <= data.length)
{
Date blockEndDate = MPPUtility.getTimestampFromTenths(data, index + 16);
double currentTotalCost = (double) ((long) MPPUtility.getDouble(data, index + 8)) / 100;
if (!costEquals(previousTotalCost, currentTotalCost))
{
TimephasedCost cost = new TimephasedCost();
cost.setStart(blockStartDate);
cost.setFinish(blockEndDate);
cost.setTotalAmount(Double.valueOf(currentTotalCost - previousTotalCost));
if (list == null)
{
list = new LinkedList<TimephasedCost>();
}
list.add(cost);
//System.out.println(cost);
previousTotalCost = currentTotalCost;
}
blockStartDate = blockEndDate;
index += blockSize;
}
if (list != null)
{
result = new DefaultTimephasedCostContainer(calendar, normaliser, list, raw);
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q857
|
SplitTaskFactory.processSplitData
|
train
|
public void processSplitData(Task task, List<TimephasedWork> timephasedComplete, List<TimephasedWork> timephasedPlanned)
{
Date splitsComplete = null;
TimephasedWork lastComplete = null;
TimephasedWork firstPlanned = null;
if (!timephasedComplete.isEmpty())
{
lastComplete = timephasedComplete.get(timephasedComplete.size() - 1);
splitsComplete = lastComplete.getFinish();
}
if (!timephasedPlanned.isEmpty())
{
firstPlanned = timephasedPlanned.get(0);
}
LinkedList<DateRange> splits = new LinkedList<DateRange>();
TimephasedWork lastAssignment = null;
DateRange lastRange = null;
for (TimephasedWork assignment : timephasedComplete)
{
if (lastAssignment != null && lastRange != null && lastAssignment.getTotalAmount().getDuration() != 0 && assignment.getTotalAmount().getDuration() != 0)
{
splits.removeLast();
lastRange = new DateRange(lastRange.getStart(), assignment.getFinish());
}
else
{
lastRange = new DateRange(assignment.getStart(), assignment.getFinish());
}
splits.add(lastRange);
lastAssignment = assignment;
}
//
// We may not have a split, we may just have a partially
// complete split.
//
Date splitStart = null;
if (lastComplete != null && firstPlanned != null && lastComplete.getTotalAmount().getDuration() != 0 && firstPlanned.getTotalAmount().getDuration() != 0)
{
lastRange = splits.removeLast();
splitStart = lastRange.getStart();
}
lastAssignment = null;
lastRange = null;
for (TimephasedWork assignment : timephasedPlanned)
{
if (splitStart == null)
{
if (lastAssignment != null && lastRange != null && lastAssignment.getTotalAmount().getDuration() != 0 && assignment.getTotalAmount().getDuration() != 0)
{
splits.removeLast();
lastRange = new DateRange(lastRange.getStart(), assignment.getFinish());
}
else
{
lastRange = new DateRange(assignment.getStart(), assignment.getFinish());
}
}
else
{
lastRange = new DateRange(splitStart, assignment.getFinish());
}
splits.add(lastRange);
splitStart = null;
lastAssignment = assignment;
}
//
// We must have a minimum of 3 entries for this to be a valid split task
//
if (splits.size() > 2)
{
task.getSplits().addAll(splits);
task.setSplitCompleteDuration(splitsComplete);
}
else
{
task.setSplits(null);
task.setSplitCompleteDuration(null);
}
}
|
java
|
{
"resource": ""
}
|
q858
|
MSPDIReader.updateScheduleSource
|
train
|
private void updateScheduleSource(ProjectProperties properties)
{
// Rudimentary identification of schedule source
if (properties.getCompany() != null && properties.getCompany().equals("Synchro Software Ltd"))
{
properties.setFileApplication("Synchro");
}
else
{
if (properties.getAuthor() != null && properties.getAuthor().equals("SG Project"))
{
properties.setFileApplication("Simple Genius");
}
else
{
properties.setFileApplication("Microsoft");
}
}
properties.setFileType("MSPDI");
}
|
java
|
{
"resource": ""
}
|
q859
|
MSPDIReader.readCalendars
|
train
|
private void readCalendars(Project project, HashMap<BigInteger, ProjectCalendar> map)
{
Project.Calendars calendars = project.getCalendars();
if (calendars != null)
{
LinkedList<Pair<ProjectCalendar, BigInteger>> baseCalendars = new LinkedList<Pair<ProjectCalendar, BigInteger>>();
for (Project.Calendars.Calendar cal : calendars.getCalendar())
{
readCalendar(cal, map, baseCalendars);
}
updateBaseCalendarNames(baseCalendars, map);
}
try
{
ProjectProperties properties = m_projectFile.getProjectProperties();
BigInteger calendarID = new BigInteger(properties.getDefaultCalendarName());
ProjectCalendar calendar = map.get(calendarID);
m_projectFile.setDefaultCalendar(calendar);
}
catch (Exception ex)
{
// Ignore exceptions
}
}
|
java
|
{
"resource": ""
}
|
q860
|
MSPDIReader.updateBaseCalendarNames
|
train
|
private static void updateBaseCalendarNames(List<Pair<ProjectCalendar, BigInteger>> baseCalendars, HashMap<BigInteger, ProjectCalendar> map)
{
for (Pair<ProjectCalendar, BigInteger> pair : baseCalendars)
{
ProjectCalendar cal = pair.getFirst();
BigInteger baseCalendarID = pair.getSecond();
ProjectCalendar baseCal = map.get(baseCalendarID);
if (baseCal != null)
{
cal.setParent(baseCal);
}
}
}
|
java
|
{
"resource": ""
}
|
q861
|
MSPDIReader.readCalendar
|
train
|
private void readCalendar(Project.Calendars.Calendar calendar, HashMap<BigInteger, ProjectCalendar> map, List<Pair<ProjectCalendar, BigInteger>> baseCalendars)
{
ProjectCalendar bc = m_projectFile.addCalendar();
bc.setUniqueID(NumberHelper.getInteger(calendar.getUID()));
bc.setName(calendar.getName());
BigInteger baseCalendarID = calendar.getBaseCalendarUID();
if (baseCalendarID != null)
{
baseCalendars.add(new Pair<ProjectCalendar, BigInteger>(bc, baseCalendarID));
}
readExceptions(calendar, bc);
boolean readExceptionsFromDays = bc.getCalendarExceptions().isEmpty();
Project.Calendars.Calendar.WeekDays days = calendar.getWeekDays();
if (days != null)
{
for (Project.Calendars.Calendar.WeekDays.WeekDay weekDay : days.getWeekDay())
{
readDay(bc, weekDay, readExceptionsFromDays);
}
}
else
{
bc.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
bc.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);
}
readWorkWeeks(calendar, bc);
map.put(calendar.getUID(), bc);
m_eventManager.fireCalendarReadEvent(bc);
}
|
java
|
{
"resource": ""
}
|
q862
|
MSPDIReader.readDay
|
train
|
private void readDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay day, boolean readExceptionsFromDays)
{
BigInteger dayType = day.getDayType();
if (dayType != null)
{
if (dayType.intValue() == 0)
{
if (readExceptionsFromDays)
{
readExceptionDay(calendar, day);
}
}
else
{
readNormalDay(calendar, day);
}
}
}
|
java
|
{
"resource": ""
}
|
q863
|
MSPDIReader.readNormalDay
|
train
|
private void readNormalDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay weekDay)
{
int dayNumber = weekDay.getDayType().intValue();
Day day = Day.getInstance(dayNumber);
calendar.setWorkingDay(day, BooleanHelper.getBoolean(weekDay.isDayWorking()));
ProjectCalendarHours hours = calendar.addCalendarHours(day);
Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes times = weekDay.getWorkingTimes();
if (times != null)
{
for (Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime period : times.getWorkingTime())
{
Date startTime = period.getFromTime();
Date endTime = period.getToTime();
if (startTime != null && endTime != null)
{
if (startTime.getTime() >= endTime.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
hours.addRange(new DateRange(startTime, endTime));
}
}
}
}
|
java
|
{
"resource": ""
}
|
q864
|
MSPDIReader.readExceptionDay
|
train
|
private void readExceptionDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay day)
{
Project.Calendars.Calendar.WeekDays.WeekDay.TimePeriod timePeriod = day.getTimePeriod();
Date fromDate = timePeriod.getFromDate();
Date toDate = timePeriod.getToDate();
Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes times = day.getWorkingTimes();
ProjectCalendarException exception = calendar.addCalendarException(fromDate, toDate);
if (times != null)
{
List<Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime> time = times.getWorkingTime();
for (Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime period : time)
{
Date startTime = period.getFromTime();
Date endTime = period.getToTime();
if (startTime != null && endTime != null)
{
if (startTime.getTime() >= endTime.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
exception.addRange(new DateRange(startTime, endTime));
}
}
}
}
|
java
|
{
"resource": ""
}
|
q865
|
MSPDIReader.readExceptions
|
train
|
private void readExceptions(Project.Calendars.Calendar calendar, ProjectCalendar bc)
{
Project.Calendars.Calendar.Exceptions exceptions = calendar.getExceptions();
if (exceptions != null)
{
for (Project.Calendars.Calendar.Exceptions.Exception exception : exceptions.getException())
{
readException(bc, exception);
}
}
}
|
java
|
{
"resource": ""
}
|
q866
|
MSPDIReader.readException
|
train
|
private void readException(ProjectCalendar bc, Project.Calendars.Calendar.Exceptions.Exception exception)
{
Date fromDate = exception.getTimePeriod().getFromDate();
Date toDate = exception.getTimePeriod().getToDate();
// Vico Schedule Planner seems to write start and end dates to FromTime and ToTime
// rather than FromDate and ToDate. This is plain wrong, and appears to be ignored by MS Project
// so we will ignore it too!
if (fromDate != null && toDate != null)
{
ProjectCalendarException bce = bc.addCalendarException(fromDate, toDate);
bce.setName(exception.getName());
readRecurringData(bce, exception);
Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes times = exception.getWorkingTimes();
if (times != null)
{
List<Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime> time = times.getWorkingTime();
for (Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime period : time)
{
Date startTime = period.getFromTime();
Date endTime = period.getToTime();
if (startTime != null && endTime != null)
{
if (startTime.getTime() >= endTime.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
bce.addRange(new DateRange(startTime, endTime));
}
}
}
}
}
|
java
|
{
"resource": ""
}
|
q867
|
MSPDIReader.readRecurringData
|
train
|
private void readRecurringData(ProjectCalendarException bce, Project.Calendars.Calendar.Exceptions.Exception exception)
{
RecurrenceType rt = getRecurrenceType(NumberHelper.getInt(exception.getType()));
if (rt != null)
{
RecurringData rd = new RecurringData();
rd.setStartDate(bce.getFromDate());
rd.setFinishDate(bce.getToDate());
rd.setRecurrenceType(rt);
rd.setRelative(getRelative(NumberHelper.getInt(exception.getType())));
rd.setOccurrences(NumberHelper.getInteger(exception.getOccurrences()));
switch (rd.getRecurrenceType())
{
case DAILY:
{
rd.setFrequency(getFrequency(exception));
break;
}
case WEEKLY:
{
rd.setWeeklyDaysFromBitmap(NumberHelper.getInteger(exception.getDaysOfWeek()), DAY_MASKS);
rd.setFrequency(getFrequency(exception));
break;
}
case MONTHLY:
{
if (rd.getRelative())
{
rd.setDayOfWeek(Day.getInstance(NumberHelper.getInt(exception.getMonthItem()) - 2));
rd.setDayNumber(Integer.valueOf(NumberHelper.getInt(exception.getMonthPosition()) + 1));
}
else
{
rd.setDayNumber(NumberHelper.getInteger(exception.getMonthDay()));
}
rd.setFrequency(getFrequency(exception));
break;
}
case YEARLY:
{
if (rd.getRelative())
{
rd.setDayOfWeek(Day.getInstance(NumberHelper.getInt(exception.getMonthItem()) - 2));
rd.setDayNumber(Integer.valueOf(NumberHelper.getInt(exception.getMonthPosition()) + 1));
}
else
{
rd.setDayNumber(NumberHelper.getInteger(exception.getMonthDay()));
}
rd.setMonthNumber(Integer.valueOf(NumberHelper.getInt(exception.getMonth()) + 1));
break;
}
}
if (rd.getRecurrenceType() != RecurrenceType.DAILY || rd.getDates().length > 1)
{
bce.setRecurring(rd);
}
}
}
|
java
|
{
"resource": ""
}
|
q868
|
MSPDIReader.getFrequency
|
train
|
private Integer getFrequency(Project.Calendars.Calendar.Exceptions.Exception exception)
{
Integer period = NumberHelper.getInteger(exception.getPeriod());
if (period == null)
{
period = Integer.valueOf(1);
}
return period;
}
|
java
|
{
"resource": ""
}
|
q869
|
MSPDIReader.readWorkWeeks
|
train
|
private void readWorkWeeks(Project.Calendars.Calendar xmlCalendar, ProjectCalendar mpxjCalendar)
{
WorkWeeks ww = xmlCalendar.getWorkWeeks();
if (ww != null)
{
for (WorkWeek xmlWeek : ww.getWorkWeek())
{
ProjectCalendarWeek week = mpxjCalendar.addWorkWeek();
week.setName(xmlWeek.getName());
Date startTime = xmlWeek.getTimePeriod().getFromDate();
Date endTime = xmlWeek.getTimePeriod().getToDate();
week.setDateRange(new DateRange(startTime, endTime));
WeekDays xmlWeekDays = xmlWeek.getWeekDays();
if (xmlWeekDays != null)
{
for (WeekDay xmlWeekDay : xmlWeekDays.getWeekDay())
{
int dayNumber = xmlWeekDay.getDayType().intValue();
Day day = Day.getInstance(dayNumber);
week.setWorkingDay(day, BooleanHelper.getBoolean(xmlWeekDay.isDayWorking()));
ProjectCalendarHours hours = week.addCalendarHours(day);
Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes times = xmlWeekDay.getWorkingTimes();
if (times != null)
{
for (Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes.WorkingTime period : times.getWorkingTime())
{
startTime = period.getFromTime();
endTime = period.getToTime();
if (startTime != null && endTime != null)
{
if (startTime.getTime() >= endTime.getTime())
{
endTime = DateHelper.addDays(endTime, 1);
}
hours.addRange(new DateRange(startTime, endTime));
}
}
}
}
}
}
}
}
|
java
|
{
"resource": ""
}
|
q870
|
MSPDIReader.readProjectExtendedAttributes
|
train
|
private void readProjectExtendedAttributes(Project project)
{
Project.ExtendedAttributes attributes = project.getExtendedAttributes();
if (attributes != null)
{
for (Project.ExtendedAttributes.ExtendedAttribute ea : attributes.getExtendedAttribute())
{
readFieldAlias(ea);
}
}
}
|
java
|
{
"resource": ""
}
|
q871
|
MSPDIReader.readFieldAlias
|
train
|
private void readFieldAlias(Project.ExtendedAttributes.ExtendedAttribute attribute)
{
String alias = attribute.getAlias();
if (alias != null && alias.length() != 0)
{
FieldType field = FieldTypeHelper.getInstance(Integer.parseInt(attribute.getFieldID()));
m_projectFile.getCustomFields().getCustomField(field).setAlias(attribute.getAlias());
}
}
|
java
|
{
"resource": ""
}
|
q872
|
MSPDIReader.readResources
|
train
|
private void readResources(Project project, HashMap<BigInteger, ProjectCalendar> calendarMap)
{
Project.Resources resources = project.getResources();
if (resources != null)
{
for (Project.Resources.Resource resource : resources.getResource())
{
readResource(resource, calendarMap);
}
}
}
|
java
|
{
"resource": ""
}
|
q873
|
MSPDIReader.readResourceBaselines
|
train
|
private void readResourceBaselines(Project.Resources.Resource xmlResource, Resource mpxjResource)
{
for (Project.Resources.Resource.Baseline baseline : xmlResource.getBaseline())
{
int number = NumberHelper.getInt(baseline.getNumber());
Double cost = DatatypeConverter.parseCurrency(baseline.getCost());
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());
if (number == 0)
{
mpxjResource.setBaselineCost(cost);
mpxjResource.setBaselineWork(work);
}
else
{
mpxjResource.setBaselineCost(number, cost);
mpxjResource.setBaselineWork(number, work);
}
}
}
|
java
|
{
"resource": ""
}
|
q874
|
MSPDIReader.readResourceExtendedAttributes
|
train
|
private void readResourceExtendedAttributes(Project.Resources.Resource xml, Resource mpx)
{
for (Project.Resources.Resource.ExtendedAttribute attrib : xml.getExtendedAttribute())
{
int xmlFieldID = Integer.parseInt(attrib.getFieldID()) & 0x0000FFFF;
ResourceField mpxFieldID = MPPResourceField.getInstance(xmlFieldID);
TimeUnit durationFormat = DatatypeConverter.parseDurationTimeUnits(attrib.getDurationFormat(), null);
DatatypeConverter.parseExtendedAttribute(m_projectFile, mpx, attrib.getValue(), mpxFieldID, durationFormat);
}
}
|
java
|
{
"resource": ""
}
|
q875
|
MSPDIReader.readCostRateTables
|
train
|
private void readCostRateTables(Resource resource, Rates rates)
{
if (rates == null)
{
CostRateTable table = new CostRateTable();
table.add(CostRateTableEntry.DEFAULT_ENTRY);
resource.setCostRateTable(0, table);
table = new CostRateTable();
table.add(CostRateTableEntry.DEFAULT_ENTRY);
resource.setCostRateTable(1, table);
table = new CostRateTable();
table.add(CostRateTableEntry.DEFAULT_ENTRY);
resource.setCostRateTable(2, table);
table = new CostRateTable();
table.add(CostRateTableEntry.DEFAULT_ENTRY);
resource.setCostRateTable(3, table);
table = new CostRateTable();
table.add(CostRateTableEntry.DEFAULT_ENTRY);
resource.setCostRateTable(4, table);
}
else
{
Set<CostRateTable> tables = new HashSet<CostRateTable>();
for (net.sf.mpxj.mspdi.schema.Project.Resources.Resource.Rates.Rate rate : rates.getRate())
{
Rate standardRate = DatatypeConverter.parseRate(rate.getStandardRate());
TimeUnit standardRateFormat = DatatypeConverter.parseTimeUnit(rate.getStandardRateFormat());
Rate overtimeRate = DatatypeConverter.parseRate(rate.getOvertimeRate());
TimeUnit overtimeRateFormat = DatatypeConverter.parseTimeUnit(rate.getOvertimeRateFormat());
Double costPerUse = DatatypeConverter.parseCurrency(rate.getCostPerUse());
Date endDate = rate.getRatesTo();
CostRateTableEntry entry = new CostRateTableEntry(standardRate, standardRateFormat, overtimeRate, overtimeRateFormat, costPerUse, endDate);
int tableIndex = rate.getRateTable().intValue();
CostRateTable table = resource.getCostRateTable(tableIndex);
if (table == null)
{
table = new CostRateTable();
resource.setCostRateTable(tableIndex, table);
}
table.add(entry);
tables.add(table);
}
for (CostRateTable table : tables)
{
Collections.sort(table);
}
}
}
|
java
|
{
"resource": ""
}
|
q876
|
MSPDIReader.readAvailabilityTable
|
train
|
private void readAvailabilityTable(Resource resource, AvailabilityPeriods periods)
{
if (periods != null)
{
AvailabilityTable table = resource.getAvailability();
List<AvailabilityPeriod> list = periods.getAvailabilityPeriod();
for (AvailabilityPeriod period : list)
{
Date start = period.getAvailableFrom();
Date end = period.getAvailableTo();
Number units = DatatypeConverter.parseUnits(period.getAvailableUnits());
Availability availability = new Availability(start, end, units);
table.add(availability);
}
Collections.sort(table);
}
}
|
java
|
{
"resource": ""
}
|
q877
|
MSPDIReader.readTasks
|
train
|
private void readTasks(Project project)
{
Project.Tasks tasks = project.getTasks();
if (tasks != null)
{
int tasksWithoutIDCount = 0;
for (Project.Tasks.Task task : tasks.getTask())
{
Task mpxjTask = readTask(task);
if (mpxjTask.getID() == null)
{
++tasksWithoutIDCount;
}
}
for (Project.Tasks.Task task : tasks.getTask())
{
readPredecessors(task);
}
//
// MS Project will happily read tasks from an MSPDI file without IDs,
// it will just generate ID values based on the task order in the file.
// If we find that there are no ID values present, we'll do the same.
//
if (tasksWithoutIDCount == tasks.getTask().size())
{
m_projectFile.getTasks().renumberIDs();
}
}
m_projectFile.updateStructure();
}
|
java
|
{
"resource": ""
}
|
q878
|
MSPDIReader.updateProjectProperties
|
train
|
private void updateProjectProperties(Task task)
{
ProjectProperties props = m_projectFile.getProjectProperties();
props.setComments(task.getNotes());
}
|
java
|
{
"resource": ""
}
|
q879
|
MSPDIReader.readTaskBaselines
|
train
|
private void readTaskBaselines(Project.Tasks.Task xmlTask, Task mpxjTask, TimeUnit durationFormat)
{
for (Project.Tasks.Task.Baseline baseline : xmlTask.getBaseline())
{
int number = NumberHelper.getInt(baseline.getNumber());
Double cost = DatatypeConverter.parseCurrency(baseline.getCost());
Duration duration = DatatypeConverter.parseDuration(m_projectFile, durationFormat, baseline.getDuration());
Date finish = baseline.getFinish();
Date start = baseline.getStart();
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());
if (number == 0)
{
mpxjTask.setBaselineCost(cost);
mpxjTask.setBaselineDuration(duration);
mpxjTask.setBaselineFinish(finish);
mpxjTask.setBaselineStart(start);
mpxjTask.setBaselineWork(work);
}
else
{
mpxjTask.setBaselineCost(number, cost);
mpxjTask.setBaselineDuration(number, duration);
mpxjTask.setBaselineFinish(number, finish);
mpxjTask.setBaselineStart(number, start);
mpxjTask.setBaselineWork(number, work);
}
}
}
|
java
|
{
"resource": ""
}
|
q880
|
MSPDIReader.readTaskExtendedAttributes
|
train
|
private void readTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx)
{
for (Project.Tasks.Task.ExtendedAttribute attrib : xml.getExtendedAttribute())
{
int xmlFieldID = Integer.parseInt(attrib.getFieldID()) & 0x0000FFFF;
TaskField mpxFieldID = MPPTaskField.getInstance(xmlFieldID);
TimeUnit durationFormat = DatatypeConverter.parseDurationTimeUnits(attrib.getDurationFormat(), null);
DatatypeConverter.parseExtendedAttribute(m_projectFile, mpx, attrib.getValue(), mpxFieldID, durationFormat);
}
}
|
java
|
{
"resource": ""
}
|
q881
|
MSPDIReader.getTaskCalendar
|
train
|
private ProjectCalendar getTaskCalendar(Project.Tasks.Task task)
{
ProjectCalendar calendar = null;
BigInteger calendarID = task.getCalendarUID();
if (calendarID != null)
{
calendar = m_projectFile.getCalendarByUniqueID(Integer.valueOf(calendarID.intValue()));
}
return (calendar);
}
|
java
|
{
"resource": ""
}
|
q882
|
MSPDIReader.readPredecessors
|
train
|
private void readPredecessors(Project.Tasks.Task task)
{
Integer uid = task.getUID();
if (uid != null)
{
Task currTask = m_projectFile.getTaskByUniqueID(uid);
if (currTask != null)
{
for (Project.Tasks.Task.PredecessorLink link : task.getPredecessorLink())
{
readPredecessor(currTask, link);
}
}
}
}
|
java
|
{
"resource": ""
}
|
q883
|
MSPDIReader.readPredecessor
|
train
|
private void readPredecessor(Task currTask, Project.Tasks.Task.PredecessorLink link)
{
BigInteger uid = link.getPredecessorUID();
if (uid != null)
{
Task prevTask = m_projectFile.getTaskByUniqueID(Integer.valueOf(uid.intValue()));
if (prevTask != null)
{
RelationType type;
if (link.getType() != null)
{
type = RelationType.getInstance(link.getType().intValue());
}
else
{
type = RelationType.FINISH_START;
}
TimeUnit lagUnits = DatatypeConverter.parseDurationTimeUnits(link.getLagFormat());
Duration lagDuration;
int lag = NumberHelper.getInt(link.getLinkLag());
if (lag == 0)
{
lagDuration = Duration.getInstance(0, lagUnits);
}
else
{
if (lagUnits == TimeUnit.PERCENT || lagUnits == TimeUnit.ELAPSED_PERCENT)
{
lagDuration = Duration.getInstance(lag, lagUnits);
}
else
{
lagDuration = Duration.convertUnits(lag / 10.0, TimeUnit.MINUTES, lagUnits, m_projectFile.getProjectProperties());
}
}
Relation relation = currTask.addPredecessor(prevTask, type, lagDuration);
m_eventManager.fireRelationReadEvent(relation);
}
}
}
|
java
|
{
"resource": ""
}
|
q884
|
MSPDIReader.readAssignments
|
train
|
private void readAssignments(Project project)
{
Project.Assignments assignments = project.getAssignments();
if (assignments != null)
{
SplitTaskFactory splitFactory = new SplitTaskFactory();
TimephasedWorkNormaliser normaliser = new MSPDITimephasedWorkNormaliser();
for (Project.Assignments.Assignment assignment : assignments.getAssignment())
{
readAssignment(assignment, splitFactory, normaliser);
}
}
}
|
java
|
{
"resource": ""
}
|
q885
|
MSPDIReader.readAssignmentBaselines
|
train
|
private void readAssignmentBaselines(Project.Assignments.Assignment assignment, ResourceAssignment mpx)
{
for (Project.Assignments.Assignment.Baseline baseline : assignment.getBaseline())
{
int number = NumberHelper.getInt(baseline.getNumber());
//baseline.getBCWP()
//baseline.getBCWS()
Number cost = DatatypeConverter.parseExtendedAttributeCurrency(baseline.getCost());
Date finish = DatatypeConverter.parseExtendedAttributeDate(baseline.getFinish());
//baseline.getNumber()
Date start = DatatypeConverter.parseExtendedAttributeDate(baseline.getStart());
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());
if (number == 0)
{
mpx.setBaselineCost(cost);
mpx.setBaselineFinish(finish);
mpx.setBaselineStart(start);
mpx.setBaselineWork(work);
}
else
{
mpx.setBaselineCost(number, cost);
mpx.setBaselineWork(number, work);
mpx.setBaselineStart(number, start);
mpx.setBaselineFinish(number, finish);
}
}
}
|
java
|
{
"resource": ""
}
|
q886
|
MSPDIReader.readAssignmentExtendedAttributes
|
train
|
private void readAssignmentExtendedAttributes(Project.Assignments.Assignment xml, ResourceAssignment mpx)
{
for (Project.Assignments.Assignment.ExtendedAttribute attrib : xml.getExtendedAttribute())
{
int xmlFieldID = Integer.parseInt(attrib.getFieldID()) & 0x0000FFFF;
AssignmentField mpxFieldID = MPPAssignmentField.getInstance(xmlFieldID);
TimeUnit durationFormat = DatatypeConverter.parseDurationTimeUnits(attrib.getDurationFormat(), null);
DatatypeConverter.parseExtendedAttribute(m_projectFile, mpx, attrib.getValue(), mpxFieldID, durationFormat);
}
}
|
java
|
{
"resource": ""
}
|
q887
|
MSPDIReader.isSplit
|
train
|
private boolean isSplit(ProjectCalendar calendar, List<TimephasedWork> list)
{
boolean result = false;
for (TimephasedWork assignment : list)
{
if (calendar != null && assignment.getTotalAmount().getDuration() == 0)
{
Duration calendarWork = calendar.getWork(assignment.getStart(), assignment.getFinish(), TimeUnit.MINUTES);
if (calendarWork.getDuration() != 0)
{
result = true;
break;
}
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q888
|
MSPDIReader.readTimephasedAssignment
|
train
|
private LinkedList<TimephasedWork> readTimephasedAssignment(ProjectCalendar calendar, Project.Assignments.Assignment assignment, int type)
{
LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>();
for (TimephasedDataType item : assignment.getTimephasedData())
{
if (NumberHelper.getInt(item.getType()) != type)
{
continue;
}
Date startDate = item.getStart();
Date finishDate = item.getFinish();
// Exclude ranges which don't have a start and end date.
// These seem to be generated by Synchro and have a zero duration.
if (startDate == null && finishDate == null)
{
continue;
}
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.MINUTES, item.getValue());
if (work == null)
{
work = Duration.getInstance(0, TimeUnit.MINUTES);
}
else
{
work = Duration.getInstance(NumberHelper.round(work.getDuration(), 2), TimeUnit.MINUTES);
}
TimephasedWork tra = new TimephasedWork();
tra.setStart(startDate);
tra.setFinish(finishDate);
tra.setTotalAmount(work);
result.add(tra);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q889
|
AstaReader.deriveResourceCalendar
|
train
|
private ProjectCalendar deriveResourceCalendar(Integer parentCalendarID)
{
ProjectCalendar calendar = m_project.addDefaultDerivedCalendar();
calendar.setUniqueID(Integer.valueOf(m_project.getProjectConfig().getNextCalendarUniqueID()));
calendar.setParent(m_project.getCalendarByUniqueID(parentCalendarID));
return calendar;
}
|
java
|
{
"resource": ""
}
|
q890
|
AstaReader.processTasks
|
train
|
public void processTasks(List<Row> bars, List<Row> expandedTasks, List<Row> tasks, List<Row> milestones)
{
List<Row> parentBars = buildRowHierarchy(bars, expandedTasks, tasks, milestones);
createTasks(m_project, "", parentBars);
deriveProjectCalendar();
updateStructure();
}
|
java
|
{
"resource": ""
}
|
q891
|
AstaReader.buildRowHierarchy
|
train
|
private List<Row> buildRowHierarchy(List<Row> bars, List<Row> expandedTasks, List<Row> tasks, List<Row> milestones)
{
//
// Create a list of leaf nodes by merging the task and milestone lists
//
List<Row> leaves = new ArrayList<Row>();
leaves.addAll(tasks);
leaves.addAll(milestones);
//
// Sort the bars and the leaves
//
Collections.sort(bars, BAR_COMPARATOR);
Collections.sort(leaves, LEAF_COMPARATOR);
//
// Map bar IDs to bars
//
Map<Integer, Row> barIdToBarMap = new HashMap<Integer, Row>();
for (Row bar : bars)
{
barIdToBarMap.put(bar.getInteger("BARID"), bar);
}
//
// Merge expanded task attributes with parent bars
// and create an expanded task ID to bar map.
//
Map<Integer, Row> expandedTaskIdToBarMap = new HashMap<Integer, Row>();
for (Row expandedTask : expandedTasks)
{
Row bar = barIdToBarMap.get(expandedTask.getInteger("BAR"));
bar.merge(expandedTask, "_");
Integer expandedTaskID = bar.getInteger("_EXPANDED_TASKID");
expandedTaskIdToBarMap.put(expandedTaskID, bar);
}
//
// Build the hierarchy
//
List<Row> parentBars = new ArrayList<Row>();
for (Row bar : bars)
{
Integer expandedTaskID = bar.getInteger("EXPANDED_TASK");
Row parentBar = expandedTaskIdToBarMap.get(expandedTaskID);
if (parentBar == null)
{
parentBars.add(bar);
}
else
{
parentBar.addChild(bar);
}
}
//
// Attach the leaves
//
for (Row leaf : leaves)
{
Integer barID = leaf.getInteger("BAR");
Row bar = barIdToBarMap.get(barID);
bar.addChild(leaf);
}
//
// Prune any "displaced items" from the top level.
// We're using a heuristic here as this is the only thing I
// can see which differs between bars that we want to include
// and bars that we want to exclude.
//
Iterator<Row> iter = parentBars.iterator();
while (iter.hasNext())
{
Row bar = iter.next();
String barName = bar.getString("NAMH");
if (barName == null || barName.isEmpty() || barName.equals("Displaced Items"))
{
iter.remove();
}
}
//
// If we only have a single top level node (effectively a summary task) prune that too.
//
if (parentBars.size() == 1)
{
parentBars = parentBars.get(0).getChildRows();
}
return parentBars;
}
|
java
|
{
"resource": ""
}
|
q892
|
AstaReader.createTasks
|
train
|
private void createTasks(ChildTaskContainer parent, String parentName, List<Row> rows)
{
for (Row row : rows)
{
boolean rowIsBar = (row.getInteger("BARID") != null);
//
// Don't export hammock tasks.
//
if (rowIsBar && row.getChildRows().isEmpty())
{
continue;
}
Task task = parent.addTask();
//
// Do we have a bar, task, or milestone?
//
if (rowIsBar)
{
//
// If the bar only has one child task, we skip it and add the task directly
//
if (skipBar(row))
{
populateLeaf(row.getString("NAMH"), row.getChildRows().get(0), task);
}
else
{
populateBar(row, task);
createTasks(task, task.getName(), row.getChildRows());
}
}
else
{
populateLeaf(parentName, row, task);
}
m_eventManager.fireTaskReadEvent(task);
}
}
|
java
|
{
"resource": ""
}
|
q893
|
AstaReader.skipBar
|
train
|
private boolean skipBar(Row row)
{
List<Row> childRows = row.getChildRows();
return childRows.size() == 1 && childRows.get(0).getChildRows().isEmpty();
}
|
java
|
{
"resource": ""
}
|
q894
|
AstaReader.populateLeaf
|
train
|
private void populateLeaf(String parentName, Row row, Task task)
{
if (row.getInteger("TASKID") != null)
{
populateTask(row, task);
}
else
{
populateMilestone(row, task);
}
String name = task.getName();
if (name == null || name.isEmpty())
{
task.setName(parentName);
}
}
|
java
|
{
"resource": ""
}
|
q895
|
AstaReader.populateTask
|
train
|
private void populateTask(Row row, Task task)
{
//"PROJID"
task.setUniqueID(row.getInteger("TASKID"));
//GIVEN_DURATIONTYPF
//GIVEN_DURATIONELA_MONTHS
task.setDuration(row.getDuration("GIVEN_DURATIONHOURS"));
task.setResume(row.getDate("RESUME"));
//task.setStart(row.getDate("GIVEN_START"));
//LATEST_PROGRESS_PERIOD
//TASK_WORK_RATE_TIME_UNIT
//TASK_WORK_RATE
//PLACEMENT
//BEEN_SPLIT
//INTERRUPTIBLE
//HOLDING_PIN
///ACTUAL_DURATIONTYPF
//ACTUAL_DURATIONELA_MONTHS
task.setActualDuration(row.getDuration("ACTUAL_DURATIONHOURS"));
task.setEarlyStart(row.getDate("EARLY_START_DATE"));
task.setLateStart(row.getDate("LATE_START_DATE"));
//FREE_START_DATE
//START_CONSTRAINT_DATE
//END_CONSTRAINT_DATE
//task.setBaselineWork(row.getDuration("EFFORT_BUDGET"));
//NATURAO_ORDER
//LOGICAL_PRECEDENCE
//SPAVE_INTEGER
//SWIM_LANE
//USER_PERCENT_COMPLETE
task.setPercentageComplete(row.getDouble("OVERALL_PERCENV_COMPLETE"));
//OVERALL_PERCENT_COMPL_WEIGHT
task.setName(row.getString("NARE"));
task.setNotes(getNotes(row));
task.setText(1, row.getString("UNIQUE_TASK_ID"));
task.setCalendar(m_project.getCalendarByUniqueID(row.getInteger("CALENDAU")));
//EFFORT_TIMI_UNIT
//WORL_UNIT
//LATEST_ALLOC_PROGRESS_PERIOD
//WORN
//BAR
//CONSTRAINU
//PRIORITB
//CRITICAM
//USE_PARENU_CALENDAR
//BUFFER_TASK
//MARK_FOS_HIDING
//OWNED_BY_TIMESHEEV_X
//START_ON_NEX_DAY
//LONGEST_PATH
//DURATIOTTYPF
//DURATIOTELA_MONTHS
//DURATIOTHOURS
task.setStart(row.getDate("STARZ"));
task.setFinish(row.getDate("ENJ"));
//DURATION_TIMJ_UNIT
//UNSCHEDULABLG
//SUBPROJECT_ID
//ALT_ID
//LAST_EDITED_DATE
//LAST_EDITED_BY
processConstraints(row, task);
if (NumberHelper.getInt(task.getPercentageComplete()) != 0)
{
task.setActualStart(task.getStart());
if (task.getPercentageComplete().intValue() == 100)
{
task.setActualFinish(task.getFinish());
task.setDuration(task.getActualDuration());
}
}
}
|
java
|
{
"resource": ""
}
|
q896
|
AstaReader.populateBar
|
train
|
private void populateBar(Row row, Task task)
{
Integer calendarID = row.getInteger("CALENDAU");
ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);
//PROJID
task.setUniqueID(row.getInteger("BARID"));
task.setStart(row.getDate("STARV"));
task.setFinish(row.getDate("ENF"));
//NATURAL_ORDER
//SPARI_INTEGER
task.setName(row.getString("NAMH"));
//EXPANDED_TASK
//PRIORITY
//UNSCHEDULABLE
//MARK_FOR_HIDING
//TASKS_MAY_OVERLAP
//SUBPROJECT_ID
//ALT_ID
//LAST_EDITED_DATE
//LAST_EDITED_BY
//Proc_Approve
//Proc_Design_info
//Proc_Proc_Dur
//Proc_Procurement
//Proc_SC_design
//Proc_Select_SC
//Proc_Tender
//QA Checked
//Related_Documents
task.setCalendar(calendar);
}
|
java
|
{
"resource": ""
}
|
q897
|
AstaReader.populateMilestone
|
train
|
private void populateMilestone(Row row, Task task)
{
task.setMilestone(true);
//PROJID
task.setUniqueID(row.getInteger("MILESTONEID"));
task.setStart(row.getDate("GIVEN_DATE_TIME"));
task.setFinish(row.getDate("GIVEN_DATE_TIME"));
//PROGREST_PERIOD
//SYMBOL_APPEARANCE
//MILESTONE_TYPE
//PLACEMENU
task.setPercentageComplete(row.getBoolean("COMPLETED") ? COMPLETE : INCOMPLETE);
//INTERRUPTIBLE_X
//ACTUAL_DURATIONTYPF
//ACTUAL_DURATIONELA_MONTHS
//ACTUAL_DURATIONHOURS
task.setEarlyStart(row.getDate("EARLY_START_DATE"));
task.setLateStart(row.getDate("LATE_START_DATE"));
//FREE_START_DATE
//START_CONSTRAINT_DATE
//END_CONSTRAINT_DATE
//EFFORT_BUDGET
//NATURAO_ORDER
//LOGICAL_PRECEDENCE
//SPAVE_INTEGER
//SWIM_LANE
//USER_PERCENT_COMPLETE
//OVERALL_PERCENV_COMPLETE
//OVERALL_PERCENT_COMPL_WEIGHT
task.setName(row.getString("NARE"));
//NOTET
task.setText(1, row.getString("UNIQUE_TASK_ID"));
task.setCalendar(m_project.getCalendarByUniqueID(row.getInteger("CALENDAU")));
//EFFORT_TIMI_UNIT
//WORL_UNIT
//LATEST_ALLOC_PROGRESS_PERIOD
//WORN
//CONSTRAINU
//PRIORITB
//CRITICAM
//USE_PARENU_CALENDAR
//BUFFER_TASK
//MARK_FOS_HIDING
//OWNED_BY_TIMESHEEV_X
//START_ON_NEX_DAY
//LONGEST_PATH
//DURATIOTTYPF
//DURATIOTELA_MONTHS
//DURATIOTHOURS
//STARZ
//ENJ
//DURATION_TIMJ_UNIT
//UNSCHEDULABLG
//SUBPROJECT_ID
//ALT_ID
//LAST_EDITED_DATE
//LAST_EDITED_BY
task.setDuration(Duration.getInstance(0, TimeUnit.HOURS));
}
|
java
|
{
"resource": ""
}
|
q898
|
AstaReader.getInitials
|
train
|
private String getInitials(String name)
{
String result = null;
if (name != null && name.length() != 0)
{
StringBuilder sb = new StringBuilder();
sb.append(name.charAt(0));
int index = 1;
while (true)
{
index = name.indexOf(' ', index);
if (index == -1)
{
break;
}
++index;
if (index < name.length() && name.charAt(index) != ' ')
{
sb.append(name.charAt(index));
}
++index;
}
result = sb.toString();
}
return result;
}
|
java
|
{
"resource": ""
}
|
q899
|
AstaReader.deriveProjectCalendar
|
train
|
private void deriveProjectCalendar()
{
//
// Count the number of times each calendar is used
//
Map<ProjectCalendar, Integer> map = new HashMap<ProjectCalendar, Integer>();
for (Task task : m_project.getTasks())
{
ProjectCalendar calendar = task.getCalendar();
Integer count = map.get(calendar);
if (count == null)
{
count = Integer.valueOf(1);
}
else
{
count = Integer.valueOf(count.intValue() + 1);
}
map.put(calendar, count);
}
//
// Find the most frequently used calendar
//
int maxCount = 0;
ProjectCalendar defaultCalendar = null;
for (Entry<ProjectCalendar, Integer> entry : map.entrySet())
{
if (entry.getValue().intValue() > maxCount)
{
maxCount = entry.getValue().intValue();
defaultCalendar = entry.getKey();
}
}
//
// Set the default calendar for the project
// and remove it's use as a task-specific calendar.
//
if (defaultCalendar != null)
{
m_project.setDefaultCalendar(defaultCalendar);
for (Task task : m_project.getTasks())
{
if (task.getCalendar() == defaultCalendar)
{
task.setCalendar(null);
}
}
}
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.