Search in sources :

Example 1 with AccountingLineGroupDefinition

use of org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition in project cu-kfs by CU-CommunityApps.

the class FinancialSystemSearchableAttribute method getSearchingRows.

@Override
protected List<Row> getSearchingRows(String documentTypeName) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getSearchingRows( " + documentTypeName + " )");
        if (LOG.isTraceEnabled()) {
            LOG.trace("Stack Trace at point of call", new Throwable());
        }
    }
    DataDictionaryService ddService = SpringContext.getBean(DataDictionaryService.class);
    List<Row> docSearchRows = super.getSearchingRows(documentTypeName);
    // add account number search field when selected document type is COA
    if (StringUtils.isNotEmpty(documentTypeName)) {
        if (CUKFSConstants.COA_DOCUMENT_TYPE.equalsIgnoreCase(documentTypeName)) {
            Field accountField = FieldUtils.getPropertyField(Account.class, KFSPropertyConstants.ACCOUNT_NUMBER, true);
            accountField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            accountField.setColumnVisible(true);
            docSearchRows.add(new Row(Collections.singletonList(accountField)));
        }
    }
    DocumentEntry entry = ddService.getDataDictionary().getDocumentEntry(documentTypeName);
    if (entry != null) {
        Class<? extends Document> docClass = entry.getDocumentClass();
        if (AccountingDocument.class.isAssignableFrom(docClass)) {
            Map<String, AccountingLineGroupDefinition> alGroups = ((FinancialSystemTransactionalDocumentEntry) entry).getAccountingLineGroups();
            Class alClass = SourceAccountingLine.class;
            if (ObjectUtils.isNotNull(alGroups)) {
                if (alGroups.containsKey("source")) {
                    alClass = alGroups.get("source").getAccountingLineClass();
                }
            }
            BusinessObject alBusinessObject = null;
            try {
                alBusinessObject = (BusinessObject) alClass.newInstance();
            } catch (Exception cnfe) {
                throw new RuntimeException("Unable to instantiate accounting line class: " + alClass, cnfe);
            }
            Field chartField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, true);
            chartField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            chartField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartField, Collections.singletonList(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE));
            docSearchRows.add(new Row(Collections.singletonList(chartField)));
            Field orgField = FieldUtils.getPropertyField(Organization.class, KFSPropertyConstants.ORGANIZATION_CODE, true);
            orgField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            orgField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(new Account(), KFSPropertyConstants.ORGANIZATION_CODE, orgField, Collections.singletonList(KFSPropertyConstants.ORGANIZATION_CODE));
            docSearchRows.add(new Row(Collections.singletonList(orgField)));
            Field accountField = FieldUtils.getPropertyField(alClass, KFSPropertyConstants.ACCOUNT_NUMBER, true);
            accountField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            accountField.setColumnVisible(true);
            LookupUtils.setFieldQuickfinder(alBusinessObject, KFSPropertyConstants.ACCOUNT_NUMBER, accountField, Collections.singletonList(KFSPropertyConstants.ACCOUNT_NUMBER));
            docSearchRows.add(new Row(Collections.singletonList(accountField)));
        }
        boolean displayedLedgerPostingDoc = false;
        if (LaborLedgerPostingDocumentForSearching.class.isAssignableFrom(docClass)) {
            Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
            searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
            displayedLedgerPostingDoc = true;
        }
        if (GeneralLedgerPostingDocument.class.isAssignableFrom(docClass) && !displayedLedgerPostingDoc) {
            Field searchField = FieldUtils.getPropertyField(GeneralLedgerPendingEntry.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, true);
            searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_STRING);
            LookupUtils.setFieldQuickfinder(new GeneralLedgerPendingEntry(), KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, searchField, Collections.singletonList(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE));
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
        }
        if (AmountTotaling.class.isAssignableFrom(docClass)) {
            Field searchField = FieldUtils.getPropertyField(FinancialSystemDocumentHeader.class, KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, true);
            searchField.setFieldDataType(SearchableAttributeConstants.DATA_TYPE_FLOAT);
            docSearchRows.add(new Row(Collections.singletonList(searchField)));
        }
    }
    Row resultType = createSearchResultDisplayTypeRow();
    docSearchRows.add(resultType);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Returning Rows: " + docSearchRows);
    }
    return docSearchRows;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) BusinessObject(org.kuali.rice.krad.bo.BusinessObject) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) Field(org.kuali.kfs.kns.web.ui.Field) AccountingLineGroupDefinition(org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition) FinancialSystemTransactionalDocumentEntry(org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) FinancialSystemTransactionalDocumentEntry(org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry) DocumentEntry(org.kuali.kfs.krad.datadictionary.DocumentEntry) Row(org.kuali.kfs.kns.web.ui.Row)

Aggregations

Account (org.kuali.kfs.coa.businessobject.Account)1 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)1 Field (org.kuali.kfs.kns.web.ui.Field)1 Row (org.kuali.kfs.kns.web.ui.Row)1 DocumentEntry (org.kuali.kfs.krad.datadictionary.DocumentEntry)1 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1 GeneralLedgerPostingDocument (org.kuali.kfs.sys.document.GeneralLedgerPostingDocument)1 AccountingLineGroupDefinition (org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition)1 FinancialSystemTransactionalDocumentEntry (org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry)1 DocumentAttributeString (org.kuali.rice.kew.api.document.attribute.DocumentAttributeString)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1 BusinessObject (org.kuali.rice.krad.bo.BusinessObject)1