예제 #1
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClassNode node = e.ModelElement as ShapeClassNode;

            if (node != null)
            {
                if (node.ShapeClass != null)
                {
                    node.ShapeClass.DomainClass = null;
                }
            }
        }
        /// <summary>
        /// This method is called when the rule is fired, that is when a compartment entry is deleting from the model.
        /// </summary>
        /// <param name="e">the ElementDeletingEventArgs</param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            // it is not easy to find the compartment parent of a compartment entry
            if (e.ModelElement != null)
            {
                foreach (ElementLink link in DomainRoleInfo.GetAllElementLinks(e.ModelElement))
                {
                    // I have to find the ElementLink where the compartment entry is the target
                    if (DomainRoleInfo.GetTargetRolePlayer(link) == e.ModelElement)
                    {
                        // and check if this ElementLink is annotated with the DomainRelationshipAttribute
                        object[] attrs = link.GetType().GetCustomAttributes(typeof(DomainRelationshipAttribute), true);
                        if (attrs.Length > 0)
                        {
                            DomainRelationshipAttribute attr = attrs[0] as DomainRelationshipAttribute;
                            if (attr != null)
                            {
                                // and only if the DomainRelationshipAttribute is set to IsEmbedding == true
                                if (attr.IsEmbedding)  // follow only embedded links - there is only one embedded link with a concret class (the child) as target
                                {
                                    // finally we found the parent of the compartment entry
                                    ModelElement parent = DomainRoleInfo.GetSourceRolePlayer(link);

                                    // check all links from parent if anyone uses this child as source or target
                                    DeleteReferencesFromParentToChild(parent, e.ModelElement);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            ModelClass  element = (ModelClass)e.ModelElement;
            Store       store   = element.Store;
            Transaction current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing)
            {
                return;
            }

            List <Generalization> generalizations = store.ElementDirectory.AllElements.OfType <Generalization>().Where(g => g.Superclass == element).ToList();

            if (generalizations.Any())
            {
                string question = generalizations.Count == 1
                                 ? $"Push {element.Name} attributes and associations down its to its subclass?"
                                 : $"Push {element.Name} attributes and associations down its to {generalizations.Count} subclasses?";

                if (QuestionDisplay.Show(question) == true)
                {
                    foreach (ModelClass subclass in generalizations.Select(g => g.Subclass))
                    {
                        element.PushDown(subclass);
                    }
                }
            }
        }
예제 #4
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            ModelClass  element = (ModelClass)e.ModelElement;
            Store       store   = element.Store;
            Transaction current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing || ModelRoot.BatchUpdating)
            {
                return;
            }

            foreach (ModelAttribute attribute in element.Attributes)
            {
                attribute.SetLocks(Locks.None);
            }

            List <Generalization> generalizations = store.GetAll <Generalization>().Where(g => g.Superclass == element).ToList();

            if (generalizations.Any())
            {
                string question = generalizations.Count == 1
                                 ? $"Push {element.Name} attributes and associations down its to its subclass?"
                                 : $"Push {element.Name} attributes and associations down its to {generalizations.Count} subclasses?";

                if (BooleanQuestionDisplay.Show(store, question) == true)
                {
                    foreach (ModelClass subclass in generalizations.Select(g => g.Subclass))
                    {
                        element.MoveContents(subclass);
                    }
                }
            }
        }
예제 #5
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClass shapeClass = e.ModelElement as ShapeClass;

            if (shapeClass != null)
            {
                for (int i = shapeClass.Children.Count - 1; i >= 0; i--)
                {
                    shapeClass.Children[i].Delete();
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ReferenceRSNodeReferencesShapeRelationshipNodes con = e.ModelElement as ReferenceRSNodeReferencesShapeRelationshipNodes;

            if (con != null)
            {
                if (con.ShapeRelationshipNode != null)
                {
                    con.ShapeRelationshipNode.Delete();
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DomainClass domainClass = e.ModelElement as DomainClass;
            if (domainClass != null)
            {
                for (int i = domainClass.DomainModelTreeNodes.Count - 1; i >= 0; i--)
                    if (i < domainClass.DomainModelTreeNodes.Count)
                        domainClass.DomainModelTreeNodes[i].Delete();
            }

            List<DomainRole> roles = new List<DomainRole>();
            foreach (DomainRole role in domainClass.RolesPlayed)
                roles.Add(role);

            for (int i = roles.Count - 1; i >= 0; i--)
                if (roles[i] != null)
                    if (roles[i].Relationship != null)
                        roles[i].Relationship.Delete();
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship;
            if (con != null)
                if (con.DomainRelationship is ReferenceRelationship)
                {
                    RelationshipShapeClass shape = con.RelationshipShapeClass;
                    ShapeRelationshipNode node = shape.ShapeRelationshipNode;
                    if (node != null)
                    {

                        // delete
                        ReferenceRelationship rel = con.DomainRelationship as ReferenceRelationship;
                        ReferenceRSNode n = rel.ReferenceRSNode;
                        if (n != null)
                        {
                            if (n.ShapeRelationshipNodes.Contains(node))
                                n.ShapeRelationshipNodes.Remove(node);
                        }
                        node.Delete();
                    }
                }
        }
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            DomainModelElement modelElement = e.ModelElement as DomainModelElement;
            if (modelElement == null)
                return;

            
            List<Guid> shapes = GraphicalDependencyShapeStore.GetFromStore(modelElement.Id);
            if (shapes != null)
            {
                modelElement.Store.UndoManager.UndoState = UndoState.DisabledNoFlush;
                using (Transaction t = modelElement.Store.TransactionManager.BeginTransaction("", true))
                {

                    for (int i = shapes.Count - 1; i >= 0; i--)
                    {
                        ShapeElement shape = modelElement.Store.ElementDirectory.FindElement(shapes[i]) as ShapeElement;
                        if (shape != null)
                            shape.Delete();
                    }
                    t.Commit();
                }
                modelElement.Store.UndoManager.UndoState = UndoState.Enabled;
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            LibraryModelContext libraryModelContext = e.ModelElement as LibraryModelContext;

            if (libraryModelContext != null)
            {
                if (libraryModelContext.ViewContext != null)
                {
                    libraryModelContext.ViewContext.Delete();
                }
            }
        }
예제 #11
0
        /// <summary>
        /// DeletingRule: typeof(UniquenessConstraintIncludesColumn)
        /// If a uniqueness constraint column is being removed, then remove the corresponding column
        /// in any reference constraints that target the columns in the uniqueness constraint.
        /// </summary>
        private static void UniquenessConstraintColumnDeleting(ElementDeletingEventArgs e)
        {
            UniquenessConstraintIncludesColumn link   = (UniquenessConstraintIncludesColumn)e.ModelElement;
            UniquenessConstraint uniquenessConstraint = link.UniquenessConstraint;

            if (!uniquenessConstraint.IsDeleting)
            {
                bool haveIndex = false;
                int  index     = -1;
                foreach (ReferenceConstraint referenceConstraint in uniquenessConstraint.ReferenceConstraintCollection)
                {
                    if (!haveIndex)
                    {
                        haveIndex = true;
                        index     = UniquenessConstraintIncludesColumn.GetLinksToColumnCollection(uniquenessConstraint).IndexOf(link);
                    }
                    LinkedElementCollection <ColumnReference> columnRefs = referenceConstraint.ColumnReferenceCollection;
                    if (index < columnRefs.Count && columnRefs[index].TargetColumn == link.Column)                     // Sanity check
                    {
                        columnRefs.RemoveAt(index);
                    }
                    else
                    {
                        // Something is off, delay validate this later
                        ReferenceConstraintTargetsTable tableLink = ReferenceConstraintTargetsTable.GetLinkToTargetTable(referenceConstraint);
                        if (tableLink != null)
                        {
                            FrameworkDomainModel.DelayValidateElement(tableLink, DelayValidateTargetUniquenessConstraint);
                        }
                    }
                }
            }
        }
        /// <inheritdoc />
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            Generalization element = (Generalization)e.ModelElement;
            Store          store   = element.Store;
            Transaction    current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing)
            {
                return;
            }

            if (element.Superclass.IsDeleting)
            {
                return;
            }

            ModelClass         superclass   = element.Superclass;
            ModelClass         subclass     = element.Subclass;
            List <Association> associations = store.ElementDirectory.AllElements.OfType <Association>().Where(a => a.Source == superclass || a.Target == superclass).ToList();

            if (!superclass.AllAttributes.Any() && !associations.Any())
            {
                return;
            }

            if (!subclass.IsDeleting && QuestionDisplay.Show($"Push {superclass.Name} attributes and associations down to {subclass.Name}?") == true)
            {
                superclass.PushDown(subclass);
            }
        }
        /// <inheritdoc />
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            ModelDiagramData element = (ModelDiagramData)e.ModelElement;
            Store            store   = element.Store;
            Transaction      current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing || ModelRoot.BatchUpdating)
            {
                return;
            }

            if (BooleanQuestionDisplay.Show($"About to permanently delete diagram named {element.Name} - are you sure?") != true)
            {
                current.Rollback();

                return;
            }

            EFModelDiagram diagram = element.GetDiagram();

            ModelDiagramData.CloseDiagram?.Invoke(diagram);
            diagram.Delete();
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            TreeNodeReferencesReferenceRSNodes con = e.ModelElement as TreeNodeReferencesReferenceRSNodes;
            if (con != null)
            {
                ReferenceRSNode rsNode = con.ReferenceRSNode;
                if (rsNode != null)
                {
                    ReferenceNode node = rsNode.ReferenceNode;
                    if (node != null)
                    {
                        // since this node still exists, it isnt included in the deletion process
                        // --> move to root node if this node is the element holder, as its parent has been deleted
                        if (node.IsElementHolder)
                        {
                            RootNode rootNode = new RootNode(node.Store);
                            rootNode.DomainElement = node.DomainElement;

                            node.EmbeddingModelTreeViewModel.RootNodes.Add(rootNode);
                            node.EmbeddingModelTreeViewModel.ModelTreeNodes.Add(rootNode);

                            // copy sub tree
                            for (int i = node.EmbeddingRSNodes.Count - 1; i >= 0; i--)
                                node.EmbeddingRSNodes[i].TreeNode = rootNode;

                            for (int i = node.ReferenceRSNodes.Count - 1; i >= 0; i--)
                                node.ReferenceRSNodes[i].TreeNode = rootNode;

                            for (int i = node.InheritanceNodes.Count - 1; i >= 0; i--)
                                node.InheritanceNodes[i].TreeNode = rootNode;

                            for (int i = node.ShapeClassNodes.Count - 1; i >= 0; i--)
                                node.ShapeClassNodes[i].TreeNode = rootNode;

                            rootNode.IsElementHolder = true;
                            rootNode.IsEmbeddingTreeExpanded = node.IsEmbeddingTreeExpanded;
                            rootNode.IsExpanded = true;
                            rootNode.IsInheritanceTreeExpanded = node.IsInheritanceTreeExpanded;
                            rootNode.IsReferenceTreeExpanded = node.IsReferenceTreeExpanded;
                            rootNode.IsShapeMappingTreeExpanded = node.IsShapeMappingTreeExpanded;
                        }

                        node.Delete();
                    }

                    rsNode.Delete();
                }
            }
        }
예제 #15
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DiagramClassViewReferencesDiagramClass con = e.ModelElement as DiagramClassViewReferencesDiagramClass;

            if (con != null)
            {
                if (con.DiagramClassView != null)
                {
                    con.DiagramClassView.Delete();
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            DomainModelElement modelElement = e.ModelElement as DomainModelElement;

            if (modelElement == null)
            {
                return;
            }


            List <Guid> shapes = GraphicalDependencyShapeStore.GetFromStore(modelElement.Id);

            if (shapes != null)
            {
                modelElement.Store.UndoManager.UndoState = UndoState.DisabledNoFlush;
                using (Transaction t = modelElement.Store.TransactionManager.BeginTransaction("", true))
                {
                    for (int i = shapes.Count - 1; i >= 0; i--)
                    {
                        ShapeElement shape = modelElement.Store.ElementDirectory.FindElement(shapes[i]) as ShapeElement;
                        if (shape != null)
                        {
                            shape.Delete();
                        }
                    }
                    t.Commit();
                }
                modelElement.Store.UndoManager.UndoState = UndoState.Enabled;
            }
        }
예제 #17
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            Association element = (Association)e.ModelElement;
            Store       store   = element.Store;
            Transaction current = store.TransactionManager.CurrentTransaction;

            if (current.IsSerializing || ModelRoot.BatchUpdating)
            {
                return;
            }

            List <ModelAttribute> unnecessaryProperties = element.Dependent?.AllAttributes?.Where(x => x.IsForeignKeyFor == element.Id && !x.IsIdentity).ToList();

            if (unnecessaryProperties?.Any() != true)
            {
                WarningDisplay.Show($"{element.GetDisplayText()} doesn't specify defined foreign keys. Removing foreign key attribute(s) {string.Join(", ", unnecessaryProperties.Select(x => x.GetDisplayText()))}");

                foreach (ModelAttribute fkProperty in unnecessaryProperties)
                {
                    fkProperty.ClearFKMods();
                    fkProperty.ModelClass.Attributes.Remove(fkProperty);
                    fkProperty.Delete();
                }
            }
        }
예제 #18
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            NodeShape nodeShape = e.ModelElement as NodeShape;

            if (nodeShape != null)
            {
                if (nodeShape.SourceAnchors.Count > 0)
                {
                    for (int i = nodeShape.SourceAnchors.Count - 1; i >= 0; i--)
                    {
                        if (nodeShape.SourceAnchors[i].LinkShape != null)
                        {
                            nodeShape.SourceAnchors[i].LinkShape.Delete();
                        }
                    }
                }

                if (nodeShape.TargetAnchors.Count > 0)
                {
                    for (int i = nodeShape.TargetAnchors.Count - 1; i >= 0; i--)
                    {
                        if (nodeShape.TargetAnchors[i].LinkShape != null)
                        {
                            nodeShape.TargetAnchors[i].LinkShape.Delete();
                        }
                    }
                }
            }
        }
예제 #19
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainClass domainClass = e.ModelElement as DomainClass;

            if (domainClass != null)
            {
                if (domainClass.SerializedDomainClass != null)
                {
                    domainClass.SerializedDomainClass.Delete();
                }
            }
        }
예제 #20
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainProperty domainProperty = e.ModelElement as DomainProperty;

            if (domainProperty != null)
            {
                AttributedDomainElement element = domainProperty.Element;
                domainProperty.Element = null;

                // update properties
                SerializationHelper.UpdateDerivedElementsSerializationProperties(element);
            }
        }
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            DomainModelElement modelElement = e.ModelElement as DomainModelElement;
            deletionHelper.DeleteShapesForElement(modelElement);
        }
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            if (e.ModelElement is DomainModelLink)
                deletionHelper.DeleteShapesForElement(e.ModelElement as DomainModelLink);
            
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement.Store.InSerializationTransaction)
                return;

            PersonShape shape = e.ModelElement as PersonShape;
            DiagramLayouter.Layout(shape.Diagram);
        }
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            DomainModelElement modelElement = e.ModelElement as DomainModelElement;

            deletionHelper.DeleteShapesForElement(modelElement);
        }
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            if (e.ModelElement is DomainModelLink)
            {
                deletionHelper.DeleteShapesForElement(e.ModelElement as DomainModelLink);
            }
        }
예제 #26
0
        /// <summary>
        /// DeletingRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ModelHasError)
        /// </summary>
        private static void ModelErrorDeletingRule(ElementDeletingEventArgs e)
        {
            ModelHasError link = e.ModelElement as ModelHasError;

            if (!link.Model.IsDeleting)
            {
                ProcessModelErrorChange(link);
            }
        }
예제 #27
0
		/// <summary>
		/// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMAbstractionToConceptualDatabaseBridge.TableIsPrimarilyForConceptType)
		/// Cache the position of the <see cref="TableShape"/> corresponding to the object type being deleted
		/// </summary>
		private static void ConceptTypeDetachingFromTableRule(ElementDeletingEventArgs e)
		{
			TableIsPrimarilyForConceptType link = (TableIsPrimarilyForConceptType)e.ModelElement;
			ObjectType objectType;
			if (null != (objectType = ConceptTypeIsForObjectType.GetObjectType(link.ConceptType)) &&
				!objectType.IsDeleting)
			{
				RememberTableShapeLocations(objectType, link.Table);
			}
		}
예제 #28
0
		/// <summary>
		/// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMToORMAbstractionBridge.ConceptTypeIsForObjectType)
		/// Cache the position of the <see cref="BarkerEntityShape"/> corresponding to the object type being deleted
		/// </summary>
		private static void ConceptTypeDetachingFromObjectTypeRule(ElementDeletingEventArgs e)
		{
			ConceptTypeIsForObjectType link = (ConceptTypeIsForObjectType)e.ModelElement;
			ObjectType objectType = link.ObjectType;
			EntityType barkerEntity;
			if (!objectType.IsDeleting &&
				null != (barkerEntity = EntityTypeIsPrimarilyForConceptType.GetEntityType(link.ConceptType)))
			{
				RememberBarkerEntityShapeLocations(objectType, barkerEntity);
			}
		}
예제 #29
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainClass domainClass = e.ModelElement as DomainClass;

            if (domainClass != null)
            {
                for (int i = domainClass.DomainModelTreeNodes.Count - 1; i >= 0; i--)
                {
                    if (i < domainClass.DomainModelTreeNodes.Count)
                    {
                        domainClass.DomainModelTreeNodes[i].Delete();
                    }
                }
            }

            List <DomainRole> roles = new List <DomainRole>();

            foreach (DomainRole role in domainClass.RolesPlayed)
            {
                roles.Add(role);
            }

            for (int i = roles.Count - 1; i >= 0; i--)
            {
                if (roles[i] != null)
                {
                    if (roles[i].Relationship != null)
                    {
                        roles[i].Relationship.Delete();
                    }
                }
            }
        }
예제 #30
0
        /// <summary>
        /// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMAbstractionToBarkerERBridge.EntityTypeIsPrimarilyForConceptType)
        /// Cache the position of the <see cref="BarkerEntityShape"/> corresponding to the object type being deleted
        /// </summary>
        private static void ConceptTypeDetachingFromEntityTypeRule(ElementDeletingEventArgs e)
        {
            EntityTypeIsPrimarilyForConceptType link = (EntityTypeIsPrimarilyForConceptType)e.ModelElement;
            ObjectType objectType;

            if (null != (objectType = ConceptTypeIsForObjectType.GetObjectType(link.ConceptType)) &&
                !objectType.IsDeleting)
            {
                RememberBarkerEntityShapeLocations(objectType, link.EntityType);
            }
        }
예제 #31
0
		/// <summary>
		/// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMToORMAbstractionBridge.ConceptTypeIsForObjectType)
		/// Cache the position of the <see cref="TableShape"/> corresponding to the object type being deleted
		/// </summary>
		private static void ConceptTypeDetachingFromObjectTypeRule(ElementDeletingEventArgs e)
		{
			ConceptTypeIsForObjectType link = (ConceptTypeIsForObjectType)e.ModelElement;
			ObjectType objectType = link.ObjectType;
			Table table;
			if (!objectType.IsDeleting &&
				null != (table = TableIsPrimarilyForConceptType.GetTable(link.ConceptType)))
			{
				RememberTableShapeLocations(objectType, table);
			}
		}
예제 #32
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement.Store.InSerializationTransaction)
            {
                return;
            }

            PersonShape shape = e.ModelElement as PersonShape;

            DiagramLayouter.Layout(shape.Diagram);
        }
예제 #33
0
        /// <summary>
        /// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMToORMAbstractionBridge.ConceptTypeIsForObjectType)
        /// Cache the position of the <see cref="BarkerEntityShape"/> corresponding to the object type being deleted
        /// </summary>
        private static void ConceptTypeDetachingFromObjectTypeRule(ElementDeletingEventArgs e)
        {
            ConceptTypeIsForObjectType link = (ConceptTypeIsForObjectType)e.ModelElement;
            ObjectType objectType           = link.ObjectType;
            EntityType barkerEntity;

            if (!objectType.IsDeleting &&
                null != (barkerEntity = EntityTypeIsPrimarilyForConceptType.GetEntityType(link.ConceptType)))
            {
                RememberBarkerEntityShapeLocations(objectType, barkerEntity);
            }
        }
예제 #34
0
        /// <summary>
        /// DeletingRule: typeof(ReadingOrderHasRole)
        /// Handles the clean up of the readings that the role is involved in by replacing
        /// the place holder with the text DELETED
        /// </summary>
        private static void ReadingOrderHasRoleDeletingRule(ElementDeletingEventArgs e)
        {
            ReadingOrderHasRole link             = e.ModelElement as ReadingOrderHasRole;
            RoleBase            linkRole         = link.Role;
            ReadingOrder        linkReadingOrder = link.ReadingOrder;

            if (linkReadingOrder.IsDeleting || linkReadingOrder.IsDeleted)
            {
                // Don't validate if we're removing the reading order
                return;
            }
            FactType factType = linkReadingOrder.FactType;

            if (factType != null)
            {
                FrameworkDomainModel.DelayValidateElement(factType, DelayValidateReadingOrderCollation);
            }

            int pos = linkReadingOrder.RoleCollection.IndexOf(linkRole);

            if (pos >= 0)
            {
                bool isUnaryFactType = factType.UnaryRole != null;
                LinkedElementCollection <Reading> readings = linkReadingOrder.ReadingCollection;
                int numReadings = readings.Count;
                int roleCount   = linkReadingOrder.RoleCollection.Count;
                for (int iReading = 0; iReading < numReadings; ++iReading)
                {
                    Reading linkReading = readings[iReading];
                    if (!linkReading.IsDeleting)
                    {
                        Debug.Assert(!linkReading.IsDeleted);
                        string          text           = linkReading.Text;
                        IFormatProvider formatProvider = CultureInfo.InvariantCulture;
                        linkReading.SetAutoText(Reading.ReplaceFields(
                                                    linkReading.Text,
                                                    delegate(int replaceIndex)
                        {
                            if (replaceIndex == pos)
                            {
                                return(isUnaryFactType ? "" : ResourceStrings.ModelReadingRoleDeletedRoleText);
                            }
                            else if (replaceIndex > pos)
                            {
                                return("{" + (replaceIndex - 1).ToString(formatProvider) + "}");
                            }
                            return(null);
                        }
                                                    ));
                    }
                }
            }
        }
예제 #35
0
        /// <summary>
        /// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMToORMAbstractionBridge.ConceptTypeIsForObjectType)
        /// Cache the position of the <see cref="TableShape"/> corresponding to the object type being deleted
        /// </summary>
        private static void ConceptTypeDetachingFromObjectTypeRule(ElementDeletingEventArgs e)
        {
            ConceptTypeIsForObjectType link = (ConceptTypeIsForObjectType)e.ModelElement;
            ObjectType objectType           = link.ObjectType;
            Table      table;

            if (!objectType.IsDeleting &&
                null != (table = TableIsPrimarilyForConceptType.GetTable(link.ConceptType)))
            {
                RememberTableShapeLocations(objectType, table);
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClassReferencesDomainClass shapeCon = e.ModelElement as ShapeClassReferencesDomainClass;

            if (shapeCon != null)
            {
                PresentationDomainClassElement shapeClass = shapeCon.ShapeClass;
                ShapeClassNode node = shapeClass.ShapeClassNode;

                if (node != null)
                {
                    // delete
                    DomainClass domainClass = shapeCon.DomainClass;
                    foreach (TreeNode n in domainClass.DomainModelTreeNodes)
                    {
                        if (n.IsElementHolder)
                        {
                            if (n.ShapeClassNodes.Contains(node))
                            {
                                n.ShapeClassNodes.Remove(node);
                            }
                            break;
                        }
                    }

                    node.Delete();
                }
            }
        }
예제 #37
0
        /// <summary>
        /// DeletingRule: typeof(FrequencyConstraintShape)
        /// If the FrequencyConstraintShape is being deleted as a result of conversion to a uniqueness constraint
        /// </summary>
        private static void FrequencyConstraintConversionDeletingRule(ElementDeletingEventArgs e)
        {
            FrequencyConstraintShape     shape;
            UniquenessConstraint         convertingTo;
            IDictionary <object, object> contextInfo;

            if (e.ChangeSource == ChangeSource.Propagate &&
                (contextInfo = (shape = (FrequencyConstraintShape)e.ModelElement).Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo).ContainsKey(FrequencyConstraint.ConvertingToUniquenessConstraintKey) &&
                !(convertingTo = (UniquenessConstraint)contextInfo[FrequencyConstraint.ConvertingToUniquenessConstraintKey]).IsInternal &&
                shape.ModelElement == contextInfo[FrequencyConstraint.ConvertingFromFrequencyConstraintKey])
            {
                ((ORMDiagram)shape.Diagram).PlaceORMElementOnDiagram(null, convertingTo, shape.Location, ORMPlacementOption.AllowMultipleShapes, null, null);
            }
        }
예제 #38
0
            /// <summary>
            /// DeletingRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ConstraintRoleSequenceHasRole)
            /// Propagate role deletion in a uniqueness constraint to an absorbed uniqueness
            /// </summary>
            private static void UniquenessConstraintRoleDeleting(ElementDeletingEventArgs e)
            {
                UniquenessConstraint          constraint;
                Uniqueness                    uniqueness;
                ConstraintRoleSequenceHasRole link     = (ConstraintRoleSequenceHasRole)e.ModelElement;
                ConstraintRoleSequence        sequence = link.ConstraintRoleSequence;

                if (!sequence.IsDeleting &&
                    null != (constraint = sequence as UniquenessConstraint) &&
                    !link.Role.IsDeleting &&
                    null != (uniqueness = UniquenessIsForUniquenessConstraint.GetUniqueness(constraint)))
                {
                    uniqueness.ConceptTypeChildCollection.RemoveAt(ConstraintRoleSequenceHasRole.GetLinksToRoleCollection(sequence).IndexOf(link));
                }
            }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship;

            if (con != null)
            {
                if (con.DomainRelationship is ReferenceRelationship)
                {
                    RelationshipShapeClass shape = con.RelationshipShapeClass;
                    ShapeRelationshipNode  node  = shape.ShapeRelationshipNode;
                    if (node != null)
                    {
                        // delete
                        ReferenceRelationship rel = con.DomainRelationship as ReferenceRelationship;
                        ReferenceRSNode       n   = rel.ReferenceRSNode;
                        if (n != null)
                        {
                            if (n.ShapeRelationshipNodes.Contains(node))
                            {
                                n.ShapeRelationshipNodes.Remove(node);
                            }
                        }
                        node.Delete();
                    }
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement.Store.InSerializationTransaction)
                return;

            if (e.ModelElement is MarriedToShape)
            {
                MarriedToShape shape = e.ModelElement as MarriedToShape;
                DiagramLayouter.Layout(shape.Diagram);
            }
            else
            {
                ParentOfShape shape = e.ModelElement as ParentOfShape;
                DiagramLayouter.Layout(shape.Diagram);
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            ModelProperty property = e.ModelElement as ModelProperty;
            // TODO: Add nested support
            if (property != null && property.ModelClass != null)
            {
                Transaction transaction = property.Store.TransactionManager.CurrentTransaction.TopLevelTransaction;

                if (transaction != null && !transaction.IsSerializing && !transaction.Context.ContextInfo.ContainsKey(property.Name))
                    // We're adding the model element to the context so property deleted event wil use it to fire the ondeleted event
                    // on the Model class
                    transaction.Context.ContextInfo.Add(property.Name, property.ModelClass.Model);
            }
        }
 public override void ElementDeleting(ElementDeletingEventArgs e)
 {
     ReferenceDataType rdt = e.ModelElement as ReferenceDataType;
     if (rdt != null && rdt.DataContract != null)
     {
         // If this is the last element in DataMembers, restore the dash style to solid 
         if (rdt.DataContract.DataMembers.FindAll(m => { return (m is ReferenceDataType); }).Count == 1)
         {
             DataContractCompartmentShape shape = DomainModelHelper.GetShapeFromElement<DataContractCompartmentShape>(rdt.DataContract);
             if (shape != null)
             {
                 shape.OutlineDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                 shape.OutlineThickness = 0.0125f;
             }
         }
     }
 }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            LibraryModelContext libraryModelContext = e.ModelElement as LibraryModelContext;
            if (libraryModelContext != null)
                if (libraryModelContext.ViewContext != null)
                    libraryModelContext.ViewContext.Delete();
        }
예제 #44
0
            /// <summary>
            /// DeletingRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ModelContainsRecognizedPhrase)
            /// Regenerate names when a recognized phrase with relational-targeted aliases is deleting
            /// </summary>
            private static void RecognizedPhraseDeletingRule(ElementDeletingEventArgs e)
            {
                ORMCore.ModelContainsRecognizedPhrase link = (ORMCore.ModelContainsRecognizedPhrase)e.ModelElement;
                Store           store          = link.Store;
                DomainClassInfo relationalInfo = store.DomainDataDirectory.GetDomainClass(RelationalNameGenerator.DomainClassId);

                foreach (ORMCore.NameAlias alias in link.RecognizedPhrase.AbbreviationCollection)
                {
                    if (relationalInfo.IsDerivedFrom(alias.NameConsumerDomainClass))
                    {
                        foreach (Schema schema in store.ElementDirectory.FindElements <Schema>(true))
                        {
                            ValidateSchemaNamesChanged(schema);
                        }
                        break;
                    }
                }
            }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ShapeClass shapeClass = e.ModelElement as ShapeClass;
            if (shapeClass != null)
            {
                for (int i = shapeClass.Children.Count - 1; i >= 0; i--)
                    shapeClass.Children[i].Delete();
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DiagramClassViewReferencesDiagramClass con = e.ModelElement as DiagramClassViewReferencesDiagramClass;
            if (con != null)
            {
                if (con.DiagramClassView != null)
                    con.DiagramClassView.Delete();
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ShapeClassNode node = e.ModelElement as ShapeClassNode;
            if (node != null)
            {
                if (node.ShapeClass != null)
                    node.ShapeClass.DomainClass = null;
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DomainClass domainClass = e.ModelElement as DomainClass;
            if (domainClass != null)
            {
                if (domainClass.SerializedDomainClass != null)
                    domainClass.SerializedDomainClass.Delete();
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ReferenceRSNodeReferencesShapeRelationshipNodes con = e.ModelElement as ReferenceRSNodeReferencesShapeRelationshipNodes;
            if (con != null)
            {
                if (con.ShapeRelationshipNode != null)
                    con.ShapeRelationshipNode.Delete();
            }
        }
        /// <summary>
        /// Handles the element deleting rule
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            Guard.NotNull(() => e, e);

            base.ElementDeleting(e);

            var deletingCommand = e.ModelElement as CommandSettings;
            if (deletingCommand != null && deletingCommand.Extends != null)
            {
                // Find all aggregator commands on same element as the command being deleted
                var element = deletingCommand.Owner;
                var aggregatorCommands = element.AutomationSettings
                        .Select(s => s.As<ICommandSettings>())
                        .Where(s => s != null && s.TypeId == typeof(AggregatorCommand).FullName && s.Id != deletingCommand.Id);
                if (aggregatorCommands.Any())
                {
                    // Update references for each aggregator command
                    aggregatorCommands.ForEach(cmdSettings =>
                        {
                            // Get the referenced aggregated commands
                            var property = TypeDescriptor.GetProperties(cmdSettings).Cast<PropertyDescriptor>()
                                .FirstOrDefault(p => p.Name == Reflector<AggregatorCommand>.GetPropertyName(x => x.CommandReferenceList));
                            if (property != null)
                            {
                                var references = DesignCollectionPropertyDescriptor<CommandSettings>.FromObjectToCollection<CommandReference>(property.GetValue(cmdSettings));
                                if (references != null)
                                {
                                    // Remove reference if references the command being deleted.
                                    var referenceToRemove = references.FirstOrDefault(r => r.CommandId == deletingCommand.Id);
                                    if (referenceToRemove != null)
                                    {
                                        references.Remove(referenceToRemove);
                                        property.SetValue(cmdSettings, DesignCollectionPropertyDescriptor<CommandSettings>.ToObjectCollection<CommandReference>(references));
                                    }
                                }
                            }
                        });
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            NodeShape nodeShape = e.ModelElement as NodeShape;
            if (nodeShape != null)
            {
                if (nodeShape.SourceAnchors.Count > 0)
                {
                    for (int i = nodeShape.SourceAnchors.Count - 1; i >= 0; i--)
                        if( nodeShape.SourceAnchors[i].LinkShape != null )
                            nodeShape.SourceAnchors[i].LinkShape.Delete();
                }

                if (nodeShape.TargetAnchors.Count > 0)
                {
                    for (int i = nodeShape.TargetAnchors.Count - 1; i >= 0; i--)
                        if (nodeShape.TargetAnchors[i].LinkShape != null)
                            nodeShape.TargetAnchors[i].LinkShape.Delete();
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ShapeClassReferencesDomainClass shapeCon = e.ModelElement as ShapeClassReferencesDomainClass;
            if (shapeCon != null)
            {
                PresentationDomainClassElement shapeClass = shapeCon.ShapeClass;
                ShapeClassNode node = shapeClass.ShapeClassNode;

                if (node != null)
                {
                    // delete
                    DomainClass domainClass = shapeCon.DomainClass;
                    foreach (TreeNode n in domainClass.DomainModelTreeNodes)
                    {
                        if (n.IsElementHolder)
                        {

                            if (n.ShapeClassNodes.Contains(node))
                                n.ShapeClassNodes.Remove(node);
                            break;
                        }
                    }

                    node.Delete();
                }
            }
        } 
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DomainProperty domainProperty = e.ModelElement as DomainProperty;
            if (domainProperty != null)
            {
                AttributedDomainElement element = domainProperty.Element;
                domainProperty.Element = null;

                // update properties
                SerializationHelper.UpdateDerivedElementsSerializationProperties(element);
            }
        }
예제 #54
0
		/// <summary>
		/// DeletingRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ModelHasError)
		/// </summary>
		private static void ModelErrorDeletingRule(ElementDeletingEventArgs e)
		{
			ModelHasError link = e.ModelElement as ModelHasError;
			if (!link.Model.IsDeleting)
			{
				ProcessModelErrorChange(link);
			}
		}
예제 #55
0
			/// <summary>
			/// DeletingRule: typeof(FactTypeHasRole)
			/// </summary>
			private static void FactTypeHasRoleDeletingRule(ElementDeletingEventArgs e)
			{
				FactType factType = (e.ModelElement as FactTypeHasRole).FactType;
				if (!factType.IsDeleting)
				{
					LinkedElementCollection<RoleBase> factRoles = factType.RoleCollection;
					int? unaryIndex = GetUnaryRoleIndex(factRoles);
					Role implicitRole;
					ObjectType implicitRolePlayer;
					if (unaryIndex.HasValue &&
						null != (implicitRole = factRoles[(unaryIndex.Value == 0) ? 1 : 0].Role) &&
						null != (implicitRolePlayer = implicitRole.RolePlayer))
					{
						// Delete the Implicit Boolean ValueType
						implicitRole.Delete();
						// Delete the Unary FactType
						factType.Delete();
					}
				}
			}
예제 #56
0
			/// <summary>
			/// DeletingRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ModelContainsRecognizedPhrase)
			/// Regenerate names when a recognized phrase with relational-targeted aliases is deleting
			/// </summary>
			private static void RecognizedPhraseDeletingRule(ElementDeletingEventArgs e)
			{
				ORMCore.ModelContainsRecognizedPhrase link = (ORMCore.ModelContainsRecognizedPhrase)e.ModelElement;
				Store store = link.Store;
				DomainClassInfo relationalInfo = store.DomainDataDirectory.GetDomainClass(RelationalNameGenerator.DomainClassId);
				foreach (ORMCore.NameAlias alias in link.RecognizedPhrase.AbbreviationCollection)
				{
					if (relationalInfo.IsDerivedFrom(alias.NameConsumerDomainClass))
					{
						foreach (Schema schema in store.ElementDirectory.FindElements<Schema>(true))
						{
							ValidateSchemaNamesChanged(schema);
						}
						break;
					}
				}
			}
예제 #57
0
		/// <summary>
		/// DeletingRule: typeof(ReadingOrderHasRole)
		/// Handles the clean up of the readings that the role is involved in by replacing
		/// the place holder with the text DELETED
		/// </summary>
		private static void ReadingOrderHasRoleDeletingRule(ElementDeletingEventArgs e)
		{
			ReadingOrderHasRole link = e.ModelElement as ReadingOrderHasRole;
			RoleBase linkRole = link.Role;
			ReadingOrder linkReadingOrder = link.ReadingOrder;

			if (linkReadingOrder.IsDeleting || linkReadingOrder.IsDeleted)
			{
				// Don't validate if we're removing the reading order
				return;
			}
			FactType factType = linkReadingOrder.FactType;
			if (factType != null)
			{
				FrameworkDomainModel.DelayValidateElement(factType, DelayValidateReadingOrderCollation);
			}

			int pos = linkReadingOrder.RoleCollection.IndexOf(linkRole);
			if (pos >= 0)
			{
				bool isUnaryFactType = factType.UnaryRole != null;
				LinkedElementCollection<Reading> readings = linkReadingOrder.ReadingCollection;
				int numReadings = readings.Count;
				int roleCount = linkReadingOrder.RoleCollection.Count;
				for (int iReading = 0; iReading < numReadings; ++iReading)
				{
					Reading linkReading = readings[iReading];
					if (!linkReading.IsDeleting)
					{
						Debug.Assert(!linkReading.IsDeleted);
						string text = linkReading.Text;
						IFormatProvider formatProvider = CultureInfo.InvariantCulture;
						linkReading.SetAutoText(Reading.ReplaceFields(
							linkReading.Text,
							delegate(int replaceIndex)
							{
								if (replaceIndex == pos)
								{
									return isUnaryFactType ? "" : ResourceStrings.ModelReadingRoleDeletedRoleText;
								}
								else if (replaceIndex > pos)
								{
									return "{" + (replaceIndex - 1).ToString(formatProvider) + "}";
								}
								return null;
							}
							));
					}
				}
			}
		}
        public override void  ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ReferenceRelationship referenceRelationship = e.ModelElement as ReferenceRelationship;
            if (referenceRelationship != null)
            {
                if (referenceRelationship.SerializedReferenceRelationship != null)
                    referenceRelationship.SerializedReferenceRelationship.Delete();

                if (referenceRelationship.Source != null)
                    if (referenceRelationship.Source.RolePlayer != null)
                    {
                        SerializationHelper.UpdateDerivedElementsSerializationProperties(referenceRelationship.Source.RolePlayer);
                        SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(referenceRelationship.Source.RolePlayer);
                    }

                if (referenceRelationship.Target != null)
                    if (referenceRelationship.Target.RolePlayer != null)
                    {
                        SerializationHelper.UpdateDerivedElementsSerializationProperties(referenceRelationship.Target.RolePlayer);
                        SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(referenceRelationship.Target.RolePlayer);
                    }
            }

            EmbeddingRelationship embeddingRelationship = e.ModelElement as EmbeddingRelationship;
            if (embeddingRelationship != null)
            {
                if (embeddingRelationship.SerializedEmbeddingRelationship != null)
                    embeddingRelationship.SerializedEmbeddingRelationship.Delete();

                if (embeddingRelationship.Source != null)
                    if (embeddingRelationship.Source.RolePlayer != null)
                    {
                        SerializationHelper.UpdateDerivedElementsSerializationProperties(embeddingRelationship.Source.RolePlayer);
                        SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(embeddingRelationship.Source.RolePlayer);
                    }

                if( embeddingRelationship.Target != null )
                    if (embeddingRelationship.Target.RolePlayer != null)
                    {
                        SerializationHelper.UpdateDerivedElementsSerializationProperties(embeddingRelationship.Target.RolePlayer);
                        SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(embeddingRelationship.Target.RolePlayer);
                    }
            }

            DomainClassReferencesBaseClass inhRelationship = e.ModelElement as DomainClassReferencesBaseClass;
            if (inhRelationship != null)
            {
                inhRelationship.DerivedClass.BaseClass = null;

                SerializationHelper.UpdateDerivedElementsSerializationProperties(inhRelationship.DerivedClass);
                SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(inhRelationship.DerivedClass);
            }

            DomainRelationshipReferencesBaseRelationship inhRelationshipRel = e.ModelElement as DomainRelationshipReferencesBaseRelationship;
            if (inhRelationshipRel != null)
            {
                inhRelationshipRel.DerivedRelationship.BaseRelationship = null;

                SerializationHelper.UpdateDerivedElementsSerializationProperties(inhRelationshipRel.DerivedRelationship);
            }
        }
예제 #59
0
			/// <summary>
			/// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.UniquenessIncludesConceptTypeChild)
			/// Remove a column in a uniqueness constraint when a concept type child is removed from the
			/// corresponding abstraction construct
			/// </summary>
			private static void UniquenessConstraintRoleDeleting(ElementDeletingEventArgs e)
			{
				UniquenessIncludesConceptTypeChild link = (UniquenessIncludesConceptTypeChild)e.ModelElement;
				Uniqueness uniqueness = link.Uniqueness;
				LinkedElementCollection<UniquenessConstraint> constraints;
				int constraintCount;
				if (!uniqueness.IsDeleting &&
					!link.ConceptTypeChild.IsDeleting &&
					0 != (constraintCount = (constraints = UniquenessConstraintIsForUniqueness.GetUniquenessConstraint(uniqueness)).Count))
				{
					int removeAtIndex = UniquenessIncludesConceptTypeChild.GetLinksToConceptTypeChildCollection(uniqueness).IndexOf(link);
					for (int i = 0; i < constraintCount; ++i)
					{
						constraints[i].ColumnCollection.RemoveAt(removeAtIndex);
					}
				}
			}
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            ReferenceRelationship referenceRelationship = e.ModelElement as ReferenceRelationship;
            if (referenceRelationship != null)
            {
                if (referenceRelationship.ReferenceRSNode != null)
                    referenceRelationship.ReferenceRSNode.Delete();
            }

            EmbeddingRelationship embeddingRelationship = e.ModelElement as EmbeddingRelationship;
            if (embeddingRelationship != null)
            {
                if(embeddingRelationship.EmbeddingRSNode != null )
                    embeddingRelationship.EmbeddingRSNode.Delete();
            }

            DomainClassReferencesBaseClass inhRelationship = e.ModelElement as DomainClassReferencesBaseClass;
            if (inhRelationship != null)
            {
                InheritanceNode node = inhRelationship.Store.ElementDirectory.FindElement(inhRelationship.InhNodeId) as InheritanceNode;
                if (node != null)
                {
                    if (node.IsElementHolder)
                    {
                        RootNode rootNode = new RootNode(node.Store);
                        rootNode.DomainElement = node.DomainElement;

                        rootNode.IsElementHolder = true;
                        rootNode.IsEmbeddingTreeExpanded = node.IsEmbeddingTreeExpanded;
                        rootNode.IsExpanded = true;
                        rootNode.IsInheritanceTreeExpanded = node.IsInheritanceTreeExpanded;
                        rootNode.IsReferenceTreeExpanded = node.IsReferenceTreeExpanded;
                        rootNode.IsShapeMappingTreeExpanded = node.IsShapeMappingTreeExpanded;

                        // copy sub tree
                        for (int i = node.EmbeddingRSNodes.Count - 1; i >= 0; i--)
                            node.EmbeddingRSNodes[i].TreeNode = rootNode;

                        for (int i = node.ReferenceRSNodes.Count - 1; i >= 0; i--)
                            node.ReferenceRSNodes[i].TreeNode = rootNode;

                        for (int i = node.InheritanceNodes.Count - 1; i >= 0; i--)
                            node.InheritanceNodes[i].TreeNode = rootNode;

                        for (int i = node.ShapeClassNodes.Count - 1; i >= 0; i--)
                            node.ShapeClassNodes[i].TreeNode = rootNode;

                        node.DomainElement.ParentModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(rootNode);
                        node.DomainElement.ParentModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(rootNode);
                    }

                    // connection was deleted using the property window and not the menu item, so delete the rs and the
                    // node here
                    //if (inhNode.IsElementHolder)
                    //    TreeOperations.SplitTree(inhNode);

                    node.Delete();
                }

            }
        }