当前位置: 首页>>代码示例>>C#>>正文


C# GraphDBType.GetTypeAttributeByName方法代码示例

本文整理汇总了C#中sones.GraphDB.TypeManagement.GraphDBType.GetTypeAttributeByName方法的典型用法代码示例。如果您正苦于以下问题:C# GraphDBType.GetTypeAttributeByName方法的具体用法?C# GraphDBType.GetTypeAttributeByName怎么用?C# GraphDBType.GetTypeAttributeByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sones.GraphDB.TypeManagement.GraphDBType的用法示例。


在下文中一共展示了GraphDBType.GetTypeAttributeByName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        /// <summary>
        /// Execute the renaming of the backwardedge of a given type.
        /// </summary>
        /// <param name="myDBContext"></param>
        /// <param name="myGraphDBType"></param>
        /// <returns></returns>
        public override Exceptional Execute(DBContext myDBContext, GraphDBType myGraphDBType)
        {
            TypeAttribute Attribute = myGraphDBType.GetTypeAttributeByName(OldName);

            if (Attribute == null)
            {
                return new Exceptional(new Error_AttributeIsNotDefined(OldName));
            }

            return myGraphDBType.RenameBackwardedge(Attribute, NewName, myDBContext.DBTypeManager);
        }
开发者ID:TheByte,项目名称:sones,代码行数:17,代码来源:AlterType_RenameBackwardedge.cs

示例2: Execute

        /// <summary>
        /// Executes the removal of certain myAttributes.
        /// <seealso cref=" AAlterTypeCommand"/>
        /// </summary>
        public override Exceptional Execute(DBContext myDBContext, GraphDBType myGraphDBType)
        {
            Exceptional result = new Exceptional();

            foreach (String aAttributeName in _ListOfAttributes)
            {
                var attr = myGraphDBType.GetTypeAttributeByName(aAttributeName);

                if (attr != null)
                {
                    var idxs = new List<Indices.AAttributeIndex>(myGraphDBType.GetAttributeIndices(myDBContext, attr.UUID));

                    foreach (var item in idxs)
                    {
                        var remIdxResult = myGraphDBType.RemoveIndex(item.IndexName, item.IndexEdition, myDBContext);

                        if (remIdxResult.Failed())
                        {
                            result.PushIExceptional(remIdxResult);
                        }
                    }
                }
                else
                {
                    result.PushIError(new Error_AttributeIsNotDefined(aAttributeName));
                    return result;
                }

                //Hack: remove myAttributes in DBObjects
                var aTempResult = myDBContext.DBTypeManager.RemoveAttributeFromType(myGraphDBType.Name, aAttributeName, myDBContext.DBTypeManager);

                if (aTempResult.Failed())
                {
                    result.PushIExceptional(aTempResult);
                    return result;
                }
            }

            return result;
        }
开发者ID:Vadi,项目名称:sones,代码行数:44,代码来源:AlterType_DropAttributes.cs

示例3: CreateNewDBObject

 /// <summary>
 /// Creates a new DBObject of a given GraphType inserts its UUID into all indices of the given GraphType.
 /// </summary>
 /// <param name="myGraphDBType">The GraphType of the DBObject to create</param>
 /// <param name="myDBObjectAttributes">A dictionary of attributes for the new DBObject</param>
 /// <param name="myExtractSettings">Special values which should be set to a object</param>
 /// <returns>The UUID of the new DBObject</returns>
 public Exceptional<DBObjectStream> CreateNewDBObject(GraphDBType myGraphDBType, Dictionary<String, IObject> myDBObjectAttributes, Dictionary<String, IObject> myUndefAttributes, Dictionary<ASpecialTypeAttribute, Object> mySpecialTypeAttributes, SessionSettings mySessionSettings, Boolean myCheckUniqueness)
 {
     Dictionary<AttributeUUID, IObject> _attrs = myDBObjectAttributes.ToDictionary(key => myGraphDBType.GetTypeAttributeByName(key.Key).UUID, value => value.Value);
     return CreateNewDBObjectStream(myGraphDBType, _attrs, myUndefAttributes, mySpecialTypeAttributes, mySessionSettings, myCheckUniqueness);
 }
开发者ID:ipbi,项目名称:sones,代码行数:12,代码来源:DBObjectManager.cs

示例4: RenameAttributeOfType

        public Exceptional<Boolean> RenameAttributeOfType(GraphDBType myType, String oldName, String newName)
        {
            #region INPUT EXCEPTIONS

            if (myType == null)
            {
                return new Exceptional<Boolean>(new Error_ArgumentNullOrEmpty("myType"));
            }

            if (String.IsNullOrEmpty(oldName))
            {
                return new Exceptional<Boolean>(new Error_ArgumentNullOrEmpty("oldName)"));
            }
            if (String.IsNullOrEmpty(newName))
            {
                return new Exceptional<Boolean>(new Error_ArgumentNullOrEmpty("newName"));
            }

            #endregion

            #region Data

            TypeAttribute typeAttribute = null;

            #endregion

            #region rename attribute of type

            typeAttribute = myType.GetTypeAttributeByName(oldName);

            if (typeAttribute != null)
            {

                Exceptional<Boolean> Result = myType.RenameAttribute(typeAttribute.UUID, newName);

                if (Result.Failed())
                    return new Exceptional<Boolean>(Result);

                var FlushExcept = FlushType(myType);

                if (FlushExcept.Failed())
                {

                    Result = myType.RenameAttribute(typeAttribute.UUID, oldName);

                    if (Result.Failed())
                        return new Exceptional<Boolean>(Result);

                    return new Exceptional<Boolean>(FlushExcept);
                }

            }
            else
            {
                return new Exceptional<Boolean>(new Error_AttributeIsNotDefined(myType.Name, oldName));
            }

            #endregion

            return new Exceptional<Boolean>(true);
        }
开发者ID:TheByte,项目名称:sones,代码行数:61,代码来源:DBTypeManager.cs

示例5: Execute

        /// <summary>
        /// Adds myAttributes to a certain graphDBType.
        /// </summary>
        /// <param name="myGraphDBType">The type that should be added some myAttributes.</param>
        /// <param name="myDBContext">The DBContext.</param>
        /// <returns>A Exceptional.</returns>
        public override Exceptional Execute(DBContext myDBContext, GraphDBType myGraphDBType)
        {
            #region check type for myAttributes

            foreach (var aAttributeDefinition in _ListOfAttributes)
            {
                if (myGraphDBType.GetTypeAttributeByName(aAttributeDefinition.AttributeName) != null)
                {
                    var aError = new Error_AttributeAlreadyExists(aAttributeDefinition.AttributeName);

                    return new Exceptional(aError);
                }
            }

            #endregion

            #region add myAttributes

            foreach (var aAttributeDefinition in _ListOfAttributes)
            {

                var typeAttributeExceptional = aAttributeDefinition.CreateTypeAttribute(myDBContext);
                if (typeAttributeExceptional.Failed())
                {
                    return typeAttributeExceptional;
                }
                var typeAttribute = typeAttributeExceptional.Value;

                try
                {
                    var theType = myDBContext.DBTypeManager.GetTypeByName(aAttributeDefinition.AttributeType.Name);
                    typeAttribute.DBTypeUUID = theType.UUID;
                    typeAttribute.RelatedGraphDBTypeUUID = myGraphDBType.UUID;

                    #region EdgeType
                    if (typeAttribute.EdgeType == null) // should never happen - delete me!
                    {
                        #region we had not defined a special EdgeType - for single reference attributes we need to set the EdgeTypeSingle NOW!
                        if (typeAttribute.KindOfType == KindsOfType.SingleReference)
                            typeAttribute.EdgeType = new EdgeTypeSingleReference(null, theType.UUID);

                        if (typeAttribute.KindOfType == KindsOfType.ListOfNoneReferences)
                            typeAttribute.EdgeType = new EdgeTypeListOfBaseObjects();

                        if (typeAttribute.KindOfType == KindsOfType.SetOfReferences || typeAttribute.KindOfType == KindsOfType.SetOfNoneReferences)
                            typeAttribute.EdgeType = new EdgeTypeSetOfReferences(null, theType.UUID);

                        #endregion
                    }
                    #endregion

                    var aTempResult = myDBContext.DBTypeManager.AddAttributeToType(myGraphDBType, typeAttribute);

                    if (!aTempResult.Success())
                    {
                        return aTempResult;
                    }
                }
                catch (Exception e)
                {
                    var aError = new Error_UnknownDBError(e);

                    return new Exceptional(aError);
                }
            }

            #endregion

            #region add BackwardEdges

            if (_BackwardEdgeInformation != null)
            {
                foreach (var beDef in _BackwardEdgeInformation)
                {
                    //GraphDBType edgeType = typeManager.GetTypeByName(tuple.TypeName);
                    //TypeAttribute edgeAttribute = edgeType.GetTypeAttributeByName(tuple.TypeAttributeName);

                    var typeAttribute = myDBContext.DBTypeManager.CreateBackwardEdgeAttribute(beDef, myGraphDBType);

                    if (typeAttribute.Failed())
                    {
                        return new Exceptional(typeAttribute);
                    }

                    // TODO: go through all DB Objects of the _TypeName and change the implicit backward edge type to the new ta.EdgeType
                    //       if the DBObject has one!

                    try
                    {
                        var aTempResult = myDBContext.DBTypeManager.AddAttributeToType(myGraphDBType, typeAttribute.Value);

                        if (aTempResult.Failed())
                        {
                            return aTempResult;
//.........这里部分代码省略.........
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:AlterType_AddAttributes.cs

示例6: Execute

        public override Exceptional Execute(DBContext dbContext, GraphDBType graphDBType)
        {
            var listOfTypeAttrs = new List<TypeAttribute>();
            var retExcept = new Exceptional();

            foreach (var attr in _ListOfAttributes)
            {

                var typeAttr = graphDBType.GetTypeAttributeByName(attr);

                if (typeAttr == null)
                {
                    return new Exceptional(new Error_AttributeIsNotDefined(attr));
                }

                var attrType = dbContext.DBTypeManager.GetTypeByUUID(typeAttr.DBTypeUUID);

                if (attrType == null)
                    return new Exceptional(new Error_TypeDoesNotExist(""));

                if (attrType.IsUserDefined)
                    return new Exceptional(new Error_InvalidReferenceAssignmentOfUndefAttr());

                listOfTypeAttrs.Add(typeAttr);

            }

            var dbobjects = dbContext.DBObjectCache.SelectDBObjectsForLevelKey(new LevelKey(graphDBType, dbContext.DBTypeManager), dbContext);

            foreach (var item in dbobjects)
            {

                if (!item.Success())
                {
                    retExcept.PushIExceptional(item);
                }

                else
                {
                    foreach (var attr in listOfTypeAttrs)
                    {
                        if (item.Value.HasAttribute(attr.UUID, graphDBType))
                        {
                            var attrVal = item.Value.GetAttribute(attr.UUID);

                            var addExcept = item.Value.AddUndefinedAttribute(attr.Name, attrVal, dbContext.DBObjectManager);

                            if (!addExcept.Success())
                                retExcept.PushIExceptional(addExcept);

                            item.Value.RemoveAttribute(attr.UUID);

                            var saveExcept = dbContext.DBObjectManager.FlushDBObject(item.Value);

                            if (!saveExcept.Success())
                                retExcept.PushIExceptional(saveExcept);
                        }
                    }
                }
            }

            var indices = graphDBType.GetAllAttributeIndices();
            List<AAttributeIndex> idxToDelete = new List<AAttributeIndex>();

            //remove attributes from type
            foreach (var attr in listOfTypeAttrs)
            {

                foreach (var item in indices)
                {
                    var index = item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Find(idx => idx == attr.UUID);

                    if (index != null && item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count == 1)
                    {
                        idxToDelete.Add(item);
                    }
                }

                //remove indices
                foreach (var idx in idxToDelete)
                {
                    var remExcept = graphDBType.RemoveIndex(idx.IndexName, idx.IndexEdition, dbContext.DBTypeManager);

                    if (!remExcept.Success())
                    {
                        retExcept.PushIExceptional(remExcept);
                    }
                }

                idxToDelete.Clear();
                graphDBType.RemoveAttribute(attr.UUID);

                var flushExcept = dbContext.DBTypeManager.FlushType(graphDBType);

                if (!flushExcept.Success())
                {
                    retExcept.PushIExceptional(flushExcept);
                }
            }

//.........这里部分代码省略.........
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:AlterType_UndefineAttributes.cs

示例7: Update

        /// <summary>
        /// <seealso cref=" AAttributeAssignOrUpdateOrRemove"/>
        /// </summary>
        public override Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>> Update(DBContext myDBContext, DBObjectStream myDBObjectStream, GraphDBType myGraphDBType)
        {
            Dictionary<String, Tuple<TypeAttribute, IObject>> attrsForResult = new Dictionary<String, Tuple<TypeAttribute, IObject>>();

            #region AttributeRemove

            #region divide remove list in undefined and defined attributes

            var undefAttrsExcept = myDBObjectStream.GetUndefinedAttributePayload(myDBContext.DBObjectManager);

            if (undefAttrsExcept.Failed())
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(undefAttrsExcept);
            }

            var undefAttrsOfObject = undefAttrsExcept.Value;

            var undefAttrsToRemove = ToBeRemovedAttributes.Where(item => undefAttrsOfObject.ContainsKey(item)).ToList();

            List<String> defAttrsToRemove = new List<String>();
            List<String> unknowAttrs = new List<String>();

            foreach (var item in ToBeRemovedAttributes.Where(item => !undefAttrsOfObject.ContainsKey(item)).ToList())
            {
                if (myGraphDBType.GetTypeAttributeByName(item) != null)
                    defAttrsToRemove.Add(item);
                else
                    unknowAttrs.Add(item);
            }

            #endregion

            #region remove undefined attributes

            if (!unknowAttrs.IsNullOrEmpty())
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(new Error_InvalidUndefinedAttributes(unknowAttrs));
            }

            foreach (var aAttribute in undefAttrsToRemove)
            {
                var removeExcept = myDBContext.DBObjectManager.RemoveUndefinedAttribute(aAttribute, myDBObjectStream);

                if (removeExcept.Failed())
                {
                    return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(removeExcept);
                }

                attrsForResult.Add(aAttribute, new Tuple<TypeAttribute, IObject>(new UndefinedTypeAttribute(aAttribute), null));
            }

            //if (!undefAttrsToRemove.IsNullOrEmpty())
            //    sthChanged = true;

            #endregion

            #region RemoveAttribute

            var applyRemoveResult = ApplyRemoveAttribute(defAttrsToRemove, myDBContext, myDBObjectStream, myGraphDBType);

            if (applyRemoveResult.Failed())
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(applyRemoveResult);
            }

            if (applyRemoveResult.Value.Count > 0)
            {
                //sthChanged = true;

                #region Add to queryResult

                foreach (var attr in applyRemoveResult.Value)
                {
                    attrsForResult.Add(attr.Name, new Tuple<TypeAttribute, IObject>(attr, null));
                }

                #endregion

            }

            #endregion

            #endregion

            return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(attrsForResult);
        }
开发者ID:Vadi,项目名称:sones,代码行数:89,代码来源:AttributeRemove.cs

示例8: ApplyRemoveAttribute

        /// <summary>
        /// Execute the remove of attributes
        /// </summary>
        /// <param name="myAttrsToRemove">The list of attributes to remove</param>
        /// <param name="myDBContext">The db context</param>
        /// <param name="myDBDBObject">The db object from which the attributes should be deleted</param>
        /// <param name="myGraphDBType">The type of the db object</param>
        /// <returns>The list of removed attributes</returns>
        private Exceptional<List<TypeAttribute>> ApplyRemoveAttribute(List<string> myAttrsToRemove, DBContext myDBContext, DBObjectStream myDBDBObject, GraphDBType myGraphDBType)
        {
            #region data

            List<TypeAttribute> removedAttributes = new List<TypeAttribute>();

            #endregion

            var MandatoryTypeAttrib = myGraphDBType.GetMandatoryAttributesUUIDs(myDBContext.DBTypeManager);
            foreach (String aAttribute in myAttrsToRemove)
            {
                TypeAttribute typeAttribute = myGraphDBType.GetTypeAttributeByName(aAttribute);

                if (myDBDBObject.HasAttribute(typeAttribute.UUID, myGraphDBType))
                {
                    if (!MandatoryTypeAttrib.Contains(typeAttribute.UUID))
                    {
                        #region remove backward edges

                        if (typeAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
                        {
                            var userdefinedAttributes = new Dictionary<AttributeUUID, object>();
                            userdefinedAttributes.Add(typeAttribute.UUID, myDBDBObject.GetAttribute(typeAttribute.UUID));

                            RemoveBackwardEdges(myGraphDBType.UUID, userdefinedAttributes, myDBDBObject.ObjectUUID, myDBContext);
                        }

                        #endregion

                        myDBDBObject.RemoveAttribute(typeAttribute.UUID);
                        removedAttributes.Add(typeAttribute);
                    }
                    else
                    {
                        return new Exceptional<List<TypeAttribute>>(new Error_MandatoryConstraintViolation("Error in update statement. The attribute \"" + typeAttribute.Name + "\" is mandatory and can not be removed."));
                    }
                }
            }

            return new Exceptional<List<TypeAttribute>>(removedAttributes);
        }
开发者ID:Vadi,项目名称:sones,代码行数:49,代码来源:AttributeRemove.cs


注:本文中的sones.GraphDB.TypeManagement.GraphDBType.GetTypeAttributeByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。