for (Row row : rows)
{
//
// Retrieve the core resource data
//
Resource resource = m_project.addResource();
resource.setUniqueID(row.getInteger("rsrc_id"));
resource.setName(row.getString("rsrc_name"));
resource.setCode(row.getString("employee_code"));
resource.setEmailAddress(row.getString("email_addr"));
resource.setNotes(row.getString("rsrc_notes"));
resource.setCreationDate(row.getDate("create_date"));
resource.setType(RESOURCE_TYPE_MAP.get(row.getString("rsrc_type")));
resource.setInitials(row.getString("rsrc_short_name"));
//resource.setMaxUnits(maxUnits); // RSRCRATE.max_qty_per_hr?
//resource.setStandardRate(val); // RSRCRATE.cost_per_qty?
//resource.setOvertimeRate(overtimeRate); // RSRCRATE.cost_per_qty * RSRC.ot_factor?
//resource.setGroup(val); parent resource name?
resource.setNumber1(row.getInteger("parent_rsrc_id"));
//
// Attempt to locate a calendar for this resource
//
Integer calendarID = row.getInteger("clndr_id");
if (calendarID != null)
{
ProjectCalendar calendar = m_calMap.get(calendarID);
if (calendar != null)
{
//
// If the resource is linked to a base calendar, derive
// a default calendar from the base calendar.
//
if (!calendar.isDerived())
{
ProjectCalendar resourceCalendar = m_project.addResourceCalendar();
resourceCalendar.setParent(calendar);
resourceCalendar.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);
resourceCalendar.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
resource.setResourceCalendar(resourceCalendar);
}
else
{
//
// Primavera seems to allow a calendar to be shared between resources
// whereas in the MS Project model there is a one-to-one
// relationship. If we find a shared calendar, take a copy of it
//
if (calendar.getResource() == null)
{
resource.setResourceCalendar(calendar);
}
else
{
ProjectCalendar copy = m_project.addResourceCalendar();
copy.copy(calendar);
resource.setResourceCalendar(copy);
}
}
}
}