use of org.kuali.rice.kew.api.document.DocumentStatus in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImpl method retrieveAdvanceDepositDocumentsToRoute.
/**
* Returns a list of all initiated but not yet routed advance deposit documents, using the WorkflowDocumentService.
*
* @return a list of advance deposit documents to route
*/
protected List<String> retrieveAdvanceDepositDocumentsToRoute(String statusCode) throws WorkflowException, RemoteException {
List<String> documentIds = new ArrayList<String>();
List<DocumentStatus> routeStatuses = new ArrayList<DocumentStatus>();
routeStatuses.add(DocumentStatus.fromCode(statusCode));
Person systemUser = getPersonService().getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
String principalName = systemUser.getPrincipalName();
DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
criteria.setDocumentTypeName(KFSConstants.FinancialDocumentTypeCodes.ADVANCE_DEPOSIT);
criteria.setDocumentStatuses(routeStatuses);
criteria.setInitiatorPrincipalName(principalName);
DocumentSearchResults results = getWorkflowDocumentService().documentSearch(systemUser.getPrincipalId(), criteria.build());
for (DocumentSearchResult resultRow : results.getSearchResults()) {
Document document = resultRow.getDocument();
if (ObjectUtils.isNotNull(document)) {
documentIds.add(document.getDocumentId());
}
}
return documentIds;
}
use of org.kuali.rice.kew.api.document.DocumentStatus in project cu-kfs by CU-CommunityApps.
the class TransactionRowDvBuilder method updateTransactionRowsFromWorkflowDocuments.
@Override
void updateTransactionRowsFromWorkflowDocuments(ResultSet rs, T summary) throws SQLException {
TransactionDetailRow detailRow = summary.transactionDetailRow;
Pattern nonPrintableCharsPattern = Pattern.compile("[^\\p{Graph}\\p{Space}]");
String documentId;
String initiatorPrincipalId;
String initiatorPrincipalName;
String paymentMethodCode;
String vendorTaxNumber;
String checkStubText;
Matcher checkStubMatcher;
java.sql.Date dateFinalized;
Document document;
DocumentStatus documentStatus = null;
boolean processCurrentRow;
boolean useDateFinalized;
java.sql.Date startDate = summary.getStartDate();
java.sql.Date endDate = summary.getEndDate();
// Update or remove rows as needed.
while (rs.next()) {
// Only update DV-related rows.
if (DisbursementVoucherConstants.DOCUMENT_TYPE_CODE.equals(rs.getString(detailRow.documentType.index))) {
// Initialized minimal variables for current row.
processCurrentRow = true;
documentId = rs.getString(detailRow.documentNumber.index);
initiatorPrincipalId = null;
documentStatus = null;
dateFinalized = null;
useDateFinalized = false;
// Retrieve document info.
document = getWorkflowDocumentForTaxRow(documentId, summary);
if (document != null) {
initiatorPrincipalId = document.getInitiatorPrincipalId();
documentStatus = document.getStatus();
if (document.getDateFinalized() != null) {
dateFinalized = new java.sql.Date(document.getDateFinalized().getMillis());
}
}
// Retrieve payment method, which is temporarily stored in the doc title field.
paymentMethodCode = rs.getString(detailRow.documentTitle.index);
// Depending on payment method, verify that the DV has indeed been finalized during the given time period.
if (summary.foreignDraftCode.equals(paymentMethodCode) || summary.wireTransferCode.equals(paymentMethodCode)) {
// If a Foreign Draft or Wire Transfer, check the doc finalization date and status.
if (DocumentStatus.FINAL.equals(documentStatus) && dateFinalized != null && dateFinalized.compareTo(startDate) >= 0 && dateFinalized.compareTo(endDate) <= 0) {
// If finalized during the current reporting period, then increment counters accordingly and use finalize date as payment date.
useDateFinalized = true;
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsSelected++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersSelected++;
}
} else {
// If not finalized or if in the wrong reporting period, then skip the current DV data row.
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsIgnored++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersIgnored++;
}
// Skip any further processing for the current row.
processCurrentRow = false;
}
}
if (processCurrentRow) {
// Finish initialization.
vendorTaxNumber = rs.getString(detailRow.vendorTaxNumber.index);
checkStubText = rs.getString(detailRow.dvCheckStubText.index);
checkStubMatcher = nonPrintableCharsPattern.matcher((checkStubText != null) ? checkStubText : KRADConstants.EMPTY_STRING);
// Check for null objects as needed, and get the initiator's principal name.
initiatorPrincipalName = checkForEntityAndAccountAndOrgExistence(initiatorPrincipalId, rs.getString(detailRow.chartCode.index), rs.getString(detailRow.accountNumber.index), summary);
// If vendor tax number is blank, then replace with a generated value accordingly.
if (StringUtils.isBlank(vendorTaxNumber)) {
vendorTaxNumber = getReplacementVendorTaxNumber(rs.getString(detailRow.payeeId.index), summary);
rs.updateString(detailRow.vendorTaxNumber.index, vendorTaxNumber);
}
// Remove unprintable characters from the check stub text if necessary.
if (checkStubMatcher.find()) {
checkStubText = checkStubMatcher.replaceAll(KRADConstants.EMPTY_STRING);
rs.updateString(detailRow.dvCheckStubText.index, checkStubText);
numDvCheckStubTextsAltered++;
} else {
numDvCheckStubTextsNotAltered++;
}
// Do tax-type-specific updates.
doTaxSpecificSecondPassRowSetup(rs, summary);
// Update other fields as needed.
if (StringUtils.isBlank(documentId)) {
rs.updateString(detailRow.documentNumber.index, CUTaxConstants.DOC_ID_ZERO);
}
rs.updateString(detailRow.documentTitle.index, (document != null && StringUtils.isNotBlank(document.getTitle())) ? document.getTitle() : CUTaxConstants.DOC_TITLE_IF_NOT_FOUND);
rs.updateString(detailRow.initiatorNetId.index, StringUtils.isNotBlank(initiatorPrincipalName) ? initiatorPrincipalName : CUTaxConstants.NETID_IF_NOT_FOUND);
if (useDateFinalized) {
rs.updateDate(detailRow.paymentDate.index, dateFinalized);
}
// Update the transaction row.
rs.updateRow();
} else {
// If a Foreign Draft or Wire Transfer that wasn't finalized or was in the wrong reporting period, then delete the row.
rs.deleteRow();
}
}
}
}
use of org.kuali.rice.kew.api.document.DocumentStatus in project cu-kfs by CU-CommunityApps.
the class TransactionRowPRNCBuilder method updateTransactionRowsFromWorkflowDocuments.
@Override
void updateTransactionRowsFromWorkflowDocuments(ResultSet rs, T summary) throws SQLException {
TransactionDetailRow detailRow = summary.transactionDetailRow;
String documentId;
String initiatorPrincipalId;
String initiatorPrincipalName;
String paymentMethodCode;
String vendorTaxNumber;
java.sql.Date dateFinalized;
Document document;
DocumentStatus documentStatus = null;
boolean processCurrentRow;
boolean useDateFinalized;
java.sql.Date startDate = summary.getStartDate();
java.sql.Date endDate = summary.getEndDate();
// Update or remove rows as needed.
while (rs.next()) {
String documentType = rs.getString(detailRow.documentType.index);
// Retrieve payment method, which is temporarily stored in the doc title field.
paymentMethodCode = rs.getString(detailRow.documentTitle.index);
if (isPaymentRequestDocument(documentType) && isForeignOrWireTransferPaymentMethod(summary, paymentMethodCode)) {
// Initialized minimal variables for current row.
processCurrentRow = true;
documentId = rs.getString(detailRow.documentNumber.index);
initiatorPrincipalId = null;
documentStatus = null;
dateFinalized = null;
useDateFinalized = false;
// Retrieve document info.
document = getWorkflowDocumentForTaxRow(documentId, summary);
if (document != null) {
initiatorPrincipalId = document.getInitiatorPrincipalId();
documentStatus = document.getStatus();
if (document.getDateFinalized() != null) {
dateFinalized = new java.sql.Date(document.getDateFinalized().getMillis());
}
}
// Depending on payment method, verify that the PRNC has indeed been finalized during the given time period.
if (summary.foreignDraftCode.equals(paymentMethodCode) || summary.wireTransferCode.equals(paymentMethodCode)) {
// If a Foreign Draft or Wire Transfer, check the doc finalization date and status.
if (DocumentStatus.FINAL.equals(documentStatus) && dateFinalized != null && dateFinalized.compareTo(startDate) >= 0 && dateFinalized.compareTo(endDate) <= 0) {
// If finalized during the current reporting period, then increment counters accordingly and use finalize date as payment date.
useDateFinalized = true;
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsSelected++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersSelected++;
}
} else {
// If not finalized or if in the wrong reporting period, then skip the current PRNC data row.
if (summary.foreignDraftCode.equals(paymentMethodCode)) {
numForeignDraftsIgnored++;
} else if (summary.wireTransferCode.equals(paymentMethodCode)) {
numWireTransfersIgnored++;
}
// Skip any further processing for the current row.
processCurrentRow = false;
}
}
if (processCurrentRow) {
// Finish initialization.
vendorTaxNumber = rs.getString(detailRow.vendorTaxNumber.index);
// Check for null objects as needed, and get the initiator's principal name.
initiatorPrincipalName = checkForEntityAndAccountAndOrgExistence(initiatorPrincipalId, rs.getString(detailRow.chartCode.index), rs.getString(detailRow.accountNumber.index), summary);
// If vendor tax number is blank, then replace with a generated value accordingly.
if (StringUtils.isBlank(vendorTaxNumber)) {
vendorTaxNumber = getReplacementVendorTaxNumber(rs.getString(detailRow.payeeId.index), summary);
rs.updateString(detailRow.vendorTaxNumber.index, vendorTaxNumber);
}
// Do tax-type-specific updates.
doTaxSpecificSecondPassRowSetup(rs, summary);
// Update other fields as needed.
if (StringUtils.isBlank(documentId)) {
rs.updateString(detailRow.documentNumber.index, CUTaxConstants.DOC_ID_ZERO);
}
rs.updateString(detailRow.documentTitle.index, (document != null && StringUtils.isNotBlank(document.getTitle())) ? document.getTitle() : CUTaxConstants.DOC_TITLE_IF_NOT_FOUND);
rs.updateString(detailRow.initiatorNetId.index, StringUtils.isNotBlank(initiatorPrincipalName) ? initiatorPrincipalName : CUTaxConstants.NETID_IF_NOT_FOUND);
if (useDateFinalized) {
rs.updateDate(detailRow.paymentDate.index, dateFinalized);
}
// Update the transaction row.
rs.updateRow();
} else {
// If a Foreign Draft or Wire Transfer that wasn't finalized or was in the wrong reporting period, then delete the row.
rs.deleteRow();
}
}
}
}
use of org.kuali.rice.kew.api.document.DocumentStatus in project cu-kfs by CU-CommunityApps.
the class PurApRelatedViews method maskPONumberIfUnapproved.
/**
* masks the po number if the po is unappoved yet. If the document status is not FINAL then
* check for permission for purapDocumentIdentifier field. If NOT permitted to view the value
* then mask the value with * and setting this value in poNumberMasked property.
*
* @param view
*/
protected void maskPONumberIfUnapproved(AbstractRelatedView view) {
String poIDstr = "";
if (ObjectUtils.isNotNull(view.getPurapDocumentIdentifier())) {
poIDstr = view.getPurapDocumentIdentifier().toString();
}
if (PurapConstants.PurapDocTypeCodes.PO_DOCUMENT.equals(view.getDocumentTypeName())) {
DocumentStatus documentStatus = KewApiServiceLocator.getWorkflowDocumentService().getDocumentStatus(view.getDocumentNumber());
if (!(StringUtils.equals(documentStatus.getCode(), DocumentStatus.FINAL.getCode()))) {
String principalId = GlobalVariables.getUserSession().getPrincipalId();
String namespaceCode = KFSConstants.ParameterNamespaces.KNS;
String permissionTemplateName = KimConstants.PermissionTemplateNames.FULL_UNMASK_FIELD;
Map<String, String> roleQualifiers = new HashMap<String, String>();
Map<String, String> permissionDetails = new HashMap<String, String>();
permissionDetails.put(KimConstants.AttributeConstants.COMPONENT_NAME, PurchaseOrderDocument.class.getSimpleName());
permissionDetails.put(KimConstants.AttributeConstants.PROPERTY_NAME, PurapPropertyConstants.PURAP_DOC_ID);
IdentityManagementService identityManagementService = SpringContext.getBean(IdentityManagementService.class);
Boolean isAuthorized = identityManagementService.isAuthorizedByTemplateName(principalId, namespaceCode, permissionTemplateName, permissionDetails, roleQualifiers);
if (!isAuthorized) {
// not authorized to see... so mask the po number string
poIDstr = "";
int strLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurApGenericAttributes.class.getName(), PurapPropertyConstants.PURAP_DOC_ID);
for (int i = 0; i < strLength; i++) {
poIDstr = poIDstr.concat("*");
}
}
}
}
view.setPoNumberMasked(poIDstr);
}
Aggregations