Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bonita-studio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
bonita
bonita-studio
Commits
48328967
Commit
48328967
authored
Jun 09, 2017
by
Romain Bioteau
Committed by
GitHub
Jun 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model) clear children inputs from COMPLEX contract input (#528)
Closes BS-16705
parent
61f125fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
40 deletions
+68
-40
bundles/plugins/org.bonitasoft.studio-models/process.history
bundles/plugins/org.bonitasoft.studio-models/process.history
+3
-0
bundles/plugins/org.bonitasoft.studio.common/src/org/bonitasoft/studio/common/emf/tools/ExpressionHelper.java
.../bonitasoft/studio/common/emf/tools/ExpressionHelper.java
+30
-9
bundles/plugins/org.bonitasoft.studio.common/src/org/bonitasoft/studio/common/emf/tools/RemoveDanglingReferences.java
...oft/studio/common/emf/tools/RemoveDanglingReferences.java
+1
-1
bundles/plugins/org.bonitasoft.studio.migration/src/org/bonitasoft/studio/migration/custom/migration/DependenciesCopyCustomMigration.java
...ion/custom/migration/DependenciesCopyCustomMigration.java
+34
-30
No files found.
bundles/plugins/org.bonitasoft.studio-models/process.history
View file @
48328967
...
...
@@ -14437,5 +14437,8 @@
</changes>
</changes>
</releases>
<releases xmi:id="_zVbFAEzvEee-aqxzWrdt2g" date="2017-06-09T11:43:27.494+0200" label="7.5.2-001">
<changes xsi:type="history:MigrationChange" xmi:id="_2bs5cEzvEee-aqxzWrdt2g" migration="org.bonitasoft.studio.migration.custom.migration.DependenciesCopyCustomMigration"/>
</releases>
<releases xmi:id="_15TmyGnREeaTLbmqFFisdA"/>
</history:History>
bundles/plugins/org.bonitasoft.studio.common/src/org/bonitasoft/studio/common/emf/tools/ExpressionHelper.java
View file @
48328967
...
...
@@ -39,6 +39,7 @@ import org.bonitasoft.studio.model.parameter.Parameter;
import
org.bonitasoft.studio.model.process.BusinessObjectData
;
import
org.bonitasoft.studio.model.process.BusinessObjectType
;
import
org.bonitasoft.studio.model.process.ContractInput
;
import
org.bonitasoft.studio.model.process.ContractInputType
;
import
org.bonitasoft.studio.model.process.Data
;
import
org.bonitasoft.studio.model.process.DataType
;
import
org.bonitasoft.studio.model.process.Document
;
...
...
@@ -148,7 +149,8 @@ public class ExpressionHelper {
return
exp
;
}
public
static
Expression
createConstantExpression
(
final
String
name
,
final
String
content
,
final
String
returnClassName
)
{
public
static
Expression
createConstantExpression
(
final
String
name
,
final
String
content
,
final
String
returnClassName
)
{
final
Expression
exp
=
createConstantExpression
(
content
,
returnClassName
);
exp
.
setName
(
name
);
return
exp
;
...
...
@@ -167,9 +169,20 @@ public class ExpressionHelper {
if
(
dependency
instanceof
SearchIndex
)
{
return
createSearchIndexDependency
(
dependency
);
}
if
(
dependency
instanceof
ContractInput
)
{
return
createContractInputependency
(
dependency
);
}
return
EcoreUtil
.
copy
(
dependency
);
}
private
static
EObject
createContractInputependency
(
EObject
dependency
)
{
final
ContractInput
contractInputDependency
=
(
ContractInput
)
EcoreUtil
.
copy
(
dependency
);
if
(
contractInputDependency
.
getType
()
==
ContractInputType
.
COMPLEX
)
{
contractInputDependency
.
getInputs
().
clear
();
}
return
contractInputDependency
;
}
private
static
EObject
createSearchIndexDependency
(
final
EObject
dependency
)
{
final
SearchIndex
searchIndexDependency
=
(
SearchIndex
)
ProcessFactory
.
eINSTANCE
.
create
(
dependency
.
eClass
());
final
Expression
name
=
((
SearchIndex
)
dependency
).
getName
();
...
...
@@ -212,13 +225,17 @@ public class ExpressionHelper {
}
final
CompoundCommand
cc
=
new
CompoundCommand
(
"Clear Expression"
);
if
(!
ExpressionConstants
.
CONDITION_TYPE
.
equals
(
expr
.
getType
()))
{
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__TYPE
,
ExpressionConstants
.
CONSTANT_TYPE
));
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__TYPE
,
ExpressionConstants
.
CONSTANT_TYPE
));
}
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__NAME
,
""
));
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__CONTENT
,
""
));
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__RETURN_TYPE
,
returnType
));
cc
.
append
(
RemoveCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__REFERENCED_ELEMENTS
,
expr
.
getReferencedElements
()));
cc
.
append
(
RemoveCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__CONNECTORS
,
expr
.
getConnectors
()));
cc
.
append
(
SetCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__RETURN_TYPE
,
returnType
));
cc
.
append
(
RemoveCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__REFERENCED_ELEMENTS
,
expr
.
getReferencedElements
()));
cc
.
append
(
RemoveCommand
.
create
(
editingDomain
,
expr
,
ExpressionPackage
.
Literals
.
EXPRESSION__CONNECTORS
,
expr
.
getConnectors
()));
return
cc
;
}
else
{
clearExpression
(
expr
);
...
...
@@ -260,7 +277,8 @@ public class ExpressionHelper {
return
expression
;
}
public
static
Expression
createExpression
(
final
String
name
,
final
String
content
,
final
String
type
,
final
String
returnType
,
final
boolean
fixedReturnType
)
{
public
static
Expression
createExpression
(
final
String
name
,
final
String
content
,
final
String
type
,
final
String
returnType
,
final
boolean
fixedReturnType
)
{
final
Expression
expression
=
ExpressionFactory
.
eINSTANCE
.
createExpression
();
expression
.
setType
(
type
);
expression
.
setReturnType
(
returnType
);
...
...
@@ -403,7 +421,8 @@ public class ExpressionHelper {
public
static
Operation
createDefaultConnectorOutputOperation
(
final
Output
output
)
{
final
Operation
operation
=
ExpressionFactory
.
eINSTANCE
.
createOperation
();
final
Operator
assignment
=
ExpressionFactory
.
eINSTANCE
.
createOperator
();
assignment
.
setType
(
isDocumentValue
(
output
)
?
ExpressionConstants
.
SET_DOCUMENT_OPERATOR
:
ExpressionConstants
.
ASSIGNMENT_OPERATOR
);
assignment
.
setType
(
isDocumentValue
(
output
)
?
ExpressionConstants
.
SET_DOCUMENT_OPERATOR
:
ExpressionConstants
.
ASSIGNMENT_OPERATOR
);
operation
.
setOperator
(
assignment
);
final
Expression
rightOperand
=
ExpressionFactory
.
eINSTANCE
.
createExpression
();
...
...
@@ -423,7 +442,8 @@ public class ExpressionHelper {
return
Objects
.
equals
(
DocumentValue
.
class
.
getName
(),
output
.
getType
());
}
public
static
Data
dataFromIteratorExpression
(
final
MultiInstantiable
parentFlowElement
,
final
Expression
iteratorExpression
,
final
MainProcess
mainProcess
)
{
public
static
Data
dataFromIteratorExpression
(
final
MultiInstantiable
parentFlowElement
,
final
Expression
iteratorExpression
,
final
MainProcess
mainProcess
)
{
final
String
returnType
=
iteratorExpression
.
getReturnType
();
Data
d
=
null
;
if
(
returnType
!=
null
)
{
...
...
@@ -443,7 +463,8 @@ public class ExpressionHelper {
return
d
;
}
private
static
DataType
getDataTypeFrom
(
final
String
returnType
,
final
MainProcess
mainProcess
,
final
MultiInstantiable
parentFlowElement
)
{
private
static
DataType
getDataTypeFrom
(
final
String
returnType
,
final
MainProcess
mainProcess
,
final
MultiInstantiable
parentFlowElement
)
{
if
(
parentFlowElement
.
getCollectionDataToMultiInstantiate
()
instanceof
BusinessObjectData
)
{
return
find
(
mainProcess
.
getDatatypes
(),
instanceOf
(
BusinessObjectType
.
class
),
null
);
}
else
{
...
...
bundles/plugins/org.bonitasoft.studio.common/src/org/bonitasoft/studio/common/emf/tools/RemoveDanglingReferences.java
View file @
48328967
...
...
@@ -42,7 +42,7 @@ public class RemoveDanglingReferences {
public
void
execute
()
{
removeDanglingReferences
(
root
);
//
removeSequenceFlowWithoutSourceAndTarget(root);
removeSequenceFlowWithoutSourceAndTarget
(
root
);
}
private
void
removeSequenceFlowWithoutSourceAndTarget
(
EObject
element
)
{
...
...
bundles/plugins/org.bonitasoft.studio.migration/src/org/bonitasoft/studio/migration/custom/migration/DependenciesCopyCustomMigration.java
View file @
48328967
...
...
@@ -5,14 +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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.bonitasoft.studio.migration.custom.migration
;
...
...
@@ -25,62 +23,70 @@ import org.eclipse.emf.edapt.spi.migration.Instance;
import
org.eclipse.emf.edapt.spi.migration.Metamodel
;
import
org.eclipse.emf.edapt.spi.migration.Model
;
/**
* @author Romain Bioteau
*
*/
public
class
DependenciesCopyCustomMigration
extends
CustomMigration
{
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see org.eclipse.emf.edapt.migration.CustomMigration#migrateAfter(org.eclipse.emf.edapt.spi.migration.Model, org.eclipse.emf.edapt.migration.Metamodel)
*/
@Override
public
void
migrateAfter
(
final
Model
model
,
final
Metamodel
metamodel
)
throws
MigrationException
{
final
List
<
Instance
>
allReferencesToBeDeleted
=
new
ArrayList
<
Instance
>();
for
(
final
Instance
expInstance
:
model
.
getAllInstances
(
"expression.Expression"
))
{
final
List
<
Instance
>
allReferencesToBeDeleted
=
new
ArrayList
<>();
for
(
final
Instance
expInstance
:
model
.
getAllInstances
(
"expression.Expression"
))
{
final
List
<
Instance
>
referencedElements
=
expInstance
.
get
(
"referencedElements"
);
final
List
<
Instance
>
newReferencedElements
=
new
ArrayList
<
Instance
>();
final
List
<
Instance
>
referencesToBeDeleted
=
new
ArrayList
<
Instance
>();
for
(
final
Instance
refElement
:
referencedElements
)
{
final
List
<
Instance
>
newReferencedElements
=
new
ArrayList
<>();
final
List
<
Instance
>
referencesToBeDeleted
=
new
ArrayList
<>();
for
(
final
Instance
refElement
:
referencedElements
)
{
Instance
newCleanedDependency
=
null
;
if
(
refElement
.
instanceOf
(
"form.Widget"
)){
newCleanedDependency
=
newCleanedWidgetDependency
(
refElement
,
model
);
if
(
refElement
.
instanceOf
(
"form.Widget"
))
{
newCleanedDependency
=
newCleanedWidgetDependency
(
refElement
,
model
);
referencesToBeDeleted
.
add
(
refElement
);
}
else
if
(
refElement
.
instanceOf
(
"process.Data"
))
{
newCleanedDependency
=
newCleaneDataDependency
(
refElement
);
referencesToBeDeleted
.
add
(
refElement
);
}
else
if
(
refElement
.
instanceOf
(
"process.Data"
))
{
newCleanedDependency
=
newCleane
DataDependency
(
refElement
,
model
);
}
else
if
(
refElement
.
instanceOf
(
"process.Document"
))
{
newCleanedDependency
=
newCleane
dDocumentDependency
(
refElement
,
model
);
referencesToBeDeleted
.
add
(
refElement
);
}
else
if
(
refElement
.
instanceOf
(
"process.Document"
)){
newCleanedDependency
=
newCleanedDocumentDependency
(
refElement
,
model
);
}
else
if
(
model
.
getMetamodel
().
getEClass
(
"process.ContractInput"
)
!=
null
&&
refElement
.
instanceOf
(
"process.ContractInput"
))
{
newCleanedDependency
=
newCleanedContractInputDependency
(
refElement
,
model
);
referencesToBeDeleted
.
add
(
refElement
);
}
if
(
newCleanedDependency
!=
null
)
{
if
(
newCleanedDependency
!=
null
)
{
newReferencedElements
.
add
(
newCleanedDependency
);
}
}
for
(
final
Instance
instanceToDelete
:
referencesToBeDeleted
)
{
for
(
final
Instance
instanceToDelete
:
referencesToBeDeleted
)
{
expInstance
.
remove
(
"referencedElements"
,
instanceToDelete
);
}
allReferencesToBeDeleted
.
addAll
(
referencesToBeDeleted
);
for
(
final
Instance
newInstance
:
newReferencedElements
)
{
for
(
final
Instance
newInstance
:
newReferencedElements
)
{
expInstance
.
add
(
"referencedElements"
,
newInstance
);
}
}
for
(
final
Instance
instance
:
allReferencesToBeDeleted
)
{
for
(
final
Instance
instance
:
allReferencesToBeDeleted
)
{
model
.
delete
(
instance
);
}
allReferencesToBeDeleted
.
clear
();
for
(
final
Instance
expInstance
:
model
.
getAllInstances
(
"expression.Expression"
))
{
if
(
expInstance
.
getContainer
()
==
null
)
{
for
(
final
Instance
expInstance
:
model
.
getAllInstances
(
"expression.Expression"
))
{
if
(
expInstance
.
getContainer
()
==
null
)
{
allReferencesToBeDeleted
.
add
(
expInstance
);
}
}
for
(
final
Instance
instance
:
allReferencesToBeDeleted
)
{
for
(
final
Instance
instance
:
allReferencesToBeDeleted
)
{
model
.
delete
(
instance
);
}
allReferencesToBeDeleted
.
clear
();
}
private
Instance
newCleanedContractInputDependency
(
Instance
refElement
,
final
Model
model
)
{
final
Instance
newInstance
=
refElement
.
copy
();
((
List
<
Instance
>)
newInstance
.
get
(
"inputs"
)).
stream
().
forEach
(
model:
:
delete
);
return
newInstance
;
}
protected
Instance
newCleanedDocumentDependency
(
final
Instance
refElement
,
final
Model
model
)
{
final
Instance
newInstance
=
model
.
newInstance
(
refElement
.
getEClass
());
...
...
@@ -88,23 +94,21 @@ public class DependenciesCopyCustomMigration extends CustomMigration {
return
newInstance
;
}
protected
Instance
newCleaneDataDependency
(
final
Instance
refElement
,
final
Model
model
)
{
protected
Instance
newCleaneDataDependency
(
final
Instance
refElement
)
{
final
Instance
newInstance
=
refElement
.
copy
();
newInstance
.
set
(
"defaultValue"
,
null
);
return
newInstance
;
}
protected
Instance
newCleanedWidgetDependency
(
final
Instance
refElement
,
final
Model
model
)
{
final
Instance
newInstance
=
model
.
newInstance
(
refElement
.
getEClass
());
newInstance
.
set
(
"name"
,
refElement
.
get
(
"name"
));
Object
modifier
=
refElement
.
get
(
"returnTypeModifier"
);
if
(
modifier
==
null
)
{
if
(
modifier
==
null
)
{
modifier
=
String
.
class
.
getName
();
}
newInstance
.
set
(
"returnTypeModifier"
,
modifier
);
if
(
newInstance
.
instanceOf
(
"form.Duplicable"
))
{
if
(
newInstance
.
instanceOf
(
"form.Duplicable"
))
{
newInstance
.
set
(
"duplicate"
,
refElement
.
get
(
"duplicate"
));
}
return
newInstance
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment