Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-studio
Commits
3c881fa2
Commit
3c881fa2
authored
Nov 08, 2014
by
apupier
Browse files
On import, fix when there are several subfolders which correspond to
different repository stores due to previous refactoring code commit
parent
c315a787
Changes
2
Hide whitespace changes
Inline
Side-by-side
bundles/plugins/org.bonitasoft.studio.common.repository/src/org/bonitasoft/studio/common/repository/operation/IResourceImporter.java
View file @
3c881fa2
...
@@ -60,11 +60,7 @@ public class IResourceImporter {
...
@@ -60,11 +60,7 @@ public class IResourceImporter {
final
List
<
IFolder
>
folderSortedList
=
getFolders
(
rootContainer
);
final
List
<
IFolder
>
folderSortedList
=
getFolders
(
rootContainer
);
Collections
.
sort
(
folderSortedList
,
importFolderComparator
);
Collections
.
sort
(
folderSortedList
,
importFolderComparator
);
for
(
final
IFolder
folder
:
folderSortedList
)
{
for
(
final
IFolder
folder
:
folderSortedList
)
{
final
Pair
<
IRepositoryStore
<?
extends
IRepositoryFileStore
>,
IFolder
>
pair
=
findRepository
(
findRepository
(
repositoryStoreMap
,
folder
,
monitor
);
repositoryStoreMap
,
folder
);
if
(
pair
!=
null
)
{
importRepositoryStore
(
pair
,
monitor
);
}
}
}
}
}
...
@@ -76,23 +72,18 @@ public class IResourceImporter {
...
@@ -76,23 +72,18 @@ public class IResourceImporter {
return
fileStoresToOpen
;
return
fileStoresToOpen
;
}
}
private
Pair
<
IRepositoryStore
<?
extends
IRepositoryFileStore
>,
IFolder
>
findRepository
(
private
void
findRepository
(
final
Map
<
String
,
IRepositoryStore
<?
extends
IRepositoryFileStore
>>
repositoryStoreMap
,
final
Map
<
String
,
IRepositoryStore
<?
extends
IRepositoryFileStore
>>
repositoryStoreMap
,
final
IFolder
folder
)
throws
ResourceImportException
{
final
IFolder
folder
,
final
IProgressMonitor
monitor
)
throws
ResourceImportException
{
final
String
path
=
folder
.
getProjectRelativePath
().
removeFirstSegments
(
1
).
toOSString
();
final
String
path
=
folder
.
getProjectRelativePath
().
removeFirstSegments
(
1
).
toOSString
();
final
IRepositoryStore
<?
extends
IRepositoryFileStore
>
store
=
repositoryStoreMap
.
get
(
path
);
final
IRepositoryStore
<?
extends
IRepositoryFileStore
>
store
=
repositoryStoreMap
.
get
(
path
);
if
(
store
!=
null
)
{
if
(
store
!=
null
)
{
return
new
Pair
<
IRepositoryStore
<?
extends
IRepositoryFileStore
>,
IFolder
>(
store
,
folder
);
importRepositoryStore
(
new
Pair
<
IRepositoryStore
<?
extends
IRepositoryFileStore
>,
IFolder
>(
store
,
folder
)
,
monitor
)
;
}
else
{
}
else
{
for
(
final
IFolder
subFolder
:
getFolders
(
folder
))
{
for
(
final
IFolder
subFolder
:
getFolders
(
folder
))
{
final
Pair
<
IRepositoryStore
<?
extends
IRepositoryFileStore
>,
IFolder
>
pair
=
findRepository
(
repositoryStoreMap
,
subFolder
);
findRepository
(
repositoryStoreMap
,
subFolder
,
monitor
);
if
(
pair
!=
null
)
{
return
pair
;
}
}
}
}
}
return
null
;
}
}
protected
List
<
IFolder
>
getFolders
(
final
IContainer
container
)
throws
ResourceImportException
{
protected
List
<
IFolder
>
getFolders
(
final
IContainer
container
)
throws
ResourceImportException
{
...
...
bundles/plugins/org.bonitasoft.studio.simulation/src/org/bonitasoft/studio/simulation/engine/SimulationExporter.java
View file @
3c881fa2
/**
/**
* Copyright (C) 2010 BonitaSoft S.A.
* Copyright (C) 2010 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
*
*
* This program is free software: you can redistribute it and/or modify
* 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
* 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
* the Free Software Foundation, either version 2.0 of the License, or
...
@@ -82,7 +82,7 @@ import org.eclipse.emf.ecore.EClass;
...
@@ -82,7 +82,7 @@ import org.eclipse.emf.ecore.EClass;
/**
/**
* @author Romain Bioteau
* @author Romain Bioteau
*
*
*/
*/
public
class
SimulationExporter
{
public
class
SimulationExporter
{
...
@@ -90,23 +90,23 @@ public class SimulationExporter {
...
@@ -90,23 +90,23 @@ public class SimulationExporter {
private
final
Map
<
String
,
List
<
Resource
>>
usedResourceMap
=
new
HashMap
<
String
,
List
<
Resource
>>();
private
final
Map
<
String
,
List
<
Resource
>>
usedResourceMap
=
new
HashMap
<
String
,
List
<
Resource
>>();
private
Map
<
String
,
SimActivity
>
simulationActivities
;
private
Map
<
String
,
SimActivity
>
simulationActivities
;
public
List
<
SimProcess
>
createSimulationModel
(
List
<
AbstractProcess
>
processes
)
throws
Exception
{
public
List
<
SimProcess
>
createSimulationModel
(
final
List
<
AbstractProcess
>
processes
)
throws
Exception
{
List
<
SimProcess
>
results
=
new
ArrayList
<
SimProcess
>();
final
List
<
SimProcess
>
results
=
new
ArrayList
<
SimProcess
>();
for
(
AbstractProcess
abstractProcess
:
processes
)
{
for
(
final
AbstractProcess
abstractProcess
:
processes
)
{
results
.
add
(
createSimulationProcess
(
abstractProcess
));
results
.
add
(
createSimulationProcess
(
abstractProcess
));
}
}
return
results
;
return
results
;
}
}
public
SimProcess
createSimulationProcess
(
AbstractProcess
process
)
throws
Exception
{
public
SimProcess
createSimulationProcess
(
final
AbstractProcess
process
)
throws
Exception
{
// CREATE SIMULATION PROCESS
// CREATE SIMULATION PROCESS
SimProcess
simProcess
=
new
SimProcess
(
process
.
getName
(),
process
.
getMaximumTime
());
final
SimProcess
simProcess
=
new
SimProcess
(
process
.
getName
(),
process
.
getMaximumTime
());
List
<
Resource
>
usedResource
=
new
ArrayList
<
Resource
>();
final
List
<
Resource
>
usedResource
=
new
ArrayList
<
Resource
>();
usedResourceMap
.
put
(
simProcess
.
getName
(),
usedResource
);
usedResourceMap
.
put
(
simProcess
.
getName
(),
usedResource
);
List
<
Element
>
elements
=
new
ArrayList
<
Element
>();
final
List
<
Element
>
elements
=
new
ArrayList
<
Element
>();
List
<
EClass
>
types
=
new
ArrayList
<
EClass
>();
final
List
<
EClass
>
types
=
new
ArrayList
<
EClass
>();
types
.
clear
();
types
.
clear
();
elements
.
clear
();
elements
.
clear
();
...
@@ -118,17 +118,17 @@ public class SimulationExporter {
...
@@ -118,17 +118,17 @@ public class SimulationExporter {
if
(
elements
.
size
()
!=
1
)
{
if
(
elements
.
size
()
!=
1
)
{
throw
new
SimulationException
(
Messages
.
simulation_Error_startEvent
);
throw
new
SimulationException
(
Messages
.
simulation_Error_startEvent
);
}
}
List
<
FlowElement
>
flowElements
=
new
ArrayList
<
FlowElement
>();
final
List
<
FlowElement
>
flowElements
=
new
ArrayList
<
FlowElement
>();
for
(
Element
elem
:
elements
){
for
(
final
Element
elem
:
elements
){
flowElements
.
add
((
FlowElement
)
elem
);
flowElements
.
add
((
FlowElement
)
elem
);
}
}
Map
<
SimulationActivity
,
SimActivity
>
processElems
=
new
HashMap
<
SimulationActivity
,
SimActivity
>();
final
Map
<
SimulationActivity
,
SimActivity
>
processElems
=
new
HashMap
<
SimulationActivity
,
SimActivity
>();
List
<
SimTransition
>
processTransitions
=
new
ArrayList
<
SimTransition
>();
final
List
<
SimTransition
>
processTransitions
=
new
ArrayList
<
SimTransition
>();
HashSet
<
SimActivity
>
startElems
=
new
HashSet
<
SimActivity
>()
;
final
HashSet
<
SimActivity
>
startElems
=
new
HashSet
<
SimActivity
>()
;
simulationActivities
=
new
HashMap
<
String
,
SimActivity
>();
simulationActivities
=
new
HashMap
<
String
,
SimActivity
>();
buildProcess
(
flowElements
,
null
,
processElems
,
processTransitions
,
true
,
simProcess
.
getName
(),
startElems
);
buildProcess
(
flowElements
,
null
,
processElems
,
processTransitions
,
true
,
simProcess
.
getName
(),
startElems
);
for
(
SimActivity
start
:
startElems
){
for
(
final
SimActivity
start
:
startElems
){
simProcess
.
addStartElement
(
start
);
simProcess
.
addStartElement
(
start
);
}
}
createData
(
simProcess
,
process
);
createData
(
simProcess
,
process
);
...
@@ -139,8 +139,8 @@ public class SimulationExporter {
...
@@ -139,8 +139,8 @@ public class SimulationExporter {
* @param simProcess
* @param simProcess
* @param process
* @param process
*/
*/
private
void
createData
(
SimProcess
simProcess
,
AbstractProcess
process
)
{
private
void
createData
(
final
SimProcess
simProcess
,
final
AbstractProcess
process
)
{
for
(
SimulationData
data
:
process
.
getSimulationData
())
{
for
(
final
SimulationData
data
:
process
.
getSimulationData
())
{
simProcess
.
addData
(
getData
(
data
));
simProcess
.
addData
(
getData
(
data
));
}
}
}
}
...
@@ -149,12 +149,12 @@ public class SimulationExporter {
...
@@ -149,12 +149,12 @@ public class SimulationExporter {
* @param data
* @param data
* @return
* @return
*/
*/
public
SimData
getData
(
SimulationData
data
)
{
public
SimData
getData
(
final
SimulationData
data
)
{
if
(
data
instanceof
SimulationBoolean
)
{
if
(
data
instanceof
SimulationBoolean
)
{
if
(
data
.
isExpressionBased
())
{
if
(
data
.
isExpressionBased
())
{
return
new
SimBooleanData
(
data
.
getName
(),
data
.
getExpression
()
==
null
?
""
:
data
.
getExpression
().
getContent
());
return
new
SimBooleanData
(
data
.
getName
(),
data
.
getExpression
()
==
null
?
""
:
data
.
getExpression
().
getContent
());
}
else
{
}
else
{
SimulationBoolean
booleanData
=
(
SimulationBoolean
)
data
;
final
SimulationBoolean
booleanData
=
(
SimulationBoolean
)
data
;
return
new
SimBooleanData
(
booleanData
.
getName
(),
booleanData
.
getProbabilityOfTrue
());
return
new
SimBooleanData
(
booleanData
.
getName
(),
booleanData
.
getProbabilityOfTrue
());
}
}
}
else
if
(
data
instanceof
SimulationLiteralData
)
{
}
else
if
(
data
instanceof
SimulationLiteralData
)
{
...
@@ -162,9 +162,9 @@ public class SimulationExporter {
...
@@ -162,9 +162,9 @@ public class SimulationExporter {
// TODO expression for literals
// TODO expression for literals
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
else
{
}
else
{
SimulationLiteralData
literalData
=
(
SimulationLiteralData
)
data
;
final
SimulationLiteralData
literalData
=
(
SimulationLiteralData
)
data
;
List
<
SimLiteral
>
literals
=
new
ArrayList
<
SimLiteral
>();
final
List
<
SimLiteral
>
literals
=
new
ArrayList
<
SimLiteral
>();
for
(
SimulationLiteral
literal
:
literalData
.
getLiterals
())
{
for
(
final
SimulationLiteral
literal
:
literalData
.
getLiterals
())
{
literals
.
add
(
new
SimLiteral
(
literal
.
getValue
(),
literal
.
getProbability
()));
literals
.
add
(
new
SimLiteral
(
literal
.
getValue
(),
literal
.
getProbability
()));
}
}
return
new
SimLiteralsData
(
literalData
.
getName
(),
literals
);
return
new
SimLiteralsData
(
literalData
.
getName
(),
literals
);
...
@@ -174,9 +174,9 @@ public class SimulationExporter {
...
@@ -174,9 +174,9 @@ public class SimulationExporter {
if
(
data
.
isExpressionBased
())
{
if
(
data
.
isExpressionBased
())
{
return
new
SimNumberData
(
data
.
getName
(),
data
.
getExpression
()
==
null
?
""
:
data
.
getExpression
().
getContent
());
return
new
SimNumberData
(
data
.
getName
(),
data
.
getExpression
()
==
null
?
""
:
data
.
getExpression
().
getContent
());
}
else
{
}
else
{
SimulationNumberData
numberData
=
(
SimulationNumberData
)
data
;
final
SimulationNumberData
numberData
=
(
SimulationNumberData
)
data
;
List
<
NumericRange
>
ranges
=
new
ArrayList
<
NumericRange
>();
final
List
<
NumericRange
>
ranges
=
new
ArrayList
<
NumericRange
>();
for
(
SimulationNumberRange
numericRange
:
numberData
.
getRanges
())
{
for
(
final
SimulationNumberRange
numericRange
:
numberData
.
getRanges
())
{
ranges
.
add
(
new
NumericRange
(
numericRange
.
getMin
(),
numericRange
.
getMax
(),
numericRange
.
getProbability
(),
RepartitionType
.
CONSTANT
));
ranges
.
add
(
new
NumericRange
(
numericRange
.
getMin
(),
numericRange
.
getMax
(),
numericRange
.
getProbability
(),
RepartitionType
.
CONSTANT
));
}
}
return
new
SimNumberData
(
numberData
.
getName
(),
ranges
);
return
new
SimNumberData
(
numberData
.
getName
(),
ranges
);
...
@@ -186,10 +186,10 @@ public class SimulationExporter {
...
@@ -186,10 +186,10 @@ public class SimulationExporter {
}
}
}
}
public
void
buildProcess
(
List
<
FlowElement
>
elems
,
SimActivity
simActivity
,
Map
<
SimulationActivity
,
SimActivity
>
processElems
,
List
<
SimTransition
>
processTransitions
,
public
void
buildProcess
(
final
List
<
FlowElement
>
elems
,
final
SimActivity
simActivity
,
final
Map
<
SimulationActivity
,
SimActivity
>
processElems
,
final
List
<
SimTransition
>
processTransitions
,
boolean
isStartElement
,
String
parentProcessName
,
Set
<
SimActivity
>
startElems
)
throws
Exception
{
final
boolean
isStartElement
,
final
String
parentProcessName
,
final
Set
<
SimActivity
>
startElems
)
throws
Exception
{
for
(
FlowElement
startElem
:
elems
){
for
(
final
FlowElement
startElem
:
elems
){
SimActivity
simElem
=
null
;
SimActivity
simElem
=
null
;
if
(
simActivity
==
null
){
if
(
simActivity
==
null
){
simElem
=
getSimActivity
(
startElem
,
processElems
,
isStartElement
,
parentProcessName
);
simElem
=
getSimActivity
(
startElem
,
processElems
,
isStartElement
,
parentProcessName
);
...
@@ -198,8 +198,8 @@ public class SimulationExporter {
...
@@ -198,8 +198,8 @@ public class SimulationExporter {
}
}
EList
<
Connection
>
outgoingConnection
=
startElem
.
getOutgoing
();
final
EList
<
Connection
>
outgoingConnection
=
startElem
.
getOutgoing
();
for
(
Connection
c
:
outgoingConnection
)
{
for
(
final
Connection
c
:
outgoingConnection
)
{
if
(
c
instanceof
SequenceFlow
)
{
if
(
c
instanceof
SequenceFlow
)
{
String
transitionName
;
String
transitionName
;
if
(
c
.
getName
()
==
null
||
c
.
getName
().
trim
().
length
()
==
0
)
{
if
(
c
.
getName
()
==
null
||
c
.
getName
().
trim
().
length
()
==
0
)
{
...
@@ -238,7 +238,7 @@ public class SimulationExporter {
...
@@ -238,7 +238,7 @@ public class SimulationExporter {
final
ThrowLinkEvent
throwLink
=
(
ThrowLinkEvent
)
c
.
getTarget
()
;
final
ThrowLinkEvent
throwLink
=
(
ThrowLinkEvent
)
c
.
getTarget
()
;
if
(
throwLink
.
getTo
()
!=
null
){
if
(
throwLink
.
getTo
()
!=
null
){
final
CatchLinkEvent
target
=
throwLink
.
getTo
()
;
final
CatchLinkEvent
target
=
throwLink
.
getTo
()
;
for
(
Connection
conn
:
target
.
getOutgoing
()){
for
(
final
Connection
conn
:
target
.
getOutgoing
()){
if
(
conn
.
getName
()
==
null
||
conn
.
getName
().
trim
().
length
()
==
0
)
{
if
(
conn
.
getName
()
==
null
||
conn
.
getName
().
trim
().
length
()
==
0
)
{
transitionName
=
c
.
getSource
().
getName
()
+
"_"
+
conn
.
getTarget
().
getName
();
//$NON-NLS-1$
transitionName
=
c
.
getSource
().
getName
()
+
"_"
+
conn
.
getTarget
().
getName
();
//$NON-NLS-1$
}
else
{
}
else
{
...
@@ -275,7 +275,7 @@ public class SimulationExporter {
...
@@ -275,7 +275,7 @@ public class SimulationExporter {
}
}
private
String
toSimpleString
(
Expression
expression
)
throws
Exception
{
private
String
toSimpleString
(
final
Expression
expression
)
throws
Exception
{
if
(
expression
==
null
){
if
(
expression
==
null
){
return
""
;
return
""
;
}
else
{
}
else
{
...
@@ -291,14 +291,14 @@ public class SimulationExporter {
...
@@ -291,14 +291,14 @@ public class SimulationExporter {
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
private
SimActivity
getSimActivity
(
FlowElement
activity
,
Map
<
SimulationActivity
,
SimActivity
>
processElems
,
boolean
isStartElement
,
String
parentProcessName
)
throws
Exception
{
private
SimActivity
getSimActivity
(
final
FlowElement
activity
,
final
Map
<
SimulationActivity
,
SimActivity
>
processElems
,
final
boolean
isStartElement
,
final
String
parentProcessName
)
throws
Exception
{
SimActivity
simElem
;
SimActivity
simElem
;
if
(
processElems
.
containsKey
(
activity
))
{
if
(
processElems
.
containsKey
(
activity
))
{
simElem
=
processElems
.
get
(
activity
);
simElem
=
processElems
.
get
(
activity
);
}
else
{
}
else
{
long
estimatedTime
=
Math
.
round
(
activity
.
getExecutionTime
()
+
activity
.
getEstimatedTime
()
*
activity
.
getExecutionTime
());
final
long
estimatedTime
=
Math
.
round
(
activity
.
getExecutionTime
()
+
activity
.
getEstimatedTime
()
*
activity
.
getExecutionTime
());
long
maximumTime
=
Math
.
round
(
activity
.
getExecutionTime
()
+
activity
.
getMaximumTime
()
*
activity
.
getExecutionTime
());
final
long
maximumTime
=
Math
.
round
(
activity
.
getExecutionTime
()
+
activity
.
getMaximumTime
()
*
activity
.
getExecutionTime
());
if
(
activity
instanceof
ANDGateway
)
{
if
(
activity
instanceof
ANDGateway
)
{
simElem
=
new
SimActivity
(
activity
.
getName
(),
JoinType
.
AND
,
parentProcessName
,
activity
.
getExecutionTime
(),
estimatedTime
,
maximumTime
,
simElem
=
new
SimActivity
(
activity
.
getName
(),
JoinType
.
AND
,
parentProcessName
,
activity
.
getExecutionTime
(),
estimatedTime
,
maximumTime
,
...
@@ -322,8 +322,8 @@ public class SimulationExporter {
...
@@ -322,8 +322,8 @@ public class SimulationExporter {
* @param activity
* @param activity
* @throws Exception
* @throws Exception
*/
*/
private
void
addDataChanges
(
SimActivity
simElem
,
FlowElement
activity
)
throws
Exception
{
private
void
addDataChanges
(
final
SimActivity
simElem
,
final
FlowElement
activity
)
throws
Exception
{
for
(
DataChange
dataChange
:
activity
.
getDataChange
())
{
for
(
final
DataChange
dataChange
:
activity
.
getDataChange
())
{
if
(
dataChange
.
getData
()
!=
null
&&
dataChange
.
getValue
()
!=
null
)
{
if
(
dataChange
.
getData
()
!=
null
&&
dataChange
.
getValue
()
!=
null
)
{
if
(
dataChange
.
getData
()
instanceof
SimulationBoolean
)
{
if
(
dataChange
.
getData
()
instanceof
SimulationBoolean
)
{
simElem
.
addData
(
new
SimBooleanData
(
dataChange
.
getData
().
getName
(),
toSimpleString
(
dataChange
.
getValue
())));
simElem
.
addData
(
new
SimBooleanData
(
dataChange
.
getData
().
getName
(),
toSimpleString
(
dataChange
.
getValue
())));
...
@@ -340,8 +340,8 @@ public class SimulationExporter {
...
@@ -340,8 +340,8 @@ public class SimulationExporter {
* @param simElem
* @param simElem
* @param activity
* @param activity
*/
*/
private
void
addResourceAssignments
(
SimActivity
simElem
,
FlowElement
activity
)
{
private
void
addResourceAssignments
(
final
SimActivity
simElem
,
final
FlowElement
activity
)
{
for
(
ResourceUsage
resourceUsage
:
activity
.
getResourcesUsages
())
{
for
(
final
ResourceUsage
resourceUsage
:
activity
.
getResourcesUsages
())
{
ResourceAssignement
assignment
;
ResourceAssignement
assignment
;
...
@@ -353,9 +353,10 @@ public class SimulationExporter {
...
@@ -353,9 +353,10 @@ public class SimulationExporter {
.
getQuantity
());
.
getQuantity
());
}
}
simElem
.
addResourceAssignement
(
assignment
);
simElem
.
addResourceAssignement
(
assignment
);
List
<
Resource
>
list
=
usedResourceMap
.
get
(
simElem
.
getParentProcessName
());
final
List
<
Resource
>
list
=
usedResourceMap
.
get
(
simElem
.
getParentProcessName
());
if
(!
list
.
contains
(
assignment
.
getResource
()))
{
final
Resource
assignmentResource
=
assignment
.
getResource
();
list
.
add
(
assignment
.
getResource
());
if
(!
list
.
contains
(
assignmentResource
))
{
list
.
add
(
assignmentResource
);
}
}
}
}
}
}
...
@@ -364,11 +365,11 @@ public class SimulationExporter {
...
@@ -364,11 +365,11 @@ public class SimulationExporter {
* @param modelResource
* @param modelResource
* @return
* @return
*/
*/
private
Resource
getResource
(
String
resourceID
)
{
private
Resource
getResource
(
final
String
resourceID
)
{
final
SimulationResourceRepositoryStore
store
=
(
SimulationResourceRepositoryStore
)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
SimulationResourceRepositoryStore
.
class
)
;
final
SimulationResourceRepositoryStore
store
=
RepositoryManager
.
getInstance
().
getRepositoryStore
(
SimulationResourceRepositoryStore
.
class
)
;
final
IRepositoryFileStore
file
=
store
.
getChild
(
resourceID
+
"."
+
SimulationResourceRepositoryStore
.
SIMULATION_RESOURCE_EXT
);
final
IRepositoryFileStore
file
=
store
.
getChild
(
resourceID
+
"."
+
SimulationResourceRepositoryStore
.
SIMULATION_RESOURCE_EXT
);
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
org
.
bonitasoft
.
studio
.
model
.
simulation
.
Resource
modelResource
=
(
org
.
bonitasoft
.
studio
.
model
.
simulation
.
Resource
)
file
.
getContent
();
final
org
.
bonitasoft
.
studio
.
model
.
simulation
.
Resource
modelResource
=
(
org
.
bonitasoft
.
studio
.
model
.
simulation
.
Resource
)
file
.
getContent
();
Resource
resource
;
Resource
resource
;
if
(
resourcesMap
.
containsKey
(
modelResource
))
{
if
(
resourcesMap
.
containsKey
(
modelResource
))
{
resource
=
resourcesMap
.
get
(
modelResource
);
resource
=
resourcesMap
.
get
(
modelResource
);
...
@@ -418,27 +419,27 @@ public class SimulationExporter {
...
@@ -418,27 +419,27 @@ public class SimulationExporter {
* @param calendar
* @param calendar
* @return
* @return
*/
*/
private
SimCalendar
createSimCalendar
(
SimulationCalendar
calendar
)
{
private
SimCalendar
createSimCalendar
(
final
SimulationCalendar
calendar
)
{
SimCalendar
cal
=
new
SimCalendar
();
final
SimCalendar
cal
=
new
SimCalendar
();
if
(
calendar
!=
null
)
{
if
(
calendar
!=
null
)
{
Map
<
Integer
,
Set
<
SimCalendarPeriod
>>
map
=
new
HashMap
<
Integer
,
Set
<
SimCalendarPeriod
>>();
final
Map
<
Integer
,
Set
<
SimCalendarPeriod
>>
map
=
new
HashMap
<
Integer
,
Set
<
SimCalendarPeriod
>>();
for
(
int
i
=
Calendar
.
getInstance
().
getActualMinimum
(
Calendar
.
DAY_OF_WEEK
);
i
<=
Calendar
.
getInstance
().
getActualMaximum
(
Calendar
.
DAY_OF_WEEK
);
i
++)
{
for
(
int
i
=
Calendar
.
getInstance
().
getActualMinimum
(
Calendar
.
DAY_OF_WEEK
);
i
<=
Calendar
.
getInstance
().
getActualMaximum
(
Calendar
.
DAY_OF_WEEK
);
i
++)
{
map
.
put
(
i
,
new
HashSet
<
SimCalendarPeriod
>());
map
.
put
(
i
,
new
HashSet
<
SimCalendarPeriod
>());
}
}
for
(
DayPeriod
dayPeriod
:
calendar
.
getDaysOfWeek
())
{
for
(
final
DayPeriod
dayPeriod
:
calendar
.
getDaysOfWeek
())
{
for
(
Integer
dayNumber
:
dayPeriod
.
getDay
())
{
for
(
final
Integer
dayNumber
:
dayPeriod
.
getDay
())
{
map
.
get
(
dayNumber
).
add
(
map
.
get
(
dayNumber
).
add
(
new
SimCalendarPeriod
(
new
SimCalendarTime
(
dayPeriod
.
getStartHour
(),
dayPeriod
.
getStartMinute
()),
new
SimCalendarTime
(
dayPeriod
new
SimCalendarPeriod
(
new
SimCalendarTime
(
dayPeriod
.
getStartHour
(),
dayPeriod
.
getStartMinute
()),
new
SimCalendarTime
(
dayPeriod
.
getEndHour
(),
dayPeriod
.
getEndMinute
())));
.
getEndHour
(),
dayPeriod
.
getEndMinute
())));
}
}
}
}
for
(
Entry
<
Integer
,
Set
<
SimCalendarPeriod
>>
entry
:
map
.
entrySet
())
{
for
(
final
Entry
<
Integer
,
Set
<
SimCalendarPeriod
>>
entry
:
map
.
entrySet
())
{
try
{
try
{
cal
.
addSimCalendarDay
(
entry
.
getKey
(),
entry
.
getValue
());
cal
.
addSimCalendarDay
(
entry
.
getKey
(),
entry
.
getValue
());
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
BonitaStudioLog
.
error
(
e
);
BonitaStudioLog
.
error
(
e
);
}
}
}
}
...
@@ -450,8 +451,8 @@ public class SimulationExporter {
...
@@ -450,8 +451,8 @@ public class SimulationExporter {
* @param profile
* @param profile
* @return
* @return
*/
*/
public
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
createLoadProfile
(
LoadProfile
profile
)
{
public
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
createLoadProfile
(
final
LoadProfile
profile
)
{
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
loadProfile
=
new
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
(
final
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
loadProfile
=
new
org
.
bonitasoft
.
simulation
.
model
.
loadprofile
.
LoadProfile
(
createSimCalendar
(
profile
.
getCalendar
()),
createInjectionPeriods
(
profile
.
getInjectionPeriods
()));
createSimCalendar
(
profile
.
getCalendar
()),
createInjectionPeriods
(
profile
.
getInjectionPeriods
()));
return
loadProfile
;
return
loadProfile
;
}
}
...
@@ -460,9 +461,9 @@ public class SimulationExporter {
...
@@ -460,9 +461,9 @@ public class SimulationExporter {
* @param injectionPeriods
* @param injectionPeriods
* @return
* @return
*/
*/
private
List
<
InjectionPeriod
>
createInjectionPeriods
(
EList
<
org
.
bonitasoft
.
studio
.
model
.
simulation
.
InjectionPeriod
>
injectionPeriods
)
{
private
List
<
InjectionPeriod
>
createInjectionPeriods
(
final
EList
<
org
.
bonitasoft
.
studio
.
model
.
simulation
.
InjectionPeriod
>
injectionPeriods
)
{
List
<
InjectionPeriod
>
result
=
new
ArrayList
<
InjectionPeriod
>();
final
List
<
InjectionPeriod
>
result
=
new
ArrayList
<
InjectionPeriod
>();
for
(
org
.
bonitasoft
.
studio
.
model
.
simulation
.
InjectionPeriod
injectionPeriod
:
injectionPeriods
)
{
for
(
final
org
.
bonitasoft
.
studio
.
model
.
simulation
.
InjectionPeriod
injectionPeriod
:
injectionPeriods
)
{
RepartitionType
type
;
RepartitionType
type
;
if
(
injectionPeriod
.
getRepartition
().
equals
(
org
.
bonitasoft
.
studio
.
model
.
simulation
.
RepartitionType
.
CONSTANT
))
{
if
(
injectionPeriod
.
getRepartition
().
equals
(
org
.
bonitasoft
.
studio
.
model
.
simulation
.
RepartitionType
.
CONSTANT
))
{
type
=
RepartitionType
.
CONSTANT
;
type
=
RepartitionType
.
CONSTANT
;
...
@@ -477,7 +478,7 @@ public class SimulationExporter {
...
@@ -477,7 +478,7 @@ public class SimulationExporter {
/**
/**
* @return the resourcesMap
* @return the resourcesMap
*/
*/
public
List
<
Resource
>
getSimProcessResources
(
String
simProcessName
)
{
public
List
<
Resource
>
getSimProcessResources
(
final
String
simProcessName
)
{
return
usedResourceMap
.
get
(
simProcessName
);
return
usedResourceMap
.
get
(
simProcessName
);
}
}
...
...
Write
Preview
Supports
Markdown
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