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
PaaSage
meta_solver
Commits
51dfe812
Commit
51dfe812
authored
Nov 30, 2015
by
Shirley Crompton
Browse files
attempt to fix null pointer exception for simple deployment
parent
c14ec070
Changes
4
Show whitespace changes
Inline
Side-by-side
src/main/java/eu/paasage/upperware/metasolver/metrics/Mapper.java
View file @
51dfe812
...
...
@@ -116,8 +116,9 @@ public class Mapper {
//to hold the metricVariableValues
// go ahead
List
<
MetricVariable
>
mvs
=
cp
.
getMetricVariables
();
log
.
debug
(
"...about to get metric variables...."
);
//
if
(
mvs
.
isEmpty
())
{
if
(
mvs
==
null
||
mvs
.
isEmpty
())
{
log
.
debug
(
"CP model in "
+
resId
+
" has no Metric Variable entities..."
);
}
else
{
...
...
@@ -139,6 +140,8 @@ public class Mapper {
solution
=
CpModelTool
.
setConstantValue
(
mv
,
solution
);
}
}
else
{
// cp generator has created the solution
log
.
debug
(
"CP model in "
+
resId
+
" already has a Solution entity..."
);
// match the metricVariables
for
(
MetricVariable
mv
:
mvs
)
{
if
(
CPModelTool
.
searchMetricValue
(
solution
,
mv
)
==
null
)
{
...
...
@@ -151,11 +154,15 @@ public class Mapper {
jObj
.
add
(
"solution_tmp"
,
solution
.
getTimestamp
());
// milp-solver needs this
}
if
(
updateCP
)
{
log
.
debug
(
"updating CP Model( "
+
resId
+
") in CDO..."
);
//get a new resource id
String
newId
=
CpModelTool
.
getCloneId
(
CpModelTool
.
getAppId
(
model_contents
),
resId
);
this
.
utils
.
overwriteCPModelinCDO
(
model_contents
,
newId
);
jObj
.
add
(
"id"
,
newId
);
}
else
{
log
.
debug
(
"no change to CP Model("
+
resId
+
") ..."
);
//we are using the same model
jObj
.
add
(
"id"
,
resId
);
}
...
...
@@ -254,6 +261,9 @@ public class Mapper {
}
//ready to save to CDO, get a new resource id
String
newId
=
CpModelTool
.
getCloneId
(
CpModelTool
.
getAppId
(
model_contents
),
resId
);
//debug
//System.out.println("I am here ... ");
//this.utils.overwriteCPModelinCDO(model_contents, newId);
this
.
utils
.
overwriteCPModelinCDO
(
model_contents
,
newId
);
jObj
.
add
(
"id"
,
newId
);
// explicitly stop the cdo client
...
...
src/main/java/eu/paasage/upperware/metasolver/util/CdoTool.java
View file @
51dfe812
...
...
@@ -183,6 +183,7 @@ public final class CdoTool {
EList
<
EObject
>
contents1
=
cdo
.
getContents
();
try
{
if
(
contents1
.
size
()
>
0
){
log
.
debug
(
" ... there are contents, will be deleting....."
);
//do this via CDO id
CDOObject
cdoObj
=
(
CDOObject
)
contents1
.
get
(
0
);
trans
.
getObject
(
cdoObj
.
cdoID
());
...
...
src/main/java/eu/paasage/upperware/metasolver/util/CpModelTool.java
View file @
51dfe812
...
...
@@ -236,6 +236,7 @@ public final class CpModelTool {
try
{
for
(
EObject
obj
:
model
)
{
if
(
obj
instanceof
eu
.
paasage
.
upperware
.
metamodel
.
cp
.
impl
.
ConstraintProblemImpl
)
{
log
.
debug
(
"found constraint problem...."
);
cpModel
=
(
ConstraintProblem
)
obj
;
break
;
}
...
...
@@ -281,10 +282,11 @@ public final class CpModelTool {
for
(
int
i
=
suffix
.
length
()-
1
;
i
>=
0
;
i
--){
char
character
=
suffix
.
charAt
(
i
);
log
.
debug
(
"suffix char at "
+
i
+
" is "
+
suffix
.
charAt
(
i
));
if
(
Character
.
isLetter
(
character
)){
if
(
Character
.
isLetter
(
character
)
||
character
==
'_'
){
//stop here
log
.
debug
(
"The numeric part of the suffix is : "
+
suffix
.
substring
(
i
+
1
));
int
version
=
Integer
.
parseInt
(
suffix
.
substring
(
i
+
1
))+
1
;
log
.
debug
(
"the version is : "
+
version
);
cloneId
=
appId
+
suffix
.
substring
(
0
,
i
+
1
)
+
version
;
log
.
debug
(
"the computed cloneId is "
+
cloneId
);
break
;
...
...
src/test/java/eu/paasage/upperware/metasolver/test/CpModelToolTest.java
View file @
51dfe812
...
...
@@ -243,4 +243,10 @@ public class CpModelToolTest {
}
assertTrue
(
"Failed to add the metric variable"
,
found
);
}
@Test
public
void
testIGetCloneId
(){
String
cloneId
=
CpModelTool
.
getCloneId
(
"upperware-models/OpenFoamApplication1447777579963"
,
"upperware-models/OpenFoamApplication1447777579963_2"
);
assertEquals
(
"Error getting cloned id, got : "
+
cloneId
,
"upperware-models/OpenFoamApplication1447777579963_3"
,
cloneId
);
}
}
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