use of org.kuali.kfs.kns.service.DataDictionaryService 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;
}
use of org.kuali.kfs.kns.service.DataDictionaryService in project cu-kfs by CU-CommunityApps.
the class ScrubberValidatorImpl method validateSubAccount.
/**
* Validates the sub account of the origin entry
*
* @param originEntry the origin entry being scrubbed
* @param workingEntry the scrubbed version of the origin entry
* @return a Message if an error was encountered, otherwise null
*/
protected Message validateSubAccount(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
LOG.debug("validateSubAccount() started");
// when continuationAccount used, the subAccountNumber should be changed to dashes and skip validation subAccount process
if (continuationAccountIndicator) {
workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
return null;
}
// If the sub account number is empty, set it to dashes.
// Otherwise set the workingEntry sub account number to the
// sub account number of the input origin entry.
String subAccount = originEntry.getSubAccountNumber();
if (StringUtils.hasText(subAccount)) {
// sub account IS specified
// check if need upper case
DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
// uppercase the data used to generate the collector header
if (dataDictionaryService.getAttributeForceUppercase(SubAccount.class, KFSPropertyConstants.SUB_ACCOUNT_NUMBER)) {
subAccount = originEntry.getSubAccountNumber().toUpperCase();
}
if (!KFSConstants.getDashSubAccountNumber().equals(subAccount)) {
SubAccount originEntrySubAccount = accountingCycleCachingService.getSubAccount(originEntry.getChartOfAccountsCode(), originEntry.getAccountNumber(), subAccount);
// SubAccount originEntrySubAccount = getSubAccount(originEntry);
if (originEntrySubAccount == null) {
// sub account does not exist
int messageType = Message.TYPE_FATAL;
if (isAssetRecoveryGlobalOrTransfer(originEntry)) {
// Not fatal: We want to remove the invalid subAccountNumber and post it
messageType = Message.TYPE_WARNING;
originEntry.setSubAccountNumber(null);
workingEntry.setSubAccountNumber(null);
}
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_FOUND, originEntry.getChartOfAccountsCode() + "-" + originEntry.getAccountNumber() + "-" + subAccount, messageType);
} else {
// sub account IS valid
if (originEntrySubAccount.isActive()) {
// sub account IS active
workingEntry.setSubAccountNumber(subAccount);
} else {
// sub account IS NOT active
if (parameterService.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, KFSConstants.SystemGroupParameterNames.GL_ANNUAL_CLOSING_DOC_TYPE).equals(originEntry.getFinancialDocumentTypeCode())) {
// document IS annual closing
workingEntry.setSubAccountNumber(subAccount);
} else {
// sub account not active
int messageType = Message.TYPE_FATAL;
if (isAssetRecoveryGlobalOrTransfer(originEntry)) {
// Not fatal: We want to remove the invalid subAccountNumber and post it
messageType = Message.TYPE_WARNING;
originEntry.setSubAccountNumber(null);
workingEntry.setSubAccountNumber(null);
}
// document is NOT annual closing
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_ACTIVE, originEntry.getChartOfAccountsCode() + "-" + originEntry.getAccountNumber() + "-" + subAccount, messageType);
}
}
}
} else {
// the sub account is dashes
workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
}
} else {
// No sub account is specified.
workingEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
}
return null;
}
use of org.kuali.kfs.kns.service.DataDictionaryService in project cu-kfs by CU-CommunityApps.
the class CuCreditMemoServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
accountsPayableService = EasyMock.createNiceMock(AccountsPayableService.class);
EasyMock.expect(accountsPayableService.getExpiredOrClosedAccountList(creditMemoDocument)).andReturn(new HashMap<>());
EasyMock.replay(accountsPayableService);
dataDictionaryService = EasyMock.createNiceMock(DataDictionaryService.class);
EasyMock.expect(dataDictionaryService.getAttributeMaxLength(DocumentHeader.class, KRADPropertyConstants.DOCUMENT_DESCRIPTION)).andReturn(200);
EasyMock.replay(dataDictionaryService);
dateTimeService = new DateTimeServiceImpl();
documentService = new MockDocumentServiceImpl();
noteService = EasyMock.createMock(NoteService.class);
purapService = EasyMock.createMock(PurapService.class);
vendorService = new MockVendorServiceImpl();
creditMemoServiceImpl = PowerMock.createPartialMock(CuCreditMemoServiceImplTest.TestCuCreditMemoServiceImpl.class, "reIndexDocument", "getCreditMemoDocumentById");
creditMemoServiceImpl.setDocumentService(documentService);
creditMemoServiceImpl.setNoteService(noteService);
creditMemoServiceImpl.setPurapService(purapService);
creditMemoServiceImpl.setAccountsPayableService(accountsPayableService);
creditMemoServiceImpl.setVendorService(vendorService);
creditMemoServiceImpl.setDataDictionaryService(dataDictionaryService);
creditMemoDocument = setupVendorCreditMemoDocument();
mo14Person = MockPersonUtil.createMockPerson(UserNameFixture.mo14);
mo14Session = MockPersonUtil.createMockUserSession(mo14Person);
GlobalVariables.setUserSession(mo14Session);
}
use of org.kuali.kfs.kns.service.DataDictionaryService in project cu-kfs by CU-CommunityApps.
the class CUFinancialSystemDocumentServiceImpl method getDocumentAuthorizer.
protected FinancialSystemTransactionalDocumentAuthorizerBase getDocumentAuthorizer(Document doc) {
DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
final String docTypeName = dataDictionaryService.getDocumentTypeNameByClass(doc.getClass());
Class<? extends DocumentAuthorizer> documentAuthorizerClass = (Class<? extends DocumentAuthorizer>) dataDictionaryService.getDataDictionary().getDocumentEntry(docTypeName).getDocumentAuthorizerClass();
FinancialSystemTransactionalDocumentAuthorizerBase documentAuthorizer = null;
try {
documentAuthorizer = (FinancialSystemTransactionalDocumentAuthorizerBase) documentAuthorizerClass.newInstance();
} catch (InstantiationException ie) {
throw new RuntimeException("Could not construct document authorizer: " + documentAuthorizerClass.getName(), ie);
} catch (IllegalAccessException iae) {
throw new RuntimeException("Could not construct document authorizer: " + documentAuthorizerClass.getName(), iae);
}
return documentAuthorizer;
}
Aggregations