/*--------------------------------------------------------------------------------------------*/ 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 void GetElementPropertyAttributes(Type pType, int pCount) { IList <WeaverPropPair> result = WeaverUtil.GetElementPropertyAttributes(pType); Assert.NotNull(result, "Result should be filled."); Assert.AreEqual(pCount, result.Count, "Incorrect result count."); }
/*--------------------------------------------------------------------------------------------*/ private void BuildMaps <T>(IEnumerable <Type> pTypes, Action <Type, T> pFinish) where T : WeaverElementAttribute { foreach (Type t in pTypes) { BuildType(t, pFinish); IList <WeaverPropPair> props = WeaverUtil.GetElementPropertyAttributes(t); foreach (WeaverPropPair p in props) { BuildProp(p); } } }
/*--------------------------------------------------------------------------------------------*/ public IWeaverPathPipeEnd BuildEdgeLabel <T>( Func <string, IWeaverVarAlias> pGetPropVarAliasByDbName) where T : IWeaverEdge { Type et = typeof(T); var e = WeaverTitanUtil.GetAndVerifyElementAttribute <WeaverTitanEdgeAttribute>(et); var ivc = e.InConn; var ovc = e.OutConn; var props = new List <WeaverPropPair>(); props.AddRange(WeaverUtil.GetElementPropertyAttributes(e.OutVertex)); props.AddRange(WeaverUtil.GetElementPropertyAttributes(e.InVertex)); var keys = new HashSet <string>(); var sigs = new HashSet <string>(); foreach (WeaverPropPair wpp in props) { WeaverTitanPropertyAttribute att = WeaverTitanUtil.GetAndVerifyTitanPropertyAttribute(wpp, true); if (att == null) { continue; } string alias = pGetPropVarAliasByDbName(att.DbName).Name; if (att.HasTitanVertexCentricIndex(et)) { keys.Add(alias); continue; } sigs.Add(alias); } //// AddCustom("makeType()"); AddCustom("name(" + Path.Query.AddParam(new WeaverQueryVal(e.DbName)) + ")"); if (keys.Count > 0) { AddCustom("primaryKey(" + string.Join(",", keys) + ")"); } if (sigs.Count > 0) { AddCustom("signature(" + string.Join(",", sigs) + ")"); } // An edge label is out-unique, if a vertex has at most one outgoing edge for that label. // "father" is of an out-unique edge label, since each god has at most one father. // https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview if (ivc == WeaverEdgeConn.InOne || ivc == WeaverEdgeConn.InZeroOrOne) { AddCustom("unique(IN)"); } if (ovc == WeaverEdgeConn.OutOne || ovc == WeaverEdgeConn.OutZeroOrOne) { AddCustom("unique(OUT)"); } return(AddCustom("makeEdgeLabel()")); }