Example #1
0
		private void UpdateInteger(string sClassName, string sFieldName, int hvoItem, XmlDocument fxtResult)
		{
			XmlNode fxtFieldNode;
			string sResultOwningElementName;
			XmlNode resultNode;

			string[] asAttributeValues = new string[1];
			asAttributeValues[0] = sFieldName;
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksAttribute, ksSimpleProperty, asAttributeValues);
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(1);
			searchPropsList.Add(searchProps);
			fxtFieldNode = GetFxtFieldNode(sClassName, searchPropsList, out sResultOwningElementName);
			if (fxtFieldNode == null)
				return; // Not all fields are addressed in the FXT description

			ICmObject obj = CmObject.CreateFromDBObject(m_cache, hvoItem);
			string x = GetSimplePropertyString(fxtFieldNode, (CmObject)obj);
			XmlNode fxtNameAttr = fxtFieldNode.SelectSingleNode("@name");
			resultNode = fxtResult.SelectSingleNode("//" + sResultOwningElementName + "[@Id='" + hvoItem + "']");
			if (resultNode == null)
			{
				resultNode = FindOrInsertAllElementObject(hvoItem, fxtResult);
				if (resultNode == null)
					// The object has not been added to the result yet, most likely it is being initialized, so wait for owner to add it
					return;
			}

			XmlNode resultAttrNode = resultNode.SelectSingleNode("@" + fxtNameAttr.InnerText);
			resultAttrNode.InnerText = x;
		}
Example #2
0
		private XmlNode GetFxtNodeAndFxtItemLabel(string sClassName, int flid, string sFieldName, int fieldType, out string sResultOwningElementName,
			out bool fIsRefVector, out string sFxtItemLabel)
		{
			const string ksObjVector = "objVector";
			string sObjFieldType = "OS";
			if (fieldType == (int) CellarModuleDefns.kcptOwningCollection)
				sObjFieldType = "OC";

			string[] asAttributeValues = new string[1];
			asAttributeValues[0] = sFieldName + sObjFieldType;
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksObjVector, "objProperty", asAttributeValues);
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(2);
			searchPropsList.Add(searchProps);
			string[] asAttributeValues2 = new string[1];
			asAttributeValues2[0] = sFieldName;
			FXTElementSearchProperties searchProps2 = new FXTElementSearchProperties(ksRefVector, ksField, asAttributeValues2);
			searchPropsList.Add(searchProps2);

			string sAttrValueFound;
			FXTElementSearchProperties searchPropsFound;
			XmlNode fxtFieldNode =
				GetFxtFieldNode(sClassName, searchPropsList, out sResultOwningElementName, out searchPropsFound,
								out sAttrValueFound);
			if (fxtFieldNode == null)
			{
				sResultOwningElementName = "";
				fIsRefVector = false;
				sFxtItemLabel = "";
				return null; // Not all fields are addressed in the FXT description
			}

			if (searchPropsFound.ElementName == ksObjVector)
			{
				fIsRefVector = false;
				// want the signature of the field
				uint destClassId = m_cache.GetDestinationClass((uint) flid);

				if (m_cache.GetAbstract((int)destClassId))
				{
					int iCount = 0;
					StringBuilder sbSubClasses = new StringBuilder();
					GetNamesOfSubClasses(destClassId, sbSubClasses, iCount);
					sFxtItemLabel = sbSubClasses.ToString();
				}
				else
					sFxtItemLabel = m_cache.GetClassName(destClassId);
			}
			else
			{
				fIsRefVector = true;
				XmlNode fxtItemLabelAttr = fxtFieldNode.SelectSingleNode("@itemLabel");
				sFxtItemLabel = fxtItemLabelAttr.InnerText;
			}
			return fxtFieldNode;
		}
Example #3
0
		/// <summary>
		/// Find the element node in the FXT description file that is for this class and field
		/// </summary>
		/// <param name="sClassName">the class</param>
		/// <param name="searchProps">The search props.</param>
		/// <param name="sResultOwningElementName">Name of the owning element in the result.</param>
		/// <param name="searchPropsFound">The search props found.</param>
		/// <param name="sAttrValueFound">The search attribute value found.</param>
		/// <returns></returns>
		private XmlNode GetFxtFieldNode(string sClassName, List<FXTElementSearchProperties> searchProps, out string sResultOwningElementName,
			out FXTElementSearchProperties searchPropsFound, out string sAttrValueFound)
		{
			XmlNode fieldNode;
			// find the class
			XmlNode classNode = FxtDocument.SelectSingleNode("//class[@name='" + sClassName + "']");
			if (classNode == null)
				throw new XUpdaterException("Could not find class " + sClassName + " in FXT document " + m_sTemplateFilePath + " while getting field node.");
			// for the various element/attribute/attribute values combinations, try to find the element here
			foreach (FXTElementSearchProperties prop in searchProps)
			{
				foreach (string sValue in prop.AttributeValues)
				{
					string sXPath = "descendant-or-self::" + prop.ElementName + "[@" + prop.AttributeName + "='" + sValue + "']";
					fieldNode = classNode.SelectSingleNode(sXPath);
					if (fieldNode != null)
					{
						searchPropsFound = prop;
						sAttrValueFound = sValue;
						sResultOwningElementName = GetFxtParentNodeName(fieldNode);
						return fieldNode;
					}
				}
			}
			// did not find it;  look in any call elements
			XmlNodeList callNodes = classNode.SelectNodes("descendant-or-self::call");
			foreach (XmlNode callNode in callNodes)
			{
				XmlNode nameAttr = callNode.SelectSingleNode("@name");
				fieldNode = GetFxtFieldNode(nameAttr.InnerText, searchProps, out sResultOwningElementName, out searchPropsFound, out sAttrValueFound);
				if (fieldNode != null)
				{
					XmlNode flagsAttr = callNode.SelectSingleNode("@flags");
					// assume element name for a class will always be the class name
					if (flagsAttr != null && flagsAttr.InnerText == "NoWrapper" && sResultOwningElementName == nameAttr.InnerText)
						sResultOwningElementName = GetFxtParentNodeName(callNode);
					return fieldNode;
				}
			}
			searchPropsFound = null;
			sAttrValueFound = null;
			sResultOwningElementName = null;
			return null;
		}
Example #4
0
		private void UpdateReferenceVector(string sClassName, int flid, string sFieldName, int hvoItem, int fieldType, XmlDocument fxtResult)
		{
			XmlNode fxtFieldNode;
			string sResultOwningElementName;
			XmlNode resultNode;

			string[] asAttributeValues = new string[1];
			asAttributeValues[0] = sFieldName;
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksRefVector, ksField, asAttributeValues);
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(1);
			searchPropsList.Add(searchProps);
			fxtFieldNode = GetFxtFieldNode(sClassName, searchPropsList, out sResultOwningElementName);
			if (fxtFieldNode == null)
				return; // Not all fields are addressed in the FXT description

			XmlNode itemLabelAttr =  fxtFieldNode.SelectSingleNode("@itemLabel");
			string sFxtItemLabel = itemLabelAttr.InnerText;

			// get the owner object in the fxt result
			string sParentName = GetFxtParentNodeName(fxtFieldNode);
			resultNode = fxtResult.SelectSingleNode("//*[@Id='" + hvoItem + "']"); // is the owner
			if (resultNode == null)
			{
				XmlNode objResultNode = FindOrInsertAllElementObject(hvoItem, fxtResult);
				if (objResultNode != null)
				{
					resultNode = objResultNode.SelectSingleNode("descendant-or-self::" + sResultOwningElementName);
				}
				else
				{
					// the item does not have an Id; it's just the parent element
					resultNode = fxtResult.SelectSingleNode("//" + sResultOwningElementName);
					if (resultNode == null)
						// The object has not been added to the result yet, most likely it is being initialized, so wait for owner to add it
						return;
				}
			}

			// get set of field items in the database
			List<int> hvosDatabase = GetHvosInDatabase(hvoItem, flid);

			// get set of field items in the FXT result file
			List<int> hvosResult = GetHvosInFxtResult(resultNode, sFxtItemLabel, fxtFieldNode);

			HandleReferenceVectorDeletions(fxtResult, resultNode, hvosResult, hvosDatabase);

			HandleVectorAdditions(fxtResult, resultNode, sFxtItemLabel, hvosResult, hvosDatabase, sParentName, true);

			UpdateVectorOrds(resultNode, hvosDatabase);
		}
Example #5
0
		private void UpdateReferenceAtomic(string sClassName, int flid, string sFieldName, int hvoItem, XmlDocument fxtResult)
		{
			const string ksRefAtomic = "refAtomic";

			// need to find the correct class as well as the field in the FXT document
			string[] asAttributeValues = new string[2];
			asAttributeValues[0] = sFieldName + "RA";
			asAttributeValues[1] = sFieldName + "RAHvo";
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(2);
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksAttribute, ksSimpleProperty, asAttributeValues);
			searchPropsList.Add(searchProps);
			searchProps = new FXTElementSearchProperties("refAtomic", ksSimpleProperty, asAttributeValues);
			searchPropsList.Add(searchProps);

			FXTElementSearchProperties searchPropsFound;
			string sAttrValueFound;
			string sFxtParentName;
			XmlNode fxtFieldNode = GetFxtFieldNode(sClassName, searchPropsList, out sFxtParentName, out searchPropsFound, out sAttrValueFound);
			if (fxtFieldNode == null)
				return; // Not all fields are addressed in the FXT description

			XmlNode resultNode = null;
			XmlNode fxtNameAttr;
			string sNewResultValue = m_cache.GetIntProperty(hvoItem, flid).ToString();
			XmlNode resultParentNode = fxtResult.SelectSingleNode("//" + sFxtParentName + "[@Id='" + hvoItem + "']");
			if (resultParentNode == null)
			{
				XmlNode objResultNode = FindOrInsertAllElementObject(hvoItem, fxtResult);
				if (objResultNode != null)
				{
					resultParentNode = objResultNode.SelectSingleNode("descendant-or-self::" + sFxtParentName);
				}
				else
				{
					// the item does not have an Id; it's just the parent element
					resultParentNode = fxtResult.SelectSingleNode("//" + sFxtParentName);
					if (resultParentNode == null)
						// The object has not been added to the result yet, most likely it is being initialized, so wait for owner to add it
						return;
				}
			}

			if (searchPropsFound.ElementName == ksRefAtomic)
			{
				fxtNameAttr = fxtFieldNode.SelectSingleNode("@name");
				resultNode = resultParentNode.SelectSingleNode(fxtNameAttr.InnerText);
				XmlNode dst = resultNode.SelectSingleNode("@dst");
				dst.InnerText = sNewResultValue;
			}
			else
			{
				fxtNameAttr = fxtFieldNode.SelectSingleNode("@name");
				XmlNode resultAttr = resultParentNode.SelectSingleNode("@" + fxtNameAttr.InnerText);
				resultAttr.InnerText = sNewResultValue;
			}

		}
Example #6
0
		private XmlNode GetFxtFieldNodeForOwningAtomic(string sFieldName, string ksObjAtomic, string ksGroup, string sClassName, out string sFxtParentName, out FXTElementSearchProperties searchPropsFound)
		{
			string[] asAttributeValues = new string[3];
			asAttributeValues[0] = sFieldName + "OA";
			asAttributeValues[1] = sFieldName + "OAHvo";
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(2);
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksAttribute, ksSimpleProperty, asAttributeValues);
			searchPropsList.Add(searchProps);
			searchProps = new FXTElementSearchProperties(ksObjAtomic, "objProperty", asAttributeValues);
			searchPropsList.Add(searchProps);
			searchProps = new FXTElementSearchProperties(ksGroup, "objProperty", asAttributeValues);
			searchPropsList.Add(searchProps);

			string sAttrValueFound;
			return GetFxtFieldNode(sClassName, searchPropsList, out sFxtParentName, out searchPropsFound, out sAttrValueFound);
		}
Example #7
0
		private void UpdateString(string sClassName, string sFieldName, int hvoItem, XmlDocument fxtResult)
		{
			XmlNode fxtFieldNode;
			XmlNode fxtFieldParentElementNode;
			XmlNode fxtNameAttr = null;
			string sXPath;
			XmlNode resultNode;
			const string ksXmlstring = "xmlstring";

			string[] asAttributeValues = new string[1];
			asAttributeValues[0] = sFieldName;
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties(ksAttribute, ksSimpleProperty, asAttributeValues);
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(2);
			searchPropsList.Add(searchProps);
			string[] asAttributeValues2 = new string[1];
			asAttributeValues[0] = sFieldName;
			FXTElementSearchProperties searchProps2 =
				new FXTElementSearchProperties(ksXmlstring, ksSimpleProperty, asAttributeValues);
			searchPropsList.Add(searchProps2);

			string sResultOwningElementName;
			FXTElementSearchProperties searchPropsFound;
			string sAttrValueFound;
			fxtFieldNode = GetFxtFieldNode(sClassName, searchPropsList, out sResultOwningElementName, out searchPropsFound, out sAttrValueFound);
			if (fxtFieldNode == null)
				return; // Not all fields are addressed in the FXT description

			if (searchPropsFound.ElementName == ksXmlstring)
			{
				// assume the owner is unique and is the field name (e.g. ParserParameters in M3Parser.fxt)
				sXPath = "//" + sFieldName;
			}
			else
			{
				fxtNameAttr = fxtFieldNode.SelectSingleNode("@name");
				string sResultAttrName = fxtNameAttr.InnerText;

				fxtFieldParentElementNode = fxtFieldNode.SelectSingleNode("parent::element");
				XmlNode fxtParentNameAttr = fxtFieldParentElementNode.SelectSingleNode("@name");
				sXPath = "//" + fxtParentNameAttr.InnerText + "[@Id='" + hvoItem + "']/@" + sResultAttrName;
			}

			resultNode = fxtResult.SelectSingleNode(sXPath);
			if (resultNode == null)
			{
				XmlNode objNode = FindOrInsertAllElementObject(hvoItem, fxtResult);
				if (objNode != null && fxtNameAttr != null)
				{
					resultNode = objNode.SelectSingleNode("@" + fxtNameAttr.InnerText);
				}
				else
				{
					// The object has not been added to the result yet, most likely it is being initialized, so wait for owner to add it
					return;
				}
			}

			ICmObject obj = CmObject.CreateFromDBObject(m_cache, hvoItem);
			string x = GetSimplePropertyString(fxtFieldNode, (CmObject) obj);
			if (searchPropsFound.ElementName == ksXmlstring)
			{
				string sDumpResult = GetXmlStringDumpResult(fxtFieldNode, obj);
				string sInnerXml = GetInnerXml(sDumpResult);
				resultNode.InnerXml = sInnerXml;
			}
			else
				resultNode.InnerText = x;
		}
Example #8
0
		private void UpdateMultiUnicode(string sClassName, string sFieldName, int hvoItem, XmlDocument fxtResult)
		{
			XmlNode fxtFieldNode;
			XmlNode fxtFieldParentElementNode;
			XmlNode fxtNameAttr;
			string sXPath;
			XmlNode resultNode;

			string[] asAttributeValues = new string[1];
			asAttributeValues[0] = sFieldName;
			FXTElementSearchProperties searchProps =
				new FXTElementSearchProperties("string", ksSimpleProperty, asAttributeValues);
			List<FXTElementSearchProperties> searchPropsList = new List<FXTElementSearchProperties>(1);
			searchPropsList.Add(searchProps);

			fxtFieldNode = GetFxtFieldNode(sClassName, searchPropsList);
			if (fxtFieldNode == null)
				return; // Not all fields are addressed in the FXT description

			fxtFieldParentElementNode = fxtFieldNode.SelectSingleNode("parent::element");
			fxtNameAttr = fxtFieldParentElementNode.SelectSingleNode("@name");
			sXPath = "//" + fxtNameAttr.InnerText + "[parent::*[@Id='" + hvoItem + "']]";

			resultNode = fxtResult.SelectSingleNode(sXPath);
			if (resultNode == null)
			{
				XmlNode objResultNode = FindOrInsertAllElementObject(hvoItem, fxtResult);
				if (objResultNode != null)
				{
					resultNode = objResultNode.SelectSingleNode(fxtNameAttr.InnerText);
				}
				else
				{
					// The object has not been added to the result yet, most likely it is being initialized, so wait for owner to add it
					return;
				}
			}
			ICmObject obj = CmObject.CreateFromDBObject(m_cache, hvoItem);
			string x = GetSimplePropertyString(fxtFieldNode, (CmObject) obj);
			resultNode.InnerText = x;
		}