Пример #1
0
 public function testSetPort()
 {
     foreach ($this->_testData as $obj) {
         $this->object = KBIntegrator::create($obj['source']);
         $this->object->setPort($obj['source']['port']);
         $this->assertEquals($obj['source']['port'], $this->object->getPort());
     }
 }
Пример #2
0
 function display($tpl = NULL)
 {
     self::setToolbar();
     JRequest::setVar('hidemainmenu', 1);
     $id = JRequest::getVar('id', array(0), 'method', 'array');
     $document =& JFactory::getDocument();
     $model =& $this->getModel();
     $user =& JFactory::getUser();
     $source = $model->getSource($id[0]);
     $lists = array();
     $lists['types'] = JHTML::_('select.genericlist', $this->getTypes(), 'type', '', 'id', 'name', $source != NULL ? $source->type : NULL);
     $lists['methods'] = JHTML::_('select.genericlist', $this->getMethods(), 'method', '', 'id', 'name', $source != NULL ? $source->method : NULL);
     $this->assignRef('row', $source);
     if (!empty($source)) {
         $this->assignRef('source', KBIntegrator::create(get_object_vars($source)));
     }
     $this->assignRef('option', $this->com_kbi);
     $this->assignRef('name', $user->name);
     $this->assignRef('lists', $lists);
     $style = "#dictionaryLink.ajax-loading {background: url('/components/com_kbi/assets/loader.gif') no-repeat center right; padding-right: 20px;}";
     $style .= ' ';
     $style .= "#dictionaryLink.ajax-error {background: url('/components/com_kbi/assets/warning-icon.gif') no-repeat center right; padding-right: 20px;}";
     $document->addStyleDeclaration($style);
     parent::display($tpl);
 }
Пример #3
0
 public static function prepareKbi($lmUrl)
 {
     //TODO vazba na totožnou metodu v dbconnectModelConnections
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => $lmUrl);
     JLoader::import('KBIntegrator', JPATH_LIBRARIES . DS . 'kbi');
     return KBIntegrator::create($configArr);
 }
Пример #4
0
 /**
  *
  *
  * @param mixed $value id | array | object | json
  * @throws Exception
  */
 function setSource($value)
 {
     $config = array();
     $session = JFactory::getSession();
     if (is_numeric($value)) {
         if (!class_exists('KbiModelSources')) {
             JLoader::import('sources', COM_KBI_ADMIN . DS . 'models');
         }
         $sources = new KbiModelSources();
         $config = get_object_vars($sources->getSource($value));
     } elseif (is_array($value)) {
         $config = $value;
     } elseif (is_string($value)) {
         $config = json_decode($value, true);
     } else {
         $config = $value;
     }
     if (!is_array($config)) {
         throw new Exception("Not valid source configuration");
     }
     $this->source = KBIntegrator::create($config);
     $this->source->setUser($session->get('user', null, 'sewebar'));
 }
Пример #5
0
 /**
  * Generates JSON from FeaturesList and DataDescription that initializes ARDesigner.
  *
  */
 function features()
 {
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('application/json');
     $viewName = JRequest::getVar('view', 'features');
     $viewType = 'raw';
     $view =& $this->getView($viewName, $viewType);
     $query_id = JRequest::getInt('id_query', NULL);
     $view->assign('value', '');
     if ($query_id != NULL) {
         if (!class_exists('KbiModelQueries')) {
             $kbi = JComponentHelper::getComponent('com_kbi', true);
             if ($kbi->enabled) {
                 JLoader::import('queries', self::$com_kbi_admin . DS . 'models');
                 JLoader::import('sources', self::$com_kbi_admin . DS . 'models');
             } else {
                 throw new Exception(JText::_('Component com_kbi not found / enabled!'));
             }
         }
         $model_queries = new KbiModelQueries();
         $query = $model_queries->getQuery($query_id);
         $model_sources = new KbiModelSources();
         $source = $model_sources->getSource(JRequest::getInt('id_source', NULL));
         KBIDebug::log($source);
         $featurelist = !empty($query->featurelist) ? $query->featurelist : $this->featurelist;
         if (!empty($source->dictionaryquery)) {
             $datadescription = $source->dictionaryquery;
         } else {
             $kbi_source = KBIntegrator::create(get_object_vars($source));
             if ($kbi_source instanceof ISynchronable) {
                 $datadescription = $kbi_source->getDataDescription();
             } else {
                 $datadescription = $this->datadescription;
             }
         }
     } else {
         $featurelist = $this->featurelist;
         $datadescription = $this->datadescription;
     }
     if (class_exists('KBIDebug')) {
         KBIDebug::log(array('featurelist' => $featurelist, 'datadescription' => $datadescription), 'Loading ARD with FL and DL');
     }
     $sr = new GetDataARBuilderQuery($datadescription, $featurelist, null, 'en');
     $result = $sr->getData();
     $view->assignRef('value', $result);
     $view->display();
 }
Пример #6
0
 function storeDocument()
 {
     //$view =& $this->getView('synchronize', $document->getType());
     $id = JRequest::getVar('source', null, 'method', 'int');
     $pmml = JRequest::getVar('content', NULL, 'default', 'none', JREQUEST_ALLOWRAW);
     $pmml_id = JRequest::getVar('id', time(), 'default', 'none');
     $pmml_name = JRequest::getVar('title', "Document " . date("Y-m-d H:i:s"), 'default', 'none');
     $model = new KbiModelSources();
     $sourceConfig = $model->getSource($id);
     $source = KBIntegrator::create(get_object_vars($sourceConfig));
     $document = (object) array('id' => $pmml_id, 'title' => $pmml_name, 'modified' => date("Y-m-d H:i:s"), 'text' => $pmml, 'reportUri' => '');
     try {
         if ($document && $source instanceof ISynchronable) {
             $source->addDocument($document->id, $document, FALSE);
             echo json_encode($document);
             //$view->assignRef('document', $document);
         }
     } catch (Exception $ex) {
         //TODO: add document title to error message
         echo json_encode(array('error' => $ex->getMessage()));
     }
 }
Пример #7
0
 /**
  * Akce pro potvrzení změny hesla uživatele na connect serveru
  */
 public function confirmPasswordChange()
 {
     //TODO poslání potvrzovacího požadavku
     $minerUrl = 'http://connect-dev.lmcloud.vse.cz/SewebarConnectNext';
     //TODO výběr URL mineru
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => $minerUrl);
     $username = base64_decode(JRequest::getString('user', ''));
     $code = JRequest::getString('code', '');
     try {
         JLoader::import('KBIntegrator', JPATH_LIBRARIES . DS . 'kbi');
         /** @var $kbi LispMiner */
         $kbi = KBIntegrator::create($configArr);
         $kbi->confirmUserPasswordUpdate($username, $code);
         $application = JFactory::getApplication();
         $application->enqueueMessage(JText::_('PASSWORD_CONFIRM_REQUEST_MAIL_DONE'));
     } catch (Exception $e) {
         JError::raiseWarning(100, JText::_('PASSWORD_CONFIRM_REQUEST_MAIL_FAILED'));
     }
 }
Пример #8
0
 function delete()
 {
     global $option;
     $document =& JFactory::getDocument();
     $view =& $this->getView('documents', $document->getType());
     $user =& JFactory::getUser();
     try {
         if ($model =& $this->getModel('sources')) {
             $id = JRequest::getVar('id', array(0), 'method', 'array');
             $cids = JRequest::getVar('cid', array(0), 'method', 'array');
             $sourceConfig = $model->getSource($id[0]);
             $messages = array();
             $source = KBIntegrator::create(get_object_vars($sourceConfig));
             foreach ($cids as $cid) {
                 $source->deleteDocument($cid);
                 $messages[] = JText::_("Document {$cid} deleted.");
             }
             $this->setMessage(implode(', ', $messages));
             $this->setRedirect("index.php?option={$option}&controller=documents&id[]={$id[0]}");
         }
     } catch (Exception $ex) {
         $this->setRedirect("index.php?option={$option}");
         $this->setMessage(JText::_('ERROR LISTING DOCUMENTS') . ": " . $ex->getMessage());
     }
 }
Пример #9
0
 public static function prepareKbi()
 {
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => self::LM_URL);
     JLoader::import('KBIntegrator', JPATH_LIBRARIES . DS . 'kbi');
     return KBIntegrator::create($configArr);
 }
Пример #10
0
 public function __construct($config)
 {
     parent::__construct($config);
 }
Пример #11
0
 function remove()
 {
     global $option;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $this->setRedirect("index.php?option={$option}");
     // Initialize variables
     $db =& JFactory::getDBO();
     $ids = JRequest::getVar('cid', array(0), 'post', 'array');
     $table =& JTable::getInstance('source', 'Table');
     $n = count($ids);
     for ($i = 0; $i < $n; $i++) {
         $sources =& $this->getModel('sources');
         $source = $sources->getSource((int) $ids[$i]);
         // delete miner if it is LISpMiner
         if ($source && $source->type == 'LISPMINER') {
             try {
                 $config = get_object_vars($source);
                 JLoader::import('KBIntegrator', JPATH_PLUGINS . DS . 'kbi');
                 $miner = KBIntegrator::create($config);
                 $miner->unregister();
             } catch (Exception $ex) {
                 // Just log it
                 KBIDebug::log($ex->getMessage());
             }
         }
         if (!$table->delete((int) $ids[$i])) {
             return JError::raiseWarning(500, $table->getError());
         }
     }
     $this->setMessage(JText::sprintf('Items removed', $n));
 }
Пример #12
0
 private function generateKbiSource($configArr, $connection, $task, $pmml, $minerUrl = 'http://connect-dev.lmcloud.vse.cz/SewebarConnect')
 {
     $kbiModel =& $this->getModel('Kbi', 'dbconnectModel');
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => $minerUrl);
     JLoader::import('KBIntegrator', JPATH_PLUGINS . DS . 'kbi');
     $kbi = KBIntegrator::create($configArr);
     if ($task->kbi_source <= 0) {
         $registerNewLispminer = true;
     } else {
         //TODO kontrola, jestli lispminer existuje
         $registerNewLispminer = false;
     }
     /*-----------registrace LM a import----------*/
     //TODO kontrola, jestli server existuje
     /*musíme vytvořit nový LM server*/
     if ($connection->db_type == 'mysql') {
         $dbType = 'MySQLConnection';
     } else {
         $dbType = 'AccessConnection';
     }
     if ($registerNewLispminer) {
         //máme zaregistrovat nový lisp miner
         try {
             $lispminerId = $kbi->register(array('server' => $connection->server, 'database' => $connection->db_name, 'username' => $connection->username, 'password' => $connection->password, 'type' => $dbType));
         } catch (Exception $e) {
             exit('Při vytváření LM zdroje došlo k chybě. ' . $e->getMessage());
         }
         //--máme zaregistrovat nový lisp miner
     } else {
         //miner už existuje
         $kbiSource = $kbiModel->getSource($task->kbi_source);
         $kbiSourceParams = json_decode($kbiSource->params, true);
         $lispminerId = $kbiSourceParams['miner_id'];
     }
     if ($lispminerId) {
         //máme zaregistrovaný LM server - vytvorime KBI zdroj
         ////
         try {
             $importResult = $kbi->importDataDictionary($pmml, $lispminerId);
             //TODO kontrola $importResult !!
         } catch (Exception $e) {
             exit('Při vytváření LM zdroje došlo k chybě. ' . $e->getMessage());
         }
         //exit(var_dump($importResult));
         if ($importResult) {
             //máme úspěšně naimportováno
             if ($task->kbi_source <= 0) {
                 $kbiSource = $kbiModel->newLMSource($task->name, $minerUrl, $lispminerId, $connection->table);
                 $tasksModel =& $this->getModel('Tasks', 'dbconnectModel');
                 $tasksModel->updateTaskKbiSource($task->id, $kbiSource);
                 $task->kbi_source = $kbiSource;
             } else {
                 //TODO pokud miner neexistoval, je potřeba aktualizovat info
                 ///$kbiModel->updateLMSource_minerId($task->kbi_source,$lispminerId);
             }
         } else {
             //TODO odstraneni lispmineru, hláška pro uživatele
         }
         //
     } else {
         //TODO nepodařilo se zaregistrovat LM, hláška pro uživatele
     }
     /*-----------//registrace LM a import----------*/
     return $task->kbi_source;
 }
Пример #13
0
 /**
  * @param $id
  * @throws Exception
  */
 public function remove($id)
 {
     $table =& JTable::getInstance('source', 'Table');
     $id = (int) $id;
     $source = $this->getSource($id);
     // delete miner if it is LISpMiner
     if ($source && $source->type == 'LISPMINER') {
         try {
             $config = get_object_vars($source);
             JLoader::import('KBIntegrator', JPATH_LIBRARIES . DS . 'kbi');
             $miner = KBIntegrator::create($config);
             $miner->unregister();
         } catch (Exception $ex) {
             // Just log it
             KBIDebug::log($ex->getMessage());
         }
     }
     if (!$table->delete($id)) {
         throw new Exception($table->getError());
     }
 }
Пример #14
0
 private function generateKbiSource($configArr, $connection, $task, $pmml = '', $minerUrl = 'http://connect.lmcloud.vse.cz')
 {
     $kbiModel =& $this->getModel('Kbi', 'dbconnectModel');
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => $minerUrl);
     JLoader::import('KBIntegrator', JPATH_PLUGINS . DS . 'kbi');
     $kbi = KBIntegrator::create($configArr);
     if ($task->kbi_source <= 0) {
         $registerNewLispminer = true;
     } else {
         //TODO kontrola, jestli lispminer existuje
         $registerNewLispminer = false;
     }
     /*-----------registrace LM a import----------*/
     //TODO kontrola, jestli server existuje
     /*musíme vytvořit nový LM server*/
     if ($connection->db_type == 'mysql') {
         $dbType = 'MySQLConnection';
     } else {
         $dbType = 'AccessConnection';
     }
     if ($registerNewLispminer) {
         //máme zaregistrovat nový lisp miner
         try {
             $lispminerId = $kbi->register(array('server' => $connection->server, 'database' => $connection->db_name, 'username' => $connection->username, 'password' => $connection->password, 'type' => $dbType));
         } catch (Exception $e) {
             throw $e;
         }
         //--máme zaregistrovat nový lisp miner
     } else {
         //miner už existuje
         $kbiSource = $kbiModel->getSource($task->kbi_source);
         $kbiSourceParams = json_decode($kbiSource->params, true);
         $lispminerId = $kbiSourceParams['miner_id'];
     }
     //TODO - pokud nemáme zadaný PMML soubor, musíme vytvořit aspoň zadání primárního klíče
     if ($lispminerId) {
         //máme zaregistrovaný LM server - vytvorime KBI zdroj
         ////
         try {
             $importResult = $kbi->importDataDictionary($pmml, $lispminerId);
             //TODO kontrola $importResult !!
         } catch (Exception $e) {
             throw $e;
         }
         if ($importResult) {
             //máme úspěšně naimportováno
             if ($task->kbi_source <= 0) {
                 $kbiSource = $kbiModel->newLMSource($task->name, $minerUrl, $lispminerId, $connection->table);
                 $tasksModel =& $this->getModel('Tasks', 'dbconnectModel');
                 $tasksModel->updateTaskKbiSource($task->id, $kbiSource);
                 $task->kbi_source = $kbiSource;
             }
             /*else{       //TODO pokud miner neexistoval, je potřeba aktualizovat info
                 ///$kbiModel->updateLMSource_minerId($task->kbi_source,$lispminerId);
               }  */
         }
         //
     }
     /*-----------//registrace LM a import----------*/
     return array('kbi_source' => $task->kbi_source, 'miner_id' => $lispminerId);
 }
Пример #15
0
::<?php 
    echo $row->name;
    ?>
">
					<a href="<?php 
    echo $row->link;
    ?>
"><?php 
    echo $row->name;
    ?>
</a>
				</span>
			</td>
			<td align="center">
				<?php 
    if (!empty($row) && ($source = KBIntegrator::create(get_object_vars($row))) instanceof ISynchronable) {
        ?>
					<a href="<?php 
        echo JRoute::_("index.php?option={$option}&controller=documents&id[]={$row->id}");
        ?>
"><?php 
        echo JText::_('Documents');
        ?>
</a>
				<?php 
    } else {
        ?>
					-
				<?php 
    }
    ?>
Пример #16
0
 private function generateKbiSource($configArr, $connection, $task, $pmml, $minerUrl = 'http://connect-dev.lmcloud.vse.cz/SewebarConnect')
 {
     $kbiModel =& $this->getModel('Kbi', 'dbconnectModel');
     $configArr = array('type' => 'LISPMINER', 'name' => 'TEST', 'method' => 'POST', 'url' => $minerUrl);
     JLoader::import('KBIntegrator', JPATH_PLUGINS . DS . 'kbi');
     $kbi = KBIntegrator::create($configArr);
     if ($task->kbi_source <= 0) {
         $registerNewLispminer = true;
     } else {
         //TODO kontrola, jestli lispminer existuje
         $registerNewLispminer = false;
     }
     if ($registerNewLispminer) {
         //TODO kontrola, jestli server existuje
         /*musíme vytvořit nový LM server*/
         if ($connection->db_type == 'mysql') {
             $dbType = 'MySQLConnection';
         } else {
             $dbType = 'AccessConnection';
         }
         //$kbiSource=$kbi->register(array('server'=>'localhost','database'=>'barbora','type'=>'mysqlconnection','username'=>'lisp','password'=>'lisp'));
         $lispminerId = $kbi->register(array('server' => $connection->server, 'database' => $connection->db_name, 'username' => $connection->username, 'password' => $connection->password, 'type' => $dbType));
         if ($lispminerId) {
             //máme zaregistrovaný LM server - vytvorime KBI zdroj
             $importResult = $kbi->importDataDictionary($pmml, $lispminerId);
             //TODO kontrola $importResult !!
             //exit(var_dump($importResult));
             if ($importResult) {
                 //máme úspěšně naimportováno
                 if ($task->kbi_source <= 0) {
                     $kbiSource = $kbiModel->newLMSource($task->name, $minerUrl, $lispminerId, $connection->table);
                     $tasksModel =& $this->getModel('Tasks', 'dbconnectModel');
                     $tasksModel->updateTaskKbiSource($task->id, $kbiSource);
                     $task->kbi_source = $kbiSource;
                 } else {
                     $kbiModel->updateLMSource_minerId($task->kbi_source, $lispminerId);
                 }
             } else {
                 //TODO odstraneni lispmineru, hláška pro uživatele
             }
             //
         } else {
             //TODO nepodařilo se zaregistrovat LM, hláška pro uživatele
         }
     }
     return $task->kbi_source;
 }