Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
a2148dd6
Commit
a2148dd6
authored
8 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug 'getValue'
parent
4cc1deb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
36 deletions
+38
-36
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+2
-3
DRIPCaller.java
...api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
+1
-1
SimplePlannerService.java
...ava/nl/uva/sne/drip/api/service/SimplePlannerService.java
+35
-32
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/PlannerController.java
View file @
a2148dd6
...
...
@@ -62,9 +62,8 @@ public class PlannerController {
String
plan
(
@PathVariable
(
"tosca_id"
)
String
toscaId
)
{
try
{
// ToscaRepresentation plan = simplePlannerService.getPlan(toscaId);
// return plan.getId();
ToscaRepresentation
plan
=
plannerService
.
getPlan
(
toscaId
);
ToscaRepresentation
plan
=
simplePlannerService
.
getPlan
(
toscaId
);
// ToscaRepresentation plan = plannerService.getPlan(toscaId);
if
(
plan
==
null
)
{
throw
new
NotFoundException
(
"Could not make plan"
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
View file @
a2148dd6
...
...
@@ -132,7 +132,7 @@ public abstract class DRIPCaller implements AutoCloseable {
Parameter
parameter
=
new
Parameter
();
parameter
.
setName
(
jsonParam
.
getString
(
"name"
));
parameter
.
set
Nam
e
(
jsonParam
.
getString
(
"value"
));
parameter
.
set
Valu
e
(
jsonParam
.
getString
(
"value"
));
parameters
.
add
(
parameter
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/SimplePlannerService.java
View file @
a2148dd6
...
...
@@ -26,6 +26,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
...
...
@@ -51,44 +52,46 @@ public class SimplePlannerService {
public
ToscaRepresentation
getPlan
(
String
toscaId
)
throws
JSONException
,
IOException
,
TimeoutException
,
InterruptedException
{
Message
plannerInvokationMessage
=
buildSimplePlannerMessage
(
toscaId
);
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
toscaFiles
=
plannerReturnedMessage
.
getParameters
();
ToscaRepresentation
topLevel
=
new
ToscaRepresentation
();
ToscaRepresentation
tr
=
null
;
for
(
Parameter
p
:
toscaFiles
)
{
//Should have levels in attributes
Map
<
String
,
String
>
attributess
=
p
.
getAttributes
();
String
originalFileName
=
p
.
getName
();
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
if
(
originalFileName
.
equals
(
"planner_output_all.yml"
))
{
topLevel
.
setName
(
name
);
topLevel
.
setLevel
(
0
);
topLevel
.
setKvMap
(
Converter
.
ymlString2Map
(
p
.
getValue
()));
}
else
{
tr
=
new
ToscaRepresentation
();
tr
.
setName
(
name
);
tr
.
setKvMap
(
Converter
.
ymlString2Map
(
p
.
getValue
()));
tr
.
setLevel
(
1
);
}
tr
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
toscaService
.
getDao
().
save
(
tr
);
Set
<
String
>
ids
=
topLevel
.
getLowerLevelIDs
();
if
(
ids
==
null
)
{
ids
=
new
HashSet
<>();
}
ids
.
add
(
tr
.
getId
());
topLevel
.
setLowerLevelIDs
(
ids
);
ToscaRepresentation
topLevel
;
try
(
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
))
{
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
toscaFiles
=
plannerReturnedMessage
.
getParameters
();
topLevel
=
new
ToscaRepresentation
();
ToscaRepresentation
tr
=
null
;
for
(
Parameter
p
:
toscaFiles
)
{
//Should have levels in attributes
Map
<
String
,
String
>
attributess
=
p
.
getAttributes
();
String
originalFileName
=
p
.
getName
();
String
name
=
System
.
currentTimeMillis
()
+
"_"
+
originalFileName
;
if
(
originalFileName
.
equals
(
"planner_output_all.yml"
))
{
topLevel
.
setName
(
name
);
topLevel
.
setLevel
(
0
);
topLevel
.
setKvMap
(
Converter
.
ymlString2Map
(
p
.
getValue
()));
}
else
{
tr
=
new
ToscaRepresentation
();
tr
.
setName
(
name
);
tr
.
setKvMap
(
Converter
.
ymlString2Map
(
p
.
getValue
()));
tr
.
setLevel
(
1
);
}
tr
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
toscaService
.
getDao
().
save
(
tr
);
Set
<
String
>
ids
=
topLevel
.
getLowerLevelIDs
();
if
(
ids
==
null
)
{
ids
=
new
HashSet
<>();
}
ids
.
add
(
tr
.
getId
());
topLevel
.
setLowerLevelIDs
(
ids
);
}
topLevel
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
toscaService
.
getDao
().
save
(
topLevel
);
}
topLevel
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
toscaService
.
getDao
().
save
(
topLevel
);
planner
.
close
();
return
topLevel
;
}
private
Message
buildSimplePlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
{
ToscaRepresentation
t2
=
toscaService
.
getDao
().
findOne
(
toscaId
);
if
(
t2
==
null
)
{
throw
new
NotFoundException
();
}
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
ymlStr
=
ymlStr
.
replaceAll
(
"\\uff0E"
,
"\\."
);
...
...
This diff is collapsed.
Click to expand it.
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