package com.vci.client.workflow.launch;
|
|
import java.util.LinkedHashMap;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.FlowLayout;
|
|
import javax.imageio.ImageIO;
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JPanel;
|
import javax.swing.border.EmptyBorder;
|
import javax.swing.JSplitPane;
|
import javax.swing.border.TitledBorder;
|
import javax.swing.event.TreeExpansionEvent;
|
import javax.swing.event.TreeExpansionListener;
|
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionListener;
|
|
import java.awt.GridBagLayout;
|
import javax.swing.JLabel;
|
import java.awt.GridBagConstraints;
|
import javax.swing.JTextField;
|
import java.awt.Insets;
|
|
import javax.swing.DefaultListModel;
|
import javax.swing.ImageIcon;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
import javax.swing.JComboBox;
|
import javax.swing.JTabbedPane;
|
import javax.swing.JTable;
|
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumnModel;
|
import javax.swing.tree.TreePath;
|
import javax.swing.JList;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.TransmitTreeObject;
|
import com.vci.client.common.objects.DeptObject;
|
import com.vci.client.common.objects.RoleObject;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.common.oq.OQTool;
|
import com.vci.client.framework.delegate.RightManagementClientDelegate;
|
import com.vci.client.framework.systemConfig.stafforgmanage.RightManagementTreeCellRenderer;
|
import com.vci.client.oq.QTClient;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.components.VCIJLabel;
|
import com.vci.client.ui.swing.components.VCIJScrollPane;
|
import com.vci.client.ui.table.VCIBaseTableModel;
|
import com.vci.client.ui.table.VCIBaseTableNode;
|
import com.vci.client.ui.tree.VCIBaseTree;
|
import com.vci.client.ui.tree.VCIBaseTreeModel;
|
import com.vci.client.ui.tree.VCIBaseTreeNode;
|
import com.vci.client.workflow.commom.FlowCustomProperties;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.client.workflow.template.object.ProcessCategoryObject;
|
import com.vci.client.workflow.template.object.ProcessDefinitionObject;
|
import com.vci.common.qt.object.Condition;
|
import com.vci.common.qt.object.Connector;
|
import com.vci.common.qt.object.QueryTemplate;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.data.BusinessObject;
|
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseEvent;
|
import java.awt.image.BufferedImage;
|
import java.io.ByteArrayInputStream;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.HashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Map.Entry;
|
|
public class LaunchDialog extends JDialog {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 2539859820247075177L;
|
private final JPanel contentPanel = new JPanel();
|
private JTextField processName;
|
private JTable dataTable;
|
private JComboBox processTemplate;
|
private JTextArea processDec;
|
private JList taskList;
|
private DefaultListModel taskListModel;
|
|
private JList userList;
|
|
private DefaultListModel resultListModel;
|
private DefaultListModel tmpListModel = new DefaultListModel();
|
|
private String processType = "";
|
private boolean saveFlag = false;
|
private VCIBaseTree rightManagementTree;
|
private VCIBaseTreeModel treeModel;
|
private UserObject userInfo;
|
private TransmitTreeObject transmitTreeObject = new TransmitTreeObject();
|
// private Map<String,List<String>> taskAndUserMap = new HashMap<String,List<String>>();
|
private Map<String,List<String>> taskAndUserMap = (Map<String,List<String>>)new LinkedHashMap();
|
private Map<String,DefaultListModel> taskAndUserMap_1 = new HashMap<String,DefaultListModel>();
|
private String processTemplateName = "";
|
private String processNameValue;
|
private String processDecValue;
|
|
private String userValue ;
|
private String roleValue ;
|
private String departmentValue ;
|
|
private JScrollPane treeScrollPane;
|
private JPanel panel_2;
|
private VCIBaseTreeNode selectNode;
|
|
private VCIBaseTreeNode rootNode = new VCIBaseTreeNode("人员组织", "root");
|
|
private Map<String, Map<String,String>> resMap = new HashMap<String,Map<String,String>>();
|
public String getProcessTemplateName() {
|
return processTemplateName;
|
}
|
|
public void setProcessTemplateName(String processTemplateName) {
|
this.processTemplateName = processTemplateName;
|
}
|
|
public JComboBox getProcessTemplate() {
|
return processTemplate;
|
}
|
|
public void setProcessTemplate(JComboBox processTemplate) {
|
this.processTemplate = processTemplate;
|
}
|
|
public String getProcessName() {
|
return processNameValue;
|
}
|
|
public void setProcessName(String processNameValue) {
|
this.processNameValue = processNameValue;
|
this.processName.setText(processNameValue);
|
}
|
|
public String getProcessDec() {
|
return processDecValue;
|
}
|
|
public void setProcessDec(String processDecValue) {
|
this.processDecValue = processDecValue;
|
this.processDec.setText(processDecValue);
|
}
|
|
public Map<String, List<String>> getTaskAndUserMap() {
|
return taskAndUserMap;
|
}
|
|
public void setTaskAndUserMap(Map<String, List<String>> taskAndUserMap) {
|
this.taskAndUserMap = taskAndUserMap;
|
}
|
|
private List<String> resultList = new ArrayList<String>();
|
private String[] headers ;
|
private Class[] columnTypes ;
|
private VCIBaseTableModel tableModel = null;
|
public boolean isSaveFlag() {
|
return saveFlag;
|
}
|
|
public void setSaveFlag(boolean saveFlag) {
|
this.saveFlag = saveFlag;
|
}
|
|
public LaunchDialog(String processType,String[] headers,Map<String, Map<String,String>> resMap) {
|
super(LogonApplication.frame,true);
|
setTitle("发起流程");
|
this.processType = processType;
|
this.resMap = resMap;
|
this.headers = headers;
|
init();
|
actionListener();
|
initProcessTemplate();
|
initObjectData();
|
hiddenTableColumn();
|
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
this.setLocationRelativeTo(null);
|
// this.setVisible(true);
|
}
|
|
protected void init() {
|
setBounds(100, 100, 812, 553);
|
getContentPane().setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
contentPanel.setLayout(new BorderLayout(0, 0));
|
{
|
JSplitPane splitPane = new JSplitPane();
|
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
contentPanel.add(splitPane, BorderLayout.CENTER);
|
{
|
JPanel panel = new JPanel();
|
panel.setBorder(new TitledBorder(null, "流程信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
splitPane.setLeftComponent(panel);
|
GridBagLayout gbl_panel = new GridBagLayout();
|
gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0};
|
gbl_panel.columnWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
|
gbl_panel.rowWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
|
panel.setLayout(gbl_panel);
|
{
|
JLabel label = new JLabel("流程名称");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 0;
|
panel.add(label, gbc_label);
|
}
|
{
|
processName = new JTextField();
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
gbc_textField.insets = new Insets(0, 0, 5, 0);
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField.gridx = 2;
|
gbc_textField.gridy = 0;
|
panel.add(processName, gbc_textField);
|
processName.setColumns(10);
|
}
|
{
|
JLabel label = new JLabel("描述信息");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 1;
|
panel.add(label, gbc_label);
|
}
|
{
|
JScrollPane scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridheight = 2;
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 1;
|
panel.add(scrollPane, gbc_scrollPane);
|
{
|
processDec = new JTextArea();
|
scrollPane.setViewportView(processDec);
|
}
|
}
|
{
|
JLabel label = new JLabel("流程模板");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.anchor = GridBagConstraints.EAST;
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 3;
|
panel.add(label, gbc_label);
|
}
|
{
|
processTemplate = new JComboBox();
|
GridBagConstraints gbc_processTemplate = new GridBagConstraints();
|
gbc_processTemplate.fill = GridBagConstraints.HORIZONTAL;
|
gbc_processTemplate.gridx = 2;
|
gbc_processTemplate.gridy = 3;
|
panel.add(processTemplate, gbc_processTemplate);
|
}
|
}
|
{
|
JPanel panel = new JPanel();
|
panel.setBorder(new TitledBorder(null, "流程", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
splitPane.setRightComponent(panel);
|
panel.setLayout(new BorderLayout(0, 0));
|
{
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
JPanel panel_1 = new JPanel();
|
tabbedPane.addTab("流程审批数据", panel_1);
|
panel_1.setLayout(new BorderLayout(0, 0));
|
{
|
JScrollPane scrollPane = new JScrollPane();
|
panel_1.add(scrollPane, BorderLayout.CENTER);
|
{
|
dataTable = new JTable();
|
columnTypes = new Class[headers.length];
|
for(int i=0;i<headers.length;i++){
|
columnTypes[i] = String.class;
|
}
|
tableModel = new VCIBaseTableModel(headers,columnTypes);
|
dataTable.setModel(tableModel);
|
scrollPane.setViewportView(dataTable);
|
}
|
}
|
panel_2 = new JPanel();
|
tabbedPane.addTab("选择任务处理人", panel_2);
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
gbl_panel_2.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
|
gbl_panel_2.rowHeights = new int[]{0, 0, 0};
|
gbl_panel_2.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
gbl_panel_2.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
panel_2.setLayout(gbl_panel_2);
|
{
|
JLabel label = new JLabel("任务列表");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 1;
|
panel_2.add(label, gbc_label);
|
}
|
{
|
JScrollPane scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 2;
|
gbc_scrollPane.gridy = 1;
|
panel_2.add(scrollPane, gbc_scrollPane);
|
{
|
taskList = new JList();
|
taskListModel = new DefaultListModel();
|
taskList.setModel(taskListModel);
|
scrollPane.setViewportView(taskList);
|
}
|
}
|
{
|
JLabel label = new JLabel("人员列表");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 3;
|
gbc_label.gridy = 1;
|
panel_2.add(label, gbc_label);
|
}
|
{
|
treeScrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 4;
|
gbc_scrollPane.gridy = 1;
|
panel_2.add(treeScrollPane, gbc_scrollPane);
|
{
|
// VCIBaseTreeNode rootNode = new VCIBaseTreeNode("人员组织", "root");
|
treeModel = new VCIBaseTreeModel(rootNode);
|
initUserTree(rootNode, "root");
|
initRoleTree(rootNode, "root");
|
initDepartTree(rootNode, "root");
|
rightManagementTree = new VCIBaseTree(treeModel, new RightManagementTreeCellRenderer());
|
treeScrollPane.setViewportView(rightManagementTree);
|
}
|
}
|
{
|
JPanel panel_3 = new JPanel();
|
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
gbc_panel_3.insets = new Insets(0, 0, 0, 5);
|
gbc_panel_3.fill = GridBagConstraints.BOTH;
|
gbc_panel_3.gridx = 5;
|
gbc_panel_3.gridy = 1;
|
panel_2.add(panel_3, gbc_panel_3);
|
GridBagLayout gbl_panel_3 = new GridBagLayout();
|
gbl_panel_3.columnWidths = new int[]{45, 0};
|
gbl_panel_3.rowHeights = new int[]{23, 0, 0, 0, 0, 0};
|
gbl_panel_3.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
gbl_panel_3.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
panel_3.setLayout(gbl_panel_3);
|
{
|
JButton btnNewButton = new JButton(">>");
|
btnNewButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
int selectedIndex = taskList.getSelectedIndex();
|
if(selectedIndex==-1){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择任务!");
|
return;
|
}
|
VCIBaseTreeNode clickedNode = (VCIBaseTreeNode) rightManagementTree.getLastSelectedPathComponent();
|
Object object = clickedNode.getObj();
|
if (object instanceof RoleObject) {
|
RoleObject role = (RoleObject) object;
|
UserObject[] fetchUserInfoByRoleId;
|
try {
|
fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType());
|
if(fetchUserInfoByRoleId==null||fetchUserInfoByRoleId.length==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "该角色下没有用户");
|
return;
|
}
|
} catch (VCIException e1) {
|
e1.printStackTrace();
|
}
|
}
|
if (object instanceof DeptObject) {
|
RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
|
DeptObject dept = (DeptObject) object;
|
UserObject[] objs;
|
try {
|
objs = del.getUserByDeptId(dept.getId());
|
if(objs==null||objs.length==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "该部门下没有用户");
|
return;
|
}
|
} catch (VCIException e1) {
|
e1.printStackTrace();
|
}
|
}
|
addToUserListFromTreeNode(true);
|
taskAndUserMap.put((String) taskList.getSelectedValue(), resultList);
|
taskAndUserMap_1.put((String) taskList.getSelectedValue(), tmpListModel);
|
userList.setModel(resultListModel);
|
userList.updateUI();
|
}
|
});
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
gbc_btnNewButton.anchor = GridBagConstraints.NORTHWEST;
|
gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);
|
gbc_btnNewButton.gridx = 0;
|
gbc_btnNewButton.gridy = 2;
|
panel_3.add(btnNewButton, gbc_btnNewButton);
|
}
|
{
|
JButton btnNewButton_1 = new JButton("<<");
|
btnNewButton_1.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
removeUserFromUserList(true);
|
}
|
});
|
GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
|
gbc_btnNewButton_1.anchor = GridBagConstraints.NORTHWEST;
|
gbc_btnNewButton_1.gridx = 0;
|
gbc_btnNewButton_1.gridy = 4;
|
panel_3.add(btnNewButton_1, gbc_btnNewButton_1);
|
}
|
}
|
{
|
JScrollPane scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 6;
|
gbc_scrollPane.gridy = 1;
|
panel_2.add(scrollPane, gbc_scrollPane);
|
{
|
resultListModel = new DefaultListModel();
|
userList = new JList(resultListModel);
|
scrollPane.setViewportView(userList);
|
}
|
}
|
JPanel panel_3 = new JPanel();
|
tabbedPane.addTab("流程模板信息", panel_3);
|
panel_3.setLayout(new BorderLayout(0, 0));
|
{
|
panel_3.add(jspFlowImage);
|
}
|
panel.add(tabbedPane, BorderLayout.CENTER);
|
}
|
}
|
}
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
{
|
JButton okButton = new JButton("启动流程");
|
okButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
processNameValue = processName.getText().trim();
|
processDecValue = processDec.getText();
|
processTemplateName = ((ProcessDefinitionObject)processTemplate.getSelectedItem()).getId();
|
if(processNameValue==null||"".equals(processNameValue)){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请填写流程名称!");
|
return;
|
}
|
if(taskAndUserMap==null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择候选人!");
|
return;
|
}
|
if(taskAndUserMap.size()==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择候选人!");
|
return;
|
}
|
int size = taskListModel.getSize();
|
for(int i=0;i<size;i++){
|
String object = (String) taskListModel.get(i);
|
if(taskAndUserMap.get(object)==null||taskAndUserMap.get(object).size()==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择候选人!");
|
return;
|
}
|
}
|
saveFlag = true;
|
dispose();
|
}
|
});
|
buttonPane.add(okButton);
|
}
|
{
|
JButton cancelButton = new JButton("关闭");
|
cancelButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
saveFlag = false;
|
dispose();
|
}
|
});
|
buttonPane.add(cancelButton);
|
}
|
}
|
}
|
|
protected void initProcessTemplate(){
|
ProcessCategoryObject[] processCategories = null;
|
ProcessCustomClientDelegate delSrv = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
processCategories = delSrv.getProcessCategories("root");
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
String processCategoryId = "";
|
if(processCategories!=null){
|
for(int i=0;i<processCategories.length;i++){
|
System.out.println(processCategories[i]);
|
if(processType.equals(processCategories[i].getName())){
|
processCategoryId = processCategories[i].getId();
|
}
|
}
|
|
}
|
|
try {
|
ProcessDefinitionObject[] processDefinitions = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitions(processCategoryId);
|
for(int i = 0 ; i < processDefinitions.length ; i ++){
|
if("1".equals(processDefinitions[i].getStatus())){
|
processTemplate.addItem(processDefinitions[i]);
|
}
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
}
|
protected void loadFlowImage(ProcessDefinitionObject processDefinitionObject){
|
loadFlowCharPanel(processDefinitionObject);
|
}
|
private VCIJLabel lblFlowImage = new VCIJLabel();
|
private VCIJScrollPane jspFlowImage = new VCIJScrollPane(lblFlowImage);
|
private VCIBaseTreeNode userNode;
|
private VCIBaseTreeNode roleNode;
|
private VCIBaseTreeNode departmentNode;
|
private void loadFlowCharPanel(ProcessDefinitionObject procDecObj){
|
ProcessCustomClientDelegate del = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
String deploymentId = procDecObj.getJbpmDeploymentId();
|
try {
|
byte[] chartData = del.getProcessChart(deploymentId);
|
InputStream is = new ByteArrayInputStream(chartData, 0, chartData.length);
|
BufferedImage bu = ImageIO.read(is);
|
ImageIcon icon = new ImageIcon(bu);
|
lblFlowImage.setIcon(icon);
|
Color color = new Color(255, 251, 255);
|
jspFlowImage.getViewport().setBackground(color);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
protected void actionListener(){
|
taskList.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent arg0) {
|
super.mouseClicked(arg0);
|
try {
|
ProcessDefinitionObject procDecObj = (ProcessDefinitionObject)processTemplate.getSelectedItem();
|
String[] allCandidatesForTask = new String[0];
|
String selectTask = (String)taskList.getSelectedValue();
|
//子流程节点格式----任务(子流程名称:deployId)
|
//解析子流程节点
|
if (selectTask.indexOf("(") > 0 && selectTask.indexOf(":") > 0) {
|
String taskName = selectTask.substring(0, selectTask.indexOf("("));
|
String deployId = selectTask.substring(selectTask.lastIndexOf(":") + 1, selectTask.lastIndexOf(")"));
|
allCandidatesForTask = new ProcessCustomClientDelegate().getAllCandidatesForTask(deployId, taskName, "");
|
} else {
|
allCandidatesForTask = new ProcessCustomClientDelegate().getAllCandidatesForTask(procDecObj.getJbpmDeploymentId(), selectTask, "");
|
}
|
|
String templateFlag = FlowCustomProperties.getStrPro("workflow.template");
|
|
if (templateFlag.equals("1")) {
|
if(allCandidatesForTask.length==1){
|
if("#{process_applicant}".equals(allCandidatesForTask[0])){
|
userValue = null;
|
}else{
|
userValue = allCandidatesForTask[0];
|
}
|
roleValue = null;
|
departmentValue = null;
|
}
|
if(allCandidatesForTask.length==2){
|
userValue = allCandidatesForTask[0];
|
roleValue = allCandidatesForTask[1];
|
departmentValue = null;
|
}
|
if(allCandidatesForTask.length==3){
|
userValue = allCandidatesForTask[0];
|
roleValue = allCandidatesForTask[1];
|
departmentValue = allCandidatesForTask[2];
|
}
|
} else if (templateFlag.equals("2")){
|
constructWorkFlowUserInfo(allCandidatesForTask);
|
}
|
|
resultList = taskAndUserMap.get(taskList.getSelectedValue());
|
if(resultList == null){
|
resultList = new ArrayList<String>();
|
}
|
resultListModel.clear();
|
DefaultListModel defaultListModel = taskAndUserMap_1.get(taskList.getSelectedValue());
|
for(int i=0;i<resultList.size();i++){
|
String resultValue = resultList.get(i);
|
int indexOf = resultValue.indexOf(":");
|
String resultFilter = resultValue.substring(indexOf+1);
|
for(int j=0;j<defaultListModel.size();j++){
|
Object object = defaultListModel.get(j);
|
if(j==0){
|
if(object instanceof UserObject){
|
UserObject o = (UserObject)object;
|
if(resultFilter.equals(o.getUserName())){
|
resultListModel.addElement(o);
|
}
|
}
|
if(object instanceof RoleObject){
|
RoleObject o = (RoleObject)object;
|
if(resultFilter.equals(o.getName())){
|
resultListModel.addElement(o);
|
}
|
}
|
if(object instanceof DeptObject){
|
DeptObject o = (DeptObject)object;
|
if(resultFilter.equals(o.getName())){
|
resultListModel.addElement(o);
|
}
|
}
|
}else{
|
if(object instanceof UserObject){
|
UserObject o = (UserObject)object;
|
if(resultFilter.equals(o.getUserName())){
|
if(checkUserIdAdded(o)) continue;
|
resultListModel.addElement(o);
|
}
|
}
|
if(object instanceof RoleObject){
|
RoleObject o = (RoleObject)object;
|
if(resultFilter.equals(o.getName())){
|
if(checkRoleIdAdded(o)) continue;
|
resultListModel.addElement(o);
|
}
|
}
|
if(object instanceof DeptObject){
|
DeptObject o = (DeptObject)object;
|
if(resultFilter.equals(o.getName())){
|
if(checkDeptIdAdded(o)) continue;
|
resultListModel.addElement(o);
|
}
|
}
|
}
|
}
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
userList.setModel(resultListModel);
|
userList.updateUI();
|
VCIBaseTreeNode root = (VCIBaseTreeNode) treeModel.getRoot();
|
int childCount = root.getChildCount();
|
for(int i=0;i<childCount;i++){
|
VCIBaseTreeNode childAt = (VCIBaseTreeNode) root.getChildAt(i);
|
childAt.removeAllChildren();
|
}
|
treeModel.reload();
|
rightManagementTree.updateUI();
|
}
|
});
|
processTemplate.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent arg0) {
|
changeProcessDefinitionObject(((ProcessDefinitionObject)processTemplate.getSelectedItem()));
|
}
|
});
|
rightManagementTree.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent e) {
|
if(e.getClickCount() != 2) return;
|
TreePath path = rightManagementTree.getPathForLocation(e.getX(), e.getY());
|
VCIBaseTreeNode clickedNode = (VCIBaseTreeNode) rightManagementTree.getLastSelectedPathComponent();
|
if(path == null) return;
|
if(clickedNode.getLevel()<2) return;
|
Object object = clickedNode.getObj();
|
if (object instanceof RoleObject) {
|
RoleObject role = (RoleObject) object;
|
UserObject[] fetchUserInfoByRoleId;
|
try {
|
fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType());
|
if(fetchUserInfoByRoleId==null||fetchUserInfoByRoleId.length==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "该角色下没有用户");
|
return;
|
}
|
} catch (VCIException e1) {
|
e1.printStackTrace();
|
}
|
}
|
if (object instanceof DeptObject) {
|
RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
|
DeptObject dept = (DeptObject) object;
|
UserObject[] objs;
|
try {
|
objs = del.getUserByDeptId(dept.getId());
|
if(objs==null||objs.length==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "该部门下没有用户");
|
return;
|
}
|
} catch (VCIException e1) {
|
e1.printStackTrace();
|
}
|
}
|
transmitTreeObject.setCurrentTreeNode(clickedNode);
|
addToUserListFromTreeNode(false);
|
taskAndUserMap.put((String) taskList.getSelectedValue(), resultList);
|
taskAndUserMap_1.put((String) taskList.getSelectedValue(), tmpListModel);
|
}
|
});
|
rightManagementTree.addTreeSelectionListener(new TreeSelectionListener() {
|
public void valueChanged(TreeSelectionEvent e) {
|
TreePath treePath = e.getPath();
|
VCIBaseTreeNode selectNode = (VCIBaseTreeNode) treePath.getLastPathComponent();
|
transmitTreeObject.setCurrentTreeNode(selectNode);
|
}
|
});
|
|
/**
|
* 树的展开事件
|
*/
|
rightManagementTree.addTreeExpansionListener(new TreeExpansionListener() {
|
public void treeExpanded(TreeExpansionEvent event) {
|
TreePath treePath = event.getPath();
|
selectNode = (VCIBaseTreeNode) treePath.getLastPathComponent();
|
transmitTreeObject.setCurrentTreeNode(selectNode);
|
Object object = selectNode.getObj();
|
// if (!selectNode.isExpand()) {
|
if (selectNode.getChildCount()==0) {
|
selectNode.setExpand(true);
|
transmitTreeObject.getCurrentTreeNode().removeAllChildren();
|
|
if (object instanceof UserObject) {
|
UserObject user = (UserObject) object;
|
if (user.getId().equals("root")) {
|
try {
|
UserObject[] userInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfo();
|
for (UserObject userObject : userInfos) {
|
if(userValue!=null&&!"".equals(userValue)){
|
String[] split = userValue.split(",");
|
for(String userSplit : split){
|
if(userSplit.equals(userObject.getUserName())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount());
|
}
|
}
|
}
|
// else{
|
// treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount());
|
// }
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}
|
}
|
if (object instanceof RoleObject) {
|
RoleObject role = (RoleObject) object;
|
if (role.getId().equals("root")) {
|
try {
|
RoleObject[] roleInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchRoleInfo();
|
|
for (RoleObject roleObject : roleInfos) {
|
if(roleValue!=null&&!"".equals(roleValue)){
|
String[] split = roleValue.split(",");
|
for(String roleSplit : split){
|
if(roleSplit.equals(roleObject.getId())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(roleObject.getName(), roleObject), selectNode, selectNode.getChildCount());
|
}
|
}
|
}
|
// else{
|
// treeModel.insertNodeInto(new VCIBaseTreeNode(roleObject.getName(), roleObject), selectNode, selectNode.getChildCount());
|
// }
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}else{
|
try {
|
UserObject[] fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType());
|
for (UserObject userObject : fetchUserInfoByRoleId) {
|
treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount());
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|
if (object instanceof DeptObject){
|
RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
DeptObject[] DeptInfos = null;
|
DeptObject deptObject = (DeptObject) object;
|
if (deptObject.getId().equals("root")){
|
DeptInfos= new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDepartmentInfo();
|
|
}else{
|
DeptInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDepartmentInfoByParentId(deptObject.getId());
|
}
|
if (DeptInfos == null){
|
if (!deptObject.getId().equals("root")){
|
UserObject[] objs = del.getUserByDeptId(deptObject.getId());
|
for(int i=0;i<objs.length;i++) {
|
treeModel.insertNodeInto(new VCIBaseTreeNode(objs[i].toString(), objs[i]),selectNode,selectNode.getChildCount());
|
}
|
}else{
|
return;
|
}
|
}
|
if(DeptInfos!=null){
|
int len = DeptInfos.length;
|
for (int i = 0; i < len; i++) {
|
if(departmentValue!=null&&!"".equals(departmentValue)){
|
String[] split = departmentValue.split(",");
|
for(String deptmentSplit : split){
|
if(deptmentSplit.equals(DeptInfos[i].getId())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(DeptInfos[i].getName(), DeptInfos[i]),selectNode,selectNode.getChildCount());
|
}
|
}
|
}
|
// else{
|
// treeModel.insertNodeInto(new VCIBaseTreeNode(DeptInfos[i].getName(), DeptInfos[i]),selectNode,selectNode.getChildCount());
|
// }
|
}
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}
|
}
|
}
|
|
public void treeCollapsed(TreeExpansionEvent arg0) {
|
|
}
|
});
|
transmitTreeObject.setTreeModel(treeModel);
|
transmitTreeObject.setTree(rightManagementTree);
|
|
}
|
|
/**
|
* 判断设置用户的格式是否为新格式
|
* @param allCandidatesForTask
|
* @return
|
*/
|
private boolean isNewUserFormat(String[] allCandidatesForTask) {
|
boolean isNew = false;
|
for (int i = 0; i < allCandidatesForTask.length; i++) {
|
if (allCandidatesForTask[i].indexOf(":") > 0) {
|
return true;
|
}
|
}
|
|
return false;
|
}
|
|
protected void initUserTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
UserObject userObject = new UserObject();
|
userObject.setId("root");
|
userNode = new VCIBaseTreeNode("用户", userObject);
|
rootNode.add(userNode);
|
}
|
protected void initRoleTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
RoleObject roleObject = new RoleObject();
|
roleObject.setId("root");
|
roleNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.stafforg.menu.role", "RMIPFramework", getLocale()), roleObject);
|
rootNode.add(roleNode);
|
|
}
|
protected void initDepartTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
DeptObject rootDepartment = new DeptObject();
|
rootDepartment.setId("root");
|
departmentNode = new VCIBaseTreeNode(
|
LocaleDisplay.getI18nString("rmip.stafforg.menu.department",
|
"RMIPFramework", getLocale()), rootDepartment);
|
rootNode.add(departmentNode);
|
}
|
protected void addToUserListFromTreeNode(boolean batch){
|
LinkedList<VCIBaseTreeNode> nodeList = new LinkedList<VCIBaseTreeNode>();
|
TreePath[] paths = rightManagementTree.getSelectionPaths();
|
if(batch && paths != null){
|
for(TreePath path : paths){
|
nodeList.add((VCIBaseTreeNode)path.getLastPathComponent());
|
}
|
} else{
|
nodeList.add(transmitTreeObject.getCurrentTreeNode());
|
}
|
for(VCIBaseTreeNode selectNode : nodeList){
|
if(selectNode == null) continue;
|
Object object = selectNode.getObj();
|
if (object instanceof UserObject) {
|
UserObject user = (UserObject) object;
|
if("root".equals(user.getId())){
|
continue;
|
}
|
if(checkUserIdAdded(user)) return;
|
resultListModel.addElement(object);
|
tmpListModel.addElement(object);
|
resultList.add("user:"+user.getUserName());
|
}
|
if (object instanceof RoleObject) {
|
RoleObject role = (RoleObject) object;
|
if("root".equals(role.getId())){
|
continue;
|
}
|
if(checkRoleIdAdded(role)) return;
|
resultListModel.addElement(object);
|
tmpListModel.addElement(object);
|
resultList.add("role:"+role.getName());
|
}
|
if (object instanceof DeptObject) {
|
DeptObject dept = (DeptObject) object;
|
if("root".equals(dept.getId())){
|
continue;
|
}
|
if(checkDeptIdAdded(dept)) return;
|
resultListModel.addElement(object);
|
tmpListModel.addElement(object);
|
resultList.add("department:"+dept.getName());
|
}
|
}
|
}
|
protected void removeUserFromUserList(boolean batch){
|
Object[] selectedIndices = userList.getSelectedValues();
|
String selectedTaskValue = (String) taskList.getSelectedValue();
|
if(!batch){
|
selectedIndices = new Object[]{userList.getSelectedValue()};
|
}
|
for(int i =0;i<selectedIndices.length;i++){
|
resultListModel.removeElement(selectedIndices[i]);
|
tmpListModel.removeElement(selectedIndices[i]);
|
if(selectedIndices[i] instanceof UserObject){
|
UserObject u = (UserObject) selectedIndices[i];
|
resultList.remove("user:"+u.getUserName());
|
}
|
if(selectedIndices[i] instanceof RoleObject){
|
RoleObject u = (RoleObject) selectedIndices[i];
|
resultList.remove("role:"+u.getName());
|
}
|
if(selectedIndices[i] instanceof DeptObject){
|
DeptObject u = (DeptObject) selectedIndices[i];
|
resultList.remove("department:"+u.getName());
|
}
|
}
|
|
taskAndUserMap.put(selectedTaskValue, resultList);
|
taskAndUserMap_1.put(selectedTaskValue, tmpListModel);
|
|
}
|
protected boolean checkUserIdAdded(UserObject obj){
|
boolean res = false;
|
int size = resultListModel.getSize();
|
for(int i = 0; i < size; i++){
|
if(resultListModel.get(i) instanceof UserObject){
|
res = obj.getId().equals(((UserObject)resultListModel.get(i)).getId());
|
if(res) break;
|
}else{
|
res = obj.getUserName().equals(resultListModel.get(i));
|
if(res) break;
|
}
|
}
|
return res;
|
}
|
protected boolean checkRoleIdAdded(RoleObject obj){
|
boolean res = false;
|
int size = resultListModel.getSize();
|
for(int i = 0; i < size; i++){
|
if(resultListModel.get(i) instanceof RoleObject){
|
res = obj.getId().equals(((RoleObject)resultListModel.get(i)).getId());
|
if(res) break;
|
}else{
|
res = obj.getName().equals(resultListModel.get(i));
|
if(res) break;
|
}
|
}
|
return res;
|
}
|
protected boolean checkDeptIdAdded(DeptObject obj){
|
boolean res = false;
|
int size = resultListModel.getSize();
|
for(int i = 0; i < size; i++){
|
if(resultListModel.get(i) instanceof DeptObject){
|
res = obj.getId().equals(((DeptObject)resultListModel.get(i)).getId());
|
if(res) break;
|
}else{
|
res = obj.getName().equals(resultListModel.get(i));
|
if(res) break;
|
}
|
}
|
return res;
|
}
|
protected void initTaskList(ProcessDefinitionObject processDefinitionObject){
|
ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate();
|
try {
|
taskListModel.clear();
|
String jbpmDeploymentId = delegate.getDeploymentID(processDefinitionObject.getId());
|
String[] allTaskNames = delegate.getAllTaskNames(jbpmDeploymentId);
|
for(int i=0;i<allTaskNames.length;i++){
|
taskListModel.addElement(allTaskNames[i]);
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 更换选择的洛模板
|
* @param processDefinitionObject 流程模板定义对象
|
* @return
|
*/
|
public void changeProcessDefinitionObject(ProcessDefinitionObject processDefinitionObject){
|
processTemplate.setSelectedItem(processDefinitionObject);
|
taskAndUserMap.clear();
|
taskAndUserMap_1.clear();
|
initTaskList(processDefinitionObject);
|
loadFlowImage(processDefinitionObject);
|
}
|
protected void initObjectData(){
|
tableModel.list.clear();
|
VCIBaseTableNode vciBaseTableNode = null;
|
int c = 0;
|
for(Entry<String, Map<String, String>> entrySet : resMap.entrySet()){
|
String key = entrySet.getKey();
|
// for(int i =0;i<objId.length;i++){
|
// vciBaseTableNode = new VCIBaseTableNode(objId[i]);
|
// vciBaseTableNode.setPropertyValueByName(dataTable.getColumnName(0), objCode[i]==null?"":objCode[i]);
|
// vciBaseTableNode.setPropertyValueByName(dataTable.getColumnName(1), objNum[i]==null?"":objNum[i]);
|
// vciBaseTableNode.setPropertyValueByName(dataTable.getColumnName(2), objName[i]==null?"":objName[i]);
|
// tableModel.addRow(i, vciBaseTableNode);
|
vciBaseTableNode = new VCIBaseTableNode(key);
|
Map<String, String> value = entrySet.getValue();
|
|
for(Entry<String, String> data : value.entrySet()){
|
for(int k=0;k<headers.length;k++){
|
if(headers[k].equals(data.getKey())){
|
vciBaseTableNode.setPropertyValueByName(dataTable.getColumnName(k), data.getValue()==null?"":data.getValue());
|
}
|
}
|
}
|
tableModel.addRow(c, vciBaseTableNode);
|
c++;
|
// }
|
}
|
dataTable.setModel(tableModel);
|
dataTable.updateUI();
|
}
|
|
protected void hiddenTableColumn(){
|
TableColumnModel columnModel = dataTable.getColumnModel();
|
TableColumn column = columnModel.getColumn(0);
|
column.setWidth(0);
|
dataTable.updateUI();
|
}
|
|
private void constructWorkFlowUserInfo(String[] userInfos) {
|
List<String> userList = new ArrayList<String>();
|
List<String> roleList = new ArrayList<String>();
|
List<String> deptList = new ArrayList<String>();
|
for (int i = 0; i < userInfos.length; i++) {
|
String[] cVal = userInfos[i].split(",");
|
for (int j = 0; j < cVal.length; j++) {
|
String[] valType = cVal[j].split(":");
|
if (valType.length != 2) {
|
continue;
|
}
|
if (valType[0].equalsIgnoreCase("user")) {
|
userList.add(valType[1]);
|
} else if (valType[0].equalsIgnoreCase("role")) {
|
roleList.add(valType[1]);
|
} else if (valType[0].equalsIgnoreCase("org")) {
|
deptList.add(valType[1]);
|
}
|
}
|
}
|
userList = getUserByPersonID(userList);
|
if (userList.size() > 0) {
|
this.userValue = convertListToString(userList);
|
}
|
if (roleList.size() > 0) {
|
this.roleValue = convertListToString(roleList);
|
}
|
if (deptList.size() > 0 ){
|
this.departmentValue = convertListToString(deptList);
|
}
|
}
|
|
private String convertListToString(List<String> list) {
|
String str = Arrays.toString(list.toArray(new String[0]));
|
return str.substring(1, str.length() - 1);
|
}
|
|
private List<String> getUserByPersonID(List<String> personIdList) {
|
List<String> userList = new ArrayList<String>();
|
QueryTemplate qt2 = new QueryTemplate();
|
qt2.setId("btmQuery");
|
qt2.setBtmType("person");
|
qt2.setType("btm");
|
List<String> clauseList = new ArrayList<String>();
|
clauseList.add("*");
|
qt2.setClauseList(clauseList);
|
qt2.setQueryChildrenFlag(false);
|
qt2.setRightFlag(false);
|
qt2.setVersion(1);
|
|
Map<String, String> map = new HashMap<String, String>();
|
Condition condition_ = OQTool.getCondition(map);
|
|
for(String key : personIdList){
|
map.put("oid", key);
|
Condition condition = OQTool.getCondition(map);
|
condition_ = OQTool.mergeCondition(condition, condition_, Connector.OR);
|
map.clear();
|
}
|
qt2.setCondition(condition_);
|
try {
|
BusinessObject[] bos = QTClient.getService().findBTMObjects(qt2.getId(), OQTool.qtTOXMl(qt2).asXML());
|
for (int i = 0; i < bos.length; i++) {
|
userList.add(bos[i].id);
|
}
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
return userList;
|
}
|
}
|