Commit 6852e8ef authored by Ahmed Zarioh's avatar Ahmed Zarioh

centralize parseResult

parent 0dfde9f7
......@@ -69,9 +69,12 @@ class RestService
{
$apiObjects[$value2] = [];
$temp = static::getSimpleAll($value2);
foreach ($temp as $k => $val)
if(isset($temp))
{
$apiObjects[$value2][$val->id] = $val;
foreach ($temp as $k => $val)
{
$apiObjects[$value2][$val->id] = $val;
}
}
}
}
......@@ -131,39 +134,42 @@ class RestService
public static function getAll($apiname)
{
$result = static::getSimpleAll($apiname);
$apiObjects = static::getCurrentObjectOptions();
$fkList = static::getFKList($GLOBALS['currentobject']["form"]);
foreach ($result as $key1 => $value1)
{
foreach ($fkList as $key2 => $value2)
if(count($result))
{
$apiObjects = static::getCurrentObjectOptions();
$fkList = static::getFKList($GLOBALS['currentobject']["form"]);
foreach ($result as $key1 => $value1)
{
if(isset($value1->$key2) &&
!(isset($GLOBALS['config']['apisObjects'][$apiname]["form"][$key2]["isArray"]) &&
$GLOBALS['config']['apisObjects'][$apiname]["form"][$key2]["isArray"]==true))
foreach ($fkList as $key2 => $value2)
{
if(is_array($value2))
if(isset($value1->$key2) &&
!(isset($GLOBALS['config']['apisObjects'][$apiname]["form"][$key2]["isArray"]) &&
$GLOBALS['config']['apisObjects'][$apiname]["form"][$key2]["isArray"]==true))
{
$cont = true;
if(is_array($value2))
{
$cont = true;
foreach ($value2 as $key3 => $value3)
{
if($cont && isset($apiObjects[$value3][$value1->$key2]))
foreach ($value2 as $key3 => $value3)
{
$current = $apiObjects[$value3][$value1->$key2];
$result[$key1]->$key2 = Tools::convertToField($current,$value3);
$cont = false;
if($cont && isset($apiObjects[$value3][$value1->$key2]))
{
$current = $apiObjects[$value3][$value1->$key2];
$result[$key1]->$key2 = Tools::convertToField($current,$value3);
$cont = false;
}
}
}
}
else
{
$current = $apiObjects[$value2][$value1->$key2];
$result[$key1]->$key2 = Tools::convertToField($current,$value2);
else
{
$current = $apiObjects[$value2][$value1->$key2];
$result[$key1]->$key2 = Tools::convertToField($current,$value2);
}
}
}
}
}
}
return static::parseResults($result);
}
......
......@@ -75,27 +75,27 @@ class ApplicationService extends ColosseumService
{
$url ="/$apiname/$val";
//GET APPLICATION BY ID
$result = static::parseResult(static::getResponse($url,'GET', ''));
$result = parent::getSimpleOne($apiname,$val);
//GET ApplicationComponent BY application id
$applicationComponents = static::parseResults(static::getResponse("/ac",'GET', ''));
$applicationComponents = parent::getSimpleAll("applicationComponent");
$result->applicationComponents = [];
$result->applicationComponentsById = [];
foreach ($applicationComponents as $key => $value)
{
if($result->id == $value->application)
{
$component = static::parseResult(static::getResponse("/lifecycleComponent/".$value->component,'GET', ''));
$component = parent::getSimpleOne("component",$value->component);
$value->components = [$component];
$result->applicationComponentsById[$value->id] = $value;
$result->applicationComponents[] = $value;
}
}
//GET portReq BY application id
$portReqs = static::parseResults(static::getResponse("/portReq",'GET', ''));
$portReqs = parent::getSimpleAll("requiredPort");
$result->portReqs = [];
foreach ($portReqs as $key => $value)
{
if(array_key_exists ( $value->applicationComponent , $result->applicationComponentsById))
......@@ -106,7 +106,7 @@ class ApplicationService extends ColosseumService
}
//GET portProv BY application id
$portProvs = static::parseResults(static::getResponse("/portProv",'GET', ''));
$portProvs = parent::getSimpleAll("providedPort");
$result->portProvs = [];
foreach ($portProvs as $key => $value)
{
......@@ -118,7 +118,7 @@ class ApplicationService extends ColosseumService
}
//GET COMMUCICATION by ...
$communications = static::parseResults(static::getResponse("/communication",'GET', ''));
$communications = parent::getSimpleAll("communication");
$result->communications = [];
foreach ($communications as $key => $value)
{
......@@ -131,5 +131,4 @@ class ApplicationService extends ColosseumService
}
return static::parseResult($result);
}
}
\ No newline at end of file
......@@ -30,12 +30,12 @@ class VirtualMachineService extends ColosseumService
{
$url ="/$apiname/$val";
//GET VM BY ID
$result = static::parseResult(static::getResponse($url,'GET', '', $apiname));
$result = parent::getOne($apiname,$val);
//GET monitorInstance
$result->monitorInstances = [];
//$result->monitorInstancesById = [];
$monitorInstances = static::parseResults(static::getResponse("/monitorInstance",'GET', '', $apiname));
$monitorInstances = parent::getSimpleAll("monitorInstance");
foreach ($monitorInstances as $key => $value)
{
if($result->id == $value->virtualMachine)
......@@ -51,10 +51,10 @@ class VirtualMachineService extends ColosseumService
{
//"rawMonitor","composedMonitor","constantMonitor"
$rawMonitors = static::parseResults(static::getResponse("/rawMonitor",'GET', '', $apiname));
$composedMonitors = static::parseResults(static::getResponse("/composedMonitor",'GET', '', $apiname));
$constantMonitors = static::parseResults(static::getResponse("/constantMonitor",'GET', '', $apiname));
$sensorDescriptions = static::parseResults(static::getResponse("/sensorDescription",'GET', '', $apiname));
$rawMonitors = parent::getSimpleAll("rawMonitor");
$composedMonitors = parent::getSimpleAll("composedMonitor");
$constantMonitors = parent::getSimpleAll("constantMonitor");
$sensorDescriptions = parent::getSimpleAll("sensorDescription");
$rawMonitorsById = Tools::getKeyValueArray($rawMonitors);
$composedMonitorsById = Tools::getKeyValueArray($composedMonitors);
......
......@@ -51,8 +51,14 @@ class KairosService extends RestService
)
);
$url = isset($chartInfo->apiEndpoint)?"http://".$chartInfo->apiEndpoint:$GLOBALS['config']['apis']['kairosapi']['url'];
$url = $url.":8080/api/v1/datapoints/query";
if(isset($chartInfo->apiEndpoint))
{
$url = "http://".$chartInfo->apiEndpoint.":8080/api/v1/datapoints/query";
}
else
{
$url = $GLOBALS['config']['apis']['kairosapi']['url'];
}
$option = array(
'metrics' => [$metric],
......
......@@ -6,6 +6,12 @@
"start_relative":{"value":"1","unit":"hours"}
},
"de.uniulm.omi.cloudiator.visor.sensors.MemoryUsageSensor" :
{
"aggregator": {"name":"avg"},
"interval": {"value":"1","unit":"seconds"},
"start_relative":{"value":"1","unit":"hours"}
},
"default" :
{
"aggregator": {"name":"avg"},
"interval": {"value":"1","unit":"seconds"},
......
......@@ -6,7 +6,7 @@
},
"kairosapi" : {
"name": "kairosapi",
"url": "http://52.21.93.224",
"url": "http://52.21.93.224:8080/api/v1/datapoints/query",
"controller": "KairosController",
"router": "KairosRouter"
}
......
......@@ -24,6 +24,17 @@
crudControllers.controller('ChartsCtrl', function($scope,$interval,$http,ajaxFactory)
{
$scope.url = "kairosapi/charts";
$scope.init2 = function(id,metricName = null,apiEndpoint=null)
{
monitorInstance = {};
monitorInstance.id = id;
monitorInstance.metricName = metricName;
monitorInstance.apiEndpoint = apiEndpoint;
$scope.init(monitorInstance);
}
$scope.init = function(monitorInstance)
{
$scope.graphDetails = {};
......
......@@ -9,7 +9,7 @@
<div>
<div class="col-md-6 mgt10"
ng-repeat="(k,v) in item.monitorInstances"
ng-init="init(v)"
ng-init="init2(v.id, v.metricName, v.apiEndpoint)"
ng-include="chart.url"
ng-controller='ChartsCtrl'
id="graph-num-{{k}}">
......
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