DirectoryService dirService =
(DirectoryService) DirectoryLocator.getDirectory(DirectoryService.class, false);
DirectoryServicesGroupItem parent = null;
DirectoryServicesGroupItem group = null;
DirectoryServiceItem service = null;
String line = input.readLine();
while (line != null) {
if (!line.trim().isEmpty()) {
int pos = line.indexOf('|');
if (pos > -1) {
String code = line.substring(0, pos);
String title = line.substring(pos + 1);
if (code.length() == 2) {
ServiceGroupDetails parDetails = new ServiceGroupDetails();
parDetails.code = code;
parDetails.parentItem = 0;
parDetails.title = title;
parent = new DirectoryServicesGroupItem(parDetails);
dirGroup.getItems().append(parent);
System.out.println(code + " " + title);
}
else if (code.length() == 6) {
code = code.substring(3, 6);
ServiceGroupDetails grDetails = new ServiceGroupDetails();
grDetails.code = code;
grDetails.parentItem = parent.getID();
grDetails.title = title;
group = new DirectoryServicesGroupItem(grDetails);
dirGroup.getItems().append(group);
System.out.println(" " +code + " " + title);
}
else if (code.length() == 9) {
code = code.substring(7);
ServiceDetails servDetails = new ServiceDetails();
servDetails.checkupType = 0;
servDetails.code = code;
servDetails.defaultDuration = 0;
servDetails.description = "";
servDetails.serviceClass = 1;
servDetails.serviceGroup = group.getID();
servDetails.title = title;
service = new DirectoryServiceItem(servDetails);
dirService.getItems().append(service);
System.out.println(" " +code + " " + title);
}
}