Add CompatUtility::IsLegacyAttribute().

Refs #5855
This commit is contained in:
Michael Friedrich 2014-04-04 16:35:45 +02:00
parent 9dd37cf9bc
commit 17b87c9b2a
2 changed files with 26 additions and 11 deletions

View File

@ -407,6 +407,30 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
}
/* vars attr */
bool CompatUtility::IsLegacyAttribute(const String& name)
{
if (name == "address" ||
name == "address1" ||
name == "address2" ||
name == "address3" ||
name == "address4" ||
name == "address5" ||
name == "address6" || /* user, host */
name == "email" ||
name == "pager" ||
name == "notes" ||
name == "action_url" ||
name == "notes_url" ||
name == "icon_image" ||
name == "icon_image_alt" ||
name == "statusmap_image" ||
name == "2d_coords")
return true;
return false;
}
Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr& object)
{
ASSERT(object->OwnsLock());
@ -421,17 +445,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (!kv.first.IsEmpty()) {
if (kv.first != "address" &&
kv.first != "address6" &&
kv.first != "email" &&
kv.first != "pager" &&
kv.first != "notes" &&
kv.first != "action_url" &&
kv.first != "notes_url" &&
kv.first != "icon_image" &&
kv.first != "icon_image_alt" &&
kv.first != "statusmap_image" &&
kv.first != "2d_coords")
if (!IsLegacyAttribute(kv.first))
varsvars->Set(kv.first, kv.second);
}
}

View File

@ -113,6 +113,7 @@ public:
static String GetCommandLine(const Command::Ptr& command);
/* custom attribute */
static bool IsLegacyAttribute(const String& name);
static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);