Skip to content

Commit

Permalink
added dedicated ParseHandler form FormAwareServiceTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
WelschChristopher committed Jan 13, 2025
1 parent 5f4c121 commit ef6da42
Show file tree
Hide file tree
Showing 27 changed files with 1,272 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public interface BpmnXMLConstants {
public static final String ELEMENT_TASK_LISTENER = "taskListener";
public static final String ELEMENT_SCRIPT = "script";
public static final String ELEMENT_FORM_REFERENCE = "formreference";

public static final String ATTRIBUTE_LISTENER_EVENT = "event";
public static final String ATTRIBUTE_LISTENER_EVENTS = "events";
public static final String ATTRIBUTE_LISTENER_ENTITY_TYPE = "entityType";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
import org.flowable.cmmn.engine.impl.parser.handler.CaseTaskParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.DecisionTaskParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.ExternalWorkerServiceTaskParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.FormAwareServiceTaskParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.GenericEventListenerParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.HttpTaskParseHandler;
import org.flowable.cmmn.engine.impl.parser.handler.HumanTaskParseHandler;
Expand Down Expand Up @@ -1146,6 +1147,7 @@ public List<CmmnParseHandler> getDefaultCmmnParseHandlers() {
cmmnParseHandlers.add(new ProcessTaskParseHandler());
cmmnParseHandlers.add(new ScriptTaskParseHandler());
cmmnParseHandlers.add(new ServiceTaskParseHandler());
cmmnParseHandlers.add(new FormAwareServiceTaskParseHandler());
cmmnParseHandlers.add(new SendEventServiceTaskParseHandler());
cmmnParseHandlers.add(new ExternalWorkerServiceTaskParseHandler());
cmmnParseHandlers.add(new StageParseHandler());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* 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.engine.impl.parser.handler;

import org.apache.commons.lang3.StringUtils;
import org.flowable.cmmn.engine.impl.parser.CmmnActivityBehaviorFactory;
import org.flowable.cmmn.engine.impl.parser.CmmnParseResult;
import org.flowable.cmmn.engine.impl.parser.CmmnParserImpl;
import org.flowable.cmmn.model.HttpServiceTask;
import org.flowable.cmmn.model.ImplementationType;
import org.flowable.cmmn.model.PlanItem;
import org.flowable.cmmn.model.SendEventServiceTask;
import org.flowable.cmmn.model.ServiceTask;

/**
* @author Joram Barrez
*/
public abstract class AbstractServiceTaskParseHandler<T extends ServiceTask> extends AbstractPlanItemParseHandler<T> {

@Override
protected void executePlanItemParse(CmmnParserImpl cmmnParser, CmmnParseResult cmmnParseResult, PlanItem planItem, ServiceTask serviceTask) {
CmmnActivityBehaviorFactory activityBehaviorFactory = cmmnParser.getActivityBehaviorFactory();
switch (serviceTask.getType()) {
case HttpServiceTask.HTTP_TASK:
planItem.setBehavior(activityBehaviorFactory.createHttpActivityBehavior(planItem, serviceTask));
break;

case ServiceTask.MAIL_TASK:
planItem.setBehavior(activityBehaviorFactory.createEmailActivityBehavior(planItem, serviceTask));
break;

case SendEventServiceTask.SEND_EVENT:
planItem.setBehavior(activityBehaviorFactory.createSendEventActivityBehavior(planItem, (SendEventServiceTask) serviceTask));
break;

default:
// java task type was not set in the version <= 6.2.0 that's why we have to assume that default service task type is java
if (StringUtils.isNotEmpty(serviceTask.getImplementation())) {
if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createCmmnClassDelegate(planItem, serviceTask));

} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createPlanItemExpressionActivityBehavior(planItem, serviceTask));

} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createPlanItemDelegateExpressionActivityBehavior(planItem, serviceTask));
}
}
break;

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* 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.engine.impl.parser.handler;

import java.util.Collection;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.flowable.cmmn.engine.impl.parser.CmmnActivityBehaviorFactory;
import org.flowable.cmmn.engine.impl.parser.CmmnParseResult;
import org.flowable.cmmn.engine.impl.parser.CmmnParserImpl;
import org.flowable.cmmn.model.BaseElement;
import org.flowable.cmmn.model.FormAwareServiceTask;
import org.flowable.cmmn.model.HttpServiceTask;
import org.flowable.cmmn.model.ImplementationType;
import org.flowable.cmmn.model.PlanItem;
import org.flowable.cmmn.model.SendEventServiceTask;
import org.flowable.cmmn.model.ServiceTask;

/**
* @author Christopher Welsch
*/
public class FormAwareServiceTaskParseHandler extends AbstractServiceTaskParseHandler<FormAwareServiceTask> {

@Override
public Collection<Class<? extends BaseElement>> getHandledTypes() {
return Set.of(FormAwareServiceTask.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,10 @@
/**
* @author Joram Barrez
*/
public class ServiceTaskParseHandler extends AbstractPlanItemParseHandler<ServiceTask> {
public class ServiceTaskParseHandler extends AbstractServiceTaskParseHandler<ServiceTask> {

@Override
public Collection<Class<? extends BaseElement>> getHandledTypes() {
return Set.of(ServiceTask.class, FormAwareServiceTask.class);
return Set.of(ServiceTask.class);
}

@Override
protected void executePlanItemParse(CmmnParserImpl cmmnParser, CmmnParseResult cmmnParseResult, PlanItem planItem, ServiceTask serviceTask) {
CmmnActivityBehaviorFactory activityBehaviorFactory = cmmnParser.getActivityBehaviorFactory();
switch (serviceTask.getType()) {
case HttpServiceTask.HTTP_TASK:
planItem.setBehavior(activityBehaviorFactory.createHttpActivityBehavior(planItem, serviceTask));
break;

case ServiceTask.MAIL_TASK:
planItem.setBehavior(activityBehaviorFactory.createEmailActivityBehavior(planItem, serviceTask));
break;

case SendEventServiceTask.SEND_EVENT:
planItem.setBehavior(activityBehaviorFactory.createSendEventActivityBehavior(planItem, (SendEventServiceTask) serviceTask));
break;

default:
// java task type was not set in the version <= 6.2.0 that's why we have to assume that default service task type is java
if (StringUtils.isNotEmpty(serviceTask.getImplementation())) {
if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createCmmnClassDelegate(planItem, serviceTask));

} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createPlanItemExpressionActivityBehavior(planItem, serviceTask));

} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
planItem.setBehavior(activityBehaviorFactory.createPlanItemDelegateExpressionActivityBehavior(planItem, serviceTask));
}
}
break;

}
}

}
Loading

0 comments on commit ef6da42

Please sign in to comment.