////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public MemberAuthenticatedByOauthAccessSchema() : base(EdgeQuantity.ZeroOrMore)
        {
            SetNames("AuthenticatedBy", "ab");
            CreateFromOtherDirection = typeof(OauthAccessAuthenticatesMemberSchema);
            Sort = SortType.Desc;

            Timestamp           = Prop("Timestamp", "ts", (x => x.Timestamp), (x => x.FabTimestamp));
            Timestamp.SortIndex = 0;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public MemberCreatesArtifactSchema() : base(EdgeQuantity.ZeroOrMore)
        {
            SetNames("Creates", "c");
            CreateFromOtherDirection = typeof(ArtifactCreatedByMemberSchema);
            Sort = SortType.Desc;

            ////

            Timestamp           = Prop("Timestamp", "ts", (x => x.Timestamp), (x => x.FabTimestamp));
            Timestamp.SortIndex = 0;

            VertexType           = Prop("VertexType", "vt", (x => x.VertexType), (x => x.FabVertexType));
            VertexType.SortIndex = 1;
        }
Ejemplo n.º 3
0
        public override void Mouse_Down(Point pointNow)
        {
            foreach (var vertex in Globals.VertexData)
            {
                if (vertex.Coordinates.X - (Globals.VertRadius) <= pointNow.X &&
                    pointNow.X <= vertex.Coordinates.X + (Globals.VertRadius) &&
                    vertex.Coordinates.Y - (Globals.VertRadius) <= pointNow.Y &&
                    pointNow.Y <= vertex.Coordinates.Y + (Globals.VertRadius))
                {
                    vertexFirst = vertex;
                    break;
                }
            }

            if (vertexFirst != null)
            {
                if (vertexSecond == null)
                {
                    vertexSecond = vertexFirst;
                    vertexFirst  = null;

                    saveColor          = vertexSecond.Color;
                    vertexSecond.Color = Brushes.Red;
                }
                else
                {
                    if (vertexFirst == vertexSecond)
                    {
                        vertexSecond.Color = saveColor;
                        vertexFirst        = null;
                        vertexSecond       = null;
                    }
                    else
                    {
                        vertexSecond.Color = saveColor;

                        Edge edge = Globals.EdgesData.Find(match => (match.From == vertexSecond && match.To == vertexFirst));

                        if (edge != null)
                        {
                            EdgeProperty.PropertiesEdgeWindow(edge);
                        }

                        vertexFirst  = null;
                        vertexSecond = null;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected string GetAddQuery(T obj)
        {
            Type   thisType = obj.GetType();
            string query    = $"g.addV(\"{thisType.Name}\")";

            Object value = null;

            foreach (var item in thisType.GetProperties())
            {
                value = item.GetValue(obj);

                if (value == null)
                {
                    continue;
                }

                EdgeProperty edgeProperty = null;

                if (!string.IsNullOrEmpty(value.ToString()))
                {
                    edgeProperty = (EdgeProperty)item.GetCustomAttribute(typeof(EdgeProperty));
                    if (edgeProperty != null)
                    {
                        continue;
                    }

                    if (value is String)
                    {
                        query += $".property(\"{item.Name}\", \"{value.ToString().Replace("'", "’")}\")"; //Ajouter échap pour "
                    }
                    else if (value is Int32)
                    {
                        query += $".property(\"{item.Name}\", {value})";
                    }
                    else if (value is Enum)
                    {
                        query += $".property(\"{item.Name}\", {(int)value})";
                    }
                    else if (value is DateTime)
                    {
                        query += $".property(\"{item.Name}\", \"{((DateTime)value).ToString()}\")";
                    }
                }
            }

            return(query);
        }
Ejemplo n.º 5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public UserDefinesMemberSchema() : base(EdgeQuantity.ZeroOrMore)
        {
            SetNames("Defines", "d");
            CreateFromOtherDirection = typeof(MemberDefinedByUserSchema);
            Sort = SortType.Desc;

            ////

            Timestamp           = Prop("Timestamp", "ts", (x => x.Timestamp), (x => x.FabTimestamp));
            Timestamp.SortIndex = 0;

            MemberType           = Prop("MemberType", "mt", (x => x.MemberType), (x => x.FabMemberType));
            MemberType.SortIndex = 1;

            AppId           = PropFromEdge <MemberDefinedByAppSchema>("AppId", "pi");
            AppId.SortIndex = 2;
        }
Ejemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public ArtifactUsedAsRelatedByFactor() : base(EdgeQuantity.ZeroOrMore)
        {
            SetNames("UsedAsRelatedBy", "rb");
            CreateFromOtherDirection = typeof(FactorUsesRelatedArtifactSchema);
            Sort = SortType.Desc;

            ////

            Timestamp           = Prop("Timestamp", "ts", (x => x.Timestamp), (x => x.FabTimestamp));
            Timestamp.SortIndex = 0;

            DescriptorType = Prop("DescriptorType", "dt", (x => x.DescriptorType),
                                  (x => x.FabDescriptorType));
            DescriptorType.SortIndex = 1;

            PrimaryArtifactId           = PropFromEdge <FactorUsesPrimaryArtifactSchema>("PrimaryArtifactId", "pa");
            PrimaryArtifactId.SortIndex = 2;
        }
Ejemplo n.º 7
0
        public async override Task Execute(SaveEdgeCommand cmd)
        {
            // is the relationship already there?
            var edge = await UnitOfWork.Db.Edges.Where(
                e => e.SourceVertexId == cmd.SourceVertexId && e.TargetVertexId == cmd.TargetVertexId &&
                e.SchemaUri == cmd.SchemaUri &&
                e.Deleted == null).FirstOrDefaultAsync();

            var edgeExists = (edge != null);

            if (!edgeExists)
            {
                // relationship not found - create edge
                edge = new Entities.Edge()
                {
                    Id             = Guid.NewGuid(),
                    SourceVertexId = cmd.SourceVertexId,
                    TargetVertexId = cmd.TargetVertexId,
                    SchemaUri      = cmd.SchemaUri,
                    Created        = _clock.TimeStamp,
                };
                UnitOfWork.Db.Edges.Add(edge);
            }

            if (cmd.Props != null)
            {
                var edgeProps = await UnitOfWork.Db.EdgeProperties.Where(
                    p => p.EdgeId == edge.Id && p.Deleted == null)
                                .ToListAsync();

                foreach (var propModel in cmd.Props)
                {
                    var jsonValue = JsonConvention.SerializeObject(propModel.Value);

                    if (edgeExists)
                    {
                        // relationship found - find if the proeprty isn't already there
                        var prop = edgeProps.SingleOrDefault(p => p.SchemaUri == propModel.SchemaUri);

                        if (prop != null)
                        {
                            if (prop.JsonValue == jsonValue)
                            {
                                // nothing to update
                                continue;
                            }
                            else
                            {
                                // different value - close old property and continue
                                prop.Deleted = _clock.TimeStamp;
                            }
                        }
                    }

                    // if value is null do not add anything
                    if (propModel.Value == null)
                    {
                        continue;
                    }

                    // create property
                    var newProp = new EdgeProperty()
                    {
                        Id        = Guid.NewGuid(),
                        EdgeId    = edge.Id,
                        SchemaUri = propModel.SchemaUri,
                        Created   = _clock.TimeStamp,
                        JsonValue = jsonValue
                    };
                    UnitOfWork.Db.EdgeProperties.Add(newProp);

                    // prevent inserting duplicate props
                    edgeProps.Add(newProp);
                }
            }

            await Events.OnNext(new SaveEdgeCompletedEvent()
            {
                Command = cmd
            });
        }