Wednesday, March 29, 2023

log insertion from methods to db

 Bean method

-------------------------


    private void logGenericTC(String type, String title, String message, String className,String methodName, Exception e) {

        OperationBinding logGenericTCOP = ADFUtils.findOperation("logGenericTC");

        if(logGenericTCOP != null) {

            Map map = logGenericTCOP.getParamsMap();

            map.put("type",type);

            map.put("title",title);

            map.put("message",message);

            map.put("className",className);

            map.put("methodName",methodName);

            map.put("detailedMessage",LogUtils.returnStackTrace(e));

            logGenericTCOP.execute();

        }

    }


        }catch(Exception exp){

            JSFUtils.addFormattedFacesErrorMessage("System encountered an exception while running TC." +

                                                   "Please contact your System Administrator.", "",

                                                   FacesMessage.SEVERITY_ERROR);

            exp.printStackTrace();

            logGenericTC(LogUtils.ERROR, "System encountered an exception while running TC.", 

                                               "Please contact your System Administrator.", "Vetting","runTcDialogListener", exp);

        }


AM Method

------------------------------

    public  void logGenericTC(String type, String title, String message, String className,String methodName, String detailedMessage ){

        try{

            Map pMap =  ADFContext.getCurrent().getPageFlowScope();

            ViewObject vo = getRmiGenericLogsView1();

            

            Row createRow = vo.createRow();

            createRow.setAttribute("DetailedMessage", detailedMessage);

            createRow.setAttribute("Type", type);

            createRow.setAttribute("Title", title);

            createRow.setAttribute("Message", message);

            if(pMap.get("P_SOURCE_ID") == null || "".equals(pMap.get("P_SOURCE_ID")))

                createRow.setAttribute("SourceId", new BigDecimal("0"));

            else

                createRow.setAttribute("SourceId", new BigDecimal(pMap.get("P_SOURCE_ID")+""));

            createRow.setAttribute("SourceTable", pMap.get("P_SOURCE_TABLE"));

            createRow.setAttribute("SourceTableColumn", pMap.get("P_SOURCE_TABLE_COLUMN"));

            createRow.setAttribute("SourceType", pMap.get("P_SOURCE_TYPE"));

            createRow.setAttribute("ClassName", className);

            createRow.setAttribute("MethodName", methodName);

            createRow.setAttribute("Param1", pMap.get("DPC_CATEGORY"));

            

            vo.insertRow(createRow);

            getDBTransaction().commit();

            

        }catch(Exception e){

            e.printStackTrace();

        }

        

    }

----------------------------------this is the script we need to keep it in where you want to implement---------

logGenericTC(LogUtils.ERROR, "System encountered an exception while fetching responsibility details.", 

                                                               "Please contact your System Administrator.", "RMIManualTradeComplianceAppModuleImpl","userSessionValidation", LogUtils.returnStackTrace(e));

No comments:

Post a Comment