本文整理汇总了PHP中MetaModel类的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel类的具体用法?PHP MetaModel怎么用?PHP MetaModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetaModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getExportDatasetName
public static function getExportDatasetName ( $datasetName, MetaModel $metamodel ) {
$logicalDatasetName = StarSchemaNamingConvention::findFactsOwner($datasetName);
if (isset($logicalDatasetName)) {
$dataset = $metamodel->getDataset($logicalDatasetName);
return isset($dataset->uuid) ? StarSchemaNamingConvention::getFactsRelatedName($dataset->uuid) : null;
} else {
$dataset = $metamodel->getDataset($datasetName);
return isset($dataset->uuid) ? $dataset->uuid : null;
}
}
示例2: prepareDimension
public function prepareDimension(MetaModel $metamodel, DatasetMetaData $dataset, $columnName, CubeMetaData $cube)
{
$column = $dataset->getColumn($columnName);
$sourceDatasetColumn = $cube->sourceDataset->getColumn($columnName);
$dimension = $cube->getDimension($columnName);
$this->prepareYearLevel($dimension, $column);
// cube source dataset column contains a reference to year identifier
$sourceDatasetColumn->initializeTypeFrom(Sequence::getSequenceColumnType());
// adding a reference to date dataset
$referenceName = DateDimensionDatasetNames::LEVEL_YEARS;
$metamodel->registerSimpleReferencePoint($referenceName, DateDimensionDatasetNames::LEVEL_YEARS, 'year_id');
$metamodel->registerSimpleReferencePoint($referenceName, $cube->sourceDatasetName, $columnName);
}
示例3: Init
public static function Init()
{
$aParams = array("category" => "application", "key_type" => "autoincrement", "name_attcode" => "name", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_iotask", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "");
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values" => null, "sql" => "name", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values" => null, "sql" => "description", "default_value" => "", "is_null_allowed" => true, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("category", array("allowed_values" => new ValueSetEnum('Input, Ouput'), "sql" => "category", "default_value" => "Input", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("allowed_values" => new ValueSetEnum('File, Database, Web Service'), "sql" => "source_type", "default_value" => "File", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("allowed_values" => new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql" => "source_subtype", "default_value" => "CSV", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeString("source_path", array("allowed_values" => null, "sql" => "source_path", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeClass("objects_class", array("class_category" => "", "more_values" => "", "sql" => "objects_class", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("allowed_values" => new ValueSetEnum('Yes,No'), "sql" => "test_mode", "default_value" => 'No', "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("allowed_values" => new ValueSetEnum('Yes,No'), "sql" => "verbose_mode", "default_value" => 'No', "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("options", array("allowed_values" => new ValueSetEnum('Full, Update Only, Creation Only'), "sql" => "options", "default_value" => 'Full', "is_null_allowed" => true, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype', 'source_path', 'options', 'test_mode', 'verbose_mode'));
// Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('description', 'category', 'objects_class', 'source_type', 'source_subtype', 'options'));
// Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'category', 'objects_class', 'source_type', 'source_subtype'));
// Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype'));
// Criteria of the advanced search form
}
示例4: ComputeSelectedClasses
/**
* Find the lowest common ancestor for each of the selected class
*/
protected function ComputeSelectedClasses()
{
// 1 - Collect all the column/classes
$aColumnToClasses = array();
foreach ($this->aSearches as $iPos => $oSearch) {
$aSelected = array_values($oSearch->GetSelectedClasses());
if ($iPos != 0) {
if (count($aSelected) < count($aColumnToClasses)) {
throw new Exception('Too few selected classes in the subquery #' . ($iPos + 1));
}
if (count($aSelected) > count($aColumnToClasses)) {
throw new Exception('Too many selected classes in the subquery #' . ($iPos + 1));
}
}
foreach ($aSelected as $iColumn => $sClass) {
$aColumnToClasses[$iColumn][] = $sClass;
}
}
// 2 - Build the index column => alias
$oFirstSearch = $this->aSearches[0];
$aColumnToAlias = array_keys($oFirstSearch->GetSelectedClasses());
// 3 - Compute alias => lowest common ancestor
$this->aSelectedClasses = array();
foreach ($aColumnToClasses as $iColumn => $aClasses) {
$sAlias = $aColumnToAlias[$iColumn];
$sAncestor = MetaModel::GetLowestCommonAncestor($aClasses);
if (is_null($sAncestor)) {
throw new Exception('Could not find a common ancestor for the column ' . ($iColumn + 1) . ' (Classes: ' . implode(', ', $aClasses) . ')');
}
$this->aSelectedClasses[$sAlias] = $sAncestor;
}
}
示例5: GetRuleResultFilter
function GetRuleResultFilter($iRuleId, $oDefinitionFilter, $oAppContext)
{
$oRule = MetaModel::GetObject('AuditRule', $iRuleId);
$sOql = $oRule->Get('query');
$oRuleFilter = DBObjectSearch::FromOQL($sOql);
FilterByContext($oRuleFilter, $oAppContext);
// Not needed since this filter is a subset of the definition filter, but may speedup things
if ($oRule->Get('valid_flag') == 'false') {
// The query returns directly the invalid elements
$oFilter = $oRuleFilter->Intersect($oDefinitionFilter);
} else {
// The query returns only the valid elements, all the others are invalid
$aValidRows = $oRuleFilter->ToDataArray(array('id'));
$aValidIds = array();
foreach ($aValidRows as $aRow) {
$aValidIds[] = $aRow['id'];
}
$oFilter = $oDefinitionFilter->DeepClone();
if (count($aValidIds) > 0) {
$aInDefSet = array();
foreach ($oDefinitionFilter->ToDataArray(array('id')) as $aRow) {
$aInDefSet[] = $aRow['id'];
}
$aInvalids = array_diff($aInDefSet, $aValidIds);
if (count($aInvalids) > 0) {
$oFilter->AddCondition('id', $aInvalids, 'IN');
} else {
$oFilter->AddCondition('id', 0, '=');
}
}
}
return $oFilter;
}
示例6: Analyze
/**
* Split the string into placholders
* @param Hash $aParamTypes Class of the expected parameters: hash array of '<param_id>' => '<class_name>'
* @return void
*/
protected function Analyze($aParamTypes = array())
{
if (!is_null($this->m_aPlaceholders)) {
return;
}
$this->m_aPlaceholders = array();
if (preg_match_all('/\\$([a-z0-9_]+(->[a-z0-9_]+)*)\\$/', $this->m_sRaw, $aMatches)) {
foreach ($aMatches[1] as $sPlaceholder) {
$oPlaceholder = new TemplateStringPlaceholder($sPlaceholder);
$oPlaceholder->bIsValid = false;
foreach ($aParamTypes as $sParamName => $sClass) {
$sParamPrefix = $sParamName . '->';
if (substr($sPlaceholder, 0, strlen($sParamPrefix)) == $sParamPrefix) {
// Todo - detect functions (label...)
$oPlaceholder->sFunction = '';
$oPlaceholder->sParamName = $sParamName;
$sAttcode = substr($sPlaceholder, strlen($sParamPrefix));
$oPlaceholder->sAttcode = $sAttcode;
$oPlaceholder->bIsValid = MetaModel::IsValidAttCode($sClass, $sAttcode, true);
}
}
$this->m_aPlaceholders[] = $oPlaceholder;
}
}
}
示例7: Init
public static function Init()
{
$aParams = array("category" => "gui", "key_type" => "autoincrement", "name_attcode" => "user_id", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_app_dashboards", "db_key_field" => "id", "db_finalclass_field" => "");
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("targetclass" => "User", "allowed_values" => null, "sql" => "user_id", "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeString("menu_code", array("allowed_values" => null, "sql" => "menu_code", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeText("contents", array("allowed_values" => null, "sql" => "contents", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
}
示例8: findCube
public function findCube($cubeName, $localOnly = FALSE) {
$cube = parent::findCube($cubeName);
if (!isset($cube) && !$localOnly) {
$cube = $this->parentMetaModel->findCube($cubeName);
}
return $cube;
}
示例9: GetProfileActionGrant
public static function GetProfileActionGrant($iProfileId, $sClass, $sAction)
{
$bLegacyBehavior = MetaModel::GetConfig()->Get('user_rights_legacy');
// Search for a grant, stoping if any deny is encountered (allowance implies the verification of all paths)
$bAllow = null;
// 1 - The class itself
//
$sGrantKey = $iProfileId . '_' . $sClass . '_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
$bAllow = self::$aGRANTS[$sGrantKey];
if ($bLegacyBehavior) {
return $bAllow;
}
if (!$bAllow) {
return false;
}
}
// 2 - The parent classes, up to the root class
//
foreach (MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_EXCLUDELEAF, false) as $sParent) {
$sGrantKey = $iProfileId . '_' . $sParent . '+_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
$bAllow = self::$aGRANTS[$sGrantKey];
if ($bLegacyBehavior) {
return $bAllow;
}
if (!$bAllow) {
return false;
}
}
}
// 3 - The related classes (if the current is an N-N link with DEL_AUTO/DEL_SILENT)
//
$bGrant = self::GetLinkActionGrant($iProfileId, $sClass, $sAction);
if (!is_null($bGrant)) {
$bAllow = $bGrant;
if ($bLegacyBehavior) {
return $bAllow;
}
if (!$bAllow) {
return false;
}
}
// 4 - All
//
$sGrantKey = $iProfileId . '_*_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
$bAllow = self::$aGRANTS[$sGrantKey];
if ($bLegacyBehavior) {
return $bAllow;
}
if (!$bAllow) {
return false;
}
}
// null or true
return $bAllow;
}
示例10: output
public function output()
{
if (class_exists('MetaModel')) {
MetaModel::RecordQueryTrace();
}
if (class_exists('ExecutionKPI')) {
ExecutionKPI::ReportStats();
}
}
示例11: GetProfileActionGrant
public static function GetProfileActionGrant($iProfileId, $sClass, $sAction)
{
// Search for a grant, starting from the most explicit declaration,
// then searching for less and less explicit declaration
// 1 - The class itself
//
$sGrantKey = $iProfileId . '_' . $sClass . '_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
return self::$aGRANTS[$sGrantKey];
}
// 2 - The parent classes, up to the root class
//
foreach (MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_EXCLUDELEAF, false) as $sParent) {
$sGrantKey = $iProfileId . '_' . $sParent . '+_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
return self::$aGRANTS[$sGrantKey];
}
}
// 3 - The related classes (if the current is an N-N link with AUTO_DEL)
//
if (array_key_exists($sClass, self::$aLINKTOCLASSES)) {
// Get the grant for the remote classes. The resulting grant is:
// - One YES => YES
// - 100% undefined => undefined
// - otherwise => NO
//
// Having write allowed on the remote class implies write + delete on the N-N link class
if ($sAction == 'd') {
$sRemoteAction = 'w';
} elseif ($sAction == 'bd') {
$sRemoteAction = 'bw';
} else {
$sRemoteAction = $sAction;
}
foreach (self::$aLINKTOCLASSES[$sClass] as $sRemoteClass) {
$bUndefined = true;
$bGrant = self::GetProfileActionGrant($iProfileId, $sRemoteClass, $sAction);
if ($bGrant === true) {
return true;
}
if ($bGrant === false) {
$bUndefined = false;
}
}
if (!$bUndefined) {
return false;
}
}
// 4 - All
//
$sGrantKey = $iProfileId . '_*_' . $sAction;
if (isset(self::$aGRANTS[$sGrantKey])) {
return self::$aGRANTS[$sGrantKey];
}
// Still undefined for this class
return null;
}
示例12: Init
public static function Init()
{
$aParams = array("category" => "core/cmdb", "key_type" => "autoincrement", "name_attcode" => "date", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_change", "db_key_field" => "id", "db_finalclass_field" => "", 'indexes' => array(array('origin')));
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values" => null, "sql" => "date", "default_value" => "", "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values" => null, "sql" => "userinfo", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeEnum("origin", array("allowed_values" => new ValueSetEnum('interactive,csv-interactive,csv-import.php,webservice-soap,webservice-rest,synchro-data-source,email-processing,custom-extension'), "sql" => "origin", "default_value" => "interactive", "is_null_allowed" => true, "depends_on" => array())));
}
示例13: IsInstalled
/**
* Helper to check wether the table has been created into the DB
* (this table did not exist in 1.0.1 and older versions)
*/
public static function IsInstalled()
{
$sTable = MetaModel::DBGetTable(__CLASS__);
if (CMDBSource::IsTable($sTable)) {
return true;
} else {
return false;
}
return false;
}
示例14: decorationFactory
/**
* @param MetaModel $meta
*
* @return Ajde_Crud_Options_Fields_Field
*/
protected function decorationFactory(MetaModel $meta)
{
$field = new Ajde_Crud_Options_Fields_Field();
$field->setName('meta_' . $meta->getPK());
$field->setType('text');
$field->setLabel($meta->get('name'));
if ($meta->getOption('help')) {
$field->setHelp($meta->getOption('help'));
}
if ($meta->getOption('default')) {
$field->setDefault($meta->getOption('default'));
}
if ($meta->getOption('readonly')) {
$field->setIsReadonly(true);
}
$field->setLength($meta->getIntOption('length'));
$field->setIsRequired($meta->getBooleanOption('required'));
return $field;
}
示例15: GetURL
public function GetURL()
{
$aOverloads = MetaModel::GetConfig()->Get('portal_dispatch_urls');
if (array_key_exists($this->sPortalid, $aOverloads)) {
$sRet = $aOverloads[$this->sPortalid];
} else {
$sRet = utils::GetAbsoluteUrlAppRoot() . $this->aData['url'];
}
return $sRet;
}