use of org.kuali.kfs.krad.UserSession in project cu-kfs by CU-CommunityApps.
the class VendorDetailInquiryPresentationController method getConditionallyHiddenPropertyNames.
/**
* Implement this method to hide fields based on specific data in the record being inquired into
*
* @return Set of property names that should be hidden
*/
@Override
public Set<String> getConditionallyHiddenPropertyNames(BusinessObject businessObject) {
Set<String> retVal = new HashSet<String>();
IdentityManagementService idService = SpringContext.getBean(IdentityManagementService.class);
UserSession uSession = GlobalVariables.getUserSession();
Map<String, String> permissionDetails = new HashMap<String, String>();
permissionDetails.put(KewApiConstants.DOCUMENT_TYPE_NAME_DETAIL, "PVEN");
boolean canViewAttachments = idService.isAuthorizedByTemplateName(uSession.getPrincipalId(), KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.VIEW_NOTE_ATTACHMENT, permissionDetails, null);
if (!canViewAttachments) {
VendorDetail detail = (VendorDetail) businessObject;
VendorService vendorService = SpringContext.getBean(VendorService.class);
List<Note> boNotes = vendorService.getVendorNotes(detail);
for (int i = 0; i < boNotes.size(); i++) retVal.add("boNotes[" + i + "].attachmentLink");
}
return retVal;
}
use of org.kuali.kfs.krad.UserSession in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.kfs.krad.UserSession in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method submitTrip.
/**
*/
public String submitTrip(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
UserSession actualUserSession = GlobalVariables.getUserSession();
MessageMap globalErrorMap = GlobalVariables.getMessageMap();
try {
if (totalAmount > 0.00) {
return buildDisbursementVoucher(dvDescription, dvExplanation, tripNumber, travelerNetId, initiatorNetId, totalAmount, checkStubText);
} else {
return buildDistributionIncomeExpenseDocument(dvDescription, dvExplanation, tripNumber, initiatorNetId);
}
} finally {
GlobalVariables.setUserSession(actualUserSession);
GlobalVariables.setMessageMap(globalErrorMap);
}
}
use of org.kuali.kfs.krad.UserSession in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocumentBatchServiceImpl method loadDisbursementVouchers.
/**
* @see com.rsmart.kuali.kfs.fp.batch.service.DisbursementVoucherDocumentBatchService#loadDisbursementVouchers(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchFeed,
* com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchStatus, java.lang.String,
* org.kuali.kfs.kns.util.MessageMap)
*/
public void loadDisbursementVouchers(DisbursementVoucherBatchFeed batchFeed, DisbursementVoucherBatchStatus batchStatus, String incomingFileName, MessageMap MessageMap) {
// get new batch record for the load
DisbursementVoucherBatch disbursementVoucherBatch = getNewDisbursementVoucherBatch();
businessObjectService.save(disbursementVoucherBatch);
batchStatus.setUnitCode(batchFeed.getUnitCode());
boolean batchHasErrors = false;
for (BatchDisbursementVoucherDocument batchDisbursementVoucherDocument : batchFeed.getBatchDisbursementVoucherDocuments()) {
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_READ, 1);
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_READ, batchDisbursementVoucherDocument.getSourceAccountingLines().size());
// get defaults for DV chart/org
DisbursementVoucherBatchDefault batchDefault = null;
if (StringUtils.isNotBlank(batchFeed.getUnitCode())) {
batchDefault = getDisbursementVoucherBatchDefault(batchFeed.getUnitCode());
}
MessageMap documentMessageMap = new MessageMap();
batchFeedHelperService.performForceUppercase(DisbursementVoucherDocument.class.getName(), batchDisbursementVoucherDocument);
// create and route doc as system user
// create and route doc as system user
UserSession actualUserSession = GlobalVariables.getUserSession();
GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
MessageMap globalMessageMap = GlobalVariables.getMessageMap();
GlobalVariables.setMessageMap(documentMessageMap);
DisbursementVoucherDocument disbursementVoucherDocument = null;
try {
disbursementVoucherDocument = populateDisbursementVoucherDocument(disbursementVoucherBatch, batchDisbursementVoucherDocument, batchDefault, documentMessageMap);
// if the document is valid create GLPEs, Save and Approve
if (documentMessageMap.hasNoErrors()) {
businessObjectService.save(disbursementVoucherDocument.getExtension());
documentService.routeDocument(disbursementVoucherDocument, "", null);
if (documentMessageMap.hasNoErrors()) {
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_WRITTEN, 1);
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_WRITTEN, disbursementVoucherDocument.getSourceAccountingLines().size());
batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_GLPE_RECORDS_WRITTEN, disbursementVoucherDocument.getGeneralLedgerPendingEntries().size());
batchStatus.getBatchDisbursementVoucherDocuments().add(disbursementVoucherDocument);
}
}
} catch (WorkflowException e) {
LOG.error("Unable to route DV: " + e.getMessage());
throw new RuntimeException("Unable to route DV: " + e.getMessage(), e);
} catch (ValidationException e1) {
// will be reported in audit report
} finally {
GlobalVariables.setUserSession(actualUserSession);
GlobalVariables.setMessageMap(globalMessageMap);
}
if (documentMessageMap.hasErrors()) {
batchHasErrors = true;
}
// populate summary line and add to report
DisbursementVoucherBatchSummaryLine batchSummaryLine = populateBatchSummaryLine(disbursementVoucherDocument, documentMessageMap);
batchStatus.getBatchSummaryLines().add(batchSummaryLine);
}
// indicate in global map there were errors (for batch upload screen)
if (batchHasErrors) {
MessageMap.putError(KFSConstants.GLOBAL_ERRORS, FPKeyConstants.ERROR_BATCH_DISBURSEMENT_VOUCHER_ERRORS_NOTIFICATION);
}
batchFeedHelperService.removeDoneFile(incomingFileName);
}
use of org.kuali.kfs.krad.UserSession in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDistributionIncomeExpenseDocument.
/**
* @param diDescription
* @param diExplanation
* @param tripNumber
* @param initiatorNetId
* @return
* @throws Exception
*/
private String buildDistributionIncomeExpenseDocument(String diDescription, String diExplanation, String tripNumber, String initiatorNetId) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISTRIBUTION_INCOME_EXPENSE)) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DI.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDistributionOfIncomeAndExpenseDocument diDoc = null;
try {
diDoc = (CuDistributionOfIncomeAndExpenseDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DistributionOfIncomeAndExpenseDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (diDoc != null) {
diDoc.getDocumentHeader().setDocumentDescription(diDescription);
diDoc.getDocumentHeader().setExplanation(diExplanation);
diDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
diDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
diDoc.setTripId(tripNumber);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(diDoc);
return diDoc.getDocumentNumber();
} else {
return "";
}
}
Aggregations