Merge branch 'feature/AttributeSet' into feature/b931

# Conflicts:
#	core/attributedef.class.inc.php
This commit is contained in:
Eric
2018-09-27 15:29:27 +02:00
19 changed files with 1258 additions and 455 deletions

View File

@@ -1654,12 +1654,8 @@ EOF
* @throws \CoreException
* @throws \DictExceptionMissingString
*/
public static function GetFormElementForField(
$oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '',
$iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true
) {
static $iInputId = 0;
$sFieldPrefix = '';
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true)
{
$sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : '';
$sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix;
if ($sDisplayValue == '')
@@ -1958,8 +1954,7 @@ EOF
if ($bPreserveCurrentValue)
{
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '',
$value);
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value);
}
else
{
@@ -2038,6 +2033,7 @@ EOF
$oPage->add_ready_script("$('#{$iId}').bind('validate', function(evt, sFormId) { return ValidateCustomFields('$iId', sFormId) } );"); // Custom validation function
break;
case 'Set':
case 'TagSet':
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/selectize.min.js');
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css');
@@ -2045,32 +2041,19 @@ EOF
$oPage->add_dict_entry('Core:AttributeSet:placeholder');
/** @var \ormTagSet $value */
$sJson = $oAttDef->GetJsonForWidget($value);
/** @var \ormSet $value */
$sJson = $oAttDef->GetJsonForWidget($value, $aArgs);
$sInputId = "attr_{$sFormPrefix}{$sAttCode}";
$sHTMLValue = "<div class=\"field_input_zone field_input_tagset\"><input id='$sInputId' name='$sInputId' type='hidden' value='$sJson'></div>{$sValidationSpan}{$sReloadSpan}";
$sScript = "$('#$sInputId').set_widget();";
$oPage->add_ready_script($sScript);
break;
case 'ObjectAttcodeSet':
$iFieldSize = $oAttDef->GetMaxSize();
if (is_array($sDisplayValue))
{
$sDisplayValue = implode(', ', $sDisplayValue);
}
$sHTMLValue = "<div class=\"field_input_zone field_input_string\"><input title=\"$sHelpText\" type=\"text\" maxlength=\"$iFieldSize\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" value=\"".htmlentities($sDisplayValue, ENT_QUOTES, 'UTF-8')."\" id=\"$iId\"/></div>{$sValidationSpan}{$sReloadSpan}";
$aEventsList[] ='validate';
$aEventsList[] ='keyup';
$aEventsList[] ='change';
break;
case 'String':
default:
$aEventsList[] = 'validate';
// #@# todo - add context information (depending on dimensions)
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
$aAllowedValues = $oAttDef->GetAllowedValues($aArgs);
$iFieldSize = $oAttDef->GetMaxSize();
if ($aAllowedValues !== null)
{
@@ -3315,6 +3298,17 @@ EOF
$this->Set($sAttCode, $oTagSet);
break;
case 'Set':
/** @var ormSet $oSet */
$oSet = $this->Get($sAttCode);
if (is_null($oSet))
{
$oSet = new ormSet(get_class($this), $sAttCode);
}
$oSet->ApplyDelta($value);
$this->Set($sAttCode, $oSet);
break;
default:
if (!is_null($value))
{
@@ -3505,6 +3499,7 @@ EOF
);
break;
case 'Set':
case 'TagSet':
$sTagSetJson = utils::ReadPostedParam("attr_{$sFormPrefix}{$sAttCode}", null, 'raw_data');
$value = json_decode($sTagSetJson, true);
@@ -3960,9 +3955,9 @@ EOF
{
$currValue = ' '; // Don't put an empty string, in case the field would be considered as mandatory...
}
elseif ($currValue instanceof ormTagSet)
elseif ($currValue instanceof ormSet)
{
$currValue = implode(' ', $currValue->GetValue());
$currValue = $oAttDef->GetEditValue($currValue, $oObj);
}
if (is_object($currValue))
{
@@ -3998,7 +3993,6 @@ EOF
$iFormId = cmdbAbstractObject::GetNextFormId(); // Identifier that prefixes all the form fields
$sReadyScript = '';
$aDependsOn = array();
$sFormPrefix = '2_';
foreach($aList as $sAttCode => $oAttDef)
{
@@ -4077,7 +4071,7 @@ EOF
$sTip = addslashes($sTip);
$sReadyScript .= "$('#multi_values_$sAttCode').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );";
if ($oAttDef->GetEditClass() == 'TagSet')
if (($oAttDef->GetEditClass() == 'TagSet') || ($oAttDef->GetEditClass() == 'Set'))
{
// Set the value by adding the values to the first one
reset($aMultiValues);
@@ -4092,12 +4086,8 @@ EOF
{
continue;
}
$aTagCodes = array();
if (!empty($sValues))
{
$aTagCodes = explode(' ', $sValues);
}
$oTagSet->GenerateDiffFromTags($aTagCodes);
$aTagCodes = $oAttDef->FromStringToArray($sValues);
$oTagSet->GenerateDiffFromArray($aTagCodes);
}
$oDummyObj->Set($sAttCode, $oTagSet);
}

View File

@@ -262,7 +262,7 @@ EOF
// Attribute tag tooltips
$this->add_ready_script(
<<<EOF
$('.attribute-tag').each(function(){
$('.attribute-set-item').each(function(){
$(this).qtip({
content: {
text: $(this).attr('data-description'),

View File

@@ -47,7 +47,7 @@ abstract class Query extends cmdbAbstractObject
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("fields", array("allowed_values"=>null, "sql"=>"fields", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeQueryAttCodeSet("fields", array("allowed_values"=>null,"max_items" => 1000, "query_field" => "oql", "sql"=>"fields", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array('oql'))));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'fields')); // Attributes to be displayed for the complete details

File diff suppressed because it is too large Load Diff

View File

@@ -417,8 +417,8 @@ abstract class CMDBObject extends DBObject
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
$oMyChangeOp->Set("oldvalue", implode(' ', $original->GetValue()));
$oMyChangeOp->Set("newvalue", implode(' ', $value->GetValue()));
$oMyChangeOp->Set("oldvalue", implode(' ', $original->GetValues()));
$oMyChangeOp->Set("newvalue", implode(' ', $value->GetValues()));
$iId = $oMyChangeOp->DBInsertNoReload();
}
else

View File

@@ -1285,7 +1285,7 @@ abstract class DBObject implements iDisplay
$oTag = new ormTagSet(get_class($this), $sAttCode);
try
{
$oTag->SetValue(explode(' ', $toCheck));
$oTag->SetValues(explode(' ', $toCheck));
} catch (Exception $e)
{
return "Tag value '$toCheck' is not a valid tag list";
@@ -1301,6 +1301,34 @@ abstract class DBObject implements iDisplay
return "Bad type";
}
elseif ($oAtt instanceof AttributeClassAttCodeSet)
{
if (is_string($toCheck))
{
$oTag = new ormSet(get_class($this), $sAttCode);
try
{
$aValues = array();
foreach(explode(',', $toCheck) as $sValue)
{
$aValues[] = trim($sValue);
}
$oTag->SetValues($aValues);
} catch (Exception $e)
{
return "Set value '$toCheck' is not a valid set";
}
return true;
}
if ($toCheck instanceof ormSet)
{
return true;
}
return "Bad type";
}
elseif ($oAtt->IsScalar())
{
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
@@ -2213,6 +2241,17 @@ abstract class DBObject implements iDisplay
if (!MetaModel::DBIsReadOnly())
{
$this->OnDelete();
// Activate any existing trigger
$sClass = get_class($this);
$sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectDelete AS t WHERE t.target_class IN ('$sClassList')"));
while ($oTrigger = $oSet->Fetch())
{
/** @var \Trigger $oTrigger */
$oTrigger->DoActivate($this->ToArgs('this'));
}
$this->RecordObjDeletion($this->m_iKey); // May cause a reload for storing history information
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)

View File

@@ -677,7 +677,7 @@ class BinaryExpression extends Expression
}
}
}
if (isset($aCriteriaLeft['widget']) && isset($aCriteriaRight['widget']) && ($aCriteriaLeft['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_TAG_SET) && ($aCriteriaRight['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_TAG_SET))
if (isset($aCriteriaLeft['widget']) && isset($aCriteriaRight['widget']) && ($aCriteriaLeft['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_SET) && ($aCriteriaRight['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_SET))
{
$aCriteriaOverride['operator'] = 'MATCHES';
}

382
core/ormset.class.inc.php Normal file
View File

@@ -0,0 +1,382 @@
<?php
/**
* Copyright (c) 2010-2018 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*
*/
/**
* Created by PhpStorm.
* Date: 24/08/2018
* Time: 14:35
*/
class ormSet
{
protected $sClass; // class of the field
protected $sAttCode; // attcode of the field
protected $aOriginalObjects = null;
/**
* Object from the original set, minus the removed objects
*/
protected $aPreserved = array();
/**
* New items
*/
protected $aAdded = array();
/**
* Removed items
*/
protected $aRemoved = array();
/**
* Modified items (mass edit)
*/
protected $aModified = array();
/**
* @var int Max number of tags in collection
*/
protected $iLimit;
/**
* __toString magical function overload.
*/
public function __toString()
{
$aValue = $this->GetValues();
if (!empty($aValue))
{
return implode(', ', $aValue);
}
else
{
return ' ';
}
}
/**
* ormSet constructor.
*
* @param string $sClass
* @param string $sAttCode
* @param int $iLimit
*
* @throws \Exception
*/
public function __construct($sClass, $sAttCode, $iLimit = 12)
{
$this->sAttCode = $sAttCode;
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (!$oAttDef instanceof AttributeSet)
{
throw new Exception("ormSet: field {$sClass}:{$sAttCode} is not a set");
}
$this->sClass = $sClass;
$this->iLimit = $iLimit;
}
/**
* @return string
*/
public function GetClass()
{
return $this->sClass;
}
/**
* @return string
*/
public function GetAttCode()
{
return $this->sAttCode;
}
/**
*
* @param array $aItems
*
* @throws \CoreException
* @throws \CoreUnexpectedValue when a code is invalid
*/
public function SetValues($aItems)
{
if (!is_array($aItems))
{
throw new CoreUnexpectedValue("Wrong value {$aItems} for {$this->sClass}:{$this->sAttCode}");
}
$oValues = array();
$iCount = 0;
$bError = false;
foreach($aItems as $oItem)
{
$iCount++;
if (($this->iLimit != 0) && ($iCount > $this->iLimit))
{
$bError = true;
continue;
}
$oValues[] = $oItem;
}
$this->aPreserved = &$oValues;
$this->aRemoved = array();
$this->aAdded = array();
$this->aModified = array();
$this->aOriginalObjects = $oValues;
if ($bError)
{
throw new CoreException("Maximum number of items ({$this->iLimit}) reached for {$this->sClass}:{$this->sAttCode}");
}
}
public function Count()
{
return count($this->aPreserved) + count($this->aAdded) - count($this->aRemoved);
}
/**
* @return array of codes
*/
public function GetValues()
{
$aValues = array_merge($this->aPreserved, $this->aAdded);
sort($aValues);
return $aValues;
}
/**
* @return array of tag labels indexed by code for only the added tags
*/
private function GetAdded()
{
return $this->aAdded;
}
/**
* @return array of tag labels indexed by code for only the removed tags
*/
private function GetRemoved()
{
return $this->aRemoved;
}
/** Get the delta with another ItemSet
*
* $aDelta['added] = array of tag codes for only the added tags
* $aDelta['removed'] = array of tag codes for only the removed tags
*
* @param \ormSet $oOtherSet
*
* @return array
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \Exception
*/
public function GetDelta(ormSet $oOtherSet)
{
$oSet = new ormSet($this->sClass, $this->sAttCode);
// Set the initial value
$aOrigItems = $this->GetValues();
$oSet->SetValues($aOrigItems);
// now remove everything
foreach($aOrigItems as $oItem)
{
$oSet->Remove($oItem);
}
// now add the tags of the other ItemSet
foreach($oOtherSet->GetValues() as $oItem)
{
$oSet->Add($oItem);
}
$aDelta = array();
$aDelta['added'] = $oSet->GetAdded();
$aDelta['removed'] = $oSet->GetRemoved();
return $aDelta;
}
/**
* @return string[] list of codes for partial entries
*/
public function GetModified()
{
return $this->aModified;
}
/**
* Apply a delta to the current ItemSet
* $aDelta['added] = array of added items
* $aDelta['removed'] = array of removed items
*
* @param $aDelta
*
* @throws \CoreException
*/
public function ApplyDelta($aDelta)
{
if (isset($aDelta['removed']))
{
foreach($aDelta['removed'] as $oItem)
{
$this->Remove($oItem);
}
}
if (isset($aDelta['added']))
{
foreach($aDelta['added'] as $oItem)
{
$this->Add($oItem);
}
}
// Reset the object
$this->SetValues($this->GetValues());
}
/**
* @param string $oItem
*
* @throws \CoreException
*/
public function Add($oItem)
{
if ($this->Count() === $this->iLimit)
{
throw new CoreException("Maximum number of items ({$this->iLimit}) reached for {$this->sClass}:{$this->sAttCode}");
}
if ($this->IsItemInList($this->aPreserved, $oItem) || $this->IsItemInList($this->aAdded, $oItem))
{
// nothing to do, already existing tag
return;
}
// if removed and added again
if (($this->RemoveItemFromList($this->aRemoved, $oItem)) !== false)
{
// put it back into preserved
$this->aPreserved[] = $oItem;
// no need to add it to aModified : was already done when calling RemoveItem method
}
else
{
$this->aAdded[] = $oItem;
$this->aModified[] = $oItem;
}
}
/**
* @param $oItem
*/
public function Remove($oItem)
{
if ($this->IsItemInList($this->aRemoved, $oItem))
{
// nothing to do, already removed tag
return;
}
if ($this->RemoveItemFromList($this->aAdded, $oItem) !== false)
{
$this->aModified[] = $oItem;
return; // if present in added, can't be in preserved !
}
if ($this->RemoveItemFromList($this->aPreserved, $oItem) !== false)
{
$this->aModified[] = $oItem;
$this->aRemoved[] = $oItem;
}
}
private function IsItemInList($aItemList, $oItem)
{
return in_array($oItem, $aItemList);
}
/**
* @param \DBObject[] $aItemList
* @param $oItem
*
* @return bool|\DBObject false if not found, else the removed element
*/
private function RemoveItemFromList(&$aItemList, $oItem)
{
if (!($this->IsItemInList($aItemList, $oItem)))
{
return false;
}
foreach ($aItemList as $index => $value)
{
if ($value === $oItem)
{
unset($aItemList[$index]);
return $oItem;
}
}
return false;
}
/**
* Populates the added and removed arrays for bulk edit
*
* @param string[] $aItems
*
* @throws \CoreException
*/
public function GenerateDiffFromArray($aItems)
{
foreach($this->GetValues() as $oCurrentItem)
{
if (!in_array($oCurrentItem, $aItems))
{
$this->Remove($oCurrentItem);
}
}
foreach($aItems as $oNewItem)
{
$this->Add($oNewItem);
}
}
/**
* Compare Item Set
*
* @param \ormSet $other
*
* @return bool true if same tag set
*/
public function Equals(ormSet $other)
{
return implode(', ', $this->GetValue()) === implode(', ', $other->GetValue());
}
}

View File

@@ -24,55 +24,8 @@
* Date: 24/08/2018
* Time: 14:35
*/
final class ormTagSet
final class ormTagSet extends ormSet
{
private $sClass; // class of the tag field
private $sAttCode; // attcode of the tag field
private $aOriginalObjects = null;
/**
* Object from the original set, minus the removed objects
*
* @var DBObject[] array of iObjectId => DBObject
*/
private $aPreserved = array();
/**
* @var DBObject[] New items
*/
private $aAdded = array();
/**
* @var DBObject[] Removed items
*/
private $aRemoved = array();
/**
* @var DBObject[] Modified items (mass edit)
*/
private $aModified = array();
/**
* @var int Max number of tags in collection
*/
private $iLimit;
/**
* __toString magical function overload.
*/
public function __toString()
{
$aValue = $this->GetValue();
if (!empty($aValue))
{
return implode(' ', $aValue);
}
else
{
return ' ';
}
}
/**
* ormTagSet constructor.
*
@@ -84,31 +37,7 @@ final class ormTagSet
*/
public function __construct($sClass, $sAttCode, $iLimit = 12)
{
$this->sAttCode = $sAttCode;
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (!$oAttDef instanceof AttributeTagSet)
{
throw new Exception("ormTagSet: field {$sClass}:{$sAttCode} is not a tag");
}
$this->sClass = $sClass;
$this->iLimit = $iLimit;
}
/**
* @return string
*/
public function GetClass()
{
return $this->sClass;
}
/**
* @return string
*/
public function GetAttCode()
{
return $this->sAttCode;
parent::__construct($sClass, $sAttCode, $iLimit);
}
/**
@@ -118,7 +47,7 @@ final class ormTagSet
* @throws \CoreException
* @throws \CoreUnexpectedValue when a code is invalid
*/
public function SetValue($aTagCodes)
public function SetValues($aTagCodes)
{
if (!is_array($aTagCodes))
{
@@ -152,15 +81,10 @@ final class ormTagSet
}
}
private function GetCount()
{
return count($this->aPreserved) + count($this->aAdded) - count($this->aRemoved);
}
/**
* @return array of tag codes
*/
public function GetValue()
public function GetValues()
{
$aValues = array();
foreach($this->aPreserved as $sTagCode => $oTag)
@@ -183,6 +107,7 @@ final class ormTagSet
public function GetLabels()
{
$aTags = array();
/** @var \TagSetFieldData $oTag */
foreach($this->aPreserved as $sTagCode => $oTag)
{
try
@@ -300,21 +225,21 @@ final class ormTagSet
* @throws \CoreUnexpectedValue
* @throws \Exception
*/
public function GetDelta(ormTagSet $oOtherTagSet)
public function GetDelta(ormSet $oOtherTagSet)
{
$oTag = new ormTagSet($this->sClass, $this->sAttCode);
// Set the initial value
$aOrigTagCodes = $this->GetValue();
$oTag->SetValue($aOrigTagCodes);
$aOrigTagCodes = $this->GetValues();
$oTag->SetValues($aOrigTagCodes);
// now remove everything
foreach($aOrigTagCodes as $sTagCode)
{
$oTag->RemoveTag($sTagCode);
$oTag->Remove($sTagCode);
}
// now add the tags of the other TagSet
foreach($oOtherTagSet->GetValue() as $sTagCode)
foreach($oOtherTagSet->GetValues() as $sTagCode)
{
$oTag->AddTag($sTagCode);
$oTag->Add($sTagCode);
}
$aDelta = array();
$aDelta['added'] = $oTag->GetAddedCodes();
@@ -340,17 +265,17 @@ final class ormTagSet
{
$oTag = new ormTagSet($this->sClass, $this->sAttCode);
// Set the initial value
$aOrigTagCodes = $this->GetValue();
$oTag->SetValue($aOrigTagCodes);
$aOrigTagCodes = $this->GetValues();
$oTag->SetValues($aOrigTagCodes);
// now remove everything
foreach($aOrigTagCodes as $sTagCode)
{
$oTag->RemoveTag($sTagCode);
$oTag->Remove($sTagCode);
}
// now add the tags of the other TagSet
foreach($oOtherTagSet->GetValue() as $sTagCode)
foreach($oOtherTagSet->GetValues() as $sTagCode)
{
$oTag->AddTag($sTagCode);
$oTag->Add($sTagCode);
}
$aDelta = array();
$aDelta['added'] = $oTag->GetAddedTags();
@@ -362,7 +287,7 @@ final class ormTagSet
/**
* @return string[] list of codes for partial entries
*/
public function GetModifiedTags()
public function GetModified()
{
$aModifiedTagCodes = array_keys($this->aModified);
sort($aModifiedTagCodes);
@@ -370,34 +295,6 @@ final class ormTagSet
return $aModifiedTagCodes;
}
/**
* Apply a delta to the current TagSet
* $aDelta['added] = array of tag code for only the added tags
* $aDelta['removed'] = array of tag code for only the removed tags
*
* @param $aDelta
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
*/
public function ApplyDelta($aDelta)
{
if (isset($aDelta['removed']))
{
foreach($aDelta['removed'] as $sTagCode)
{
$this->RemoveTag($sTagCode);
}
}
if (isset($aDelta['added']))
{
foreach($aDelta['added'] as $sTagCode)
{
$this->AddTag($sTagCode);
}
}
}
/**
* Check whether a tag code is valid or not for this TagSet
*
@@ -424,9 +321,9 @@ final class ormTagSet
* @throws \CoreException
* @throws \CoreUnexpectedValue
*/
public function AddTag($sTagCode)
public function Add($sTagCode)
{
if ($this->GetCount() === $this->iLimit)
if ($this->Count() === $this->iLimit)
{
throw new CoreException("Maximum number of tags ({$this->iLimit}) reached for {$this->sClass}:{$this->sAttCode}");
}
@@ -440,7 +337,7 @@ final class ormTagSet
{
// put it back into preserved
$this->aPreserved[$sTagCode] = $oTag;
// no need to add it to aModified : was already done when calling RemoveTag method
// no need to add it to aModified : was already done when calling Remove method
}
else
{
@@ -453,7 +350,7 @@ final class ormTagSet
/**
* @param $sTagCode
*/
public function RemoveTag($sTagCode)
public function Remove($sTagCode)
{
if ($this->IsTagInList($this->aRemoved, $sTagCode))
{
@@ -501,30 +398,6 @@ final class ormTagSet
return $oTag;
}
/**
* Populates the added and removed arrays for bulk edit
*
* @param string[] $aTagCodes
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
*/
public function GenerateDiffFromTags($aTagCodes)
{
foreach($this->GetValue() as $sCurrentTagCode)
{
if (!in_array($sCurrentTagCode, $aTagCodes))
{
$this->RemoveTag($sCurrentTagCode);
}
}
foreach($aTagCodes as $sNewTagCode)
{
$this->AddTag($sNewTagCode);
}
}
/**
* @param $sTagCode
*
@@ -583,14 +456,18 @@ final class ormTagSet
*
* @return bool true if same tag set
*/
public function Equals(ormTagSet $other)
public function Equals(ormSet $other)
{
if (!($other instanceof ormTagSet))
{
return false;
}
if ($this->GetTagDataClass() !== $other->GetTagDataClass())
{
return false;
}
return implode(' ', $this->GetValue()) === implode(' ', $other->GetValue());
return implode(' ', $this->GetValues()) === implode(' ', $other->GetValues());
}
public function GetTagDataClass()

View File

@@ -214,13 +214,14 @@ abstract class TagSetFieldData extends cmdbAbstractObject
$sClassName = get_class($this);
if (empty($id))
{
$oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE (code = '$sTagCode' OR label = '$sTagLabel')");
$oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE (code = :tag_code OR label = :tag_label)");
}
else
{
$oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE id != $id AND (code = '$sTagCode' OR label = '$sTagLabel')");
$oSearch = DBSearch::FromOQL("SELECT $sClassName WHERE id != :id AND (code = :tag_code OR label = :tag_label)");
}
$oSet = new DBObjectSet($oSearch);
$aArgs = array('id' => $id, 'tag_code' => $sTagCode, 'tag_label' => $sTagLabel);
$oSet = new DBObjectSet($oSearch, array(), $aArgs);
if ($oSet->CountExceeds(0))
{
$this->m_aCheckIssues[] = Dict::S('Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel');
@@ -277,7 +278,6 @@ abstract class TagSetFieldData extends cmdbAbstractObject
return false;
}
/**
* Display Tag Usage
*
@@ -333,6 +333,11 @@ abstract class TagSetFieldData extends cmdbAbstractObject
public static function GetClassName($sClass)
{
if ($sClass == 'TagSetFieldData')
{
$aWords = preg_split('/(?=[A-Z]+)/', $sClass);
return trim(implode(' ', $aWords));
}
try
{
$aTagFieldInfo = self::ExtractTagFieldName($sClass);

View File

@@ -289,7 +289,7 @@ abstract class TriggerOnStateChange extends TriggerOnObject
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("state", array("allowed_values" => null, "sql" => "state", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
MetaModel::Init_AddAttribute(new AttributeClassState("state", array("class_field" => 'target_class', "allowed_values" => null, "sql" => "state", "default_value" => null, "is_null_allowed" => false, "depends_on" => array('target_class'))));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'state', 'action_list')); // Attributes to be displayed for the complete details
@@ -402,6 +402,40 @@ class TriggerOnObjectCreate extends TriggerOnObject
}
}
/**
* Class TriggerOnObjectCreate
*/
class TriggerOnObjectDelete extends TriggerOnObject
{
/**
* @throws \CoreException
*/
public static function Init()
{
$aParams = array
(
"category" => "grant_by_profile,core/cmdb,application",
"key_type" => "autoincrement",
"name_attcode" => "description",
"state_attcode" => "",
"reconc_keys" => array('description'),
"db_table" => "priv_trigger_onobjdelete",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'action_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'target_class')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('description', 'target_class')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
/**
* Class TriggerOnObjectCreate
*/
@@ -427,7 +461,7 @@ class TriggerOnObjectUpdate extends TriggerOnObject
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeObjectAttCodeSet('target_attcodes', array("allowed_values" => null, "class" => "target_class", "sql" => "target_attcodes", "default_value" => null, "is_null_allowed" => true, "depends_on" => array('target_class'))));
MetaModel::Init_AddAttribute(new AttributeClassAttCodeSet('target_attcodes', array("allowed_values" => null, "class_field" => "target_class", "sql" => "target_attcodes", "default_value" => null, "is_null_allowed" => true, "max_items" => 20, "min_items" => 0, "attribute_definition_list" => null, "depends_on" => array('target_class'))));
// Display lists
MetaModel::Init_SetZListItems('details', array('description', 'target_class', 'filter', 'target_attcodes', 'action_list')); // Attributes to be displayed for the complete details
@@ -444,11 +478,13 @@ class TriggerOnObjectUpdate extends TriggerOnObject
}
// Check the attribute
$aAttCodes = $this->Get('target_attcodes');
$oAttCodeSet = $this->Get('target_attcodes');
$aAttCodes = $oAttCodeSet->GetValues();
if (empty($aAttCodes))
{
return true;
}
foreach($aAttCodes as $sAttCode)
{
if (array_key_exists($sAttCode, $aChanges))

View File

@@ -200,6 +200,7 @@
<sql>tagfield</sql>
<is_null_allowed>true</is_null_allowed>
<tracking_level>all</tracking_level>
<max_items>12</max_items>
</field>
</fields>
<methods>

View File

@@ -588,6 +588,15 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:TriggerOnObjectCreate+' => 'Trigger on object creation of [a child class of] the given class',
));
//
// Class: TriggerOnObjectDelete
//
Dict::Add('EN US', 'English', 'English', array(
'Class:TriggerOnObjectDelete' => 'Trigger (on object deletion)',
'Class:TriggerOnObjectDelete+' => 'Trigger on object deletion of [a child class of] the given class',
));
//
// Class: TriggerOnObjectUpdate
//
@@ -595,7 +604,7 @@ Dict::Add('EN US', 'English', 'English', array(
Dict::Add('EN US', 'English', 'English', array(
'Class:TriggerOnObjectUpdate' => 'Trigger (on object update)',
'Class:TriggerOnObjectUpdate+' => 'Trigger on object update of [a child class of] the given class',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes' => 'Target attributes',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes' => 'Target fields',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes+' => '',
));

View File

@@ -61,6 +61,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:TriggerOnStateLeave+' => '',
'Class:TriggerOnObjectCreate' => 'Déclencheur sur la création d\'un objet',
'Class:TriggerOnObjectCreate+' => '',
'Class:TriggerOnObjectDelete' => 'Déclencheur sur la suppression d\'un objet',
'Class:TriggerOnObjectDelete+' => '',
'Class:TriggerOnObjectUpdate' => 'Déclencheur sur la modification d\'un objet',
'Class:TriggerOnObjectUpdate+' => '',
'Class:TriggerOnObjectUpdate/Attribute:target_attcodes' => 'Attributs cible',

View File

@@ -1389,20 +1389,49 @@ EOF
$aParameters['handler_class'] = $this->GetMandatoryPropString($oField, 'handler_class');
}
elseif ($sAttType == 'AttributeTagSet')
{
$aTagFieldsInfo[] = $sAttCode;
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['is_null_allowed'] = $this->GetPropBoolean($oField, 'is_null_allowed', false);
$aParameters['depends_on'] = $sDependencies;
$aParameters['tag_max_nb'] = $this->GetPropNumber($oField, 'tag_max_nb', 12);
$aParameters['tag_code_max_len'] = $this->GetPropNumber($oField, 'tag_code_max_len', 20);
if ($aParameters['tag_code_max_len'] > 255)
{
$aParameters['tag_code_max_len'] = 255;
}
}
else
{
$aTagFieldsInfo[] = $sAttCode;
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['is_null_allowed'] = $this->GetPropBoolean($oField, 'is_null_allowed', false);
$aParameters['depends_on'] = $sDependencies;
$aParameters['max_items'] = $this->GetPropNumber($oField, 'max_items', 12);
$aParameters['tag_code_max_len'] = $this->GetPropNumber($oField, 'tag_code_max_len', 20);
if ($aParameters['tag_code_max_len'] > 255)
{
$aParameters['tag_code_max_len'] = 255;
}
}
elseif ($sAttType == 'AttributeSet')
{
$aTagFieldsInfo[] = $sAttCode;
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['is_null_allowed'] = $this->GetPropBoolean($oField, 'is_null_allowed', false);
$aParameters['depends_on'] = $sDependencies;
$aParameters['max_items'] = $this->GetPropNumber($oField, 'max_items', 12);
}
elseif ($sAttType == 'AttributeClassAttCodeSet')
{
$aTagFieldsInfo[] = $sAttCode;
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['is_null_allowed'] = $this->GetPropBoolean($oField, 'is_null_allowed', false);
$aParameters['depends_on'] = $sDependencies;
$aParameters['max_items'] = $this->GetPropNumber($oField, 'max_items', 12);
$aParameters['class_field'] = $this->GetMandatoryPropString($oField, 'class_field');
$aParameters['attribute_definition_list'] = $this->GetPropString($oField, 'attribute_definition_list', '');
}
elseif ($sAttType == 'AttributeClassState')
{
$aTagFieldsInfo[] = $sAttCode;
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['is_null_allowed'] = $this->GetPropBoolean($oField, 'is_null_allowed', false);
$aParameters['depends_on'] = $sDependencies;
$aParameters['class_field'] = $this->GetMandatoryPropString($oField, 'class_field');
}
else
{
$aParameters['allowed_values'] = 'null'; // or "new ValueSetEnum('SELECT xxxx')"
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');

View File

@@ -71,7 +71,7 @@ class CriterionToSearchForm extends CriterionConversionAbstract
AttributeDefinition::SEARCH_WIDGET_TYPE_EXTERNAL_KEY => 'ExternalKeyToSearchForm',
AttributeDefinition::SEARCH_WIDGET_TYPE_HIERARCHICAL_KEY => 'ExternalKeyToSearchForm',
AttributeDefinition::SEARCH_WIDGET_TYPE_ENUM => 'EnumToSearchForm',
AttributeDefinition::SEARCH_WIDGET_TYPE_TAG_SET => 'TagSetToSearchForm',
AttributeDefinition::SEARCH_WIDGET_TYPE_SET => 'SetToSearchForm',
);
foreach($aAndCriterionRaw as $aCriteria)
@@ -667,7 +667,7 @@ class CriterionToSearchForm extends CriterionConversionAbstract
return $aCriteria;
}
protected static function TagSetToSearchForm($aCriteria, $aFields)
protected static function SetToSearchForm($aCriteria, $aFields)
{
$sOperator = $aCriteria['operator'];
switch ($sOperator)
@@ -700,6 +700,7 @@ class CriterionToSearchForm extends CriterionConversionAbstract
break;
case '=':
// TODO BUG SPLIT INTO AN 'AND' LIST OF MATCHES
$aCriteria['operator'] = CriterionConversionAbstract::OP_EQUALS;
if (isset($aCriteria['has_undefined']) && $aCriteria['has_undefined'])
{

View File

@@ -461,22 +461,22 @@ class CriterionConversionTest extends ItopDataTestCase
'TagSet Matches' => array(
'OQL' => "SELECT UserRequest WHERE tagfield MATCHES 'tag1'",
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE `UserRequest`.`tagfield` MATCHES 'tag1'",
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
'ExpectedCriterion' => array(array('widget' => 'set')),
),
'TagSet Matches2' => array(
'OQL' => "SELECT UserRequest WHERE tagfield MATCHES 'tag1 tag2'",
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE `UserRequest`.`tagfield` MATCHES 'tag1 tag2'",
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
'ExpectedCriterion' => array(array('widget' => 'set')),
),
'TagSet Undefined' => array(
'OQL' => "SELECT UserRequest WHERE tagfield = ''",
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`tagfield` = '')",
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
'ExpectedCriterion' => array(array('widget' => 'set')),
),
'TagSet Undefined and tag' => array(
'OQL' => "SELECT UserRequest WHERE (((tagfield MATCHES 'tag1 tag2') OR (tagfield = '')) AND 1)",
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`tagfield` MATCHES 'tag1 tag2' OR (`UserRequest`.`tagfield` = '')) AND 1)",
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
'ExpectedCriterion' => array(array('widget' => 'set')),
),
);

View File

@@ -253,7 +253,7 @@ class TagSetFieldDataTest extends ItopDataTestCase
{
/** @var \AttributeTagSet $oAttDef */
$oAttDef = \MetaModel::GetAttributeDef(TAG_CLASS, TAG_ATTCODE);
$iMaxTags = $oAttDef->GetTagMaxNb();
$iMaxTags = $oAttDef->GetMaxItems();
for ($i = 0; $i < $iMaxTags; $i++)
{
$sTagCode = 'MaxTag'.$i;

View File

@@ -66,30 +66,30 @@ class ormTagSetTest extends ItopDataTestCase
public function testGetValue()
{
$oTagSet = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
static::assertEquals($oTagSet->GetValue(), array());
static::assertEquals($oTagSet->GetValues(), array());
$oTagSet->AddTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag1'));
$oTagSet->Add('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag1'));
$oTagSet->AddTag('tag2');
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2'));
$oTagSet->Add('tag2');
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2'));
}
public function testAddTag()
{
$oTagSet = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet->AddTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag1'));
$oTagSet->Add('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag1'));
$oTagSet->SetValue(array('tag1', 'tag2'));
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2'));
$oTagSet->SetValues(array('tag1', 'tag2'));
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2'));
$oTagSet->RemoveTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag2'));
$oTagSet->Remove('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag2'));
$oTagSet->AddTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2'));
$oTagSet->Add('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2'));
}
@@ -102,13 +102,13 @@ class ormTagSetTest extends ItopDataTestCase
{
$oTagSet = new ormTagSet(TAG_CLASS, TAG_ATTCODE, 3);
$oTagSet->SetValue(array('tag1', 'tag2', 'tag3'));
$oTagSet->SetValues(array('tag1', 'tag2', 'tag3'));
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2', 'tag3'));
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2', 'tag3'));
try
{
$oTagSet->SetValue(array('tag1', 'tag2', 'tag3', 'tag4'));
$oTagSet->SetValues(array('tag1', 'tag2', 'tag3', 'tag4'));
}
catch (\CoreException $e)
{
@@ -120,15 +120,15 @@ class ormTagSetTest extends ItopDataTestCase
public function testEquals()
{
$oTagSet1 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet1->AddTag('tag1');
$oTagSet1->Add('tag1');
static::assertTrue($oTagSet1->Equals($oTagSet1));
$oTagSet2 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet2->SetValue(array('tag1'));
$oTagSet2->SetValues(array('tag1'));
static::assertTrue($oTagSet1->Equals($oTagSet2));
$oTagSet1->AddTag('tag2');
$oTagSet1->Add('tag2');
static::assertFalse($oTagSet1->Equals($oTagSet2));
}
@@ -136,48 +136,48 @@ class ormTagSetTest extends ItopDataTestCase
{
$oTagSet = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet->SetValue(array('tag1'));
static::assertEquals($oTagSet->GetValue(), array('tag1'));
$oTagSet->SetValues(array('tag1'));
static::assertEquals($oTagSet->GetValues(), array('tag1'));
$oTagSet->SetValue(array('tag1', 'tag2'));
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2'));
$oTagSet->SetValues(array('tag1', 'tag2'));
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2'));
}
public function testRemoveTag()
{
$oTagSet = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet->RemoveTag('tag_unknown');
static::assertEquals($oTagSet->GetValue(), array());
$oTagSet->Remove('tag_unknown');
static::assertEquals($oTagSet->GetValues(), array());
$oTagSet->SetValue(array('tag1'));
$oTagSet->RemoveTag('tag_unknown');
static::assertEquals($oTagSet->GetValue(), array('tag1'));
$oTagSet->SetValues(array('tag1'));
$oTagSet->Remove('tag_unknown');
static::assertEquals($oTagSet->GetValues(), array('tag1'));
$oTagSet->SetValue(array('tag1', 'tag2'));
$oTagSet->RemoveTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag2'));
$oTagSet->SetValues(array('tag1', 'tag2'));
$oTagSet->Remove('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag2'));
$oTagSet->AddTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag1', 'tag2'));
$oTagSet->Add('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag1', 'tag2'));
$oTagSet->RemoveTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag2'));
$oTagSet->Remove('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag2'));
$oTagSet->RemoveTag('tag1');
static::assertEquals($oTagSet->GetValue(), array('tag2'));
$oTagSet->Remove('tag1');
static::assertEquals($oTagSet->GetValues(), array('tag2'));
$oTagSet->RemoveTag('tag2');
static::assertEquals($oTagSet->GetValue(), array());
$oTagSet->Remove('tag2');
static::assertEquals($oTagSet->GetValues(), array());
}
public function testGetDelta()
{
$oTagSet1 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet1->SetValue(array('tag1', 'tag2'));
$oTagSet1->SetValues(array('tag1', 'tag2'));
$oTagSet2 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet2->SetValue(array('tag1', 'tag3', 'tag4'));
$oTagSet2->SetValues(array('tag1', 'tag3', 'tag4'));
$aDelta = $oTagSet1->GetDelta($oTagSet2);
static::assertCount(2, $aDelta);
@@ -188,10 +188,10 @@ class ormTagSetTest extends ItopDataTestCase
public function testApplyDelta()
{
$oTagSet1 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet1->SetValue(array('tag1', 'tag2'));
$oTagSet1->SetValues(array('tag1', 'tag2'));
$oTagSet2 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet2->SetValue(array('tag1', 'tag3', 'tag4'));
$oTagSet2->SetValues(array('tag1', 'tag3', 'tag4'));
$aDelta = $oTagSet1->GetDelta($oTagSet2);
@@ -212,12 +212,12 @@ class ormTagSetTest extends ItopDataTestCase
public function testGetModified($aInitialTags, $aDiffAndExpectedTags)
{
$oTagSet1 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet1->SetValue($aInitialTags);
$oTagSet1->SetValues($aInitialTags);
foreach($aDiffAndExpectedTags as $aTestItem)
{
$oTagSet1->GenerateDiffFromTags($aTestItem['diff']);
static::assertEquals($aTestItem['modified'], $oTagSet1->GetModifiedTags());
$oTagSet1->GenerateDiffFromArray($aTestItem['diff']);
static::assertEquals($aTestItem['modified'], $oTagSet1->GetModified());
}
}
@@ -264,11 +264,11 @@ class ormTagSetTest extends ItopDataTestCase
public function testBulkModify($aInitialTags, $aDelta, $aExpectedTags)
{
$oTagSet1 = new ormTagSet(TAG_CLASS, TAG_ATTCODE, MAX_TAGS);
$oTagSet1->SetValue($aInitialTags);
$oTagSet1->SetValues($aInitialTags);
$oTagSet1->ApplyDelta($aDelta);
static::assertEquals($aExpectedTags, $oTagSet1->GetValue());
static::assertEquals($aExpectedTags, $oTagSet1->GetValues());
}
public function BulkModifyProvider()