public override IEnumerable<IVertex> GetMatchingVertices(IVertexType myInterestingVertexType)
        {
            Regex regexpression;

            try
            {
                regexpression = new Regex((String)_constant.Value);
            }
            catch (Exception e)
            {
                throw new InvalidLikeOperationException(String.Format("Invalid regular expression given:{0}{1}", Environment.NewLine, e.Message), e);
            }

            foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
            {
                var value = _property.Property.GetValue(aVertex);

                if (value != null && (regexpression.IsMatch((String)value)))
                {
                    yield return aVertex;
                }
            }

            yield break;
        }
        /// <summary>
        /// output for the type indices
        /// </summary>
        /// <param name="myType">The db type</param>
        /// <param name="myDBContext">The db context</param>
        /// <returns>a list of readouts, contains the attributes</returns>
        private IEnumerable <ISingleEdgeView> GenerateIndicesOutput(IVertexType myType)
        {
            var _AttributeReadout = new List <ISingleEdgeView>();

            foreach (var idx in myType.GetIndexDefinitions(true))
            {
                var Attributes = new Dictionary <String, Object>();

                Attributes.Add("ID", idx.ID);
                Attributes.Add("Type", idx.IndexTypeName);
                Attributes.Add("Name", idx.Name);
                Attributes.Add("Edition", idx.Edition);

                var list = new ListCollectionWrapper();
                foreach (var item in idx.IndexedProperties)
                {
                    list.Add(item.Name);
                }

                Attributes.Add("IndexedProperties", list);

                _AttributeReadout.Add(new SingleEdgeView(null, new VertexView(Attributes, new Dictionary <String, IEdgeView>())));
            }

            return(_AttributeReadout);
        }
        /// <summary>
        /// output for the type properties
        /// </summary>
        /// <param name="myType">The db type</param>
        /// <param name="myDBContext">The db context</param>
        /// <param name="myProperties">The propertyDefinitions</param>
        /// <returns>a list of readouts, contains the properties</returns>
        private IEnumerable <ISingleEdgeView> GeneratePropertiesOutput(IVertexType myType, IEnumerable <IPropertyDefinition> myProperties, Int32 myDepth = 0)
        {
            var _AttributeReadout = new List <ISingleEdgeView>();

            foreach (var property in myProperties)
            {
                var Attributes = new Dictionary <String, Object>();

                Attributes.Add("ID", property.ID);
                Attributes.Add("Type", property.BaseType.Name);
                Attributes.Add("Name", property.Name);
                Attributes.Add("IsUserDefined", property.IsUserDefined);

                if (myDepth > 0)
                {
                    Attributes.Add("Multiplicity", property.Multiplicity);
                    Attributes.Add("IsMandatory", property.IsMandatory);

                    if (property.DefaultValue != null)
                    {
                        Attributes.Add("DefaultValue", property.DefaultValue);
                    }
                }

                _AttributeReadout.Add(new SingleEdgeView(null, new VertexView(Attributes, new Dictionary <String, IEdgeView>())));
            }

            return(_AttributeReadout);
        }
Beispiel #4
0
        private void AddVertexTypeAndAttributesRecursivly(IGraphDB myGraphDB,
                                                          SecurityToken mySecurityToken,
                                                          Int64 myTransactionToken,
                                                          IVertexType type,
                                                          ref HashSet <IVertexType> types)
        {
            if (!type.IsUserDefined)
            {
                return;
            }

            if (type.HasParentType)
            {
                if (!types.Contains(type.ParentVertexType))
                {
                    types.Add(type.ParentVertexType);

                    foreach (var attr in (type.GetAttributeDefinitions(false)).Where(attrDef => attrDef.Kind == AttributeType.Property))
                    {
                        var attrType = myGraphDB.GetVertexType <IVertexType>(mySecurityToken,
                                                                             myTransactionToken,
                                                                             new RequestGetVertexType(attr.ID),
                                                                             (stats, vertex) => vertex);

                        AddVertexTypeAndAttributesRecursivly(myGraphDB,
                                                             mySecurityToken,
                                                             myTransactionToken,
                                                             attrType,
                                                             ref types);
                    }
                }
            }
        }
Beispiel #5
0
        protected static void CheckAddStructuredProperties(IDictionary<String, IComparable> myProperties, IVertexType vertexType)
        {
            foreach (var prop in myProperties)
            {
                var propertyDef = vertexType.GetPropertyDefinition(prop.Key);
                if (propertyDef == null)
                    throw new AttributeDoesNotExistException(prop.Key, vertexType.Name);

                if (propertyDef.Multiplicity == PropertyMultiplicity.Single)
                {
                    CheckPropertyType(vertexType.Name, prop.Value, propertyDef);
                }
                else
                {
                    IEnumerable<IComparable> items = prop.Value as IEnumerable<IComparable>;
                    if (items == null)
                    {
                        throw new PropertyHasWrongTypeException(vertexType.Name, prop.Key, propertyDef.Multiplicity, propertyDef.BaseType.Name);
                    }

                    foreach (var item in items)
                    {
                        CheckPropertyType(vertexType.Name, item, propertyDef);
                    }
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Create a new query plan property
 /// </summary>
 /// <param name="myVertexType">The interesting vertex type</param>
 /// <param name="myProperty">The interesting property</param>
 public QueryPlanProperty(IVertexType myVertexType, IPropertyDefinition myProperty, String myInterestingEdition, TimeSpanDefinition myInterestingTimeSpan)
 {
     VertexType = myVertexType;
     Property = myProperty;
     Edition = myInterestingEdition;
     Timespan = myInterestingTimeSpan;
 }
        public void Add(IVertexType current_node, double current_distance, UInt64 current_depth)
        {
            var id = current_node.ID;
            _buf.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));

            _count++;
        }
Beispiel #8
0
        public VertexBuffer(Type type, int length, bool isStream = false)
        {
            TotalBuffers++;
            VBO = GL.GenBuffer();
            var usageHint = isStream ? GL.GL_STREAM_DRAW : GL.GL_STATIC_DRAW;

            streaming = isStream;
            this.type = type;
            try
            {
                vertextype = (IVertexType)Activator.CreateInstance(type);
                decl       = vertextype.GetVertexDeclaration();
            }
            catch (Exception)
            {
                throw new Exception(string.Format("{0} is not a valid IVertexType", type.FullName));
            }
            GL.GenVertexArrays(1, out VAO);
            GLBind.VertexArray(VAO);
            GL.BindBuffer(GL.GL_ARRAY_BUFFER, VBO);
            GL.BufferData(GL.GL_ARRAY_BUFFER, (IntPtr)(length * decl.Stride), IntPtr.Zero, usageHint);
            size = length;
            decl.SetPointers();
            VertexCount = length;
        }
        /// <summary>
        /// Executes the query plan recursivly
        /// </summary>
        /// <param name="myVertexType">The starting vertex type</param>
        /// <returns>An enumeration of vertices</returns>
        protected IEnumerable <IVertex> Execute_protected(IVertexType myVertexType)
        {
            #region current type

            foreach (var aVertex in GetMatchingVertices(myVertexType))
            {
                yield return(aVertex);
            }

            #endregion

            #region child types

            foreach (var aChildVertexType in myVertexType.ChildrenVertexTypes)
            {
                foreach (var aVertex in Execute_protected(aChildVertexType))
                {
                    yield return(aVertex);
                }
            }

            #endregion

            yield break;
        }
        public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            ShaderVariables sh;

            //These things don't have normals
            if (vertextype is VertexPositionColorTexture ||
                vertextype is VertexPosition ||
                vertextype is VertexPositionColor || vertextype is VertexPositionTexture)
            {
                if (shader_null == null)
                {
                    shader_null = ShaderCache.Get("Normals_Position.vs", "Normals.frag");
                }
                sh = shader_null;
            }
            else
            {
                if (shader == null)
                {
                    shader = ShaderCache.Get("Normals_PositionNormal.vs", "Normals.frag");
                }
                sh = shader;
            }
            if (Camera == null)
            {
                return;
            }
            rstate.BlendMode = BlendMode.Opaque;
            sh.SetViewProjection(Camera);
            //Dt
            sh.SetWorld(World);
            sh.UseProgram();
        }
Beispiel #11
0
        public override IEnumerable <IVertex> GetMatchingVertices(IVertexType myInterestingVertexType)
        {
            if (_constantRange.IncludeBorders)
            {
                foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
                {
                    var value = _property.Property.GetValue(aVertex);

                    if (value != null &&
                        (value.CompareTo(_constantRange.Lower) >= 0) &&
                        (value.CompareTo(_constantRange.Upper) <= 0))
                    {
                        yield return(aVertex);
                    }
                }
            }
            else
            {
                foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
                {
                    var value = _property.Property.GetValue(aVertex);

                    if (value != null &&
                        (value.CompareTo(_constantRange.Lower) > 0) &&
                        (value.CompareTo(_constantRange.Upper) < 0))
                    {
                        yield return(aVertex);
                    }
                }
            }

            yield break;
        }
Beispiel #12
0
        public VertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsageHint usage = BufferUsageHint.StaticDraw)
            : this(graphicsDevice, vertexCount, usage)
        {
            IVertexType tp = Activator.CreateInstance(vertexType) as IVertexType;

            if (tp == null)
            {
                throw new ArgumentException("must be a vertexType");
            }

            this.VertexDeclaration = tp.VertexDeclaration;
            ThreadingHelper.BlockOnUIThread(() =>
            {
                vbo = GL.GenBuffer();
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(vertexCount * VertexDeclaration.VertexStride), IntPtr.Zero, (OpenTK.Graphics.OpenGL4.BufferUsageHint)BufferUsage);
            });
            ThreadingHelper.BlockOnUIThread(() =>
            {
                vao     = new VertexAttributes();
                vao.vbo = vbo;
                vao.Bind();
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                VertexAttributes.ApplyAttributes(vao, VertexDeclaration);

                GL.BindVertexArray(0);
            }, true);
            GraphicsDevice.CheckError();
        }
Beispiel #13
0
        private void CheckOutgoingEdges(IEnumerable <EdgePredefinition> myEdges, IVertexType myVertexType)
        {
            foreach (var edge in myEdges)
            {
                var edgeDef = myVertexType.GetOutgoingEdgeDefinition(edge.EdgeName);
                switch (edgeDef.Multiplicity)
                {
                case EdgeMultiplicity.SingleEdge:
                {
                    CheckSingleEdge(edge, edgeDef.EdgeType);
                    break;
                }

                case EdgeMultiplicity.MultiEdge:
                {
                    if (edge.ContainedEdges != null)
                    {
                        foreach (var innerEdge in edge.ContainedEdges)
                        {
                            CheckSingleEdge(innerEdge, edgeDef.InnerEdgeType);
                        }
                    }
                    break;
                }

                case EdgeMultiplicity.HyperEdge:
                {
                    break;
                }
                }
            }
        }
Beispiel #14
0
        public override IVertex AddVertex(RequestInsertVertex myInsertDefinition, Int64 myTransaction, SecurityToken mySecurity)
        {
            IVertexType vertexType = GetType(myInsertDefinition.VertexTypeName, myTransaction, mySecurity);

            if (vertexType.IsAbstract)
            {
                throw new AbstractConstraintViolationException(myInsertDefinition.VertexTypeName);
            }

            ConvertUnknownProperties(myInsertDefinition, vertexType);
            ConvertDefaultValues(myInsertDefinition, vertexType);

            if (myInsertDefinition.OutgoingEdges != null)
            {
                CheckOutgoingEdges(myInsertDefinition.OutgoingEdges, vertexType);
            }


            if (myInsertDefinition.StructuredProperties != null)
            {
                CheckAddStructuredProperties(myInsertDefinition.StructuredProperties, vertexType);
            }

            CheckMandatoryConstraint(myInsertDefinition, vertexType);

            if (myInsertDefinition.BinaryProperties != null)
            {
                CheckAddBinaryProperties(myInsertDefinition, vertexType);
            }

            return(null);
        }
Beispiel #15
0
 static ShaderVariables GetShader(IVertexType vertextype, ShaderFeatures caps)
 {
     if (vertextype is Utf.Dfm.DfmVertex)
     {
         return(Basic_Skinned.Get(caps));
     }
     if (vertextype is VertexPositionNormalTexture ||
         vertextype is VertexPositionNormal)
     {
         return(Basic_PositionNormalTexture.Get(caps));
     }
     if (vertextype is VertexPositionNormalTextureTwo)
     {
         return(Basic_PositionNormalTextureTwo.Get(caps));
     }
     if (vertextype is VertexPositionNormalDiffuseTexture)
     {
         return(Basic_PositionNormalColorTexture.Get(caps));
     }
     if (vertextype is VertexPositionTexture)
     {
         return(Basic_PositionTexture.Get(caps));
     }
     if (vertextype is VertexPosition)
     {
         return(Basic_PositionTexture.Get(caps));
     }
     if (vertextype is VertexPositionColor)
     {
         return(Basic_PositionColor.Get(caps));
     }
     throw new NotImplementedException(vertextype.GetType().Name);
 }
        /// <summary>
        /// output for the edges
        /// </summary>
        /// <param name="myType">The db type</param>
        /// <param name="myDBContext">The db context</param>
        /// <param name="myEdges">The EdgeDefinitions</param>
        /// <returns>a list of readouts, contains the attributes</returns>
        private IEnumerable <ISingleEdgeView> GenerateEdgesOutput(IVertexType myType, IEnumerable <IAttributeDefinition> myEdges)
        {
            var _AttributeReadout = new List <ISingleEdgeView>();

            foreach (var edge in myEdges)
            {
                var Attributes = new Dictionary <String, Object>();

                if (edge.Kind == AttributeType.IncomingEdge)
                {
                    Attributes.Add("RelatedEdgeName", (edge as IIncomingEdgeDefinition).RelatedEdgeDefinition.Name);
                    Attributes.Add("RelatedEdgeSourceVertexType", (edge as IIncomingEdgeDefinition).RelatedEdgeDefinition.SourceVertexType.Name);
                    Attributes.Add("RelatedEdgeTargetVertexType", (edge as IIncomingEdgeDefinition).RelatedEdgeDefinition.TargetVertexType.Name);
                }
                else if (edge.Kind == AttributeType.OutgoingEdge)
                {
                    Attributes.Add("Type", (edge as IOutgoingEdgeDefinition).EdgeType.Name);
                    Attributes.Add("SourceVertexType", (edge as IOutgoingEdgeDefinition).SourceVertexType.Name);
                    Attributes.Add("TargetVertexType", (edge as IOutgoingEdgeDefinition).TargetVertexType.Name);
                }

                Attributes.Add("ID", edge.ID);
                Attributes.Add("Name", edge.Name);

                _AttributeReadout.Add(new SingleEdgeView(null, new VertexView(Attributes, null)));
            }

            return(_AttributeReadout);
        }
        public override IEnumerable<IVertex> GetMatchingVertices(IVertexType myInterestingVertexType)
        {
            if (_constantRange.IncludeBorders)
            {
                foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
                {
                    var value = _property.Property.GetValue(aVertex);

                    if (value != null &&
                            (value.CompareTo(_constantRange.Lower) >= 0) &&
                            (value.CompareTo(_constantRange.Upper) <= 0))
                    {
                        yield return aVertex;
                    }
                }
            }
            else
            {
                foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
                {
                    var value = _property.Property.GetValue(aVertex);

                    if (value != null &&
                            (value.CompareTo(_constantRange.Lower) > 0) &&
                            (value.CompareTo(_constantRange.Upper) < 0))
                    {
                        yield return aVertex;
                    }
                }
            }

            yield break;
        }
Beispiel #18
0
        private static IEnumerable <IVertex> ProcessBinaryExpression(
            BinaryExpressionDefinition binExpression,
            GQLPluginManager myPluginManager,
            IGraphDB myGraphDB,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IVertexType vertexType)
        {
            //validate
            binExpression.Validate(myPluginManager,
                                   myGraphDB,
                                   mySecurityToken,
                                   myTransactionToken,
                                   vertexType);

            //calculate
            var expressionGraph =
                binExpression.Calculon(myPluginManager,
                                       myGraphDB,
                                       mySecurityToken,
                                       myTransactionToken,
                                       new CommonUsageGraph(myGraphDB,
                                                            mySecurityToken,
                                                            myTransactionToken),
                                       false);

            //extract
            return
                (expressionGraph.Select(
                     new LevelKey(vertexType.ID,
                                  myGraphDB,
                                  mySecurityToken,
                                  myTransactionToken),
                     null, true));
        }
Beispiel #19
0
 /// <summary>
 /// Create a new query plan property
 /// </summary>
 /// <param name="myVertexType">The interesting vertex type</param>
 /// <param name="myProperty">The interesting property</param>
 public QueryPlanProperty(IVertexType myVertexType, IPropertyDefinition myProperty, String myInterestingEdition, TimeSpanDefinition myInterestingTimeSpan)
 {
     VertexType = myVertexType;
     Property   = myProperty;
     Edition    = myInterestingEdition;
     Timespan   = myInterestingTimeSpan;
 }
        public override unsafe void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            rstate.DepthEnabled = true;
            rstate.BlendMode    = BlendMode.Normal;
            var sh = GetShader(vertextype);

            sh.SetAc(Ac);
            sh.SetDc(Dc);
            sh.SetOc(Alpha);
            sh.SetTileRate(Fade);
            var w = Matrix4x4.CreateScale(Scale) * World.Source[0];

            sh.SetView(Camera);
            sh.SetViewProjection(Camera);
            sh.SetDtSampler(0);
            if (GetTexture(0, DtSampler) == null)
            {
                sh.SetOc(0);
            }
            BindTexture(rstate, 0, DtSampler, 0, DtFlags);
            var normalmat = w;

            Matrix4x4.Invert(normalmat, out normalmat);
            normalmat = Matrix4x4.Transpose(normalmat);
            SetLights(sh, ref lights);
            sh.SetWorld(ref w, ref normalmat);
            sh.UseProgram();
        }
Beispiel #21
0
        public IEnumerable <ISonesIndex> GetIndices(IVertexType myVertexType, IList <IPropertyDefinition> myPropertyDefinition, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            myVertexType.CheckNull("myVertexType");
            myPropertyDefinition.CheckNull("myPropertyDefinition");

            if (myPropertyDefinition.Count == 0)
            {
                throw new ArgumentOutOfRangeException("myPropertyDefinition", "At least one property must be given.");
            }

            var propertyTypes = myPropertyDefinition.GroupBy(_ => _.RelatedType);

            foreach (var group in propertyTypes)
            {
                if (!myVertexType.IsDescendantOrSelf(group.Key))
                {
                    throw new ArgumentException(string.Format("The properties ({0}) defined on type {1} is not part of inheritance hierarchy of {2}.",
                                                              string.Join(",", group.Select(_ => _.Name)),
                                                              group.Key.Name,
                                                              myVertexType.Name));
                }
            }

            var result = myVertexType.GetIndexDefinitions(false).Where(_ => myPropertyDefinition.SequenceEqual(_.IndexedProperties)).Select(_ => _indices[_.ID]).ToArray();

            return(result);
        }
Beispiel #22
0
        private void RebuildIndices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, bool myOnlyNonPersistent)
        {
            Dictionary <IList <IPropertyDefinition>, IEnumerable <ISonesIndex> > toRebuild = new Dictionary <IList <IPropertyDefinition>, IEnumerable <ISonesIndex> >();

            foreach (var indexDef in myVertexType.GetIndexDefinitions(false))
            {
                var indices = GetIndices(myVertexType, indexDef.IndexedProperties, mySecurity, myTransaction).Where(_ => !myOnlyNonPersistent || !GetIsPersistentIndex(_));
                toRebuild.Add(indexDef.IndexedProperties, indices);
            }

            if (toRebuild.Count > 0)
            {
                foreach (var aIdxCollection in toRebuild.Values)
                {
                    foreach (var aIdx in aIdxCollection)
                    {
                        aIdx.Clear();
                    }
                }

                var vertices = _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, myVertexType.ID);

                foreach (var vertex in vertices)
                {
                    foreach (var indexGroup in toRebuild)
                    {
                        foreach (var index in indexGroup.Value)
                        {
                            index.Add(CreateIndexKey(indexGroup.Key, vertex), vertex.VertexID);
                        }
                    }
                }
            }
        }
        internal static VertexDeclaration FromType(Type vertexType)
        {
            if (vertexType == null)
            {
                throw new ArgumentNullException("vertexType", "Cannot be null");
            }
//            if (!vertexType.IsValueType)
//            {
//                object[] args = new object[] { vertexType };
//                throw new ArgumentException("vertexType", "Must be value type");
//            }
            IVertexType type = Activator.CreateInstance(vertexType) as IVertexType;

            if (type == null)
            {
                object[] objArray3 = new object[] { vertexType };
                throw new ArgumentException("vertexData does not inherit IVertexType");
            }
            VertexDeclaration vertexDeclaration = type.VertexDeclaration;

            if (vertexDeclaration == null)
            {
                object[] objArray2 = new object[] { vertexType };
                throw new Exception("VertexDeclaration cannot be null");
            }

            return(vertexDeclaration);
        }
Beispiel #24
0
        public IIndexDefinition CreateIndexDefinition(IVertex myIndexVertex, IVertexType myDefiningVertexType = null)
        {
            var id            = GetUUID(myIndexVertex);
            var props         = GetIndexedProperties(myIndexVertex);
            var typeName      = GetIndexTypeName(myIndexVertex);
            var edition       = myIndexVertex.EditionName;
            var isUserDefined = GetIndexDotIsUserDefined(myIndexVertex);
            var name          = GetIndexDotName(myIndexVertex);
            var range         = myIndexVertex.GetProperty <bool>((long)AttributeDefinitions.IndexDotIsRange);
            var version       = myIndexVertex.GetProperty <bool>((long)AttributeDefinitions.IndexDotIsVersioned);
            var sourceIndex   = (myIndexVertex.HasOutgoingEdge((long)AttributeDefinitions.IndexDotSourceIndex))
                ? CreateIndexDefinition(myIndexVertex.GetOutgoingSingleEdge((long)AttributeDefinitions.IndexDotSourceIndex).GetTargetVertex())
                : null;

            myDefiningVertexType = myDefiningVertexType ?? GetDefiningVertexType(myIndexVertex);

            return(new IndexDefinition
            {
                ID = id,
                IndexedProperties = props,
                Edition = edition,
                IndexTypeName = typeName,
                IsUserdefined = isUserDefined,
                Name = name,
                VertexType = myDefiningVertexType,
                IsRange = range,
                IsVersioned = version,
                SourceIndex = sourceIndex,
            });
        }
Beispiel #25
0
        public override IEnumerable <IVertex> GetMatchingVertices(IVertexType myInterestingVertexType)
        {
            Regex regexpression;

            try
            {
                regexpression = new Regex((String)_constant.Value);
            }
            catch (Exception e)
            {
                throw new InvalidLikeOperationException(String.Format("Invalid regular expression given:{0}{1}", Environment.NewLine, e.Message), e);
            }

            foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
            {
                var value = _property.Property.GetValue(aVertex);

                if (value != null && (regexpression.IsMatch((String)value)))
                {
                    yield return(aVertex);
                }
            }

            yield break;
        }
Beispiel #26
0
        public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            rstate.DepthEnabled = true;
            rstate.BlendMode    = BlendMode.Opaque;

            var sh = Shaders.IllumDetailMapMaterial.Get();

            sh.SetViewProjection(Camera);
            sh.SetWorld(World);
            sh.SetView(Camera);

            sh.SetAc(Ac);
            sh.SetDc(Dc);
            sh.SetTileRate0(TileRate0);
            sh.SetTileRate1(TileRate1);
            sh.SetFlipU(FlipU);
            sh.SetFlipV(FlipV);

            sh.SetDtSampler(0);
            BindTexture(rstate, 0, DtSampler, 0, DtFlags);
            sh.SetDm0Sampler(1);
            BindTexture(rstate, 1, Dm0Sampler, 1, Dm0Flags);
            sh.SetDm1Sampler(2);
            BindTexture(rstate, 2, Dm1Sampler, 2, Dm1Flags);
            SetLights(sh, ref lights, Camera.FrameNumber);
            sh.UseProgram();
        }
Beispiel #27
0
        public void Set(double key_primary, IVertexType value, double current_distance, ulong current_depth)
        {
            var key = value.ID;

            _buf.Remove(Tuple.Create(key_primary, key));
            _buf.Add(Tuple.Create(current_distance, key), Tuple.Create(value, current_distance, current_depth));
        }
Beispiel #28
0
 private static void ProcessAAttributeDefinition(GQLPluginManager myPluginManager,
                                                 IGraphDB myGraphDB,
                                                 SecurityToken mySecurityToken,
                                                 Int64 myTransactionToken,
                                                 IVertexType vertexType,
                                                 AAttributeAssignOrUpdate aAttributeDefinition,
                                                 ref RequestInsertVertex result)
 {
     if (vertexType.HasAttribute(aAttributeDefinition.AttributeIDChain.ContentString))
     {
         ProcessStructuredProperty(myPluginManager,
                                   myGraphDB,
                                   mySecurityToken,
                                   myTransactionToken,
                                   vertexType,
                                   aAttributeDefinition,
                                   ref result);
     }
     else
     {
         ProcessUnstructuredAttribute(vertexType,
                                      aAttributeDefinition,
                                      ref result);
     }
 }
Beispiel #29
0
        public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            rstate.DepthEnabled = true;
            rstate.BlendMode    = BlendMode.Opaque;

            ShaderVariables sh = GetShader(vertextype);

            sh.SetWorld(ref World);
            sh.SetViewProjection(Camera);
            sh.SetView(Camera);
            sh.SetAc(Ac);
            sh.SetDc(Dc);
            sh.SetTileRate(TileRate);
            sh.SetFlipU(FlipU);
            sh.SetFlipV(FlipV);
            sh.SetDtSampler(0);
            BindTexture(rstate, 0, DtSampler, 0, DtFlags);
            sh.SetDm1Sampler(1);
            BindTexture(rstate, 1, Dm1Sampler, 1, Dm1Flags, ResourceManager.GreyTextureName);
            SetLights(sh, ref lights);
            var normalMatrix = World;

            normalMatrix.Invert();
            normalMatrix.Transpose();
            sh.SetNormalMatrix(ref normalMatrix);
            sh.UseProgram();
        }
        public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            rstate.DepthEnabled = true;
            rstate.BlendMode    = BlendMode.Normal;
            var sh = GetShader(vertextype);

            sh.SetAc(Ac);
            sh.SetDc(Dc);
            sh.SetOc(Alpha);
            sh.SetTileRate(Fade);
            sh.SetWorld(ref World);
            sh.SetView(Camera);
            sh.SetViewProjection(Camera);
            sh.SetDtSampler(0);
            if (GetTexture(0, DtSampler) == null)
            {
                sh.SetOc(0);
            }
            BindTexture(rstate, 0, DtSampler, 0, DtFlags);
            var normalmat = World;

            normalmat.Invert();
            normalmat.Normalize();
            SetLights(sh, ref lights);
            sh.SetNormalMatrix(ref normalmat);
            sh.UseProgram();
        }
Beispiel #31
0
        public void Add(IVertexType current_node, double current_distance, UInt64 current_depth, long current_edge, IVertexType father)
        {
            var id = current_node.ID;

            _list.Add(id, Tuple.Create(current_node, current_distance, current_depth, current_edge, father));
            _count++;
        }
Beispiel #32
0
        public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights)
        {
            rstate.DepthEnabled = true;
            rstate.BlendMode    = BlendMode.Opaque;
            var sh = GetShader(vertextype);

            sh.SetViewProjection(Camera);
            sh.SetWorld(ref World);
            sh.SetView(Camera);

            sh.SetAc(Ac);
            sh.SetDc(Dc);
            sh.SetTileRate0(TileRate0);
            sh.SetTileRate1(TileRate1);
            sh.SetFlipU(FlipU);
            sh.SetFlipV(FlipV);

            sh.SetDtSampler(0);
            BindTexture(rstate, 0, DtSampler, 0, DtFlags);
            sh.SetDm0Sampler(1);
            BindTexture(rstate, 1, Dm0Sampler, 1, Dm0Flags);
            sh.SetDm1Sampler(2);
            BindTexture(rstate, 2, Dm1Sampler, 2, Dm1Flags);
            SetLights(sh, ref lights);
            var normalMatrix = World;

            Matrix4x4.Invert(normalMatrix, out normalMatrix);
            normalMatrix = Matrix4x4.Transpose(normalMatrix);
            sh.SetNormalMatrix(ref normalMatrix);
            sh.UseProgram();
        }
        public void DrawUserIndexedPrimitives <T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount)
        {
            return;

            IVertexType tp = Activator.CreateInstance <T>() as IVertexType;

            if (tp == null)
            {
                throw new ArgumentException("must be a vertexType");
            }
            VertexBuffer old = VertexBuffer;

            ThreadingHelper.BlockOnUIThread(() =>
            {
                VertexBuffer current = new VertexBuffer(this, tp.VertexDeclaration, vertexData.Length);

                this.VertexBuffer = current;

                VertexBuffer.vao.Bind();
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);

                GL.DrawElements((OpenTK.Graphics.OpenGL4.PrimitiveType)primitiveType, primitiveCount * 3, OpenTK.Graphics.OpenGL4.DrawElementsType.UnsignedShort, indexData);

                this.VertexBuffer = old;

                current.Dispose();
            });
            CheckError();
        }
Beispiel #34
0
        /// <summary>
        /// Returns the VertexDeclaration for Type.
        /// </summary>
        /// <param name="vertexType">A value type which implements the IVertexType interface.</param>
        /// <returns>The VertexDeclaration.</returns>
        /// <remarks>
        /// Prefer to use VertexDeclarationCache when the declaration lookup
        /// can be performed with a templated type.
        /// </remarks>
        internal static VertexDeclaration FromType(Type vertexType)
        {
            if (vertexType == null)
            {
                throw new ArgumentNullException("vertexType", "Cannot be null");
            }

            if (!vertexType.IsValueType)
            {
                throw new ArgumentException("vertexType", "Must be value type");
            }

            IVertexType type = Activator.CreateInstance(vertexType) as IVertexType;

            if (type == null)
            {
                throw new ArgumentException("vertexData does not inherit IVertexType");
            }

            VertexDeclaration vertexDeclaration = type.VertexDeclaration;

            if (vertexDeclaration == null)
            {
                throw new ArgumentException("vertexType's VertexDeclaration cannot be null");
            }

            return(vertexDeclaration);
        }
Beispiel #35
0
        public void Add(IVertexType current_node, double current_distance, UInt64 current_depth)
        {
            var id = current_node.ID;

            _buf.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));

            _count++;
        }
Beispiel #36
0
 public override IEnumerable<IVertex> GetVertices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, Boolean myIncludeSubtypes)
 {
     if (myVertexType == null)
     {
         throw new ArgumentNullException("myVertexType");
     }
     return null;
 }
Beispiel #37
0
        public IDNode(IVertexType myType, String myReference)
        {

            IDChainDefinition = new IDChainDefinition();
            IDChainDefinition.AddPart(new ChainPartTypeOrAttributeDefinition(myType.Name));
            var listOfRefs = new Dictionary<String, IVertexType>();
            listOfRefs.Add(myReference, myType);

        }
Beispiel #38
0
 /// <summary>
 /// Checks whether the index can be changed
 /// </summary>
 /// <param name="idxDef">List of index attribute definitions</param>
 /// <param name="type">The db type that is to be altered</param>
 /// <returns>An exceptional</returns>
 private void CheckIndexTypeReference(List<IndexAttributeDefinition> idxDef, IVertexType type)
 {
     foreach (var idx in idxDef)
     {
         if (idx.IndexType != null && idx.IndexType != type.Name)
         {
             throw new CouldNotAlterIndexOnTypeException(idx.IndexType);
         }
     }
 }
Beispiel #39
0
        /// <summary>
        /// Transforms an IVertex in a binary property definition.
        /// </summary>
        /// <param name="myVertex">A vertex that represents a property definition.</param>
        /// <returns>A property definition.</returns>
        public static IBinaryPropertyDefinition CreateBinaryPropertyDefinition(IVertex myVertex, IVertexType myDefiningType = null)
        {
            var attributeID = GetUUID(myVertex);
            var name = GetAttributeDotName(myVertex);
            var definingType = myDefiningType ?? GetDefiningType(myVertex) as IVertexType;
            var isUserDefined = GetAttributeDotIsUserDefined(myVertex);

            return new BinaryPropertyDefinition
            {
                IsUserDefined = isUserDefined,
                Name = name,
                RelatedType = definingType,
                ID = myVertex.VertexID,
            };
        }
        public override IEnumerable<IVertex> GetMatchingVertices(IVertexType myInterestingVertexType)
        {
            foreach (var aVertex in _vertexStore.GetVerticesByTypeID(_securityToken, _transactionToken, myInterestingVertexType.ID, _property.Edition, VertexRevisionFilter))
            {
                var result = _property.Property.GetValue(aVertex);

                if (result != null)
                {
                    if (_constant.Value.CompareTo(result) == 0)
                    {
                        yield return aVertex;
                    }
                }
            }

            yield break;
        }
Beispiel #41
0
		void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
		{
		
		  var outEdges =  start.GetOutgoingEdgeDefinitions(true);
		  var incEdges = start.GetIncomingEdgeDefinitions(true);
		  
		  foreach (IOutgoingEdgeDefinition vertexType in outEdges)
		  {
			  if (Parents.Where(x=>x.Item1 == vertexType.TargetVertexType.ID).Count()==0)//(Tuple.Create(vertexType.TargetVertexType.ID,vertexType.ID)))
			  {
				  
					 var current_parents =  Parents.ToList();
					 Parents.Add(Tuple.Create(vertexType.TargetVertexType.ID,vertexType.ID));

					 if (Parents.Last().Item1 == end.ID && !_path.Contains(Parents))
						 _path.Add(Parents);
					 else
					 {
						 DFS(vertexType.TargetVertexType, end, Parents);
					 }
				  Parents = current_parents;
			  }
		  }
		  foreach (IIncomingEdgeDefinition vertexType in incEdges)
		  {
			  if (Parents.Where(x => x.Item1 == vertexType.RelatedEdgeDefinition.SourceVertexType.ID).Count() == 0) //if (!Parents.Contains(Tuple.Create(vertexType.RelatedEdgeDefinition.SourceVertexType.ID, vertexType.ID)))
			  {
				  var current_parents = Parents.ToList();
				  Parents.Add(Tuple.Create(vertexType.RelatedEdgeDefinition.SourceVertexType.ID,vertexType.ID));

				 
				  if (Parents.Last().Item1 == end.ID && !_path.Contains(Parents))
				  {
					  _path.Add(Parents);
				  }
				  else
				  {
					 DFS(vertexType.RelatedEdgeDefinition.SourceVertexType, end, Parents);
				  }
				  Parents = current_parents;
			  }
		  }
		}
        private void RemoveVertex(IVertex aVertex, IVertexType myVertexType, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            RemoveVertexFromIndices(aVertex, myVertexType, mySecurityToken, myTransactionToken);

            _vertexStore.RemoveVertex(mySecurityToken, myTransactionToken, aVertex.VertexID, aVertex.VertexTypeID);
        }
 private void RemoveVertexFromIndices(IVertex aVertex, IVertexType myVertexType, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     foreach (var aStructuredProperty in myVertexType.GetPropertyDefinitions(true))
     {
         if (aVertex.HasProperty(aStructuredProperty.ID))
         {
             foreach (var aIndexDefinition in aStructuredProperty.InIndices)
             {
                 RemoveFromIndices(aVertex,
                     _indexManager.GetIndices(myVertexType, aIndexDefinition.IndexedProperties, mySecurityToken, myTransactionToken));
             }
         }
     }
 }
Beispiel #44
0
 private void ProcessDropIndex(IEnumerable<IIndexDefinition> myToBeDroppedIndices, IVertexType vertexType, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     foreach (var aVertexType in vertexType.GetDescendantVertexTypesAndSelf())
     {
         foreach (var aIndexDefinition in myToBeDroppedIndices)
         {
             RemoveIndexInstance(aIndexDefinition.ID, myTransactionToken, mySecurityToken);
         }
     }
 }
Beispiel #45
0
        private void AddToIndex(IDictionary<string, IComparable> structured, long id, IVertexType vertexType, IDictionary<IList<IPropertyDefinition>, IEnumerable<IIndex<IComparable, long>>> indices, TransactionToken myTransaction, SecurityToken mySecurity)
        {
            foreach (var indexGroup in indices)
            {
                foreach (var index in indexGroup.Value)
                {
                    var entry = CreateIndexEntry(indexGroup.Key, structured);

                    if (index is ISingleValueIndex<IComparable, long>)
                    {
                        (index as ISingleValueIndex<IComparable, long>).Add(entry, id);
                    }
                    else if (index is IMultipleValueIndex<IComparable, long>)
                    {
                        //Ask: Why do I need to create a hashset for a single value??? *aaarghhh*
                        (index as IMultipleValueIndex<IComparable, long>).Add(entry, new HashSet<long>(new[] {id}));
                    }
                    else
                        throw new NotImplementedException("Other index types are not known.");
                }
            }
        }
        private void CreateEdgeAddDefinitions(
            IEnumerable<EdgePredefinition> myOutgoingEdges,
            IVertexType myVertexType,
            Int64 myTransaction,
            SecurityToken mySecurity,
            VertexInformation source,
            long date,
            out IEnumerable<SingleEdgeAddDefinition> outSingleEdges,
            out IEnumerable<HyperEdgeAddDefinition> outHyperEdges)
        {
            outSingleEdges = null;
            outHyperEdges = null;
            if (myOutgoingEdges == null)
                return;

            var singleEdges = new Dictionary<String, SingleEdgeAddDefinition>();
            var hyperEdges = new Dictionary<String, HyperEdgeAddDefinition>();
            foreach (var edgeDef in myOutgoingEdges)
            {
                var attrDef = myVertexType.GetOutgoingEdgeDefinition(edgeDef.EdgeName);

                switch (attrDef.Multiplicity)
                {
                    case EdgeMultiplicity.SingleEdge:
                        {
                            var edge = CreateSingleEdgeAddDefinition(myTransaction, 
                                                                        mySecurity, 
                                                                        date, 
                                                                        attrDef.ID, 
                                                                        edgeDef, 
                                                                        attrDef.EdgeType, 
                                                                        source,
                                                                        attrDef);

                            if (edge.HasValue)
                                singleEdges.Add(edgeDef.EdgeName, edge.Value);
                        }
                        break;

                    case EdgeMultiplicity.HyperEdge:
                        {
                            break;
                        }
                    case EdgeMultiplicity.MultiEdge:
                        {
                            var edge = CreateMultiEdgeAddDefinition(myTransaction, 
                                                                    mySecurity, 
                                                                    source, 
                                                                    date, 
                                                                    edgeDef, 
                                                                    attrDef);

                            if (edge.HasValue)
                                hyperEdges.Add(attrDef.Name, edge.Value);
                        }
                        break;
                    default:
                        throw new UnknownDBException("The EdgeMultiplicy enumeration was updated, but not this switch statement.");
                }
            }

            outSingleEdges = singleEdges.Select(x => x.Value);
            outHyperEdges = hyperEdges.Select(x => x.Value);
        }
Beispiel #47
0
 public void RebuildIndices(IVertexType myVertexType, Int64 myTransactionToken, SecurityToken mySecurityToken)
 {
     RebuildIndices(myVertexType, myTransactionToken, mySecurityToken, false);
 }
        private Tuple<long?, String, VertexUpdateDefinition> CreateVertexUpdateDefinition(
                                                                IVertex myVertex,
                                                                IVertexType myVertexType,
                                                                RequestUpdate myUpdate,
                                                                IPropertyProvider myPropertyCopy,
                                                                Int64 myTransaction,
                                                                SecurityToken mySecurity)
        {

            #region get removes

            List<long> toBeDeletedSingle = null;
            List<long> toBeDeletedHyper = null;
            List<long> toBeDeletedStructured = null;
            List<String> toBeDeletedUnstructured = null;
            List<long> toBeDeletedBinaries = null;

            if (myUpdate.RemovedAttributes != null)
            {
                #region remove each defined attribute

                foreach (var name in myUpdate.RemovedAttributes)
                {
                    if (myVertexType.HasAttribute(name))
                    {
                        var attr = myVertexType.GetAttributeDefinition(name);

                        switch (attr.Kind)
                        {
                            case AttributeType.Property:

                                if ((attr as IPropertyDefinition).IsMandatory)
                                    throw new MandatoryConstraintViolationException(attr.Name);

                                toBeDeletedStructured = toBeDeletedStructured ?? new List<long>();
                                toBeDeletedStructured.Add(attr.ID);
                                break;

                            case AttributeType.BinaryProperty:
                                toBeDeletedBinaries = toBeDeletedBinaries ?? new List<long>();
                                toBeDeletedBinaries.Add(attr.ID);
                                break;

                            case AttributeType.IncomingEdge:
                                //TODO: a better exception here.
                                throw new Exception("The edges on an incoming edge attribute can not be removed.");

                            case AttributeType.OutgoingEdge:
                                switch ((attr as IOutgoingEdgeDefinition).Multiplicity)
                                {
                                    case EdgeMultiplicity.HyperEdge:
                                    case EdgeMultiplicity.MultiEdge:
                                        toBeDeletedHyper = toBeDeletedHyper ?? new List<long>();
                                        toBeDeletedHyper.Add(attr.ID);
                                        break;
                                    case EdgeMultiplicity.SingleEdge:
                                        toBeDeletedSingle = toBeDeletedSingle ?? new List<long>();
                                        toBeDeletedSingle.Add(attr.ID);
                                        break;
                                    default:
                                        //TODO a better exception here
                                        throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement.");
                                }
                                break;

                            default:
                                //TODO: a better exception here.
                                throw new Exception("The enumeration AttributeType was updated, but not this switch statement.");
                        }
                    }
                    else
                    {
                        toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>();
                        toBeDeletedUnstructured.Add(name);
                    }
                }

                #endregion
            }

            if (myUpdate.RemovedUnstructuredProperties != null)
            {
                #region remove each unstructured property

                foreach (var name in myUpdate.RemovedUnstructuredProperties)
                {
                    if ((myVertexType.HasAttribute(name)) && (myVertexType.GetAttributeDefinition(name).Kind == AttributeType.Property))
                    {
                        toBeDeletedUnstructured = toBeDeletedUnstructured ?? new List<String>();
                        toBeDeletedUnstructured.Add(name);
                    }
                }

                #endregion
            }

            #endregion

            #region get update definitions

            IDictionary<Int64, HyperEdgeUpdateDefinition> toBeUpdatedHyper = null;
            IDictionary<Int64, SingleEdgeUpdateDefinition> toBeUpdatedSingle = null;
            IDictionary<Int64, IComparable> toBeUpdatedStructured = null;
            IDictionary<String, Object> toBeUpdatedUnstructured = null;
            IDictionary<Int64, StreamAddDefinition> toBeUpdatedBinaries = null;
            long? revision = null;
            string edition = myUpdate.UpdatedEdition;
            string comment = myUpdate.UpdatedComment;

            #region property copy things

            if (myPropertyCopy.StructuredProperties != null)
            {
                toBeUpdatedStructured = new Dictionary<long, IComparable>();
                foreach (var prop in myPropertyCopy.StructuredProperties)
                {
                    var propDef = myVertexType.GetPropertyDefinition(prop.Key);
                    CheckPropertyType(myVertexType.Name, prop.Value, propDef);
                    toBeUpdatedStructured.Add(propDef.ID, prop.Value);
                }
            }

            toBeUpdatedUnstructured = myPropertyCopy.UnstructuredProperties;

            #endregion

            #region binary properties
            if (myUpdate.UpdatedBinaryProperties != null)
            {
                foreach (var prop in myUpdate.UpdatedBinaryProperties)
                {
                    var propDef = myVertexType.GetBinaryPropertyDefinition(prop.Key);

                    toBeUpdatedBinaries = toBeUpdatedBinaries ?? new Dictionary<long, StreamAddDefinition>();
                    toBeUpdatedBinaries.Add(propDef.ID, new StreamAddDefinition(propDef.ID, prop.Value));
                }
            }
            #endregion

            #region collections

            if (myUpdate.AddedElementsToCollectionProperties != null || myUpdate.RemovedElementsFromCollectionProperties != null)
            {
                if (myUpdate.AddedElementsToCollectionProperties != null && myUpdate.RemovedElementsFromCollectionProperties != null)
                {
                    var keys = myUpdate.AddedElementsToCollectionProperties.Keys.Intersect(myUpdate.RemovedElementsFromCollectionProperties.Keys);
                    if (keys.CountIsGreater(0))
                    {
                        //TOTO a better exception here
                        throw new Exception("You can not add and remove items simultaneously on a collection attribute.");
                    }

                    if (myUpdate.AddedElementsToCollectionProperties != null)
                    {
                        foreach (var added in myUpdate.AddedElementsToCollectionProperties)
                        {
                            var propDef = myVertexType.GetPropertyDefinition(added.Key);

                            var hasValue = (propDef == null)
                                ? myVertex.HasUnstructuredProperty(added.Key)
                                : myVertex.HasProperty(propDef.ID);

                            //if it is not ICollectionWrapper something wrong with deserialization
                            var extractedValue = (!hasValue)
                                ? null
                                : (propDef == null)
                                    ? myVertex.GetUnstructuredProperty<ICollectionWrapper>(added.Key)
                                    : (ICollectionWrapper)propDef.GetValue(myVertex);

                            PropertyMultiplicity mult;
                            if (propDef != null)
                            {
                                //check types only for structured properties
                                foreach (var element in added.Value)
                                {
                                    CheckPropertyType(myVertexType.Name, element, propDef);
                                }
                                mult = propDef.Multiplicity;
                            }
                            else
                                mult = (added.Value is SetCollectionWrapper)
                                    ? PropertyMultiplicity.Set
                                    : PropertyMultiplicity.List;


                            var newValue = CreateNewCollectionWrapper(
                                (hasValue)
                                    ? extractedValue.Union(added.Value)
                                    : added.Value,
                                 mult);

                            if (propDef == null)
                            {
                                toBeUpdatedUnstructured = toBeUpdatedUnstructured ?? new Dictionary<String, object>();
                                toBeUpdatedUnstructured.Add(added.Key, newValue);
                            }
                            else
                            {
                                toBeUpdatedStructured = toBeUpdatedStructured ?? new Dictionary<long, IComparable>();
                                toBeUpdatedStructured.Add(propDef.ID, newValue);
                            }

                        }
                    }
                    if (myUpdate.RemovedElementsFromCollectionProperties != null)
                    {
                        foreach (var remove in myUpdate.RemovedElementsFromCollectionProperties)
                        {
                            var propDef = myVertexType.GetPropertyDefinition(remove.Key);

                            var hasValue = (propDef == null)
                                ? myVertex.HasUnstructuredProperty(remove.Key)
                                : myVertex.HasProperty(propDef.ID);

                            //no value, nothing to remove
                            if (!hasValue)
                                continue;

                            //if it is not ICollectionWrapper something wrong with deserialization
                            var extractedValue = (propDef == null)
                                ? myVertex.GetUnstructuredProperty<ICollectionWrapper>(remove.Key)
                                : (ICollectionWrapper)propDef.GetValue(myVertex);

                            PropertyMultiplicity mult = (propDef != null)
                                ? propDef.Multiplicity
                                : (extractedValue is SetCollectionWrapper)
                                    ? PropertyMultiplicity.Set
                                    : PropertyMultiplicity.List;

                            var newValue = CreateNewCollectionWrapper(extractedValue.Except(remove.Value), mult);

                            toBeUpdatedStructured.Add(propDef.ID, newValue);

                            if (propDef == null)
                            {
                                toBeUpdatedUnstructured = toBeUpdatedUnstructured ?? new Dictionary<String, object>();
                                toBeUpdatedUnstructured.Add(remove.Key, newValue);
                            }
                            else
                            {
                                toBeUpdatedStructured = toBeUpdatedStructured ?? new Dictionary<long, IComparable>();
                                toBeUpdatedStructured.Add(propDef.ID, newValue);
                            }

                        }
                    }
                }
            }

            #endregion

            #region extract vertex properties
            #region will be ignored
            long vertexID = 0L;
            long creationDate = 0L;
            long modificationDate = 0L;
            #endregion

            ExtractVertexProperties(ref edition, ref revision, ref comment, ref vertexID, ref creationDate, ref modificationDate, toBeUpdatedStructured);
            #endregion

            #region edge magic

            if (myUpdate.AddedElementsToCollectionEdges != null ||
                myUpdate.RemovedElementsFromCollectionEdges != null ||
                myUpdate.UpdateOutgoingEdges != null ||
                myUpdate.UpdateOutgoingEdgesProperties != null)
            {
                VertexInformation source = new VertexInformation(myVertex.VertexTypeID, myVertex.VertexID);

                #region update outgoing edges

                if (myUpdate.UpdateOutgoingEdges != null)
                {
                    foreach (var edge in myUpdate.UpdateOutgoingEdges)
                    {
                        var edgeDef = myVertexType.GetOutgoingEdgeDefinition(edge.EdgeName);

                        switch (edgeDef.Multiplicity)
                        {
                            case EdgeMultiplicity.SingleEdge:
                                {
                                    #region SingleEdge
                                    var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType);
                                    if (targets == null || !targets.CountIsGreater(0))
                                    {
                                        toBeDeletedSingle = toBeDeletedSingle ?? new List<long>();
                                        toBeDeletedSingle.Add(edgeDef.ID);
                                    }
                                    else if (targets.CountIsGreater(1))
                                    {
                                        throw new Exception("Single edge can not have more than one target.");
                                    }
                                    else
                                    {
                                        ConvertUnknownProperties(edge, edgeDef.EdgeType);
                                        var structured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType);
                                        var unstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties);

                                        toBeUpdatedSingle = toBeUpdatedSingle ?? new Dictionary<long, SingleEdgeUpdateDefinition>();

                                        toBeUpdatedSingle.Add(edgeDef.ID,
                                                                new SingleEdgeUpdateDefinition(source,
                                                                                                targets.First(),
                                                                                                edgeDef.EdgeType.ID,
                                                                                                edge.Comment,
                                                                                                structured,
                                                                                                unstructured));
                                    }
                                    #endregion
                                }
                                break;

                            case EdgeMultiplicity.MultiEdge:
                                {
                                    #region MultiEdge
                                    // Why deleting the edge instances ???
                                    // they will never be inserted inside the update !!!
                                    // After delete the update will be needless because the edges are deleted !!!

                                    //List<SingleEdgeDeleteDefinition> internSingleDelete = null;
                                    //if (myVertex.HasOutgoingEdge(edgeDef.ID))
                                    //{
                                    //    internSingleDelete = new List<SingleEdgeDeleteDefinition>();
                                    //    foreach (var edgeInstance in myVertex.GetOutgoingHyperEdge(edgeDef.ID).GetTargetVertices())
                                    //    {
                                    //        internSingleDelete.Add(
                                    //            new SingleEdgeDeleteDefinition(source,
                                    //                                            new VertexInformation(edgeInstance.VertexTypeID,
                                    //                                                                    edgeInstance.VertexID)));
                                    //    }
                                    //}

                                    List<SingleEdgeUpdateDefinition> internSingleUpdate = null;
                                    var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType);

                                    if (targets != null)
                                    {
                                        foreach (var target in targets)
                                        {
                                            internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>();
                                            internSingleUpdate.Add(new SingleEdgeUpdateDefinition(source, target, edgeDef.InnerEdgeType.ID));
                                        }
                                    }
                                    if (edge.ContainedEdges != null)
                                    {
                                        foreach (var innerEdge in edge.ContainedEdges)
                                        {
                                            targets = GetResultingVertexIDs(myTransaction, mySecurity, innerEdge, edgeDef.TargetVertexType);
                                            if (targets != null && targets.CountIsGreater(0))
                                            {
                                                ConvertUnknownProperties(innerEdge, edgeDef.InnerEdgeType);
                                                var structured = CreateStructuredUpdate(innerEdge.StructuredProperties, edgeDef.InnerEdgeType);
                                                var unstructured = CreateUnstructuredUpdate(innerEdge.UnstructuredProperties);

                                                foreach (var target in targets)
                                                {
                                                    internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>();

                                                    internSingleUpdate.Add(
                                                        new SingleEdgeUpdateDefinition(source,
                                                                                        target,
                                                                                        edgeDef.InnerEdgeType.ID,
                                                                                        innerEdge.Comment,
                                                                                        structured,
                                                                                        unstructured));
                                                }
                                            }

                                        }
                                    }
                                    ConvertUnknownProperties(edge, edgeDef.EdgeType);
                                    var outerStructured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType);
                                    var outerUnstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties);

                                    toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>();

                                    toBeUpdatedHyper.Add(edgeDef.ID,
                                                            new HyperEdgeUpdateDefinition(edgeDef.EdgeType.ID,
                                                                                            edge.Comment,
                                                                                            outerStructured,
                                                                                            outerUnstructured,
                                                                                            null,//internSingleDelete,
                                                                                            internSingleUpdate));
                                    #endregion
                                }
                                break;

                            case EdgeMultiplicity.HyperEdge:
                                break;

                            default:
                                throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement.");
                        }
                    }
                }

                #endregion

                #region update outgoing edges properties

                if (myUpdate.UpdateOutgoingEdgesProperties != null)
                {
                    foreach (var edge in myUpdate.UpdateOutgoingEdgesProperties)
                    {
                        var edgeDef = myVertexType
                                        .GetOutgoingEdgeDefinitions(true)
                                        .Where(_ => _.ID.Equals(edge.EdgeTypeID) ||
                                                _.InnerEdgeType.ID.Equals(edge.EdgeTypeID)).FirstOrDefault();

                        switch (edgeDef.Multiplicity)
                        {
                            case EdgeMultiplicity.SingleEdge:
                                {
                                    #region SingleEdge
                                    //var targets = GetResultingVertexIDs(myTransaction, mySecurity, edge, edgeDef.TargetVertexType);

                                    //if (targets == null || !targets.CountIsGreater(0))
                                    //{
                                    //    toBeDeletedSingle = toBeDeletedSingle ?? new List<long>();
                                    //    toBeDeletedSingle.Add(edgeDef.ID);
                                    //}
                                    //else if (targets.CountIsGreater(1))
                                    //{
                                    //    throw new Exception("Single edge can not have more than one target.");
                                    //}
                                    //else
                                    //{
                                    //    ConvertUnknownProperties(edge, edgeDef.EdgeType);
                                    //    var structured = CreateStructuredUpdate(edge.StructuredProperties, edgeDef.EdgeType);
                                    //    var unstructured = CreateUnstructuredUpdate(edge.UnstructuredProperties);

                                    //    toBeUpdatedSingle = toBeUpdatedSingle ?? new Dictionary<long, SingleEdgeUpdateDefinition>();

                                    //    toBeUpdatedSingle.Add(edgeDef.ID,
                                    //                            new SingleEdgeUpdateDefinition(source,
                                    //                                                            targets.First(),
                                    //                                                            edgeDef.EdgeType.ID,
                                    //                                                            edge.Comment,
                                    //                                                            structured,
                                    //                                                            unstructured));
                                    //}
                                    #endregion
                                }
                                break;

                            case EdgeMultiplicity.MultiEdge:
                                {
                                    #region MultiEdge
                                    List<SingleEdgeUpdateDefinition> internSingleUpdate = null;

                                    var targets =
                                        myVertex
                                        .GetOutgoingEdge(edgeDef.ID)
                                        .GetTargetVertices()
                                        .Select(_ => new VertexInformation(_.VertexTypeID,
                                                                            _.VertexID));

                                    if (targets != null && targets.CountIsGreater(0))
                                    {
                                        var structured = edge.UpdatedStructuredProperties;
                                        var unstructured = edge.UpdatedUnstructuredProperties;

                                        foreach (var target in targets)
                                        {
                                            internSingleUpdate = internSingleUpdate ?? new List<SingleEdgeUpdateDefinition>();

                                            internSingleUpdate.Add(
                                                new SingleEdgeUpdateDefinition(source,
                                                                                target,
                                                                                edgeDef.InnerEdgeType.ID,
                                                                                edge.CommentUpdate,
                                                                                structured,
                                                                                unstructured));
                                        }
                                    }

                                    toBeUpdatedHyper = toBeUpdatedHyper ??
                                                        new Dictionary<long, HyperEdgeUpdateDefinition>();

                                    if (toBeUpdatedHyper.ContainsKey(edgeDef.ID))
                                    {
                                        var temp = toBeUpdatedHyper[edgeDef.ID];
                                        toBeUpdatedHyper.Remove(edgeDef.ID);
                                        toBeUpdatedHyper.Add(edgeDef.ID,
                                                            MergeToBeAddedHyperEdgeUpdates(temp,
                                                                                            internSingleUpdate));
                                    }
                                    else
                                        toBeUpdatedHyper.Add(edgeDef.ID,
                                                                new HyperEdgeUpdateDefinition(edgeDef.EdgeType.ID,
                                                                                                null,
                                                                                                null,
                                                                                                null,
                                                                                                null,
                                                                                                internSingleUpdate));

                                    #endregion
                                }
                                break;

                            case EdgeMultiplicity.HyperEdge:
                                break;

                            default:
                                throw new Exception("The enumeration EdgeMultiplicity was changed, but not this switch statement.");
                        }
                    }
                }

                #endregion

                #region update AddedElementsToCollectionEdges

                if (myUpdate.AddedElementsToCollectionEdges != null)
                {
                    foreach (var hyperEdge in myUpdate.AddedElementsToCollectionEdges)
                    {
                        var edgeDef = myVertexType.GetOutgoingEdgeDefinition(hyperEdge.Key);

                        if (edgeDef == null)
                            //TODO a better exception here
                            throw new Exception("edge attribute not defined.");

                        if (edgeDef.Multiplicity == EdgeMultiplicity.SingleEdge)
                            //TODO a better exception here
                            throw new Exception("Add edges is only defined on hyper/multi edges.");

                        var edgeTypeID = edgeDef.ID;
                        StructuredPropertiesUpdate structuredUpdate;
                        UnstructuredPropertiesUpdate unstructuredUpdate;
                        IEnumerable<SingleEdgeUpdateDefinition> singleUpdate;

                        CheckIfToBeAddedElementAlreadyExist(myVertex, 
                                                            edgeDef, 
                                                            hyperEdge.Value,
                                                            myTransaction,
                                                            mySecurity);

                        CreateSingleEdgeUpdateDefinitions(source,
                                                            myTransaction,
                                                            mySecurity,
                                                            hyperEdge.Value,
                                                            edgeDef,
                                                            out structuredUpdate,
                                                            out unstructuredUpdate,
                                                            out singleUpdate);

                        toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>();

                        toBeUpdatedHyper.Add(edgeTypeID, new HyperEdgeUpdateDefinition(edgeTypeID, null, structuredUpdate, unstructuredUpdate, null, singleUpdate));
                    }
                }

                #endregion

                #region update RemovedElementsFromCollectionEdges

                if (myUpdate.RemovedElementsFromCollectionEdges != null)
                {
                    foreach (var hyperEdge in myUpdate.RemovedElementsFromCollectionEdges)
                    {
                        var edgeDef = myVertexType.GetOutgoingEdgeDefinition(hyperEdge.Key);

                        if (edgeDef == null)
                            //TODO a better exception here
                            throw new Exception("Edge attribute not defined.");

                        if (edgeDef.Multiplicity == EdgeMultiplicity.SingleEdge)
                            //TODO a better exception here
                            throw new Exception("Removing edges is only defined on hyper/multi edges.");

                        var edgeTypeID = edgeDef.ID;

                        var del = CreateSingleEdgeDeleteDefinitions(source, myTransaction, mySecurity, hyperEdge.Value, edgeDef);

                        toBeUpdatedHyper = toBeUpdatedHyper ?? new Dictionary<long, HyperEdgeUpdateDefinition>();
                        toBeUpdatedHyper.Add(edgeTypeID, new HyperEdgeUpdateDefinition(edgeTypeID, null, null, null, del, null));

                    }
                }

                #endregion
            }

            #endregion

            #region create updates

            var updateSingle = (toBeUpdatedSingle != null || toBeDeletedSingle != null)
                ? new SingleEdgeUpdate(toBeUpdatedSingle, toBeDeletedSingle)
                : null;

            var updateHyper = (toBeUpdatedHyper != null || toBeDeletedHyper != null)
                ? new HyperEdgeUpdate(toBeUpdatedHyper, toBeDeletedHyper)
                : null;

            var updateStructured = (toBeUpdatedStructured != null || toBeDeletedStructured != null)
                ? new StructuredPropertiesUpdate(toBeUpdatedStructured, toBeDeletedStructured)
                : null;

            var updateUnstructured = (toBeUpdatedUnstructured != null || toBeDeletedUnstructured != null)
                ? new UnstructuredPropertiesUpdate(toBeUpdatedUnstructured, toBeDeletedUnstructured)
                : null;

            var updateBinaries = (toBeUpdatedBinaries != null || toBeDeletedBinaries != null)
                ? new BinaryPropertiesUpdate(toBeUpdatedBinaries, toBeDeletedBinaries)
                : null;

            #endregion

            return Tuple.Create(revision,
                                edition,
                                new VertexUpdateDefinition(comment,
                                                            updateStructured,
                                                            updateUnstructured,
                                                            updateBinaries,
                                                            updateSingle,
                                                            updateHyper));
        }
        private Tuple<long?, VertexAddDefinition> RequestInsertVertexToVertexAddDefinition(RequestInsertVertex myInsertDefinition,
                                                                                            IVertexType myVertexType,
                                                                                            Int64 myTransaction,
                                                                                            SecurityToken mySecurity)
        {
            long vertexID = (myInsertDefinition.VertexUUID.HasValue)
                ? myInsertDefinition.VertexUUID.Value
                : _idManager.GetVertexTypeUniqeID(myVertexType.ID).GetNextID();

            var source = new VertexInformation(myVertexType.ID, vertexID);
            long creationdate = DateTime.UtcNow.ToBinary();
            long modificationDate = creationdate;
            String comment = myInsertDefinition.Comment;
            String edition = myInsertDefinition.Edition;
            long? revision = null;

            IEnumerable<SingleEdgeAddDefinition> singleEdges;
            IEnumerable<HyperEdgeAddDefinition> hyperEdges;

            CreateEdgeAddDefinitions(myInsertDefinition.OutgoingEdges,
                                        myVertexType,
                                        myTransaction,
                                        mySecurity,
                                        source,
                                        creationdate,
                                        out singleEdges,
                                        out hyperEdges);

            var binaries = (myInsertDefinition.BinaryProperties == null)
                            ? null
                            : myInsertDefinition.BinaryProperties.Select(x => new StreamAddDefinition(myVertexType.GetAttributeDefinition(x.Key).ID, x.Value));

            var structured = ConvertStructuredProperties(myInsertDefinition, myVertexType);

            ExtractVertexProperties(ref edition,
                                    ref revision,
                                    ref comment,
                                    ref vertexID,
                                    ref creationdate,
                                    ref modificationDate,
                                    structured);

            //set id to maximum to allow user set UUIDs
            _idManager.GetVertexTypeUniqeID(myVertexType.ID).SetToMaxID(vertexID);

            return Tuple.Create(revision, new VertexAddDefinition(vertexID,
                                                                    myVertexType.ID,
                                                                    edition,
                                                                    hyperEdges,
                                                                    singleEdges,
                                                                    null,
                                                                    binaries,
                                                                    comment,
                                                                    creationdate,
                                                                    modificationDate,
                                                                    structured,
                                                                    myInsertDefinition.UnstructuredProperties));
        }
Beispiel #50
0
        private SingleEdgeAddDefinition? CreateSingleEdgeAddDefinition(
            TransactionToken myTransaction,
            SecurityToken mySecurity,
            long date,
            long myAttributeID,
            EdgePredefinition edgeDef,
            IEdgeType myEdgeType,
            VertexInformation source,
            IVertexType myTargetType = null)
        {
            var vertexIDs = GetResultingVertexIDs(myTransaction, mySecurity, edgeDef, myTargetType);
            if (vertexIDs == null)
                return null;

            CheckMandatoryConstraint(edgeDef, myEdgeType);
            CheckTargetVertices(myTargetType, vertexIDs);
            AddDefaultValues(edgeDef, myEdgeType);
            return new SingleEdgeAddDefinition(myAttributeID, myEdgeType.ID, source, vertexIDs.First(), edgeDef.Comment, date, date, ConvertStructuredProperties(edgeDef, myEdgeType), edgeDef.UnstructuredProperties);
        }
Beispiel #51
0
        private IDictionary<String, IComparable> GetStructuredFromVertex(IVertex vertex, IVertexType vertexType, IEnumerable<string> neededPropNames)
        {
            var result = new Dictionary<String, IComparable>();
            foreach (var propName in neededPropNames)
            {
                var propDef = vertexType.GetPropertyDefinition(propName);

                if (propDef.HasValue(vertex))
                    result.Add(propName, propDef.GetValue(vertex));
            }

            return result;
        }
Beispiel #52
0
        private void RemoveFromIndex(
            long myVertexID, 
            IDictionary<string, IComparable> structured, 
            IVertexType vertexType, 
            IEnumerable<KeyValuePair<IList<IPropertyDefinition>, IEnumerable<IIndex<IComparable, long>>>> indices, 
            TransactionToken myTransaction, 
            SecurityToken mySecurity)
        {
            foreach (var indexGroup in indices)
            {
                foreach (var index in indexGroup.Value)
                {
                    var entry = CreateIndexEntry(indexGroup.Key, structured);

                    if (entry != null)
                    {
                        if (index is IMultipleValueIndex<IComparable, long>)
                        {
                            lock (index)
                            {
                                if (index.ContainsKey(entry))
                                {
                                    var toBeUpdatedIndex = (IMultipleValueIndex<IComparable, long>) index;

                                    var payLoad = toBeUpdatedIndex[entry];
                                    payLoad.Remove(myVertexID);

                                    toBeUpdatedIndex.Add(entry, payLoad, IndexAddStrategy.REPLACE);
                                }
                            }
                        }
                        else
                        {
                            index.Remove(entry);
                        }
                    }

                }

            }

        }
Beispiel #53
0
        public IEnumerable<ISonesIndex> GetIndices(IVertexType myVertexType, IList<IPropertyDefinition> myPropertyDefinition, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            myVertexType.CheckNull("myVertexType");
            myPropertyDefinition.CheckNull("myPropertyDefinition");

            if (myPropertyDefinition.Count == 0)
                throw new ArgumentOutOfRangeException("myPropertyDefinition", "At least one property must be given.");

            var propertyTypes = myPropertyDefinition.GroupBy(_ => _.RelatedType);
            foreach (var group in propertyTypes)
            {
                if (!myVertexType.IsDescendantOrSelf(group.Key))
                {
                    throw new ArgumentException(string.Format("The properties ({0}) defined on type {1} is not part of inheritance hierarchy of {2}.",
                        string.Join(",", group.Select(_ => _.Name)),
                        group.Key.Name,
                        myVertexType.Name));
                }
            }

            var result = myVertexType.GetIndexDefinitions(false).Where(_ => myPropertyDefinition.SequenceEqual(_.IndexedProperties)).Select(_=>_indices[_.ID]).ToArray();

            return result;
        }
 private static void CheckTargetVertices(IVertexType myTargetVertexType, IEnumerable<VertexInformation> vertexIDs)
 {
     var distinctTypeIDS = new HashSet<Int64>(vertexIDs.Select(x => x.VertexTypeID));
     var allowedTypeIDs = new HashSet<Int64>(myTargetVertexType.GetDescendantVertexTypesAndSelf().Select(x => x.ID));
     distinctTypeIDS.ExceptWith(allowedTypeIDs);
     if (distinctTypeIDS.Count > 0)
         throw new Exception("A target vertex has a type, that is not assignable to the target vertex type of the edge.");
 }
Beispiel #55
0
 public IEnumerable<ISonesIndex> GetIndices(IVertexType myVertexType, IPropertyDefinition myPropertyDefinition, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     myVertexType.CheckNull("myVertexType");
     return myVertexType.GetIndexDefinitions(false).Where(_=>_.IndexedProperties.Count == 1 && _.IndexedProperties.Contains(myPropertyDefinition)).Select(_ => _indices[_.ID]);
     //return myPropertyDefinition.InIndices.Where(_ => myVertexType.Equals(_.VertexType)).Select(_ => _indices[_.ID]);
 }
        private IEnumerable<VertexInformation> GetResultingVertexIDs(Int64 myTransaction, SecurityToken mySecurity, EdgePredefinition myEdgeDef, IVertexType myTargetType = null)
        {
            if (myEdgeDef.VertexIDsByVertexTypeID != null || myEdgeDef.VertexIDsByVertexTypeName != null)
            {
                HashSet<VertexInformation> result = new HashSet<VertexInformation>();
                if (myEdgeDef.VertexIDsByVertexTypeID != null)
                {
                    foreach (var kvP in myEdgeDef.VertexIDsByVertexTypeID)
                    {
                        foreach (var vertex in kvP.Value)
                        {
                            result.Add(new VertexInformation(kvP.Key, vertex));
                        }

                    }
                }
                if (myEdgeDef.VertexIDsByVertexTypeName != null)
                {
                    foreach (var kvP in myEdgeDef.VertexIDsByVertexTypeName)
                    {
                        var vertexType = _vertexTypeManager.ExecuteManager.GetType(kvP.Key, myTransaction, mySecurity);
                        foreach (var vertex in kvP.Value)
                        {
                            result.Add(new VertexInformation(vertexType.ID, vertex));
                        }

                    }
                }
                return result;
            }
            return null;
        }
Beispiel #57
0
        private string CreateIndexName(IndexPredefinition myIndexDefinition, IVertexType vertexType)
        {
            var propNames = string.Join("AND", myIndexDefinition.Properties);

            int count = 0;
            string result;
            do
            {
                result = string.Join("_", "sones", propNames, vertexType.Name, count++);
            } while (_ownIndex.ContainsKey(result));

            return result;
        }
        public override IEnumerable<IVertex> GetVertices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, Boolean includeSubtypes)
        {
            if (includeSubtypes)
            {
                return myVertexType.GetDescendantVertexTypesAndSelf().SelectMany(_ => _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, _.ID));
            }
            else
            {
                return _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, myVertexType.ID);
            }

        }
Beispiel #59
0
        private void RebuildIndices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, bool myOnlyNonPersistent )
        {
            Dictionary<IList<IPropertyDefinition>, IEnumerable<ISonesIndex>> toRebuild = new Dictionary<IList<IPropertyDefinition>, IEnumerable<ISonesIndex>>();
            foreach (var indexDef in myVertexType.GetIndexDefinitions(false))
            {
                var indices = GetIndices(myVertexType, indexDef.IndexedProperties, mySecurity, myTransaction).Where(_=>!myOnlyNonPersistent || !GetIsPersistentIndex(_));
                toRebuild.Add(indexDef.IndexedProperties, indices);
            }

            if (toRebuild.Count > 0)
            {
                foreach (var aIdxCollection in toRebuild.Values)
                {
                    foreach (var aIdx in aIdxCollection)
                    {
                        aIdx.Clear();
                    }
                }

                var vertices = _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, myVertexType.ID);

                foreach (var vertex in vertices)
                {
                    foreach (var indexGroup in toRebuild)
                    {
                        foreach (var index in indexGroup.Value)
                        {
                            index.Add(CreateIndexKey(indexGroup.Key, vertex), vertex.VertexID);
                        }
                    }
                }
            }
        }
Beispiel #60
0
 public static IEnumerable<IOutgoingEdgeDefinition> GetOutgoingEdgesFromFS(IVertex myTypeVertex, IVertexType myBaseType = null)
 {
     return GetAttributeVertices(myTypeVertex, (long)BaseTypes.OutgoingEdge).Select(x => CreateOutgoingEdgeDefinition(x, myBaseType));
 }