本文整理汇总了C#中sones.GraphDB.TypeManagement.GraphDBType.GetMandatoryAttributesUUIDs方法的典型用法代码示例。如果您正苦于以下问题:C# GraphDBType.GetMandatoryAttributesUUIDs方法的具体用法?C# GraphDBType.GetMandatoryAttributesUUIDs怎么用?C# GraphDBType.GetMandatoryAttributesUUIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sones.GraphDB.TypeManagement.GraphDBType
的用法示例。
在下文中一共展示了GraphDBType.GetMandatoryAttributesUUIDs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMandatoryAttributes
private Exceptional AddMandatoryAttributes(DBContext myDBContext, GraphDBType myGraphDBType, ManipulationAttributes myManipulationAttributes)
{
Boolean mandatoryDefaults = (Boolean)myDBContext.DBSettingsManager.GetSettingValue((new SettingDefaultsOnMandatory()).ID, myDBContext, TypesSettingScope.TYPE, myGraphDBType).Value.Value;
TypeAttribute typeAttr = null;
GraphDBType typeOfAttr = null;
var typeMandatoryAttribs = myGraphDBType.GetMandatoryAttributesUUIDs(myDBContext.DBTypeManager);
if ((myManipulationAttributes.MandatoryAttributes.Count < typeMandatoryAttribs.Count()) && !mandatoryDefaults)
return new Exceptional(new Error_MandatoryConstraintViolation(myGraphDBType.Name));
foreach (var attrib in typeMandatoryAttribs)
{
if (!myManipulationAttributes.MandatoryAttributes.Contains(attrib))
{
//if we have mandatory attributes in type but not in the current statement and USE_DEFAULTS_ON_MANDATORY is true then do this
if (mandatoryDefaults)
{
typeAttr = myGraphDBType.GetTypeAttributeByUUID(attrib);
if (typeAttr == null)
return new Exceptional(new Error_AttributeIsNotDefined(myGraphDBType.Name, typeAttr.Name));
typeOfAttr = myDBContext.DBTypeManager.GetTypeByUUID(typeAttr.DBTypeUUID);
IObject defaultValue = typeAttr.DefaultValue;
if (defaultValue == null)
defaultValue = typeAttr.GetDefaultValue(myDBContext);
myManipulationAttributes.Attributes.Add(new TypeAndAttributeDefinition(typeAttr, typeOfAttr), defaultValue);
}
else
{
return new Exceptional(new Error_MandatoryConstraintViolation("Attribute \"" + myGraphDBType.GetTypeAttributeByUUID(attrib).Name + "\" of Type \"" + myGraphDBType.Name + "\" is mandatory."));
}
}
}
return Exceptional.OK;
}
示例2: GetRecursiveAttributes
/// <summary>
/// Get attribute assignments for new DBObjects.
/// </summary>
/// <param name="myAttributeAssigns">The interesting ParseTreeNode.</param>
/// <param name="typeManager">The TypeManager of the GraphDB.</param>
/// <returns>A Dictionary of AttributeAssignments</returns>
private Exceptional<ManipulationAttributes> GetRecursiveAttributes(List<AAttributeAssignOrUpdate> myAttributeAssigns, DBContext myDBContext, GraphDBType myGraphDBType)
{
#region Data
var manipulationAttributes = new ManipulationAttributes();
var resultExcept = new Exceptional<ManipulationAttributes>();
if (myAttributeAssigns == null)
{
return new Exceptional<ManipulationAttributes>(manipulationAttributes);
}
TypeAttribute attr;
ADBBaseObject typedAttributeValue;
BasicType correspondingCSharpType;
Warning_UndefinedAttribute undefAttrWarning = null;
var typeMandatoryAttribs = myGraphDBType.GetMandatoryAttributesUUIDs(myDBContext.DBTypeManager);
var setExcept = myDBContext.DBSettingsManager.GetSetting(SettingUndefAttrBehaviour.UUID, myDBContext, TypesSettingScope.DB);
if (!setExcept.Success())
{
return new Exceptional<ManipulationAttributes>(setExcept);
}
var undefAttrBehave = (SettingUndefAttrBehaviour)setExcept.Value;
#endregion
#region get Data
#region proceed list
foreach (var aAttributeAssign in myAttributeAssigns)
{
var validateResult = aAttributeAssign.AttributeIDChain.Validate(myDBContext, true);
if (validateResult.Failed())
{
return new Exceptional<ManipulationAttributes>(validateResult);
}
#region Undefined attributes - Refactor and add undefined logic into defined attribute AssignsOrUpdate
System.Diagnostics.Debug.Assert(aAttributeAssign.AttributeIDChain != null);
//in this case we have an undefined attribute
if (aAttributeAssign.AttributeIDChain.IsUndefinedAttribute)
{
var UndefAttrName = aAttributeAssign.AttributeIDChain.UndefinedAttribute;
switch (undefAttrBehave.Behaviour)
{
case UndefAttributeBehaviour.disallow:
return new Exceptional<ManipulationAttributes>(new Error_UndefinedAttributes());
case UndefAttributeBehaviour.warn:
if (undefAttrWarning == null)
{
undefAttrWarning = new Warning_UndefinedAttribute();
}
resultExcept.PushIWarning(undefAttrWarning);
break;
}
if (aAttributeAssign is AttributeAssignOrUpdateList)
{
#region AttributeAssignCollection
var colDefinition = (aAttributeAssign as AttributeAssignOrUpdateList).CollectionDefinition;
EdgeTypeListOfBaseObjects valueList = new EdgeTypeListOfBaseObjects();
foreach (var tuple in colDefinition.TupleDefinition)
{
if (tuple.TypeOfValue == BasicType.Unknown)
valueList.Add((tuple.Value as ValueDefinition).Value);
else if (tuple.Value is ValueDefinition)
valueList.Add((tuple.Value as ValueDefinition).Value);
else
return new Exceptional<ManipulationAttributes>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
}
if (colDefinition.CollectionType == CollectionType.Set)
valueList.UnionWith(valueList);
manipulationAttributes.UndefinedAttributes.Add(UndefAttrName, valueList);
var undefAttr = new UndefinedAttributeDefinition() { AttributeName = UndefAttrName, AttributeValue = valueList };
var undefAttrAssign = new AttributeAssignOrUpdateUndefined((aAttributeAssign as AttributeAssignOrUpdateList).AttributeIDChain, undefAttr);
manipulationAttributes.AttributeToUpdateOrAssign.Add(undefAttrAssign);
//.........这里部分代码省略.........
示例3: 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);
}