List of usage examples for org.apache.commons.lang StringUtils left
public static String left(String str, int len)
Gets the leftmost len
characters of a String.
From source file:com.commander4j.messages.OutgoingDespatchConfirmation.java
public Boolean processMessage(Long transactionRef) { Boolean result = false;/*from w ww . j a v a 2 s. co m*/ String path = ""; String defaultBatchStatus = ""; JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID()); JDBControl ctrl = new JDBControl(getHostID(), getSessionID()); GenericMessageHeader gmh = new GenericMessageHeader(); JDBInterface inter = new JDBInterface(getHostID(), getSessionID()); JDBUom uoml = new JDBUom(getHostID(), getSessionID()); String batchDateMode = ctrl.getKeyValue("EXPIRY DATE MODE"); inter.getInterfaceProperties("Despatch Confirmation", "Output"); String device = inter.getDevice(); JDBDespatch desp = new JDBDespatch(getHostID(), getSessionID()); desp.setTransactionRef(transactionRef); desp.getDespatchPropertiesFromTransactionRef(); String sourceGLN = JUtility.replaceNullStringwithBlank(desp.getLocationDBFrom().getGLN()); String destinationGLN = JUtility.replaceNullStringwithBlank(desp.getLocationDBTo().getGLN()); Boolean suppressMessage = false; gmh.setMessageRef(desp.getTransactionRef().toString()); gmh.setInterfaceType(inter.getInterfaceType()); gmh.setMessageInformation("Despatch=" + desp.getDespatchNo()); gmh.setInterfaceDirection(inter.getInterfaceDirection()); gmh.setMessageDate(JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime())); String noJourneyPrefix = ctrl.getKeyValueWithDefault("NO JOURNEY PREFIX", "NJ_", "Prefix for No Journey Messages"); if (desp.getDespatchPalletCount() == 0) { setErrorMessage("Message Suppressed - 0 pallets assigned to despatch"); suppressMessage = true; } if (sourceGLN.length() == 0) { setErrorMessage("Message Suppressed - No GLN Source (From) GLN for Location [" + desp.getLocationIDFrom() + "]"); suppressMessage = true; } if (destinationGLN.length() == 0) { setErrorMessage("Message Suppressed - No GLN Destination (To) GLN for Location [" + desp.getLocationIDTo() + "]"); suppressMessage = true; } if (suppressMessage == true) { result = true; il.write(gmh, GenericMessageHeader.msgStatusWarning, getErrorMessage(), "File Write", ""); } else { if (inter.getFormat().equals("EANCOM")) { if (sourceGLN.endsWith("")) { } int segments = 0; int optional = 0; String document = ""; String despdateShort = new java.text.SimpleDateFormat("yyMMdd:HHmm").format(desp.getDespatchDate()); String despdateLong = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(desp.getDespatchDate()); document = document + "UNA:+.? 'UNB+UNOA:3+" + desp.getLocationDBFrom().getGLN() + ":14+" + desp.getLocationDBTo().getGLN() + ":14+"; document = document + despdateShort + "+" + desp.getDespatchNo() + "'"; document = document + "UNH+" + desp.getDespatchNo() + "+DESADV:D:96A:EN:EAN005'"; document = document + "BGM+351+" + desp.getDespatchNo() + "+9'"; document = document + "DTM+11:" + despdateLong + ":203'"; document = document + "RFF+LO:" + desp.getDespatchNo() + "'"; document = document + "RFF+ZCO:'"; if (desp.getLocationDBTo().getMsgJourneyRef().equals("Y")) { if (desp.getJourneyRef().equals("NO JOURNEY")) { document = document + "RFF+SRN:" + noJourneyPrefix + desp.getDespatchNo() + "'"; } else { document = document + "RFF+SRN:" + desp.getJourneyRef() + "'"; } optional++; } document = document + "RFF+ZAF:'"; document = document + "RFF+ZPI:1'"; document = document + "RFF+ZCH:'"; document = document + "NAD+SF+" + desp.getLocationDBFrom().getGLN() + "::9'"; if (desp.getLocationDBFrom().getStorageLocation().equals("") == false) { if (desp.getLocationDBTo().getStorageLocation().equals("") == false) { document = document + "LOC+198+" + desp.getLocationDBFrom().getStorageLocation() + "::91'"; optional++; } } document = document + "NAD+ST+" + desp.getLocationDBTo().getGLN() + "::9'"; if (desp.getLocationDBFrom().getStorageLocation().equals("") == false) { if (desp.getLocationDBTo().getStorageLocation().equals("") == false) { document = document + "LOC+195+" + desp.getLocationDBTo().getStorageLocation() + "::91'"; optional++; } } document = document + "TDT+20++30+31+::9:" + JUtility.stripEANCOMSpecialCharacters( JUtility.replaceNullStringwithBlank(desp.getHaulier())) + "+++:::" + JUtility.stripEANCOMSpecialCharacters( JUtility.replaceNullStringwithBlank(desp.getTrailer())) + "'"; if (desp.getLoadNo().equals("")) { desp.setLoadNo("123"); } document = document + "EQD+CN+" + JUtility.replaceNullStringwithBlank(StringUtils.left(desp.getTrailer(), 10)) + "'"; // NEXT 2 LINES COMMENTS NEED TO BE RESTORED FOR SAP EWM // Next line needs commenting pre SAP EWM document = document + "SEL+" + JUtility.replaceNullStringwithBlank(StringUtils.left(desp.getLoadNo(), 10)) + "+CA'"; document = document + "SEL+" + desp.getDespatchNo() + "+CU'"; // Next line needs amending pre SAP EWM segments = 14 + optional; //segments = 13 + optional; JDBPalletHistory palhist = new JDBPalletHistory(getHostID(), getSessionID()); ResultSet rs = palhist.getInterfacingData(transactionRef, "DESPATCH", "TO", Long.valueOf(0), "SSCC", "asc"); int x = 1; try { rs.beforeFirst(); while (rs.next()) { palhist.getPropertiesfromResultSet(rs); document = document + "CPS+" + JUtility.padString(String.valueOf(x).trim(), false, 4, "0") + "'"; document = document + "PAC+1++202'"; document = document + "PCI+33E'"; document = document + "GIN+BJ+" + palhist.getPallet().getSSCC() + "'"; document = document + "LIN+1++" + palhist.getPallet().getEAN() + ":EN'"; document = document + "PIA+1+" + palhist.getPallet().getVariant() + ":PV+" + palhist.getPallet().getMaterial() + ":SA'"; NumberFormat formatter = new DecimalFormat("#.#"); String outqty = formatter.format(palhist.getPallet().getQuantity()); // -1234.567000 document = document + "QTY+12:" + outqty + ":" + palhist.getPallet().getUom() + "'"; document = document + "DLM+++0::9'"; // String batchExpiryLong = new java.text.SimpleDateFormat("yyyyMMdd").format(palhist.getPallet().getMaterialBatchExpiryDate()); String batchExpiryLong = ""; if (batchDateMode.equals("BATCH")) { batchExpiryLong = new java.text.SimpleDateFormat("yyyyMMdd") .format(palhist.getPallet().getMaterialBatchExpiryDate()); } if (batchDateMode.equals("SSCC")) { batchExpiryLong = new java.text.SimpleDateFormat("yyyyMMdd") .format(palhist.getPallet().getBatchExpiry()); } String dateOfManufactureLong = new java.text.SimpleDateFormat("yyyyMMdd") .format(palhist.getPallet().getDateOfManufacture()); document = document + "DTM+361:" + batchExpiryLong + ":102'"; document = document + "DTM+94:" + dateOfManufactureLong + ":102'"; document = document + "RFF+AAJ:" + palhist.getPallet().getDespatchNo() + ":1'"; defaultBatchStatus = palhist.getPallet().getMaterialBatchStatus(); if (defaultBatchStatus.equals("Unrestricted")) { document = document + "RFF+ZBR:'"; } else { document = document + "RFF+ZBR:B'"; } document = document + "RFF+ZRB:'"; document = document + "RFF+ZSR:'"; document = document + "RFF+ZRC:'"; document = document + "RFF+ZRT:'"; document = document + "PCI+36E'"; document = document + "GIN+BX+" + palhist.getPallet().getBatchNumber() + "'"; segments = segments + 18; x++; } rs.close(); segments = segments + 1; document = document + "UNT+" + String.valueOf(segments).trim() + "+" + desp.getDespatchNo() + "'"; document = document + "UNZ+1+" + desp.getDespatchNo() + "'"; if (device.equals("Disk") | device.equals("Email")) { path = inter.getRealPath(); if (fio.writeToDisk(path, document, transactionRef, "_" + desp.getLocationIDTo().replace(" ", "_") + "_DespatchConfirmation.txt") == true) { result = true; il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename()); setErrorMessage(""); if (device.equals("Email")) { ogm = new JeMailOutGoingMessage(inter, transactionRef, fio); ogm.sendEmail(); } } else { result = false; il.write(gmh, GenericMessageHeader.msgStatusError, fio.getErrorMessage(), "File Write", fio.getFilename()); setErrorMessage(fio.getErrorMessage()); } } } catch (SQLException e) { } } if (inter.getFormat().equals("XML")) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.newDocument(); Element message = (Element) document.createElement("message"); Element hostUniqueID = addElement(document, "hostRef", Common.hostList.getHost(getHostID()).getUniqueID()); message.appendChild(hostUniqueID); Element messageRef = addElement(document, "messageRef", String.valueOf(transactionRef)); message.appendChild(messageRef); Element messageType = addElement(document, "interfaceType", "Despatch Confirmation"); message.appendChild(messageType); Element messageInformation = addElement(document, "messageInformation", "Despatch=" + desp.getDespatchNo()); message.appendChild(messageInformation); Element messageDirection = addElement(document, "interfaceDirection", "Output"); message.appendChild(messageDirection); Element messageDate = addElement(document, "messageDate", JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime())); message.appendChild(messageDate); Element despatchConfirmation = (Element) document.createElement("despatchConfirmation"); Element noofpallets = addElement(document, "numberOfPallets", String.valueOf(desp.getTotalPallets())); despatchConfirmation.appendChild(noofpallets); Element haulier = addElement(document, "haulier", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getHaulier()))); despatchConfirmation.appendChild(haulier); Element trailer = addElement(document, "trailer", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getTrailer()))); despatchConfirmation.appendChild(trailer); Element load = addElement(document, "loadNo", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getLoadNo()))); despatchConfirmation.appendChild(load); Element journey = addElement(document, "journeyRef", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getJourneyRef()))); despatchConfirmation.appendChild(journey); Element despatch = addElement(document, "despatchNo", desp.getDespatchNo()); despatchConfirmation.appendChild(despatch); Element despatchDate = addElement(document, "despatchDate", JUtility.getISOTimeStampStringFormat(desp.getDespatchDate())); despatchConfirmation.appendChild(despatchDate); Element locationFrom = addElement(document, "fromLocation", desp.getLocationIDFrom()); despatchConfirmation.appendChild(locationFrom); Element locationFromPlant = addElement(document, "fromPlant", desp.getLocationDBFrom().getPlant()); despatchConfirmation.appendChild(locationFromPlant); Element locationFromWarehouse = addElement(document, "fromWarehouse", desp.getLocationDBFrom().getWarehouse()); despatchConfirmation.appendChild(locationFromWarehouse); Element locationFromStorageSection = addElement(document, "fromStorageSection", desp.getLocationDBFrom().getStorageSection()); despatchConfirmation.appendChild(locationFromStorageSection); Element locationFromStorageType = addElement(document, "fromStorageType", desp.getLocationDBFrom().getStorageType()); despatchConfirmation.appendChild(locationFromStorageType); Element locationFromStorageBin = addElement(document, "fromStorageBin", desp.getLocationDBFrom().getStorageBin()); despatchConfirmation.appendChild(locationFromStorageBin); Element locationFromGLN = addElement(document, "fromGLN", desp.getLocationDBFrom().getGLN()); despatchConfirmation.appendChild(locationFromGLN); Element locationFromStorageLocation = addElement(document, "fromStorageLocation", desp.getLocationDBFrom().getStorageLocation()); despatchConfirmation.appendChild(locationFromStorageLocation); Element locationTo = addElement(document, "toLocation", desp.getLocationIDTo()); despatchConfirmation.appendChild(locationTo); Element locationToPlant = addElement(document, "toPlant", desp.getLocationDBTo().getPlant()); despatchConfirmation.appendChild(locationToPlant); Element locationToWarehouse = addElement(document, "toWarehouse", desp.getLocationDBTo().getWarehouse()); despatchConfirmation.appendChild(locationToWarehouse); Element locationToStorageSection = addElement(document, "toStorageSection", desp.getLocationDBTo().getStorageSection()); despatchConfirmation.appendChild(locationToStorageSection); Element locationToStorageType = addElement(document, "toStorageType", desp.getLocationDBTo().getStorageType()); despatchConfirmation.appendChild(locationToStorageType); Element locationToStorageBin = addElement(document, "toStorageBin", desp.getLocationDBTo().getStorageBin()); despatchConfirmation.appendChild(locationToStorageBin); Element locationToGLN = addElement(document, "toGLN", desp.getLocationDBTo().getGLN()); despatchConfirmation.appendChild(locationToGLN); Element locationToStorageLocation = addElement(document, "toStorageLocation", desp.getLocationDBTo().getStorageLocation()); despatchConfirmation.appendChild(locationToStorageLocation); Element contents = (Element) document.createElement("contents"); despatchConfirmation.appendChild(contents); JDBPalletHistory palhist = new JDBPalletHistory(getHostID(), getSessionID()); ResultSet rs = palhist.getInterfacingData(transactionRef, "DESPATCH", "TO", Long.valueOf(0), "SSCC", "asc"); int x = 1; try { rs.beforeFirst(); while (rs.next()) { palhist.getPropertiesfromResultSet(rs); Element pallet = (Element) document.createElement("pallet"); Element item = addElement(document, "item", String.valueOf(x)); pallet.appendChild(item); x++; Element sscc = addElement(document, "SSCC", palhist.getPallet().getSSCC()); pallet.appendChild(sscc); Element processOrder = addElement(document, "processOrder", palhist.getPallet().getProcessOrder()); pallet.appendChild(processOrder); Element material = addElement(document, "material", palhist.getPallet().getMaterial()); pallet.appendChild(material); Element materialDescription = addElement(document, "materialDescription", palhist.getPallet().getMaterialObj().getDescription()); pallet.appendChild(materialDescription); Element ean = addElement(document, "ean", palhist.getPallet().getEAN()); pallet.appendChild(ean); Element variant = addElement(document, "variant", palhist.getPallet().getVariant()); pallet.appendChild(variant); Element qty = addElement(document, "quantity", palhist.getPallet().getQuantity().toString()); pallet.appendChild(qty); String paluom = palhist.getPallet().getUom(); paluom = uoml.convertUom(inter.getUOMConversion(), paluom); Element uom = addElement(document, "UOM", paluom); pallet.appendChild(uom); Element status = addElement(document, "status", palhist.getPallet().getStatus()); pallet.appendChild(status); String expiryDateStr = ""; if (batchDateMode.equals("BATCH")) { expiryDateStr = JUtility.getISOTimeStampStringFormat( palhist.getPallet().getMaterialBatchExpiryDate()); } if (batchDateMode.equals("SSCC")) { expiryDateStr = JUtility .getISOTimeStampStringFormat(palhist.getPallet().getBatchExpiry()); } Element expiryDate = addElement(document, "bestBefore", expiryDateStr); pallet.appendChild(expiryDate); Element dom = addElement(document, "productionDate", JUtility .getISOTimeStampStringFormat(palhist.getPallet().getDateOfManufacture())); pallet.appendChild(dom); Element batch = addElement(document, "batch", palhist.getPallet().getBatchNumber()); pallet.appendChild(batch); Element batchStatus = addElement(document, "batchStatus", palhist.getPallet().getMaterialBatchStatus()); pallet.appendChild(batchStatus); contents.appendChild(pallet); } rs.close(); } catch (SQLException e) { } Element messageData = (Element) document.createElement("messageData"); messageData.appendChild(despatchConfirmation); message.appendChild(messageData); document.appendChild(message); JXMLDocument xmld = new JXMLDocument(); xmld.setDocument(document); gmh.decodeHeader(xmld); if (device.equals("Disk") | device.equals("Email")) { path = inter.getRealPath(); if (fio.writeToDisk(path, document, transactionRef, "_" + desp.getLocationIDTo().replace(" ", "_") + "_DespatchConfirmation.xml") == true) { result = true; il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename()); setErrorMessage(""); if (device.equals("Email")) { ogm = new JeMailOutGoingMessage(inter, transactionRef, fio); ogm.sendEmail(); } } else { result = false; il.write(gmh, GenericMessageHeader.msgStatusError, fio.getErrorMessage(), "File Write", fio.getFilename()); setErrorMessage(fio.getErrorMessage()); } } } catch (Exception ex) { logger.error("Error sending message. " + ex.getMessage()); result = false; } } } return result; }
From source file:com.skratchdot.electribe.model.esx.presentation.EsxComposite.java
/** * This function is intended to be called from within a loop, passing * a different currentIndex each time. It will return the given string * with a number appended to the end of it. * @param string The string to append a number to * @param currentIndex The current index (the number appended will be currentIndex+1) * @param listSize The total size of the list you are appending numbers to * @param maxAppendStringLength The maximum length of the string that is returned * @return// w w w .j a v a2s . co m */ protected String getMultiNumberString(final String string, final int currentIndex, final int listSize, final int maxAppendStringLength) { if (listSize <= 1) { return string; } else { int listSizeStringLength = Integer.toString(listSize).length(); return StringUtils.left(string, maxAppendStringLength - listSizeStringLength) + StringUtils.leftPad(Integer.toString(currentIndex + 1), listSizeStringLength, "0"); } }
From source file:de.tudarmstadt.ukp.dkpro.core.io.tuebadz.TuebaDZReader.java
/** * Read a single sentence.//from w w w. j a v a2 s. co m */ private static List<String[]> readSentence(BufferedReader aReader) throws IOException { List<String[]> words = new ArrayList<String[]>(); String line; while ((line = aReader.readLine()) != null) { if (StringUtils.isBlank(line)) { break; // End of sentence } if (StringUtils.left(line, SENTENCE_HEADER_LEN).equals(SENTENCE_HEADER)) { break; // Ignore sentence header line } String[] fields = line.split(TAB); if (fields.length != 3) { throw new IOException("Invalid file format. Line needs to have 3 tab-separated fields."); } words.add(fields); } if (line == null && words.isEmpty()) { return null; } else { return words; } }
From source file:com.bluexml.xforms.generator.forms.Renderable.java
/** * Gets the root path.<br>/* www.ja v a 2 s . co m*/ * Retrieves the path from where we can access directly to the data.<br> * This is used for association class or anywhere there's a repeater. * * @param renderedParents * the rendered parents * * @return the root path (empty string if no repeater are found among parents) */ protected String getRootPath(Stack<Rendered> renderedParents) { StringBuffer result = new StringBuffer(""); for (Rendered rendered : renderedParents) { if (rendered instanceof RenderedRepeater) { RenderedRepeater repeated = (RenderedRepeater) rendered; String repeaterNodeSet = repeated.getNodeSet(); repeaterNodeSet = StringUtils.left(repeaterNodeSet, repeaterNodeSet.lastIndexOf("[")); repeaterNodeSet = repeaterNodeSet + "[index('" + repeated.getRepeatId() + "')]"; result.append(repeaterNodeSet + "/"); } } return result.toString(); }
From source file:net.bible.android.control.readingplan.ReadingPlanControl.java
public String getShortTitle() { return StringUtils.left(getCurrentPlanCode(), 8); }
From source file:edu.cornell.kfs.fp.service.impl.CUPaymentMethodGeneralLedgerPendingEntryServiceImpl.java
/** * Generates the GL entries to charge the department for the foreign draft and credit the Wire Charge * Fee Account as specified by system parameters. * //from w ww . j a v a 2 s . c om * @param document Document into which to add the generated GL Entries. * */ protected boolean generateFeeAssessmentEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntry templatePendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, boolean reverseEntries) { LOG.debug("generateForeignDraftChargeEntries started"); PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(templatePendingEntry.getChartOfAccountsCode(), new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis())); if (pmc == null) { LOG.warn("No Applicable PaymentMethodChart found for chart: " + templatePendingEntry.getChartOfAccountsCode() + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated()); return false; } // Get all the parameters which control these entries String feeIncomeChartCode = pmc.getFeeIncomeChartOfAccountsCode(); String feeIncomeAccountNumber = pmc.getFeeIncomeAccountNumber(); String feeExpenseObjectCode = pmc.getFeeExpenseFinancialObjectCode(); String feeIncomeObjectCode = pmc.getFeeIncomeFinancialObjectCode(); KualiDecimal feeAmount = pmc.getFeeAmount(); // skip creation if the fee has been set to zero if (!KualiDecimal.ZERO.equals(feeAmount)) { // grab the explicit entry for the first accounting line and adjust for the foreign draft fee GeneralLedgerPendingEntry chargeEntry = new GeneralLedgerPendingEntry( document.getGeneralLedgerPendingEntry(0)); chargeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter()); // change the object code (expense to the department) chargeEntry.setFinancialObjectCode(feeExpenseObjectCode); chargeEntry .setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode()); chargeEntry.setTransactionLedgerEntryDescription( StringUtils.left("Automatic debit for " + pm.getPaymentMethodName() + " fee", 40)); chargeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL); // retrieve object type ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear( chargeEntry.getChartOfAccountsCode(), chargeEntry.getFinancialObjectCode()); if (objectCode == null) { LOG.fatal( "Specified offset object code: " + chargeEntry.getChartOfAccountsCode() + "-" + chargeEntry.getFinancialObjectCode() + " does not exist - failed to generate foreign draft fee entries", new RuntimeException()); return false; } chargeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode()); // Set the amount from the parameter chargeEntry.setTransactionLedgerEntryAmount(feeAmount); chargeEntry.setTransactionDebitCreditCode(reverseEntries ? GL_CREDIT_CODE : GL_DEBIT_CODE); document.addPendingEntry(chargeEntry); sequenceHelper.increment(); // handle the offset entry GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(chargeEntry); getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), chargeEntry, sequenceHelper, offsetEntry); document.addPendingEntry(offsetEntry); sequenceHelper.increment(); // Now, create the income entry in the AP Foreign draft fee account GeneralLedgerPendingEntry feeIncomeEntry = new GeneralLedgerPendingEntry( document.getGeneralLedgerPendingEntry(0)); feeIncomeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter()); feeIncomeEntry.setChartOfAccountsCode(feeIncomeChartCode); feeIncomeEntry.setAccountNumber(feeIncomeAccountNumber); feeIncomeEntry.setFinancialObjectCode(feeIncomeObjectCode); feeIncomeEntry .setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode()); feeIncomeEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber()); feeIncomeEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode()); // retrieve object type objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(feeIncomeChartCode, feeIncomeObjectCode); if (objectCode == null) { LOG.fatal( "Specified income object code: " + feeIncomeChartCode + "-" + feeIncomeObjectCode + " does not exist - failed to generate foreign draft income entries", new RuntimeException()); return false; } feeIncomeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode()); feeIncomeEntry.setTransactionLedgerEntryAmount(feeAmount); feeIncomeEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE); feeIncomeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL); document.addPendingEntry(feeIncomeEntry); sequenceHelper.increment(); // create the offset entry offsetEntry = new GeneralLedgerPendingEntry(feeIncomeEntry); getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), feeIncomeEntry, sequenceHelper, offsetEntry); document.addPendingEntry(offsetEntry); sequenceHelper.increment(); } return true; }
From source file:io.swagger.codegen.languages.SwiftCodegen.java
@Override public CodegenProperty fromProperty(String name, Property p) { CodegenProperty codegenProperty = super.fromProperty(name, p); if (codegenProperty.isEnum) { List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>(); List<String> values = (List<String>) codegenProperty.allowableValues.get("values"); for (String value : values) { Map<String, String> map = new HashMap<String, String>(); map.put("enum", toSwiftyEnumName(value)); map.put("raw", value); swiftEnums.add(map);/* w w w. j a v a 2 s .c om*/ } codegenProperty.allowableValues.put("values", swiftEnums); codegenProperty.datatypeWithEnum = StringUtils.left(codegenProperty.datatypeWithEnum, codegenProperty.datatypeWithEnum.length() - "Enum".length()); if (reservedWords.contains(codegenProperty.datatypeWithEnum)) { codegenProperty.datatypeWithEnum = escapeReservedWord(codegenProperty.datatypeWithEnum); } } return codegenProperty; }
From source file:ai.grakn.graql.internal.gremlin.GraqlTraversal.java
@Override public String toString() { return "{" + fragments.stream().map(list -> { StringBuilder sb = new StringBuilder(); String currentName = null; for (Fragment fragment : list) { if (!fragment.getStart().equals(currentName)) { if (currentName != null) sb.append(" "); sb.append("$").append(StringUtils.left(fragment.getStart(), 3)); currentName = fragment.getStart(); }/*w w w . ja v a 2 s .c o m*/ sb.append(fragment.getName()); Optional<String> end = fragment.getEnd(); if (end.isPresent()) { sb.append("$").append(StringUtils.left(end.get(), 3)); currentName = end.get(); } } return sb.toString(); }).collect(joining(", ")) + "}"; }
From source file:com.funambol.foundation.items.dao.PIMNoteDAO.java
public List getTwinItems(Note note) throws DAOException { if (log.isTraceEnabled()) { log.trace("PIMNoteDAO getTwinItems begin"); }//from w ww .ja v a 2 s. co m List twins = new ArrayList(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; if (!isTwinSearchAppliableOn(note)) { return twins; } try { // Looks up the data source when the first connection is created con = getUserDataSource().getRoutedConnection(userId); con.setReadOnly(true); // calculate crc String textDescription = note.getTextDescription().getPropertyValueAsString(); if (textDescription != null) { textDescription = textDescription.replace('\0', ' '); } String truncatedTextDescription = StringUtils.left(textDescription, SQL_TEXTDESCRIPTION_DIM); Long crc = calculateCrc(truncatedTextDescription); // // If funambol is not in the debug mode is not possible to print the // note because it contains sensitive data. // if (Configuration.getConfiguration().isDebugMode()) { if (log.isTraceEnabled()) { String tdSearch = (crc == null ? "<N/A>" : crc.toString()); StringBuilder sb = new StringBuilder(); sb.append("Looking for items having: ").append("\n> crc: '").append(tdSearch).append('\''); log.trace(sb.toString()); } } if (crc == null) { ps = con.prepareStatement(SQL_GET_NOTE_TWIN_ID_LIST_CRC_NULL + SQL_ORDER_BY_ID); } else { ps = con.prepareStatement(SQL_GET_NOTE_TWIN_ID_LIST + SQL_ORDER_BY_ID); ps.setLong(2, crc); } ps.setString(1, userId); rs = ps.executeQuery(); long twinId; while (rs.next()) { twinId = rs.getLong(1); // The id is the first // and only column if (log.isTraceEnabled()) { log.trace("Twin found: " + twinId); } twins.add(Long.toString(twinId)); } } catch (Exception e) { throw new DAOException("Error retrieving twin.", e); } finally { DBTools.close(con, ps, rs); } if (log.isTraceEnabled()) { log.trace("PIMNoteDAO getTwinItems end"); } return twins; }
From source file:com.evolveum.midpoint.repo.sql.util.RUtil.java
public static QName stringToQName(String text) { if (StringUtils.isEmpty(text)) { return null; }// w ww . jav a2s . co m int index = text.lastIndexOf(QNAME_DELIMITER); String namespace = StringUtils.left(text, index); String localPart = StringUtils.right(text, text.length() - index - 1); if (StringUtils.isEmpty(localPart)) { return null; } return new QName(namespace, localPart); }