Пример #1
0
 private void calcQuoteSummaryFromList(List<FclQuotationSummaryModel> list) throws ParseException {
   for (FclQuotationSummaryModel model : list) {
     this.buy += model.buy;
     this.sell += model.sell;
     this.margin += model.margin;
     this.noOfTEUs += model.noOfTEUs;
     this.totalNoOfContainers += model.totalNoOfContainers;
     this.totalTurnAroundTime += model.getTurnAroundTime();
   }
 }
Пример #2
0
 private static Collection<List<FclQuotationSummaryModel>> getCategorizedList(
     List<FclQuotationSummaryModel> summaryModels, String sortItem, boolean isPrimary) {
   Map<String, List<FclQuotationSummaryModel>> map =
       new HashMap<String, List<FclQuotationSummaryModel>>();
   String keyString;
   if (CommonUtil.isNotEmpty(sortItem)) {
     List<FclQuotationSummaryModel> valList;
     for (FclQuotationSummaryModel model : summaryModels) {
       keyString = isPrimary ? model.getPrimaryColumnValue() : model.getSecondaryColumnValue();
       valList = map.get(keyString);
       if (valList != null) {
         valList.add(model);
       } else {
         valList = new ArrayList<FclQuotationSummaryModel>();
         valList.add(model);
         map.put(keyString, valList);
       }
     }
   }
   return new TreeMap<String, List<FclQuotationSummaryModel>>(map).values();
 }
Пример #3
0
 public static FclQuotationSummaryModel getGroupedFinalModel(
     List<FclQuotationSummaryModel> globalModels, String primarySortItem, String secondarySortItem)
     throws ParseException {
   List<FclQuotationSummaryModel> priGrpList = new ArrayList<FclQuotationSummaryModel>();
   FclQuotationSummaryModel finalModel = new FclQuotationSummaryModel();
   // Primary sort item
   if (CommonUtil.isNotEmpty(primarySortItem)) {
     Collection<List<FclQuotationSummaryModel>> listOfPriGrpLists =
         getCategorizedList(globalModels, primarySortItem, true);
     // Primary grouping
     for (List<FclQuotationSummaryModel> priGrpModel : listOfPriGrpLists) {
       FclQuotationSummaryModel priFinalModel = new FclQuotationSummaryModel();
       // Secondary sort item
       if (CommonUtil.isNotEmpty(secondarySortItem)) {
         List<FclQuotationSummaryModel> secGrpList = new ArrayList<FclQuotationSummaryModel>();
         Collection<List<FclQuotationSummaryModel>> listOfSecGrpLists =
             getCategorizedList(priGrpModel, secondarySortItem, false);
         // Secondary grouping
         for (List<FclQuotationSummaryModel> secGrpModels : listOfSecGrpLists) {
           FclQuotationSummaryModel secFinalModel = new FclQuotationSummaryModel();
           secFinalModel.calcQuoteSummaryFromList(secGrpModels);
           secFinalModel.setBasicQuoteModelList(secGrpModels);
           secGrpList.add(secFinalModel);
         }
         priFinalModel.calcQuoteSummaryFromList(secGrpList);
         priFinalModel.setGroupedQuoteModelList(secGrpList);
       } else {
         priFinalModel.calcQuoteSummaryFromList(priGrpModel);
         priFinalModel.setBasicQuoteModelList(priGrpModel);
       }
       priGrpList.add(priFinalModel);
     }
     finalModel.calcQuoteSummaryFromList(priGrpList);
     finalModel.setGroupedQuoteModelList(priGrpList);
   } else {
     finalModel.calcQuoteSummaryFromList(globalModels);
     finalModel.setBasicQuoteModelList(globalModels);
   }
   return finalModel;
 }