int discountCardID = discountCard == null ? 0 : discountCard.getID();
int packetServiceID = packetService == null ? 0 : packetService.getID();
ArrayList<ServiceContractPriceData> dataList = new ArrayList<ServiceContractPriceData>();
DirectoryEnterprise directoryEnterprise = DirectoryLocator.getDirectory(DirectoryEnterprise.class, false);
DirectoryService directoryService = DirectoryLocator.getDirectory(DirectoryService.class, false);
List<ServiceContractPriceChunk> chunkList;
try {
chunkList = createServiceBean.get().getServiceContractPriceInfo(getID(), services, discountCardID, packetServiceID);
} catch (Exception ex) {
try {
createServiceBean.clear();
chunkList = createServiceBean.get().getServiceContractPriceInfo(getID(), services, discountCardID, packetServiceID);
} catch (ClipsServerException ex1) {
throw new ClipsException("Не удалось загрузить цены по договору", ex1);
}
}
// преобразование чанка пришедшего с сервера в данные
//Log.printlnAnsPos("Получен ArrayList<ServiceContractPriceChunk>");
for (int i = 0; i < chunkList.size(); i++) {
ServiceContractPriceChunk chunk = chunkList.get(i);
String index = chunk.index;
String type = chunk.contractType;
String enterprise = directoryEnterprise.getItemFromID(chunk.enterpriseID).getTitle();
PolisDetails polisID = chunk.polisDetails;
HashMap<DirectoryServiceItem, Integer> priceMap = new HashMap<DirectoryServiceItem, Integer>();
HashMap<DirectoryServiceItem, Integer> moneyMap = new HashMap<DirectoryServiceItem, Integer>();
HashMap<DirectoryServiceItem, Integer> discountMap = new HashMap<DirectoryServiceItem, Integer>();
Iterator<Integer> it;
it = chunk.priceMap.keySet().iterator();
while (it.hasNext()) {
Integer serviseID = it.next();
DirectoryServiceItem service = directoryService.getItemFromID(serviseID);
priceMap.put(service, chunk.priceMap.get(serviseID));
moneyMap.put(service, chunk.moneyMap.get(serviseID));
discountMap.put(service, chunk.discountMap.get(serviseID));
}
ServiceContractPriceData scpd = new ServiceContractPriceData(index, type, enterprise, polisID, priceMap, moneyMap, discountMap);