Exemplo n.º 1
0
 function dataDescription()
 {
     $viewName = JRequest::getVar('view', 'results');
     $viewType = 'raw';
     $view =& $this->getView($viewName, $viewType);
     $config = array('source' => JRequest::getVar('source', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => JRequest::getVar('query', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'xslt' => JRequest::getVar('xslt', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'parameters' => JRequest::getVar('parameters', NULL, 'default', 'none', JREQUEST_ALLOWRAW));
     try {
         $model = new KbiModelTransformator($config);
         $view->assignRef('value', $model->getDataDescription());
     } catch (Exception $e) {
         $view->assign('value', "<p class=\"kbierror\">Chyba dotazu: {$e->getMessage()}</p>");
     }
     $view->display();
 }
Exemplo n.º 2
0
 /**
  *  Akce pro zobrazení hodnot vybraného atributu
  */
 public function previewAttribute()
 {
     //TODO
     $attributeName = JRequest::getVar('attribute', '');
     $kbiId = JRequest::getInt('kbi', '');
     try {
         require_once JPATH_COMPONENT . DS . '../com_kbi/models/transformator.php';
         $config = array('source' => JRequest::getVar('kbi', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => JRequest::getVar('query', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'xslt' => JRequest::getVar('xslt', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'parameters' => JRequest::getVar('parameters', NULL, 'default', 'none', JREQUEST_ALLOWRAW));
         $model = new KbiModelTransformator($config);
         $dataDescription = $model->getDataDescription(array('template' => 'LMDataSource.Matrix.ARD.DBConnect.Template.PMML'));
         $data = simplexml_load_string($dataDescription);
         /*máme načtený XML dokument => získáme z něj příslušnou část (hodnoty zvoleného atributu)*/
         $dictionary = null;
         if (count($data->Dictionary) > 0) {
             foreach ($data->Dictionary as $dict) {
                 if ($dict['sourceDictType'] == 'TransformationDictionary') {
                     $dictionary = $dict;
                     break;
                 }
             }
         }
         $field = null;
         if ($dictionary && count($dictionary->Field) > 0) {
             foreach ($dictionary->Field as $fie) {
                 if ((string) $fie->Name == $attributeName) {
                     $field = $fie;
                     break;
                 }
             }
         }
         //pokud máme konkrétní field, tak načteme seznam hodnot
         if ($field && count($field->Category) > 0) {
             $categoriesArr = array();
             $order = 1;
             foreach ($field->Category as $category) {
                 $categoriesArr[] = array('order' => $order, 'name' => (string) $category, 'frequency' => (int) $category['frequency']);
                 $order++;
             }
         }
         if (is_array($categoriesArr)) {
             //výběr způsobu řazení a seřazení položek
             $order = JRequest::getVar('order', 'order/asc');
             $orderArr = explode('/', $order);
             if (!in_array($orderArr[0], array('order', 'name', 'frequency'))) {
                 $orderArr[0] = 'order';
             }
             if (@$orderArr[1] != 'desc') {
                 $orderArr[1] = 'asc';
                 $order = $orderArr[0];
             } else {
                 $order = $orderArr[0] . '/desc';
             }
             usort($categoriesArr, self::buildDatadictionarySorter($orderArr[0], $orderArr[1]));
         }
     } catch (Exception $e) {
         var_dump($e);
         return;
     }
     $view =& $this->getView('IziAttributeHistogram', $this->document->getType());
     $view->assign('field', $field);
     $view->assign('kbiId', $kbiId);
     $view->assignRef('categoriesArr', $categoriesArr);
     $view->assign('order', $order);
     $view->assign('graphStyle', JRequest::getVar('graph'));
     $view->display();
 }
Exemplo n.º 3
0
    sleep($sleep);
    // simulates time required for remote request
    $DP = new DataParser(DDPath, unserialize(FLPath), FGCPath, null, null, $lang);
    $DP->loadData();
    $responseContent = $DP->parseData();
    $responseContent['status'] = 'ok';
} else {
    // 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();
Exemplo n.º 4
0
 public function brBaseAddRules()
 {
     $kbiId = JRequest::getInt('kbi', -1);
     $lmtaskId = JRequest::getVar('lmtask', '');
     $template = JRequest::getVar('template', self::RULES_XML_TEMPLATE);
     $rules = JRequest::getString('rules', JRequest::getString('rulesIds', ""));
     try {
         /** @var LispMiner $source */
         $source = $this->getKbiSource($kbiId);
         $resultRules = $source->queryPost(null, array('export' => $lmtaskId, 'template' => $template));
         #region získání atributů
         require_once JPATH_COMPONENT . DS . '../com_kbi/models/transformator.php';
         $config = array('source' => JRequest::getVar('kbi', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => JRequest::getVar('query', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'xslt' => JRequest::getVar('xslt', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'parameters' => JRequest::getVar('parameters', NULL, 'default', 'none', JREQUEST_ALLOWRAW));
         $model = new KbiModelTransformator($config);
         $resultAttributes = $model->getDataDescription(array('template' => self::ATTRIBUTES_XML_TEMPLATE));
         #endregion získání atributů
         if (!strpos($resultRules, '<AssociationRules')) {
             throw new Exception('Export failed!');
         }
         $rules = $this->decodeRules($rules);
         if (is_array($rules) && count($rules)) {
             $resultRules = $this->cleanRulesXml($resultRules, $rules);
         }
         //TODO doladit - aktuálně jen provizorní řešení...
         #regin odeslání dat do EasyMinerCenter
         $urlAttributes = self::BRBASE_URL . '/association-rules/import-data-description?baseId=http://easyminer.eu/kb/KnowledgeBase/kb' . $kbiId . '&kbi=' . $kbiId;
         $data = array('data' => $resultAttributes);
         $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
         $context = stream_context_create($options);
         $result = file_get_contents($urlAttributes, false, $context);
         $urlRules = self::BRBASE_URL . '/association-rules/import-association-rules?baseId=http://easyminer.eu/kb/KnowledgeBase/kb' . $kbiId . '&kbi=' . $kbiId;
         $data = array('data' => $resultRules);
         $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
         $context = stream_context_create($options);
         $result = file_get_contents($urlRules, false, $context);
         #endregion odeslání dat do EasyMinerCenter
         /*
         / ** @var dbconnectModelTasks $tasksModel * /
         $tasksModel=&$this->getModel('Tasks','dbconnectModel');
         $task=$tasksModel->getTaskByKbi($kbiId);
         / ** @var dbconnectModelBRBase $brbaseModel * /
         $brbaseModel=&$this->getModel('BRBase','dbconnectModel');
         $brbaseModel->addRules($resultRules,$task->id);
         */
     } catch (Exception $e) {
         var_dump($e);
         exit;
         //TODO show error
     }
 }