Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/flowable/flowable-engine
Browse files Browse the repository at this point in the history
…into flowable-release-6.4.2
  • Loading branch information
tijsrademakers committed Apr 11, 2019
2 parents 45ef625 + 4fcd2e2 commit 32c44f9
Show file tree
Hide file tree
Showing 44 changed files with 901 additions and 245 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ After you've done that you can post questions and comments on https://forum.flow

### QA server

There's a Jenkins server running the Flowable unit tests on http://qa.flowable.org.
There's a Jenkins server running the Flowable unit tests on http://qa.flowable.org:8080.
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public void initialize() {
).
deploy();
SideEffectTaskListener.reset();
ThrowExceptionFormFieldValidator.activate();
TestValidationFormEngineConfigurator.ThrowExceptionOnValidationFormService.activate();
}

@After
public void cleanDeployments() {
ThrowExceptionFormFieldValidator.deactivate();
TestValidationFormEngineConfigurator.ThrowExceptionOnValidationFormService.deactivate();
formRepositoryService.createDeploymentQuery().list().forEach(
formDeployment -> formRepositoryService.deleteDeployment(formDeployment.getId())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.cmmn.test.validate;

import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import org.flowable.form.api.FormInfo;
import org.flowable.form.engine.FlowableFormValidationException;
import org.flowable.form.engine.FormEngineConfiguration;
import org.flowable.form.engine.configurator.FormEngineConfigurator;
import org.flowable.form.engine.impl.FormServiceImpl;
import org.flowable.form.engine.impl.cfg.StandaloneFormEngineConfiguration;

/**
* @author martin.grofcik
*/
public class TestValidationFormEngineConfigurator extends FormEngineConfigurator {

public TestValidationFormEngineConfigurator() {
this.formEngineConfiguration = new StandaloneFormEngineConfiguration();
this.formEngineConfiguration.setFormService(new ThrowExceptionOnValidationFormService(formEngineConfiguration));
}

public static class ThrowExceptionOnValidationFormService extends FormServiceImpl {

protected static AtomicBoolean activate = new AtomicBoolean(false);

public ThrowExceptionOnValidationFormService(FormEngineConfiguration engineConfiguration) {
super(engineConfiguration);
}

@Override
public void validateFormFields(FormInfo formInfo, Map<String, Object> values) {
if (activate.get() && (values == null || !values.containsKey("doNotThrowException"))) {
throw new FlowableFormValidationException("Validation failed by default");
}
}

public static void activate() {
activate.set(true);
}

public static void deactivate() {
activate.set(false);
}

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<bean class="org.flowable.cmmn.engine.configurator.CmmnEngineConfigurator">
<property name="cmmnEngineConfiguration" ref="cmmnEngineConfiguration" />
</bean>
<bean class="org.flowable.form.engine.configurator.FormEngineConfigurator"/>
<bean class="org.flowable.cmmn.test.validate.TestValidationFormEngineConfigurator"/>
</list>
</property>
</bean>
Expand All @@ -45,10 +45,6 @@

<property name="formFieldValidationEnabled" value="true"/>
<property name="enableHistoricTaskLogging" value="true"/>
<property name="formFieldHandler">
<bean class="org.flowable.cmmn.test.validate.ThrowExceptionFormFieldValidator"/>
</property>

</bean>

<bean id="processAsyncExecutor" class="org.flowable.job.service.impl.asyncexecutor.DefaultAsyncJobExecutor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.flowable.cmmn.engine.impl.history.async.json.transformer.VariableUpdatedHistoryJsonTransformer;
import org.flowable.cmmn.engine.impl.idm.DefaultCandidateManager;
import org.flowable.cmmn.engine.impl.interceptor.CmmnCommandInvoker;
import org.flowable.cmmn.engine.impl.interceptor.DefaultCmmnIdentityLinkInterceptor;
import org.flowable.cmmn.engine.impl.job.AsyncActivatePlanItemInstanceJobHandler;
import org.flowable.cmmn.engine.impl.job.AsyncInitializePlanModelJobHandler;
import org.flowable.cmmn.engine.impl.job.TriggerTimerEventJobHandler;
Expand Down Expand Up @@ -176,6 +177,8 @@
import org.flowable.cmmn.engine.impl.runtime.DefaultCmmnDynamicStateManager;
import org.flowable.cmmn.engine.impl.scripting.CmmnVariableScopeResolverFactory;
import org.flowable.cmmn.engine.impl.task.DefaultCmmnTaskVariableScopeResolver;
import org.flowable.cmmn.engine.interceptor.CmmnIdentityLinkInterceptor;
import org.flowable.cmmn.engine.interceptor.StartCaseInstanceInterceptor;
import org.flowable.cmmn.image.CaseDiagramGenerator;
import org.flowable.cmmn.image.impl.DefaultCaseDiagramGenerator;
import org.flowable.common.engine.api.FlowableException;
Expand Down Expand Up @@ -335,6 +338,8 @@ public class CmmnEngineConfiguration extends AbstractEngineConfiguration impleme
protected CmmnDynamicStateManager dynamicStateManager;
protected Map<String, List<RuntimeInstanceStateChangeCallback>> caseInstanceStateChangeCallbacks;
protected Map<String, List<PlanItemInstanceLifecycleListener>> planItemInstanceLifecycleListeners;
protected StartCaseInstanceInterceptor startCaseInstanceInterceptor;
protected CmmnIdentityLinkInterceptor identityLinkInterceptor;

protected boolean executeServiceSchemaManagers = true;

Expand Down Expand Up @@ -787,6 +792,7 @@ protected void init() {
initDynamicStateManager();
initCaseInstanceCallbacks();
initFormFieldHandler();
initIdentityLinkInterceptor();
initClock();
initIdentityLinkServiceConfiguration();
initEntityLinkServiceConfiguration();
Expand Down Expand Up @@ -1265,6 +1271,12 @@ public void initFormFieldHandler() {
this.formFieldHandler = new DefaultFormFieldHandler();
}
}

public void initIdentityLinkInterceptor() {
if (identityLinkInterceptor == null) {
identityLinkInterceptor = new DefaultCmmnIdentityLinkInterceptor();
}
}

protected void initDefaultCaseInstanceCallbacks() {
this.caseInstanceStateChangeCallbacks.put(CallbackTypes.PLAN_ITEM_CHILD_CASE,
Expand Down Expand Up @@ -2234,8 +2246,18 @@ public Map<String, List<PlanItemInstanceLifecycleListener>> getPlanItemInstanceL
return planItemInstanceLifecycleListeners;
}

public void setPlanItemInstanceLifecycleListeners(Map<String, List<PlanItemInstanceLifecycleListener>> planItemInstanceLifecycleListeners) {
public CmmnEngineConfiguration setPlanItemInstanceLifecycleListeners(Map<String, List<PlanItemInstanceLifecycleListener>> planItemInstanceLifecycleListeners) {
this.planItemInstanceLifecycleListeners = planItemInstanceLifecycleListeners;
return this;
}

public StartCaseInstanceInterceptor getStartCaseInstanceInterceptor() {
return startCaseInstanceInterceptor;
}

public CmmnEngineConfiguration setStartCaseInstanceInterceptor(StartCaseInstanceInterceptor startCaseInstanceInterceptor) {
this.startCaseInstanceInterceptor = startCaseInstanceInterceptor;
return this;
}

/**
Expand Down Expand Up @@ -3298,6 +3320,15 @@ public CmmnEngineConfiguration setFormFieldHandler(FormFieldHandler formFieldHan
return this;
}

public CmmnIdentityLinkInterceptor getIdentityLinkInterceptor() {
return identityLinkInterceptor;
}

public CmmnEngineConfiguration setIdentityLinkInterceptor(CmmnIdentityLinkInterceptor identityLinkInterceptor) {
this.identityLinkInterceptor = identityLinkInterceptor;
return this;
}

public boolean isFormFieldValidationEnabled() {
return this.isFormFieldValidationEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntity;
import org.flowable.cmmn.engine.impl.task.TaskHelper;
import org.flowable.cmmn.engine.impl.util.CommandContextUtil;
import org.flowable.cmmn.engine.impl.util.IdentityLinkUtil;
import org.flowable.common.engine.api.scope.ScopeTypes;
import org.flowable.identitylink.api.IdentityLink;
import org.flowable.identitylink.api.IdentityLinkType;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
import org.flowable.task.api.Task;
import org.flowable.task.service.InternalTaskAssignmentManager;
Expand All @@ -34,16 +29,6 @@
*/
public class DefaultTaskAssignmentManager implements InternalTaskAssignmentManager {

protected String parentIdentityLinkType;

public DefaultTaskAssignmentManager() {
this(IdentityLinkType.PARTICIPANT);
}

public DefaultTaskAssignmentManager(String parentIdentityLinkType) {
this.parentIdentityLinkType = parentIdentityLinkType;
}

@Override
public void changeAssignee(Task task, String assignee) {
TaskHelper.changeTaskAssignee((TaskEntity) task, assignee);
Expand Down Expand Up @@ -106,22 +91,4 @@ public void deleteGroupIdentityLink(Task task, IdentityLink identityLink) {
IdentityLinkUtil.handleTaskIdentityLinkDeletions((TaskEntity) task, identityLinks, true);
}

@Override
public void addUserIdentityLinkToParent(Task task, String userId) {
if (userId != null && ScopeTypes.CMMN.equals(task.getScopeType()) && StringUtils.isNotEmpty(task.getScopeId())) {
CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager().findById(task.getScopeId());
if (caseInstanceEntity != null) {
List<IdentityLinkEntity> identityLinks = CommandContextUtil.getIdentityLinkService()
.findIdentityLinksByScopeIdAndType(caseInstanceEntity.getId(), ScopeTypes.CMMN);
for (IdentityLinkEntity identityLink : identityLinks) {
if (identityLink.isUser() && identityLink.getUserId().equals(userId) && parentIdentityLinkType.equals(identityLink.getType())) {
return;
}
}

IdentityLinkUtil.createCaseInstanceIdentityLink(caseInstanceEntity, userId, null, parentIdentityLinkType);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import java.util.Map;

import org.flowable.cmmn.engine.CmmnEngineConfiguration;
import org.flowable.cmmn.engine.impl.persistence.entity.PlanItemInstanceEntity;
import org.flowable.cmmn.engine.impl.task.TaskHelper;
import org.flowable.cmmn.engine.impl.util.CommandContextUtil;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.task.service.delegate.TaskListener;
Expand Down Expand Up @@ -72,9 +72,13 @@ public Void execute(CommandContext commandContext) {
}

logUserTaskCompleted(taskEntity);

CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
if (cmmnEngineConfiguration.getIdentityLinkInterceptor() != null) {
cmmnEngineConfiguration.getIdentityLinkInterceptor().handleCompleteTask(taskEntity);
}

CommandContextUtil.getInternalTaskAssignmentManager(commandContext).addUserIdentityLinkToParent(taskEntity, Authentication.getAuthenticatedUserId());
CommandContextUtil.getCmmnEngineConfiguration(commandContext).getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_COMPLETE);
cmmnEngineConfiguration.getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_COMPLETE);

if (planItemInstanceEntity != null) {
CommandContextUtil.getAgenda(commandContext).planTriggerPlanItemInstanceOperation(planItemInstanceEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.flowable.cmmn.model.HumanTask;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.form.api.FormFieldHandler;
import org.flowable.form.api.FormInfo;
Expand Down Expand Up @@ -81,7 +80,7 @@ protected Void execute(CommandContext commandContext, TaskEntity task) {
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
FormFieldHandler formFieldHandler = cmmnEngineConfiguration.getFormFieldHandler();
if (isFormFieldValidationEnabled(cmmnEngineConfiguration, task)) {
formFieldHandler.validateFormFieldsOnSubmit(formInfo, task, variables);
formService.validateFormFields(formInfo, variables);
}
// Extract raw variables and complete the task
Map<String, Object> taskVariables = formService.getVariablesFromFormSubmission(formInfo, variables, outcome);
Expand Down Expand Up @@ -145,8 +144,12 @@ protected void completeTask(CommandContext commandContext, TaskEntity task, Map<

logUserTaskCompleted(task);

CommandContextUtil.getInternalTaskAssignmentManager(commandContext).addUserIdentityLinkToParent(task, Authentication.getAuthenticatedUserId());
CommandContextUtil.getCmmnEngineConfiguration(commandContext).getListenerNotificationHelper().executeTaskListeners(task, TaskListener.EVENTNAME_COMPLETE);
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
if (cmmnEngineConfiguration.getIdentityLinkInterceptor() != null) {
cmmnEngineConfiguration.getIdentityLinkInterceptor().handleCompleteTask(task);
}

cmmnEngineConfiguration.getListenerNotificationHelper().executeTaskListeners(task, TaskListener.EVENTNAME_COMPLETE);

CommandContextUtil.getAgenda(commandContext).planTriggerPlanItemInstanceOperation(planItemInstanceEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,4 @@ public void enrichFormFields(FormInfo formInfo) {
}
}

@Override
public void validateFormFieldsOnSubmit(FormInfo formInfo, VariableContainer variableContainer, Map<String, Object> variables) {
// do not validate form fields by default
}

}

0 comments on commit 32c44f9

Please sign in to comment.