IDEMPIERE-2771 Improve 2pack tracing for errors / run role access update at the end
This commit is contained in:
parent
966d02d2fe
commit
679e2fd06a
|
@ -72,6 +72,7 @@ public class FormElementHandler extends AbstractElementHandler {
|
|||
if (mForm.save(getTrxName(ctx)) == true){
|
||||
logImportDetail (ctx, impDetail, 1, mForm.getName(), mForm.get_ID(), action);
|
||||
element.recordId = mForm.get_ID();
|
||||
element.requireRoleAccessUpdate = true;
|
||||
}
|
||||
else{
|
||||
logImportDetail (ctx, impDetail, 0, mForm.getName(), mForm.get_ID(), action);
|
||||
|
|
|
@ -36,6 +36,12 @@ import org.adempiere.pipo2.PackOut;
|
|||
import org.adempiere.pipo2.PackoutItem;
|
||||
import org.adempiere.pipo2.PoExporter;
|
||||
import org.adempiere.pipo2.PoFiller;
|
||||
import org.compiere.model.I_AD_Form;
|
||||
import org.compiere.model.I_AD_InfoWindow;
|
||||
import org.compiere.model.I_AD_Process;
|
||||
import org.compiere.model.I_AD_Role;
|
||||
import org.compiere.model.I_AD_Window;
|
||||
import org.compiere.model.I_C_DocType;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTable;
|
||||
|
@ -91,6 +97,13 @@ public class GenericPOElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
po.saveEx();
|
||||
element.recordId = po.get_ID();
|
||||
if ( I_AD_Window.Table_Name.equals(tableName)
|
||||
|| I_AD_Process.Table_Name.equals(tableName)
|
||||
|| I_AD_Role.Table_Name.equals(tableName)
|
||||
|| I_AD_Form.Table_Name.equals(tableName)
|
||||
|| I_C_DocType.Table_Name.equals(tableName)
|
||||
|| I_AD_InfoWindow.Table_Name.equals(tableName))
|
||||
element.requireRoleAccessUpdate = true;
|
||||
}
|
||||
|
||||
public void endElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ProcessElementHandler extends AbstractElementHandler {
|
|||
logImportDetail(ctx, impDetail, 1, mProcess.getName(), mProcess
|
||||
.get_ID(), action);
|
||||
element.recordId = mProcess.get_ID();
|
||||
element.requireRoleAccessUpdate = true;
|
||||
} else {
|
||||
logImportDetail(ctx, impDetail, 0, mProcess.getName(), mProcess
|
||||
.get_ID(), action);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class RoleElementHandler extends AbstractElementHandler {
|
|||
element.recordId = mRole.getAD_Role_ID();
|
||||
logImportDetail(ctx, impDetail, 1, mRole.getName(), mRole.get_ID(),
|
||||
action);
|
||||
element.requireRoleAccessUpdate = true;
|
||||
} else {
|
||||
|
||||
logImportDetail(ctx, impDetail, 0, mRole.getName(), mRole.get_ID(),
|
||||
|
|
|
@ -94,6 +94,7 @@ public class WindowElementHandler extends AbstractElementHandler {
|
|||
.get_ID(), action);
|
||||
windows.add(mWindow.getAD_Window_ID());
|
||||
element.recordId = mWindow.get_ID();
|
||||
element.requireRoleAccessUpdate = true;
|
||||
} else {
|
||||
logImportDetail(ctx, impDetail, 0, mWindow.getName(), mWindow
|
||||
.get_ID(), action);
|
||||
|
|
|
@ -91,6 +91,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
|||
.get_ID(), action);
|
||||
workflows.add(mWorkflow.getAD_Workflow_ID());
|
||||
element.recordId = mWorkflow.get_ID();
|
||||
element.requireRoleAccessUpdate = true;
|
||||
} else {
|
||||
log.info("m_Workflow save failure");
|
||||
logImportDetail(ctx, impDetail, 0, mWorkflow.getName(), mWorkflow
|
||||
|
@ -131,6 +132,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
|||
.get_ID(), "Update");
|
||||
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||
element.requireRoleAccessUpdate = true;
|
||||
} else {
|
||||
log.info("m_Workflow update fail");
|
||||
logImportDetail(ctx, impDetail, 0, m_Workflow.getName(), m_Workflow
|
||||
|
|
|
@ -52,6 +52,8 @@ public class Element {
|
|||
|
||||
public boolean deferEnd = false;
|
||||
|
||||
public boolean requireRoleAccessUpdate = false;
|
||||
|
||||
public Map<String, Element> properties = new LinkedHashMap<String, Element>();
|
||||
|
||||
public List<Element> childrens = new ArrayList<Element>();
|
||||
|
|
|
@ -32,7 +32,9 @@ import java.util.logging.Level;
|
|||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.pipo2.exception.DatabaseAccessException;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_AD_Package_Imp;
|
||||
import org.compiere.model.X_AD_Package_Imp_Inst;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -78,6 +80,7 @@ public class PackInHandler extends DefaultHandler {
|
|||
private Stack<Element> stack = new Stack<Element>();
|
||||
private PackIn packIn;
|
||||
private int elementProcessed = 0;
|
||||
private boolean isUpdateRoleAccess = false;
|
||||
|
||||
private void init() throws SAXException {
|
||||
|
||||
|
@ -241,6 +244,9 @@ public class PackInHandler extends DefaultHandler {
|
|||
if (! deferFK.contains(element.deferFKColumnID))
|
||||
deferFK.add(element.deferFKColumnID);
|
||||
}
|
||||
if (element.requireRoleAccessUpdate) {
|
||||
isUpdateRoleAccess = true;
|
||||
}
|
||||
|
||||
for (Element childElement : element.childrens)
|
||||
{
|
||||
|
@ -298,6 +304,8 @@ public class PackInHandler extends DefaultHandler {
|
|||
|
||||
processDeferFKElements();
|
||||
|
||||
updateRoleAccess();
|
||||
|
||||
if (!packageStatus.equals("Completed with errors")) {
|
||||
if (getUnresolvedCount() > 0) {
|
||||
packageStatus = "Completed - unresolved";
|
||||
|
@ -493,4 +501,18 @@ public class PackInHandler extends DefaultHandler {
|
|||
startElement = b;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRoleAccess() {
|
||||
if (!isUpdateRoleAccess)
|
||||
return;
|
||||
|
||||
List<MRole> roles = new Query(m_ctx.ctx, MRole.Table_Name, "IsManual='N'", m_ctx.trx.getTrxName())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy("AD_Client_ID, Name")
|
||||
.list();
|
||||
for (MRole role : roles) {
|
||||
role.updateAccessRecords(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // PackInHandler
|
||||
|
|
Loading…
Reference in New Issue