use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class CuFormatServiceImpl method startFormatProcess.
@Override
public FormatProcessSummary startFormatProcess(Person user, String campus, List<CustomerProfile> customers, Date paydate, String paymentTypes, String paymentDistribution) {
LOG.debug("startFormatProcess() started");
for (CustomerProfile element : customers) {
LOG.debug("startFormatProcess() Customer: " + element);
}
// Create the process
Date d = new Date();
PaymentProcess paymentProcess = new PaymentProcess();
paymentProcess.setCampusCode(campus);
paymentProcess.setProcessUser(user);
paymentProcess.setProcessTimestamp(new Timestamp(d.getTime()));
this.businessObjectService.save(paymentProcess);
// add an entry in the format process table (to lock the format process)
FormatProcess formatProcess = new FormatProcess();
formatProcess.setPhysicalCampusProcessCode(campus);
formatProcess.setBeginFormat(dateTimeService.getCurrentTimestamp());
formatProcess.setPaymentProcIdentifier(paymentProcess.getId().intValue());
this.businessObjectService.save(formatProcess);
Timestamp now = new Timestamp((new Date()).getTime());
java.sql.Date sqlDate = new java.sql.Date(paydate.getTime());
Calendar c = Calendar.getInstance();
c.setTime(sqlDate);
c.set(Calendar.HOUR, 11);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 59);
c.set(Calendar.AM_PM, Calendar.PM);
Timestamp paydateTs = new Timestamp(c.getTime().getTime());
LOG.debug("startFormatProcess() last update = " + now);
LOG.debug("startFormatProcess() entered paydate = " + paydate);
LOG.debug("startFormatProcess() actual paydate = " + paydateTs);
PaymentStatus format = this.businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.FORMAT);
List customerIds = new ArrayList();
for (Iterator iter = customers.iterator(); iter.hasNext(); ) {
CustomerProfile element = (CustomerProfile) iter.next();
customerIds.add(element.getId());
}
// Mark all of them ready for format
Iterator groupIterator = ((CuFormatPaymentDao) formatPaymentDao).markPaymentsForFormat(customerIds, paydateTs, paymentTypes, paymentDistribution);
while (groupIterator.hasNext()) {
PaymentGroup paymentGroup = (PaymentGroup) groupIterator.next();
paymentGroup.setLastUpdatedTimestamp(paydateTs);
paymentGroup.setPaymentStatus(format);
paymentGroup.setProcess(paymentProcess);
businessObjectService.save(paymentGroup);
}
// summarize them
FormatProcessSummary preFormatProcessSummary = new FormatProcessSummary();
Iterator<PaymentGroup> iterator = this.paymentGroupService.getByProcess(paymentProcess);
while (iterator.hasNext()) {
PaymentGroup paymentGroup = iterator.next();
preFormatProcessSummary.add(paymentGroup);
}
// if no payments found for format clear the format process
if (preFormatProcessSummary.getProcessSummaryList().size() == 0) {
LOG.debug("startFormatProcess() No payments to process. Format process ending");
// ?? maybe call end format process
clearUnfinishedFormat(paymentProcess.getId().intValue());
}
return preFormatProcessSummary;
}
use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class CuPaymentFileServiceImpl method getCustomerProfileFromUnparsableFile.
/**
* @param incomingFileName
* @param paymentFile
* @return
*/
private PaymentFileLoad getCustomerProfileFromUnparsableFile(String incomingFileName, PaymentFileLoad paymentFile) {
FileInputStream exFileContents;
try {
exFileContents = new FileInputStream(incomingFileName);
} catch (FileNotFoundException e1) {
LOG.error("file to load not found " + incomingFileName, e1);
throw new RuntimeException("Cannot find the file requested to be loaded " + incomingFileName, e1);
}
try {
InputStreamReader inputReader = new InputStreamReader(exFileContents);
BufferedReader bufferedReader = new BufferedReader(inputReader);
String line = "";
boolean found = false;
String chartVal = "";
String unitVal = "";
String subUnitVal = "";
while (!found && (line = bufferedReader.readLine()) != null) {
// Use multiple ifs instead of else/ifs because all values could occur on the same line.
if (StringUtils.contains(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.CHART_OPEN)) {
chartVal = StringUtils.substringBetween(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.CHART_OPEN, CUPdpConstants.CustomerProfilePrimaryKeyTags.CHART_CLOSE);
}
if (StringUtils.contains(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.UNIT_OPEN)) {
unitVal = StringUtils.substringBetween(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.UNIT_OPEN, CUPdpConstants.CustomerProfilePrimaryKeyTags.UNIT_CLOSE);
}
if (StringUtils.contains(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.SUBUNIT_OPEN)) {
subUnitVal = StringUtils.substringBetween(line, CUPdpConstants.CustomerProfilePrimaryKeyTags.SUBUNIT_OPEN, CUPdpConstants.CustomerProfilePrimaryKeyTags.SUBUNIT_CLOSE);
found = true;
}
}
if (found) {
// Note: the pdpEmailServiceImpl doesn't actually use the customer object from the paymentFile, but rather retrieves an instance using
// the values provided for chart, unit and sub_unit. However, it doesn't make sense to even populate the paymentFile object if
// the values retrieved don't map to a valid customer object, so we will retrieve the object here to validate the values.
CustomerProfile customer = customerProfileService.get(chartVal, unitVal, subUnitVal);
if (ObjectUtils.isNotNull(customer)) {
if (ObjectUtils.isNull(paymentFile)) {
paymentFile = new PaymentFileLoad();
}
paymentFile.setChart(chartVal);
paymentFile.setUnit(unitVal);
paymentFile.setSubUnit(subUnitVal);
paymentFile.setCustomer(customer);
}
}
} catch (Exception ex) {
LOG.error("Attempts to retrieve the customer profile from the unparsable XML file failed with the following error.", ex);
} finally {
try {
exFileContents.close();
} catch (IOException io) {
LOG.error("File stream object could not be closed.", io);
}
}
return paymentFile;
}
Aggregations