Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) 2009-2013 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.ow2.bonita.facade.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.ow2.bonita.connector.core.Connector;
import org.ow2.bonita.connector.core.Mapper;
import org.ow2.bonita.definition.activity.ConnectorExecutor;
import org.ow2.bonita.facade.WebAPI;
import org.ow2.bonita.facade.def.InternalProcessDefinition;
import org.ow2.bonita.facade.def.majorElement.ProcessDefinition;
import org.ow2.bonita.facade.exception.CategoryAlreadyExistsException;
import org.ow2.bonita.facade.exception.CategoryNotFoundException;
import org.ow2.bonita.facade.exception.DocumentAlreadyExistsException;
import org.ow2.bonita.facade.exception.DocumentationCreationException;
import org.ow2.bonita.facade.exception.ProcessNotFoundException;
import org.ow2.bonita.facade.runtime.ActivityInstance;
import org.ow2.bonita.facade.runtime.Category;
import org.ow2.bonita.facade.runtime.Document;
import org.ow2.bonita.facade.runtime.Label;
import org.ow2.bonita.facade.runtime.WebTemporaryToken;
import org.ow2.bonita.facade.runtime.impl.CaseImpl;
import org.ow2.bonita.facade.runtime.impl.CategoryImpl;
import org.ow2.bonita.facade.runtime.impl.InternalProcessInstance;
import org.ow2.bonita.facade.runtime.impl.LabelImpl;
import org.ow2.bonita.facade.runtime.impl.WebTemporaryTokenImpl;
import org.ow2.bonita.facade.uuid.CategoryUUID;
import org.ow2.bonita.facade.uuid.ProcessDefinitionUUID;
import org.ow2.bonita.facade.uuid.ProcessInstanceUUID;
import org.ow2.bonita.light.LightProcessDefinition;
import org.ow2.bonita.light.LightProcessInstance;
import org.ow2.bonita.light.impl.LightProcessDefinitionImpl;
import org.ow2.bonita.light.impl.LightProcessInstanceImpl;
import org.ow2.bonita.services.DocumentationManager;
import org.ow2.bonita.services.WebService;
import org.ow2.bonita.services.WebTokenManagementService;
import org.ow2.bonita.util.BonitaConstants;
import org.ow2.bonita.util.DocumentService;
import org.ow2.bonita.util.EnvTool;
import org.ow2.bonita.util.Misc;
/**
* @author Charles Souillard, Matthieu Chaffotte, Nicolas Chabanoles, Christophe
* Leroy
*/
public class WebAPIImpl implements WebAPI {
protected WebAPIImpl(final String queryList) {
}
@Override
public void deletePhantomCases() {
final Set webCases = EnvTool.getWebService().getAllCases();
final Set runtimeCases = EnvTool.getAllQueriers().getParentInstancesUUIDs();
webCases.removeAll(runtimeCases);
if (!webCases.isEmpty()) {
EnvTool.getWebService().deleteCases(webCases);
}
}
@Override
public void addLabel(final String labelName, final String ownerName, final String editableCSSStyleName,
final String readonlyCSSStyleName, final String previewCSSStyleName, final boolean isVisible,
final boolean hasToBeDisplayed, final String iconCSSStyle, final Set caseList,
final int displayOrder, final boolean isSystemLabel) {
final WebService webService = EnvTool.getWebService();
final LabelImpl label = new LabelImpl(labelName, ownerName, editableCSSStyleName, readonlyCSSStyleName,
previewCSSStyleName, isVisible, hasToBeDisplayed, iconCSSStyle, displayOrder, isSystemLabel);
webService.addLabel(label);
addCasesToLabel(ownerName, labelName, caseList);
}
@Override
public void removeLabel(final String ownerName, final String labelName) {
EnvTool.getWebService().removeLabel(ownerName, labelName);
}
@Override
public void removeCasesFromLabel(final String ownerName, final String labelName,
final Set caseList) {
final Set instances = EnvTool.getAllQueriers().getProcessInstances(caseList);
final WebService webService = EnvTool.getWebService();
for (final InternalProcessInstance parentNewOrUpdatedInstance : instances) {
webService.removeCase(parentNewOrUpdatedInstance.getUUID(), ownerName, labelName);
}
EnvTool.getWebService().removeCasesFromLabel(ownerName, labelName, caseList);
}
@Override
public void deleteAllCases() {
EnvTool.getWebService().deleteAllCases();
}
@Override
public void updateLabelCSS(final String ownerName, final String labelName, final String aEditableCSSStyle,
final String aPreviewCSSStyle, final String aReadOnlyCSSStyle) {
final LabelImpl label = EnvTool.getWebService().getLabel(ownerName, labelName);
label.setEditableCSSStyleName(aEditableCSSStyle);
label.setPreviewCSSStyleName(aPreviewCSSStyle);
label.setReadonlyCSSStyleName(aReadOnlyCSSStyle);
}
@Override
public void addCasesToLabel(final String ownerName, final String labelName, final Set caseList) {
final Set instances = EnvTool.getAllQueriers().getProcessInstances(caseList);
final WebService webService = EnvTool.getWebService();
for (final InternalProcessInstance internalProcessInstance : instances) {
if (webService.getCase(internalProcessInstance.getUUID(), ownerName, labelName) == null) {
webService.addCase(new CaseImpl(internalProcessInstance.getUUID(), ownerName, labelName));
}
}
}
@Override
public Label getLabel(final String ownerName, final String labelName) {
final LabelImpl label = EnvTool.getWebService().getLabel(ownerName, labelName);
if (label == null) {
return null;
}
return new LabelImpl(label);
}
@Override
public Set