/// <summary> /// Adds a software system instance (and its parent deployment nodes) to this view. /// </summary> /// <param name="softwareSystemInstance">the SoftwareSystemInstance to add</param> public void Add(SoftwareSystemInstance softwareSystemInstance) { AddElement(softwareSystemInstance, true); DeploymentNode parent = (DeploymentNode)softwareSystemInstance.Parent; while (parent != null) { AddElement(parent, true); parent = (DeploymentNode)parent.Parent; } }
/// <summary> /// Adds a software system instance to this deployment node, optionally replicating relationships. /// </summary> /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param> /// <param name="deploymentGroup">the deployment group</param> /// <returns>a SoftwareSystemInstance object</returns> public SoftwareSystemInstance Add(SoftwareSystem softwareSystem, string deploymentGroup) { if (softwareSystem == null) { throw new ArgumentException("A software system must be specified."); } SoftwareSystemInstance softwareSystemInstance = Model.AddSoftwareSystemInstance(this, softwareSystem, deploymentGroup); _softwareSystemInstances.Add(softwareSystemInstance); return(softwareSystemInstance); }
/// <summary> /// Adds a software system instance to this deployment node, optionally replicating relationships. /// </summary> /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param> /// <param name="replicateRelationships">true if relationships should be replicated between the element instances in the same deployment environment, false otherwise</param> /// <returns>a SoftwareSystemInstance object</returns> public SoftwareSystemInstance Add(SoftwareSystem softwareSystem, bool replicateRelationships) { if (softwareSystem == null) { throw new ArgumentException("A software system must be specified."); } SoftwareSystemInstance softwareSystemInstance = Model.AddSoftwareSystemInstance(this, softwareSystem, replicateRelationships); _softwareSystemInstances.Add(softwareSystemInstance); return(softwareSystemInstance); }
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."); } } }
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."); * } * } */ }
internal SoftwareSystemInstance AddSoftwareSystemInstance(DeploymentNode deploymentNode, SoftwareSystem softwareSystem, string deploymentGroup) { if (softwareSystem == null) { throw new ArgumentException("A software system must be specified."); } long instanceNumber = deploymentNode.SoftwareSystemInstances.Count(ssi => ssi.SoftwareSystem.Equals(softwareSystem)); instanceNumber++; SoftwareSystemInstance softwareSystemInstance = new SoftwareSystemInstance(softwareSystem, (int)instanceNumber, deploymentNode.Environment, deploymentGroup); softwareSystemInstance.Parent = deploymentNode; softwareSystemInstance.Id = IdGenerator.GenerateId(softwareSystemInstance); ReplicateElementRelationships(softwareSystemInstance); AddElementToInternalStructures(softwareSystemInstance); return(softwareSystemInstance); }
internal string Generate(SoftwareSystemInstance softwareSystemInstance) { string deploymentNodeCanonicalName = Generate((DeploymentNode)softwareSystemInstance.Parent).Substring(DeploymentNodeType.Length); return(SoftwareSystemInstanceType + deploymentNodeCanonicalName + DeploymentCanonicalNameSeperator + formatName(softwareSystemInstance.SoftwareSystem) + "[" + softwareSystemInstance.InstanceId + "]"); }
/// <summary> /// Removes a software system instance from this view. /// </summary> /// <param name="softwareSystemInstance">the SoftwareSystemInstance to remove</param> public void Remove(SoftwareSystemInstance softwareSystemInstance) { RemoveElement(softwareSystemInstance); }