Joget DX Beta Available for Download

Check out Joget DX, the next generation successor to Joget Workflow for faster, simpler digital transformation.

 
1
0
-1

Dear Experts,

 

I'm currently developing some plugin to generate an automatic approval list based on what have been designed in database. But the problem is, my joget app is in MySQL and the data I want to get is from Oracle. I still can't connect to Oracle db with my Plugin. Do you guys have any suggestions?

 

this is my code:

 

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

package org.joget.sample;

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.Map;

import java.util.logging.Level;

import java.util.logging.Logger;

import javax.sql.DataSource;

import org.joget.apps.app.service.AppService;

import org.joget.apps.app.service.AppUtil;

import org.joget.plugin.base.DefaultApplicationPlugin;

import org.joget.plugin.base.PluginManager;

import org.joget.workflow.model.WorkflowAssignment;

import org.joget.workflow.model.service.WorkflowManager;

 

 

/**

 *

 * @author APP

 */

public class GenerateApproverMpr extends DefaultApplicationPlugin {

 

    @Override

    public Object execute(Map props) {

 

 

        AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");

        WorkflowAssignment workflowAssignment = (WorkflowAssignment) props.get("workflowAssignment");

        String processId = appService.getOriginProcessId(workflowAssignment.getProcessId());

        

        PluginManager pluginManager = (PluginManager) props.get("pluginManager");

        WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");

        String orgId = wm.getProcessVariable(processId, "org_id");

        String braCo = wm.getProcessVariable(processId, "branch_code");

        

        // 2. dapatkan data approver1, 2, 3

        String query = "select APPROVAL1, APPROVAL2, APPROVAL3, APPROVAL4, APPROVAL5 from hrocs_v_matrix_approval_mpr where mtx_mpr_id = ? and org_id = ? ";

        Connection con = null; // object utk koneksi

        PreparedStatement ps = null; // objek utk statement / query

        ResultSet rs = null; // objek utk menyimpan hasil query;

        DataSource ds = (DataSource) AppUtil.getApplicationContext().getBean("setupDataSource");

        

        String approval1 = "";

        String approval2 = "";

        String approval3 = "";

        String approval4 = "";

        String approval5 = "";

//        String approval6 = "";

        

        try {

//            con = ds.getConnection();

            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

            con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:db","uname","passwd");

            if (con != null && !con.isClosed()) {

                ps = con.prepareStatement(query);

                ps.setString(1, orgId);

                ps.setString(2, braCo);

                

                rs = ps.executeQuery();

                while (rs.next()) {

                    approval1 = rs.getString("APPROVAL1");

                    approval2 = rs.getString("APPROVAL2");

                    approval3 = rs.getString("APPROVAL3");

                    approval4 = rs.getString("APPROVAL4");

                    approval5 = rs.getString("APPROVAL5");

                }

            }

            

        } catch (SQLException ex) {

            Logger.getLogger(GenerateApproverMpr.class.getName()).log(Level.SEVERE, null, ex);

        } catch (ClassNotFoundException ex) {

            Logger.getLogger(GenerateApproverMpr.class.getName()).log(Level.SEVERE, null, ex);

        } catch (InstantiationException ex) {

            Logger.getLogger(GenerateApproverMpr.class.getName()).log(Level.SEVERE, null, ex);

        } catch (IllegalAccessException ex) {

            Logger.getLogger(GenerateApproverMpr.class.getName()).log(Level.SEVERE, null, ex);

        } finally {

            try {

                if(rs!=null){

                    rs.close();    

                }

                if(ps!=null){

                    ps.close();

                }

                if(con!=null){

                    con.close();

                }

            } catch (SQLException ex) {

                Logger.getLogger(GenerateApproverMpr.class.getName()).log(Level.SEVERE, null, ex);

            }

        }

        

        // set workflow variable value

        PluginManager pluginManagers = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager");

        WorkflowManager workflowManager = (WorkflowManager) pluginManagers.getBean("workflowManager");

        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval1", approval1);

        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval2", approval2);

        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval3", approval3);

        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval4", approval4);

        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval5", approval5);

//        workflowManager.activityVariable(workflowAssignment.getActivityId(),"approval6", approval6);

        return null;

    }

 

    public String getName() {

        return "Generate Approver MPR";

    }

 

    public String getVersion() {

        return "1.0";

    }

 

    public String getDescription() {

        return "";

    }

 

    public String getLabel() {

         return "Generate Approver MPR";

    }

 

    public String getClassName() {

         return getClass().getName();

    }

 

    public String getPropertyOptions() {

         return "";

    }

    

}

 

 

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, it is difficult to tell from just the code. What is the error that you are getting? That should reveal the actual problem.

        CommentAdd your comment...