/// /// <summary> * UpdateBusiness /// * </summary> /// * <param name="businessObject"> </param> /// * <param name="newID"> /// * @return </param> /// public virtual bool updateBusiness(EnumBusinessObject businessObject, string newID) { KElement bo = getElement(ElementName.BUSINESSINFO, JDFConstants.EMPTYSTRING, 0); ArrayList vBos = EnumBusinessObject.getNamesVector(); KElement boe = bo.getChildFromList(new VString(vBos), 0, null, true); string bos = boe.Name; int oldType = vBos.IndexOf(bos); Console.WriteLine("JDFNodeInfo:: " + businessObject.getValue() + " Boe:: " + boe); //C# renameElement only returns the renamed element. boe = boe.renameElement((string)vBos[businessObject.getValue()], JDFConstants.EMPTYSTRING); if (businessObject.getValue() > oldType) { boe.setAttribute(JDFConstants.BUSINESSREFID, boe.getAttribute(JDFConstants.BUSINESSID, JDFConstants.EMPTYSTRING, JDFConstants.EMPTYSTRING), JDFConstants.EMPTYSTRING); if (newID.Length != 0) { boe.setAttribute(JDFConstants.BUSINESSID, newID, JDFConstants.EMPTYSTRING); } } return(true); }
public virtual void testCreateElement() { XMLDoc d = new XMLDoc("TEST", null); KElement e = (KElement)d.createElement("foo:bar"); // e.appendElement("bar:foo"); e.setAttribute("foo:at", "1"); e.appendElement("bar2"); d.getRoot().appendChild(e); Assert.AreEqual("1", e.getAttribute("foo:at")); }
/// /// <summary> * remove the KElement from the target list /// * </summary> /// * <param name="target"> the element to remove </param> /// public virtual void removeTarget(KElement targetElement) { if (!useIDCache || m_mapTarget == null) { return; } string id = targetElement.getAttribute("ID", null, null); if (id != null) { KElement kelem = (KElement)m_mapTarget[id]; if (kelem != null) { // element with key of id was found, so delete it m_mapTarget.Remove(id); } } }
public virtual void testGetElementByID() { _setUp(); KElement kelem = m_jdfRoot.getChildWithAttribute("*", "ID", "*", "n0006", 0, true); Assert.IsTrue(kelem != null, "kelem==null"); if (kelem == null) { return; // soothe findbugs ;) } string strAtrib = kelem.getAttribute("ID", "", ""); Assert.IsTrue(strAtrib.Equals("n0006"), "ID!=n0006"); // second try KElement kelem2 = m_jdfRoot.getTarget("n0006", "ID"); Assert.IsTrue(kelem2 != null, "kelem2==null"); if (kelem2 == null) { return; // soothe findbugs ;) } string strAtrib2 = kelem2.getAttribute("ID", "", ""); Assert.IsTrue(strAtrib2.Equals("n0006"), "ID!=n0006"); // third try KElement kelem3 = m_jdfRoot.getTarget("198", "Preferred"); Assert.IsTrue(kelem3 != null, "kelem3==null"); if (kelem3 == null) { return; // soothe findbugs ;) } string strAtrib3 = kelem3.getAttribute("Preferred", "", ""); Assert.IsTrue(strAtrib3.Equals("198"), "Preferred!=198"); // fourth try: GetChildWithAttribute does only find direct children but // no deep children KElement kelem4 = m_jdfRoot.getChildWithAttribute("*", "Preferred", "*", "198", 0, true); Assert.IsTrue(kelem4 == null, "kelem4!=null"); }
/// /// <summary> * Set the target to target /// * </summary> /// * <param name="targetElement"> the target element </param> /// * <param name="id"> </param> /// public virtual void setTarget(KElement targetElement, string id) { string idLocal = id; if (!useIDCache || m_mapTarget == null) { return; } if (idLocal == null) { idLocal = targetElement.getAttribute(AttributeName.ID, null, null); } if (idLocal != null) { if (m_mapTarget.ContainsKey(idLocal)) { m_mapTarget.Remove(idLocal); } m_mapTarget.Add(idLocal, targetElement); // put the correct in } }