Commit 476d391f authored by Bonita CI's avatar Bonita CI
Browse files

Merge branch 'MasterBugFixing' into 'master'

parents 91dc644f 6f79671c
......@@ -6,6 +6,7 @@
<installerFilename>@installer.name@</installerFilename>
<licenseFile>@license@</licenseFile>
<licenseFileEncoding>utf-8</licenseFileEncoding>
<compressionAlgorithm>lzma-ultra</compressionAlgorithm>
<logoImage>@logo@</logoImage>
<leftImage>@leftImage@</leftImage>
<splashImage>@splash@</splashImage>
......
......@@ -13,6 +13,8 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="version" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="modelVersion" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral=""/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConnectorParameter">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="key" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
......
......@@ -201,7 +201,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultValueIdOfDocumentStore"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="documentType" lowerBound="1"
eType="#//DocumentType" defaultValueLiteral="0"/>
eType="#//DocumentType" defaultValueLiteral="NONE"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="multiple" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Boolean"
defaultValueLiteral="false"/>
......
......@@ -94,6 +94,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute connector-configuration.ecore#//ConnectorConfiguration/definitionId"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute connector-configuration.ecore#//ConnectorConfiguration/version"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute connector-configuration.ecore#//ConnectorConfiguration/name"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute connector-configuration.ecore#//ConnectorConfiguration/modelVersion"/>
</genClasses>
<genClasses ecoreClass="connector-configuration.ecore#//ConnectorParameter">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute connector-configuration.ecore#//ConnectorParameter/key"/>
......
......@@ -53,7 +53,8 @@ Require-Bundle: org.eclipse.core.runtime,
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.junit;bundle-version="4.11.0";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.bonitasoft.studio.expression.editor
org.bonitasoft.studio.expression.editor,
org.apache.commons.lang;bundle-version="2.6.0"
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
......
......@@ -255,6 +255,4 @@ defaultCustomUserInformationName=Information
nameLimitSize=the name is limited to 50 char
displayNameLimitSize=the display name is limited to 75 char
labelExplicationCustomUserInformation=The information below (default and custom) applies to all users. Custom information can be used in the processes (e.g. by implementing actor filters on tasks).
ayNameLimitSize=the display name is limited to 75 char
labelExplicationCustomUserInformation=The information below (default and custom) applies to all users. Custom information can be used in the processes (e.g. by implementing actor filters on tasks).
details=Details
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.ui.wizard.page;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.actors.model.organization.Group;
import org.bonitasoft.studio.actors.model.organization.OrganizationFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class OrganizationGroupLabelProviderTest {
private OrganizationGroupLabelProvider organizationGroupLabelProvider;
private Group shortGroup;
private Group longGroup;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
organizationGroupLabelProvider = new OrganizationGroupLabelProvider();
longGroup = OrganizationFactory.eINSTANCE.createGroup();
longGroup.setName("longGroup");
longGroup.setParentPath("/acme/group1/group2/group3/group4/group5/group6");
shortGroup = OrganizationFactory.eINSTANCE.createGroup();
shortGroup.setName("shortGroup");
shortGroup.setParentPath("/acme/");
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_getText_returns_group_path() throws Exception {
assertThat(organizationGroupLabelProvider.getText(shortGroup)).isEqualTo(GroupContentProvider.getGroupPath(shortGroup));
}
@Test
public void should_getText_returns_group_path_with_ellipsis() throws Exception {
assertThat(organizationGroupLabelProvider.getText(longGroup)).hasSize(OrganizationGroupLabelProvider.MAX_GROUP_PATH_LENGTH).endsWith("longGroup")
.contains("...");
}
@Test
public void should_getText_returns_empty_string() throws Exception {
assertThat(organizationGroupLabelProvider.getText(null)).isEmpty();
}
}
......@@ -5,12 +5,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
*
* This program 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 General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
......@@ -48,69 +48,72 @@ import org.eclipse.emf.edit.domain.EditingDomain;
*/
public class RefactorActorOperation extends AbstractRefactorOperation<String, Actor, ActorRefactorPair> {
private AbstractProcess process;
private final AbstractProcess process;
public RefactorActorOperation(AbstractProcess process, Actor actor, String newValue) {
public RefactorActorOperation(final AbstractProcess process, final Actor actor, final String newValue) {
super(RefactoringOperationType.UPDATE);
this.process = process;
addItemToRefactor(newValue, actor);
}
@Override
protected void doExecute(IProgressMonitor monitor) {
protected void doExecute(final IProgressMonitor monitor) {
monitor.beginTask(Messages.updateActorReferences, IProgressMonitor.UNKNOWN);
String id = ModelHelper.getEObjectID(process);
String fileName = id + ".conf";
ProcessConfigurationRepositoryStore processConfStore = (ProcessConfigurationRepositoryStore) RepositoryManager.getInstance().getCurrentRepository()
final String id = ModelHelper.getEObjectID(process);
final String fileName = id + ".conf";
final ProcessConfigurationRepositoryStore processConfStore = (ProcessConfigurationRepositoryStore) RepositoryManager.getInstance().getCurrentRepository()
.getRepositoryStore(ProcessConfigurationRepositoryStore.class);
ProcessConfigurationFileStore file = processConfStore.getChild(fileName);
final ProcessConfigurationFileStore file = processConfStore.getChild(fileName);
Configuration localeConfiguration = null;
Configuration localConfigurationCopy = null;
if (file != null) {
localeConfiguration = file.getContent();
localConfigurationCopy = EcoreUtil.copy(localeConfiguration);
}
List<Configuration> configurations = new ArrayList<Configuration>();
final List<Configuration> configurations = new ArrayList<Configuration>();
if (localeConfiguration != null) {
configurations.add(localeConfiguration);
}
configurations.addAll(process.getConfigurations());
CompoundCommand cc = new CompoundCommand();
for(ActorRefactorPair pairToRefactor : pairsToRefactor){
Actor actor = (Actor) pairToRefactor.getOldValue();
for (Configuration configuration : configurations) {
if (configuration.getActorMappings() != null) {
List<ActorMapping> actorMappings = configuration.getActorMappings().getActorMapping();
for (ActorMapping actorMapping : actorMappings) {
if (actorMapping.getName().equals(actor.getName())) {
cc.append(SetCommand.create(domain, actorMapping, ActorMappingPackage.Literals.ACTOR_MAPPING__NAME, pairToRefactor.getNewValueName()));
}
}
if (localeConfiguration != null) {
cc.append(new SaveConfigurationEMFCommand(file, localConfigurationCopy, localeConfiguration));
}
}
}
cc.append(SetCommand.create(domain, actor, ProcessPackage.Literals.ELEMENT__NAME, pairToRefactor.getNewValueName()));
if (compoundCommand == null) {
compoundCommand = new CompoundCommand();
}
for(final ActorRefactorPair pairToRefactor : pairsToRefactor){
final Actor actor = pairToRefactor.getOldValue();
for (final Configuration configuration : configurations) {
if (configuration.getActorMappings() != null) {
final List<ActorMapping> actorMappings = configuration.getActorMappings().getActorMapping();
for (final ActorMapping actorMapping : actorMappings) {
if (actorMapping.getName().equals(actor.getName())) {
compoundCommand.append(SetCommand.create(domain, actorMapping, ActorMappingPackage.Literals.ACTOR_MAPPING__NAME,
pairToRefactor.getNewValueName()));
}
}
if (localeConfiguration != null) {
compoundCommand.append(new SaveConfigurationEMFCommand(file, localConfigurationCopy, localeConfiguration));
}
}
}
compoundCommand.append(SetCommand.create(domain, actor, ProcessPackage.Literals.ELEMENT__NAME, pairToRefactor.getNewValueName()));
}
}
@Override
protected AbstractScriptExpressionRefactoringAction<ActorRefactorPair> getScriptExpressionRefactoringAction(List<ActorRefactorPair> pairsToRefactor,
List<Expression> scriptExpressions, List<Expression> refactoredScriptExpression, CompoundCommand compoundCommand, EditingDomain domain,
RefactoringOperationType operationType) {
protected AbstractScriptExpressionRefactoringAction<ActorRefactorPair> getScriptExpressionRefactoringAction(final List<ActorRefactorPair> pairsToRefactor,
final List<Expression> scriptExpressions, final List<Expression> refactoredScriptExpression, final CompoundCommand compoundCommand, final EditingDomain domain,
final RefactoringOperationType operationType) {
return null;
}
@Override
protected EObject getContainer(Actor oldValue) {
protected EObject getContainer(final Actor oldValue) {
return null;
}
@Override
protected ActorRefactorPair createRefactorPair(String newItem, Actor oldItem) {
return new ActorRefactorPair(newItem, oldItem);
}
@Override
protected ActorRefactorPair createRefactorPair(final String newItem, final Actor oldItem) {
return new ActorRefactorPair(newItem, oldItem);
}
}
......@@ -16,19 +16,40 @@
*/
package org.bonitasoft.studio.actors.repository;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bonitasoft.studio.actors.ActorsPlugin;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.common.ModelVersion;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.platform.tools.CopyInputStream;
import org.bonitasoft.studio.common.repository.CommonRepositoryPlugin;
import org.bonitasoft.studio.common.repository.filestore.DefinitionConfigurationFileStore;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.store.AbstractEMFRepositoryStore;
import org.bonitasoft.studio.model.connectorconfiguration.ConnectorConfiguration;
import org.bonitasoft.studio.model.connectorconfiguration.util.ConnectorConfigurationAdapterFactory;
import org.bonitasoft.studio.pics.Pics;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLOptions;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMLOptionsImpl;
import org.eclipse.emf.edapt.history.Release;
import org.eclipse.emf.edapt.migration.MigrationException;
import org.eclipse.emf.edapt.migration.execution.Migrator;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.swt.graphics.Image;
......@@ -50,7 +71,7 @@ public class ActorFilterConfRepositoryStore extends AbstractEMFRepositoryStore<D
* @see org.bonitasoft.studio.common.repository.model.IRepositoryStore#createRepositoryFileStore(java.lang.String)
*/
@Override
public DefinitionConfigurationFileStore createRepositoryFileStore(String fileName) {
public DefinitionConfigurationFileStore createRepositoryFileStore(final String fileName) {
return new DefinitionConfigurationFileStore(fileName, this);
}
......@@ -87,18 +108,17 @@ public class ActorFilterConfRepositoryStore extends AbstractEMFRepositoryStore<D
return extensions;
}
public List<ConnectorConfiguration> getConnectorConfigurations() {
List<ConnectorConfiguration> result = new ArrayList<ConnectorConfiguration>() ;
for(IRepositoryFileStore child : getChildren()){
public List<ConnectorConfiguration> getFilterConfigurations() {
final List<ConnectorConfiguration> result = new ArrayList<ConnectorConfiguration>();
for (final IRepositoryFileStore child : getChildren()) {
result.add((ConnectorConfiguration) child.getContent()) ;
}
return result ;
}
public List<ConnectorConfiguration> getConnectorConfigurationsFor(String defintionId,String definitionVersion) {
List<ConnectorConfiguration> result = new ArrayList<ConnectorConfiguration>() ;
for(ConnectorConfiguration child : getConnectorConfigurations()){
public List<ConnectorConfiguration> getFilterConfigurationsFor(final String defintionId, final String definitionVersion) {
final List<ConnectorConfiguration> result = new ArrayList<ConnectorConfiguration>();
for (final ConnectorConfiguration child : getFilterConfigurations()) {
if(child.getDefinitionId().equals(defintionId) && child.getVersion().equals(definitionVersion) ){
result.add(child) ;
}
......@@ -106,9 +126,97 @@ public class ActorFilterConfRepositoryStore extends AbstractEMFRepositoryStore<D
return result ;
}
@Override
protected Release getRelease(final Migrator targetMigrator, final Resource resource) {
final Map<Object, Object> loadOptions = new HashMap<Object, Object>();
//Ignore unknown features
loadOptions.put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
final XMLOptions options = new XMLOptionsImpl();
options.setProcessAnyXML(true);
loadOptions.put(XMLResource.OPTION_XML_OPTIONS, options);
try {
resource.load(loadOptions);
} catch (final IOException e) {
BonitaStudioLog.error(e, CommonRepositoryPlugin.PLUGIN_ID);
}
final String modelVersion = getModelVersion(resource);
for (final Release release : targetMigrator.getReleases()) {
if (release.getLabel().equals(modelVersion)) {
return release;
}
}
return targetMigrator.getReleases().iterator().next(); //First release of all time
}
protected String getModelVersion(final Resource resource) {
final String modelVersion = ModelVersion.VERSION_6_0_0_ALPHA;
for (final EObject root : resource.getContents()) {
if (root instanceof ConnectorConfiguration) {
final String version = ((ConnectorConfiguration) root).getModelVersion();
if (version != null) {
return version;
}
}
}
return modelVersion;
}
@Override
protected InputStream handlePreImport(final String fileName, final InputStream inputStream) throws MigrationException, IOException {
CopyInputStream copyIs = null;
try {
final InputStream is = super.handlePreImport(fileName, inputStream);
copyIs = new CopyInputStream(is);
final Resource r = getTmpEMFResource("beforeImport",
copyIs.getCopy());
try {
r.load(Collections.EMPTY_MAP);
} catch (final IOException e) {
BonitaStudioLog.error(e);
}
if (!r.getContents().isEmpty()) {
final ConnectorConfiguration configuration = (ConnectorConfiguration) r.getContents()
.get(0);
if (configuration != null) {
final String mVersion = configuration.getVersion();
if (!ModelVersion.CURRENT_VERSION.equals(mVersion)) {
configuration.setModelVersion(ModelVersion.CURRENT_VERSION);
}
try {
r.save(Collections.EMPTY_MAP);
} catch (final IOException e) {
BonitaStudioLog.error(e);
}
try {
return new FileInputStream(new File(r.getURI()
.toFileString()));
} catch (final FileNotFoundException e) {
BonitaStudioLog.error(e);
} finally {
copyIs.close();
try {
r.delete(Collections.EMPTY_MAP);
} catch (final IOException e) {
BonitaStudioLog.error(e);
}
}
} else {
return null;
}
}
return copyIs.getCopy();
} catch (final IOException e) {
BonitaStudioLog.error(e);
return null;
} finally {
if (copyIs != null) {
copyIs.close();
}
}
}
@Override
protected void addAdapterFactory(ComposedAdapterFactory adapterFactory) {
protected void addAdapterFactory(final ComposedAdapterFactory adapterFactory) {
adapterFactory.addAdapterFactory(new ConnectorConfigurationAdapterFactory());
}
......
......@@ -66,8 +66,6 @@ import org.eclipse.swt.graphics.Image;
*/
public class OrganizationRepositoryStore extends AbstractEMFRepositoryStore<OrganizationFileStore> {
private static final String NAMESPACE_6_3_0 = "xmlns:organization=\"http://documentation.bonitasoft.com/organization-xml-schema\"";
private static final String NAMESPACE_6_0_0_BETA_016 = "xmlns:organization=\"http://www.bonitasoft.org/ns/organization/6.0.0-beta-016\"";
private static final String STORE_NAME = "organizations";
public static final String ORGANIZATION_EXT = "organization";
private static final Set<String> extensions = new HashSet<String>() ;
......@@ -207,10 +205,6 @@ public class OrganizationRepositoryStore extends AbstractEMFRepositoryStore<Orga
final Resource resource = new XMLResourceImpl(resourceURI);
final DocumentRoot root = OrganizationFactory.eINSTANCE.createDocumentRoot();
final Organization orga = EcoreUtil.copy(((DocumentRoot) r.getContents().get(0)).getOrganization());
// List<PasswordType> passwords = ModelHelper.getAllItemsOfType(orga, OrganizationPackage.Literals.PASSWORD_TYPE);
// for(PasswordType p : passwords){
// p.setEncrypted(p.isEncrypted());
// }
root.setOrganization(orga);
resource.getContents().add(root);
final Map<String, String> options = new HashMap<String, String>();
......
......@@ -5,12 +5,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
*
* This program 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 General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
......@@ -41,7 +41,7 @@ import org.eclipse.ui.progress.IProgressService;
/**
* @author Romain Bioteau
*
*
*/
public class ActorNameEditingSupport extends EditingSupport {
......@@ -49,7 +49,7 @@ public class ActorNameEditingSupport extends EditingSupport {
private final CellEditorValidationStatusListener listener;
public ActorNameEditingSupport(ColumnViewer viewer, TransactionalEditingDomain transactionalEditingDomain, CellEditorValidationStatusListener listener) {
public ActorNameEditingSupport(final ColumnViewer viewer, final TransactionalEditingDomain transactionalEditingDomain, final CellEditorValidationStatusListener listener) {
super(viewer);
this.transactionalEditingDomain = transactionalEditingDomain;
this.listener = listener;
......@@ -60,7 +60,7 @@ public class ActorNameEditingSupport extends EditingSupport {
* @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
*/
@Override
protected boolean canEdit(Object element) {
protected boolean canEdit(final Object element) {
return true;
}
......@@ -70,21 +70,21 @@ public class ActorNameEditingSupport extends EditingSupport {
*/
@Override
protected CellEditor getCellEditor(final Object element) {
TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE);
final TextCellEditor editor = new TextCellEditor((Composite) getViewer().getControl(), SWT.NONE);
editor.setValidator(new ICellEditorValidator() {
@Override
public String isValid(Object value) {
String input = (String) value;
public String isValid(final Object value) {
final String input = (String) value;
if (input.isEmpty()) {
return Messages.nameIsEmpty;
}
if (input.length() > 50) {
return Messages.nameTooLong;
}
Actor actor = (Actor) element;
AbstractProcess process = ModelHelper.getParentProcess(actor);
for (Actor a : process.getActors()) {
final Actor actor = (Actor) element;
final AbstractProcess process = ModelHelper.getParentProcess(actor);
for (final Actor a : process.getActors()) {
if (!a.equals(actor)) {
if (a.getName().equals(input)) {
return Messages.nameAlreadyExists;
......@@ -104,7 +104,7 @@ public class ActorNameEditingSupport extends EditingSupport {
* @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
*/
@Override
protected Object getValue(Object element) {
protected Object getValue(final Object element) {
if (element instanceof Actor) {
return ((Actor) element).getName();
}
......@@ -116,31 +116,33 @@ public class ActorNameEditingSupport extends EditingSupport {
* @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
*/
@Override
protected void setValue(Object element, Object value) {
protected void setValue(final Object element, final Object value) {
if (element != null && value != null && transactionalEditingDomain != null) {
AbstractProcess process = ModelHelper.getParentProcess((EObject) element);
final AbstractProcess process = ModelHelper.getParentProcess((EObject) element);
if (process != null) {
executeOperation(process, (String) value, element);
transactionalEditingDomain.getCommandStack().execute(
SetCommand.create(transactionalEditingDomain, element, ProcessPackage.Literals.ELEMENT__NAME, value));
executeOperation(process, (String) value, element);
getViewer().refresh();
if (!getViewer().getControl().isDisposed()) {