Commit a2148dd6 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Fixed bug 'getValue'

parent 4cc1deb3
...@@ -62,9 +62,8 @@ public class PlannerController { ...@@ -62,9 +62,8 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) { String plan(@PathVariable("tosca_id") String toscaId) {
try { try {
// ToscaRepresentation plan = simplePlannerService.getPlan(toscaId); ToscaRepresentation plan = simplePlannerService.getPlan(toscaId);
// return plan.getId(); // ToscaRepresentation plan = plannerService.getPlan(toscaId);
ToscaRepresentation plan = plannerService.getPlan(toscaId);
if (plan == null) { if (plan == null) {
throw new NotFoundException("Could not make plan"); throw new NotFoundException("Could not make plan");
} }
......
...@@ -132,7 +132,7 @@ public abstract class DRIPCaller implements AutoCloseable { ...@@ -132,7 +132,7 @@ public abstract class DRIPCaller implements AutoCloseable {
Parameter parameter = new Parameter(); Parameter parameter = new Parameter();
parameter.setName(jsonParam.getString("name")); parameter.setName(jsonParam.getString("name"));
parameter.setName(jsonParam.getString("value")); parameter.setValue(jsonParam.getString("value"));
parameters.add(parameter); parameters.add(parameter);
} }
......
...@@ -26,6 +26,7 @@ import java.util.List; ...@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeoutException; 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.api.rpc.PlannerCaller;
import nl.uva.sne.drip.commons.types.Message; import nl.uva.sne.drip.commons.types.Message;
import nl.uva.sne.drip.commons.types.Parameter; import nl.uva.sne.drip.commons.types.Parameter;
...@@ -51,11 +52,11 @@ public class SimplePlannerService { ...@@ -51,11 +52,11 @@ public class SimplePlannerService {
public ToscaRepresentation getPlan(String toscaId) throws JSONException, IOException, TimeoutException, InterruptedException { public ToscaRepresentation getPlan(String toscaId) throws JSONException, IOException, TimeoutException, InterruptedException {
Message plannerInvokationMessage = buildSimplePlannerMessage(toscaId); Message plannerInvokationMessage = buildSimplePlannerMessage(toscaId);
PlannerCaller planner = new PlannerCaller(messageBrokerHost); ToscaRepresentation topLevel;
try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) {
Message plannerReturnedMessage = planner.call(plannerInvokationMessage); Message plannerReturnedMessage = planner.call(plannerInvokationMessage);
List<Parameter> toscaFiles = plannerReturnedMessage.getParameters(); List<Parameter> toscaFiles = plannerReturnedMessage.getParameters();
ToscaRepresentation topLevel = new ToscaRepresentation(); topLevel = new ToscaRepresentation();
ToscaRepresentation tr = null; ToscaRepresentation tr = null;
for (Parameter p : toscaFiles) { for (Parameter p : toscaFiles) {
//Should have levels in attributes //Should have levels in attributes
...@@ -80,15 +81,17 @@ public class SimplePlannerService { ...@@ -80,15 +81,17 @@ public class SimplePlannerService {
} }
ids.add(tr.getId()); ids.add(tr.getId());
topLevel.setLowerLevelIDs(ids); topLevel.setLowerLevelIDs(ids);
} } topLevel.setType(ToscaRepresentation.Type.PLAN);
topLevel.setType(ToscaRepresentation.Type.PLAN);
toscaService.getDao().save(topLevel); toscaService.getDao().save(topLevel);
planner.close(); }
return topLevel; return topLevel;
} }
private Message buildSimplePlannerMessage(String toscaId) throws JSONException, UnsupportedEncodingException, IOException { private Message buildSimplePlannerMessage(String toscaId) throws JSONException, UnsupportedEncodingException, IOException {
ToscaRepresentation t2 = toscaService.getDao().findOne(toscaId); ToscaRepresentation t2 = toscaService.getDao().findOne(toscaId);
if (t2 == null) {
throw new NotFoundException();
}
Map<String, Object> map = t2.getKvMap(); Map<String, Object> map = t2.getKvMap();
String ymlStr = Converter.map2YmlString(map); String ymlStr = Converter.map2YmlString(map);
ymlStr = ymlStr.replaceAll("\\uff0E", "\\."); ymlStr = ymlStr.replaceAll("\\uff0E", "\\.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment