Пример #1
0
        protected override void CheckElementCanBeAdded(Element elementToBeAdded)
        {
            if (!(elementToBeAdded is DeploymentElement))
            {
                throw new ElementNotPermittedInViewException("Only deployment nodes, infrastructure nodes, software system instances, and container instances can be added to deployment views.");
            }

            DeploymentElement deploymentElementToBeAdded = (DeploymentElement)elementToBeAdded;

            if (!deploymentElementToBeAdded.Environment.Equals(this.Environment))
            {
                throw new ElementNotPermittedInViewException("Only elements in the " + this.Environment + " deployment environment can be added to this view.");
            }

            if (this.SoftwareSystem != null && elementToBeAdded is SoftwareSystemInstance)
            {
                SoftwareSystemInstance ssi = (SoftwareSystemInstance)elementToBeAdded;

                if (ssi.SoftwareSystem.Equals(this.SoftwareSystem))
                {
                    // adding an instance of the scoped software system isn't permitted
                    throw new ElementNotPermittedInViewException("The software system in scope cannot be added to a deployment view.");
                }
            }

            if (elementToBeAdded is SoftwareSystemInstance)
            {
                // check that a child container instance hasn't been added already
                SoftwareSystemInstance softwareSystemInstanceToBeAdded = (SoftwareSystemInstance)elementToBeAdded;
                IList <string>         softwareSystemIds = Elements.Select(ev => ev.Element).OfType <ContainerInstance>().Select(ci => ci.Container.SoftwareSystem.Id).ToList();

                if (softwareSystemIds.Contains(softwareSystemInstanceToBeAdded.SoftwareSystemId))
                {
                    throw new ElementNotPermittedInViewException("A child of " + elementToBeAdded.Name + " is already in this view.");
                }
            }

            if (elementToBeAdded is ContainerInstance)
            {
                // check that the parent software system instance hasn't been added already
                ContainerInstance containerInstanceToBeAdded = (ContainerInstance)elementToBeAdded;
                IList <String>    softwareSystemIds          = Elements.Select(ev => ev.Element).OfType <SoftwareSystemInstance>().Select(ssi => ssi.SoftwareSystemId).ToList();

                if (softwareSystemIds.Contains(containerInstanceToBeAdded.Container.SoftwareSystem.Id))
                {
                    throw new ElementNotPermittedInViewException("The parent of " + elementToBeAdded.Name + " is already in this view.");
                }
            }
        }
Пример #2
0
        protected override void CheckElementCanBeAdded(Element elementToBeAdded)
        {
            if (!(elementToBeAdded is DeploymentElement))
            {
                throw new ElementNotPermittedInViewException("Only deployment nodes, infrastructure nodes, software system instances, and container instances can be added to deployment views.");
            }

            DeploymentElement deploymentElementToBeAdded = (DeploymentElement)elementToBeAdded;

            if (!deploymentElementToBeAdded.Environment.Equals(this.Environment))
            {
                throw new ElementNotPermittedInViewException("Only elements in the " + this.Environment + " deployment environment can be added to this view.");
            }

            if (this.SoftwareSystem != null && elementToBeAdded is SoftwareSystemInstance)
            {
                SoftwareSystemInstance ssi = (SoftwareSystemInstance)elementToBeAdded;

                if (ssi.SoftwareSystem.Equals(this.SoftwareSystem))
                {
                    // adding an instance of the scoped software system isn't permitted
                    throw new ElementNotPermittedInViewException("The software system in scope cannot be added to a deployment view.");
                }
            }

            /*
             * if (elementToBeAdded is SoftwareSystemInstance) {
             *  // check that a child container instance hasn't been added already
             *  SoftwareSystemInstance softwareSystemInstanceToBeAdded = (SoftwareSystemInstance) elementToBeAdded;
             *  ISet<string> softwareSystemIds = Elements.stream().map(ElementView::getElement).filter(e -> e instanceof ContainerInstance).map(e -> (ContainerInstance)e).map(ci -> ci.getContainer().getSoftwareSystem().getId()).collect(Collectors.toSet());
             *
             *  if (softwareSystemIds.Contains(softwareSystemInstanceToBeAdded.SoftwareSystemId)) {
             *      throw new ElementNotPermittedInViewException("A child of " + elementToBeAdded.Name + " is already in this view.");
             *  }
             * }
             *
             * if (elementToBeAdded is ContainerInstance) {
             *  // check that the parent software system instance hasn't been added already
             *  ContainerInstance containerInstanceToBeAdded = (ContainerInstance)elementToBeAdded;
             *  ISet<String> softwareSystemIds = Elements.stream().map(ElementView::getElement).filter(e -> e instanceof SoftwareSystemInstance).map(e -> (SoftwareSystemInstance)e).map(SoftwareSystemInstance::getSoftwareSystemId).collect(Collectors.toSet());
             *
             *  if (softwareSystemIds.Contains(containerInstanceToBeAdded.Container.SoftwareSystem.Id)) {
             *      throw new ElementNotPermittedInViewException("The parent of " + elementToBeAdded.Name + " is already in this view.");
             *  }
             * }
             */
        }
Пример #3
0
 /// <summary>
 /// Adds a relationship between this and another deployment element (deployment node, infrastructure node, or container instance).
 /// </summary>
 /// <param name="destination">the destination DeploymentElement</param>
 /// <param name="description">a short description of the relationship</param>
 /// <param name="technology">the technology</param>
 /// <param name="interactionStyle">the interaction style (Synchronous vs Asynchronous)</param>
 /// <returns>a Relationship object</returns>
 public Relationship Uses(DeploymentElement destination, string description, string technology, InteractionStyle interactionStyle)
 {
     return(Model.AddRelationship(this, destination, description, technology, interactionStyle));
 }
Пример #4
0
 /// <summary>
 /// Adds a relationship between this and another deployment element (deployment node, infrastructure node, or container instance).
 /// </summary>
 /// <param name="destination">the destination DeploymentElement</param>
 /// <param name="description">a short description of the relationship</param>
 /// <param name="technology">the technology</param>
 /// <returns>a Relationship object</returns>
 public Relationship Uses(DeploymentElement destination, string description, string technology)
 {
     return(Model.AddRelationship(this, destination, description, technology));
 }