//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static string BuildPropList <T>(IWeaverConfig pConfig, IWeaverQuery pQuery, T pElem, bool pIncludeId = false) where T : IWeaverElement { IList <WeaverPropPair> props = GetElementPropertyAttributes(typeof(T)); var sb = new StringBuilder(); foreach (WeaverPropPair wpp in props) { string dbName = wpp.Attrib.DbName; if (!pIncludeId && dbName == "id") { continue; } object val = wpp.Info.GetValue(pElem, null); if (val != null) { sb.Append((sb.Length > 0 ? "," : "") + dbName + ":" + pQuery.AddParam(new WeaverQueryVal(val))); } } return(sb.ToString()); }
public void Success(string pName, string pDisamb) { vCreateClass.Name = pName; vCreateClass.Disamb = pDisamb; Class result = ExecuteOperation(); CheckNewVertex(result, VertexType.Id.Class); Assert.AreEqual(vCreateClass.Name, result.Name, "Incorrect Name."); Assert.AreEqual(vCreateClass.Disamb, result.Disamb, "Incorrect Disamb."); Assert.AreEqual(vCreateClass.Note, result.Note, "Incorrect Note."); IWeaverQuery verify = Weave.Inst.Graph .V.ExactIndex <Class>(x => x.VertexId, result.VertexId) .CreatedByMember.ToMember .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, CreatorId) .CreatesArtifacts .Has(x => x.VertexType, WeaverStepHasOp.EqualTo, result.VertexType) .Has(x => x.Timestamp, WeaverStepHasOp.EqualTo, result.Timestamp) .ToArtifact .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, result.VertexId) .ToQuery(); NewVertexCount = 1; NewEdgeCount = 2; SetNewElementQuery(verify); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public TravPathData(string pRawText, long?pMemberId = null) { MemberId = pMemberId; CurrIndex = 0; CurrType = typeof(FabTravRoot); Items = new List <ITravPathItem>(); Aliases = new Dictionary <string, int>(); Backs = new Dictionary <string, int>(); Types = new List <Type> { CurrType }; vQuery = new WeaverQuery(); vScript = "g.V"; //// string p = pRawText.Replace("%20", " ").TrimEnd(new[] { '/' }); string[] parts = (p.Length > 0 ? p.Split('/') : new string[0]); for (int i = 0; i < parts.Length; i++) { Items.Add(new TravPathItem(i, parts[i])); } }
public void ComplexPath() { IWeaverStepAs <Person> personAlias; IWeaverQuery q = WeavInst.Graph.V.ExactIndex <Root>(x => x.Id, 0) .OutHasPerson.InVertex .Has(x => x.PersonId, WeaverStepHasOp.EqualTo, 22) .Has(x => x.Name, WeaverStepHasOp.EqualTo, "test") .As(out personAlias) .OutLikesCandy.InVertex .Back(personAlias) .ToQuery(); const string expect = "g.V('id',_P0)" + ".outE('" + TestSchema.RootHasPerson + "').inV" + ".has('" + TestSchema.Person_PersonId + "',Tokens.T.eq,_P1)" + ".has('" + TestSchema.Vertex_Name + "',Tokens.T.eq,_P2)" + ".as('step7')" + ".outE('" + TestSchema.PersonLikesCandy + "').inV" + ".back('step7');"; Assert.AreEqual(expect, q.Script, "Incorrect Query.Script."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(0)); expectParams.Add("_P1", new WeaverQueryVal(22)); expectParams.Add("_P2", new WeaverQueryVal("test")); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
public void AddEdgeVarNoProps() { var rhp = new RootHasPerson(); const string outVarName = "_var0"; const string inVarName = "_var1"; var mockOutVar = new Mock <IWeaverVarAlias>(); mockOutVar.SetupGet(x => x.Name).Returns(outVarName); mockOutVar.SetupGet(x => x.VarType).Returns(typeof(Root)); var mockInVar = new Mock <IWeaverVarAlias>(); mockInVar.SetupGet(x => x.Name).Returns(inVarName); mockInVar.SetupGet(x => x.VarType).Returns(typeof(Person)); IWeaverQuery q = vGraph.AddEdge(mockOutVar.Object, rhp, mockInVar.Object); Assert.True(q.IsFinalized, "Incorrect IsFinalized."); Assert.NotNull(q.Script, "Script should be filled."); Assert.AreEqual(q.Script, "g.addEdge(" + outVarName + "," + inVarName + ",_P0);", "Incorrect Script."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(TestSchema.RootHasPerson)); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
public void Success() { Member result = ExecuteOperation(); CheckNewVertex(result, VertexType.Id.Member); Assert.AreEqual(vCreateMember.Type, result.MemberType, "Incorrect MemberType."); Assert.AreEqual(null, result.OauthGrantCode, "Incorrect OauthGrantCode."); Assert.AreEqual(null, result.OauthGrantExpires, "Incorrect OauthGrantExpires."); Assert.AreEqual(null, result.OauthGrantRedirectUri, "Incorrect OauthGrantRedirectUri."); Assert.AreEqual(null, result.OauthScopeAllow, "Incorrect OauthScopeAllow."); IWeaverQuery verify = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, result.VertexId) .DefinedByApp.ToApp .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, vCreateMember.DefinedByAppId) .DefinesMembers .Has(x => x.UserId, WeaverStepHasOp.EqualTo, vCreateMember.DefinedByUserId) .Has(x => x.MemberType, WeaverStepHasOp.EqualTo, result.MemberType) .Has(x => x.Timestamp, WeaverStepHasOp.EqualTo, result.Timestamp) .ToMember .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, result.VertexId) .DefinedByUser.ToUser .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, vCreateMember.DefinedByUserId) .DefinesMembers .Has(x => x.AppId, WeaverStepHasOp.EqualTo, vCreateMember.DefinedByAppId) .Has(x => x.MemberType, WeaverStepHasOp.EqualTo, result.MemberType) .Has(x => x.Timestamp, WeaverStepHasOp.EqualTo, result.Timestamp) .ToMember .Has(x => x.VertexId, WeaverStepHasOp.EqualTo, result.VertexId) .ToQuery(); NewVertexCount = 1; NewEdgeCount = 4; SetNewElementQuery(verify); }
/*--------------------------------------------------------------------------------------------*/ private OauthMember GetOauthMember(IOperationData pData, Member pMemPath, string pName) { IWeaverVarAlias <Member> memAlias; IWeaverQuery memQ = pMemPath.ToQueryAsVar("m", out memAlias); IWeaverQuery appQ = Weave.Inst.FromVar(memAlias) .DefinedByApp.ToApp .Property(x => x.VertexId) .ToQuery(); IDataAccess acc = pData.Build(null, true); acc.AddSessionStart(); acc.AddQuery(memQ, true); acc.AppendScriptToLatestCommand("(m?m=m.next():null);"); string memCmdId = acc.GetLatestCommandId(); acc.AddQuery(appQ, true); acc.AddConditionsToLatestCommand(memCmdId); acc.AddSessionClose(); IDataResult res = acc.Execute("OauthAccess-" + pName); if (res.GetCommandResultCount(1) == 0) { return(null); } var om = new OauthMember(); om.Member = res.ToElementAt <Member>(1, 0); om.AppId = res.ToLongAt(2, 0); return(om); }
/*--------------------------------------------------------------------------------------------*/ public T GetVertexById <T>(long pVertexId) where T : Vertex, new() { T item = vCache.FindVertex <T>(pVertexId); if (item != null) { return(item); } item = new T(); item.VertexId = pVertexId; IWeaverQuery q = Weave.Inst.Graph.V.ExactIndex(item).ToQuery(); item = Build().AddQuery(q).Execute("GetVertexById").ToElement <T>(); if (item == null) { vCache.RemoveVertex <T>(pVertexId); } else { vCache.AddVertex(item); } return(item); }
public void Success() { FabOauthLogout result = ExecuteOperation(); Assert.AreEqual(1, result.Success, "Incorrect Success."); Assert.AreEqual(vToken, result.AccessToken, "Incorrect AccessToken."); VerificationQueryFunc = () => { IWeaverQuery q1 = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, (long)SetupMemberId.FabZach) .AuthenticatedByOauthAccesses.ToOauthAccess .Has(x => x.Token) .ToQuery(); IWeaverQuery q2 = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, (long)SetupMemberId.FabZach) .AuthenticatedByOauthAccesses.ToOauthAccess .Has(x => x.Refresh) .ToQuery(); IDataResult dr1 = OpCtx.ExecuteForTest(q1, "OauthLogoutOperation-Token"); IDataResult dr2 = OpCtx.ExecuteForTest(q2, "OauthLogoutOperation-Refresh"); Assert.AreEqual(0, dr1.GetCommandResultCount(), "Tokens were not cleared."); Assert.AreEqual(0, dr2.GetCommandResultCount(), "Refresh were not cleared."); }; }
public void AddVertex() { var vert = new Vertex(); vert.VertexId = 9876; vert.VertexType = 7; vert.Timestamp = 102030405060; IWeaverVarAlias <Vertex> alias; const string expectScript = "_V0=g.addVertex([" + DbName.Vert.Vertex.VertexId + ":_P0," + DbName.Vert.Vertex.Timestamp + ":_P1," + DbName.Vert.Vertex.VertexType + ":_P2" + "]);"; var txb = new TxBuilder(); txb.AddVertex(vert, out alias); txb.Finish(alias); //ensure that the alias becomes registered IWeaverQuery q = GetFirstQuery(txb); TestUtil.LogWeaverScript(Log, q); Assert.AreEqual(expectScript, q.Script, "Incorrect script."); TestUtil.CheckParams(q.Params, "_P", new List <object> { vert.VertexId, vert.Timestamp, vert.VertexType }); }
public void GetVertex(bool pById) { const long id = 123456; const string expectScript = "_V0=g.V('" + DbName.Vert.Vertex.VertexId + "',_P0).next();"; IWeaverVarAlias <App> alias; var txb = new TxBuilder(); if (pById) { txb.GetVertex(id, out alias); } else { var app = new App(); app.VertexId = id; txb.GetVertex(app, out alias); } IWeaverQuery q = GetFirstQuery(txb); TestUtil.LogWeaverScript(Log, q); Assert.AreEqual(expectScript, q.Script, "Incorrect script."); TestUtil.CheckParams(q.Params, "_P", new List <object> { id }); }
public void AddEdgeVciVarNoProps() { vMockPath.SetupGet(x => x.Query).Returns(new WeaverQuery()); //should mock this var ehe = new EmptyHasEmpty(); const string outVarName = "_var0"; const string inVarName = "_var1"; var mockOutVar = new Mock <IWeaverVarAlias>(); mockOutVar.SetupGet(x => x.Name).Returns(outVarName); mockOutVar.SetupGet(x => x.VarType).Returns(typeof(Empty)); var mockInVar = new Mock <IWeaverVarAlias>(); mockInVar.SetupGet(x => x.Name).Returns(inVarName); mockInVar.SetupGet(x => x.VarType).Returns(typeof(Empty)); IWeaverQuery q = vGraph.AddEdgeVci(mockOutVar.Object, ehe, mockInVar.Object); const string expect = "g.addEdge(" + outVarName + "," + inVarName + ",_P0);"; Assert.True(q.IsFinalized, "Incorrect IsFinalized."); Assert.NotNull(q.Script, "Script should be filled."); Assert.AreEqual(expect, q.Script, "Incorrect Script."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal("EHE")); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
public void AddEdgeVciNoProps() { vMockPath.SetupGet(x => x.Query).Returns(new WeaverQuery()); //should mock this var ehe = new EmptyHasEmpty(); var e1 = new Empty { Id = "V0" }; var e2 = new Empty { Id = "eee99" }; IWeaverQuery q = vGraph.AddEdgeVci(e1, ehe, e2); const string expect = "_A=g.v(_P0);" + "_B=g.v(_P1);" + "g.addEdge(_A,_B,_P2);"; Assert.True(q.IsFinalized, "Incorrect IsFinalized."); Assert.NotNull(q.Script, "Script should be filled."); Assert.AreEqual(expect, q.Script, "Incorrect Script."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(e1.Id)); expectParams.Add("_P1", new WeaverQueryVal(e2.Id)); expectParams.Add("_P2", new WeaverQueryVal("EHE")); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
public void AddEdge() { var plc = new PersonLikesCandy(); plc.Enjoyment = 0.84f; plc.TimesEaten = 54; plc.Notes = "Tastes great!"; const string perId = "a99"; const string candyId = "x1234"; var person = new Person { Id = perId }; var candy = new Candy { Id = candyId }; IWeaverQuery q = vGraph.AddEdge(person, plc, candy); int bracketI = q.Script.IndexOf('['); int bracketIClose = q.Script.LastIndexOf(']'); Assert.True(q.IsFinalized, "Incorrect IsFinalized."); Assert.NotNull(q.Script, "Script should be filled."); Assert.AreEqual("g.addEdge(g.v(_P0),g.v(_P1),_P2,[", q.Script.Substring(0, bracketI + 1), "Incorrect starting code."); Assert.AreEqual("]);", q.Script.Substring(bracketIClose), "Incorrect ending code."); //// string vals = q.Script.Substring(bracketI + 1, bracketIClose - bracketI - 1); Dictionary <string, string> pairMap = WeaverTestUtil.GetPropListDictionary(vals); Assert.AreEqual(3, pairMap.Keys.Count, "Incorrect Key count."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_TimesEaten), "Missing TimesEaten key."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_Enjoyment), "Missing Enjoyment key."); Assert.True(pairMap.ContainsKey(TestSchema.PersonLikesCandy_Notes), "Missing Notes key."); Assert.AreEqual("_P3", pairMap[TestSchema.PersonLikesCandy_TimesEaten], "Incorrect TimesEaten value."); Assert.AreEqual("_P4", pairMap[TestSchema.PersonLikesCandy_Enjoyment], "Incorrect Enjoyment value."); Assert.AreEqual("_P5", pairMap[TestSchema.PersonLikesCandy_Notes], "Incorrect Notes value."); var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(person.Id)); expectParams.Add("_P1", new WeaverQueryVal(candy.Id)); expectParams.Add("_P2", new WeaverQueryVal(TestSchema.PersonLikesCandy)); expectParams.Add("_P3", new WeaverQueryVal(plc.TimesEaten)); expectParams.Add("_P4", new WeaverQueryVal(plc.Enjoyment)); expectParams.Add("_P5", new WeaverQueryVal(plc.Notes)); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
/*--------------------------------------------------------------------------------------------*/ private static void AddEdge <TEdge>(ICreateOperationBuilder pCreCtx, IWeaverVarAlias pFromVar, TEdge pEdge, IWeaverVarAlias pToVar) where TEdge : IWeaverEdge { IWeaverQuery q = Weave.Inst.Graph.AddEdge(pFromVar, pEdge, pToVar); pCreCtx.AddQuery(q, true); pCreCtx.SetupLatestCommand(true); }
/*--------------------------------------------------------------------------------------------*/ public static Member GetMember(IOperationData pData, long pMemId) { IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, pMemId) .ToQuery(); return(pData.Get <Member>(q, "Test-OauthLoginGetMember")); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void AddVertex <T>(T pVertex, out IWeaverVarAlias <T> pNewVertexVar) where T : IVertex { IWeaverQuery q = Weave.Inst.Graph.AddVertex(pVertex); q = WeaverQuery.StoreResultAsVar(GetNextVarName(), q, out pNewVertexVar); Transaction.AddQuery(q); RegisterVarWithTxBuilder(pNewVertexVar); }
//Demonstrating some traversals shown here: //https://github.com/thinkaurelius/titan/wiki/Getting-Started //See unit tests in Weaver.Test.WeavExamples.TTraversal //////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static IWeaverQuery GetCharacterByName <T>(string pName, string pVarName, out IWeaverVarAlias <T> pCharVar) where T : Character, new() { IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <T>(x => x.Name, pName).Next() .ToQuery(); return(WeaverQuery.StoreResultAsVar(pVarName, q, out pCharVar)); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private static void AddVertex <T>(ICreateOperationBuilder pCreCtx, T pVertex, out IWeaverVarAlias <T> pAlias) where T : Vertex, new() { IWeaverQuery q = Weave.Inst.Graph.AddVertex(pVertex); q = WeaverQuery.StoreResultAsVar(pCreCtx.GetNextAliasName(), q, out pAlias); pCreCtx.AddQuery(q, true); pCreCtx.SetupLatestCommand(); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void AddQuery(IWeaverQuery pQuery, bool pCache = false, string pAppendScript = null) { vDataAcc.AddQuery(pQuery, pCache); if (pAppendScript != null) { vDataAcc.AppendScriptToLatestCommand(pAppendScript); } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public Member Execute(IOperationContext pOpCtx, long pMemberId, MemberType.Id pTypeId) { CreateFabMemberValidator.Type((byte)pTypeId); IWeaverVarAlias <Member> memAlias; IWeaverQuery memQ = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, pMemberId) .Next() .ToQueryAsVar("m", out memAlias); IWeaverQuery userQ = Weave.Inst.FromVar(memAlias) .DefinedByUser.ToUser .Property(x => x.VertexId) .ToQuery(); IWeaverQuery appQ = Weave.Inst.FromVar(memAlias) .DefinedByApp.ToApp .Property(x => x.VertexId) .ToQuery(); IDataAccess acc = pOpCtx.Data.Build(); acc.AddSessionStart(); acc.AddQuery(memQ, true); acc.OmitResultsOfLatestCommand(); acc.AddQuery(userQ, true); acc.AddQuery(appQ, true); acc.AddSessionClose(); IDataResult memRes = acc.Execute("Web-GetMemberDetails"); long userId = memRes.ToLongAt(2, 0); long appId = memRes.ToLongAt(3, 0); //// IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <Member>(x => x.VertexId, pMemberId) .SideEffect(new WeaverStatementSetProperty <Member>( x => x.MemberType, (byte)pTypeId)) .DefinedByUser.ToUser .DefinesMembers .Has(x => x.AppId, WeaverStepHasOp.EqualTo, appId) .SideEffect(new WeaverStatementSetProperty <UserDefinesMember>( x => x.MemberType, (byte)pTypeId)) .ToMember .DefinedByApp.ToApp .DefinesMembers .Has(x => x.UserId, WeaverStepHasOp.EqualTo, userId) .SideEffect(new WeaverStatementSetProperty <AppDefinesMember>( x => x.MemberType, (byte)pTypeId)) .ToMember .ToQuery(); return(pOpCtx.Data.Get <Member>(q, "Web-UpdateMemberType")); }
/*--------------------------------------------------------------------------------------------*/ private bool FindDuplicateEmail() { IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <Email>(x => x.Address, vEmail) .ToQuery(); Email e = vOpCtx.Data.Get <Email>(q, GetType().Name + "-FindDuplicateEmail"); return(e != null); }
public void AddQueryFinished() { IWeaverQuery wq = GetBasicQuery(); var tx = new WeaverTransaction(); tx.AddQuery(wq); tx.Finish(); WeaverTestUtil.CheckThrows <WeaverException>(true, () => tx.AddQuery(wq)); }
/*--------------------------------------------------------------------------------------------*/ public User GetUserByCredentials(IOperationData pData, string pUsername, string pPassword) { IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <User>(x => x.NameKey, pUsername.ToLower()) .Has(x => x.Password, WeaverStepHasOp.EqualTo, DataUtil.HashPassword(pPassword)) .ToQuery(); return(pData.Get <User>(q, "OauthLogin-GetUserByCredentials")); }
/*--------------------------------------------------------------------------------------------*/ public void GetVertexByDatabaseId <T>(T pVertex, out IWeaverVarAlias <T> pVertexVar, string pVarName = null) where T : IVertex, new() { IWeaverQuery q = Weave.Inst.Graph.V.Id <T>(pVertex.Id).ToQuery(); string varName = (pVarName ?? GetNextVarName()); q = WeaverQuery.StoreResultAsVar(varName, q, out pVertexVar); Transaction.AddQuery(q); RegisterVarWithTxBuilder(pVertexVar); }
/*--------------------------------------------------------------------------------------------*/ public void AddEdge <TEdge>(IWeaverVarAlias pFromVar, TEdge pEdge, IWeaverVarAlias pToVar) where TEdge : IWeaverEdge, new() { VerifyVar(pFromVar); VerifyVar(pToVar); IWeaverQuery q = Weave.Inst.Graph.AddEdge(pFromVar, pEdge, pToVar); Transaction.AddQuery(q); }
public void ToQuery() { var q = new WeaverQuery(); vElem.MockPath.SetupGet(x => x.Query).Returns(q); IWeaverQuery result = vElem.ToQuery(); Assert.AreEqual(q, result, "Incorrect result."); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void GetVertex <T>(long pVertexId, out IWeaverVarAlias <T> pVertexVar) where T : Vertex, new() { IWeaverQuery q = Weave.Inst.Graph.V .ExactIndex <T>((x => x.VertexId), pVertexId).Next() .ToQuery(); q = WeaverQuery.StoreResultAsVar(GetNextVarName(), q, out pVertexVar); Transaction.AddQuery(q); RegisterVarWithTxBuilder(pVertexVar); }
public void ColumnOrder() { IWeaverStepAs <Person> nullAlias; IWeaverStepAsColumn <Candy> candyPropAppendCol; IWeaverStepAsColumn <Candy> candyReplaceCol; IWeaverStepAsColumn <Candy> candyAppendCol; IWeaverVarAlias tableAlias; var path = WeavInst.Graph .V.ExactIndex <Person>(x => x.PersonId, 123) .AsColumn("PersObj") .As(out nullAlias) .OutLikesCandy.InVertex .AsColumn("CandyId", x => x.CandyId) .AsColumn("CandyCal", x => x.Calories, out candyPropAppendCol) .AsColumn("CandyReplace", out candyReplaceCol) .AsColumn("CandyAppend", out candyAppendCol) .Table(out tableAlias) .Iterate(); //script adjustments must occur before using ToQuery() candyPropAppendCol.AppendScript = ".append.script()"; candyReplaceCol.ReplaceScript = "123"; candyAppendCol.AppendScript = ".outE.inV"; IWeaverQuery q = path.ToQuery(); const string expect = "g.V('PerId',_P0)" + ".as('PersObj')" + ".as('step4')" + ".outE('PLC').inV" + ".as('CandyId')" + ".as('CandyCal')" + ".as('CandyReplace')" + ".as('CandyAppend')" + ".table(_TABLE11=new Table())" + "{}" + "{it}" + "{it.outE.inV}" + "{123}" + "{it.getProperty(_P1).append.script()}" + "{it.getProperty(_P2)}" + ".iterate();"; var expectParams = new Dictionary <string, IWeaverQueryVal>(); expectParams.Add("_P0", new WeaverQueryVal(123)); expectParams.Add("_P1", new WeaverQueryVal(TestSchema.Candy_Calories)); expectParams.Add("_P2", new WeaverQueryVal(TestSchema.Candy_CandyId)); Assert.AreEqual(expect, q.Script, "Incorrect query script."); WeaverTestUtil.CheckQueryParamsOriginalVal(q, expectParams); }
/*--------------------------------------------------------------------------------------------*/ public Member GetDataProvMemberByApp(IOperationData pData, long pAppId) { IWeaverQuery q = Weave.Inst.Graph .V.ExactIndex <App>(x => x.VertexId, pAppId) .DefinesMembers .Has(x => x.MemberType, WeaverStepHasOp.EqualTo, (byte)MemberType.Id.DataProv) .ToMember .ToQuery(); return(pData.Get <Member>(q, "OauthAccess-GetDPMemByApp")); }