public static function log($message, $severity = self::SEVERITY_INFO) { $date = date('Y-m-d H:i:s') . " - "; $severity = $severity . " - "; $payload = $date . $severity . $message; $logger = new LogHelper(); $logger->_write($payload); }
public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Generating Environment Meta Model for Drupal database connections ...')); global $databases; $datasourceCount = 0; foreach ($databases as $namespace => $connections) { foreach ($connections as $datasourceNameOnly => $connection) { $datasource = new DataSourceMetaData(); $datasource->name = NameSpaceHelper::addNameSpace($namespace, $datasourceNameOnly); $datasource->markAsPrivate(); $datasource->readonly = FALSE; // setting required properties $this->setDataSourceProperty($datasource, $connection, 'type', 'driver'); // setting other provided properties $this->setDataSourceExtensionProperties($datasource, $connection); // registering the data source $environment_metamodel->registerDataSource($datasource); $datasourceCount++; } } // Default database connection is shared because we store common utilities and dimensions there $defaultDataSource = $environment_metamodel->getDataSource(self::$DATASOURCE_NAME__DEFAULT); $defaultDataSource->shared = TRUE; LogHelper::log_info(t('Generated @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying ReportConfigRemoveColumnConfig treatment to: ' . $patient->reportNodeId); $node = node_load($patient->reportNodeId); $reportConfigText = get_node_field_value($node, 'field_report_conf', 0, 'value', FALSE); $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL; if (!isset($reportConfig)) { \LogHelper::log_info('Report configuration is EMPTY'); return; } // check column configs if (!empty($reportConfig->columnConfigs)) { foreach ($reportConfig->columnConfigs as $key => $value) { if (empty($value->columnId)) { unset($reportConfig->columnConfigs[$key]); } } $node->field_report_conf[$node->language][0]['value'] = json_encode($reportConfig); node_save($node); } } }
public function actionDescription() { Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord)); $id = 0; $class = $this->classModel; if (!empty($_GET["slug"])) { $model = $class::fetchBySlug(trim($_GET["slug"])); if ($model->id > 0) { $_GET["id"] = $model->id; $id = $model->id; } } if ($id > 0) { LogHelper::save("resorts", $id, "show"); $item = CatalogKurorts::fetch($id); if ($item->id > 0) { Yii::app()->page->title = $item->name; $this->render('description', array("item" => $item, "otherHotels" => CatalogKurorts::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND category_id=:category_id AND id!=:id")->setParams(array(":category_id" => $item->category_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(8)), "hotelCount" => CatalogKurorts::count(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category")->setParams(array(":category" => $item->category_id->id))))); } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } } else { throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу")); } }
public function actionDescription() { Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord)); $id = 0; $class = $this->classModel; if (!empty($_GET["slug"])) { $model = $class::fetchBySlug(trim($_GET["slug"])); if ($model->id > 0) { $_GET["id"] = $model->id; $id = $model->id; } else { $arrId = explode("-", $_GET["slug"]); if (sizeof($arrId) > 0) { $id = (int) $arrId[0]; } } } $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы"); if ($id > 0) { $item = CatalogTours::fetch($id); if ($item->id > 0) { LogHelper::saveCatLogTours($item->id); CCModelHelper::colCounter($item); // Картинки тура $images = ImageHelper::getImages($item); Yii::app()->page->title = $item->name . ", тур " . $item->category_id->name . ", " . $item->country_id->name; $this->render('description', array("item" => $item, "images" => $images, "otherTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:country_id AND id!=:id AND firm_id!=:firm_id")->setParams(array(":country_id" => $item->country_id->id, ":id" => $item->id, ":firm_id" => $item->firm_id->id))->setOrderBy("col DESC")->setLimit(6)), "firmsTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND firm_id=:firm_id AND id!=:id")->setParams(array(":firm_id" => $item->firm_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(6)), "tourCount" => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id))), "firmCount" => CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id))))); } else { throw new CHttpException("", $error); } } else { throw new CHttpException("", $error); } }
public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Loading Environment Meta Model from GovDashboard Content Types ...')); // Note we do not apply filters because we do not have any // if we want to use the filters we would need to prepare list of data source names // but to prepare those name we need to load meta model. // but that is what we are trying to do in this code // Catch 22 if (isset($filters)) { throw new UnsupportedOperationException(t('Filters are not supported during data source loading')); } $datamartNodes = gd_datamart_get_datamarts(LOAD_ENTITY); // preparing data sources foreach ($datamartNodes as $datamartNode) { GD_DataMartMetaModelLoaderHelper::prepareDataSource($environment_metamodel, $datamartNode); } // finalizing the preparation foreach($datamartNodes as $datamartNode) { $datasource = GD_DataMartMetaModelLoaderHelper::getDataSourceByNodeId($environment_metamodel->datasources, $datamartNode->nid); GD_DataMartMetaModelLoaderHelper::finalizeDataSourcePreparation($environment_metamodel, $datasource); } LogHelper::log_info(t('Processed @datamartCount data mart node(s)', array('@datamartCount' => count($datamartNodes)))); }
public function __call($methodName, $args) { $timeStart = microtime(TRUE); $result = call_user_func_array(array($this->instance, $methodName), $args); LogHelper::log_info(t('Data Controller execution time for @methodName(): !executionTime', array('@methodName' => $methodName, '!executionTime' => ExecutionPerformanceHelper::formatExecutionTime($timeStart)))); return $result; }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying ReportConfigRemoveFilter treatment to: ' . $patient->reportNodeId); $node = node_load($patient->reportNodeId); $reportConfigText = get_node_field_value($node, 'field_report_conf', 0, 'value', FALSE); $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL; if (!isset($reportConfig)) { \LogHelper::log_info('Report configuration is EMPTY'); return; } // check column configs if (!empty($reportConfig->model->filters)) { $preservedFilters = array(); foreach ($reportConfig->model->filters as $key => $filter) { if ( $patient->filter != $filter ) { $preservedFilters[] = $filter; } } $reportConfig->model->filters = $preservedFilters; $node->field_report_conf[$node->language][0]['value'] = json_encode($reportConfig); node_save($node); } } }
public function actionLog() { $type = Yii::app()->request->getParam("type", 0); $id = (int) Yii::app()->request->getParam("id", 0); $action = Yii::app()->request->getParam("action", 0); LogHelper::save($type, $id, $action); }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying ReportRepairDataset treatment to: ' . $patient->reportNodeId); $reportNode = node_load($patient->reportNodeId); $reportConfigText = get_node_field_value($reportNode, 'field_report_conf', 0, 'value', FALSE); $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL; if (!isset($reportConfig)) { \LogHelper::log_info('Report configuration is EMPTY'); continue; } // check columns if (!empty($reportConfig->model->datasets)) { $reportNode->field_report_dataset_sysnames[$reportNode->language] = array(); foreach ($reportConfig->model->datasets as $datasetName) { $reportNode->field_report_dataset_sysnames[$reportNode->language][] = array('value' => $datasetName); } node_save($reportNode); } } }
public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) { LogHelper::log_notice(t('Loading Environment Meta Model from settings.php ...')); $datasourceCount = 0; $configurationDataSources = Environment::getInstance()->getConfigurationSection('Data Sources'); if (isset($configurationDataSources)) { foreach ($configurationDataSources as $namespace => $sourceDataSources) { foreach ($sourceDataSources as $datasourceName => $sourceDataSource) { $datasourceName = NameSpaceHelper::resolveNameSpace($namespace, $datasourceName); $datasource = new DataSourceMetaData(); $datasource->name = $datasourceName; $datasource->initializeFrom($sourceDataSource); // it is possible that configuration contains 'readonly' property. We need to honor it // ... and only when it is not set we mark the data source as read only if (!isset($datasource->readonly)) { $datasource->readonly = TRUE; } $environment_metamodel->registerDataSource($datasource); $datasourceCount++; } } } LogHelper::log_info(t('Processed @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); }
public final function join(JoinController_SourceConfiguration $sourceConfigurationA, JoinController_SourceConfiguration $sourceConfigurationB) { $timeStart = microtime(TRUE); $result = $this->joinSourceConfigurations($sourceConfigurationA, $sourceConfigurationB); LogHelper::log_info(t('@className execution time: !executionTime', array('@className' => get_class($this), '!executionTime' => ExecutionPerformanceHelper::formatExecutionTime($timeStart)))); return $result; }
protected function loadFromDirectory(AbstractMetaModel $metamodel, array $filters = NULL, $path, $namespace, $level = 0) { $filecount = 0; $handle = opendir($path); if ($handle !== FALSE) { $indent = str_pad('', $level * 4); while (($filename = readdir($handle)) !== FALSE) { if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) { if ($filename[0] != '.') { $folder = DIRECTORY_SEPARATOR . $filename; // once name space is defined we do not change it // it will be the same for all sub-folders regardless on depth $ns = isset($namespace) ? $namespace : $filename; LogHelper::log_debug(t("{$indent}Scanning '@folderName' ...", array('@folderName' => $folder))); $filecount += $this->loadFromDirectory($metamodel, $filters, $path . $folder, $ns, $level + 1); } } elseif ($this->fileNameEndsWithJson($filename)) { LogHelper::log_debug(t("{$indent}Processing '@filename' ...", array('@filename' => $filename))); $this->loadFromFile($metamodel, $filters, $namespace, $path . DIRECTORY_SEPARATOR, $filename); $filecount++; } } closedir($handle); } return $filecount; }
protected function loadFromDirectory(AbstractMetaModel $metamodel, array $filters = NULL, $path, $namespace, $level = 0) { $filecount = 0; $handle = opendir($path); if ($handle !== FALSE) { $indent = str_pad('', $level * 4); while (($filename = readdir($handle)) !== FALSE) { if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) { if ($filename[0] != '.') { $folder = DIRECTORY_SEPARATOR . $filename; $nestedNameSpace = isset($namespace) ? NameSpaceHelper::addNameSpace($namespace, $filename) : $filename; LogHelper::log_debug(t("{$indent}Scanning '@folderName' ...", array('@folderName' => $folder))); $filecount += $this->loadFromDirectory($metamodel, $filters, $path . $folder, $nestedNameSpace, $level + 1); } } elseif ($this->fileNameEndsWithJson($filename)) { LogHelper::log_debug(t("{$indent}Processing '@filename' ...", array('@filename' => $filename))); $this->loadFromFile($metamodel, $filters, $namespace, $path . DIRECTORY_SEPARATOR, $filename); $filecount++; } } closedir($handle); } return $filecount; }
protected function prepareColumnsMetaDataProperties(DataSourceMetaData $datasource, array $tableNames) { $datasourceHandler = DataSourceQueryFactory::getInstance()->getHandler($datasource->type); $sql = 'SELECT c.relname AS ' . self::PROPERTY__TABLE_NAME . ', ' . ' a.attname AS ' . self::PROPERTY__COLUMN_NAME . ', ' . ' a.attnum AS ' . self::PROPERTY__COLUMN_INDEX . ', ' . ' t.typname AS ' . self::PROPERTY__COLUMN_TYPE . ' FROM pg_class c INNER JOIN pg_namespace ns ON ns.oid = c.relnamespace' . ' INNER JOIN pg_attribute a ON a.attrelid = c.oid' . ' INNER JOIN pg_type t ON t.oid = a.atttypid' . " WHERE c.relname IN ('" . implode("', '", $tableNames) . "')" . " AND c.relkind IN ('r','v')" . " AND ns.nspname = '{$datasource->schema}'" . ' AND a.attnum > 0'; LogHelper::log_info(new StatementLogMessage('metadata.dataset.systemTable', $sql)); return $datasourceHandler->executeQuery(new DataControllerCallContext(), $datasource, $sql, new PassthroughResultFormatter()); }
protected function registerServer($host, $port) { $result = $this->memcache->addServer($host, $port); if (!$result) { LogHelper::log_error(t('[@cacheType] Could not add server (@host:@port)', array('@cacheType' => self::$CACHE__TYPE, '@host' => $host, '@port' => $port))); } return $result; }
/** * Handle all plans for subscription. * Main goal - to stop all automailings for unsubscribed user. */ public function processUnsubscription($options) { // Check required parameters if (empty($options['subscriberId'])) { LogHelper::addError('COM_NEWSLETTER_AUTOMAILING_UNSUBSCRIPTION_SUBSCRIBER_ID_ABSENT', LogHelper::CAT_AUTOMAILING); return false; } }
public function executeDatasetUpdateOperations(DataControllerCallContext $callcontext, DatasetMetaData $dataset, array $operations) { $request = new UpdateDatasetStorageRequest($dataset->name); $request->addOperations($operations); LogHelper::log_debug($request); $this->datasourceStructureHandler->updateDatasetStorage($callcontext, $request); }
protected function executeManipulationStatementBatch(DataSourceMetaData $datasource, $sqls) { $sql = (count($sqls) == 1) ? $sqls : $this->getExtension('prepareManipulationStatementBatch')->prepare($this, $sqls); LogHelper::log_info(new StatementLogMessage('table.DML', $sql)); return $this->executeStatement($datasource, $sql); }
public function dropDimensionStorage(DataControllerCallContext $callcontext, DataSourceStructureHandler $datasourceStructureHandler, DatasetMetaData $logicalDataset, $columnName) { $lookupDatasetName = StarSchemaNamingConvention::getAttributeRelatedName($logicalDataset->name, $columnName); $request = new DatasetStorageRequest($lookupDatasetName); LogHelper::log_debug($request); $datasourceStructureHandler->dropDatasetStorage($callcontext, $request); parent::dropDimensionStorage($callcontext, $datasourceStructureHandler, $logicalDataset, $columnName); }
protected function executeQuery(DataSourceMetaData $datasource, $operationName, $sql) { LogHelper::log_info(new StatementLogMessage("metamodel.system.{$operationName}[{$datasource->type}][{$datasource->name}]", $sql)); $executionCallContext = new DataControllerCallContext(); $datasourceQueryHandler = DataSourceQueryFactory::getInstance()->getHandler($datasource->type); return $datasourceQueryHandler->executeQuery($executionCallContext, $datasource, $sql); }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying ReportConfigRemoveColumnLevel treatment to: ' . $patient->reportNodeId); } }
public function dropDatasetStorage(DataControllerCallContext $callcontext, DropDatasetStorageRequest $request) { $environment_metamodel = data_controller_get_environment_metamodel(); $dataset = DatasetTypeHelper::getTableDataset($request->datasetName); $datasource = $environment_metamodel->getDataSource($dataset->datasourceName); $sql = $this->getExtension('dropTable')->generate($this, $dataset); LogHelper::log_info(new StatementLogMessage('table.drop', $sql)); $this->executeStatement($datasource, $sql); }
public function apply ( $patients ) { if ( !is_array($patients) ) { $patients = array($patients); } foreach ( $patients as $patient ) { \LogHelper::log_info('Applying DeleteReport treatment to: '.$patient->reportNodeId); node_delete($patient->reportNodeId); } }
public function track() { // Required data $subkey = JRequest::getString('uid', ''); $newsletterId = JRequest::getInt('nid', 0); $action = JRequest::getString('action', ''); $link = base64_decode(urldecode(JRequest::getVar('link', ''))); // Optional data $listId = JRequest::getInt('lid', 0); $listId = !empty($listId) ? $listId : null; try { // Check the uid $subscriber = SubscriberHelper::getBySubkey($subkey); if (empty($subscriber->subscriber_id)) { throw new Exception('User is absent'); } // Determine the action $table = JTable::getInstance('history', 'NewsletterTable'); $actionCode = $table->getActionCode($action); if ($actionCode === false) { throw new Exception('Unknown action'); } // If this is a "clicked" event we should save the link $text = $actionCode == NewsletterTableHistory::ACTION_CLICKED ? $link : ""; // Track the event // If type of action is ACTION_OPENED then check it // should be only one in the DB for sid-nid if ($actionCode == NewsletterTableHistory::ACTION_OPENED) { $res = $table->load(array('subscriber_id' => (int) $subscriber->subscriber_id, 'newsletter_id' => (int) $newsletterId, 'action' => $actionCode)); if (!empty($table->history_id)) { throw new Exception('no need to track'); } } $res = $table->save(array('subscriber_id' => (int) $subscriber->subscriber_id, 'list_id' => $listId, 'newsletter_id' => (int) $newsletterId, 'date' => date('Y-m-d H:i:s'), 'action' => $actionCode, 'text' => addslashes($link))); if (!$res) { $err = $table->getError(); $err = $err instanceof Exception ? $err->getMessage() : $err; throw new Exception('Error saving data: ' . $err); } } catch (Exception $e) { if ($e->getMessage() != 'no need to track') { // For debug LogHelper::addDebug('Tracking failed', LogHelper::CAT_TRACKING, array('Message' => $e->getMessage(), 'Data' => JRequest::get())); jexit(); } else { // For debug LogHelper::addDebug('Tracking', LogHelper::CAT_TRACKING, array('Message' => 'No need to track', 'data' => JRequest::get())); } } LogHelper::addDebug('Tracking', LogHelper::CAT_TRACKING, JRequest::get()); // Redirect it! if (!empty($link)) { $this->setRedirect($link); } }
public function setValues($values, $expiration = NULL) { $timeStart = microtime(TRUE); $errorEntryNames = parent::setValues($values, $expiration); $entryCount = count($values); $errorEntryCount = count($errorEntryNames); $successfulEntryCount = $entryCount - $errorEntryCount; LogHelper::log_info(t("[@cacheType] Execution time for @successFlag storing of @entryCount entries is !executionTime", array('@cacheType' => $this->getCacheType(), '@entryCount' => $errorEntryCount == 0 ? $entryCount : ($successfulEntryCount == 0 ? $entryCount : "{$successfulEntryCount} out of {$entryCount}"), '!executionTime' => ExecutionPerformanceHelper::formatExecutionTime($timeStart), '@successFlag' => $errorEntryCount == 0 ? 'SUCCESSFUL' : ($successfulEntryCount == 0 ? 'UNSUCCESSFUL' : 'successful')))); // some errors but also some success return $errorEntryNames; }
public function openResource() { LogHelper::log_notice(t('Parsing data from a buffer (size: @bufferSize) ...', array('@bufferSize' => $this->bufferSize))); $result = parent::openResource(); if ($result) { $this->index = 0; } return $result; }
public function __destruct() { // because it is executed in destructor we should not allow exceptions to reach PHP script execution engine // otherwise execution of the script will halt try { $this->flush(); } catch (Exception $e) { LogHelper::log_error($e); } parent::__destruct(); }
public function load(AbstractMetaModelFactory $factory, AbstractMetaModel $environment_metamodel, array $filters = NULL, $finalAttempt) { LogHelper::log_notice(t('Generating Environment Meta Model for APC cache ...')); $datasourceCount = 0; $datasource = new DataSourceMetaData(); $datasource->name = NameSpaceHelper::addNameSpace(APCHandler::$CACHE__TYPE, DefaultCacheFactory::$DATASOURCE_NAME__DEFAULT); $datasource->type = APCHandler::$CACHE__TYPE; $environment_metamodel->registerDataSource($datasource); $datasourceCount++; LogHelper::log_info(t('Generated @datasourceCount data sources', array('@datasourceCount' => $datasourceCount))); return self::LOAD_STATE__SUCCESSFUL; }
public static function detectDatasetSourceType(DatasetMetaData $dataset) { if (isset($dataset->assembler)) { return self::DATASET_SOURCE_TYPE__DYNAMIC; } elseif (isset($dataset->source)) { $source = trim($dataset->source); $isTableName = strpos($source, ' ') === FALSE; return $isTableName ? self::DATASET_SOURCE_TYPE__TABLE : self::DATASET_SOURCE_TYPE__SUBQUERY; } LogHelper::log_error($dataset); throw new IllegalArgumentException(t('Could not detect type of dataset source for the dataset: @datasetName', array('@datasetName' => $dataset->publicName))); }