Esempio n. 1
0
        /// <summary>
        /// Converts an enumerable of SingleLink into an enumerable of SingleEdgeAddDefinition.
        /// </summary>
        /// <param name="mySingleLinks">The enumerable of SingleLink instances to be converted.</param>
        /// <param name="myVertextype">The vertex type, that is used to get the property id.</param>
        /// <param name="mySource">The vertex information of the source vertex.</param>
        /// <returns>An enumerable of SingleEdgeAddDefinition one definition per SingleLink instance.</returns>
        /// <exception cref="NullReferenceException">If <paramref name="mySingleLinks"/> or <paramref name="myVertextype"/> is <c>Null</c>.</exception>
        private IEnumerable<SingleEdgeAddDefinition> ConvertSingleEdges(List<SingleLink> mySingleLinks, InternVertexType myVertextype, VertexInformation mySource)
        {
            List<SingleEdgeAddDefinition> result = new List<SingleEdgeAddDefinition>();

            foreach (var singleLink in mySingleLinks)
            {

                var propID = myVertextype.Attributes[singleLink.Key];
                result.Add(ConvertLink(singleLink.Link, propID, mySource));

            }

            return result;
        }
Esempio n. 2
0
        /// <summary>
        /// Converts a dictionary string to string into long to IComparable.
        /// </summary>
        /// <param name="myValues">An dictionary of string to string.</param>
        /// <param name="myVertexType">The vertex type, that is needed to get the attribute ids of properties.</param>
        /// <returns>An dictionary of long to IComparable.</returns>
        /// <exception cref="NullReferenceException">If <paramref name="myValues"/> or <paramref name="myVertexType"/>is <c>Null</c>.</exception>
        private IDictionary<long, IComparable> ConvertStructuredProperties(IDictionary<string, string> myValues, InternVertexType myVertexType)
        {
            Dictionary<long, IComparable> result = new Dictionary<long, IComparable>();
            List<String> toBeDeleted = new List<String>();

            foreach (var value in myValues)
            {
                if (myVertexType.Attributes.ContainsKey(value.Key))
                {
                    var id = myVertexType.Attributes[value.Key];

                    IComparable newValue;

                    try
                    {
                        newValue = value.Value.ConvertToIComparable(_propertyTypes[id]);
                    }
                    catch (Exception e)
                    {
                        _logger.Log(Level.SEVERE, "Exception thrown: {0}", e);
                        _logger.Log(Level.SEVERE, "Key: " + value.Key);
                        _logger.Log(Level.SEVERE, "Value: " + value.Value);
                        _logger.Log(Level.WARNING, String.Format("Could not convert {0} into {1} of vertex type {2} and property {3}", value.Value, _propertyTypes[id].Name, myVertexType.Name, value.Key));
                        continue;
                    }

                    result.Add(id, newValue);

                    toBeDeleted.Add(value.Key);

                }
            }

            foreach (var delete in toBeDeleted)
            {
                myValues.Remove(delete);
            }

            return result;
        }
Esempio n. 3
0
        /// <summary>
        /// Converts an enumerable of MultiLink into an enumerable of HyperEdgeAddDefinition.
        /// </summary>
        /// <param name="myMultiLinks">The enumerable of MultiLink instances that will be converted.</param>
        /// <param name="myVertextype">The vertex type, that is used to get the property id.</param>
        /// <param name="mySource">The vertex information of the source vertex.</param>
        /// <returns>An enumerable of HyperEdgeAddDefinition one definition per MultiLink instance.</returns>
        /// <exception cref="NullReferenceException">If <paramref name="myMultiLinks"/> or <paramref name="myVertextype"/> is <c>Null</c>.</exception>
        private IEnumerable<HyperEdgeAddDefinition> ConvertOutgoingEdges(List<MultiLink> myMultiLinks, InternVertexType myVertextype, VertexInformation mySource)
        {
            List<HyperEdgeAddDefinition> result = new List<HyperEdgeAddDefinition>();

            foreach (var multiLink in myMultiLinks)
            {

                var propID = myVertextype.Attributes[multiLink.Key];

                var date = DateTime.UtcNow.ToBinary();

                var add = new HyperEdgeAddDefinition(propID, _edgeTypes[propID], mySource, multiLink.Links.Select(_ => ConvertLink(_, propID, mySource)), null, date, date, null, null);
                result.Add(add);

            }

            return result;
        }