Source Code Cross Referenced for PrintServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » purap » service » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.purap.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.module.purap.service.impl;
017:
018:        import java.io.ByteArrayOutputStream;
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.HashMap;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.kuali.core.bo.user.UniversalUser;
028:        import org.kuali.core.service.BusinessObjectService;
029:        import org.kuali.core.service.KualiConfigurationService;
030:        import org.kuali.kfs.KFSConstants;
031:        import org.kuali.kfs.KFSPropertyConstants;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.service.ParameterService;
034:        import org.kuali.kfs.service.impl.ParameterConstants;
035:        import org.kuali.module.purap.PurapConstants;
036:        import org.kuali.module.purap.bo.CampusParameter;
037:        import org.kuali.module.purap.bo.PurchaseOrderContractLanguage;
038:        import org.kuali.module.purap.bo.PurchaseOrderItem;
039:        import org.kuali.module.purap.bo.PurchaseOrderVendorQuote;
040:        import org.kuali.module.purap.dao.ImageDao;
041:        import org.kuali.module.purap.document.PurchaseOrderDocument;
042:        import org.kuali.module.purap.exceptions.PurError;
043:        import org.kuali.module.purap.exceptions.PurapConfigurationException;
044:        import org.kuali.module.purap.pdf.PurchaseOrderPdf;
045:        import org.kuali.module.purap.pdf.PurchaseOrderPdfParameters;
046:        import org.kuali.module.purap.pdf.PurchaseOrderQuotePdf;
047:        import org.kuali.module.purap.pdf.PurchaseOrderQuoteRequestsPdf;
048:        import org.kuali.module.purap.service.PrintService;
049:        import org.kuali.module.vendor.bo.ContractManager;
050:        import org.springframework.transaction.annotation.Transactional;
051:
052:        @Transactional
053:        public class PrintServiceImpl implements  PrintService {
054:            private static Log LOG = LogFactory.getLog(PrintServiceImpl.class);
055:            private static final boolean TRANSMISSION_IS_RETRANSMIT = true;
056:            private static final boolean TRANSMISSION_IS_NOT_RETRANSMIT = !TRANSMISSION_IS_RETRANSMIT;
057:
058:            private ImageDao imageDao;
059:            private ParameterService parameterService;
060:            private BusinessObjectService businessObjectService;
061:
062:            public void setParameterService(ParameterService parameterService) {
063:                this .parameterService = parameterService;
064:            }
065:
066:            public void setImageDao(ImageDao imageDao) {
067:                this .imageDao = imageDao;
068:            }
069:
070:            public void setBusinessObjectService(
071:                    BusinessObjectService businessObjectService) {
072:                this .businessObjectService = businessObjectService;
073:            }
074:
075:            /**
076:             * @see org.kuali.module.purap.service.PrintService#generatePurchaseOrderQuoteRequestsListPdf(org.kuali.module.purap.document.PurchaseOrderDocument, java.io.ByteArrayOutputStream)
077:             */
078:            public Collection generatePurchaseOrderQuoteRequestsListPdf(
079:                    PurchaseOrderDocument po,
080:                    ByteArrayOutputStream byteArrayOutputStream) {
081:                LOG
082:                        .debug("generatePurchaseOrderQuoteRequestsListPdf() started");
083:                Collection errors = new ArrayList();
084:
085:                PurchaseOrderQuoteRequestsPdf poQuoteRequestsPdf = new PurchaseOrderQuoteRequestsPdf();
086:
087:                try {
088:                    PurchaseOrderPdfParameters pdfParameters = getPurchaseOrderQuoteRequestsListPdfParameters(po);
089:                    String deliveryCampusName = pdfParameters
090:                            .getCampusParameter().getCampus().getCampusName();
091:                    poQuoteRequestsPdf.generatePOQuoteRequestsListPdf(po,
092:                            byteArrayOutputStream);
093:                    if (pdfParameters.isUseImage()) {
094:                        // Removes temporary images; only need to call once.
095:                        imageDao.removeImages(po.getPurapDocumentIdentifier()
096:                                .toString(), pdfParameters
097:                                .getImageTempLocation());
098:                    }
099:                } catch (PurError pe) {
100:                    LOG.error("Caught exception ", pe);
101:                    errors.add(pe.getMessage());
102:                } catch (PurapConfigurationException pce) {
103:                    LOG.error("Caught exception ", pce);
104:                    errors.add(pce.getMessage());
105:                } catch (Exception e) {
106:                    LOG.error("Caught exception ", e);
107:                    errors.add(e.getMessage());
108:                }
109:
110:                LOG.debug("generatePurchaseOrderQuoteRequestsListPdf() ended");
111:                return errors;
112:            }
113:
114:            /**
115:             * @see org.kuali.module.purap.service.PrintService#savePurchaseOrderQuoteRequestsListPdf(org.kuali.module.purap.document.PurchaseOrderDocument)
116:             */
117:            public Collection savePurchaseOrderQuoteRequestsListPdf(
118:                    PurchaseOrderDocument po) {
119:                return null;
120:            }
121:
122:            /**
123:             * Returns the PurchaseOrderPdfParameters given the PurchaseOrderDocument.
124:             * 
125:             * @param po  The PurchaseOrderDocument object to be used to obtain the PurchaseOrderPdfParameters.
126:             * @return    The PurchaseOrderPdfParameters given the PurchaseOrderDocument.
127:             */
128:            private PurchaseOrderPdfParameters getPurchaseOrderQuotePdfParameters(
129:                    PurchaseOrderDocument po) {
130:                String key = po.getPurapDocumentIdentifier().toString(); // key can be any string; chose to use the PO number.
131:                String campusCode = po.getDeliveryCampusCode().toLowerCase();
132:                String imageTempLocation = "";
133:                String logoImage = "";
134:                boolean useImage = true;
135:                if (parameterService.parameterExists(
136:                        ParameterConstants.PURCHASING_DOCUMENT.class,
137:                        PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR)) {
138:                    useImage = parameterService.getIndicatorParameter(
139:                            ParameterConstants.PURCHASING_DOCUMENT.class,
140:                            PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR);
141:                }
142:                // We'll get the imageTempLocation and the actual images only if the useImage is true. If useImage is false, we'll leave the
143:                // images as blank space
144:                if (useImage) {
145:                    imageTempLocation = SpringContext.getBean(
146:                            KualiConfigurationService.class).getPropertyString(
147:                            KFSConstants.TEMP_DIRECTORY_KEY)
148:                            + "/";
149:
150:                    if (imageTempLocation == null) {
151:                        LOG.debug("generatePurchaseOrderQuotePdf() ended");
152:                        throw new PurapConfigurationException(
153:                                "Application Setting IMAGE_TEMP_PATH is missing");
154:                    }
155:                    // Get logo image.
156:                    logoImage = imageDao.getLogo(key, campusCode,
157:                            imageTempLocation);
158:                }
159:                Map<String, Object> criteria = new HashMap<String, Object>();
160:                criteria.put(KFSPropertyConstants.CAMPUS_CODE, po
161:                        .getDeliveryCampusCode());
162:                CampusParameter campusParameter = (CampusParameter) ((List) businessObjectService
163:                        .findMatching(CampusParameter.class, criteria)).get(0);
164:
165:                // Get the contract manager's campus
166:                criteria.clear();
167:                ContractManager contractManager = po.getContractManager();
168:                String contractManagerCampusCode = "N/A";
169:                if (contractManager != null
170:                        && contractManager.getContractManagerUserIdentifier() != null) {
171:                    criteria.put("personUserIdentifier", contractManager
172:                            .getContractManagerUserIdentifier());
173:                    UniversalUser contractManagerUser = (UniversalUser) ((List) businessObjectService
174:                            .findMatching(UniversalUser.class, criteria))
175:                            .get(0);
176:                    contractManagerCampusCode = contractManagerUser
177:                            .getCampusCode();
178:                } else {
179:
180:                }
181:
182:                String pdfFileLocation = parameterService.getParameterValue(
183:                        ParameterConstants.PURCHASING_DOCUMENT.class,
184:                        PurapConstants.PDF_DIRECTORY);
185:                if (pdfFileLocation == null) {
186:                    LOG.debug("savePurchaseOrderPdf() ended");
187:                    throw new PurapConfigurationException(
188:                            "Application Setting PDF_DIRECTORY is missing.");
189:                }
190:
191:                PurchaseOrderPdfParameters pdfParameters = new PurchaseOrderPdfParameters();
192:                pdfParameters.setImageTempLocation(imageTempLocation);
193:                pdfParameters.setKey(key);
194:                pdfParameters.setLogoImage(logoImage);
195:                pdfParameters.setCampusParameter(campusParameter);
196:                pdfParameters
197:                        .setContractManagerCampusCode(contractManagerCampusCode);
198:                pdfParameters.setPdfFileLocation(pdfFileLocation);
199:                pdfParameters.setUseImage(useImage);
200:                return pdfParameters;
201:            }
202:
203:            /**
204:             * Returns the PurchaseOrderPdfParameters given the PurchaseOrderDocument.
205:             * 
206:             * @param po  The PurchaseOrderDocument object to be used to obtain the PurchaseOrderPdfParameters.
207:             * @return    The PurchaseOrderPdfParameters given the PurchaseOrderDocument.
208:             */
209:            private PurchaseOrderPdfParameters getPurchaseOrderQuoteRequestsListPdfParameters(
210:                    PurchaseOrderDocument po) {
211:                String key = po.getPurapDocumentIdentifier().toString(); // key can be any string; chose to use the PO number.
212:                String campusCode = po.getDeliveryCampusCode().toLowerCase();
213:                String imageTempLocation = "";
214:                String logoImage = "";
215:                boolean useImage = true;
216:                if (parameterService.parameterExists(
217:                        ParameterConstants.PURCHASING_DOCUMENT.class,
218:                        PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR)) {
219:                    useImage = parameterService.getIndicatorParameter(
220:                            ParameterConstants.PURCHASING_DOCUMENT.class,
221:                            PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR);
222:                }
223:                // We'll get the imageTempLocation and the actual images only if the useImage is true. If useImage is false, we'll leave the
224:                // images as blank space
225:                if (useImage) {
226:                    imageTempLocation = SpringContext.getBean(
227:                            KualiConfigurationService.class).getPropertyString(
228:                            KFSConstants.TEMP_DIRECTORY_KEY)
229:                            + "/";
230:
231:                    if (imageTempLocation == null) {
232:                        LOG.debug("generatePurchaseOrderQuotePdf() ended");
233:                        throw new PurapConfigurationException(
234:                                "Application Setting IMAGE_TEMP_PATH is missing");
235:                    }
236:                    // Get logo image.
237:                    logoImage = imageDao.getLogo(key, campusCode,
238:                            imageTempLocation);
239:                }
240:                Map<String, Object> criteria = new HashMap<String, Object>();
241:                criteria.put(KFSPropertyConstants.CAMPUS_CODE, po
242:                        .getDeliveryCampusCode());
243:                CampusParameter campusParameter = (CampusParameter) ((List) businessObjectService
244:                        .findMatching(CampusParameter.class, criteria)).get(0);
245:
246:                // Get the contract manager's campus
247:                criteria.clear();
248:                ContractManager contractManager = po.getContractManager();
249:                criteria.put("personUserIdentifier", contractManager
250:                        .getContractManagerUserIdentifier());
251:                String contractManagerCampusCode = "";
252:                if (contractManager.getContractManagerUserIdentifier() != null) {
253:                    UniversalUser contractManagerUser = (UniversalUser) ((List) businessObjectService
254:                            .findMatching(UniversalUser.class, criteria))
255:                            .get(0);
256:                    contractManagerCampusCode = contractManagerUser
257:                            .getCampusCode();
258:                }
259:
260:                String pdfFileLocation = parameterService.getParameterValue(
261:                        ParameterConstants.PURCHASING_DOCUMENT.class,
262:                        PurapConstants.PDF_DIRECTORY);
263:                if (pdfFileLocation == null) {
264:                    LOG.debug("savePurchaseOrderPdf() ended");
265:                    throw new PurapConfigurationException(
266:                            "Application Setting PDF_DIRECTORY is missing.");
267:                }
268:
269:                PurchaseOrderPdfParameters pdfParameters = new PurchaseOrderPdfParameters();
270:                pdfParameters.setImageTempLocation(imageTempLocation);
271:                pdfParameters.setKey(key);
272:                pdfParameters.setLogoImage(logoImage);
273:                pdfParameters.setCampusParameter(campusParameter);
274:                pdfParameters
275:                        .setContractManagerCampusCode(contractManagerCampusCode);
276:                pdfParameters.setPdfFileLocation(pdfFileLocation);
277:                pdfParameters.setUseImage(useImage);
278:                return pdfParameters;
279:            }
280:
281:            /**
282:             * @see org.kuali.module.purap.service.PrintService#generatePurchaseOrderQuotePdf(org.kuali.module.purap.document.PurchaseOrderDocument, org.kuali.module.purap.bo.PurchaseOrderVendorQuote, java.io.ByteArrayOutputStream, java.lang.String)
283:             */
284:            public Collection generatePurchaseOrderQuotePdf(
285:                    PurchaseOrderDocument po, PurchaseOrderVendorQuote povq,
286:                    ByteArrayOutputStream byteArrayOutputStream,
287:                    String environment) {
288:                LOG.debug("generatePurchaseOrderQuotePdf() started");
289:
290:                PurchaseOrderQuotePdf poQuotePdf = new PurchaseOrderQuotePdf();
291:                Collection errors = new ArrayList();
292:
293:                try {
294:                    PurchaseOrderPdfParameters pdfParameters = getPurchaseOrderQuotePdfParameters(po);
295:                    String deliveryCampusName = pdfParameters
296:                            .getCampusParameter().getCampus().getCampusName();
297:                    poQuotePdf.generatePOQuotePDF(po, povq, deliveryCampusName,
298:                            pdfParameters.getContractManagerCampusCode(),
299:                            pdfParameters.getLogoImage(),
300:                            byteArrayOutputStream, environment);
301:                    if (pdfParameters.isUseImage()) {
302:                        // Removes temporary images; only need to call once.
303:                        imageDao.removeImages(po.getPurapDocumentIdentifier()
304:                                .toString(), pdfParameters
305:                                .getImageTempLocation());
306:                    }
307:                } catch (PurError pe) {
308:                    LOG.error("Caught exception ", pe);
309:                    errors.add(pe.getMessage());
310:                } catch (PurapConfigurationException pce) {
311:                    LOG.error("Caught exception ", pce);
312:                    errors.add(pce.getMessage());
313:                } catch (Exception e) {
314:                    LOG.error("Caught exception ", e);
315:                    errors.add(e.getMessage());
316:                }
317:
318:                LOG.debug("generatePurchaseOrderQuotePdf() ended");
319:                return errors;
320:            }
321:
322:            /**
323:             * @see org.kuali.module.purap.service.PrintService#savePurchaseOrderQuotePdf(org.kuali.module.purap.document.PurchaseOrderDocument, org.kuali.module.purap.bo.PurchaseOrderVendorQuote, java.lang.String)
324:             */
325:            public Collection savePurchaseOrderQuotePdf(
326:                    PurchaseOrderDocument po, PurchaseOrderVendorQuote povq,
327:                    String environment) {
328:                LOG.debug("savePurchaseOrderQuotePdf() started");
329:
330:                String pdfQuoteFilename = "PURAP_PO_"
331:                        + po.getPurapDocumentIdentifier().toString()
332:                        + "_Quote_"
333:                        + povq.getPurchaseOrderVendorQuoteIdentifier()
334:                                .toString() + "_" + System.currentTimeMillis()
335:                        + ".pdf";
336:                PurchaseOrderQuotePdf poQuotePdf = new PurchaseOrderQuotePdf();
337:                Collection errors = new ArrayList();
338:
339:                PurchaseOrderPdfParameters pdfParameters = null;
340:                try {
341:                    pdfParameters = getPurchaseOrderQuotePdfParameters(po);
342:                    String deliveryCampusName = pdfParameters
343:                            .getCampusParameter().getCampus().getCampusName();
344:                    poQuotePdf.savePOQuotePDF(po, povq, pdfParameters
345:                            .getPdfFileLocation(), pdfQuoteFilename,
346:                            deliveryCampusName, pdfParameters
347:                                    .getContractManagerCampusCode(),
348:                            pdfParameters.getLogoImage(), environment);
349:                    if (pdfParameters.isUseImage()) {
350:                        // Removes temporary images; only need to call once.
351:                        imageDao.removeImages(po.getPurapDocumentIdentifier()
352:                                .toString(), pdfParameters
353:                                .getImageTempLocation());
354:                    }
355:                } catch (PurError e) {
356:                    LOG.error("Caught exception ", e);
357:                    errors.add(e.getMessage());
358:                } catch (PurapConfigurationException pce) {
359:                    LOG.error("Caught exception ", pce);
360:                    errors.add(pce.getMessage());
361:                } finally {
362:                    try {
363:                        poQuotePdf.deletePdf(
364:                                pdfParameters.getPdfFileLocation(),
365:                                pdfQuoteFilename);
366:                    } catch (Throwable e) {
367:                        LOG.error(
368:                                "savePurchaseOrderQuotePdf() Error deleting Quote PDF"
369:                                        + pdfQuoteFilename
370:                                        + " - Exception was " + e.getMessage(),
371:                                e);
372:                        errors.add(e.getMessage());
373:                    }
374:                }
375:
376:                LOG.debug("savePurchaseOrderQuotePdf() ended");
377:                return errors;
378:            }
379:
380:            /**
381:             * Returns the PurchaseOrderPdfParameters given the PurchaseOrderDocument.
382:             * 
383:             * @param po  The PurchaseOrderDocument object to be used to obtain the PurchaseOrderPdfParameters.
384:             * @return    The PurchaseOrderPdfParameters given the PurchaseOrderDocument.
385:             */
386:            private PurchaseOrderPdfParameters getPurchaseOrderPdfParameters(
387:                    PurchaseOrderDocument po) {
388:                String key = po.getPurapDocumentIdentifier().toString(); // key can be any string; chose to use the PO number.
389:                String campusCode = po.getDeliveryCampusCode().toLowerCase();
390:                String imageTempLocation = "";
391:                String logoImage = "";
392:                String directorSignatureImage = "";
393:                String contractManagerSignatureImage = "";
394:                boolean useImage = true;
395:                if (parameterService.parameterExists(
396:                        ParameterConstants.PURCHASING_DOCUMENT.class,
397:                        PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR)) {
398:                    useImage = parameterService.getIndicatorParameter(
399:                            ParameterConstants.PURCHASING_DOCUMENT.class,
400:                            PurapConstants.PDF_IMAGES_AVAILABLE_INDICATOR);
401:                }
402:                // We'll get the imageTempLocation and the actual images only if the useImage is true. If useImage is false, we'll leave the
403:                // images as blank space
404:                if (useImage) {
405:                    imageTempLocation = SpringContext.getBean(
406:                            KualiConfigurationService.class).getPropertyString(
407:                            KFSConstants.TEMP_DIRECTORY_KEY)
408:                            + "/";
409:
410:                    if (imageTempLocation == null) {
411:                        throw new PurapConfigurationException(
412:                                "IMAGE_TEMP_PATH is missing");
413:                    }
414:
415:                    // Get images
416:                    if ((logoImage = imageDao.getLogo(key, campusCode,
417:                            imageTempLocation)) == null) {
418:                        throw new PurapConfigurationException(
419:                                "logoImage is null.");
420:                    }
421:                    if ((directorSignatureImage = imageDao
422:                            .getPurchasingDirectorImage(key, campusCode,
423:                                    imageTempLocation)) == null) {
424:                        throw new PurapConfigurationException(
425:                                "directorSignatureImage is null.");
426:                    }
427:                    if ((contractManagerSignatureImage = imageDao
428:                            .getContractManagerImage(key, po
429:                                    .getContractManagerCode(),
430:                                    imageTempLocation)) == null) {
431:                        throw new PurapConfigurationException(
432:                                "contractManagerSignatureImage is null.");
433:                    }
434:                }
435:
436:                Map<String, Object> criteria = new HashMap<String, Object>();
437:                criteria.put(KFSPropertyConstants.CAMPUS_CODE, po
438:                        .getDeliveryCampusCode());
439:                CampusParameter campusParameter = (CampusParameter) ((List) businessObjectService
440:                        .findMatching(CampusParameter.class, criteria)).get(0);
441:
442:                String statusInquiryUrl = parameterService.getParameterValue(
443:                        ParameterConstants.PURCHASING_DOCUMENT.class,
444:                        PurapConstants.STATUS_INQUIRY_URL);
445:                if (statusInquiryUrl == null) {
446:                    LOG.debug("generatePurchaseOrderPdf() ended");
447:                    throw new PurapConfigurationException(
448:                            "Application Setting INVOICE_STATUS_INQUIRY_URL is missing.");
449:                }
450:
451:                StringBuffer contractLanguage = new StringBuffer();
452:                criteria.put(KFSPropertyConstants.ACTIVE, true);
453:                List<PurchaseOrderContractLanguage> contractLanguageList = (List<PurchaseOrderContractLanguage>) (businessObjectService
454:                        .findMatching(PurchaseOrderContractLanguage.class,
455:                                criteria));
456:                if (!contractLanguageList.isEmpty()) {
457:                    int lineNumber = 1;
458:                    for (PurchaseOrderContractLanguage row : contractLanguageList) {
459:                        if (row.getCampusCode().equals(
460:                                po.getDeliveryCampusCode())) {
461:                            contractLanguage
462:                                    .append(lineNumber
463:                                            + " "
464:                                            + row
465:                                                    .getPurchaseOrderContractLanguageDescription()
466:                                            + "\n");
467:                            ++lineNumber;
468:                        }
469:                    }
470:                }
471:
472:                String pdfFileLocation = parameterService.getParameterValue(
473:                        ParameterConstants.PURCHASING_DOCUMENT.class,
474:                        PurapConstants.PDF_DIRECTORY);
475:                if (pdfFileLocation == null) {
476:                    LOG.debug("savePurchaseOrderPdf() ended");
477:                    throw new PurapConfigurationException(
478:                            "Application Setting PDF_DIRECTORY is missing.");
479:                }
480:
481:                String pdfFileName = "PURAP_PO_"
482:                        + po.getPurapDocumentIdentifier().toString() + "_"
483:                        + System.currentTimeMillis() + ".pdf";
484:
485:                PurchaseOrderPdfParameters pdfParameters = new PurchaseOrderPdfParameters();
486:                pdfParameters.setCampusParameter(campusParameter);
487:                pdfParameters.setContractLanguage(contractLanguage.toString());
488:                pdfParameters
489:                        .setContractManagerSignatureImage(contractManagerSignatureImage);
490:                pdfParameters.setDirectorSignatureImage(directorSignatureImage);
491:                pdfParameters.setImageTempLocation(imageTempLocation);
492:                pdfParameters.setKey(key);
493:                pdfParameters.setLogoImage(logoImage);
494:                pdfParameters.setStatusInquiryUrl(statusInquiryUrl);
495:                pdfParameters.setPdfFileLocation(pdfFileLocation);
496:                pdfParameters.setPdfFileName(pdfFileName);
497:                pdfParameters.setUseImage(useImage);
498:                return pdfParameters;
499:            }
500:
501:            /**
502:             * Creates purchase order pdf document given the input parameters.
503:             * 
504:             * @param po                     The PurchaseOrderDocument.
505:             * @param byteArrayOutputStream  ByteArrayOutputStream that the action is using, where the pdf will be printed to.
506:             * @param isRetransmit           boolean true if this is a retransmit purchase order document.
507:             * @param environment            The current environment used (e.g. DEV if it is a development environment).
508:             * @param retransmitItems        The items selected by the user to be retransmitted.
509:             * @return                       Collection of error strings.
510:             */
511:            private Collection generatePurchaseOrderPdf(
512:                    PurchaseOrderDocument po,
513:                    ByteArrayOutputStream byteArrayOutputStream,
514:                    boolean isRetransmit, String environment,
515:                    List<PurchaseOrderItem> retransmitItems) {
516:                LOG.debug("generatePurchaseOrderPdf() started");
517:
518:                PurchaseOrderPdf poPdf = new PurchaseOrderPdf();
519:                Collection errors = new ArrayList();
520:                try {
521:                    PurchaseOrderPdfParameters pdfParameters = getPurchaseOrderPdfParameters(po);
522:                    poPdf.generatePdf(po, pdfParameters, byteArrayOutputStream,
523:                            isRetransmit, environment, retransmitItems);
524:                    if (pdfParameters.isUseImage()) {
525:                        // Removes temporary images; only need to call once.
526:                        imageDao.removeImages(po.getPurapDocumentIdentifier()
527:                                .toString(), pdfParameters
528:                                .getImageTempLocation());
529:                    }
530:                } catch (PurError e) {
531:                    LOG.error("Caught exception ", e);
532:                    errors.add(e.getMessage());
533:                } catch (PurapConfigurationException pce) {
534:                    LOG.error("Caught exception ", pce);
535:                    errors.add(pce.getMessage());
536:                }
537:
538:                LOG.debug("generatePurchaseOrderPdf() ended");
539:                return errors;
540:            }
541:
542:            /**
543:             * @see org.kuali.module.purap.service.PrintService#generatePurchaseOrderPdf(org.kuali.module.purap.document.PurchaseOrderDocument,
544:             *      java.io.ByteArrayOutputStream, java.lang.String)
545:             */
546:            public Collection generatePurchaseOrderPdf(
547:                    PurchaseOrderDocument po,
548:                    ByteArrayOutputStream byteArrayOutputStream,
549:                    String environment, List<PurchaseOrderItem> retransmitItems) {
550:                return generatePurchaseOrderPdf(po, byteArrayOutputStream,
551:                        TRANSMISSION_IS_NOT_RETRANSMIT, environment,
552:                        retransmitItems);
553:            }
554:
555:            /**
556:             * @see org.kuali.module.purap.service.PrintService#generatePurchaseOrderPdfForRetransmission(org.kuali.module.purap.document.PurchaseOrderDocument,
557:             *      java.io.ByteArrayOutputStream, java.lang.String)
558:             */
559:            public Collection generatePurchaseOrderPdfForRetransmission(
560:                    PurchaseOrderDocument po,
561:                    ByteArrayOutputStream byteArrayOutputStream,
562:                    String environment, List<PurchaseOrderItem> retransmitItems) {
563:                return generatePurchaseOrderPdf(po, byteArrayOutputStream,
564:                        TRANSMISSION_IS_RETRANSMIT, environment,
565:                        retransmitItems);
566:            }
567:
568:            /**
569:             * Saves the purchase order pdf document.
570:             * 
571:             * @param po            The PurchaseOrderDocument.
572:             * @param isRetransmit  boolean true if this is a retransmit purchase order document.
573:             * @param environment   The current environment used (e.g. DEV if it is a development environment).
574:             * @return              Collection of error strings.
575:             */
576:            private Collection savePurchaseOrderPdf(PurchaseOrderDocument po,
577:                    boolean isRetransmit, String environment) {
578:                LOG.debug("savePurchaseOrderPdf() started");
579:
580:                PurchaseOrderPdf poPdf = new PurchaseOrderPdf();
581:                Collection errors = new ArrayList();
582:
583:                PurchaseOrderPdfParameters pdfParameters = null;
584:
585:                try {
586:                    pdfParameters = getPurchaseOrderPdfParameters(po);
587:                    poPdf.savePdf(po, pdfParameters, isRetransmit, environment);
588:                    if (pdfParameters.isUseImage()) {
589:                        // Removes temporary images; only need to call once.
590:                        imageDao.removeImages(po.getPurapDocumentIdentifier()
591:                                .toString(), pdfParameters
592:                                .getImageTempLocation());
593:                    }
594:                } catch (PurError e) {
595:                    LOG.error("Caught exception ", e);
596:                    errors.add(e.getMessage());
597:                } catch (PurapConfigurationException pce) {
598:                    LOG.error("Caught exception ", pce);
599:                    errors.add(pce.getMessage());
600:                } finally {
601:                    try {
602:                        poPdf.deletePdf(pdfParameters.getPdfFileLocation(),
603:                                pdfParameters.getPdfFileName());
604:                    } catch (Throwable e) {
605:                        LOG.error("savePurchaseOrderPdf() Error deleting PDF"
606:                                + pdfParameters.getPdfFileName()
607:                                + " - Exception was " + e.getMessage(), e);
608:                        errors
609:                                .add("Error while deleting the pdf after savePurchaseOrderPdf"
610:                                        + e.getMessage());
611:                    }
612:                }
613:
614:                LOG.debug("savePurchaseOrderPdf() ended");
615:                return errors;
616:            }
617:
618:            /**
619:             * @see org.kuali.module.purap.service.PrintService#savePurchaseOrderPdf(org.kuali.module.purap.document.PurchaseOrderDocument,
620:             *      java.lang.String)
621:             */
622:            public Collection savePurchaseOrderPdf(PurchaseOrderDocument po,
623:                    String environment) {
624:                return savePurchaseOrderPdf(po, TRANSMISSION_IS_NOT_RETRANSMIT,
625:                        environment);
626:            }
627:
628:            /**
629:             * @see org.kuali.module.purap.service.PrintService#savePurchaseOrderPdfForRetransmission(org.kuali.module.purap.document.PurchaseOrderDocument,
630:             *      java.lang.String)
631:             */
632:            public Collection savePurchaseOrderPdfForRetransmission(
633:                    PurchaseOrderDocument po, String environment) {
634:                return savePurchaseOrderPdf(po, TRANSMISSION_IS_RETRANSMIT,
635:                        environment);
636:            }
637:
638:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.