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);
 }
Example #3
0
    // 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();
Example #4
0
    curl_setopt($ch, CURLOPT_POSTFIELDS, $encoder->encode($requestData));
    curl_setopt($ch, CURLOPT_VERBOSE, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    $response = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
    $ok = $info['http_code'] === 200 && strpos($response, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $response);
    if (++$numRequests < MAX_ETREE_REQUESTS && !$ok) {
        sleep(REQUEST_DELAY);
        goto sendRequest;
    }
    if (FB_ENABLED && $debug) {
        // log into console
        FB::info(['num requests' => $numRequests, 'curl request' => $requestData, 'curl response' => $response, 'curl info' => $info]);
    }
    if ($ok) {
        // save LM result
        $LM_export_path = './temp/etree_result_' . date('md_His') . '.pmml';
        file_put_contents($LM_export_path, $response);
        $DP = new DataParser($DDPath, unserialize(FLPath), FGCPath, null, $response, $lang);
        $DP->loadData();
        $DP->parseData();
        $responseContent = ['recommendation' => $DP->getRecommendedAttributes(), 'status' => 'ok'];
    } else {
        $responseContent = ['status' => 'error'];
    }
}
sendResponse:
$response = new Response(json_encode($responseContent), 200, array('content-type' => 'application/json; charset=UTF-8'));
$response->send();