Commit 6f74b4e9 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-12139

Move parameters to bos
parent be5442d5
......@@ -51,9 +51,11 @@ Export-Package: org.bonitasoft.studio.engine,org.bonitasoft.studio.eng
Bundle-Activator: org.bonitasoft.studio.engine.EnginePlugin
Bundle-ActivationPolicy: lazy
Import-Package: com.bonitasoft.engine.api,
com.bonitasoft.engine.bpm.process.impl,
org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.bpm.businessdata,
org.bonitasoft.engine.bpm.connector,
org.bonitasoft.engine.bpm.flownode,
org.bonitasoft.engine.bpm.process,
......
/**
* 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.engine.export.switcher;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.bonitasoft.engine.bpm.businessdata.BusinessDataDefinition;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.bonitasoft.engine.bpm.process.impl.ProcessDefinitionBuilderExt;
/**
* @author Romain Bioteau
*
*/
public class DataSwitchTest {
private DataSwitch switchUnderTest;
private BusinessObjectData data;
private ProcessDefinitionBuilderExt designProcessDefinitionBuilderEx;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
designProcessDefinitionBuilderEx = new ProcessDefinitionBuilderExt().createNewInstance("p1", "1.0");
data = ProcessFactory.eINSTANCE.createBusinessObjectData();
data.setName("myLeaveRequest");
data.setClassName("org.bonitasoft.hr.LeaveRequest");
data.setDataType(ProcessFactory.eINSTANCE.createBusinessObjectType());
data.setDocumentation("Some doc");
data.setMultiple(false);
switchUnderTest = new DataSwitch(data, null, designProcessDefinitionBuilderEx);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for
* {@link org.bonitasoft.studio.engine.ex.exporter.switcher.DataSwitchEx#caseBusinessObjectData(org.bonitasoft.studio.model.process.BusinessObjectData)}.
*/
@Test
public void shouldCaseBusinessObjecType_addBusinessObjectDataInProcessDefinition() throws Exception {
switchUnderTest.doSwitch(data.getDataType());
final List<BusinessDataDefinition> businessDataDefinitions = designProcessDefinitionBuilderEx.getProcess().getProcessContainer()
.getBusinessDataDefinitions();
assertThat(businessDataDefinitions).hasSize(1).extracting("name").contains("myLeaveRequest");
assertThat(designProcessDefinitionBuilderEx.getProcess().getProcessContainer().getBusinessDataDefinitions()).extracting("className").contains(
"org.bonitasoft.hr.LeaveRequest");
assertThat(designProcessDefinitionBuilderEx.getProcess().getProcessContainer().getBusinessDataDefinitions()).extracting("description").contains(
"Some doc");
assertThat(designProcessDefinitionBuilderEx.getProcess().getProcessContainer().getBusinessDataDefinitions()).extracting("multiple").contains(false);
}
@Test
public void shouldCaseBusinessObjecType_addMultipleBusinessObjectDataInProcessDefinition() throws Exception {
data.setMultiple(true);
switchUnderTest.doSwitch(data.getDataType());
final List<BusinessDataDefinition> businessDataDefinitions = designProcessDefinitionBuilderEx.getProcess().getProcessContainer()
.getBusinessDataDefinitions();
assertThat(businessDataDefinitions).hasSize(1);
assertThat(designProcessDefinitionBuilderEx.getProcess().getProcessContainer().getBusinessDataDefinitions()).extracting("multiple").contains(true);
}
}
......@@ -23,6 +23,8 @@ import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.Element;
import org.eclipse.emf.ecore.EObject;
import com.bonitasoft.engine.bpm.process.impl.ProcessDefinitionBuilderExt;
/**
* @author Romain Bioteau
......@@ -32,20 +34,23 @@ public class AbstractProcessSwitch extends AbstractSwitch {
protected final ProcessDefinitionBuilder builder;
public AbstractProcessSwitch(ProcessDefinitionBuilder processBuilder,Set<EObject> eObjectNotExported){
public AbstractProcessSwitch(final ProcessDefinitionBuilder processBuilder,final Set<EObject> eObjectNotExported){
super(eObjectNotExported);
builder = processBuilder ;
}
@Override
public Element caseAbstractProcess(AbstractProcess object) {
public Element caseAbstractProcess(final AbstractProcess object) {
addActors(builder,object);
addData(builder,object) ;
if (builder instanceof ProcessDefinitionBuilderExt) {
addParameters((ProcessDefinitionBuilderExt) builder, object);
}
addConnector(builder, object) ;
addKPIBinding(builder, object);
return object;
}
public ProcessDefinitionBuilder getProcessBuilder(){
return builder;
}
......
......@@ -31,6 +31,7 @@ import org.bonitasoft.studio.model.connectorconfiguration.ConnectorParameter;
import org.bonitasoft.studio.model.expression.Operation;
import org.bonitasoft.studio.model.kpi.AbstractKPIBinding;
import org.bonitasoft.studio.model.kpi.DatabaseKPIBinding;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.Actor;
import org.bonitasoft.studio.model.process.ConnectableElement;
......@@ -42,6 +43,8 @@ import org.bonitasoft.studio.model.process.util.ProcessSwitch;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;
import com.bonitasoft.engine.bpm.process.impl.ProcessDefinitionBuilderExt;
/**
* @author Romain Bioteau
*/
......@@ -73,6 +76,13 @@ public abstract class AbstractSwitch extends ProcessSwitch<Element> {
}
}
protected void addParameters(final ProcessDefinitionBuilderExt builder, final AbstractProcess process) {
for (final Parameter p : process.getParameters()) {
final String description = p.getDescription();
builder.addParameter(p.getName(), p.getTypeClassname()).addDescription(description == null ? "" : description);
}
}
protected void addConnector(final FlowElementBuilder builder, final ConnectableElement element) {
for (Connector connector : element.getConnectors()) {
if (!eObjectNotExported.contains(connector)) {
......
......@@ -16,10 +16,13 @@ package org.bonitasoft.studio.engine.export.switcher;
import java.util.Collection;
import org.bonitasoft.engine.bpm.process.impl.BusinessDataDefinitionBuilder;
import org.bonitasoft.engine.bpm.process.impl.DataDefinitionBuilder;
import org.bonitasoft.engine.bpm.process.impl.FlowElementBuilder;
import org.bonitasoft.engine.expression.Expression;
import org.bonitasoft.studio.model.process.BooleanType;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.BusinessObjectType;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.DateType;
import org.bonitasoft.studio.model.process.DoubleType;
......@@ -33,6 +36,8 @@ import org.bonitasoft.studio.model.process.StringType;
import org.bonitasoft.studio.model.process.XMLType;
import org.bonitasoft.studio.model.process.util.ProcessSwitch;
import com.bonitasoft.engine.bpm.process.impl.ProcessDefinitionBuilderExt;
/**
* @author Romain Bioteau
*/
......@@ -144,4 +149,14 @@ public class DataSwitch extends ProcessSwitch<DataDefinitionBuilder> {
return builder.addDateData(data.getName(), expr);
}
@Override
public DataDefinitionBuilder caseBusinessObjectType(
final BusinessObjectType object) {
final BusinessObjectData bod = (BusinessObjectData) getData();
final BusinessDataDefinitionBuilder businessDataBuilder = ((ProcessDefinitionBuilderExt) getBuilder()).addBusinessData(bod.getName(),
bod.getClassName(), getDefaultValueExpression());
businessDataBuilder.setMultiple(bod.isMultiple());
businessDataBuilder.addDescription(bod.getDocumentation());
return null;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-test/java"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.bonitasoft.studio.parameters</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Localization: plugin
Bundle-Name: Parameters Plugin
Bundle-SymbolicName: org.bonitasoft.studio.parameters;singleton:=true
Bundle-Version: 6.5.0.qualifier
Bundle-Activator: org.bonitasoft.studio.parameters.ParameterPlugin
Bundle-Vendor: BonitaSoft S.A.
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.bonitasoft.studio.model;bundle-version="1.0.0",
org.bonitasoft.studio.expression.editor;bundle-version="1.0.0",
org.eclipse.gmf.runtime.diagram.ui.properties,
org.bonitasoft.studio.pics;bundle-version="1.0.0",
org.bonitasoft.studio.common;bundle-version="1.0.0",
org.eclipse.core.databinding;bundle-version="1.4.0",
org.eclipse.emf.databinding;bundle-version="1.2.0",
org.eclipse.emf.databinding.edit,
org.eclipse.jface.databinding;bundle-version="1.5.0",
org.bonitasoft.studio.configuration;bundle-version="1.0.0",
org.bonitasoft.studio.common.repository;bundle-version="1.0.0",
org.bonitasoft.studio.diagram;bundle-version="1.0.0",
org.bonitasoft.studio.diagram.form;bundle-version="1.0.0",
org.eclipse.xtext.ui;bundle-version="2.3.1",
org.eclipse.jdt.core,
org.eclipse.core.databinding.property;bundle-version="1.4.0",
org.eclipse.jface,
org.bonitasoft.studio.diagram.custom,
org.bonitasoft.studio.groovy.ui;bundle-version="6.2.0",
org.bonitasoft.studio.refactoring;bundle-version="6.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.parameters.action,org.bonitasoft
.studio.parameters.i18n,org.bonitasoft.studio.parameters.wizard.page
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
messages.properties,\
plugin.xml,\
plugin.properties
src.excludes = src-test/java/
name=Name *
textType=Text
integerType=Integer
booleanType=Boolean
doubleType=Double
value=Value
type=Type
add=Add...
addData=Add...
remove=Remove
parameterDescription=Description
paramDefaultName=parameter
parameters=Parameter
createOrRemoveParameterDetail=A parameter stores a value that is fixed for a process. Click Add to add a parameter. The parameter value must be set at configuration in Studio or when the process is deployed in the Portal.
invalidName=Name already exists
returnType=Return type
invalidDouble=Invalid double value
invalidInteger=Invalid integer value
parameterWizardDesc=Configure the process parameters
invalidIntegerForParameter=Invalid integer value for {0}
invalidDoulbeForParameter=Invalid double value for {0}
missingParameterValue=Missing value for parameter {0}
exportParameterFile=Export parameters as file...
importParameterFile=Import properties file...
areYouSureMessage=Are you sure you want to remove the parameter\: {0} ?
areYouSureTitle=Remove parameter?
newParameter=New parameter
newParameterWizardTitle=Add a new parameter to {0}
newParameterWizardDescription=Add a new parameter
createAndNewButton=Finish && Add
updateParameter=Edit...
selectOnlyOneElementTitle=No element or too many elements selected
selectOnlyOneElementMessage=One and only one element must be selected. Please select only the element you want to update.
editParameterWizardTitle=Edit a parameter
editParameterWizardDescription=When you click OK, if the parameter is used in a Groovy script, the refactor window is displayed and you can validate the changes.
additionalInformationText=Parameter initialization is done in the 'Configure' menu of the coolbar.
removeParameters=Removing parameters...
updatingParameterReferences=Updating parameter references...
Parameter=Parameters
createDataLabel=<A>Create a parameter...</A>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs
contributorId="org.bonitasoft.studio.diagram">
<propertyTab
afterTab="tab.connectors"
category="domain"
id="tab.parameter"
label="%Parameter">
</propertyTab>
</propertyTabs>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="org.bonitasoft.studio.diagram">
<propertySection
class="org.bonitasoft.studio.parameters.property.section.ParameterPropertySection"
enablesFor="1"
filter="org.bonitasoft.studio.parameters.property.section.AbstractProcessFilter"
id="parameter.section"
tab="tab.parameter"
viewID="org.bonitasoft.studio.views.properties.process.general">
</propertySection>
</propertySections>
</extension>
<extension
point="org.bonitasoft.studio.expression.expressionProvider">
<expressionProvider
providerClass="org.bonitasoft.studio.parameters.expression.ParameterExpressionProvider">
</expressionProvider>
</extension>
<extension
point="org.bonitasoft.studio.configuration.wizardPage">
<configurationWizardPage
class="org.bonitasoft.studio.parameters.wizard.page.ParametersConfigurationWizardPage"
priority="3">
</configurationWizardPage>
</extension>
<extension
point="org.bonitasoft.studio.configuration.importConfigurationAction">
<importConfigurationAction
class="org.bonitasoft.studio.parameters.action.ImportParametersAction">
</importConfigurationAction>
</extension>
<extension
point="org.bonitasoft.studio.configuration.exportConfigurationAction">
<exportConfigurationAction
class="org.bonitasoft.studio.parameters.action.ExportParametersAction">
</exportConfigurationAction>
</extension>
<extension
point="org.bonitasoft.studio.configuration.synchronizer">
<synchronier
class="org.bonitasoft.studio.parameters.configuration.ParametersConfigurationSynchronizer">
</synchronier>
</extension>
<extension
point="org.bonitasoft.studio.expression.proposalListener">
<proposalListner
name="%createDataLabel"
providerClass="org.bonitasoft.studio.parameters.wizard.page.CreateParameterProposalListener"
type="TYPE_PARAMETER">
</proposalListner>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.bonitasoft.studio.bundles</groupId>
<artifactId>plugins</artifactId>
<version>6.5.0-SNAPSHOT</version>
</parent>
<groupId>org.bonitasoft.studio.bundles.plugins</groupId>
<artifactId>org.bonitasoft.studio.parameters</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
/**
*
*/
package org.bonitasoft.studio.parameters.wizard.page;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashSet;
import java.util.Set;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.parameter.ParameterFactory;
import org.bonitasoft.studio.parameters.i18n.Messages;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain
*
*/
public class ParametersWizardPageTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_isNameValid_return_null() throws Exception {
Parameter parameterWorkingCopy = ParameterFactory.eINSTANCE.createParameter();
Set<String> existingParameterNames = new HashSet<String>();
existingParameterNames.add("myParam2");
ParametersWizardPage wizardPage = new ParametersWizardPage(parameterWorkingCopy, existingParameterNames);
assertThat(wizardPage.isNameValid("myParam")).isNull();
}
@Test
public void should_isNameValid_return_errormessage() throws Exception {
Parameter parameterWorkingCopy = ParameterFactory.eINSTANCE.createParameter();
Set<String> existingParameterNames = new HashSet<String>();
existingParameterNames.add("myParam");
ParametersWizardPage wizardPage = new ParametersWizardPage(parameterWorkingCopy, existingParameterNames);
assertThat(wizardPage.isNameValid("myParam")).isEqualTo(Messages.invalidName);
}
}
/*******************************************************************************
* Copyright (C) 2009, 2013 BonitaSoft S.A.
* BonitaSoft is a trademark of BonitaSoft SA.
* This software file is BONITASOFT CONFIDENTIAL. Not For Distribution.
* For commercial licensing information, contact:
* BonitaSoft, 32 rue Gustave Eiffel – 38000 Grenoble
* or BonitaSoft US, 51 Federal Street, Suite 305, San Francisco, CA 94107
*******************************************************************************/
package org.bonitasoft.studio.parameters;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class ParameterPlugin extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.bonitasoft.studio.parameters"; //$NON-NLS-1$
// The shared instance
private static ParameterPlugin plugin;
/**
* The constructor
*/
public ParameterPlugin() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static ParameterPlugin getDefault() {
return plugin;
}
}
/*******************************************************************************
* Copyright (C) 2009, 2013 BonitaSoft S.A.
* BonitaSoft is a trademark of BonitaSoft SA.
* This software file is BONITASOFT CONFIDENTIAL. Not For Distribution.
* For commercial licensing information, contact:
* BonitaSoft, 32 rue Gustave Eiffel – 38000 Grenoble
* or BonitaSoft US, 51 Federal Street, Suite 305, San Francisco, CA 94107
*******************************************************************************/
package org.bonitasoft.studio.parameters.action;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import org.bonitasoft.studio.common.jface.FileActionDialog;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.configuration.extension.IConfigurationExportAction;
import org.bonitasoft.studio.model.configuration.Configuration;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.parameters.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;