public ServiceVertexView(IVertexView myVertexView)
        {
            var singleEdges = myVertexView.GetAllSingleEdges();

            SingleEdges = (singleEdges == null) ? null : singleEdges.Select(x => new Tuple <string, ServiceSingleEdgeView>(x.Item1, new ServiceSingleEdgeView(x.Item2))).ToList();
            var hyperEdges = myVertexView.GetAllHyperEdges();

            HyperEdges = (hyperEdges == null) ? null : hyperEdges.Select(x => new Tuple <string, ServiceHyperEdgeView>(x.Item1, new ServiceHyperEdgeView(x.Item2))).ToList();
            var properties = myVertexView.GetAllProperties();

            if (properties == null)
            {
                Properties = null;
            }
            else
            {
                Properties = properties.Select(x =>
                {
                    object value = ConvertHelper.ToServiceObject(x.Item2);
                    if (value != null)
                    {
                        return(new Tuple <string, object>(x.Item1, value));
                    }
                    else
                    {
                        return(x);
                    }
                }).ToList();
            }
        }
        public bool IsSatisfyHaving(IVertexView myDBObjectReadoutGroup)
        {
            if (TypeOfBinaryExpression == TypesOfBinaryExpression.LeftComplex)
            {
                String          attributeName = null;
                ValueDefinition leftValue     = null;

                if (!EvaluateHaving(myDBObjectReadoutGroup, _Left, out attributeName, out leftValue))
                {
                    return(false);
                }


                throw new NotImplementedQLException("TODO");
                //var resultValue = Operator.SimpleOperation(leftValue, ((ValueDefinition)_Right), TypeOfBinaryExpression);
                //return (Boolean)((resultValue as ValueDefinition).Value);
            }

            else if (TypeOfBinaryExpression == TypesOfBinaryExpression.RightComplex)
            {
                String          attributeName = null;
                ValueDefinition rightValue    = null;

                if (!EvaluateHaving(myDBObjectReadoutGroup, _Right, out attributeName, out rightValue))
                {
                    return(false);
                }

                throw new NotImplementedQLException("TODO");
                //var resultValue = Operator.SimpleOperation(((ValueDefinition)_Left), rightValue, TypeOfBinaryExpression);
                //return (Boolean)((resultValue as ValueDefinition).Value);
            }

            throw new NotImplementedQLException("");
        }
Exemple #3
0
        public ServiceVertexView(IVertexView myVertexView)
        {
            var singleEdges = myVertexView.GetAllSingleEdges();

            SingleEdges = (singleEdges == null) ? null : singleEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceSingleEdgeView(_.Edge));
            var hyperEdges = myVertexView.GetAllHyperEdges();

            HyperEdges = (hyperEdges == null) ? null : hyperEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceHyperEdgeView(_.Edge));
            var properties = myVertexView.GetAllProperties();

            if (properties == null)
            {
                Properties = null;
            }
            else
            {
                Properties = properties.ToDictionary(_ => _.PropertyName, _ =>
                {
                    object value = ConvertHelper.ToServiceObject(_.Property);
                    if (value != null)
                    {
                        return(value);
                    }
                    else
                    {
                        return(_.Property);
                    }
                });
            }
        }
Exemple #4
0
        private String GenerateVertexViewHTML(IVertexView aVertex)
        {
            StringBuilder Output = new StringBuilder();

            // take one IVertexView and traverse through it
            #region Vertex Properties
            if (aVertex.GetCountOfProperties() > 0)
            {
                //Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- VertexProperties -->");
                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                    }
                    else
                    if (_property.Item2 is Stream)
                    {
                        Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>");
                    }
                    else
                    {
                        Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>");
                    }
                }
                //Output.Append("</table> <!-- VertexProperties -->");
            }
            #endregion

            #region Edges
            Output.Append("<tr><td><td><table class=\"gql_table\"border=\"1\"> <!-- Edges -->");
            Output.Append("<tr><td style=\"width:250px\">edges</td><td style=\"width:400px\">");

            foreach (var _edge in aVertex.GetAllEdges())
            {
                if (_edge.Item2 == null)
                {
                    Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                }
                else
                {
                    Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\">").Append(GenerateEdgeViewHTML(_edge.Item2)).Append("</td></tr>");
                }
            }

            Output.Append("</td></td></tr>");
            Output.Append("</table> <!-- Edges -->");
            // add to the results...
            //_results.Add(new JObject(new JProperty("edges", _edges)));
            #endregion

            return(Output.ToString());
        }
 public ServiceVertexView(IVertexView myVertexView)
 {
     var singleEdges = myVertexView.GetAllSingleEdges();
     SingleEdges = (singleEdges == null) ? null : singleEdges.Select(x => new Tuple<string, ServiceSingleEdgeView>(x.Item1, new ServiceSingleEdgeView(x.Item2))).ToList();
     var hyperEdges = myVertexView.GetAllHyperEdges();
     HyperEdges = (hyperEdges == null) ? null : hyperEdges.Select(x => new Tuple<string, ServiceHyperEdgeView>(x.Item1, new ServiceHyperEdgeView(x.Item2))).ToList();
     var properties = myVertexView.GetAllProperties();
     if (properties == null)
         Properties = null;
     else
         Properties = properties.Select(x =>
         {
             object value = ConvertHelper.ToServiceObject(x.Item2);
             if (value != null)
                 return new Tuple<string, object>(x.Item1, value);
             else
                 return x;
         }).ToList();
 }
Exemple #6
0
 public ServiceVertexView(IVertexView myVertexView)
 {
     var singleEdges = myVertexView.GetAllSingleEdges();
     SingleEdges = (singleEdges == null) ? null : singleEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceSingleEdgeView(_.Edge));
     var hyperEdges = myVertexView.GetAllHyperEdges();
     HyperEdges = (hyperEdges == null) ? null : hyperEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceHyperEdgeView(_.Edge));
     var properties = myVertexView.GetAllProperties();
     if (properties == null)
         Properties = null;
     else
         Properties = properties.ToDictionary(_ => _.PropertyName, _ =>
             {
                 object value = ConvertHelper.ToServiceObject(_.Property);
                 if (value != null)
                     return value;
                 else
                     return _.Property;
             });
 }
Exemple #7
0
        /// <summary>
        /// Parsing an single edge.
        /// </summary>
        /// <param name="mySingleEdges">The single edge.</param>
        /// <returns>An single edge view.</returns>
        private ISingleEdgeView ParseSingleEdge(XmlNode mySingleEdges)
        {
            var         edgeProperties = new Dictionary <String, Object>();
            IVertexView target         = null;

            if (mySingleEdges.HasChildNodes)
            {
                var edgeItems = mySingleEdges.FirstChild;

                while (edgeItems != null)
                {
                    switch (edgeItems.Name)
                    {
                    case "Properties":
                        var prop = edgeItems.FirstChild;

                        while (prop != null)
                        {
                            var edgeProp = ParseProperties(prop);
                            edgeProperties.Add(edgeProp.Item1, edgeProp.Item2);
                            prop = prop.NextSibling;
                        }

                        break;

                    case "TargetVertex":
                        target = ParseVertex(edgeItems);
                        break;
                    }

                    edgeItems = edgeItems.NextSibling;
                }
            }

            return(new sones.GraphQL.Result.SingleEdgeView(new Dictionary <String, Object>(edgeProperties), target));
        }
Exemple #8
0
        /// <summary>
        /// Generates a xml vertex view class.
        /// </summary>
        /// <param name="aVertex">The vertex view of the query result.</param>
        /// <returns>An generated xml class.</returns>
        private SchemaToClassesGenerator.VertexView GenerateVertexView(IVertexView aVertex)
        {
            var resultVertex = new SchemaToClassesGenerator.VertexView();

            if (aVertex != null)
            {
                #region properties

                List<Property> properties = new List<Property>();

                foreach (var aProperty in aVertex.GetAllProperties())
                {
                    var property = new Property();

                    property.ID = aProperty.Item1;

                    if (aProperty.Item2 != null)
                    {
                        if (aProperty.Item2 is ICollectionWrapper)
                        {
                            HandleListProperties((ICollectionWrapper)aProperty.Item2, ref property);
                        }
                        else
                        {

                            if (aProperty.Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType)))
                            {
                                property.Value = ((AUserdefinedDataType)aProperty.Item2).Value;
                            }
                            else
                            {
                                property.Value = aProperty.Item2.ToString();                                
                            }

                            property.Type = aProperty.Item2.GetType().Name;
                        }
                        
                    }
                    else
                    {
                        property.Value = String.Empty;
                        property.Type = "null";
                    }

                    properties.Add(property);
                }

                resultVertex.Properties = properties.ToArray();

                #endregion

                #region binaries

                List<BinaryData> binProperties = new List<BinaryData>();

                foreach (var aProperty in aVertex.GetAllBinaryProperties())
                {
                    var binProp = new BinaryData();

                    binProp.ID = aProperty.Item1;
                    var content = new byte[aProperty.Item2.Length];
                    aProperty.Item2.Read(content, 0, content.Length);

                    binProp.Content = content;

                    binProperties.Add(binProp);
                }

                resultVertex.BinaryProperties = binProperties.ToArray();

                #endregion

                #region edges

                List<SchemaToClassesGenerator.EdgeView> edges = new List<SchemaToClassesGenerator.EdgeView>();

                foreach (var aEdge in aVertex.GetAllEdges())
                {
                    if (aEdge.Item2 is IHyperEdgeView)
                    {
                        List<Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>> innerVertices = new List<Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>>();

                        #region single edges

                        foreach (var SingleEdges in ((sones.GraphQL.Result.HyperEdgeView)aEdge.Item2).GetAllEdges())
                        {
                            innerVertices.Add(new Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>(GenerateVertexView(SingleEdges.GetTargetVertex()), SingleEdges.GetAllProperties()));
                        }

                        #endregion

                        var hyperEdge = new SchemaToClassesGenerator.HyperEdgeView();

                        hyperEdge.Name = aEdge.Item1;

                        #region set hyperedge properties

                        var edgeProperties = aEdge.Item2.GetAllProperties().ToArray();
                        hyperEdge.Properties = new Property[edgeProperties.Count()];

                        for (Int32 i = 0; i < edgeProperties.Count(); i++)
                        {
                            hyperEdge.Properties[i] = new Property();
                            hyperEdge.Properties[i].ID = edgeProperties[i].Item1;

                            if (edgeProperties[i].Item2 is ICollectionWrapper)
                            {
                                HandleListProperties((ICollectionWrapper)edgeProperties[i].Item2, ref hyperEdge.Properties[i]);
                            }
                            else
                            {
                                if (edgeProperties[i].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType)))
                                {
                                    hyperEdge.Properties[i].Value = ((AUserdefinedDataType)edgeProperties[i].Item2).Value;
                                }
                                else
                                {
                                    hyperEdge.Properties[i].Value = edgeProperties[i].Item2.ToString();
                                }

                                hyperEdge.Properties[i].Type = edgeProperties[i].Item2.GetType().Name;
                            }                            
                        }

                        #endregion

                        hyperEdge.SingleEdge = new SchemaToClassesGenerator.SingleEdgeView[innerVertices.Count];

                        for (Int32 i = 0; i < innerVertices.Count; i++)
                        {
                            hyperEdge.SingleEdge[i] = new SchemaToClassesGenerator.SingleEdgeView();
                            var SingleEdgesProperties = innerVertices[i].Item2.ToArray();
                            
                            hyperEdge.SingleEdge[i].Properties = new Property[SingleEdgesProperties.Count()];

                            #region single edge properties

                            for (Int32 j = 0; j < SingleEdgesProperties.Count(); j++)
                            {
                                hyperEdge.SingleEdge[i].Properties[j] = new Property();
                                hyperEdge.SingleEdge[i].Properties[j].ID = SingleEdgesProperties[j].Item1;

                                if (SingleEdgesProperties[j].Item2 is ICollectionWrapper)
                                {
                                    HandleListProperties((ICollectionWrapper)SingleEdgesProperties[j].Item2, ref hyperEdge.SingleEdge[i].Properties[j]);
                                }
                                else
                                {
                                    if (SingleEdgesProperties[j].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType)))
                                    {
                                        hyperEdge.SingleEdge[i].Properties[j].Value = ((AUserdefinedDataType)SingleEdgesProperties[j].Item2).Value;
                                    }
                                    else
                                    {
                                        hyperEdge.SingleEdge[i].Properties[j].Value = SingleEdgesProperties[j].Item2.ToString();
                                    }

                                    hyperEdge.SingleEdge[i].Properties[j].Type = SingleEdgesProperties[j].Item2.GetType().Name;
                                }
                            }

                            #endregion

                            #region target vertex

                            hyperEdge.SingleEdge[i].TargetVertex = new SchemaToClassesGenerator.VertexView();
                            
                            if (innerVertices[i].Item1.Properties != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.Properties = innerVertices[i].Item1.Properties.ToArray();
                            }

                            if (innerVertices[i].Item1.BinaryProperties != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.BinaryProperties = innerVertices[i].Item1.BinaryProperties.ToArray();
                            }

                            if (innerVertices[i].Item1.Edges != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.Edges = innerVertices[i].Item1.Edges.ToArray();
                            }

                            #endregion
                        }

                        edges.Add(hyperEdge);

                    }
                    else
                    {
                        var SingleEdges = new SchemaToClassesGenerator.SingleEdgeView();

                        SingleEdges.Name = aEdge.Item1;

                        var edgeProperties = aEdge.Item2.GetAllProperties().ToArray();

                        #region properties

                        SingleEdges.Properties = new Property[edgeProperties.Count()];

                        for (Int32 i = 0; i < edgeProperties.Count(); i++)
                        {
                            SingleEdges.Properties[i] = new Property();
                            SingleEdges.Properties[i].ID = edgeProperties[i].Item1;

                            if (edgeProperties[i].Item2 is ICollectionWrapper)
                            {
                                HandleListProperties((ICollectionWrapper)edgeProperties[i].Item2, ref SingleEdges.Properties[i]);
                            }
                            else
                            {
                                if (edgeProperties[i].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType)))
                                {
                                    SingleEdges.Properties[i].Value = ((AUserdefinedDataType)edgeProperties[i].Item2).Value;
                                }
                                else
                                {
                                    SingleEdges.Properties[i].Value = edgeProperties[i].Item2.ToString();
                                }

                                SingleEdges.Properties[i].Type = edgeProperties[i].Item2.GetType().Name;
                            }
                        }

                        #endregion

                        #region target vertex

                        SingleEdges.TargetVertex = new SchemaToClassesGenerator.VertexView();
                        
                        var edgeTargetVertex = ((sones.GraphQL.Result.SingleEdgeView)aEdge.Item2).GetTargetVertex();

                        var targetVertex = GenerateVertexView(edgeTargetVertex);

                        if (edgeTargetVertex != null)
                        {
                            SingleEdges.TargetVertex.Properties = targetVertex.Properties.ToArray();
                            SingleEdges.TargetVertex.BinaryProperties = targetVertex.BinaryProperties.ToArray();
                            SingleEdges.TargetVertex.Edges = targetVertex.Edges.ToArray();
                        }

                        #endregion

                        edges.Add(SingleEdges);

                    }

                #endregion

                }

                resultVertex.Edges = edges.ToArray();

                #endregion
            }
            return resultVertex;
        }
Exemple #9
0
 /// <summary>
 /// The single edge view constructor.
 /// </summary>
 /// <param name="myProperties">The properties of the edge.</param>
 /// <param name="myTargetVertex">The target vertex of the edge.</param>
 public SingleEdgeView(IDictionary <String, Object> myProperties, IVertexView myTargetVertex)
 {
     _propertyList = myProperties;
     _targetVertex = myTargetVertex;
 }
Exemple #10
0
        /// <summary>
        /// Generates an json vertex view.
        /// </summary>
        /// <param name="aVertex">The vertex.</param>
        /// <returns>An jarray contains the json vertex view.</returns>
        private JArray GenerateVertexViewJSON(IVertexView aVertex)
        {
            JArray _results = new JArray();

            if (aVertex != null)
            {
                // take one IVertexView and traverse through it
                #region Vertex Properties

                JObject _properties = new JObject();

                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                        _properties.Add(new JProperty(_property.Item1, ""));
                    else
                        if (_property.Item2 is Stream)
                        {
                            _properties.Add(new JProperty(_property.Item1, "BinaryProperty"));
                        }
                        else
                        {
                            if (_property.Item2 is ICollectionWrapper)
                            {
                                _properties.Add(new JProperty(_property.Item1, HandleListProperties((ICollectionWrapper)_property.Item2)));
                            }
                            else
                            {
                                _properties.Add(new JProperty(_property.Item1, _property.Item2.ToString()));
                            }
                        }
                }
                // add to the results...
                _results.Add(new JObject(new JProperty("Properties", new JObject(_properties))));

                #endregion

                #region Edges

                JArray _edges = new JArray();

                foreach (var _edge in aVertex.GetAllEdges())
                {
                    if (_edge.Item2 == null)
                    {
                        _edges.Add(new JObject(new JProperty(_edge.Item1, "")));
                    }
                    else
                    {
                        JArray _newEdge = GenerateEdgeViewJSON(_edge.Item2);
                        _edges.Add(new JObject(new JProperty(_edge.Item2.GetType().Name, new JObject(new JProperty(_edge.Item1, _newEdge)))));
                    }
                }
                // add to the results...
                _results.Add(new JObject(new JProperty("Edges", _edges)));

                #endregion
            }
            return _results;
        }
Exemple #11
0
        /// <summary>
        /// Generates a xml vertex view class.
        /// </summary>
        /// <param name="aVertex">The vertex view of the query result.</param>
        /// <returns>An generated xml class.</returns>
        private SchemaToClassesGenerator.VertexView GenerateVertexView(IVertexView aVertex)
        {
            var resultVertex = new SchemaToClassesGenerator.VertexView();

            if (aVertex != null)
            {
                #region properties

                List <Property> properties = new List <Property>();

                foreach (var aProperty in aVertex.GetAllProperties())
                {
                    var property = new Property();

                    property.ID = aProperty.PropertyName;

                    if (aProperty.Property != null)
                    {
                        if (aProperty.Property is ICollectionWrapper)
                        {
                            HandleListProperties((ICollectionWrapper)aProperty.Property, ref property);
                        }
                        else
                        {
                            property.Value = aProperty.Property.ToString();
                            property.Type  = aProperty.Property.GetType().Name;
                        }
                    }
                    else
                    {
                        property.Value = String.Empty;
                        property.Type  = "null";
                    }

                    properties.Add(property);
                }

                resultVertex.Properties = properties.ToArray();

                #endregion

                #region binaries

                List <BinaryData> binProperties = new List <BinaryData>();

                foreach (var aProperty in aVertex.GetAllBinaryProperties())
                {
                    var binProp = new BinaryData();

                    binProp.ID = aProperty.PropertyName;
                    var content = new byte[aProperty.BinaryPropery.Length];
                    aProperty.BinaryPropery.Read(content, 0, content.Length);

                    binProp.Content = content;

                    binProperties.Add(binProp);
                }

                resultVertex.BinaryProperties = binProperties.ToArray();

                #endregion

                #region edges

                List <SchemaToClassesGenerator.EdgeView> edges = new List <SchemaToClassesGenerator.EdgeView>();

                foreach (var aEdge in aVertex.GetAllEdges())
                {
                    if (aEdge.Edge is IHyperEdgeView)
                    {
                        List <Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> > > innerVertices = new List <Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> > >();

                        #region single edges

                        foreach (var SingleEdges in ((sones.GraphQL.Result.HyperEdgeView)aEdge.Edge).GetAllEdges())
                        {
                            innerVertices.Add(new Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> >(GenerateVertexView(SingleEdges.GetTargetVertex()), SingleEdges.GetAllProperties()));
                        }

                        #endregion

                        var hyperEdge = new SchemaToClassesGenerator.HyperEdgeView();

                        hyperEdge.Name = aEdge.EdgeName;

                        #region set hyperedge properties

                        var edgeProperties = aEdge.Edge.GetAllProperties().ToArray();
                        hyperEdge.Properties = new Property[edgeProperties.Count()];

                        for (Int32 i = 0; i < edgeProperties.Count(); i++)
                        {
                            hyperEdge.Properties[i]    = new Property();
                            hyperEdge.Properties[i].ID = edgeProperties[i].PropertyName;

                            if (edgeProperties[i].Property is ICollectionWrapper)
                            {
                                HandleListProperties((ICollectionWrapper)edgeProperties[i].Property, ref hyperEdge.Properties[i]);
                            }
                            else
                            {
                                hyperEdge.Properties[i].Type  = edgeProperties[i].Property.GetType().Name;
                                hyperEdge.Properties[i].Value = edgeProperties[i].Property.ToString();
                            }
                        }

                        #endregion

                        hyperEdge.SingleEdge = new SchemaToClassesGenerator.SingleEdgeView[innerVertices.Count];

                        for (Int32 i = 0; i < innerVertices.Count; i++)
                        {
                            hyperEdge.SingleEdge[i] = new SchemaToClassesGenerator.SingleEdgeView();
                            var SingleEdgesProperties = innerVertices[i].Item2.ToArray();

                            hyperEdge.SingleEdge[i].Properties = new Property[SingleEdgesProperties.Count()];

                            #region single edge properties

                            for (Int32 j = 0; j < SingleEdgesProperties.Count(); j++)
                            {
                                hyperEdge.SingleEdge[i].Properties[j]    = new Property();
                                hyperEdge.SingleEdge[i].Properties[j].ID = SingleEdgesProperties[j].PropertyName;

                                if (SingleEdgesProperties[j].Property is ICollectionWrapper)
                                {
                                    HandleListProperties((ICollectionWrapper)SingleEdgesProperties[j].Property, ref hyperEdge.SingleEdge[i].Properties[j]);
                                }
                                else
                                {
                                    hyperEdge.SingleEdge[i].Properties[j].Type  = SingleEdgesProperties[j].Property.GetType().Name;
                                    hyperEdge.SingleEdge[i].Properties[j].Value = SingleEdgesProperties[j].Property.ToString();
                                }
                            }

                            #endregion

                            #region target vertex

                            hyperEdge.SingleEdge[i].TargetVertex = new SchemaToClassesGenerator.VertexView();

                            if (innerVertices[i].Item1.Properties != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.Properties = innerVertices[i].Item1.Properties.ToArray();
                            }

                            if (innerVertices[i].Item1.BinaryProperties != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.BinaryProperties = innerVertices[i].Item1.BinaryProperties.ToArray();
                            }

                            if (innerVertices[i].Item1.Edges != null)
                            {
                                hyperEdge.SingleEdge[i].TargetVertex.Edges = innerVertices[i].Item1.Edges.ToArray();
                            }

                            #endregion
                        }

                        edges.Add(hyperEdge);
                    }
                    else
                    {
                        var SingleEdges = new SchemaToClassesGenerator.SingleEdgeView();

                        SingleEdges.Name = aEdge.EdgeName;

                        var edgeProperties = aEdge.Edge.GetAllProperties().ToArray();

                        #region properties

                        SingleEdges.Properties = new Property[edgeProperties.Count()];

                        for (Int32 i = 0; i < edgeProperties.Count(); i++)
                        {
                            SingleEdges.Properties[i]    = new Property();
                            SingleEdges.Properties[i].ID = edgeProperties[i].PropertyName;

                            if (edgeProperties[i].Property is ICollectionWrapper)
                            {
                                HandleListProperties((ICollectionWrapper)edgeProperties[i].Property, ref SingleEdges.Properties[i]);
                            }
                            else
                            {
                                SingleEdges.Properties[i].Type  = edgeProperties[i].Property.GetType().Name;
                                SingleEdges.Properties[i].Value = edgeProperties[i].Property.ToString();
                            }
                        }

                        #endregion

                        #region target vertex

                        SingleEdges.TargetVertex = new SchemaToClassesGenerator.VertexView();

                        var edgeTargetVertex = ((sones.GraphQL.Result.SingleEdgeView)aEdge.Edge).GetTargetVertex();

                        var targetVertex = GenerateVertexView(edgeTargetVertex);

                        if (edgeTargetVertex != null)
                        {
                            SingleEdges.TargetVertex.Properties       = targetVertex.Properties.ToArray();
                            SingleEdges.TargetVertex.BinaryProperties = targetVertex.BinaryProperties.ToArray();
                            SingleEdges.TargetVertex.Edges            = targetVertex.Edges.ToArray();
                        }

                        #endregion

                        edges.Add(SingleEdges);
                    }

                    #endregion
                }

                resultVertex.Edges = edges.ToArray();

                #endregion
            }
            return(resultVertex);
        }
        private Boolean EvaluateHaving(IVertexView myDBObjectReadoutGroup, AExpressionDefinition complexValue, out String attributeName, out ValueDefinition simpleValue)
        {

            //VertexType graphDBType = null;
            attributeName = null;
            simpleValue = null;

            if (complexValue is IDChainDefinition)
            {
                if (((IDChainDefinition)complexValue).LastAttribute == null)
                {
                    if (((IDChainDefinition)complexValue).Last() is ChainPartFuncDefinition)
                    {
                        var func = (((IDChainDefinition)complexValue).Last() as ChainPartFuncDefinition);
                        if (func.Parameters.Count != 1)
                        {
                            throw new NotImplementedQLException("");
                        }

                        attributeName = func.SourceParsedString;
                        //graphDBType = func.Parameters.First().LastAttribute.GetDBType(dbContext.DBTypeManager);
                    }
                    else if (((IDChainDefinition)complexValue).IsUndefinedAttribute)
                    {
                        attributeName = ((IDChainDefinition)complexValue).UndefinedAttribute;

                        //return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                    }
                    else
                    {
                        //return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                    }
                }
                else
                {
                    attributeName = ((IDChainDefinition)complexValue).LastAttribute.Name;
                    //graphDBType = ((IDChainDefinition)complexValue).LastAttribute.GetDBType(dbContext.DBTypeManager);
                }
            }
            else
            {
                if (complexValue is AggregateDefinition)
                {
                    var func = (complexValue as AggregateDefinition);
                    if (func.ChainPartAggregateDefinition.Parameters.Count != 1)
                        throw new NotImplementedQLException("");

                    attributeName = func.ChainPartAggregateDefinition.SourceParsedString;
                    //graphDBType = func.ContainingIDNodes.First().LastAttribute.GetDBType(dbContext.DBTypeManager);
                }
                else
                {
                    throw new NotImplementedQLException("");
                }
            }

            if (myDBObjectReadoutGroup.HasProperty(attributeName))
            {
                simpleValue = new ValueDefinition(myDBObjectReadoutGroup.GetProperty<Object>(attributeName));
                return true;
            }

            return false;

        }
Exemple #13
0
        private String GenerateVertexViewHTML(IVertexView aVertex)
        {
            StringBuilder Output = new StringBuilder();
            // take one IVertexView and traverse through it
            #region Vertex Properties
            if (aVertex.GetCountOfProperties() > 0)
            {
                //Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- VertexProperties -->");
                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                        Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                    else
                        if (_property.Item2 is Stream)
                            Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>");
                        else
                            Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>");
                }
                //Output.Append("</table> <!-- VertexProperties -->");
            }
            #endregion

            #region Edges
            Output.Append("<tr><td><td><table class=\"gql_table\"border=\"1\"> <!-- Edges -->");
            Output.Append("<tr><td style=\"width:250px\">edges</td><td style=\"width:400px\">");

            foreach (var _edge in aVertex.GetAllEdges())
            {
                if (_edge.Item2 == null)
                {
                    Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                }
                else
                {
                    Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\">").Append(GenerateEdgeViewHTML(_edge.Item2)).Append("</td></tr>");
                }
            }

            Output.Append("</td></td></tr>");
            Output.Append("</table> <!-- Edges -->");
            // add to the results...
            //_results.Add(new JObject(new JProperty("edges", _edges)));
            #endregion

            return Output.ToString();
        }
Exemple #14
0
        public bool Equals(IVertexView x, IVertexView y)
        {
            if (x.GetCountOfProperties() != y.GetCountOfProperties())
            {
                return(false);
            }

            var xProperties = x.GetAllProperties().ToList();
            var yProperties = y.GetAllProperties().ToList();

            if (xProperties.Count != xProperties.Count)
            {
                return(false);
            }


            for (int i = 0; i <= xProperties.Count; i++)
            {
                if (xProperties[i].PropertyName != yProperties[i].PropertyName)
                {
                    return(false);
                }

                if (!xProperties[i].Property.Equals(yProperties[i].Property))
                {
                    return(false);
                }
            }

            var xBinaryProperties = x.GetAllBinaryProperties().ToList();
            var yBinaryProperties = y.GetAllBinaryProperties().ToList();

            if (xBinaryProperties.Count != yBinaryProperties.Count)
            {
                return(false);
            }

            for (int i = 0; i <= xBinaryProperties.Count; i++)
            {
                if (xBinaryProperties[i].PropertyName != yBinaryProperties[i].PropertyName)
                {
                    return(false);
                }

                if (!xBinaryProperties[i].BinaryPropery.Equals(yBinaryProperties[i].BinaryPropery))
                {
                    return(false);
                }
            }

            var xEdges = x.GetAllEdges().ToList();
            var yEdges = y.GetAllEdges().ToList();

            if (xEdges.Count != yEdges.Count)
            {
                return(false);
            }

            for (int i = 0; i <= xEdges.Count; i++)
            {
                if (xEdges[i].EdgeName != xEdges[i].EdgeName)
                {
                    return(false);
                }


                if (!this.Equals(xEdges[i].Edge, yEdges[i].Edge))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #15
0
 public int GetHashCode(IVertexView obj)
 {
     throw new NotImplementedException();
 }
Exemple #16
0
        /// <summary>
        /// Generates an text vertex view.
        /// </summary>
        /// <param name="aVertex">The vertex.</param>
        /// <param name="Header">The header.</param>
        /// <returns>An string, that contains the text vertex view.</returns>
        private String GenerateVertexViewText(String Header, IVertexView aVertex)
        {
            StringBuilder Output = new StringBuilder();

            // take one IVertexView and traverse through it
            #region Vertex Properties

            Output.AppendLine();

            if (aVertex.GetCountOfProperties() > 0)
            {
                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Property == null)
                    {
                        Output.AppendLine(Header + _property.PropertyName);
                    }
                    else
                    {
                        if (_property.Property is Stream)
                        {
                            Output.AppendLine(Header + _property.PropertyName + "\t BinaryProperty");
                        }
                        else
                        {
                            if (_property.Property is ICollectionWrapper)
                            {
                                Output.AppendLine(Header + _property.PropertyName);
                                HandleListProperties((ICollectionWrapper)_property.Property, Header, ref Output);
                            }
                            else
                            {
                                Output.AppendLine(Header + _property.PropertyName + "\t " + _property.Property.ToString());
                            }
                        }
                    }
                }
            }

            #endregion

            #region Edges

            Output.AppendLine(Header + "\t Edges:");

            foreach (var _edge in aVertex.GetAllEdges())
            {
                if (_edge.Edge == null)
                {
                    Output.AppendLine(Header + "\t\t" + _edge.EdgeName);
                }
                else
                {
                    Output.AppendLine(Header + "\t\t" + _edge.Edge.GetType().Name);
                    Output.AppendLine(Header + "\t\t" + _edge.EdgeName).Append(GenerateEdgeViewText(Header + "\t\t\t", _edge.Edge));
                }
            }

            #endregion

            return(Output.ToString());
        }
        public bool IsSatisfyHaving(IVertexView myDBObjectReadoutGroup)
        {

            if (TypeOfBinaryExpression == TypesOfBinaryExpression.LeftComplex)
            {
                String attributeName = null;
                ValueDefinition leftValue = null;

                if (!EvaluateHaving(myDBObjectReadoutGroup, _Left, out attributeName, out leftValue))
                {
                    return false;
                }


                throw new NotImplementedQLException("TODO");
                //var resultValue = Operator.SimpleOperation(leftValue, ((ValueDefinition)_Right), TypeOfBinaryExpression);
                //return (Boolean)((resultValue as ValueDefinition).Value);

            }

            else if (TypeOfBinaryExpression == TypesOfBinaryExpression.RightComplex)
            {
                String attributeName = null;
                ValueDefinition rightValue = null;

                if (!EvaluateHaving(myDBObjectReadoutGroup, _Right, out attributeName, out rightValue))
                {
                    return false;
                }

                throw new NotImplementedQLException("TODO");
                //var resultValue = Operator.SimpleOperation(((ValueDefinition)_Left), rightValue, TypeOfBinaryExpression);
                //return (Boolean)((resultValue as ValueDefinition).Value);

            }

            throw new NotImplementedQLException("");

        }
Exemple #18
0
        /// <summary>
        /// Generates an json vertex view.
        /// </summary>
        /// <param name="aVertex">The vertex.</param>
        /// <returns>An jarray contains the json vertex view.</returns>
        private JArray GenerateVertexViewJSON(IVertexView aVertex)
        {
            JArray _results = new JArray();

            if (aVertex != null)
            {
                // take one IVertexView and traverse through it
                #region Vertex Properties

                JObject _properties = new JObject();

                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        _properties.Add(new JProperty(_property.Item1, ""));
                    }
                    else
                    if (_property.Item2 is Stream)
                    {
                        _properties.Add(new JProperty(_property.Item1, "BinaryProperty"));
                    }
                    else
                    {
                        if (_property.Item2 is ICollectionWrapper)
                        {
                            _properties.Add(new JProperty(_property.Item1, HandleListProperties((ICollectionWrapper)_property.Item2)));
                        }
                        else
                        {
                            _properties.Add(new JProperty(_property.Item1, _property.Item2.ToString()));
                        }
                    }
                }
                // add to the results...
                _results.Add(new JObject(new JProperty("Properties", new JObject(_properties))));

                #endregion

                #region Edges

                JArray _edges = new JArray();

                foreach (var _edge in aVertex.GetAllEdges())
                {
                    if (_edge.Item2 == null)
                    {
                        _edges.Add(new JObject(new JProperty(_edge.Item1, "")));
                    }
                    else
                    {
                        JArray _newEdge = GenerateEdgeViewJSON(_edge.Item2);
                        _edges.Add(new JObject(new JProperty(_edge.Item2.GetType().Name, new JObject(new JProperty(_edge.Item1, _newEdge)))));
                    }
                }
                // add to the results...
                _results.Add(new JObject(new JProperty("Edges", _edges)));

                #endregion
            }
            return(_results);
        }
Exemple #19
0
        /// <summary>
        /// Generates an text vertex view.
        /// </summary>
        /// <param name="aVertex">The vertex.</param>
        /// <param name="Header">The header.</param>
        /// <returns>An string, that contains the text vertex view.</returns>
        private String GenerateVertexViewText(String Header, IVertexView aVertex)
        {
            StringBuilder Output = new StringBuilder();

            // take one IVertexView and traverse through it
            #region Vertex Properties

            Output.AppendLine();

            if (aVertex.GetCountOfProperties() > 0)
            {
                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        Output.AppendLine(Header + _property.Item1);
                    }
                    else
                    {
                        if (_property.Item2 is Stream)
                        {
                            Output.AppendLine(Header + _property.Item1 + "\t BinaryProperty");
                        }
                        else
                        {
                            if (_property.Item2 is ICollectionWrapper)
                            {
                                Output.AppendLine(Header + _property.Item1);
                                HandleListProperties((ICollectionWrapper)_property.Item2, Header, ref Output);
                            }
                            else
                            {
                                Output.AppendLine(Header + _property.Item1 + "\t " + _property.Item2.ToString());
                            }
                        }
                    }
                }
            }

            #endregion

            #region Edges

            Output.AppendLine(Header + "\t Edges:");

            foreach (var _edge in aVertex.GetAllEdges())
            {
                if (_edge.Item2 == null)
                {
                    Output.AppendLine(Header+"\t\t"+_edge.Item1);
                }
                else
                {
                    Output.AppendLine(Header+"\t\t"+_edge.Item2.GetType().Name);
                    Output.AppendLine(Header+"\t\t"+_edge.Item1).Append(GenerateEdgeViewText(Header+"\t\t\t",_edge.Item2));
                }
            }

            #endregion

            return Output.ToString();
        }
Exemple #20
0
 private void PrintWays(IVertexView current_vertex, int lev = 0)
 {
     for (int i = 0; i < 2 * lev; ++i)
         Console.Write(' ');
     if (current_vertex.HasProperty("VertexID"))
         Console.WriteLine(current_vertex.GetPropertyAsString("VertexID"));
     if (!current_vertex.HasEdge("path"))
         return;
     foreach (var edge in current_vertex.GetHyperEdge("path").GetAllEdges())
     {
         PrintWays(edge.GetTargetVertex(), lev + 1);
     }
 }
        private Boolean EvaluateHaving(IVertexView myDBObjectReadoutGroup, AExpressionDefinition complexValue, out String attributeName, out ValueDefinition simpleValue)
        {
            //VertexType graphDBType = null;
            attributeName = null;
            simpleValue   = null;

            if (complexValue is IDChainDefinition)
            {
                if (((IDChainDefinition)complexValue).LastAttribute == null)
                {
                    if (((IDChainDefinition)complexValue).Last() is ChainPartFuncDefinition)
                    {
                        var func = (((IDChainDefinition)complexValue).Last() as ChainPartFuncDefinition);
                        if (func.Parameters.Count != 1)
                        {
                            throw new NotImplementedQLException("");
                        }

                        attributeName = func.SourceParsedString;
                        //graphDBType = func.Parameters.First().LastAttribute.GetDBType(dbContext.DBTypeManager);
                    }
                    else if (((IDChainDefinition)complexValue).IsUndefinedAttribute)
                    {
                        attributeName = ((IDChainDefinition)complexValue).UndefinedAttribute;

                        //return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                    }
                    else
                    {
                        //return new Exceptional<bool>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                    }
                }
                else
                {
                    attributeName = ((IDChainDefinition)complexValue).LastAttribute.Name;
                    //graphDBType = ((IDChainDefinition)complexValue).LastAttribute.GetDBType(dbContext.DBTypeManager);
                }
            }
            else
            {
                if (complexValue is AggregateDefinition)
                {
                    var func = (complexValue as AggregateDefinition);
                    if (func.ChainPartAggregateDefinition.Parameters.Count != 1)
                    {
                        throw new NotImplementedQLException("");
                    }

                    attributeName = func.ChainPartAggregateDefinition.SourceParsedString;
                    //graphDBType = func.ContainingIDNodes.First().LastAttribute.GetDBType(dbContext.DBTypeManager);
                }
                else
                {
                    throw new NotImplementedQLException("");
                }
            }

            if (myDBObjectReadoutGroup.HasProperty(attributeName))
            {
                simpleValue = new ValueDefinition(myDBObjectReadoutGroup.GetProperty <Object>(attributeName));
                return(true);
            }

            return(false);
        }
Exemple #22
0
        /// <summary>
        /// Generates an text vertex view.
        /// </summary>
        /// <param name="aVertex">The vertex.</param>
        /// <param name="Header">The header.</param>
        /// <returns>An string, that contains the text vertex view.</returns>
        private String GenerateVertexViewText(String Header, IVertexView aVertex)
        {
            StringBuilder Output = new StringBuilder();

            // take one IVertexView and traverse through it
            #region Vertex Properties

            Output.AppendLine();

            if (aVertex.GetCountOfProperties() > 0)
            {
                foreach (var _property in aVertex.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        Output.AppendLine(Header + _property.Item1);
                    }
                    else
                    {
                        if (_property.Item2 is Stream)
                        {
                            Output.AppendLine(Header + _property.Item1 + "\t BinaryProperty");
                        }
                        else
                        {
                            if (_property.Item2 is ICollectionWrapper)
                            {
                                Output.AppendLine(Header + _property.Item1);
                                HandleListProperties((ICollectionWrapper)_property.Item2, Header, ref Output);
                            }
                            else
                            {
                                if (_property.Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType)))
                                {
                                    Output.AppendLine(Header + _property.Item1 + "\t " + ((AUserdefinedDataType)_property.Item2).Value);
                                }
                                else
                                {
                                    Output.AppendLine(Header + _property.Item1 + "\t " + _property.Item2.ToString());
                                }
                            }
                        }
                    }
                }
            }

            #endregion

            #region Edges

            Output.AppendLine(Header + "\t Edges:");

            foreach (var _edge in aVertex.GetAllEdges())
            {
                if (_edge.Item2 == null)
                {
                    Output.AppendLine(Header + "\t\t" + _edge.Item1);
                }
                else
                {
                    Output.AppendLine(Header + "\t\t" + _edge.Item2.GetType().Name);
                    Output.AppendLine(Header + "\t\t" + _edge.Item1).Append(GenerateEdgeViewText(Header + "\t\t\t", _edge.Item2));
                }
            }

            #endregion

            return(Output.ToString());
        }