use of org.kuali.kfs.kew.doctype.bo.DocumentType in project cu-kfs by CU-CommunityApps.
the class AccountingLineRuleHelperServiceImpl method getAccountingLineValidationErrors.
@Override
public List<AccountingLineValidationError> getAccountingLineValidationErrors(AccountingLine accountingLine, boolean useShortMessages) {
List<AccountingLineValidationError> validationErrors = new ArrayList<>();
// CORNELL FIX:
if (ObjectUtils.isNull(accountingLine)) {
return validationErrors;
}
// get the accounting line sequence string to identify which line has error.
String accountIdentifyingPropertyName = getAccountIdentifyingPropertyName(accountingLine);
// retrieve accounting line objects to validate
Chart chart = accountingLine.getChart();
Account account = accountingLine.getAccount();
ObjectCode objectCode = accountingLine.getObjectCode();
validationErrors.addAll(getChartValidationErrors(chart, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, accountIdentifyingPropertyName, useShortMessages));
validationErrors.addAll(getAccountValidationErrors(account, KFSPropertyConstants.ACCOUNT_NUMBER, accountIdentifyingPropertyName, useShortMessages));
// sub account is not required
if (StringUtils.isNotBlank(accountingLine.getSubAccountNumber()) && !accountingLine.getSubAccountNumber().equals(KFSConstants.getDashSubAccountNumber())) {
SubAccount subAccount = accountingLine.getSubAccount();
validationErrors.addAll(getSubAccountValidationErrors(subAccount, KFSPropertyConstants.SUB_ACCOUNT_NUMBER, accountIdentifyingPropertyName, useShortMessages));
}
validationErrors.addAll(getObjectCodeValidationErrors(objectCode, KFSPropertyConstants.FINANCIAL_OBJECT_CODE, accountIdentifyingPropertyName, useShortMessages));
// sub object is not required
if (StringUtils.isNotBlank(accountingLine.getFinancialSubObjectCode())) {
SubObjectCode subObjectCode = accountingLine.getSubObjectCode();
validationErrors.addAll(getSubObjectCodeValidationErrors(subObjectCode, KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, accountIdentifyingPropertyName, useShortMessages));
}
// project code is not required
if (StringUtils.isNotBlank(accountingLine.getProjectCode())) {
ProjectCode projectCode = accountingLine.getProject();
validationErrors.addAll(getProjectCodeValidationErrors(projectCode, KFSConstants.PROJECT_CODE_PROPERTY_NAME, accountIdentifyingPropertyName, useShortMessages));
}
if (StringUtils.isNotBlank(accountingLine.getReferenceOriginCode())) {
OriginationCode referenceOrigin = accountingLine.getReferenceOrigin();
validationErrors.addAll(getReferenceOriginCodeValidationErrors(accountIdentifyingPropertyName, referenceOrigin, useShortMessages));
}
if (StringUtils.isNotBlank(accountingLine.getReferenceTypeCode())) {
DocumentType referenceType = accountingLine.getReferenceFinancialSystemDocumentType();
validationErrors.addAll(getReferenceTypeCodeValidationErrors(accountingLine.getReferenceTypeCode(), referenceType, accountIdentifyingPropertyName, useShortMessages));
}
return validationErrors;
}
use of org.kuali.kfs.kew.doctype.bo.DocumentType in project cu-kfs by CU-CommunityApps.
the class CuPdpExtractServiceImpl method updatePaymentRequest.
@Override
protected void updatePaymentRequest(PaymentRequestDocument paymentRequestDocument, Person puser, Date processRunDate) {
try {
PaymentRequestDocument doc = (PaymentRequestDocument) documentService.getByDocumentHeaderId(paymentRequestDocument.getDocumentNumber());
doc.setExtractedTimestamp(new Timestamp(processRunDate.getTime()));
getPurapService().saveDocumentNoValidation(doc);
DocumentType documentType = documentTypeService.getDocumentTypeByName(doc.getFinancialDocumentTypeCode());
DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue();
queue.indexDocument(doc.getDocumentNumber());
} catch (WorkflowException e) {
throw new IllegalArgumentException("Unable to retrieve payment request: " + paymentRequestDocument.getDocumentNumber());
}
}
use of org.kuali.kfs.kew.doctype.bo.DocumentType in project cu-kfs by CU-CommunityApps.
the class CuAutoDisapproveDocumentsServiceImpl method getYearEndAutoDisapproveParentDocumentTypes.
/**
* Gets the year end auto disapprove parent document types.
* @return Returns the parentDocumentTypes.
*/
protected List<DocumentType> getYearEndAutoDisapproveParentDocumentTypes() {
List<DocumentType> parentDocumentTypes = new ArrayList<DocumentType>();
Collection<String> documentTypeCodes = getParameterService().getParameterValuesAsString(AutoDisapproveDocumentsStep.class, KFSParameterKeyConstants.YearEndAutoDisapprovalConstants.YEAR_END_AUTO_DISAPPROVE_PARENT_DOCUMENT_TYPE);
for (String documentTypeCode : documentTypeCodes) {
DocumentType parentDocumentType = (DocumentType) documentTypeService.getDocumentTypeByName(documentTypeCode);
if (ObjectUtils.isNotNull(parentDocumentType)) {
parentDocumentTypes.add(parentDocumentType);
}
}
return parentDocumentTypes;
}
use of org.kuali.kfs.kew.doctype.bo.DocumentType in project cu-kfs by CU-CommunityApps.
the class ActionListDAOOjbImpl method setUpActionListCriteria.
private Criteria setUpActionListCriteria(String principalId, ActionListFilter filter) {
LOG.debug("setting up Action List criteria");
Criteria criteria = new Criteria();
boolean filterOn = false;
String filteredByItems = "";
if (filter.getActionRequestCd() != null && !"".equals(filter.getActionRequestCd().trim()) && !filter.getActionRequestCd().equals(KewApiConstants.ALL_CODE)) {
if (filter.isExcludeActionRequestCd()) {
criteria.addNotEqualTo("actionRequestCd", filter.getActionRequestCd());
} else {
criteria.addEqualTo("actionRequestCd", filter.getActionRequestCd());
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Action Requested";
}
if (filter.getCreateDateFrom() != null || filter.getCreateDateTo() != null) {
if (filter.isExcludeCreateDate()) {
if (filter.getCreateDateFrom() != null && filter.getCreateDateTo() != null) {
criteria.addNotBetween("routeHeader.createDate", new Timestamp(beginningOfDay(filter.getCreateDateFrom()).getTime()), new Timestamp(endOfDay(filter.getCreateDateTo()).getTime()));
} else if (filter.getCreateDateFrom() != null && filter.getCreateDateTo() == null) {
criteria.addLessOrEqualThan("routeHeader.createDate", new Timestamp(beginningOfDay(filter.getCreateDateFrom()).getTime()));
} else if (filter.getCreateDateFrom() == null && filter.getCreateDateTo() != null) {
criteria.addGreaterOrEqualThan("routeHeader.createDate", new Timestamp(endOfDay(filter.getCreateDateTo()).getTime()));
}
} else {
if (filter.getCreateDateFrom() != null && filter.getCreateDateTo() != null) {
criteria.addBetween("routeHeader.createDate", new Timestamp(beginningOfDay(filter.getCreateDateFrom()).getTime()), new Timestamp(endOfDay(filter.getCreateDateTo()).getTime()));
} else if (filter.getCreateDateFrom() != null && filter.getCreateDateTo() == null) {
criteria.addGreaterOrEqualThan("routeHeader.createDate", new Timestamp(beginningOfDay(filter.getCreateDateFrom()).getTime()));
} else if (filter.getCreateDateFrom() == null && filter.getCreateDateTo() != null) {
criteria.addLessOrEqualThan("routeHeader.createDate", new Timestamp(endOfDay(filter.getCreateDateTo()).getTime()));
}
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Date Created";
}
if (filter.getDocRouteStatus() != null && !"".equals(filter.getDocRouteStatus().trim()) && !filter.getDocRouteStatus().equals(KewApiConstants.ALL_CODE)) {
if (filter.isExcludeRouteStatus()) {
criteria.addNotEqualTo("routeHeader.docRouteStatus", filter.getDocRouteStatus());
} else {
criteria.addEqualTo("routeHeader.docRouteStatus", filter.getDocRouteStatus());
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Document Route Status";
}
if (filter.getDocumentTitle() != null && !"".equals(filter.getDocumentTitle().trim())) {
String docTitle = filter.getDocumentTitle();
if (docTitle.trim().endsWith("*")) {
docTitle = docTitle.substring(0, docTitle.length() - 1);
}
if (filter.isExcludeDocumentTitle()) {
criteria.addNotLike("docTitle", "%" + docTitle + "%");
} else {
criteria.addLike("docTitle", "%" + docTitle + "%");
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Document Title";
}
if (filter.getDocumentType() != null && !"".equals(filter.getDocumentType().trim())) {
if (filter.isExcludeDocumentType()) {
criteria.addNotLike("docName", "%" + filter.getDocumentType() + "%");
} else {
String documentTypeName = filter.getDocumentType();
DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName(documentTypeName);
if (documentType == null) {
criteria.addLike("docName", "%" + filter.getDocumentType() + "%");
} else {
// search this document type plus it's children
Criteria docTypeCrit = new Criteria();
constructDocumentTypeCriteria(docTypeCrit, documentType);
criteria.addAndCriteria(docTypeCrit);
}
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Document Type";
}
if (filter.getLastAssignedDateFrom() != null || filter.getLastAssignedDateTo() != null) {
if (filter.isExcludeLastAssignedDate()) {
if (filter.getLastAssignedDateFrom() != null && filter.getLastAssignedDateTo() != null) {
criteria.addNotBetween("dateAssigned", new Timestamp(beginningOfDay(filter.getLastAssignedDateFrom()).getTime()), new Timestamp(endOfDay(filter.getLastAssignedDateTo()).getTime()));
} else if (filter.getLastAssignedDateFrom() != null && filter.getLastAssignedDateTo() == null) {
criteria.addLessOrEqualThan("dateAssigned", new Timestamp(beginningOfDay(filter.getLastAssignedDateFrom()).getTime()));
} else if (filter.getLastAssignedDateFrom() == null && filter.getLastAssignedDateTo() != null) {
criteria.addGreaterOrEqualThan("dateAssigned", new Timestamp(endOfDay(filter.getLastAssignedDateTo()).getTime()));
}
} else {
if (filter.getLastAssignedDateFrom() != null && filter.getLastAssignedDateTo() != null) {
criteria.addBetween("dateAssigned", new Timestamp(beginningOfDay(filter.getLastAssignedDateFrom()).getTime()), new Timestamp(endOfDay(filter.getLastAssignedDateTo()).getTime()));
} else if (filter.getLastAssignedDateFrom() != null && filter.getLastAssignedDateTo() == null) {
criteria.addGreaterOrEqualThan("dateAssigned", new Timestamp(beginningOfDay(filter.getLastAssignedDateFrom()).getTime()));
} else if (filter.getLastAssignedDateFrom() == null && filter.getLastAssignedDateTo() != null) {
criteria.addLessOrEqualThan("dateAssigned", new Timestamp(endOfDay(filter.getLastAssignedDateTo()).getTime()));
}
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Date Last Assigned";
}
// CU customization: Logic for filtering by last modified date
if (filter.getLastModifiedDateFrom() != null || filter.getLastModifiedDateTo() != null) {
if (filter.isExcludeLastModifiedDate()) {
if (filter.getLastModifiedDateFrom() != null && filter.getLastModifiedDateTo() != null) {
criteria.addNotBetween("routeHeader.dateModified", new Timestamp(beginningOfDay(filter.getLastModifiedDateFrom()).getTime()), new Timestamp(endOfDay(filter.getLastModifiedDateTo()).getTime()));
} else if (filter.getLastModifiedDateFrom() != null && filter.getLastModifiedDateTo() == null) {
criteria.addLessOrEqualThan("routeHeader.dateModified", new Timestamp(beginningOfDay(filter.getLastModifiedDateFrom()).getTime()));
} else if (filter.getLastAssignedDateFrom() == null && filter.getLastModifiedDateTo() != null) {
criteria.addGreaterOrEqualThan("routeHeader.dateModified", new Timestamp(endOfDay(filter.getLastModifiedDateTo()).getTime()));
}
} else {
if (filter.getLastModifiedDateFrom() != null && filter.getLastModifiedDateTo() != null) {
criteria.addBetween("routeHeader.dateModified", new Timestamp(beginningOfDay(filter.getLastModifiedDateFrom()).getTime()), new Timestamp(endOfDay(filter.getLastModifiedDateTo()).getTime()));
} else if (filter.getLastModifiedDateFrom() != null && filter.getLastModifiedDateTo() == null) {
criteria.addGreaterOrEqualThan("routeHeader.dateModified", new Timestamp(beginningOfDay(filter.getLastModifiedDateFrom()).getTime()));
} else if (filter.getLastModifiedDateFrom() == null && filter.getLastModifiedDateTo() != null) {
criteria.addLessOrEqualThan("routeHeader.dateModified", new Timestamp(endOfDay(filter.getLastModifiedDateTo()).getTime()));
}
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Date Last Modified";
}
filter.setGroupId(null);
if (filter.getGroupIdString() != null && !"".equals(filter.getGroupIdString().trim()) && !filter.getGroupIdString().trim().equals(KewApiConstants.NO_FILTERING)) {
filter.setGroupId(filter.getGroupIdString().trim());
if (filter.isExcludeGroupId()) {
Criteria critNotEqual = new Criteria();
critNotEqual.addNotEqualTo("groupId", filter.getGroupId());
Criteria critNull = new Criteria();
critNull.addIsNull("groupId");
critNotEqual.addOrCriteria(critNull);
criteria.addAndCriteria(critNotEqual);
} else {
criteria.addEqualTo("groupId", filter.getGroupId());
}
filteredByItems += filteredByItems.length() > 0 ? ", " : "";
filteredByItems += "Action Request Workgroup";
}
if (filteredByItems.length() > 0) {
filterOn = true;
}
boolean addedDelegationCriteria = false;
if (StringUtils.isBlank(filter.getDelegationType()) && StringUtils.isBlank(filter.getPrimaryDelegateId()) && StringUtils.isBlank(filter.getDelegatorId())) {
criteria.addEqualTo("principalId", principalId);
addedDelegationCriteria = true;
} else if ((StringUtils.isNotBlank(filter.getDelegationType()) && DelegationType.PRIMARY.getCode().equals(filter.getDelegationType())) || StringUtils.isNotBlank(filter.getPrimaryDelegateId())) {
// using a primary delegation
if ((StringUtils.isBlank(filter.getPrimaryDelegateId())) || (filter.getPrimaryDelegateId().trim().equals(KewApiConstants.ALL_CODE))) {
// user wishes to see all primary delegations
Criteria userCrit = new Criteria();
Criteria groupCrit = new Criteria();
Criteria orCrit = new Criteria();
userCrit.addEqualTo("delegatorPrincipalId", principalId);
List<String> delegatorGroupIds = KimApiServiceLocator.getGroupService().getGroupIdsByPrincipalId(principalId);
if (delegatorGroupIds != null && !delegatorGroupIds.isEmpty()) {
groupCrit.addIn("delegatorGroupId", delegatorGroupIds);
}
orCrit.addOrCriteria(userCrit);
orCrit.addOrCriteria(groupCrit);
criteria.addAndCriteria(orCrit);
criteria.addEqualTo("delegationType", DelegationType.PRIMARY.getCode());
filter.setDelegationType(DelegationType.PRIMARY.getCode());
filter.setExcludeDelegationType(false);
addToFilterDescription(filteredByItems, "Primary Delegator Id");
addedDelegationCriteria = true;
filterOn = true;
} else if (!filter.getPrimaryDelegateId().trim().equals(KewApiConstants.PRIMARY_DELEGATION_DEFAULT)) {
// user wishes to see primary delegation for a single user
criteria.addEqualTo("principalId", filter.getPrimaryDelegateId());
Criteria userCrit = new Criteria();
Criteria groupCrit = new Criteria();
Criteria orCrit = new Criteria();
userCrit.addEqualTo("delegatorPrincipalId", principalId);
List<String> delegatorGroupIds = KimApiServiceLocator.getGroupService().getGroupIdsByPrincipalId(principalId);
if (delegatorGroupIds != null && !delegatorGroupIds.isEmpty()) {
groupCrit.addIn("delegatorGroupId", delegatorGroupIds);
}
orCrit.addOrCriteria(userCrit);
orCrit.addOrCriteria(groupCrit);
criteria.addAndCriteria(orCrit);
criteria.addEqualTo("delegationType", DelegationType.PRIMARY.getCode());
filter.setDelegationType(DelegationType.PRIMARY.getCode());
filter.setExcludeDelegationType(false);
addToFilterDescription(filteredByItems, "Primary Delegator Id");
addedDelegationCriteria = true;
filterOn = true;
}
}
if (!addedDelegationCriteria && ((StringUtils.isNotBlank(filter.getDelegationType()) && DelegationType.SECONDARY.getCode().equals(filter.getDelegationType())) || StringUtils.isNotBlank(filter.getDelegatorId()))) {
// using a secondary delegation
criteria.addEqualTo("principalId", principalId);
if (StringUtils.isBlank(filter.getDelegatorId())) {
filter.setDelegationType(DelegationType.SECONDARY.getCode());
// method
if (!filter.isExcludeDelegationType()) {
criteria.addEqualTo("delegationType", DelegationType.SECONDARY.getCode());
addToFilterDescription(filteredByItems, "Secondary Delegator Id");
addedDelegationCriteria = true;
filterOn = true;
}
} else if (filter.getDelegatorId().trim().equals(KewApiConstants.ALL_CODE)) {
// user wishes to see all secondary delegations
criteria.addEqualTo("delegationType", DelegationType.SECONDARY.getCode());
filter.setDelegationType(DelegationType.SECONDARY.getCode());
filter.setExcludeDelegationType(false);
addToFilterDescription(filteredByItems, "Secondary Delegator Id");
addedDelegationCriteria = true;
filterOn = true;
} else if (!filter.getDelegatorId().trim().equals(KewApiConstants.DELEGATION_DEFAULT)) {
// user has specified an id to see for secondary delegation
filter.setDelegationType(DelegationType.SECONDARY.getCode());
filter.setExcludeDelegationType(false);
Criteria userCrit = new Criteria();
Criteria groupCrit = new Criteria();
if (filter.isExcludeDelegatorId()) {
Criteria userNull = new Criteria();
userCrit.addNotEqualTo("delegatorPrincipalId", filter.getDelegatorId());
userNull.addIsNull("delegatorPrincipalId");
userCrit.addOrCriteria(userNull);
Criteria groupNull = new Criteria();
groupCrit.addNotEqualTo("delegatorGroupId", filter.getDelegatorId());
groupNull.addIsNull("delegatorGroupId");
groupCrit.addOrCriteria(groupNull);
criteria.addAndCriteria(userCrit);
criteria.addAndCriteria(groupCrit);
} else {
Criteria orCrit = new Criteria();
userCrit.addEqualTo("delegatorPrincipalId", filter.getDelegatorId());
groupCrit.addEqualTo("delegatorGroupId", filter.getDelegatorId());
orCrit.addOrCriteria(userCrit);
orCrit.addOrCriteria(groupCrit);
criteria.addAndCriteria(orCrit);
}
addToFilterDescription(filteredByItems, "Secondary Delegator Id");
addedDelegationCriteria = true;
filterOn = true;
}
}
// if we haven't added delegation criteria then use the default criteria below
if (!addedDelegationCriteria) {
criteria.addEqualTo("principalId", principalId);
filter.setDelegationType(DelegationType.SECONDARY.getCode());
filter.setExcludeDelegationType(true);
Criteria critNotEqual = new Criteria();
Criteria critNull = new Criteria();
critNotEqual.addNotEqualTo("delegationType", DelegationType.SECONDARY.getCode());
critNull.addIsNull("delegationType");
critNotEqual.addOrCriteria(critNull);
criteria.addAndCriteria(critNotEqual);
}
if (!"".equals(filteredByItems)) {
filteredByItems = "Filtered by " + filteredByItems;
}
filter.setFilterLegend(filteredByItems);
filter.setFilterOn(filterOn);
LOG.debug("returning from Action List criteria");
return criteria;
}
use of org.kuali.kfs.kew.doctype.bo.DocumentType in project cu-kfs by CU-CommunityApps.
the class ActionListDAOOjbImpl method constructDocumentTypeCriteria.
private void constructDocumentTypeCriteria(Criteria criteria, DocumentType documentType) {
// search this document type plus it's children
Criteria docTypeBaseCrit = new Criteria();
docTypeBaseCrit.addEqualTo("docName", documentType.getName());
criteria.addOrCriteria(docTypeBaseCrit);
Collection children = documentType.getChildrenDocTypes();
if (children != null) {
for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
DocumentType childDocumentType = (DocumentType) iterator.next();
constructDocumentTypeCriteria(criteria, childDocumentType);
}
}
}
Aggregations