| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.bpm; |
| |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.List; |
| import java.util.Map; |
| |
| import org.eclipse.osbp.bpm.api.BPMTaskSummary; |
| import org.eclipse.osbp.bpm.api.IBPMEngine; |
| import org.eclipse.osbp.bpm.api.IBPMTaskClient; |
| import org.eclipse.osbp.bpm.api.IBlipBPMFunctionProvider; |
| import org.eclipse.osbp.bpm.api.IBlipBPMStartInfo; |
| |
| @SuppressWarnings("all") |
| public abstract class AbstractBlipBPMFunctionProvider implements IBlipBPMFunctionProvider { |
| |
| protected Map<String, IBlipBPMStartInfo> startInfos; |
| |
| protected List<String> errors; |
| |
| protected abstract Map<String, IBlipBPMStartInfo> initializeStartInfos(); |
| |
| protected abstract boolean initializeBpmEngine(); |
| |
| @Override |
| public IBlipBPMStartInfo getStartInfo(BPMTaskSummary taskSummary) { |
| IBlipBPMStartInfo startInfo = null; |
| String processId = getProcessId(taskSummary); |
| if (processId != null) { |
| startInfo = startInfos.get(processId); |
| } |
| return startInfo; |
| } |
| |
| protected String getProcessId(BPMTaskSummary taskSummary) { |
| if (ServiceBinder.getTaskClient() != null) { |
| return ServiceBinder.getTaskClient().getProcessId(taskSummary); |
| } |
| return null; |
| } |
| |
| @Override |
| public final boolean initBlip() { |
| startInfos = initializeStartInfos(); |
| errors = new ArrayList<String>(); |
| return initializeBpmEngine(); |
| } |
| |
| @Override |
| public final void startProcess(final String processName) { |
| IBlipBPMStartInfo bpm = startInfos.get(processName); |
| if (ServiceBinder.getBPMEngine() != null) { |
| Map<String,Object> metadata = new HashMap<String,Object>(); |
| metadata.put(VARIABLE_PROCESS_PROTOCOL, ""); |
| metadata.put(VARIABLE_PROCESS_WORKLOAD_DTO_FQN, bpm.getWorkloadDtoFqn()); |
| metadata.put(VARIABLE_PROCESS_WORKLOAD_DTO, bpm.createWorkloadDto()); |
| ServiceBinder.getBPMEngine().startProcess(bpm, metadata); |
| } |
| } |
| |
| @Override |
| public final Map<String, IBlipBPMStartInfo> getBpmns() { |
| return startInfos; |
| } |
| |
| @Override |
| public final List<String> getErrors() { |
| return errors; |
| } |
| } |