Example #1
0
        public EdgeType GetEdgeType(string typename, bool typeadd = false)
        {
            EdgeType etype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                etype = db.edgetypes
                        .Where(et => et.name == typename)
                        .Select(et => new EdgeType
                {
                    typeId      = et.edgetypeid,
                    name        = et.name,
                    description = et.descr,
                    iconUrl     = et.iconurl
                })
                        .SingleOrDefault();
                if (etype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    edgetype netype = new edgetype {
                        name = typename
                    };
                    db.edgetypes.Add(netype);
                    db.SaveChanges();
                    etype = new EdgeType {
                        name = typename, typeId = netype.edgetypeid
                    };
                }
            }
            return(etype);
        }
Example #2
0
        private static edgetype CreateEdge([NotNull] DatasetDependency dependency)
        {
            var data = new List <datatype>
            {
                CreateData(_keyEdgeLabel, dependency.QualityCondition.Name),
                CreateData(_keyQualityCondition, dependency.QualityCondition.Name),
                CreateData(_keyFromDataset, dependency.FromDatasetNode.Dataset.Name),
                CreateData(_keyFromModel, dependency.FromDatasetNode.Dataset.Model.Name),
                CreateData(_keyFromParameter, dependency.FromParameterName),
                CreateData(_keyToDataset, dependency.ToDatasetNode.Dataset.Name),
                CreateData(_keyToModel, dependency.ToDatasetNode.Dataset.Model.Name),
                CreateData(_keyToParameter, dependency.ToParameterName),
                CreateData(_keyIssueType, dependency.Element.AllowErrors
                                                                             ? _issueTypeWarning
                                                                             : _issueTypeError),
                CreateData(_keyStopCondition, dependency.Element.StopOnError
                                                                                 ? "true"
                                                                                 : "false"),
                CreateData(_keyTest, dependency.QualityCondition.TestDescriptor.Name)
            };

            string categoryName = GetCategoryName(dependency);

            if (categoryName != null)
            {
                data.Add(CreateData(_keyCategory, categoryName));
            }

            if (StringUtils.IsNotEmpty(dependency.FromFilterExpression))
            {
                data.Add(CreateData(_keyFromFilterExpression, dependency.FromFilterExpression));
            }

            if (StringUtils.IsNotEmpty(dependency.ToFilterExpression))
            {
                data.Add(CreateData(_keyToFilterExpression, dependency.ToFilterExpression));
            }

            var result = new edgetype
            {
                data   = data.ToArray(),
                source = dependency.FromDatasetNode.NodeId,
                target = dependency.ToDatasetNode.NodeId
            };

            if (!dependency.Directed)
            {
                result.directed          = false;
                result.directedSpecified = true;
            }

            return(result);
        }
Example #3
0
 public void UpdateEdgeType(EdgeType udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         edgetype utype = db.edgetypes
                          .Where(et => et.edgetypeid == udata.typeId)
                          .SingleOrDefault();
         if (utype != null)
         {
             utype.name    = udata.name;
             utype.descr   = udata.description;
             utype.iconurl = udata.iconUrl;
             db.SaveChanges();
         }
     }
 }
Example #4
0
        public EdgeType AddEdgeType(EdgeType etype)
        {
            EdgeType typeval = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                //check that we don't already have this name
                int ecount = db.edgetypes.Where(n => n.name == etype.name).Count();
                if (ecount == 0)
                {
                    //Go ahead and add it
                    edgetype addtype = new edgetype {
                        name = etype.name, descr = etype.description, iconurl = etype.iconUrl
                    };
                    db.edgetypes.Add(addtype);
                    db.SaveChanges();
                    typeval = new EdgeType {
                        typeId = addtype.edgetypeid, name = addtype.name, description = addtype.descr, iconUrl = addtype.iconurl
                    };
                }
                else
                {
                    typeval = db.edgetypes
                              .Where(n => n.name == etype.name)
                              .Select(n => new EdgeType
                    {
                        typeId      = n.edgetypeid,
                        name        = n.name,
                        description = n.descr,
                        iconUrl     = n.iconurl
                    })
                              .FirstOrDefault();
                }
            }
            return(typeval);
        }