Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Code Block |
---|
ERROR 06 Mar 2015 10:49:33 org.joget.apps.app.web.JsonResponseFilter - java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/SimpleDriverDataSource java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/SimpleDriverDataSource .... .... .... Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.SimpleDriverDataSource not found by nz.net.snap.workflow-joget-archiver [1] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) |
Code Block |
---|
package org.joget.workflow;
import java.io.IOException;
import java.sql.Driver;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.joget.apps.app.dao.FormDefinitionDao;
import org.joget.apps.app.model.AppDefinition;
import org.joget.apps.app.model.FormDefinition;
import org.joget.apps.app.service.AppService;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.FormRowSet;
import org.joget.commons.util.DynamicDataSourceManager;
import org.joget.commons.util.LogUtil;
import org.joget.plugin.base.DefaultApplicationPlugin;
import org.joget.plugin.base.PluginProperty;
import org.joget.plugin.base.PluginWebSupport;
import org.joget.workflow.model.WorkflowAssignment;
import org.springframework.beans.BeansException;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
public class MyTool extends DefaultApplicationPlugin implements PluginWebSupport {
private static final String TAG = "MyTool1";
@Override
public String getName() {
return "My Tool";
}
@Override
public String getVersion() {
return "1.0";
}
@Override
public String getDescription() {
return getName();
}
@Override
public String getLabel() {
return getName();
}
@Override
public String getClassName() {
return getClass().getName();
}
@Override
public PluginProperty[] getPluginProperties() {
return null;
}
@Override
public String getPropertyOptions() {
return null;
}
@Override
public void webService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String action = request.getParameter("action");
LogUtil.info(TAG, ">>>>>>>action=" + action);
String processId = request.getParameter("id");
//
saveRecord(processId);
} catch (Exception e) {
LogUtil.info(TAG, e.getMessage());
}
}
@Override
public Object execute(Map properties) {
WorkflowAssignment wfAssignment = (WorkflowAssignment) properties.get("workflowAssignment");
LogUtil.debug(TAG, wfAssignment.getActivityId());
String processId = appService().getOriginProcessId(wfAssignment.getProcessId());
return saveRecord(processId);
}
private Object saveRecord(String processId) {
AppService appService = appService();
try {
//Get primary key
AppDefinition appDef = appService.getAppDefinitionForWorkflowProcess(processId);
//Get existing data
String provFormDefId = "my_from_def";
FormDefinition provFormDef = formDefDao().loadById(provFormDefId, appDef);
FormRowSet provDataSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), provFormDefId, processId);
String provTable = provFormDef.getTableName();
LogUtil.info(TAG, ">>>>>>>>>>>>>>>>>>>>>> " + provDataSet.toString());
try {
String driverClass = "org.postgresql.Driver";
String dbURL = "jdbc:postgresql://localhost/workflow";
String user = "admin";
String password = "mypass";
String dbSchema = "public";
Driver driver = (Driver) Class.forName(driverClass).newInstance();
//
DataSource ds = new SimpleDriverDataSource(driver, dbURL, user, password);
SimpleJdbcInsert insert = new SimpleJdbcInsert(ds);
insert.withSchemaName(dbSchema);
insert.withTableName(provTable);
insert.executeAndReturnKey(provDataSet.get(0).getCustomProperties());
} catch (Exception e) {
LogUtil.info(TAG, e.getMessage());
LogUtil.error(TAG, e, e.getMessage());
} finally {
DynamicDataSourceManager.changeProfile("default");
}
} catch (Exception e) {
LogUtil.info(TAG, e.getMessage());
LogUtil.error(TAG, e, e.getMessage());
} finally {
}
return null;
}
private static FormDefinitionDao formDefDao() throws BeansException {
return (FormDefinitionDao) AppUtil.getApplicationContext().getBean("formDefinitionDao");
}
private static AppService appService() throws BeansException {
return (AppService) AppUtil.getApplicationContext().getBean("appService");
}
}
|