IDEMPIERE-2405 Implement SaaS support for Setup Wizard
This commit is contained in:
parent
2e8fce6fde
commit
03fb5cbda7
|
@ -0,0 +1,11 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Jan 16, 2015 5:50:47 PM COT
|
||||||
|
-- IDEMPIERE-2405 Implement SaaS support for Setup Wizard
|
||||||
|
UPDATE AD_Val_Rule SET Code='AD_Workflow.WorkflowType IN (''G'',''W'')',Updated=TO_DATE('2015-01-16 17:50:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=52006
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201501161751_IDEMPIERE-2405.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
-- Jan 16, 2015 5:50:47 PM COT
|
||||||
|
-- IDEMPIERE-2405 Implement SaaS support for Setup Wizard
|
||||||
|
UPDATE AD_Val_Rule SET Code='AD_Workflow.WorkflowType IN (''G'',''W'')',Updated=TO_TIMESTAMP('2015-01-16 17:50:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=52006
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201501161751_IDEMPIERE-2405.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.adempiere.webui.util.TreeUtils;
|
||||||
import org.compiere.apps.form.SetupWizard;
|
import org.compiere.apps.form.SetupWizard;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.X_AD_CtxHelp;
|
import org.compiere.model.X_AD_CtxHelp;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -68,6 +69,7 @@ import org.zkoss.zul.Treechildren;
|
||||||
import org.zkoss.zul.Treeitem;
|
import org.zkoss.zul.Treeitem;
|
||||||
import org.zkoss.zul.Treerow;
|
import org.zkoss.zul.Treerow;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Vbox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View for Setup Wizard
|
* View for Setup Wizard
|
||||||
*
|
*
|
||||||
|
@ -88,6 +90,8 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
private Treeitem firstOpenNode = null;
|
private Treeitem firstOpenNode = null;
|
||||||
private Treeitem firstOpenWF = null;
|
private Treeitem firstOpenWF = null;
|
||||||
private Treeitem firstWF = null;
|
private Treeitem firstWF = null;
|
||||||
|
private int cntNodes = 0;
|
||||||
|
private int cntSolved = 0;
|
||||||
|
|
||||||
private Label pretitleLabel = new Label(Msg.getMsg(Env.getCtx(), "SetupTask"));
|
private Label pretitleLabel = new Label(Msg.getMsg(Env.getCtx(), "SetupTask"));
|
||||||
private Label titleLabel = new Label();
|
private Label titleLabel = new Label();
|
||||||
|
@ -181,6 +185,8 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
* Load Wizard Nodes
|
* Load Wizard Nodes
|
||||||
*/
|
*/
|
||||||
private void loadWizardNodes() {
|
private void loadWizardNodes() {
|
||||||
|
cntNodes = 0;
|
||||||
|
cntSolved = 0;
|
||||||
nextItems.removeAll(nextItems);
|
nextItems.removeAll(nextItems);
|
||||||
Treechildren treeChildren = wfnodeTree.getTreechildren();
|
Treechildren treeChildren = wfnodeTree.getTreechildren();
|
||||||
List<MWorkflow> wfwizards = getWfWizards();
|
List<MWorkflow> wfwizards = getWfWizards();
|
||||||
|
@ -200,9 +206,19 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
protected void addWfEntry(MWorkflow wfwizard) {
|
protected void addWfEntry(MWorkflow wfwizard) {
|
||||||
allFinished = true;
|
allFinished = true;
|
||||||
allPending = true;
|
allPending = true;
|
||||||
Treechildren treeChildren = wfnodeTree.getTreechildren();
|
|
||||||
Treeitem treeitemwf = new Treeitem();
|
Treeitem treeitemwf = new Treeitem();
|
||||||
|
Treechildren treeChildren = wfnodeTree.getTreechildren();
|
||||||
treeChildren.appendChild(treeitemwf);
|
treeChildren.appendChild(treeitemwf);
|
||||||
|
addNodes(wfwizard, treeitemwf);
|
||||||
|
if ( treeitemwf.getTreechildren() == null
|
||||||
|
|| treeitemwf.getTreechildren().getChildren() == null
|
||||||
|
|| treeitemwf.getTreechildren().getChildren().size() == 0) {
|
||||||
|
// no nodes
|
||||||
|
treeChildren.removeChild(treeitemwf);
|
||||||
|
treeitemwf = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (firstWF == null)
|
if (firstWF == null)
|
||||||
firstWF = treeitemwf;
|
firstWF = treeitemwf;
|
||||||
|
|
||||||
|
@ -211,7 +227,6 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
Div div = new Div();
|
Div div = new Div();
|
||||||
div.setStyle("display:inline;");
|
div.setStyle("display:inline;");
|
||||||
div.appendChild(wizardLabel);
|
div.appendChild(wizardLabel);
|
||||||
|
|
||||||
Treerow treerow = new Treerow();
|
Treerow treerow = new Treerow();
|
||||||
treerow.setStyle("vertical-align:top;");
|
treerow.setStyle("vertical-align:top;");
|
||||||
treeitemwf.appendChild(treerow);
|
treeitemwf.appendChild(treerow);
|
||||||
|
@ -222,7 +237,6 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
nextItems.add(treeitemwf);
|
nextItems.add(treeitemwf);
|
||||||
if (openNodes.contains(wfwizard.getAD_Workflow_ID()))
|
if (openNodes.contains(wfwizard.getAD_Workflow_ID()))
|
||||||
treeitemwf.setOpen(true);
|
treeitemwf.setOpen(true);
|
||||||
addNodes(wfwizard, treeitemwf);
|
|
||||||
if (firstOpenWF == treeitemwf && allPending) {
|
if (firstOpenWF == treeitemwf && allPending) {
|
||||||
firstOpenNode = firstOpenWF;
|
firstOpenNode = firstOpenWF;
|
||||||
}
|
}
|
||||||
|
@ -251,6 +265,20 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWfNode(MWFNode node, Treeitem treeitemwf) {
|
private void addWfNode(MWFNode node, Treeitem treeitemwf) {
|
||||||
|
if (MWFNode.ACTION_UserWindow.equals(node.getAction()) && node.getAD_Window_ID() > 0) {
|
||||||
|
if (MRole.getDefault().getWindowAccess(node.getAD_Window_ID()) == null)
|
||||||
|
return;
|
||||||
|
} else if (MWFNode.ACTION_UserForm.equals(node.getAction()) && node.getAD_Form_ID() > 0) {
|
||||||
|
if (MRole.getDefault().getFormAccess(node.getAD_Form_ID()) == null)
|
||||||
|
return;
|
||||||
|
} else if ((MWFNode.ACTION_AppsProcess.equals(node.getAction()) || MWFNode.ACTION_AppsReport.equals(node.getAction())) && node.getAD_Process_ID() > 0) {
|
||||||
|
if (MRole.getDefault().getProcessAccess(node.getAD_Process_ID()) == null)
|
||||||
|
return;
|
||||||
|
} else if (MWFNode.ACTION_AppsTask.equals(node.getAction()) && node.getAD_Task_ID() > 0) {
|
||||||
|
if (MRole.getDefault().getTaskAccess(node.getAD_Task_ID()) == null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Color of node according to wizard status */
|
/* Color of node according to wizard status */
|
||||||
Label nodeLabel = new Label(node.getName(true));
|
Label nodeLabel = new Label(node.getName(true));
|
||||||
MWizardProcess wp = MWizardProcess.get(Env.getCtx(), node.getAD_WF_Node_ID(), Env.getAD_Client_ID(Env.getCtx()));
|
MWizardProcess wp = MWizardProcess.get(Env.getCtx(), node.getAD_WF_Node_ID(), Env.getAD_Client_ID(Env.getCtx()));
|
||||||
|
@ -270,9 +298,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
nodeLabel.setZclass("tree-setupwizard-nostatus");
|
nodeLabel.setZclass("tree-setupwizard-nostatus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cntNodes++;
|
||||||
if ( MWizardProcess.WIZARDSTATUS_Finished.equals(status)
|
if ( MWizardProcess.WIZARDSTATUS_Finished.equals(status)
|
||||||
|| MWizardProcess.WIZARDSTATUS_Skipped.equals(status)) {
|
|| MWizardProcess.WIZARDSTATUS_Skipped.equals(status)) {
|
||||||
allPending = false;
|
allPending = false;
|
||||||
|
cntSolved++;
|
||||||
} else {
|
} else {
|
||||||
allFinished = false;
|
allFinished = false;
|
||||||
}
|
}
|
||||||
|
@ -465,14 +495,12 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
} // jbInit
|
} // jbInit
|
||||||
|
|
||||||
private void refreshProgress() {
|
private void refreshProgress() {
|
||||||
int nodes = getNodesCnt();
|
int percent = cntSolved * 100;
|
||||||
int solved = getWizardCnt();
|
if (cntNodes > 0)
|
||||||
int percent = solved * 100;
|
percent = percent / cntNodes;
|
||||||
if (nodes > 0)
|
|
||||||
percent = percent / nodes;
|
|
||||||
else
|
else
|
||||||
percent = 0;
|
percent = 0;
|
||||||
Object[] args = new Object[] {solved, nodes, percent};
|
Object[] args = new Object[] {cntSolved, cntNodes, percent};
|
||||||
String msg = Msg.getMsg(Env.getCtx(), "SetupWizardProgress", args);
|
String msg = Msg.getMsg(Env.getCtx(), "SetupWizardProgress", args);
|
||||||
progressLabel.setText(msg);
|
progressLabel.setText(msg);
|
||||||
progressbar.setValue(percent);
|
progressbar.setValue(percent);
|
||||||
|
@ -496,7 +524,7 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
if (e.getTarget() == wfnodeTree) {
|
if (e.getTarget() == wfnodeTree) {
|
||||||
onTreeSelection(e);
|
onTreeSelection(e);
|
||||||
} else if (e.getTarget() == bRefresh) {
|
} else if (e.getTarget() == bRefresh) {
|
||||||
showInRightPanel(0, m_node.getAD_WF_Node_ID());
|
repaintTree();
|
||||||
} else if (e.getTarget() == bOK) {
|
} else if (e.getTarget() == bOK) {
|
||||||
int userid = 0;
|
int userid = 0;
|
||||||
allFinished=true;
|
allFinished=true;
|
||||||
|
@ -672,7 +700,6 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
|
||||||
private void setNotesPanelVisible(boolean visible) {
|
private void setNotesPanelVisible(boolean visible) {
|
||||||
notesLabel.setVisible(visible);
|
notesLabel.setVisible(visible);
|
||||||
notesField.setVisible(visible);
|
notesField.setVisible(visible);
|
||||||
bRefresh.setVisible(visible);
|
|
||||||
bOK.setVisible(visible);
|
bOK.setVisible(visible);
|
||||||
statusLabel.setVisible(visible);
|
statusLabel.setVisible(visible);
|
||||||
statusField.setVisible(visible);
|
statusField.setVisible(visible);
|
||||||
|
|
|
@ -18,9 +18,9 @@ package org.compiere.apps.form;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.adempiere.model.MWizardProcess;
|
import org.adempiere.model.MWizardProcess;
|
||||||
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.wf.MWFNode;
|
import org.compiere.wf.MWFNode;
|
||||||
import org.compiere.wf.MWorkflow;
|
import org.compiere.wf.MWorkflow;
|
||||||
|
@ -39,41 +39,41 @@ public class SetupWizard
|
||||||
|
|
||||||
public MWFNode m_node;
|
public MWFNode m_node;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of workflow wizard nodes
|
|
||||||
*/
|
|
||||||
public int getNodesCnt() {
|
|
||||||
/* TODO: SaaS filter */
|
|
||||||
final String sql = "SELECT COUNT(1) " +
|
|
||||||
"FROM AD_Workflow w " +
|
|
||||||
"JOIN AD_WF_Node n ON (n.AD_Workflow_ID=w.AD_Workflow_ID) " +
|
|
||||||
"WHERE w.WorkflowType='W' " + // Wizard
|
|
||||||
"AND w.IsActive='Y' " +
|
|
||||||
"AND n.IsActive='Y'";
|
|
||||||
return DB.getSQLValue(null, sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of wizard nodes that has been finished or skipped by user
|
|
||||||
*/
|
|
||||||
public int getWizardCnt() {
|
|
||||||
/* TODO: SaaS filter */
|
|
||||||
final String sql = "SELECT COUNT(DISTINCT z.AD_WF_Node_ID) " +
|
|
||||||
"FROM AD_Workflow w " +
|
|
||||||
"JOIN AD_WF_Node n ON (n.AD_Workflow_ID=w.AD_Workflow_ID) " +
|
|
||||||
"JOIN AD_WizardProcess z ON (n.AD_WF_Node_ID=z.AD_WF_Node_ID) " +
|
|
||||||
"WHERE w.WorkflowType='W' " + // Wizard
|
|
||||||
"AND w.IsActive='Y' " +
|
|
||||||
"AND n.IsActive='Y' " +
|
|
||||||
"AND z.AD_Client_ID=" + Env.getAD_Client_ID(Env.getCtx()) +
|
|
||||||
" AND z.IsActive='Y' " +
|
|
||||||
"AND z.WizardStatus IN ('F','S')"; // Finished/Skipped
|
|
||||||
return DB.getSQLValue(null, sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MWorkflow> getWfWizards() {
|
public List<MWorkflow> getWfWizards() {
|
||||||
/* TODO: SaaS filter */
|
MClient client = MClient.get(Env.getCtx());
|
||||||
return new Query(Env.getCtx(), MWorkflow.Table_Name, "WorkflowType=? AND IsActive='Y' AND AD_Client_ID IN (0, ?)", null)
|
String ASPFilter = "";
|
||||||
|
if (client.isUseASP())
|
||||||
|
ASPFilter =
|
||||||
|
" AND ( AD_Workflow.AD_Workflow_ID IN ( "
|
||||||
|
// Just ASP subscribed workflows for client "
|
||||||
|
+ " SELECT w.AD_Workflow_ID "
|
||||||
|
+ " FROM ASP_Workflow w, ASP_Level l, ASP_ClientLevel cl "
|
||||||
|
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND cl.AD_Client_ID = " + client.getAD_Client_ID()
|
||||||
|
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
|
||||||
|
+ " AND w.IsActive = 'Y' "
|
||||||
|
+ " AND l.IsActive = 'Y' "
|
||||||
|
+ " AND cl.IsActive = 'Y' "
|
||||||
|
+ " AND w.ASP_Status = 'S') " // Show
|
||||||
|
+ " OR AD_Workflow.AD_Workflow_ID IN ( "
|
||||||
|
// + show ASP exceptions for client
|
||||||
|
+ " SELECT AD_Workflow_ID "
|
||||||
|
+ " FROM ASP_ClientException ce "
|
||||||
|
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
|
||||||
|
+ " AND ce.IsActive = 'Y' "
|
||||||
|
+ " AND ce.AD_Workflow_ID IS NOT NULL "
|
||||||
|
+ " AND ce.ASP_Status = 'S') " // Show
|
||||||
|
+ " ) "
|
||||||
|
+ " AND AD_Workflow.AD_Workflow_ID NOT IN ( "
|
||||||
|
// minus hide ASP exceptions for client
|
||||||
|
+ " SELECT AD_Workflow_ID "
|
||||||
|
+ " FROM ASP_ClientException ce "
|
||||||
|
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
|
||||||
|
+ " AND ce.IsActive = 'Y' "
|
||||||
|
+ " AND ce.AD_Workflow_ID IS NOT NULL "
|
||||||
|
+ " AND ce.ASP_Status = 'H')"; // Hide
|
||||||
|
String where = "WorkflowType=? AND IsActive='Y' AND AD_Client_ID IN (0, ?)" + ASPFilter;
|
||||||
|
return new Query(Env.getCtx(), MWorkflow.Table_Name, where, null)
|
||||||
.setParameters(MWorkflow.WORKFLOWTYPE_Wizard, Env.getAD_Client_ID(Env.getCtx()))
|
.setParameters(MWorkflow.WORKFLOWTYPE_Wizard, Env.getAD_Client_ID(Env.getCtx()))
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setOrderBy(MWorkflow.COLUMNNAME_Priority)
|
.setOrderBy(MWorkflow.COLUMNNAME_Priority)
|
||||||
|
|
Loading…
Reference in New Issue