### Implement Study Error Handler Interface Source: https://github.com/litteice/gpf_study/blob/main/文档/异常处理干预/异常处理干预.md This Java code defines the `IStudyErrorHandler` interface, which extends `CellIntf` and `BaseFeActionIntf`. It provides a static `get()` method for retrieving an instance and a `testErrorHander()` method that throws a PostgreSQL exception. This serves as a sample for testing exception handling. ```Java package cell.gpf.study.errorhandler; import bap.cells.Cells; import cell.CellIntf; import gpf.dc.basic.fe.component.BaseFeActionIntf; import gpf.dc.basic.param.view.BaseFeActionParameter; public interface IStudyErrorHandler extends CellIntf,BaseFeActionIntf{ public static IStudyErrorHandler get() { return Cells.get(IStudyErrorHandler.class); } @Override default Object execute(T input) throws Exception { testErrorHander("测试表"); return null; } @Override default Class getInputParamClass() { return (Class) BaseFeActionParameter.class; } default void testErrorHander(String table) throws Exception { throw new Exception("org.postgresql.util.PSQLException: 错误: 关系 "+table+" 不存在"); } } ``` -------------------------------- ### Log PDF Deletion (After) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs information after a PDF document is deleted, including its UUID and the class names of related form models. It retrieves the current tracer, PDF data, and uses ProcessFormConst to get model class names. ```Java Tracer tracer = TraceUtil.getCurrentTracer(); PDF pdf = (PDF) context.getBeforeOpData(); tracer.info("删除PDF:"+pdf.getUuid()); tracer.info("删除PDF表单模型:"+ProcessFormConst.getFormModelClass(pdf.getUuid())); tracer.info("删除PDF表单历史操作记录模型:"+ProcessFormConst.getHistoryOpLogModelClass(pdf.getUuid())); tracer.info("删除PDF表单当前状态模型:"+ProcessFormConst.getCurrentOpStatusModelClass(pdf.getUuid())); ``` -------------------------------- ### GPF配置参数 Source: https://github.com/litteice/gpf_study/blob/main/文档/网络附件/网络附件.md 在starter.xml文件中配置GPF服务与文件服务的连接参数,包括文件服务类型(local/remote)、本地文件根目录、远程服务地址、账号和密钥等。 ```XML ... ``` -------------------------------- ### Java Exception Handling Intervention Example Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF应用干预/GPF应用干预接口.md Implements the ErrorHandler interface to intercept and re-throw exceptions with custom messages and error codes. It defines an enum for error information and uses regex to match patterns in the exception stack trace. ```Java package gpf.study.errorhandler; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.kwaidoo.ms.tool.ToolUtilities; import com.leavay.dfc.gui.LvUtil; import cmn.anotation.ClassDeclare; import cmn.enums.ErrorLevel; import cmn.exception.BaseException; import cmn.exception.ErrorInfoInterface; import cmn.exception.handler.ErrorHandler; @ClassDeclare(label = "异常处理类代码样例" ,what="异常处理类代码样例,演示如何对服务抛出的异常进行干预包装成业务可以读懂的异常,以下定义了错误码枚举类示例,具体可根据实际项目需要,调整为模型管理配置的错误码和匹配规则" , why = "" , how = "" ,developer="陈晓斌" ,version = "1.0" ,createTime = "205-02-14" ,updateTime = "205-02-14") public class StudyErrorHandler implements ErrorHandler{ /** * */ private static final long serialVersionUID = 7752892622107640444L; /** * 错误码枚举类定义示例 * 带有错误级别、错误码、错误描述 */ public static enum StudyErrorInfo implements ErrorInfoInterface{ ConnectionFail(ErrorLevel.ERROR,"ERROR_0001","数据库连接异常"), TableNotFound(ErrorLevel.INFO,"ERROR_0002","表不存在"), Unkown(ErrorLevel.WARN,"ERROR_9999","未知异常") ; String errorCode; ErrorLevel errorLevel; String errorMsg; private StudyErrorInfo(ErrorLevel level,String errorCode,String errorMsg) { this.errorLevel = level; this.errorCode = errorCode; this.errorMsg = errorMsg; } @Override public String getErrorCode() { return errorCode; } @Override public ErrorLevel getErrorLevel() { return errorLevel; } @Override public String getErrorMsg() { return errorMsg; } } @Override public Throwable handle(Throwable exception) { LvUtil.trace("处理异常:" + exception); String message = exception.getMessage(); LvUtil.trace("message:" + message); String exceptionStack = ToolUtilities.getFullExceptionStack(exception); LvUtil.trace("exceptionStack:" + exceptionStack); //如果是异常基类,可以选择是原封不动抛出,或者是重新转译后抛出 if(exception instanceof BaseException) { return new StudyBizException(((BaseException) exception).getErrorLevel(), ((BaseException) exception).getErrorCode(), exception.getMessage(), exception.getCause()); } if(find(exceptionStack,"PSQLException:(.+)\\timed out")) { return new StudyBizException(StudyErrorInfo.ConnectionFail,exception); }else if(find(exceptionStack,"PSQLException: 错误: 关系 (.+) 不存在")) { return new StudyBizException(StudyErrorInfo.TableNotFound,exception); }else { return new StudyBizException(StudyErrorInfo.Unkown,exception); } } /** * 检测堆栈日志是否匹配正则 * @param errorStack * @param regexStr * @return */ public boolean find(String errorStack,String regexStr) { Pattern regex = Pattern.compile(regexStr, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL | Pattern.MULTILINE); Matcher regexMatcher = regex.matcher(errorStack); return regexMatcher.find(); } public static void main(String[] args) { String errorStack = "org.postgresql.util.PSQLException: 错误: 关系 测试表 不存在\r\n" + "\tat cell.gpf.study.errorhandler.IStudyErrorHandler.testErrorHande"; String regexStr = "PSQLException: 错误: 关系 (.+) 不存在"; System.out.println(new StudyErrorHandler().find(errorStack, regexStr)); } } ``` -------------------------------- ### Generate Short Link for Mini Program Access (Java) Source: https://github.com/litteice/gpf_study/blob/main/文档/小程序二维码分享/小程序二维码分享.md This Java code demonstrates how to construct a mini program link and then generate a short HTTP link for it. It involves configuring project settings like WebSocket URLs, service cells, and initialization parameters, then using `IShortLinkService` to build the links. ```java String wsUrl = "";//用于生成小程序访问的projectConfig的websocket地址,为目标应用的websocket String cell = IAppFeLoginPage.class.getName();//目标应用的服务cell,默认是登录页,有特殊需求可自定义设置 String systemUuid = "";//目标应用的uuid String appCode = "";//目标应用的编号 String appSessionKey = "";//目标应用的会话ID String appId = "";//小程序的appId String envVersion = "";//访问的小程序环境版本dev、trival、release String shortLinkServerUrl = "http://xxx";//提供短链服务的url,如果GPF应用和短链服务为同一个GPF服务中可使用http://xxx提供短链服务 Map projectConfig = new LinkedHashMap<>(); projectConfig.put("url", wsUrl); projectConfig.put("cell", cell); //小程序访问时携带的初始化参数,除以下参数可自定义携带的参数,在目标应用中通过PanelContext.getAppInfo获取 //注意:明文URL Scheme的query参数长度限制为256个字符,initParam不可传递过多参数 Map initParam = new LinkedHashMap<>(); initParam.put(AppCacheUtil.InitParam_SystemUuid, shareAppSetting.getUuid()); initParam.put(AppCacheUtil.InitParam_AppCode, shareAppSetting.getName()); initParam.put(AppCacheUtil.InitParam_AppSessionKey, shareAppSetting.getSessionKey()); //详情页不使用JDV的登录页 initParam.put(AppCacheUtil.InitParam_UseJDVPage, false); projectConfig.put("initParam", initParam); //生成小程序明文URL Scheme String weAppLink = IShortLinkService.get().buildMiniProgramLink(appId, projectConfig,envVersion); //生成Http短链 String shareLink = IShortLinkService.get().buildMiniProgramShortLink(shortLinkServerUrl,weAppLink); ``` -------------------------------- ### Generate Short Links for Web, Mini-Program, and APP Source: https://github.com/litteice/gpf_study/blob/main/文档/短链管理/短链管理.md This Java code demonstrates how to generate short links for different sharing scenarios: web, mini-program, and APP. It utilizes the AppRouter and IShortLinkService to construct the links, handling specific configurations for each type, including URL parameters and routing information. Dependencies include AppRouter, IApplicationService, AppCacheUtil, ShareLinkType, IJsonService, QueryWebSocketConnectUrl, IAppFeLoginPage, CmnUtil, VerifyException, and ToolUtilities. ```java AppRouter router = IApplicationService.get().buildAppRouter(title, viewModel, viewCode, modelId, uuid); String routerShortLink = AppCacheUtil.buildRouterShortLink(router); ShareLinkType shareLinkType = input.getShareLinkTypeEnum(); if(shareLinkType == ShareLinkType.MiniProgram) { Map projectConfig = new LinkedHashMap<>(); //ws请求链接 String wsUrl = QueryWebSocketConnectUrl.query(panelContext); projectConfig.put("url", wsUrl); projectConfig.put("cell", IAppFeLoginPage.class.getName()); Map initParam = new LinkedHashMap<>(); initParam.put(AppCacheUtil.InitParam_SystemUuid, shareAppSetting.getUuid()); initParam.put(AppCacheUtil.InitParam_AppCode, shareAppSetting.getName()); initParam.put(AppCacheUtil.InitParam_AppSessionKey, shareAppSetting.getSessionKey()); try(IJson json = IJsonService.get().getJson()){ initParam.put(AppCacheUtil.InitParam_RouterShortLink, routerShortLink); projectConfig.put("initParam", initParam); } String appId = input.getAppIdVarValue();// if(CmnUtil.isStringEmpty(appId)) throw new VerifyException("小程序appId未配置,请先配置!"); String envVersion = input.getEnvVersionVarValue(); String weAppLink = IShortLinkService.get().buildMiniProgramLink(appId, projectConfig,envVersion); shareLink = IShortLinkService.get().buildMiniProgramShortLink(shortLinkServerUrl,weAppLink); }else if(shareLinkType == ShareLinkType.APP) { if(CmnUtil.isStringEmpty(appShortLink)) { throw new VerifyException("APP短链未配置!"); } String appLink = appShortLink + "/detail?query=#query#"; Map regexMap = new LinkedHashMap<>(); regexMap.put("#query#", routerShortLink); String weAppLink = ToolUtilities.replaceAll(appLink, regexMap); shareLink = IShortLinkService.get().buildMiniProgramShortLink(shortLinkServerUrl,weAppLink); shareLink = shortLinkServerUrl + "/jumpApp.html?appCode="+shareAppCode+"&appLink="+weAppLink; }else if(shareLinkType == ShareLinkType.Url) { shareLink = shortLinkServerUrl+"/" + shareAppCode + "/detail?query=#query#"; Map regexMap = new LinkedHashMap<>(); regexMap.put("#query#", routerShortLink); shareLink = ToolUtilities.replaceAll(shareLink, regexMap); } ``` -------------------------------- ### Prepare for CDC Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This snippet represents the beginning of a method to handle the creation of a CDC (Change Data Capture) object. It initializes a Tracer and likely prepares to access context data. ```Java @Override public void onBeforeCreateCDC(Progress prog, ObserverContext context) throws Exception { ``` -------------------------------- ### 文件服务配置 Source: https://github.com/litteice/gpf_study/blob/main/文档/网络附件/网络附件.md 通过project_config.json文件配置进入文件服务首页的参数,包括项目名称、显示选项、URL、Cell等。 ```JSON { "projectName": "文件服务器", "showBuildLogin": true, "showUrlInput": true, "showCellInput": true, "urlByWebNavigator": false, "urlByServer": false, "url": "ws://127.0.0.1:2020", "cell": "cell.fe.fileserver.IFeFileServerHomePage", "initParam": {}, "lstUrl": [{ "ws://sit.kwaidoo.com:2022": "ws://sit.kwaidoo.com:2022", "_OBJECT_TYPE_": "fe.cmn.data.PairDto" }], "dev": false, "printAbilityLog": true, "useCDN": false, "version": "3.7.0" } ``` -------------------------------- ### Java: Handle Before Create User Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is invoked before a user model is created. It retrieves the tracer and the FormModel from the context, logging information about the user model creation. ```Java @Override public void onBeforeCreateUserModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getBeforeOpData(); tracer.info("新增用户模型前:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### Java: Handle Before Create Generic Data Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method handles the 'before create' event for various data types (PDC, Action, User, Org, Role, Form). It retrieves the tracer and context data, logging specific information based on the data type. ```Java @Override public void onBeforeCreate(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); //获取上下文中的dao对象 IDao dao = context.getDao(); Object data = context.getBeforeOpData(); if(data instanceof PDC) { tracer.info("创建PDC前:"+((PDC) data).getCode()); }else if(data instanceof Action) { tracer.info("创建Action前:"+((Action) data).getCode()); }else if(data instanceof User) { tracer.info("创建User前:"+((User) data).getCode()); }else if(data instanceof Org) { tracer.info("创建Org前:"+((Org) data).getCode()); }else if(data instanceof Role) { tracer.info("创建Role前:"+((Role) data).getCode()); }else if(data instanceof Form) { tracer.info("创建Form前:"+((Form) data).getUuid()); } } ``` -------------------------------- ### Study Proxy Service for Error Handling Source: https://github.com/litteice/gpf_study/blob/main/文档/异常处理干预/异常处理干预.md This Java class, `StudyProxyService`, demonstrates how to create a singleton service proxy that utilizes the `IStudyErrorHandler` interface. It includes a `getTestMgr()` method for obtaining the proxy instance and a `testErrorHandler()` method to trigger the error handling mechanism by calling `testErrorHander()`. ```Java package gpf.study.errorhandler; import cell.gpf.study.errorhandler.IStudyErrorHandler; import cmn.util.ProxyUtil; /** * 服务代理类样例,代理类通过单例方式构建,避免反复构建动态代理类的开销 */ public class StudyProxyService { private static IStudyErrorHandler testMgr = null; public synchronized static IStudyErrorHandler getTestMgr() { if (testMgr == null) { testMgr = (IStudyErrorHandler) ProxyUtil.newProxyInstance(IStudyErrorHandler.get(), new StudyErrorHandler()); } return testMgr; } public static void testErrorHandler() throws Exception { IStudyErrorHandler testMgr = getTestMgr(); testMgr.testErrorHander("测试表"); } } ``` -------------------------------- ### Java: Handle Before Create Organization Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is called before an organization model is created. It retrieves the current tracer and the FormModel from the context, logging information about the new organization model. ```Java public void onBeforeCreateOrgModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getBeforeOpData(); tracer.info("新增组织模型前:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### Java: Handle After Create User Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is executed after a user model has been created. It obtains the tracer and the FormModel from the context, logging details of the newly created user. ```Java @Override public void onAfterCreateUserModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getAfterOpData(); tracer.info("新增用户模型后:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### Java 进度通知代码样例 Source: https://github.com/litteice/gpf_study/blob/main/文档/表单提交进度通知/表单提交进度通知干预.md 此代码样例展示了如何在Java中实现表单提交按钮的进度干预。它演示了如何发送进度消息、显示确认对话框、显示消息框以及发送自定义数据帧。该实现依赖于gpf.dc.action和cmn包中的类。 ```Java package cell.study.progress; import java.util.LinkedHashMap; import java.util.Map; import bap.cells.Cells; import cell.CellIntf; import cmn.anotation.ClassDeclare; import cmn.dto.Progress; import cmn.enums.ProgressConfirmOperation; import cmn.enums.ProgressMessageType; import cmn.util.ProgressUtil; import gpf.dc.action.intf.BaseActionIntf; import gpf.dc.action.param.BaseActionParameter; @ClassDeclare(label = "进度通知代码样例" ,what="进度通知代码样例" , why = "" , how = "" ,developer="陈晓斌" ,version = "1.0" ,createTime = "205-01-17" ,updateTime = "205-01-17") public interface IActionStudyProgress extends CellIntf,BaseActionIntf { public static IActionStudyProgress get(){ return Cells.get(IActionStudyProgress.class);} @Override default Object execute(T input) throws Exception { Progress prog = input.getRtx().getProgress(); //发送消息 ProgressUtil.setMessage(prog, "发送一条进度消息", true); ProgressUtil.sendProcess(prog, 10, "发送一条带进度的消息", true); //弹出确认框,注意要考虑流程纯后台提交,上下文没有携带进度通知对象的处理场景,默认null是返回ProgressConfirmOperation.YES的处理结果 int option = ProgressUtil.showConfirmDialog(prog,"请确认是否继续进行?", "请选择", ProgressConfirmOperation.YES); if(option == ProgressConfirmOperation.YES.getValue()) { //弹出消息框 ProgressUtil.showMessageDialog(prog,"你选择了是!\n你选择了是!\n你选择了是!\n你选择了是!\n你选择了是!\n你选择了是!\n你选择了是!\n你选择了是!\n", "", ProgressMessageType.success); }else { ProgressUtil.showMessageDialog(prog,"你选择了否!", "", ProgressMessageType.info); } //弹出确认框 option = ProgressUtil.showConfirmDialog(prog,"请确认是否继续进行?", "请选择1", ProgressConfirmOperation.YES,ProgressMessageType.info); if(option == ProgressConfirmOperation.YES.getValue()) { //弹出消息框 ProgressUtil.showMessageDialog(prog,"你选择了是!", "", ProgressMessageType.warning); }else { //弹出消息框 ProgressUtil.showMessageDialog(prog,"你选择了否!", "", ProgressMessageType.error); } //构建自定义 Map userObject = new LinkedHashMap<>(); userObject.put("选项", option); //发送自定义对象到进度通知 ProgressUtil.sendDataFrame(prog,userObject); //断言用户是否执行取消操作,确认取消将抛出UserCancelException ProgressUtil.assertCancel(prog); return null; } } ``` -------------------------------- ### Log Batch User Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of a User object before batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建User前:"+((User) data).getCode()); ``` -------------------------------- ### Log Action Model Creation (Before) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs information about an ActionModel before it is created, including its ID and table name. ```Java @Override public void onBeforeCreateActionModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); ActionModel formModel = (ActionModel) context.getBeforeOpData(); tracer.info("新增动作模型前:"+formModel.getId()+ উত্ত "+formModel.getTableName()); } ``` -------------------------------- ### Client File Upload Sequence Diagram Source: https://github.com/litteice/gpf_study/blob/main/文档/网络附件/网络附件方案设计.md This sequence diagram illustrates the process of a client uploading a file through the GPF system to a file server. It covers the initial upload of the file as a temporary file, receiving a unique identifier, and then submitting form data to register the file formally. ```mermaid sequenceDiagram actor client participant GPF participant 文件服务器 activate client client->>GPF:上传文件 GPF->>文件服务器:上传为临时文件 文件服务器-->>GPF:(临时文件)文件唯一标识码 GPF->>client:上传结果 deactivate client activate client client->>GPF:提交表单数据 activate GPF GPF->>文件服务器:登记为正式文件(文件唯一标识码) 文件服务器-->>GPF:登记结果 GPF-->>client:数据操作结果 deactivate GPF deactivate client ``` -------------------------------- ### Java: Handle After Create Organization Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is executed after an organization model has been created. It obtains the tracer and the FormModel from the context, logging details of the newly created organization. ```Java @Override public void onAfterCreateOrgModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getAfterOpData(); tracer.info("新增组织模型后:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### Log Batch Org Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of an Org object before batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Org前:"+((Org) data).getCode()); ``` -------------------------------- ### Log Batch User Creation After Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of a User object after batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建User后:"+((User) data).getCode()); ``` -------------------------------- ### Log Batch Role Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of a Role object before batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Role前:"+((Role) data).getCode()); ``` -------------------------------- ### Log PDF Creation (Before) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the UUID of a PDF document before it is created. It retrieves the current tracer and the PDF data from the context. ```Java Tracer tracer = TraceUtil.getCurrentTracer(); PDF pdf = (PDF) context.getBeforeOpData(); tracer.info("新增PDF前:"+pdf.getUuid()); ``` -------------------------------- ### Log Batch Action Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of an Action object before batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Action前:"+((Action) data).getCode()); ``` -------------------------------- ### Java: Handle After Create Generic Data Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method handles the 'after create' event for various data types (PDC, Action, User, Org). It retrieves the tracer and context data, logging specific information based on the data type. ```Java @Override public void onAfterCreate(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); //获取上下文中的dao对象 IDao dao = context.getDao(); Object data = context.getAfterOpData(); if(data instanceof PDC) { tracer.info("创建PDC后:"+((PDC) data).getCode()); }else if(data instanceof Action) { tracer.info("创建Action后:"+((Action) data).getCode()); }else if(data instanceof User) { tracer.info("创建User后:"+((User) data).getCode()); }else if(data instanceof Org) { ``` -------------------------------- ### Log Batch Org Creation After Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of an Org object after batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Org后:"+((Org) data).getCode()); ``` -------------------------------- ### GPF数据操作监听接口定义 Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md 定义了GPF数据操作监听的接口,继承了多种操作监听器,并提供了一个静态方法用于获取实例。该接口是实现数据操作干预的基础。 ```java package cell.gpf.study.observer; import bap.cells.Cells; import cell.CellIntf; import cmn.anotation.ClassDeclare; import gpf.dc.intf.ActionModelOpObserver; import gpf.dc.intf.CDCOpObserver; import gpf.dc.intf.FormModelOpObserver; import gpf.dc.intf.FormOpObserver; import gpf.dc.intf.OrgModelOpObserver; import gpf.dc.intf.PDFFormOpObserver; import gpf.dc.intf.PDFOpObserver; import gpf.dc.intf.UserModelOpObserver; @ClassDeclare(label = "GPF数据操作监听样例" ,what="GPF数据操作监听样例" , why = "" , how = "实现相应数据操作监听接口添加自定义的处理逻辑" ,developer="陈晓斌" ,version = "1.0" ,createTime = "205-01-24" ,updateTime = "205-01-24") public interface IStudyGpfDataOpObserver extends CellIntf,FormModelOpObserver,FormOpObserver,ActionModelOpObserver,UserModelOpObserver,OrgModelOpObserver,CDCOpObserver,PDFOpObserver,PDFFormOpObserver{ static IStudyGpfDataOpObserver get() { return Cells.get(IStudyGpfDataOpObserver.class); } } ``` -------------------------------- ### Java: Handle Before Update User Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is called before a user model is updated. It retrieves the tracer and the FormModel from the context, logging information related to the user model update. ```Java @Override public void onBeforeUpdateUserModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getAfterOpData(); tracer.info("更新用户模型前:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### Log Form Creation (Before) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the form object before a new PDF form is created. It retrieves the current tracer and the Form data from the context. ```Java Tracer tracer = TraceUtil.getCurrentTracer(); Form form = (Form) context.getBeforeOpData(); tracer.info("新增流程表单前:"+form); ``` -------------------------------- ### Log Batch Role Creation After Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of a Role object after batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Role后:"+((Role) data).getCode()); ``` -------------------------------- ### Wild File Cleanup Mechanism Diagram Source: https://github.com/litteice/gpf_study/blob/main/文档/网络附件/网络附件方案设计.md This sequence diagram describes the mechanism for cleaning up 'wild' or unreferenced temporary files. It shows the file server periodically cleaning temporary files and the GPF system reporting file references to the file server for comparison and cleanup. ```mermaid sequenceDiagram participant GPF participant 文件服务器 activate 文件服务器 文件服务器->>文件服务器:定期清理临时文件 deactivate 文件服务器 activate GPF GPF->>文件服务器:定期上报文件引用列表 文件服务器->>文件服务器:比对文件引用情况,设置不再引用文件为临时文件,等待清理 文件服务器-->>GPF:处理结果 deactivate GPF ``` -------------------------------- ### Log PDF Creation (After) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs information after a PDF document is created, including its UUID and associated form model details. It retrieves the current tracer, PDF data, and queries for related form models. ```Java Tracer tracer = TraceUtil.getCurrentTracer(); PDF pdf = (PDF) context.getAfterOpData(); tracer.info("新增PDF后:"+pdf.getUuid()); FormModel formModel = IPDFMgr.get().queryFormModelOfPDF(pdf.getUuid()); FormModel hisOpLogModel = IPDFMgr.get().queryOperateLogModelOfPDF(pdf.getUuid()); FormModel currStatuModel = IPDFMgr.get().queryCurrOpStatusLogModelOfPDF(pdf.getUuid()); tracer.info("新增PDF表单模型:"+formModel.getId()+ কমান্ড+formModel.getTableName()); tracer.info("新增PDF表单历史操作记录模型:"+hisOpLogModel.getId()+ কমান্ড+hisOpLogModel.getTableName()); tracer.info("新增PDF表单当前状态模型:"+currStatuModel.getId()+ কমান্ড+currStatuModel.getTableName()); ``` -------------------------------- ### Log CDC Creation (Before) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs information about a CDC (Change Data Capture) record before it is created. It retrieves the current tracer and the CDC data from the context, then logs the CDC ID and table name. ```Java Tracer tracer = TraceUtil.getCurrentTracer(); CDC formModel = (CDC) context.getBeforeOpData(); tracer.info("新增CDC前:"+formModel.getId()+ কমান্ড+formModel.getTableName()); ``` -------------------------------- ### Log Org Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of an Org object after its creation. This snippet is part of a larger observer pattern implementation. ```Java tracer.info("创建Org后:"+((Org) data).getCode()); ``` -------------------------------- ### Log Action Model Creation (After) Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs information about an ActionModel after it has been created, including its ID and table name. ```Java @Override public void onAfterCreateActionModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); ActionModel formModel = (ActionModel) context.getAfterOpData(); tracer.info("新增动作模型后:"+formModel.getId()+ উত্ত "+formModel.getTableName()); } ``` -------------------------------- ### Log Batch Action Creation After Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of an Action object after batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建Action后:"+((Action) data).getCode()); ``` -------------------------------- ### Initialize Application Cache Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF应用干预/GPF应用干预接口.md This Java code provides an interface for initializing application cache within the GPF framework. It allows for intervention during application loading to set up new application caches or modify existing configurations. ```Java package cell.gpf.study.app; import cell.CellIntf; import fe.cmn.app.Context; import gpf.dc.basic.fe.intf.AppCacheMgrIntf; import gpf.dc.basic.param.view.dto.ApplicationSetting; public interface IStudyAppCacheMgr extends CellIntf,AppCacheMgrIntf{ @Override default void initCache(Context context) throws Exception { //在应用加载时初始化应用缓存 // setCacheValue(context, key, value); } } ``` -------------------------------- ### Implement Custom Scheduled Task Source: https://github.com/litteice/gpf_study/blob/main/文档/自定义定时任务/自定义定时任务.md This Java interface defines a custom scheduled task that implements the `ScheduleTaskIntf`. It includes a default `execute` method to process input parameters and log information. ```Java package cell.study.scheduletask; import cell.CellIntf; import cell.study.scheduletask.param.ActionStudyScheuldTaskParam; import cmn.anotation.ClassDeclare; import cmn.dto.intf.ScheduleTaskIntf; import cmn.util.TraceUtil; import cmn.util.Tracer; @ClassDeclare(label = "定时任务实现样例" ,what="定时任务实现样例" , why = "" , how = "" ,developer="陈晓斌" ,version = "1.0" ,createTime = "205-01-21" ,updateTime = "205-01-21") public interface IActionStudyScheduleTask extends CellIntf,ScheduleTaskIntf{ @Override default Object execute(Object input) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); ActionStudyScheuldTaskParam param = (ActionStudyScheuldTaskParam)input; tracer.info(param.getInputText()); return null; } } ``` -------------------------------- ### Log Batch PDC Creation Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md Logs the code of a PDC object before batch creation. This snippet iterates through a list of objects and logs specific types. ```Java tracer.info("批量创建PDC前:"+((PDC) data).getCode()); ``` -------------------------------- ### 定义业务异常基类 (Java) Source: https://github.com/litteice/gpf_study/blob/main/文档/异常处理干预/异常处理干预.md 演示如何定义一个继承自 `cmn.exception.BaseException` 的业务异常类 `StudyBizException`。该类允许自定义错误码、错误级别和消息,并提供了构造函数来处理不同情况的异常。 ```Java package gpf.study.errorhandler; import cmn.enums.ErrorLevel; import cmn.exception.BaseException; import cmn.exception.ErrorInfoInterface; /** *\t演示继承BaseException的业务异常,带有错误码和错误级别定义 */ public class StudyBizException extends BaseException{ /** * */ private static final long serialVersionUID = -5312334256208309217L; public StudyBizException(ErrorInfoInterface errorInfo) { super(errorInfo); } public StudyBizException(ErrorInfoInterface errorInfo,Throwable cause) { super(errorInfo,cause); } public StudyBizException(ErrorLevel errorLevel,String errorCode,String message) { super(errorLevel, errorCode, message); } public StudyBizException(ErrorLevel errorLevel,String errorCode,String message,Throwable cause) { super(errorLevel, errorCode, message); } } ``` -------------------------------- ### Java: Handle Before Delete User Model Source: https://github.com/litteice/gpf_study/blob/main/文档/GPF数据操作监听/GPF数据操作监听.md This method is called before a user model is deleted. It retrieves the tracer and the FormModel from the context, logging information prior to the user deletion. ```Java @Override public void onBeforeDeleteUserModel(Progress prog, ObserverContext context) throws Exception { Tracer tracer = TraceUtil.getCurrentTracer(); FormModel formModel = (FormModel) context.getBeforeOpData(); tracer.info("删除用户模型前:"+formModel.getId()+ কমান্ড+formModel.getTableName()); } ``` -------------------------------- ### GPF上传网络附件 Source: https://github.com/litteice/gpf_study/blob/main/文档/网络附件/网络附件.md 使用Java代码通过GPF的IFormMgr服务上传网络附件,并将附件信息设置到表单的指定属性中。 ```Java //上传网络附件 WebAttachData webAttach = IFormMgr.get().uploadWebAttach("test.txt", "测试上传附件".getBytes()); List lstWebAttach = CollUtil.newArrayList(webAttach); form.setAttrValue(StudyFormMockConst.WebAttachField, lstWebAttach); ```