DirectoryService ds = DirectoryLocator.getDirectory(DirectoryService.class, false);
DirectoryReceptionType recTypeDir = DirectoryLocator.getDirectory(DirectoryReceptionType.class);
Selector<DirectoryServiceItem> it = ds.getFilteredItems(group);
Set<Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>> keySet = serviceRecTypeList.getKeySet();
for (int i = 0; i < it.size(); i++) {
DirectoryServiceItem service = it.get(i);
if (status == SEL_STATUS_ALL) {
//МОЖЕТ услуга уже есть
int founded = 0;
for (Pair<DirectoryServiceItem, DirectoryReceptionTypeItem> pair : keySet) {
if (pair.first.getID() == service.getID()) {
founded ++;
}
}
if (founded == 0) {
Pair<DirectoryServiceItem, DirectoryReceptionTypeItem> pair = new Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>();
pair.first = service;
pair.second = recTypeDir.getItemFromID(0);
ServisePriceData spd = new ServisePriceData(pair);
getContractServiceList().append(spd);
}
} else if (status == SEL_STATUS_NOTHING) {
ArrayList<Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>> forDelete = new ArrayList<Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>>();
for (Iterator<Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>> it1 = keySet.iterator(); it1.hasNext();) {
Pair<DirectoryServiceItem, DirectoryReceptionTypeItem> pair = it1.next();
if (pair.first.getID() == service.getID()) {
forDelete.add(pair);
}
}
for (Pair<DirectoryServiceItem, DirectoryReceptionTypeItem> pair : forDelete) {
removeService(pair);