package oracle.apps.pon.printing.cp; import java.io.InputStream; import java.io.FileOutputStream; import oracle.jbo.domain.BlobDomain; import oracle.apps.fnd.cp.request.CpContext; import oracle.apps.fnd.cp.request.LogFile; import oracle.apps.fnd.cp.request.OutFile; import oracle.apps.fnd.cp.request.ReqCompletion; import oracle.apps.fnd.util.ParameterList; import oracle.apps.fnd.util.NameValueType; import oracle.apps.fnd.framework.OAApplicationModuleFactory; import oracle.apps.fnd.framework.server.OADBTransaction; import oracle.apps.fnd.framework.server.OAApplicationModuleImpl; import oracle.apps.pon.printing.server.SourcingPrintingAMImpl; /** * This class is a JavaConcurrentProgram to generate a Sourcing Negotiation * PDF event from the ConcurrentRequest utility rather than from the webpage. * * This tool allows sourcing events to be printed before they are published to * the suppliers so they may be reviewed by the team without the need to create * multiple revisions to the event before publishing. */ public class GenerateNegotiationPdfCp implements oracle.apps.fnd.cp.request.JavaConcurrentProgram { //class level variables public static String sourcingPrintingAmName = "oracle.apps.pon.printing.server.SourcingPrintingAM"; private LogFile m_appsLogFile; /** * Default Constructor, does nothing */ public GenerateNegotiationPdfCp() { }//End of constructor GenerateNegotiationPdfCp() /** * Main entry point for the application. This will accept the conext * and run the tools needed to generate a PDF of a sourcing negotiation */ public void runProgram(CpContext cpContext) { //Local variables OutFile out = cpContext.getOutFile(); m_appsLogFile = cpContext.getLogFile(); ReqCompletion lRC = cpContext.getReqCompletion(); BlobDomain pdf = null; Integer rfxId = null; //Grad the P_SOURCING_EVENT_ID catagory from the Concurrent context ParameterList list = cpContext.getParameterList(); m_appsLogFile.writeln("Retrieving P_SOURCING_EVENT_ID parameter", LogFile.STATEMENT); try { while(list.hasMoreElements()) { NameValueType namevaluetype = list.nextParameter(); if(namevaluetype.getName().equalsIgnoreCase("P_SOUCING_EVENT_ID")) { String val = namevaluetype.getValue(); if(val != null) { rfxId = new Integer(Integer.parseInt(val)); } } } } catch(Exception ex) { m_appsLogFile.writeln("The following error occured while retrieving " + "the P_SOURCING_EVENT_ID parameter " + ex.getMessage(), LogFile.ERROR); lRC.setCompletion(ReqCompletion.ERROR, "Failed to get P_SOURCING_EVENT_ID parameter"); return; } //Call getNegotiationPdf(string, string, string, string, Boolean) m_appsLogFile.writeln("Retrieving PDF file", LogFile.STATEMENT); try { /** * Get the BlobDomain so we can write it to the output file */ SourcingPrintingAMImpl pdflib = (SourcingPrintingAMImpl)getSourcingAppModule(cpContext); OADBTransaction trans = pdflib.getOADBTransaction(); String clientTimeZone = trans.getProfile("CLIENT_TIMEZONE_ID"); String serverTimeZone = trans.getProfile("SERVER_TIMEZONE_ID"); String dateFormat = trans.getProfile("ICX_DATE_FORMAT_MASK"); pdf = pdflib.getNegotiationPdf(rfxId.toString(), clientTimeZone, serverTimeZone, dateFormat, new Boolean(true)); } catch(Exception ex) { m_appsLogFile.writeln("The following error occured while retrieving the " + "PDF from BI Publisher: " + ex.getMessage(), LogFile.ERROR); lRC.setCompletion(ReqCompletion.ERROR, "Failed to get PDF from BI Publisher parameter"); return; } //Write the PDF to the output file 2k at a time m_appsLogFile.writeln("Writting the PDF to the output file", LogFile.STATEMENT); try { InputStream iStream = pdf.getBinaryStream(); FileOutputStream oStream = new FileOutputStream(out.getFileName(), false); byte[] buff = new byte[2048]; int count; while((count = iStream.read(buff)) >= 0) { oStream.write(buff, 0, count); } iStream.close(); oStream.flush(); oStream.close(); lRC.setCompletion(ReqCompletion.NORMAL, "SUCCESS!"); } catch(Exception ex) { m_appsLogFile.writeln("Failed to write PDF to output file [" + out.getFileName() + "] with the following error: " + ex.getMessage(), LogFile.ERROR); lRC.setCompletion(ReqCompletion.ERROR, "Failed writing to the output file"); return; } }//End of method runProgram(CpConext) /** * This method uses the OAApplicationModuleFactory to create an instance of * an Oracle Application Implimentation Module factory. The current context * of the ConcurrentRequest program is sent along so the Application Module * can initialize properly. */ protected OAApplicationModuleImpl getSourcingAppModule(CpContext cpcontext) { OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl) OAApplicationModuleFactory.createRootOAApplicationModule( cpcontext, sourcingPrintingAmName); return oaapplicationmoduleimpl; }//End of getSourcingAppModule(CpContext) }//End of class GenerateNegotiationPdfCp
其中最重要的方法便是在请求中调用AM。
SourcingPrintingAMImpl pdflib = (SourcingPrintingAMImpl)getSourcingAppModule(cpContext);
protected OAApplicationModuleImpl getSourcingAppModule(CpContext cpcontext)
{
OAApplicationModuleImpl oaapplicationmoduleimpl =
(OAApplicationModuleImpl)
OAApplicationModuleFactory.createRootOAApplicationModule(
cpcontext, sourcingPrintingAmName);
return oaapplicationmoduleimpl;
}//End of getSourcingAppModule(CpContext)
参考资料:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· Apache Tomcat RCE漏洞复现(CVE-2025-24813)