logger.log(BasicLevel.DEBUG,
"Create a new department id :" + d.getDeptid());
int nbEmployees = Alea.rand(MIN_EMPLOYEE_PER_DEPARTMENT, MAX_EMPLOYEE_PER_DEPARTMENT);
outStr.append("\n\tAdd new Department : ").append(d.getDeptid());
outStr.append(" with ").append(nbEmployees).append(" employees");
Employee boss = null;
for (int i = 0; i < nbEmployees; i++) {
Calendar cal = Calendar.getInstance();
cal.set(Alea.rand(1900, 2004), Alea.rand(1, 12), Alea.rand(1, 28));
Employee e = new Employee(
"First-" + Alea.randomstring(4, 5),
"Last-" + Alea.randomstring(8, 10),
cal.getTime(),
d);
e.setSalary(Alea.rand(5000, 45000));
Address a = new Address();
a.setCity("City-" + Alea.randomstring(4, 5));
a.setStreet("Street-" + Alea.randomstring(4, 5));
a.setState("StateItf-" + Alea.randomstring(4, 5));
a.setZipcode("ZIP-" + Alea.randomstring(2, 3));
e.setAddress(a);
pm.makePersistent(e);
if (0 == i) {
boss = e;
outStr.append("\nThe boss: ");
} else {
e.setManager(boss);
}
outStr.append(e.getAsString());
pollsSync.addInPool(DatabaseImpl.poolOfEmployeeId, e.getEmpid());
}
pm.setUserObject(pollsSync);
}