/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pIgnoredToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, ToType); string alias = ParamAt <string>(item, 0); ITravStepParam p = Params[0]; string conflictAlias; if (!pPath.HasAlias(alias)) { throw item.NewStepFault(FabFault.Code.IncorrectParamValue, p.Name + " '" + alias + "' could not be found.", 0); } if (pPath.DoesBackTouchAs(alias)) { throw item.NewStepFault(FabFault.Code.InvalidStep, "Back('" + alias + "') cannot occur directly after the As(" + alias + ").", 0); } if (!pPath.AllowBackToAlias(alias, out conflictAlias)) { throw item.NewStepFault(FabFault.Code.InvalidStep, "Cannot traverse back to " + "the As(" + alias + ") step; it exists within the As(" + conflictAlias + ") and " + "Back(" + conflictAlias + ") traversal path.", 0); } pPath.AddBackToAlias(alias); pPath.AddScript(".back(" + pPath.AddParam(alias) + ")"); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, pToType); string op = ParamAt <string>(item, 0); var ev = new CreateFabEventor(); ev.Type = (byte)EventorType.Id.Start; //to make validator happy ev.Year = ParamAt <long>(item, 1); ev.Month = ParamAt <byte>(item, 2); ev.Day = ParamAt <byte>(item, 3); ev.Hour = ParamAt <byte>(item, 4); ev.Minute = ParamAt <byte>(item, 5); ev.Second = ParamAt <byte>(item, 6); var validator = new CreateFabEventorValidator(ev); validator.Validate(); long evDateTime = DataUtil.EventorTimesToLong( ev.Year, ev.Month, ev.Day, ev.Hour, ev.Minute, ev.Second); pPath.AddScript( ".has(" + pPath.AddParam(DbName.Vert.Factor.EventorDateTime) + ", " + GremlinUtil.GetStandardCompareOperation(op) + ", " + pPath.AddParam(evDateTime) + ")" ); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ConsumeFirstPathItem(pPath, pToType); pPath.AddScript( ".outE(" + pPath.AddParam(vEdgeDbName) + ")" + (vInVertex ? ".inV" : "") ); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ConsumeFirstPathItem(pPath, pToType); pPath.AddScript( ".has(" + pPath.AddParam(DbName.Vert.Vertex.VertexType) + ", " + GremlinUtil.GetStandardCompareOperation(GremlinUtil.Equal) + ", " + pPath.AddParam(vType) + ")" ); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, pToType); string val = ParamAt <string>(item, 0); pPath.AddScript( ".has(" + pPath.AddParam(vPropDbName) + ", " + GremlinUtil.GetElasticContainsOperation() + ", " + pPath.AddParam(val) + ")" ); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, pToType); string alias = ParamAt <string>(item, 0); ITravStepParam p = Params[0]; if (pPath.HasAlias(alias)) { throw item.NewStepFault(FabFault.Code.IncorrectParamValue, p.Name + " '" + alias + "' is already in use.", 0); } pPath.AddAlias(alias); pPath.AddScript(".as(" + pPath.AddParam(alias) + ")"); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, pToType); if (pPath.MemberId == null) { throw item.NewStepFault(FabFault.Code.InvalidStep, "There is no active Member."); } pPath.AddScript( ".has(" + pPath.AddParam(DbName.Vert.Vertex.VertexId) + ", " + pPath.AddParam(pPath.MemberId) + ")" ); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static void AddTypeFilterIfNecessary(ITravPath pPath, Type pStepType, Type pPathType) { if (pStepType != typeof(FabVertex) || pPathType == typeof(FabVertex)) { return; } //TODO: BUG this doesn't work for 'artifacts' and 'vertices' traversals pPath.AddScript( ".has(" + pPath.AddParam(DbName.Vert.Vertex.VertexType) + ", " + GremlinUtil.GetStandardCompareOperation(GremlinUtil.Equal) + ", " + pPath.AddParam((byte)ApiToDomain.GetVertexTypeId(pPathType)) + ")" ); }
/*--------------------------------------------------------------------------------------------*/ public override void ConsumePath(ITravPath pPath, Type pToType) { ITravPathItem item = ConsumeFirstPathItem(pPath, pToType); TVal val = ParamAt <TVal>(item, 0); if (UpdateValue != null) { val = UpdateValue(val); } pPath.AddScript( ".has(" + pPath.AddParam(vPropDbName) + ", " + GetGremlinEqualOp() + ", " + pPath.AddParam(val) + ")" ); }