From 446bd0ad1ff05fd9d66243851135391243ccb81b Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 20 Sep 2018 09:58:35 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B0931:=20Rename=20Tag=20columns=20in=20dat?= =?UTF-8?q?abase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 4 +- core/attributedef.class.inc.php | 14 ++--- core/oql/expression.class.inc.php | 4 +- core/ormtagset.class.inc.php | 10 ++-- core/tagsetfield.class.inc.php | 76 +++++++++++++------------- pages/tagadmin.php | 2 +- setup/compiler.class.inc.php | 4 +- test/ItopDataTestCase.php | 14 ++--- test/core/TagSetFieldDataTest.php | 12 ++-- test/core/ormTagSetTest.php | 2 +- 10 files changed, 71 insertions(+), 71 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index f06a9e086..bd9959e81 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -2170,8 +2170,8 @@ EOF foreach($aTagSetObjectData as $oTagSet) { $aTagSetKeyValData[] = [ - 'code' => $oTagSet->Get('tag_code'), - 'label' => $oTagSet->Get('tag_label') + 'code' => $oTagSet->Get('code'), + 'label' => $oTagSet->Get('label') ]; } $aJson['possible_values'] = $aTagSetKeyValData; diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 2259cbc16..4668b875d 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -6797,7 +6797,7 @@ class AttributeTagSet extends AttributeDBFieldVoid $aAllowedValues = array(); foreach($aAllowedTags as $oAllowedTag) { - $aAllowedValues[$oAllowedTag->Get('tag_code')] = $oAllowedTag->Get('tag_label'); + $aAllowedValues[$oAllowedTag->Get('code')] = $oAllowedTag->Get('label'); } return $aAllowedValues; @@ -7086,9 +7086,9 @@ class AttributeTagSet extends AttributeDBFieldVoid $sTagLabel = $sTagCode; foreach($aAllowedTags as $oTag) { - if ($sTagCode === $oTag->Get('tag_code')) + if ($sTagCode === $oTag->Get('code')) { - $sTagLabel = $oTag->Get('tag_label'); + $sTagLabel = $oTag->Get('label'); } } $aRemoved[] = $sTagLabel; @@ -7115,9 +7115,9 @@ class AttributeTagSet extends AttributeDBFieldVoid $sTagLabel = $sTagCode; foreach($aAllowedTags as $oTag) { - if ($sTagCode === $oTag->Get('tag_code')) + if ($sTagCode === $oTag->Get('code')) { - $sTagLabel = $oTag->Get('tag_label'); + $sTagLabel = $oTag->Get('label'); } } $aAdded[] = $sTagLabel; @@ -7153,7 +7153,7 @@ class AttributeTagSet extends AttributeDBFieldVoid { $sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()); $sAttCode = $this->GetCode(); - $sTagCode = $oTag->Get('tag_code'); + $sTagCode = $oTag->Get('code'); $oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'"); $oAppContext = new ApplicationContext(); $sContext = $oAppContext->GetForLink(); @@ -7161,7 +7161,7 @@ class AttributeTagSet extends AttributeDBFieldVoid $sFilter = urlencode($oFilter->serialize()); $sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}"; - $sHtml .= ''.$oTag->Get('tag_label').''; + $sHtml .= ''.$oTag->Get('label').''; } else { diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index 30b94195f..be3f2c6ca 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -954,8 +954,8 @@ class ScalarExpression extends UnaryExpression $aTags = $oValue->GetTags(); foreach($aTags as $oTag) { - $aValue['label'] = $oTag->Get('tag_label'); - $aValue['value'] = $oTag->Get('tag_code'); + $aValue['label'] = $oTag->Get('label'); + $aValue['value'] = $oTag->Get('code'); $aValues[] = $aValue; } $aCriterion['values'] = $aValues; diff --git a/core/ormtagset.class.inc.php b/core/ormtagset.class.inc.php index 729063533..8f9c5e667 100644 --- a/core/ormtagset.class.inc.php +++ b/core/ormtagset.class.inc.php @@ -187,7 +187,7 @@ final class ormTagSet { try { - $aTags[$sTagCode] = $oTag->Get('tag_label'); + $aTags[$sTagCode] = $oTag->Get('label'); } catch (CoreException $e) { IssueLog::Error($e->getMessage()); @@ -197,7 +197,7 @@ final class ormTagSet { try { - $aTags[$sTagCode] = $oTag->Get('tag_label'); + $aTags[$sTagCode] = $oTag->Get('label'); } catch (CoreException $e) { IssueLog::Error($e->getMessage()); @@ -537,7 +537,7 @@ final class ormTagSet $aAllowedTags = $this->GetAllowedTags(); foreach($aAllowedTags as $oAllowedTag) { - if ($oAllowedTag->Get('tag_code') === $sTagCode) + if ($oAllowedTag->Get('code') === $sTagCode) { return $oAllowedTag; } @@ -557,9 +557,9 @@ final class ormTagSet $aAllowedTags = $this->GetAllowedTags(); foreach($aAllowedTags as $oAllowedTag) { - if ($oAllowedTag->Get('tag_label') === $sTagLabel) + if ($oAllowedTag->Get('label') === $sTagLabel) { - return $oAllowedTag->Get('tag_code'); + return $oAllowedTag->Get('code'); } } throw new CoreUnexpectedValue("{$sTagLabel} is not defined as a valid tag for {$this->sClass}:{$this->sAttCode}"); diff --git a/core/tagsetfield.class.inc.php b/core/tagsetfield.class.inc.php index 90e05e0d0..55ce3f8e1 100644 --- a/core/tagsetfield.class.inc.php +++ b/core/tagsetfield.class.inc.php @@ -40,9 +40,9 @@ abstract class TagSetFieldData extends cmdbAbstractObject ( 'category' => 'bizmodel', 'key_type' => 'autoincrement', - 'name_attcode' => array('tag_label'), + 'name_attcode' => array('label'), 'state_attcode' => '', - 'reconc_keys' => array('tag_code'), + 'reconc_keys' => array('code'), 'db_table' => 'priv_tagfielddata', 'db_key_field' => 'id', 'db_finalclass_field' => 'finalclass', @@ -51,54 +51,54 @@ abstract class TagSetFieldData extends cmdbAbstractObject MetaModel::Init_Params($aParams); MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeString("tag_code", array( + MetaModel::Init_AddAttribute(new AttributeString("code", array( "allowed_values" => null, - "sql" => 'tag_code', + "sql" => 'code', "default_value" => '', "is_null_allowed" => false, "depends_on" => array() ))); - MetaModel::Init_AddAttribute(new AttributeString("tag_label", array( + MetaModel::Init_AddAttribute(new AttributeString("label", array( "allowed_values" => null, - "sql" => 'tag_label', + "sql" => 'label', "default_value" => '', "is_null_allowed" => false, "depends_on" => array() ))); - MetaModel::Init_AddAttribute(new AttributeString("tag_description", array( + MetaModel::Init_AddAttribute(new AttributeString("description", array( "allowed_values" => null, - "sql" => 'tag_description', + "sql" => 'description', "default_value" => '', "is_null_allowed" => true, "depends_on" => array() ))); - MetaModel::Init_AddAttribute(new AttributeString("tag_class", array( + MetaModel::Init_AddAttribute(new AttributeString("obj_class", array( "allowed_values" => null, - "sql" => 'tag_class', + "sql" => 'obj_class', "default_value" => '', "is_null_allowed" => false, "depends_on" => array() ))); - MetaModel::Init_AddAttribute(new AttributeString("tag_attcode", array( + MetaModel::Init_AddAttribute(new AttributeString("obj_attcode", array( "allowed_values" => null, - "sql" => 'tag_attcode', + "sql" => 'obj_attcode', "default_value" => '', "is_null_allowed" => false, "depends_on" => array() ))); - MetaModel::Init_SetZListItems('details', array('tag_code', 'tag_label', 'tag_description')); - MetaModel::Init_SetZListItems('standard_search', array('tag_code', 'tag_label', 'tag_description')); - MetaModel::Init_SetZListItems('list', array('tag_code', 'tag_label', 'tag_description')); + MetaModel::Init_SetZListItems('details', array('code', 'label', 'description')); + MetaModel::Init_SetZListItems('standard_search', array('code', 'label', 'description')); + MetaModel::Init_SetZListItems('list', array('code', 'label', 'description')); } public function ComputeValues() { $sClassName = get_class($this); $aRes = static::ExtractTagFieldName($sClassName); - $this->_Set('tag_class', $aRes['tag_class']); - $this->_Set('tag_attcode', $aRes['tag_attcode']); + $this->_Set('obj_class', $aRes['obj_class']); + $this->_Set('obj_attcode', $aRes['obj_attcode']); } public static function GetTagDataClassName($sClass, $sAttCode) @@ -122,8 +122,8 @@ abstract class TagSetFieldData extends cmdbAbstractObject // Extract class and attcode from class name using pattern TagSetFieldDataFor__>; if (preg_match('@^TagSetFieldDataFor_(?\w+)__(?\w+)$@', $sClassName, $aMatches)) { - $aRes['tag_class'] = $aMatches['class']; - $aRes['tag_attcode'] = $aMatches['attcode']; + $aRes['obj_class'] = $aMatches['class']; + $aRes['obj_attcode'] = $aMatches['attcode']; } else { @@ -141,9 +141,9 @@ abstract class TagSetFieldData extends cmdbAbstractObject { parent::DoCheckToDelete($oDeletionPlan); - $sTagCode = $this->Get('tag_code'); - $sClass = $this->Get('tag_class'); - $sAttCode = $this->Get('tag_attcode'); + $sTagCode = $this->Get('code'); + $sClass = $this->Get('obj_class'); + $sAttCode = $this->Get('obj_attcode'); $oSearch = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'"); $oSet = new DBObjectSet($oSearch); if ($oSet->CountExceeds(0)) @@ -166,8 +166,8 @@ abstract class TagSetFieldData extends cmdbAbstractObject public function DoCheckToWrite() { $this->ComputeValues(); - $sClass = $this->Get('tag_class'); - $sAttCode = $this->Get('tag_attcode'); + $sClass = $this->Get('obj_class'); + $sAttCode = $this->Get('obj_attcode'); $iMaxLen = 20; $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); if ($oAttDef instanceof AttributeTagSet) @@ -175,14 +175,14 @@ abstract class TagSetFieldData extends cmdbAbstractObject $iMaxLen = $oAttDef->GetTagCodeMaxLength(); } - $sTagCode = $this->Get('tag_code'); - // Check tag_code syntax + $sTagCode = $this->Get('code'); + // Check code syntax if (!preg_match("@^[a-zA-Z0-9]{3,$iMaxLen}$@", $sTagCode)) { $this->m_aCheckIssues[] = Dict::Format('Core:TagSetFieldData:ErrorTagCodeSyntax', $iMaxLen); } - $sTagLabel = $this->Get('tag_label'); + $sTagLabel = $this->Get('label'); $sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator'); if (empty($sTagLabel) || (strpos($sTagLabel, $sSepItem) !== false)) { @@ -195,11 +195,11 @@ abstract class TagSetFieldData extends cmdbAbstractObject $sClassName = get_class($this); if (empty($id)) { - $oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE (tag_code = '$sTagCode' OR tag_label = '$sTagLabel')"); + $oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE (code = '$sTagCode' OR label = '$sTagLabel')"); } else { - $oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE id != $id AND (tag_code = '$sTagCode' OR tag_label = '$sTagLabel')"); + $oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE id != $id AND (code = '$sTagCode' OR label = '$sTagLabel')"); } $oSet = new DBObjectSet($oSearch); if ($oSet->CountExceeds(0)) @@ -220,7 +220,7 @@ abstract class TagSetFieldData extends cmdbAbstractObject { parent::OnUpdate(); $aChanges = $this->ListChanges(); - if (array_key_exists('tag_code', $aChanges)) + if (array_key_exists('code', $aChanges)) { throw new CoreException(Dict::S('Core:TagSetFieldData:ErrorCodeUpdateNotAllowed')); } @@ -244,9 +244,9 @@ abstract class TagSetFieldData extends cmdbAbstractObject parent::DisplayBareRelations($oPage, $bEditMode); if (!$bEditMode) { - $sClass = $this->Get('tag_class'); - $sAttCode = $this->Get('tag_attcode'); - $sTagCode = $this->Get('tag_code'); + $sClass = $this->Get('obj_class'); + $sAttCode = $this->Get('obj_attcode'); + $sTagCode = $this->Get('code'); $oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'"); $oSet = new DBObjectSet($oFilter); $iCount = $oSet->Count(); @@ -259,7 +259,7 @@ abstract class TagSetFieldData extends cmdbAbstractObject else { $aClassLabels = array(); - foreach(MetaModel::EnumChildClasses($sClass) as $sCurrentClass) + foreach(MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sCurrentClass) { $aClassLabels[$sCurrentClass] = MetaModel::GetName($sCurrentClass); } @@ -288,8 +288,8 @@ abstract class TagSetFieldData extends cmdbAbstractObject { return $sClass; } - $sClassDesc = MetaModel::GetName($aTagFieldInfo['tag_class']); - $sAttDesc = MetaModel::GetAttributeDef($aTagFieldInfo['tag_class'], $aTagFieldInfo['tag_attcode'])->GetLabel(); + $sClassDesc = MetaModel::GetName($aTagFieldInfo['obj_class']); + $sAttDesc = MetaModel::GetAttributeDef($aTagFieldInfo['obj_class'], $aTagFieldInfo['obj_attcode'])->GetLabel(); if (Dict::Exists("Class:$sClass")) { $sName = Dict::Format("Class:$sClass", $sClassDesc, $sAttDesc); @@ -317,8 +317,8 @@ abstract class TagSetFieldData extends cmdbAbstractObject if (!isset(self::$m_aAllowedValues[$sTagDataClass])) { $oSearch = new DBObjectSearch($sTagDataClass); - $oSearch->AddCondition('tag_class', $sClass); - $oSearch->AddCondition('tag_attcode', $sAttCode); + $oSearch->AddCondition('obj_class', $sClass); + $oSearch->AddCondition('obj_attcode', $sAttCode); $oSet = new DBObjectSet($oSearch); self::$m_aAllowedValues[$sTagDataClass] = $oSet->ToArray(); } diff --git a/pages/tagadmin.php b/pages/tagadmin.php index 02888dac0..7652ae9ff 100644 --- a/pages/tagadmin.php +++ b/pages/tagadmin.php @@ -63,7 +63,7 @@ try $sSearchHeaderForceDropdown = '