List of usage examples for org.apache.commons.lang StringEscapeUtils StringEscapeUtils
StringEscapeUtils
From source file:org.emmanet.controllers.requestsUpdateInterfaceFormController.java
public String escapeXml(String strToEscape) { StringEscapeUtils seu = new StringEscapeUtils(); return seu.escapeXml(strToEscape); }
From source file:org.emmanet.controllers.rssNewsController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { // return new ModelAndView(getSuccessView()); // }//from w w w . j a v a 2 s . c om /* protected ModelAndView onSubmit( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, Exception {*/ StringEscapeUtils esc = new StringEscapeUtils(); setTitle(esc.escapeXml(request.getParameter("title"))); setLink(esc.escapeXml(request.getParameter("link"))); setDescription(esc.escapeXml(request.getParameter("description"))); //create timestamp formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Date date = new Date(); publishDate = formatter.format(date); String item = ""; item = (new StringBuilder()).append("<item>" + NEW_LINE).append("<title>").append(title) .append("</title>" + NEW_LINE).append("<link>").append(link).append("</link>" + NEW_LINE) .append("<description>").append(description).append("</description>" + NEW_LINE).append("<pubDate>") .append(publishDate).append("</pubDate>" + NEW_LINE).append("</item>" + NEW_LINE).toString(); try { BufferedWriter out = new BufferedWriter(new FileWriter(getFileLocation() + getFileName(), true)); out.write(item); out.close(); } catch (IOException e) { e.printStackTrace(); } return new ModelAndView(getSuccessView()); }
From source file:org.infoglue.calendar.taglib.TextFieldTag.java
public int doEndTag() throws JspException { String errorName = name;//from w w w.j av a 2 s. co m if (errorName.indexOf("attribute_") > -1) errorName = errorName.substring(errorName.indexOf("attribute_") + 10); fieldErrors = (List) findOnValueStack("#fieldErrors." + errorName); Map fieldErrorsList = (Map) findOnValueStack("#fieldErrors"); errorAction = findOnValueStack("#errorAction"); if (errorAction != null) { Object o = findOnValueStack("#errorAction." + errorName); if (o != null) value = o.toString(); } //log.debug("name:" + name); //log.debug("errorName:" + errorName); //log.debug("fieldErrorsList:" + fieldErrorsList); //log.debug("fieldErrors: " + fieldErrors); //log.debug("value: " + value); String errorMessage = ""; if (fieldErrors != null && fieldErrors.size() > 0) { Iterator i = fieldErrors.iterator(); while (i.hasNext()) { String fieldError = (String) i.next(); //log.debug("fieldError: " + fieldError); String translatedError = this.getLabel(fieldError); if (translatedError != null && translatedError.length() > 0) fieldError = translatedError; errorMessage = "<span class=\"errorMessage\">" + fieldError + "</span>"; } } StringBuffer sb = new StringBuffer(); if (!skipRowDiv) sb.append(this.rowDivHTMLStart); if (this.label != null) { sb.append("<label for=\"" + name + "\">" + this.label + "</label>" + (getMandatory() ? "<span class=\"" + requiredLabelClass + "\">" + requiredText + "</span>" : "") + " " + errorMessage + "<br/>\n"); sb.append("<input type=\"textfield\" id=\"" + name + "\" name=\"" + name + "\" value=\"" + ((value == null) ? "" : new StringEscapeUtils().escapeHtml(value)) + "\" class=\"" + cssClass + "\"><br/>\n"); } else { sb.append("<label for=\"" + name + "\">" + this.name + "</label>" + (getMandatory() ? "<span class=\"" + requiredLabelClass + "\">requiredText</span>" : "") + " " + errorMessage + "<br/>\n"); sb.append("<input type=\"textfield\" id=\"" + name + "\" name=\"" + name + "\" value=\"" + ((value == null) ? "" : new StringEscapeUtils().escapeHtml(value)) + "\" class=\"" + cssClass + "\"><br/>\n"); } if (!skipRowDiv) sb.append(this.rowDivHTMLEnd); write(sb.toString()); this.name = null; this.rowDivHTMLStart = "<div class=\"fieldrow\">"; this.rowDivHTMLEnd = "</div>"; this.skipRowDiv = false; this.requiredLabelClass = "redstar"; this.requiredText = "*"; return EVAL_PAGE; }
From source file:org.kuali.ole.module.purap.document.service.impl.OlePurapServiceImpl.java
/** * This method is used to get the item description for the given Bib * @param bib// www . j a va 2 s . co m */ public String getItemDescription(Bib bib) { LOG.debug("### Inside setItemDescription() of OleRequisitionDocument ###"); String itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty()) ? bib.getTitle() + "," : "") + ((bib.getAuthor() != null && !bib.getAuthor().isEmpty()) ? bib.getAuthor() + "," : "") + ((bib.getPublisher() != null && !bib.getPublisher().isEmpty()) ? bib.getPublisher() + "," : "") + ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn() + "," : ""); itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); if (LOG.isDebugEnabled()) { LOG.debug("Item Description---------->" + itemDescription); } StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeHtml(itemDescription); return itemDescription; }
From source file:org.kuali.ole.module.purap.document.service.impl.OlePurapServiceImpl.java
public String getItemDescription(OlePurchaseOrderItem olePurchaseOrderItem) { BibInfoRecord bibInfoRecord = olePurchaseOrderItem.getBibInfoRecord(); String itemDescription = null; if (bibInfoRecord != null) { olePurchaseOrderItem.setBibUUID(bibInfoRecord.getBibIdStr()); olePurchaseOrderItem// w w w. j av a 2 s .co m .setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(olePurchaseOrderItem.getItemTitleId())); itemDescription = ((bibInfoRecord.getTitle() != null && !bibInfoRecord.getTitle().isEmpty()) ? bibInfoRecord.getTitle().trim() + ", " : "") + ((bibInfoRecord.getAuthor() != null && !bibInfoRecord.getAuthor().isEmpty()) ? bibInfoRecord.getAuthor().trim() + ", " : "") + ((bibInfoRecord.getPublisher() != null && !bibInfoRecord.getPublisher().isEmpty()) ? bibInfoRecord.getPublisher().trim() + ", " : "") + ((bibInfoRecord.getIsxn() != null && !bibInfoRecord.getIsxn().isEmpty()) ? bibInfoRecord.getIsxn().trim() + ", " : ""); } if (itemDescription != null && !(itemDescription.equals(""))) { itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); } return itemDescription; }
From source file:org.kuali.ole.select.document.OleCorrectionReceivingDocument.java
/** * This method is overridden to set special processing notes and other types of receipt notes * in two different lists to be displayed under Special Processing Notes Tab and Receipt Notes tab respectively. */// w w w.ja v a 2 s.c o m @Override public void processAfterRetrieve() { try { LOG.debug("Inside processAfterRetrieve of OleCorrectionReceivingDocument"); super.processAfterRetrieve(); BibInfoWrapperService docStore = SpringContext.getBean(BibInfoWrapperServiceImpl.class); FileProcessingService fileProcessingService = SpringContext.getBean(FileProcessingService.class); String itemDescription = ""; List<OleCorrectionReceivingItem> items = new ArrayList<OleCorrectionReceivingItem>(); items = this.getItems(); Iterator<OleCorrectionReceivingItem> iterator = items.iterator(); String titleId = null; int itemCount = 0; boolean isBibFileExist = false; boolean isBibEdit = false; List<OleCorrectionReceivingItemReceiptNotes> receiptNoteList; List<OleCorrectionReceivingItemReceiptNotes> specialHandlingNoteList; for (OleCorrectionReceivingItem item : items) { receiptNoteList = new ArrayList<OleCorrectionReceivingItemReceiptNotes>(); specialHandlingNoteList = new ArrayList<OleCorrectionReceivingItemReceiptNotes>(); List<OleCorrectionReceivingItemReceiptNotes> notes = new ArrayList<OleCorrectionReceivingItemReceiptNotes>(); notes = item.getCorrectionNoteList(); for (OleCorrectionReceivingItemReceiptNotes note : notes) { String noteType = note.getNoteType().getNoteType(); if (noteType.equalsIgnoreCase(OLEConstants.SPECIAL_PROCESSING_INSTRUCTION_NOTE)) { specialHandlingNoteList.add(note); } else { receiptNoteList.add(note); } item.setCorrectionSpecialHandlingNoteList(specialHandlingNoteList); item.setCorrectionReceiptNoteList(receiptNoteList); item.setCorrectionReceiptNoteListSize(receiptNoteList.size()); } while (iterator.hasNext()) { LOG.debug("###########inside processAfterRetrieve item loop###########"); Object object = iterator.next(); if (object instanceof OleCorrectionReceivingItem) { LOG.debug("###########inside processAfterRetrieve ole requisition item###########"); OleCorrectionReceivingItem singleItem = (OleCorrectionReceivingItem) object; if (LOG.isDebugEnabled()) { LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId()); } if (singleItem.getItemTitleId() == null) { singleItem.setItemTitleId(getOleCorrectionItemReceivingService() .getCorrectionItemDocItemTitleId(singleItem)); } if (singleItem.getItemTitleId() != null) { Bib bib = new BibMarc(); if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") { bib = getDocstoreClientLocator().getDocstoreClient() .retrieveBib(singleItem.getItemTitleId()); singleItem.setBibUUID(bib.getId()); } itemDescription = (bib.getTitle() != null && !bib.getTitle().isEmpty() ? bib.getTitle() : "") + (bib.getAuthor() != null && !bib.getAuthor().isEmpty() ? "," + bib.getAuthor() : "") + (bib.getPublisher() != null && !bib.getPublisher().isEmpty() ? "," + bib.getPublisher() : "") + (bib.getIsbn() != null && !bib.getIsbn().isEmpty() ? "," + bib.getIsbn() : ""); if (singleItem.getItemTitleId() != null) { singleItem.setDocFormat( DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId())); } StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); singleItem.setItemDescription(itemDescription); } OleLineItemReceivingService oleLineItemReceivingService = SpringContext .getBean(OleLineItemReceivingServiceImpl.class); OlePurchaseOrderItem olePurchaseOrderItem = null; if (singleItem.getPurchaseOrderIdentifier() != null) { olePurchaseOrderItem = oleLineItemReceivingService .getOlePurchaseOrderItem(singleItem.getPurchaseOrderIdentifier()); } else { olePurchaseOrderItem = oleLineItemReceivingService .getOlePurchaseOrderItem(getPurchaseOrderIdentifier()); } if (olePurchaseOrderItem != null && olePurchaseOrderItem.getItemTitleId() != null) { singleItem.setItemTitleId(olePurchaseOrderItem.getItemTitleId()); } else { singleItem.setItemTitleId(getOleCorrectionItemReceivingService() .getCorrectionItemDocItemTitleId(singleItem)); } Integer rcvnitemIdentifier = item.getReceivingItemIdentifier(); Map<String, Integer> recItemIdentifer = new HashMap<String, Integer>(); recItemIdentifer.put(OLEConstants.RCV_LN_ITM_IDN, rcvnitemIdentifier); OleCorrectionReceivingItem oleCorrectionReceivingItems = new OleCorrectionReceivingItem(); List<OleLineItemCorrectionReceivingDoc> oleLineItemCorrectionReceivingDocs = (List<OleLineItemCorrectionReceivingDoc>) getBusinessObjectService() .findMatching(OleLineItemCorrectionReceivingDoc.class, recItemIdentifer); if (oleLineItemCorrectionReceivingDocs != null && oleLineItemCorrectionReceivingDocs.size() > 0) { for (int i = 0; i < oleLineItemCorrectionReceivingDocs.size(); i++) { Integer rcvnItemIdentifier = oleLineItemCorrectionReceivingDocs.get(i) .getReceivingLineItemIdentifier(); if (!rcvnItemIdentifier.equals(item.getReceivingItemIdentifier())) { OleLineItemCorrectionReceivingDoc corr = new OleLineItemCorrectionReceivingDoc(); corr.setReceivingLineItemIdentifier(item.getReceivingItemIdentifier()); corr.setItemTitleId(item.getItemTitleId()); oleLineItemReceivingService.saveOleLineItemReceivingCorrection(corr); } } } else { OleLineItemCorrectionReceivingDoc corr = new OleLineItemCorrectionReceivingDoc(); corr.setReceivingLineItemIdentifier(item.getReceivingItemIdentifier()); corr.setItemTitleId(item.getItemTitleId()); oleLineItemReceivingService.saveOleLineItemReceivingCorrection(corr); } Map cpySection = new HashMap(); cpySection.put("itemIdentifier", singleItem.getPurchaseOrderIdentifier()); List<OlePurchaseOrderItem> olePurchaseOrderItems = (List<OlePurchaseOrderItem>) getBusinessObjectService() .findMatching(OlePurchaseOrderItem.class, cpySection); if (olePurchaseOrderItems.size() > 0) { for (OlePurchaseOrderItem purItem : olePurchaseOrderItems) { singleItem.setCopyList(purItem.getCopyList()); } } } } LOG.debug("Leaving processAfterRetrieve of OleCorrectionReceivingDocument"); } } catch (Exception e) { LOG.error("Exception in processAfterRetrieve of OleCorrectionReceivingDocument" + e); throw new RuntimeException(e); } }
From source file:org.kuali.ole.select.document.OleInvoiceDocument.java
public void loadInvoiceDocument() { try {/*from w w w.ja v a2 s .c om*/ long b1 = System.currentTimeMillis(); // super.processAfterRetrieve(); LOG.debug("###########inside OleInvoiceDocument processAfterRetrieve###########"); if (this.getPaymentMethodId() != null) { OlePaymentMethod olePaymentMethod = SpringContext.getBean(BusinessObjectService.class) .findBySinglePrimaryKey(OlePaymentMethod.class, this.getPaymentMethodId()); this.setPaymentMethod(olePaymentMethod); this.setPaymentMethodIdentifier(this.getPaymentMethodId().toString()); } if (this.getInvoiceTypeId() != null) { this.setInvoiceTypeHdnId(this.getInvoiceTypeId().toString()); } if (this.getInvoiceSubTypeId() != null) { this.setInvoiceSubTypeHdnId(this.getInvoiceSubTypeId().toString()); } if (this.getVendorInvoiceAmount() != null) { this.setInvoiceAmount(this.getVendorInvoiceAmount().toString()); } if (this.getForeignVendorInvoiceAmount() != null) { this.setForeignInvoiceAmount(this.getForeignVendorInvoiceAmount().toString()); } List<BigDecimal> newUnitPriceList = new ArrayList<BigDecimal>(); BigDecimal newUnitPrice = new BigDecimal(0); BigDecimal hundred = new BigDecimal(100); List<OleInvoiceItem> item = this.getItems(); String titleId = null; //int itemCount = 0; /* List<String> itemIds = new ArrayList<>(); for(OleInvoiceItem invoiceItem : (List<OleInvoiceItem>)this.getItems()){ if(invoiceItem.getItemTitleId()!=null){ itemIds.add(invoiceItem.getItemTitleId()); } } DocstoreClientLocator docstoreClientLocator = new DocstoreClientLocator(); List<Bib> bibs = new ArrayList<>(); if(itemIds.size()>0){ bibs = docstoreClientLocator.getDocstoreClient().retrieveBibs(itemIds); }*/ String itemDescription = ""; BigDecimal exchangeRate = new BigDecimal("0"); if (this.getInvoiceCurrencyTypeId() != null) { OleCurrencyType oleCurrencyType = SpringContext.getBean(BusinessObjectService.class) .findBySinglePrimaryKey(OleCurrencyType.class, this.getInvoiceCurrencyTypeId()); this.setOleCurrencyType(oleCurrencyType); this.setInvoiceCurrencyType(this.getInvoiceCurrencyTypeId().toString()); if (oleCurrencyType.getCurrencyType().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) { currencyTypeIndicator = true; this.setForeignCurrencyFlag(false); } else { currencyTypeIndicator = false; this.setForeignCurrencyFlag(true); } } else { if (this.getVendorDetail() != null && this.getVendorDetail().getCurrencyType() != null) { if (this.getVendorDetail().getCurrencyType().getCurrencyType() .equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) { currencyTypeIndicator = true; this.setForeignCurrencyFlag(false); this.setInvoiceCurrencyType( this.getVendorDetail().getCurrencyType().getCurrencyTypeId().toString()); } else { currencyTypeIndicator = false; this.setForeignCurrencyFlag(true); this.setInvoiceCurrencyType( this.getVendorDetail().getCurrencyType().getCurrencyTypeId().toString()); } } } if (this.getInvoiceCurrencyTypeId() != null && (!currencyTypeIndicator)) { if (StringUtils.isBlank(this.getInvoiceCurrencyExchangeRate())) { exchangeRate = SpringContext.getBean(OleInvoiceService.class) .getExchangeRate(this.getInvoiceCurrencyType()).getExchangeRate(); this.setInvoiceCurrencyExchangeRate(exchangeRate.toString()); // items.setItemExchangeRate(new KualiDecimal(exchangeRate)); // items.setExchangeRate(exchangeRate.toString()); } } for (int i = 0; item.size() > i; i++) { OleInvoiceItem items = (OleInvoiceItem) this.getItem(i); if (this.getInvoiceCurrencyTypeId() != null) { items.setItemCurrencyType(oleCurrencyType.getCurrencyType()); items.setInvoicedCurrency(oleCurrencyType.getCurrencyType()); } else { if (this.getVendorDetail() != null && this.getVendorDetail().getCurrencyType() != null) { items.setItemCurrencyType(this.getVendorDetail().getCurrencyType().getCurrencyType()); items.setInvoicedCurrency(this.getVendorDetail().getCurrencyType().getCurrencyType()); } } if (this.getInvoiceCurrencyTypeId() != null && (!currencyTypeIndicator)) { if (StringUtils.isNotBlank(this.getInvoiceCurrencyExchangeRate())) { try { // Double.parseDouble(this.getInvoiceCurrencyExchangeRate()); items.setItemExchangeRate(new KualiDecimal(this.getInvoiceCurrencyExchangeRate())); items.setExchangeRate(this.getInvoiceCurrencyExchangeRate()); } catch (NumberFormatException nfe) { throw new RuntimeException("Invalid Exchange Rate", nfe); } } else { items.setItemExchangeRate(new KualiDecimal(exchangeRate)); items.setExchangeRate(exchangeRate.toString()); } if (items.getItemExchangeRate() != null && items.getItemForeignUnitCost() != null && !this.getApplicationDocumentStatus().equals("Department-Approved")) { items.setItemUnitCostUSD(new KualiDecimal(items.getItemForeignUnitCost().bigDecimalValue() .divide(new BigDecimal(items.getExchangeRate()), 4, BigDecimal.ROUND_HALF_UP))); items.setItemUnitPrice(items.getItemForeignUnitCost().bigDecimalValue() .divide(new BigDecimal(items.getExchangeRate()), 4, BigDecimal.ROUND_HALF_UP)); items.setItemListPrice(items.getItemUnitCostUSD()); items.setExtendedPrice(items.calculateExtendedPrice()); } //this.setForeignVendorInvoiceAmount(this.getVendorInvoiceAmount().bigDecimalValue().multiply(tempOleExchangeRate.getExchangeRate())); } if (LOG.isDebugEnabled()) { LOG.debug("Title id while retriving ------>" + items.getItemTitleId()); } if (items.getItemTitleId() != null) { BibInfoRecord bibInfoRecord = items.getBibInfoRecord(); if (bibInfoRecord != null) { items.setBibUUID(bibInfoRecord.getBibIdStr()); items.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(items.getItemTitleId())); itemDescription = ((bibInfoRecord.getTitle() != null && !bibInfoRecord.getTitle().isEmpty()) ? bibInfoRecord.getTitle().trim() + ", " : "") + ((bibInfoRecord.getAuthor() != null && !bibInfoRecord.getAuthor().isEmpty()) ? bibInfoRecord.getAuthor().trim() + ", " : "") + ((bibInfoRecord.getPublisher() != null && !bibInfoRecord.getPublisher().isEmpty()) ? bibInfoRecord.getPublisher().trim() + ", " : "") + ((bibInfoRecord.getIsxn() != null && !bibInfoRecord.getIsxn().isEmpty()) ? bibInfoRecord.getIsxn().trim() + ", " : ""); } if (itemDescription != null && !(itemDescription.equals(""))) { itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); items.setItemDescription(itemDescription); } HashMap<String, String> queryMap = new HashMap<String, String>(); if (items.getPoItemIdentifier() != null) { queryMap.put(OLEConstants.OleCopy.PO_ITM_ID, items.getPoItemIdentifier().toString()); List<OLELinkPurapDonor> oleLinkPurapDonorList = (List<OLELinkPurapDonor>) getBusinessObjectService() .findMatching(OLELinkPurapDonor.class, queryMap); if (oleLinkPurapDonorList != null) { items.setOleDonors(oleLinkPurapDonorList); oleLinkPurapDonorList.clear(); } } } if ((items.getItemType().isQuantityBasedGeneralLedgerIndicator())) { if (items.getItemDiscount() == null) { items.setItemDiscount(KualiDecimal.ZERO); } if (items.getItemListPrice() == null) { items.setItemListPrice(KualiDecimal.ZERO); } /* if (items.getItemDiscountType() != null && items.getItemDiscountType().equalsIgnoreCase(OleSelectConstant.DISCOUNT_TYPE_PERCENTAGE)) { newUnitPrice = (hundred.subtract(items.getItemDiscount().bigDecimalValue())).divide(hundred).multiply(items.getItemListPrice().bigDecimalValue()); } else { newUnitPrice = items.getItemListPrice().bigDecimalValue().subtract(items.getItemDiscount().bigDecimalValue()); } items.setItemSurcharge(items.getItemUnitPrice().subtract(newUnitPrice).setScale(4, RoundingMode.HALF_UP));*/ } /*else if (items.getItemType().isAdditionalChargeIndicator() && (!currencyTypeIndicator)) { if (items.getItemForeignUnitCost() != null) { items.setAdditionalForeignUnitCost(items.getItemForeignUnitCost().toString()); } }*/ items.setOleOpenQuantity(String.valueOf(items.getPoOutstandingQuantity())); } if (this.getVendorHeaderGeneratedIdentifier() != null && this.getVendorDetailAssignedIdentifier() != null) { this.setVendorId(this.getVendorHeaderGeneratedIdentifier().toString() + "-" + this.getVendorDetailAssignedIdentifier().toString()); } if (this.getProrateBy() != null) { this.setProrateQty(this.getProrateBy().equals(OLEConstants.PRORATE_BY_QTY)); this.setProrateManual(this.getProrateBy().equals(OLEConstants.MANUAL_PRORATE)); this.setProrateDollar(this.getProrateBy().equals(OLEConstants.PRORATE_BY_DOLLAR)); this.setNoProrate(this.getProrateBy().equals(OLEConstants.NO_PRORATE)); } long b2 = System.currentTimeMillis(); long tot = b2 - b1; LOG.info("loadInvoiceDocument" + tot); } catch (Exception e) { LOG.error("Exception during processAfterRetrieve in OleInvoiceDocument " + e); throw new RuntimeException(e); } }
From source file:org.kuali.ole.select.document.OleLineItemReceivingDocument.java
/** * This method is overridden to set special processing notes and other types of receipt notes in two different lists to be * displayed under Special Processing Notes Tab and Receipt Notes tab respectively. *//*from w ww .ja v a 2 s . c o m*/ @Override public void processAfterRetrieve() { try { LOG.debug("Inside processAfterRetrieve of OleLineItemReceivingDocument"); String itemDescription = ""; List<OleLineItemReceivingItem> items = new ArrayList<OleLineItemReceivingItem>(); items = this.getItems(); Iterator iterator = items.iterator(); String titleId = null; int itemCount = 0; boolean isBibFileExist = false; boolean isBibEdit = false; List receiptNoteList; List specialHandlingNoteList; for (OleLineItemReceivingItem item : items) { receiptNoteList = new ArrayList(); specialHandlingNoteList = new ArrayList(); List<OleLineItemReceivingReceiptNotes> notes = new ArrayList<OleLineItemReceivingReceiptNotes>(); notes = item.getNoteList(); for (OleLineItemReceivingReceiptNotes note : notes) { String noteType = note.getNoteType().getNoteType(); if (noteType.equalsIgnoreCase(OLEConstants.SPECIAL_PROCESSING_INSTRUCTION_NOTE)) { specialHandlingNoteList.add(note); } else { receiptNoteList.add(note); } item.setSpecialHandlingNoteList(specialHandlingNoteList); item.setReceiptNoteList(receiptNoteList); item.setReceiptNoteListSize(receiptNoteList.size()); } } while (iterator.hasNext()) { LOG.debug("###########inside processAfterRetrieve item loop###########"); Object object = iterator.next(); if (object instanceof OleLineItemReceivingItem) { LOG.debug("###########inside processAfterRetrieve ole requisition item###########"); OleLineItemReceivingItem singleItem = (OleLineItemReceivingItem) object; if (LOG.isDebugEnabled()) { LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId()); } BibInfoBean xmlBibInfoBean = new BibInfoBean(); HashMap<String, String> dataMap = new HashMap<String, String>(); // Modified for Jira OLE-2515 /* if (!StringUtils.equalsIgnoreCase(singleItem.getItemTypeCode(), PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE)) { OlePurchaseOrderItem olePurchaseOrderItem = getOleLineItemReceivingService().getOlePurchaseOrderItem(singleItem.getPurchaseOrderIdentifier()); singleItem.setItemTitleId(olePurchaseOrderItem.getItemTitleId()); }*/ if (singleItem.getItemTitleId() == null) { singleItem.setItemTitleId( getOleLineItemReceivingService().getLineItemDocItemTitleId(singleItem)); } if (singleItem.getItemTitleId() != null) { Bib bib = new BibMarc(); if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") { bib = getDocstoreClientLocator().getDocstoreClient() .retrieveBib(singleItem.getItemTitleId()); singleItem.setBibUUID(bib.getId()); } singleItem .setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId())); itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty()) ? bib.getTitle().trim() + ", " : "") + ((bib.getAuthor() != null && !bib.getAuthor().isEmpty()) ? bib.getAuthor().trim() + ", " : "") + ((bib.getPublisher() != null && !bib.getPublisher().isEmpty()) ? bib.getPublisher().trim() + ", " : "") + ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn().trim() + ", " : ""); if (itemDescription != null && !(itemDescription.equals(""))) { itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); singleItem.setItemDescription(itemDescription); } } Map cpySection = new HashMap(); cpySection.put("itemIdentifier", singleItem.getPurchaseOrderIdentifier()); List<OlePurchaseOrderItem> olePurchaseOrderItems = (List<OlePurchaseOrderItem>) getBusinessObjectService() .findMatching(OlePurchaseOrderItem.class, cpySection); if (olePurchaseOrderItems.size() > 0) { for (OlePurchaseOrderItem item : olePurchaseOrderItems) { singleItem.setCopyList(item.getCopyList()); } } } } LOG.debug("Leaving processAfterRetrieve of OleLineItemReceivingDocument"); } catch (Exception e) { LOG.error("Exception during processAfterRetrieve() in OleLineItemReceivingDocument" + e); throw new RuntimeException(e); } }
From source file:org.kuali.ole.select.document.OlePaymentRequestDocument.java
@Override public void processAfterRetrieve() { super.processAfterRetrieve(); try {/*from ww w. j av a 2 s . c om*/ LOG.debug("###########inside OlePaymentRequestDocument processAfterRetrieve###########"); if (this.getVendorAliasName() == null) { populateVendorAliasName(); } if (this.getPaymentMethodId() != null) { OlePaymentMethod olePaymentMethod = SpringContext.getBean(BusinessObjectService.class) .findBySinglePrimaryKey(OlePaymentMethod.class, this.getPaymentMethodId()); this.setPaymentMethod(olePaymentMethod); } List<BigDecimal> newUnitPriceList = new ArrayList<BigDecimal>(); BigDecimal newUnitPrice = new BigDecimal(0); BigDecimal hundred = new BigDecimal(100); List<OlePaymentRequestItem> item = this.getItems(); for (int i = 0; item.size() > i; i++) { OlePaymentRequestItem items = (OlePaymentRequestItem) this.getItem(i); if ((items.getItemType().isQuantityBasedGeneralLedgerIndicator())) { if (items.getItemDiscount() == null) { items.setItemDiscount(KualiDecimal.ZERO); } if (items.getItemListPrice() == null) { items.setItemListPrice(KualiDecimal.ZERO); } if (items.getItemDiscountType() != null && items.getItemDiscountType() .equalsIgnoreCase(OleSelectConstant.DISCOUNT_TYPE_PERCENTAGE)) { newUnitPrice = (hundred.subtract(items.getItemDiscount().bigDecimalValue())).divide(hundred) .multiply(items.getItemListPrice().bigDecimalValue()); } else { newUnitPrice = items.getItemListPrice().bigDecimalValue() .subtract(items.getItemDiscount().bigDecimalValue()); } items.setItemSurcharge( items.getItemUnitPrice().subtract(newUnitPrice).setScale(4, RoundingMode.HALF_UP)); } } if (this.getVendorDetail().getCurrencyType() != null) { if (this.getVendorDetail().getCurrencyType().getCurrencyType() .equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) { currencyTypeIndicator = true; } else { currencyTypeIndicator = false; } } OleInvoiceDocument oleInvoiceDocument = SpringContext.getBean(BusinessObjectService.class) .findBySinglePrimaryKey(OleInvoiceDocument.class, this.getInvoiceIdentifier()); if (oleInvoiceDocument.getInvoiceCurrencyTypeId() != null && oleInvoiceDocument.getForeignVendorInvoiceAmount() != null && oleInvoiceDocument.getInvoiceCurrencyExchangeRate() != null) { this.setForeignVendorInvoiceAmount(this.getVendorInvoiceAmount().bigDecimalValue() .multiply(new BigDecimal(oleInvoiceDocument.getInvoiceCurrencyExchangeRate()))); } else { if (this.getVendorDetail() != null && (!currencyTypeIndicator)) { Long currencyTypeId = this.getVendorDetail().getCurrencyType().getCurrencyTypeId(); Map documentNumberMap = new HashMap(); documentNumberMap.put(OleSelectConstant.CURRENCY_TYPE_ID, currencyTypeId); List<OleExchangeRate> exchangeRateList = (List) getBusinessObjectService().findMatchingOrderBy( OleExchangeRate.class, documentNumberMap, OleSelectConstant.EXCHANGE_RATE_DATE, false); Iterator iterator = exchangeRateList.iterator(); for (OlePaymentRequestItem items : item) { iterator = exchangeRateList.iterator(); if (iterator.hasNext()) { OleExchangeRate tempOleExchangeRate = (OleExchangeRate) iterator.next(); items.setItemExchangeRate(new KualiDecimal(tempOleExchangeRate.getExchangeRate())); this.setForeignVendorInvoiceAmount(this.getVendorInvoiceAmount().bigDecimalValue() .multiply(tempOleExchangeRate.getExchangeRate())); } } } } String itemDescription = ""; for (OlePaymentRequestItem singleItem : item) { if (LOG.isDebugEnabled()) { LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId()); } if (singleItem.getItemTitleId() != null) { LOG.debug("###########inside processAfterRetrieve ole requisition item###########"); Bib bib = new BibMarc(); DocstoreClientLocator docstoreClientLocator = new DocstoreClientLocator(); if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") { bib = docstoreClientLocator.getDocstoreClient().retrieveBib(singleItem.getItemTitleId()); singleItem.setBibUUID(bib.getId()); singleItem .setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId())); } if (singleItem.getItemUnitPrice() != null) { singleItem.setItemUnitPrice( singleItem.getItemUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP)); } itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty()) ? bib.getTitle().trim() + ", " : "") + ((bib.getAuthor() != null && !bib.getAuthor().isEmpty()) ? bib.getAuthor().trim() + ", " : "") + ((bib.getPublisher() != null && !bib.getPublisher().isEmpty()) ? bib.getPublisher().trim() + ", " : "") + ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn().trim() + ", " : ""); if (itemDescription != null && !(itemDescription.equals(""))) { itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); singleItem.setItemDescription(itemDescription); } HashMap<String, String> queryMap = new HashMap<String, String>(); if (singleItem.getPoItemIdentifier() != null) { queryMap.put(OLEConstants.PO_ITEM_ID, singleItem.getPoItemIdentifier().toString()); OleInvoiceItem oleInvoiceItem = getBusinessObjectService() .findByPrimaryKey(OleInvoiceItem.class, queryMap); if (oleInvoiceItem != null && oleInvoiceItem.getPoItemIdentifier() != null) { queryMap.clear(); queryMap.put(OLEConstants.OleCopy.PO_ITM_ID, oleInvoiceItem.getPoItemIdentifier().toString()); List<OLELinkPurapDonor> oleLinkPurapDonorList = (List<OLELinkPurapDonor>) getBusinessObjectService() .findMatching(OLELinkPurapDonor.class, queryMap); if (oleLinkPurapDonorList != null) { singleItem.setOleDonors(oleLinkPurapDonorList); } } } } for (OLEPaidCopy olePaidCopy : singleItem.getPaidCopies()) { if (olePaidCopy.getPaymentRequestItemId() == null && olePaidCopy.getPaymentRequestIdentifier() == null) { olePaidCopy.setPaymentRequestItemId(singleItem.getItemIdentifier()); olePaidCopy.setPaymentRequestIdentifier(this.getPurapDocumentIdentifier()); getBusinessObjectService().save(olePaidCopy); } } } if (this.getProrateBy() != null) { this.setProrateQty(this.getProrateBy().equals(OLEConstants.PRORATE_BY_QTY)); this.setProrateManual(this.getProrateBy().equals(OLEConstants.MANUAL_PRORATE)); this.setProrateDollar(this.getProrateBy().equals(OLEConstants.PRORATE_BY_DOLLAR)); this.setNoProrate(this.getProrateBy().equals(OLEConstants.NO_PRORATE)); } } catch (Exception e) { LOG.error("Exception during processAfterRetrieve() in OlePaymentRequestDocument", e); throw new RuntimeException(e); } }
From source file:org.kuali.ole.select.document.OleVendorCreditMemoDocument.java
@Override public void processAfterRetrieve() { super.processAfterRetrieve(); try {/*from ww w.j a va2 s .c o m*/ if (this.getVendorAliasName() == null) { populateVendorAliasName(); } Map purchaseOrderTypeIdMap = new HashMap(); if (this.getPurchaseOrderTypeId() != null) { purchaseOrderTypeIdMap.put("purchaseOrderTypeId", this.getPurchaseOrderTypeId()); List<PurchaseOrderType> purchaseOrderTypeDocumentList = (List) getBusinessObjectService() .findMatching(PurchaseOrderType.class, purchaseOrderTypeIdMap); if (purchaseOrderTypeDocumentList != null && purchaseOrderTypeDocumentList.size() > 0) { PurchaseOrderType purchaseOrderTypeDoc = purchaseOrderTypeDocumentList.get(0); this.setOrderType(purchaseOrderTypeDoc); } } List<BigDecimal> newUnitPriceList = new ArrayList<BigDecimal>(); BigDecimal newUnitPrice = new BigDecimal(0); BigDecimal hundred = new BigDecimal(100); List<OleCreditMemoItem> item = this.getItems(); for (int i = 0; item.size() > i; i++) { OleCreditMemoItem items = (OleCreditMemoItem) this.getItem(i); if ((items.getItemType().isQuantityBasedGeneralLedgerIndicator())) { newUnitPrice = items.getItemUnitPrice().abs(); if (items.getItemUnitPrice() != null && items.getExtendedPrice() != null) { items.setItemSurcharge(items.getExtendedPrice().bigDecimalValue() .subtract(newUnitPrice.multiply(items.getItemQuantity().bigDecimalValue())) .setScale(4, RoundingMode.HALF_UP)); } else { items.setItemSurcharge(BigDecimal.ZERO); } } } if (this.getVendorDetail().getCurrencyType() != null) { if (this.getVendorDetail().getCurrencyType().getCurrencyType() .equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) { currencyTypeIndicator = true; } else { currencyTypeIndicator = false; } } if (this.getVendorDetail() != null && (!currencyTypeIndicator)) { Long currencyTypeId = this.getVendorDetail().getCurrencyType().getCurrencyTypeId(); Map documentNumberMap = new HashMap(); documentNumberMap.put(OleSelectConstant.CURRENCY_TYPE_ID, currencyTypeId); List<OleExchangeRate> exchangeRateList = (List) getBusinessObjectService().findMatchingOrderBy( OleExchangeRate.class, documentNumberMap, OleSelectConstant.EXCHANGE_RATE_DATE, false); Iterator iterator = exchangeRateList.iterator(); for (OleCreditMemoItem items : item) { iterator = exchangeRateList.iterator(); if (iterator.hasNext()) { OleExchangeRate tempOleExchangeRate = (OleExchangeRate) iterator.next(); items.setItemExchangeRate(new KualiDecimal(tempOleExchangeRate.getExchangeRate())); } } } List<OleCreditMemoItem> items = this.getItems(); String itemDescription = ""; for (OleCreditMemoItem singleItem : items) { if (LOG.isDebugEnabled()) { LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId()); } if (singleItem.getItemTitleId() != null) { /* LOG.debug("###########inside processAfterRetrieve ole credit memo item###########"); HashMap<String, String> queryMap = new HashMap<String, String>(); queryMap.put(OleSelectConstant.DocStoreDetails.ITEMLINKS_KEY, singleItem.getItemTitleId()); List<DocInfoBean> docStoreResult = getBibInfoWrapperService().searchBibInfo(queryMap); Iterator bibIdIterator = docStoreResult.iterator(); if (bibIdIterator.hasNext()) { DocInfoBean docInfoBean = (DocInfoBean) bibIdIterator.next(); if (docInfoBean.getBibIdentifier() == null) { singleItem.setBibUUID(docInfoBean.getUniqueId()); } else { singleItem.setBibUUID(docInfoBean.getBibIdentifier()); } }*/ Bib bib = new BibMarc(); DocstoreClientLocator docstoreClientLocator = new DocstoreClientLocator(); if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") { bib = docstoreClientLocator.getDocstoreClient().retrieveBib(singleItem.getItemTitleId()); singleItem.setBibUUID(bib.getId()); singleItem .setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId())); } itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty()) ? bib.getTitle() + "," : "") + ((bib.getAuthor() != null && !bib.getAuthor().isEmpty()) ? bib.getAuthor() + "," : "") + ((bib.getPublisher() != null && !bib.getPublisher().isEmpty()) ? bib.getPublisher() + "," : "") + ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn() + "," : ""); if (!itemDescription.isEmpty()) { itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription : itemDescription.substring(0, itemDescription.lastIndexOf(",")); } StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); itemDescription = stringEscapeUtils.unescapeXml(itemDescription); singleItem.setItemDescription(itemDescription); } } if (this.getProrateBy() != null) { this.setProrateQty(this.getProrateBy().equals(OLEConstants.PRORATE_BY_QTY)); this.setProrateManual(this.getProrateBy().equals(OLEConstants.MANUAL_PRORATE)); this.setProrateDollar(this.getProrateBy().equals(OLEConstants.PRORATE_BY_DOLLAR)); this.setNoProrate(this.getProrateBy().equals(OLEConstants.NO_PRORATE)); } } catch (Exception e) { LOG.error("Exception in OleVendorCreditMemoDocument:processAfterRetrieve " + e); throw new RuntimeException(e); } }