List of usage examples for org.apache.commons.lang StringUtils defaultIfEmpty
public static String defaultIfEmpty(String str, String defaultStr)
Returns either the passed in String, or if the String is empty or null
, the value of defaultStr
.
From source file:org.kuali.kfs.module.tem.document.CardApplicationDocumentBase.java
@Override public String getApplicationDocumentStatus() { String status = getDocumentHeader().getWorkflowDocument().getApplicationDocumentStatus(); return StringUtils.defaultIfEmpty(status, TemWorkflowConstants.RouteNodeNames.APPLICATION); }
From source file:org.kuali.ole.gl.businessobject.CollectorDetail.java
public void setFromFileForCollectorDetail(String detailLine, Map<String, String> accountRecordBalanceTypeMap, Date curDate, UniversityDate universityDate, int lineNumber, MessageMap messageMap) { try {// w ww . j a va 2 s . c o m final Map<String, Integer> pMap = getCollectorDetailFieldUtil().getFieldBeginningPositionMap(); detailLine = org.apache.commons.lang.StringUtils.rightPad(detailLine, GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length(), ' '); setCreateDate(curDate); if (!GeneralLedgerConstants.getSpaceUniversityFiscalYear() .equals(detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)))) { try { setUniversityFiscalYear( new Integer(getValue(detailLine, pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)))); } catch (NumberFormatException e) { messageMap.putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.ERROR_CUSTOM, "Collector detail university fiscal year " + lineNumber + " string " + detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE))); setUniversityFiscalYear(null); } } else { setUniversityFiscalYear(null); } if (!GeneralLedgerConstants.getSpaceChartOfAccountsCode() .equals(detailLine.substring(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)))) setChartOfAccountsCode(getValue(detailLine, pMap.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE), pMap.get(OLEPropertyConstants.ACCOUNT_NUMBER))); else setChartOfAccountsCode(GeneralLedgerConstants.getSpaceChartOfAccountsCode()); setAccountNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.ACCOUNT_NUMBER), pMap.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER))); // if chart code is empty while accounts cannot cross charts, then derive chart code from account number AccountService acctserv = SpringContext.getBean(AccountService.class); if (StringUtils.isEmpty(getChartOfAccountsCode()) && StringUtils.isNotEmpty(getAccountNumber()) && !acctserv.accountsCanCrossCharts()) { Account account = acctserv.getUniqueAccountForAccountNumber(getAccountNumber()); if (account != null) { setChartOfAccountsCode(account.getChartOfAccountsCode()); } } setSubAccountNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER), pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_CODE))); setFinancialObjectCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE))); setFinancialSubObjectCode(getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE))); // We are in Collector Detail for ID Billing Details because the value from file positions 26, 27 = DT. We don not want to set Financial Balance Type Code to detail type code (DT) // Generate the account record key to retrieve the balance type from the map which contains the balance type from the accounting record/origin entry String accountRecordKey = generateAccountRecordBalanceTypeKey(); String financialBalanceTypeCode = accountRecordBalanceTypeMap.get(accountRecordKey); // Default to "AC" if we do not find account record key record from the map setFinancialBalanceTypeCode(StringUtils.defaultIfEmpty(financialBalanceTypeCode, GeneralLedgerConstants.FINALNCIAL_BALANCE_TYPE_FOR_COLLECTOR_DETAIL_RECORD)); setFinancialObjectTypeCode( getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER))); setUniversityFiscalPeriodCode(universityDate.getUniversityFiscalAccountingPeriod()); setCollectorDetailSequenceNumber( getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER), pMap.get(OLEPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE))); setFinancialDocumentTypeCode( getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE), pMap.get(OLEPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE))); setFinancialSystemOriginationCode( getValue(detailLine, pMap.get(OLEPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE), pMap.get(OLEPropertyConstants.DOCUMENT_NUMBER))); setDocumentNumber(getValue(detailLine, pMap.get(OLEPropertyConstants.DOCUMENT_NUMBER), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT))); try { setCollectorDetailItemAmount( getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE))); } catch (NumberFormatException e) { setCollectorDetailItemAmount(KualiDecimal.ZERO); messageMap.putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.ERROR_CUSTOM, "Collector detail amount cannot be parsed on line " + lineNumber + " amount string " + detailLine.substring(pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(OLEPropertyConstants.GL_CREDIT_CODE))); } if (OLEConstants.GL_CREDIT_CODE.equalsIgnoreCase( getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE), pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT)))) { setCollectorDetailItemAmount(getCollectorDetailItemAmount().negated()); } setCollectorDetailNoteText( getValue(detailLine, pMap.get(OLEPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT), GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length())); if (org.apache.commons.lang.StringUtils.isEmpty(getSubAccountNumber())) { setSubAccountNumber(OLEConstants.getDashSubAccountNumber()); } if (org.apache.commons.lang.StringUtils.isEmpty(getFinancialSubObjectCode())) { setFinancialSubObjectCode(OLEConstants.getDashFinancialSubObjectCode()); } if (org.apache.commons.lang.StringUtils.isEmpty(getCollectorDetailSequenceNumber())) { setCollectorDetailSequenceNumber(" "); } } catch (Exception e) { throw new RuntimeException(e + " occurred in CollectorDetail.setFromFileForCollectorDetail()"); } }
From source file:org.kuali.ole.module.purap.service.impl.PdpExtractServiceImpl.java
/** * Add accounts to a PDP Payment Detail//from ww w . ja va 2 s .c o m * * @param accountsPayableDocument * @param paymentDetail * @param documentType */ protected void addAccounts(AccountsPayableDocument accountsPayableDocument, PaymentDetail paymentDetail, String documentType) { String creditMemoDocType = getDataDictionaryService() .getDocumentTypeNameByClass(VendorCreditMemoDocument.class); List<SourceAccountingLine> sourceAccountingLines = purapAccountingService .generateSourceAccountsForVendorRemit(accountsPayableDocument); for (SourceAccountingLine sourceAccountingLine : sourceAccountingLines) { KualiDecimal lineAmount = sourceAccountingLine.getAmount(); PaymentAccountDetail paymentAccountDetail = new PaymentAccountDetail(); paymentAccountDetail.setAccountNbr(sourceAccountingLine.getAccountNumber()); if (creditMemoDocType.equals(documentType)) { lineAmount = lineAmount.negated(); } paymentAccountDetail.setAccountNetAmount(sourceAccountingLine.getAmount()); paymentAccountDetail.setFinChartCode(sourceAccountingLine.getChartOfAccountsCode()); paymentAccountDetail.setFinObjectCode(sourceAccountingLine.getFinancialObjectCode()); paymentAccountDetail.setFinSubObjectCode( StringUtils.defaultIfEmpty(sourceAccountingLine.getFinancialSubObjectCode(), OLEConstants.getDashFinancialSubObjectCode())); paymentAccountDetail.setOrgReferenceId(sourceAccountingLine.getOrganizationReferenceId()); paymentAccountDetail.setProjectCode(StringUtils.defaultIfEmpty(sourceAccountingLine.getProjectCode(), OLEConstants.getDashProjectCode())); paymentAccountDetail.setSubAccountNbr(StringUtils.defaultIfEmpty( sourceAccountingLine.getSubAccountNumber(), OLEConstants.getDashSubAccountNumber())); paymentDetail.addAccountDetail(paymentAccountDetail); } }
From source file:org.kuali.student.cm.course.form.wrapper.ActivityInfoWrapper.java
/** * Reference only at KRAD markup xml/*from ww w.j a va2s . co m*/ * @return */ @SuppressWarnings("unused") public String getContactHours() { return StringUtils.defaultIfEmpty(contactHours, ""); }
From source file:org.kuali.student.cm.course.form.wrapper.ActivityInfoWrapper.java
/** * Reference only at KRAD markup xml/*ww w. ja v a2 s . co m*/ * @return */ @SuppressWarnings("unused") public String getDurationCount() { return StringUtils.defaultIfEmpty(durationCount, ""); }
From source file:org.kuali.student.enrollment.class2.courseoffering.controller.TestStatePropagationController.java
private void populateFormWithTargetSocInfo(TestStatePropagationForm form) { try {/*from w w w. j av a2 s . c o m*/ ContextInfo contextInfo = new ContextInfo(); String targetTermId = StringUtils.defaultIfEmpty(form.getTermCodeForSocStateChange(), CHANGE_SOC_STATE_DEFAULT_TERM); SocInfo targetSocInfo = getTargetSocInfoForTerm(targetTermId, contextInfo); TermInfo targetTermInfo = this.getAcalService().getTerm(targetSocInfo.getTermId(), contextInfo); form.setTermCodeForSocStateChange(targetTermInfo.getCode()); form.setNewSocStateForSocStateChange(targetSocInfo.getStateKey()); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingManagementViewHelperServiceImpl.java
private void blockUserIfSocStateIs(CourseOfferingManagementForm form, String socStateKeyToBlockUserOn, String errorMessageKey) { errorMessageKey = StringUtils.defaultIfEmpty(errorMessageKey, ManageSocConstants.MessageKeys.ERROR_CANNOT_ACCESS_COURSE_OFFERING_WHILE_SOC_INVALID_STATE_DEFAULT); if (StringUtils.equalsIgnoreCase(form.getSocStateKey(), socStateKeyToBlockUserOn)) { GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, errorMessageKey); }//from w w w .jav a2 s .co m }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingManagementViewHelperServiceImpl.java
private void setRoomNameOnAoWrapper(ScheduleRequestCalcContainer sched, ActivityOfferingWrapper aoWrapper, boolean newline, String cssStyle) { if (sched.getRooms() == null || sched.getRooms().isEmpty()) { aoWrapper.setRoomName(StringUtils.EMPTY, newline, cssStyle); return;/*w w w. j ava 2s.c o m*/ } for (RoomInfo room : sched.getRooms()) { String roomName = StringUtils.defaultIfEmpty(room.getRoomCode(), StringUtils.EMPTY); aoWrapper.setRoomName(roomName, newline, cssStyle); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingManagementViewHelperServiceImpl.java
private void setBuildingNameAndCodeOnAoWrapper(ScheduleRequestCalcContainer sched, ActivityOfferingWrapper aoWrapper, boolean newline, String cssStyle) { if (sched.getBldgs() == null || sched.getBldgs().isEmpty()) { aoWrapper.setBuildingName(StringUtils.EMPTY, newline, cssStyle); aoWrapper.setBuildingCode(StringUtils.EMPTY, newline, cssStyle); aoWrapper.setBldgCodeSimple(StringUtils.EMPTY); return;/* ww w . ja v a 2s . co m*/ } for (BuildingInfo bldg : sched.getBldgs()) { String bldgName = StringUtils.defaultIfEmpty(bldg.getName(), StringUtils.EMPTY); String bldgCode = StringUtils.defaultIfEmpty(bldg.getBuildingCode(), StringUtils.EMPTY); aoWrapper.setBuildingName(bldgName, newline, "uif-scheduled-dl"); aoWrapper.setBuildingCode(bldgCode, newline, "uif-scheduled-dl"); aoWrapper.setBldgCodeSimple(bldgCode, bldgName, "uif-scheduled-dl"); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingViewHelperUtil.java
public static List<CourseOfferingInfo> loadCourseOfferings(SearchRequestInfo searchRequest) throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException {//from w w w .jav a2 s .c om List<CourseOfferingInfo> result = new ArrayList<CourseOfferingInfo>(); ContextInfo contextInfo = new ContextInfo(); SearchResultInfo searchResult = CourseOfferingManagementUtil.getSearchService().search(searchRequest, contextInfo); for (SearchResultRowInfo row : searchResult.getRows()) { CourseOfferingInfo courseOfferingInfo = new CourseOfferingInfo(); for (SearchResultCellInfo cellInfo : row.getCells()) { String value = StringUtils.defaultIfEmpty(cellInfo.getValue(), StringUtils.EMPTY); if (CourseOfferingManagementSearchImpl.SearchResultColumns.CODE.equals(cellInfo.getKey())) { courseOfferingInfo.setCourseOfferingCode(value); } else if (CourseOfferingManagementSearchImpl.SearchResultColumns.CO_ID.equals(cellInfo.getKey())) { courseOfferingInfo.setId(value); } } result.add(courseOfferingInfo); } return result; }