Example #1
0
        private string CreateGraphDMLforVertexOutgoingHyperEdges(IVertexType myVertexType,
            IEnumerable<HyperEdgeContainer> myEdges,
            Dictionary<long, IOutgoingEdgeDefinition> myOutgoingEdgeDefinitions)
        {
            var stringBuilder = new StringBuilder();
            var delimiter = ", ";

            foreach (var hyperEdge in myEdges)
            {
                if (hyperEdge.Edge == null)
                {
                    continue;
                }

                var outgoingEdgeDef = myOutgoingEdgeDefinitions[hyperEdge.PropertyID];

                foreach (var aEdge in hyperEdge.Edge.GetAllEdges().GroupBy(x => x.GetTargetVertex().VertexTypeID, y => y))
                {
                    stringBuilder.Append(String.Concat(outgoingEdgeDef.Name,
                                                        " = ",
                                                        S_SETOFUUIDS.ToUpperString(),
                                                        TERMINAL_LT,
                                                        _vertexTypes[aEdge.Key],
                                                        TERMINAL_GT,
                                                        S_BRACKET_LEFT));

                    foreach (var edge in aEdge)
                    {
                        stringBuilder.Append(String.Concat(edge.GetTargetVertex().VertexID));

                        if (edge.GetAllProperties().Count() > 0)
                        {
                            stringBuilder.Append(String.Concat(":", S_BRACKET_LEFT));

                            stringBuilder.Append(CreateGraphDMLforDefinedProperties(
                                                    edge.GetAllProperties(),
                                                    outgoingEdgeDef
                                                        .InnerEdgeType
                                                        .GetAttributeDefinitions(true)
                                                        .ToDictionary(key => key.ID, value => value as IPropertyDefinition)));

                            if (stringBuilder.ToString().EndsWith(":" + S_BRACKET_LEFT.ToString()))
                                stringBuilder.RemoveEnding(2);
                            else if (stringBuilder.ToString().EndsWith(delimiter))
                            {
                                stringBuilder.RemoveSuffix(delimiter);
                                stringBuilder.Append(S_BRACKET_RIGHT);
                            }
                            else
                                stringBuilder.Append(S_BRACKET_RIGHT);
                        }

                        stringBuilder.Append(delimiter);
                    }

                    stringBuilder.RemoveSuffix(delimiter);
                    stringBuilder.Append(S_BRACKET_RIGHT);

                    stringBuilder.Append(delimiter);
                }
            }

            return stringBuilder.ToString();
        }
Example #2
0
        /// <summary>
        /// Creates the ddl of a type.
        /// </summary>
        /// <param name="myVertexType">The vertex type.</param>
        private String CreateGraphDDL_EdgeType(IEdgeType myEdgeType)
        {
            var stringBuilder = new StringBuilder();
            var delimiter = ", ";
            stringBuilder.AppendFormat("{0} ", myEdgeType.Name);

            #region parent type

            //EXTENDS ...
            if (myEdgeType.HasParentType)
            {
                stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myEdgeType.ParentEdgeType.Name);
            }

            #endregion

            #region attributes
            //are there attributes
            if (myEdgeType.HasAttributes(false))
            {
                //so, there are attributes that are no incoming edges
                stringBuilder.Append(String.Concat(S_ATTRIBUTES.ToUpperString(), " ", S_BRACKET_LEFT));

                #region properties

                if (myEdgeType.GetAttributeDefinitions(false).Any(aAttribute => aAttribute.Kind == AttributeType.Property))
                    stringBuilder.Append(String.Concat(CreateGraphDDLOfProperties(myEdgeType.GetPropertyDefinitions(false))));

                #endregion

                if (stringBuilder.ToString().EndsWith(delimiter))
                    stringBuilder.RemoveEnding(delimiter.Length);

                stringBuilder.Append(String.Concat(S_BRACKET_RIGHT));
            }

            #endregion

            return stringBuilder.ToString();
        }