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
 function replace($match)
 {
     if (!isset($match[1]) || empty($match[1])) {
         return;
     }
     try {
         //WYSIWYG editor zalamuje XHTML neparove znacky na \ /> aby zustal validni JSON je potreba to vratit spet na \/>
         $json = str_replace('\\ />', '\\/>', $match[1]);
         $config = json_decode($json, true);
         if ($config === NULL) {
             KBIDebug::log($match[1], 'Element not parsed as JSON');
             return $match[1];
         }
         $transfomator = new KbiModelTransformator($config);
         //var_dump($match);
         //var_dump($config);
         //var_dump($transfomator);
         return $transfomator->transform();
     } catch (Exception $ex) {
         KBIDebug::log(array($ex, $config), 'Query not succesfull');
     }
 }
Exemplo n.º 3
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.º 4
0
if ($id === 'TEST') {
    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();
Exemplo n.º 5
0
         // log into console
         FB::error(['error' => 'data description does not exist']);
     }
     $responseContent = ['status' => 'error'];
     goto sendResponse;
 }
 $serializer = new TaskSettingSerializer($DDPath);
 $requestData = array('source' => $id, 'query' => $serializer->serialize($data), 'template' => $debug ? '4ftMiner.Task.Template.PMML' : '4ftMiner.Task.ARD.Template.PMML', 'pooler' => $taskMode);
 $numRequests = 0;
 // save LM task
 $taskPath = 'temp/4ft_task_' . date('md_His') . '.pmml';
 file_put_contents($taskPath, $requestData['query']);
 // run task
 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);
Exemplo n.º 6
0
 function hits()
 {
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'hits');
     $viewType = $document->getType();
     $view =& $this->getView($viewName, $viewType);
     $data = JRequest::getVar('data', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if ($viewType == 'raw' && $data != NULL) {
         $config = array('source' => JRequest::getVar('id_source', NULL, 'default', 'none', JREQUEST_ALLOWRAW), 'query' => NULL, 'xslt' => NULL, 'parameters' => NULL);
         try {
             $com_kbi = JComponentHelper::getComponent('com_kbi', true);
             if (!$com_kbi->enabled) {
                 throw new Exception('KBI component not intalled or enabled');
             }
             JLoader::import('transformator', JPATH_COMPONENT . DS . '..' . DS . $com_kbi->option . DS . 'models');
             $model = new KbiModelTransformator($config);
             $sr = self::createSerializeRules($model->getSource());
             $model->setQuery($sr->serializeRules($data));
             $dd = null;
             $fl = null;
             $er = $model->transform();
             $sr = new GetDataARBuilderQuery($dd, $fl, $er, 'en');
             $data = $sr->getData();
             $view->assignRef('value', $data);
             KBIDebug::log($er);
         } catch (Exception $e) {
             $view->assign('value', "<p class=\"kbierror\">Chyba dotazu: {$e->getMessage()}</p>");
         }
     }
     $view->display();
 }
Exemplo n.º 7
0
$request = Request::createFromGlobals();
$id = $request->query->get('id_dm');
$data = $request->request->has('data') ? $request->request->get('data') : $request->query->get('data');
$taskId = json_decode($data)->taskId;
$debug = json_decode($data)->debug;
$joomlaUrl = json_decode($data)->joomlaUrl;
$taskMode = json_decode($data)->taskMode;
$lang = $request->query->get('lang');
if ($id === 'TEST') {
    $responseContent = ['status' => 'ok'];
} else {
    // KBI
    $requestData = ['pooler' => $taskMode];
    // run task
    $config = array('source' => intval($id), 'query' => '', 'xslt' => NULL, 'parameters' => NULL);
    $model = new KbiModelTransformator($config);
    $document = $model->cancelQuery($taskId);
    $ok = strpos($document, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $document);
    if (FB_ENABLED && $debug) {
        // log into console
        FB::info(['curl request' => $requestData]);
        FB::info(['response' => $document]);
    }
    if (strpos($document, 'kbierror') === false && !preg_match('/status=\\"failure\\"/', $document)) {
        $success = preg_match('/status=\\"success\\"/', $document);
        if ($success) {
            $responseContent = ['status' => 'ok'];
        } else {
            $responseContent = ['status' => 'error'];
        }
    } else {
Exemplo n.º 8
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
     }
 }