/*--------------------------------------------------------------------------------------------*/ private IWeaverQuery FinishEdgeVci <TEdge>(TEdge pEdge, string pOutV, string pInV, string pScript) where TEdge : IWeaverEdge { Type et = typeof(TEdge); var e = WeaverTitanUtil.GetAndVerifyElementAttribute <WeaverTitanEdgeAttribute>(et); string labelParam = Path.Query.AddStringParam(e.DbName); string propList = WeaverUtil.BuildPropList(Path.Config, Path.Query, pEdge); var sb = new StringBuilder(); AppendEdgeVciProps(sb, pOutV, et, WeaverUtil.GetElementPropertyAttributes(e.OutVertex)); AppendEdgeVciProps(sb, pInV, et, WeaverUtil.GetElementPropertyAttributes(e.InVertex)); const string tryLoop = "_TRY.each{k,v->if((z=v.getProperty(k))){_PROP.put(k,z)}};"; bool showTry = (sb.Length > 0); string propLine = (propList.Length > 0 || showTry ? "_PROP=" + (propList.Length > 0 ? "[" + propList + "];" : "[:];") : ""); Path.Query.FinalizeQuery( pScript + propLine + (showTry ? "_TRY=[" + sb + "];" + tryLoop : "") + "g.addEdge(" + pOutV + "," + pInV + "," + labelParam + (propLine.Length > 0 ? ",_PROP" : "") + ")" ); return(Path.Query); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public IWeaverQuery AddVertex <T>(T pVertex) where T : IWeaverVertex { string props = WeaverUtil.BuildPropList(Path.Config, Path.Query, pVertex); Path.Query.FinalizeQuery("g.addVertex([" + props + "])"); return(Path.Query); }
/*--------------------------------------------------------------------------------------------*/ private IWeaverQuery FinishEdge <TEdge>(TEdge pEdge, string pScript) where TEdge : IWeaverEdge { string labelParam = Path.Query.AddStringParam(Path.Config.GetEdgeDbName <TEdge>()); string propList = WeaverUtil.BuildPropList(Path.Config, Path.Query, pEdge); Path.Query.FinalizeQuery(pScript + labelParam + (propList.Length > 0 ? ",[" + propList + "]" : "") + ")"); return(Path.Query); }
public void BuildPropListPerson(bool pIncludeId, string pName) { var p = new Person(); p.Id = "123456789123ABC"; p.PersonId = 3456789; p.Name = pName; p.Age = 27.3f; p.IsMale = true; var q = new WeaverQuery(); string propList = WeaverUtil.BuildPropList(WeavInst.Config, q, p, pIncludeId); Dictionary <string, string> pairMap = WeaverTestUtil.GetPropListDictionary(propList); int expectCount = 3 + (pIncludeId ? 1 : 0) + (pName != null ? 1 : 0); Assert.AreEqual(expectCount, pairMap.Keys.Count, "Incorrect Key count."); Assert.True(pairMap.ContainsKey(TestSchema.Person_PersonId), "Missing PersonId key."); Assert.True(pairMap.ContainsKey(TestSchema.Person_Age), "Missing Age key."); Assert.True(pairMap.ContainsKey(TestSchema.Person_IsMale), "Missing IsMale key."); Assert.AreEqual(pIncludeId, pairMap.ContainsKey("id"), "Incorrect Id key."); Assert.AreEqual((pName != null), pairMap.ContainsKey("Name"), "Incorrect Name key."); Assert.AreEqual("_P0", pairMap[TestSchema.Person_PersonId], "Incorrect PersonId value."); Assert.AreEqual("_P1", pairMap[TestSchema.Person_IsMale], "Incorrect IsMale value."); Assert.AreEqual("_P2", pairMap[TestSchema.Person_Age], "Incorrect Age value."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(p.PersonId)); expectParams.Add("_P1", new WeaverQueryVal(p.IsMale)); expectParams.Add("_P2", new WeaverQueryVal(p.Age)); int pi = 3; if (pName != null) { Assert.AreEqual("_P3", pairMap["Name"], "Incorrect Name value."); expectParams.Add("_P3", new WeaverQueryVal(pName)); pi++; } if (pIncludeId) { Assert.AreEqual("_P" + pi, pairMap["id"], "Incorrect Id value."); expectParams.Add("_P" + pi, new WeaverQueryVal(p.Id)); } WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }