From 8c91ccededca39cf10f22241e343f746bbc1c6ef Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 19 Dec 2017 09:02:29 -0600 Subject: [PATCH] Issue 13208 unable upload files (#13224) * #11609 : Updating DB scripts. Adding upgrade task to create intermediate table and other minor changes. * #11609 added first draft for add/edit workflow action * #11609 almost code done for save/edit workflow actions associated to the scheme * #11609 the add action and action to step are done * #11609 Added the delete steps and dependencies/minor fixes for transactions, etc * #11609 delete action from step done in the ui/ajax and endpoint * #11609 Added the deletes for the UI * #12960 changes for reorder done * #13104 Added the new field requires lock options that supports locked, unlocked and both choices * #12960 added the scripts changes for all dbs * #12960 added changes for the workflow, action and step new relationships * #12960 notes and fixes * #12960 fixing the IT test * #12960 code review feedback * #11691 added changes for the new endpoint for getting content type schemes * #12960 added changes for h2 and mysql * #12960 added the changes for the show_on column * #12960 adding changes for the showOn * #12960 changes for show on functionality * resolving the error of the missing schemeid * solving issue with content resource test * Fixing the Task04305UpdateWorkflowActionTable * Reverting to master configuration * #12960 fixing postgres and oracle UT * #11609 fixes for 11609 * #11609 configuration rollback * #11609 fixes by code review * #13208 now when there is a wrong workflow task associated to the step, it is deleted --- dotCMS/src/main/enterprise | 2 +- .../business/WorkflowFactoryImpl.java | 32 +++++++++++-------- .../workflows/business/WorkflowSQL.java | 3 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/dotCMS/src/main/enterprise b/dotCMS/src/main/enterprise index a44a1497bb4c..4ccfa3991dc7 160000 --- a/dotCMS/src/main/enterprise +++ b/dotCMS/src/main/enterprise @@ -1 +1 @@ -Subproject commit a44a1497bb4cbe2507293164d09d7681f03f46a9 +Subproject commit 4ccfa3991dc78c015fa5688bdda2e90b49bf24d5 diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowFactoryImpl.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowFactoryImpl.java index dd773a563c04..d357b5cf8ef2 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowFactoryImpl.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowFactoryImpl.java @@ -566,18 +566,25 @@ public WorkflowStep findStep(String id) throws DotDataException { } public List findStepsByContentlet(Contentlet contentlet) throws DotDataException { - List steps = new ArrayList<>(); - List currentSteps = cache.getSteps(contentlet); - final List schemes = this.findSchemesForStruct(contentlet.getContentTypeId()); + List steps = new ArrayList<>(); + List currentSteps = cache.getSteps(contentlet); + final List schemes = this.findSchemesForStruct(contentlet.getContentTypeId()); + String workflowTaskId = null; + List> dbResults = null; + if (currentSteps == null) { WorkflowStep step = null; try { final DotConnect db = new DotConnect(); db.setSQL(sql.SELECT_STEP_BY_CONTENTLET); db.addParam(contentlet.getIdentifier()); - step = (WorkflowStep) this.convertListToObjects(db.loadObjectResults(), WorkflowStep.class).get(0); + + dbResults = db.loadObjectResults(); + step = (WorkflowStep) this.convertListToObjects + (dbResults, WorkflowStep.class).get(0); steps.add(step); + workflowTaskId = (String)dbResults.get(0).get("workflowid"); } catch (final Exception e) { Logger.debug(this.getClass(), e.getMessage()); } @@ -593,19 +600,16 @@ public List findStepsByContentlet(Contentlet contentlet) throws Do throw new DotDataException("Unable to find workflow step for content id:" + contentlet.getIdentifier()); } } - - - }else { + } else { steps.addAll(currentSteps); } - // if the existing task belongs to another workflow schema, then blank - // the workflow task status + // if the existing task belongs to another workflow schema, then remove it if (steps.size() == 1 && !existSchemeIdOnSchemesList(steps.get(0).getSchemeId(),schemes)) { - final DotConnect db = new DotConnect(); - db.setSQL(sql.RESET_CONTENTLET_STEPS); - db.addParam(StringPool.BLANK); - db.addParam(contentlet.getIdentifier()); - db.loadResult(); + + if (null != workflowTaskId) { + this.deleteWorkflowTask(this.findWorkFlowTaskById(workflowTaskId)); + } + steps = new ArrayList<>(); } diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowSQL.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowSQL.java index c0e4d59caf0c..8668b391abbb 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowSQL.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowSQL.java @@ -79,8 +79,9 @@ static protected WorkflowSQL getInstance() { protected static String INSERT_STEP= "insert into workflow_step (id, name, scheme_id,my_order,resolved,escalation_enable,escalation_action,escalation_time) values (?, ?, ?, ?, ?, ?, ?, ?) "; protected static String UPDATE_STEP= "update workflow_step set name=?, scheme_id=?, my_order=?, resolved = ?, escalation_enable = ?, escalation_action=?, escalation_time = ? where id = ?"; protected static String DELETE_STEP= "delete from workflow_step where id = ?"; - protected static String SELECT_STEP_BY_CONTENTLET= "select workflow_step.* from workflow_step join workflow_task on workflow_task.status = workflow_step.id where workflow_task.webasset= ?"; + protected static String SELECT_STEP_BY_CONTENTLET= "select workflow_task.id as workflowid, workflow_step.* from workflow_step join workflow_task on workflow_task.status = workflow_step.id where workflow_task.webasset= ?"; protected static String RESET_CONTENTLET_STEPS= "update workflow_task set status = ? where webasset= ?"; + protected static String DELETE_CONTENTLET_STEPS= "delete from workflow_task where status = ? and webasset= ?"; protected static String SELECT_COUNT_CONTENTLES_BY_STEP= "select count(workflow_task.id) as count from workflow_task join workflow_step on workflow_task.status=workflow_step.id where workflow_step.id=?"; protected static String SELECT_ACTION_CLASSES_BY_ACTION= "select * from workflow_action_class where action_id = ? order by my_order";