/// <summary> /// Checks if the given parameter type is valid. /// </summary> /// <param name="myRequest">The parameter to be checked.</param> protected override void CheckRequestType(IRequestAlterType myRequest) { if (!(myRequest is RequestAlterVertexType)) { throw new InvalidParameterTypeException("AlterTypeRequest", myRequest.GetType().Name, typeof(RequestAlterVertexType).Name); } }
/// <summary> /// Calls a Check function foreach IEnumerable of definied attributes. /// </summary> /// <param name="myRequest">The alter type request which contains the attributes.</param> protected override void CheckAttributesNameAndType(IRequestAlterType myRequest) { CheckNameAndTypeOfAttributePredefinitions(myRequest.ToBeAddedProperties); CheckNameAndTypeOfAttributePredefinitions(myRequest.ToBeAddedUnknownAttributes); CheckNameOfAttributeList(myRequest.ToBeRemovedProperties); CheckNameOfAttributeList(myRequest.ToBeRemovedUnknownAttributes); }
/// <summary> /// Checks if it possible to remove a mandatory or unique constraint /// </summary> /// <param name="myAlterTypeRequest">The request.</param> /// <param name="myType">The type.</param> protected static void CheckToBeAddedMandatoryAndUnique(IRequestAlterType myAlterTypeRequest, IVertexType myType) { var request = myAlterTypeRequest as RequestAlterVertexType; CheckToBeAddedMandatory(request, myType); CheckToBeAddedUniques(request, myType); }
public override T AlterType(IRequestAlterType myAlterTypeRequest, Int64 myTransactionToken, SecurityToken mySecurityToken, out RequestUpdate myUpdateRequest) { CheckRequestType(myAlterTypeRequest); var type = GetType(myAlterTypeRequest.TypeName, myTransactionToken, mySecurityToken); RequestUpdate updateRequest = (myAlterTypeRequest is RequestAlterVertexType) ? new RequestUpdate(new RequestGetVertices(type.ID)) : new RequestUpdate(); #region remove stuff AlterType_Remove(myAlterTypeRequest, type, myTransactionToken, mySecurityToken, ref updateRequest); CleanUpTypes(); #endregion #region add stuff AlterType_Add(myAlterTypeRequest, type, myTransactionToken, mySecurityToken, ref updateRequest); CleanUpTypes(); #endregion type = GetType(myAlterTypeRequest.TypeName, myTransactionToken, mySecurityToken); RenamesAndComment(myAlterTypeRequest, type, myTransactionToken, mySecurityToken); CleanUpTypes(); CallRebuildIndices(myTransactionToken, mySecurityToken); myUpdateRequest = updateRequest; return(GetType(type.ID, myTransactionToken, mySecurityToken)); }
/// <summary> /// Calls various check function which check the specified member inside the RequestAlterEdgeType /// </summary> /// <param name="myAlterTypeRequest">The request which contains the to be checked member.</param> /// <param name="myType">The Type which is returned.</param> /// <param name="myTransactionToken">The Int64.</param> /// <param name="mySecurityToken">The SecurityToken.</param> protected override void CallCheckFunctions(IRequestAlterType myAlterTypeRequest, IEdgeType myType, Int64 myTransactionToken, SecurityToken mySecurityToken) { CheckAttributesNameAndType(myAlterTypeRequest); CheckToBeAddedAttributes(myAlterTypeRequest, myType); CheckToBeDefinedAttributes(myAlterTypeRequest, myType); CheckToBeRemovedAttributes(myAlterTypeRequest, myType); CheckToBeRenamedAttributes(myAlterTypeRequest, myType); CheckNewTypeName(myAlterTypeRequest.AlteredTypeName, myTransactionToken, mySecurityToken); }
protected override void CallCheckFunctions(IRequestAlterType myAlterTypeRequest, IVertexType myType, Int64 myTransactionToken, SecurityToken mySecurityToken) { var request = myAlterTypeRequest as RequestAlterVertexType; CheckAttributesNameAndType(request); CheckToBeAddedAttributes(request, myType); CheckToBeDefinedAttributes(request, myType); CheckToBeRemovedAttributes(request, myType); CheckToBeRenamedAttributes(request, myType); CheckNewTypeName(request.AlteredTypeName, myTransactionToken, mySecurityToken); CheckToBeAddedMandatoryAndUnique(request, myType); CheckToBeRemovedMandatoryAndUnique(request.ToBeRemovedMandatories, request.ToBeRemovedUniques, myType); CheckToBeAddedIndices(request.ToBeAddedIndices, myType); CheckToBeRemovedIndices(request.ToBeRemovedIndices, myType); }
/// <summary> /// Checks if the to be removed attributes exists on this type /// </summary> /// <param name="myAlterTypeRequest">The request.</param> /// <param name="myType">The type.</param> protected override void CheckToBeRemovedAttributes(IRequestAlterType myAlterTypeRequest, IEdgeType myType) { #region properties var attributesOfCurrentVertexType = myType.GetAttributeDefinitions(false).ToList(); if (myAlterTypeRequest.ToBeRemovedProperties != null) { foreach (var aToBeDeletedAttribute in myAlterTypeRequest.ToBeRemovedProperties) { if (!attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDeletedAttribute)) { throw new AttributeDoesNotExistException(aToBeDeletedAttribute, myType.Name); } } } #endregion }
/// <summary> /// Calls methods to rename attrributes and changing the comment. /// </summary> /// <param name="myAlterTypeRequest">The alter type request.</param> /// <param name="myType">The to be altered type.</param> /// <param name="myTransactionToken">The Int64.</param> /// <param name="mySecurityToken">The SecurityToken.</param> protected void RenamesAndComment(IRequestAlterType myAlterTypeRequest, T myType, Int64 myTransactionToken, SecurityToken mySecurityToken) { RenameAttributes(myAlterTypeRequest.ToBeRenamedProperties, myType, myTransactionToken, mySecurityToken); ChangeCommentOnType(myType, myAlterTypeRequest.AlteredComment, myTransactionToken, mySecurityToken); RenameType(myType, myAlterTypeRequest.AlteredTypeName, myTransactionToken, mySecurityToken); }
/// <summary> /// Calls a Check function foreach IEnumerable of definied attributes. /// </summary> /// <param name="myRequest">The alter type request which contains the attributes.</param> protected override void CheckAttributesNameAndType(IRequestAlterType myRequest) { var request = myRequest as RequestAlterVertexType; CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedProperties); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedUnknownAttributes); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedBinaryProperties); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedIncomingEdges); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedOutgoingEdges); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedMandatories); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedUniques); CheckNameAndTypeOfAttributePredefinitions(request.ToBeAddedIndices); CheckNameOfAttributeList(request.ToBeRemovedProperties); CheckNameOfAttributeList(request.ToBeRemovedUnknownAttributes); CheckNameOfAttributeList(request.ToBeRemovedMandatories); CheckNameOfAttributeList(request.ToBeRemovedUniques); CheckNameOfAttributeList(request.ToBeRemovedBinaryProperties); CheckNameOfAttributeList(request.ToBeRemovedIncomingEdges); CheckNameOfAttributeList(request.ToBeRemovedOutgoingEdges); }
/// <summary> /// Checks if the attributes that should be defined exist in the given type or derived ones. /// </summary> /// <param name="myAlterTypeRequest">The request.</param> /// <param name="myType">The type.</param> protected override void CheckToBeDefinedAttributes(IRequestAlterType myAlterTypeRequest, IVertexType myType) { var request = myAlterTypeRequest as RequestAlterVertexType; foreach (var aVertexType in myType.GetDescendantVertexTypesAndSelf()) { var attributesOfCurrentVertexType = aVertexType.GetAttributeDefinitions(false).ToList(); if (request.ToBeDefinedAttributes != null) { foreach (var aToBeDefinedAttribute in request.ToBeDefinedAttributes) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDefinedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeDefinedAttribute.AttributeName); } } } } }
/// <summary> /// Checks if the to be added attributes exist in the given vertex type or derived oness /// </summary> /// <param name="myAlterVertexTypeRequest"></param> /// <param name="vertexType"></param> protected override void CheckToBeAddedAttributes(IRequestAlterType myAlterTypeRequest, IEdgeType myType) { foreach (var aType in myType.GetDescendantEdgeTypesAndSelf()) { var attributesOfCurrentVertexType = aType.GetAttributeDefinitions(false).ToList(); #region property if (myAlterTypeRequest.ToBeAddedProperties != null) { foreach (var aToBeAddedAttribute in myAlterTypeRequest.ToBeAddedProperties) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new AttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion #region unknown attributes if (myAlterTypeRequest.ToBeAddedUnknownAttributes != null) { foreach (var aToBeAddedAttribute in myAlterTypeRequest.ToBeAddedUnknownAttributes) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new AttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion } }
/// <summary> /// Checks the to be renamed attributes /// </summary> /// <param name="myAlterTypeRequest"></param> /// <param name="myType"></param> protected static void CheckToBeRenamedAttributes(IRequestAlterType myAlterTypeRequest, T myType) { if (myAlterTypeRequest.ToBeRenamedProperties == null) { return; } foreach (var aToBeRenamedAttributes in myAlterTypeRequest.ToBeRenamedProperties) { if (aToBeRenamedAttributes.Key.IsNullOrEmpty()) { throw new EmptyAttributeNameException( "The to be renamed attribute name is null or empty."); } if (aToBeRenamedAttributes.Value.IsNullOrEmpty()) { throw new EmptyAttributeNameException( String.Format("The to be attribute name to which the attribute {0} should be renamed is null or empty.", aToBeRenamedAttributes.Key)); } if (!CheckOldName(aToBeRenamedAttributes.Key, myType)) { throw new AttributeDoesNotExistException( String.Format("It is not possible to rename {0} into {1}. The to be renamed attribute does not exist.", aToBeRenamedAttributes.Key, aToBeRenamedAttributes.Value)); } if (!CheckNewName(aToBeRenamedAttributes.Value, myType)) { throw new AttributeAlreadyExistsException( String.Format("It is not possible to rename {0} into {1}. The new attribute name already exists.", aToBeRenamedAttributes.Key, aToBeRenamedAttributes.Value)); } } }
/// <summary> /// Checks if the given parameter type is valid. /// </summary> /// <param name="myRequest">The parameter to be checked.</param> protected abstract void CheckRequestType(IRequestAlterType myRequest);
public abstract T AlterType(IRequestAlterType myAlterTypeRequest, Int64 myTransactionToken, SecurityToken mySecurityToken, out RequestUpdate myUpdateRequest);
/// <summary> /// Checks the to be removed attributes. /// </summary> /// <param name="myAlterTypeRequest">The alter type request.</param> /// <param name="myType">The type.</param> protected abstract void CheckToBeRemovedAttributes(IRequestAlterType myAlterTypeRequest, T myType);
/// <summary> /// Calls a variable number of check functions. /// </summary> /// <param name="myAlterTypeRequest">The alter type request.</param> /// <param name="myType">The type which is going to be altered.</param> /// <param name="myTransactionToken">Int64</param> /// <param name="mySecurityToken">SecurityToken</param> protected abstract void CallCheckFunctions(IRequestAlterType myAlterTypeRequest, T myType, Int64 myTransactionToken, SecurityToken mySecurityToken);
/// <summary> /// Checks if the to be removed attributes exists on this type. /// </summary> /// <param name="myAlterTypeRequest">The request.</param> /// <param name="myType">The type.</param> protected override void CheckToBeRemovedAttributes(IRequestAlterType myAlterTypeRequest, IVertexType myType) { var request = myAlterTypeRequest as RequestAlterVertexType; #region properties var attributesOfCurrentVertexType = myType.GetAttributeDefinitions(false).ToList(); if (request.ToBeRemovedProperties != null) { foreach (var aToBeDeletedAttribute in request.ToBeRemovedProperties) { if (!attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDeletedAttribute)) { throw new AttributeDoesNotExistException(aToBeDeletedAttribute, myType.Name); } } } #endregion #region binary properties if (request.ToBeRemovedBinaryProperties != null) { foreach (var aToBeDeletedAttribute in request.ToBeRemovedBinaryProperties) { if (!attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDeletedAttribute)) { throw new VertexAttributeIsNotDefinedException(aToBeDeletedAttribute, myType.Name); } } } #endregion #region outgoing Edges if (request.ToBeRemovedOutgoingEdges != null) { foreach (var aToBeDeletedAttribute in request.ToBeRemovedOutgoingEdges) { if (!attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDeletedAttribute)) { throw new VertexAttributeIsNotDefinedException(aToBeDeletedAttribute, myType.Name); } } } #endregion #region incoming edges if (request.ToBeRemovedIncomingEdges != null) { foreach (var aToBeDeletedAttribute in request.ToBeRemovedIncomingEdges) { if (!attributesOfCurrentVertexType.Any(_ => _.Name == aToBeDeletedAttribute)) { throw new VertexAttributeIsNotDefinedException(aToBeDeletedAttribute, myType.Name); } } } #endregion }
/// <summary> /// Checks if the names and types of the attributes are valid. /// </summary> /// <param name="myRequest">The alter type request.</param> protected abstract void CheckAttributesNameAndType(IRequestAlterType myRequest);
/// <summary> /// Checks if the to be added attributes exist in the given type or derived ones. /// </summary> /// <param name="myAlterTypeRequest">The request.</param> /// <param name="myType">The type.</param> protected override void CheckToBeAddedAttributes(IRequestAlterType myAlterTypeRequest, IVertexType myType) { var request = myAlterTypeRequest as RequestAlterVertexType; foreach (var aVertexType in myType.GetDescendantVertexTypesAndSelf()) { var attributesOfCurrentVertexType = aVertexType.GetAttributeDefinitions(false).ToList(); #region binary properties if (request.ToBeAddedBinaryProperties != null) { foreach (var aToBeAddedAttribute in request.ToBeAddedBinaryProperties) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion #region outgoing edges if (request.ToBeAddedOutgoingEdges != null) { foreach (var aToBeAddedAttribute in request.ToBeAddedOutgoingEdges) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion #region Incoming edges if (request.ToBeAddedIncomingEdges != null) { foreach (var aToBeAddedAttribute in request.ToBeAddedIncomingEdges) { var parts = aToBeAddedAttribute.AttributeType.Split(IncomingEdgePredefinition.TypeSeparator); //check if vertex type or outgoing edge name is null or empty if (parts[0].IsNullOrEmpty() || parts[1].IsNullOrEmpty()) { throw new EmptyAttributeTypeException(aToBeAddedAttribute.GetType()); } if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion #region property if (request.ToBeAddedProperties != null) { foreach (var aToBeAddedAttribute in request.ToBeAddedProperties) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion #region unknown attributes if (request.ToBeAddedUnknownAttributes != null) { foreach (var aToBeAddedAttribute in request.ToBeAddedUnknownAttributes) { if (attributesOfCurrentVertexType.Any(_ => _.Name == aToBeAddedAttribute.AttributeName)) { throw new VertexAttributeAlreadyExistsException(aToBeAddedAttribute.AttributeName); } } } #endregion } }
/// <summary> /// All to be added things of the alter type request are going to be added inside this method, /// the related operations will be executed inside here. /// </summary> /// <param name="myAlterTypeRequest">The alter type request.</param> /// <param name="myType">The to be altered type.</param> /// <param name="myTransactionToken">The Int64.</param> /// <param name="myUpdateRequest">A reference to an update request to update relevant vertices.</param> protected abstract void AlterType_Add(IRequestAlterType myAlterTypeRequest, T myType, Int64 myTransactionToken, SecurityToken mySecurityToken, ref RequestUpdate myUpdateRequest);
public override IVertexType AlterType(IRequestAlterType myAlterTypeRequest, Int64 myTransactionToken, SecurityToken mySecurityToken, out RequestUpdate myUpdateRequest) { CheckRequestType(myAlterTypeRequest); RequestAlterVertexType myRequest = myAlterTypeRequest as RequestAlterVertexType; var vertexType = _TypeManager.GetType(myRequest.TypeName, myTransactionToken, mySecurityToken); #region check to be added if (myRequest.ToBeAddedUnknownAttributes != null) { var toBeConverted = myRequest.ToBeAddedUnknownAttributes.ToArray(); foreach (var unknown in toBeConverted) { if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType)) { var prop = ConvertUnknownToBinaryProperty(unknown); myRequest.AddBinaryProperty(prop); } else if (_baseTypeManager.IsBaseType(unknown.AttributeType)) { var prop = ConvertUnknownToProperty(unknown); myRequest.AddProperty(prop); } else if (unknown.AttributeType.Contains(IncomingEdgePredefinition.TypeSeparator)) { var prop = ConvertUnknownToIncomingEdge(unknown); myRequest.AddIncomingEdge(prop); } else { var prop = ConvertUnknownToOutgoingEdge(unknown); myRequest.AddOutgoingEdge(prop); } } myRequest.ResetUnknown(); } #endregion #region check to be removed if (myRequest.ToBeRemovedUnknownAttributes != null) { foreach (var unknownProp in myRequest.ToBeRemovedUnknownAttributes) { var attrDef = vertexType.GetAttributeDefinition(unknownProp); if (attrDef == null) { throw new AttributeDoesNotExistException(unknownProp); } switch (attrDef.Kind) { case AttributeType.Property: myRequest.RemoveProperty(unknownProp); break; case AttributeType.OutgoingEdge: myRequest.RemoveOutgoingEdge(unknownProp); break; case AttributeType.IncomingEdge: myRequest.RemoveIncomingEdge(unknownProp); break; case AttributeType.BinaryProperty: myRequest.RemoveBinaryProperty(unknownProp); break; default: throw new Exception("The enumeration AttributeType was changed, but not this switch statement."); } } myRequest.ClearToBeRemovedUnknownAttributes(); } #endregion #region check attributes to be defined if (myRequest.ToBeDefinedAttributes != null) { foreach (var unknownProp in myRequest.ToBeDefinedAttributes) { var toBeDefined = myRequest.ToBeDefinedAttributes.ToArray(); foreach (var unknown in toBeDefined) { if (BinaryPropertyPredefinition.TypeName.Equals(unknown.AttributeType)) { throw new InvalidDefineAttributeTypeException(BinaryPropertyPredefinition.TypeName, vertexType.Name); } else if (unknown.AttributeType.Contains(IncomingEdgePredefinition.TypeSeparator)) { throw new InvalidDefineAttributeTypeException("incoming edge", vertexType.Name); } else if (!_baseTypeManager.IsBaseType(unknown.AttributeType)) { throw new InvalidDefineAttributeTypeException("user defined", vertexType.Name); } } } } #endregion #region check attributes to be undefined if (myRequest.ToBeUndefinedAttributes != null) { foreach (var attr in myRequest.ToBeUndefinedAttributes) { var attrDef = vertexType.GetAttributeDefinition(attr); if (attrDef == null) { throw new AttributeDoesNotExistException(attr); } switch (attrDef.Kind) { case AttributeType.Property: break; case AttributeType.OutgoingEdge: throw new InvalidUndefineAttributeTypeException("Outgoing Edge", vertexType.Name); case AttributeType.IncomingEdge: throw new InvalidUndefineAttributeTypeException("Incoming Edge", vertexType.Name); case AttributeType.BinaryProperty: throw new InvalidUndefineAttributeTypeException(BinaryPropertyPredefinition.TypeName, vertexType.Name); default: throw new Exception("The enumeration AttributeType was changed, but not this switch statement."); } } } #endregion #region checks CallCheckFunctions(myAlterTypeRequest, vertexType, myTransactionToken, mySecurityToken); #endregion myUpdateRequest = new RequestUpdate(); return(null); }