public function testParseFGC() { $DP = new DataParser(DD, FL, FGC, null, null, $this->lang); $DP->loadData(); $data = $DP->parseData(); $this->assertTrue(isset($data['FGC'])); }
/** * Akce vracející data description a konfiguraci pro EasyMiner UI * @param int $id_dm * @param int $miner * @throws ForbiddenRequestException */ public function actionGetData($id_dm, $miner) { if (empty($miner)) { $miner = $id_dm; } //------------------------------------------------------------------------------------------------------------------ $miner = $this->findMinerWithCheckAccess($miner); $minerType = $miner->type; $FLPathElement = 'FLPath_' . Strings::upper($minerType); //------------------------------------------------------------------------------------------------------------------ #region připravení informací pro UI - s odděleným připravením DataDictionary $dataDescriptionPMML = null; $dataParser = new DataParser($dataDescriptionPMML, $this->config->{$FLPathElement}, $this->config->FGCPath, null, null, $this->translator->getLang()); $dataParser->loadData(); $responseContent = $dataParser->parseData(); $user = $this->getCurrentUser(); $responseContent['DD'] = ['dataDictionary' => $this->datasourcesFacade->exportDataDictionaryArr($miner->datasource, $user, $rowsCount), 'transformationDictionary' => $this->metasourcesFacade->exportTransformationDictionaryArr($miner->metasource, $user), 'recordCount' => $rowsCount]; #endregion připravení informací pro UI - s odděleným připravením DataDictionary uksort($responseContent['DD']['transformationDictionary'], function ($a, $b) { return strnatcasecmp($a, $b); }); uksort($responseContent['DD']['dataDictionary'], function ($a, $b) { return strnatcasecmp($a, $b); //return strnatcasecmp(mb_strtolower($a,'utf-8'),mb_strtolower($b,'utf-8')); }); $responseContent['status'] = 'ok'; $responseContent['miner_type'] = $miner->type; $responseContent['miner_name'] = $miner->name; if ($miner->ruleSet) { $ruleSet = $miner->ruleSet; } else { $ruleSet = $this->ruleSetsFacade->saveNewRuleSetForUser($miner->name, $this->getCurrentUser()); $miner->ruleSet = $ruleSet; $this->minersFacade->saveMiner($miner); } $responseContent['miner_ruleset'] = ['id' => $ruleSet->ruleSetId, 'name' => $ruleSet->name]; $responseContent['miner_config'] = $miner->getExternalConfig(); $this->sendJsonResponse($responseContent); }
// KBI $requestData = []; $numRequests = 0; $encoder = new URLEncoder(); // run export sendRequest: $config = array('source' => intval($id), 'query' => '', 'xslt' => NULL, 'parameters' => NULL); $model = new KbiModelTransformator($config); $document = $model->getDataDescription(); $ok = strpos($document, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $document); if (++$numRequests < MAX_INITIALIZATION_REQUESTS && !$ok) { sleep(REQUEST_DELAY); goto sendRequest; } if (FB_ENABLED && $debug) { // log into console FB::info(['num requests' => $numRequests, 'document' => $document]); } if ($ok) { $DDPath = APP_PATH . '/web/temp/DD_' . $id . '.pmml'; file_put_contents($DDPath, $document); $DP = new DataParser($DDPath, unserialize(FLPath), FGCPath, null, null, $lang); $DP->loadData(); $responseContent = $DP->parseData(); $responseContent['status'] = 'ok'; } else { $responseContent = ['status' => 'error']; } } $response = new Response(json_encode($responseContent), 200, array('content-type' => 'application/json; charset=UTF-8')); $response->send();
sendRequest: $config = array('source' => intval($id), 'query' => $requestData['query'], 'xslt' => NULL, 'parameters' => NULL); $model = new KbiModelTransformator($config); $document = $model->transform(); $ok = strpos($document, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $document); if (++$numRequests < MAX_MINING_REQUESTS && !$ok) { sleep(REQUEST_DELAY); goto sendRequest; } if (FB_ENABLED && $debug) { // log into console FB::info(['num requests' => $numRequests, 'request' => $requestData, 'response' => $document]); } if ($ok) { // save LM result $resultPath = 'temp/4ft_result_' . date('md_His') . '.pmml'; file_put_contents($resultPath, $document); $DP = new DataParser($DDPath, unserialize(FLPath), FGCPath, $document, null, $lang); $DP->loadData(); $DP->parseData(); $responseContent = $DP->getER(); $responseContent['task'] = $taskPath; $responseContent['result'] = $resultPath; $responseContent['status'] = 'ok'; } else { $responseContent = ['status' => 'error', 'response' => $document]; } } sendResponse: $response = new Response(json_encode($responseContent), 200, array('content-type' => 'application/json; charset=UTF-8')); $response->send();