// Read WBS entries and create tasks
//
for (Row row : wbs)
{
Task task = m_project.addTask();
Integer uniqueID = row.getInteger("wbs_id");
uniqueIDs.add(uniqueID);
task.setUniqueID(uniqueID);
task.setName(row.getString("wbs_name"));
task.setBaselineCost(row.getDouble("orig_cost"));
task.setRemainingCost(row.getDouble("indep_remain_total_cost"));
task.setRemainingWork(row.getDuration("indep_remain_work_qty"));
task.setStart(row.getDate("anticip_start_date"));
task.setFinish(row.getDate("anticip_end_date"));
task.setDate1(row.getDate("suspend_date"));
task.setDate2(row.getDate("resume_date"));
task.setText1(row.getString("task_code"));
task.setWBS(row.getString("wbs_short_name"));
//task.setNotes(getNotes(wbsmemos, "wbs_id", uniqueID.intValue(), "wbs_memo"));
//
// When reading from the database it appears that we could join
// the PROJWBS table to the TASKSUM table to retrieve the
// additional summarise values noted below. Before adding this
// functionality it would be helpful to understand from a real
// Primavera user if this is a valid thing to do?
//
//task.setActualDuration(val); // act_drtn_hr_cnt
//task.setActualWork(val); // act_work_qty
//task.setDuration(val); // total_drtn_hr_cnt
//task.setBaselineDuration(val); // base_drtn_hr_cnt
//task.setBaselineWork(val); // base_work_qty
//task.setRemainingDuration(val); // remain_drtn_hr_cnt
//task.setRemainingWork(val); // remain_work_qty
//task.setTotalSlack(val); // total_float_hr_cnt
//task.setBCWP(val); // bcwp
//task.setBCWS(val); // bcws
//task.setActualCost(val); // act_expense_cost+act_work_cost+ act_equip_cost+act_mat_cost
//task.setBaselineCost(val); // base_expense_cost+base_work_cost+base_equip_cost+base_mat_cost
//task.setRemainingCost(val); // remain_expense_cost+remain_work_cost+remain_equip_cost+remain_mat_cost
}
//
// Create hierarchical structure
//
m_project.getChildTasks().clear();
for (Row row : wbs)
{
Task task = m_project.getTaskByUniqueID(row.getInteger("wbs_id"));
Task parentTask = m_project.getTaskByUniqueID(row.getInteger("parent_wbs_id"));
if (parentTask == null)
{
m_project.getChildTasks().add(task);
}
else
{
m_project.getChildTasks().remove(task);
parentTask.getChildTasks().add(task);
task.setWBS(parentTask.getWBS() + "." + task.getWBS());
}
}
//
// Read Task entries and create tasks
//
int nextID = 1;
m_clashMap.clear();
for (Row row : tasks)
{
Integer uniqueID = row.getInteger("task_id");
if (uniqueIDs.contains(uniqueID))
{
while (uniqueIDs.contains(Integer.valueOf(nextID)))
{
++nextID;
}
Integer newUniqueID = Integer.valueOf(nextID);
m_clashMap.put(uniqueID, newUniqueID);
uniqueID = newUniqueID;
}
uniqueIDs.add(uniqueID);
Task task;
Integer parentTaskID = row.getInteger("wbs_id");
Task parentTask = m_project.getTaskByUniqueID(parentTaskID);
if (parentTask == null)
{
task = m_project.addTask();
}
else
{
task = parentTask.addTask();
}
task.setUniqueID(uniqueID);
task.setPercentageComplete(row.getDouble("phys_complete_pct"));
task.setName(row.getString("task_name"));