Method used to translate a managedobject. This method is used in CompareManagedObject.

def TranslateManagedObject(mObj, xlateOrg, xlateMap):
	""" Method used to translate a managedobject. This method is used in CompareManagedObject. """
	from UcsBase import UcsUtils, WriteUcsWarning
	from Mos import OrgOrg

	xMO = mObj.Clone()
	xMO.SetHandle(mObj.GetHandle())
	if (xlateOrg != None):
		matchObj = re.match(r'^(org-[\-\.:_a-zA-Z0-9]{1,16}/)*org-[\-\.:_a-zA-Z0-9]{1,16}', xMO.Dn)
		if matchObj:
			if UcsUtils.WordL(xMO.classId) == OrgOrg.ClassId():
				orgMoMeta = UcsUtils.GetUcsPropertyMeta(UcsUtils.WordU(OrgOrg.ClassId()), "Meta")
				if orgMoMeta == None:
					# TODO: Add Warning/Error messages in Logger.
					WriteUcsWarning('[Warning]: Could not translate [%s]' % (xMO.Dn))
					return xMO

				# Check for naming property
				matchObj1 = re.findall(r'(\[[^\]]+\])', orgMoMeta.rn)
				if matchObj1:
					UpdateMoDnAlongWithNamingProperties(xMO, orgMoMeta, xlateOrg)
				else:
					newDn = re.sub("%s" % (matchObj.group(0)), "%s" % (xlateOrg), xMO.Dn)
					# print "Translating", xMO.Dn, " => ", newDn
					xMO.Dn = newDn
			else:
				newDn = re.sub("^%s/" % (matchObj.group(0)), "%s/" % (xlateOrg), xMO.Dn)
				# print "Translating", xMO.Dn, " => ", newDn
				xMO.Dn = newDn

	if (xlateMap != None):
		originalDn = xMO.Dn
		if originalDn in xlateMap:
			xMoMeta = UcsUtils.GetUcsPropertyMeta(UcsUtils.WordU(xMO.classId), "Meta")
			if xMoMeta == None:
				# TODO: Add Warning/Error messages in Logger.
				WriteUcsWarning('[Warning]: Could not translate [%s]' % (originalDn))
				return xMO

			# Check for naming property
			matchObj = re.findall(r'(\[[^\]]+\])', xMoMeta.rn)
			if matchObj:
				UpdateMoDnAlongWithNamingProperties(xMO, xMoMeta, xlateMap[originalDn])
			else:
				# print "Translating", xMO.Dn, " => ", xlateMap[originalDn]
				xMO.Dn = xlateMap[originalDn]
		else:
			originalDn = re.sub(r'[/]*[^/]+$', '', originalDn)
			while (originalDn != None or originalDn == ""):
				if (not (originalDn in xlateMap)):
					originalDn = re.sub(r'[/]*[^/]+$', '', originalDn)
					continue

				newDn = re.sub("^%s/" % (originalDn), "%s/" % (xlateMap[originalDn]), xMO.Dn)
				# print "Translating", xMO.Dn, " => ", newDn
				xMO.Dn = newDn
				break

	return xMO