/// <summary> /// Adds a relationship between this container instance and another. /// </summary> /// <param name="destination">the destination of the relationship (a ContainerInstance)</param> /// <param name="description">a description of the relationship</param> /// <param name="technology">the technology of the relationship</param> /// <returns>a Relationship object</returns> /// <exception cref="ArgumentException"></exception> public Relationship Uses(ContainerInstance destination, string description, string technology) { if (destination != null) { return(Model.AddRelationship(this, destination, description, technology)); } else { throw new ArgumentException("The destination of a relationship must be specified."); } }
/// <summary> /// Adds a container instance (and its parent deployment nodes) to this view. /// </summary> /// <param name="containerInstance">the ContainerInstance to add</param> public void Add(ContainerInstance containerInstance) { AddElement(containerInstance, true); DeploymentNode parent = (DeploymentNode)containerInstance.Parent; while (parent != null) { AddElement(parent, true); parent = (DeploymentNode)parent.Parent; } }
internal ContainerInstance AddContainerInstance(DeploymentNode deploymentNode, Container container) { if (container == null) { throw new ArgumentException("A container must be specified."); } long instanceNumber = GetElements().Count(e => e is ContainerInstance && ((ContainerInstance)e).Container.Equals(container)); instanceNumber++; ContainerInstance containerInstance = new ContainerInstance(container, (int)instanceNumber, deploymentNode.Environment); containerInstance.Id = _idGenerator.GenerateId(containerInstance); // find all ContainerInstance objects in the same deployment environment IEnumerable <ContainerInstance> containerInstances = GetElements().OfType <ContainerInstance>().Where(ci => ci.Environment.Equals(deploymentNode.Environment)); // and replicate the container-container relationships within the same deployment environment foreach (ContainerInstance ci in containerInstances) { Container c = ci.Container; foreach (Relationship relationship in container.Relationships) { if (relationship.Destination.Equals(c)) { Relationship newRelationship = AddRelationship(containerInstance, ci, relationship.Description, relationship.Technology, relationship.InteractionStyle); if (newRelationship != null) { newRelationship.Tags = String.Empty; newRelationship.LinkedRelationshipId = relationship.Id; } } } foreach (Relationship relationship in c.Relationships) { if (relationship.Destination.Equals(container)) { Relationship newRelationship = AddRelationship(ci, containerInstance, relationship.Description, relationship.Technology, relationship.InteractionStyle); if (newRelationship != null) { newRelationship.Tags = String.Empty; newRelationship.LinkedRelationshipId = relationship.Id; } } } } AddElementToInternalStructures(containerInstance); return(containerInstance); }
/// <summary> /// Adds a container instance to this deployment node. /// </summary> /// <param name="container">the Container to add an instance of</param> /// <returns>a ContainerInstance object</returns> public ContainerInstance Add(Container container) { if (container == null) { throw new ArgumentException("A container must be specified."); } ContainerInstance containerInstance = Model.AddContainerInstance(this, container); ContainerInstances.Add(containerInstance); return(containerInstance); }
/// <summary> /// Adds a container instance to this deployment node. /// </summary> /// <param name="container">the Container to add an instance of</param> /// <param name="deploymentGroup">the deployment group</param> /// <returns>a ContainerInstance object</returns> public ContainerInstance Add(Container container, string deploymentGroup) { if (container == null) { throw new ArgumentException("A container must be specified."); } ContainerInstance containerInstance = Model.AddContainerInstance(this, container, deploymentGroup); _containerInstances.Add(containerInstance); return(containerInstance); }
/// <summary> /// Adds a container instance to this deployment node. /// </summary> /// <param name="container">the Container to add an instance of</param> /// <returns>a ContainerInstance object</returns> public ContainerInstance Add(Container container, bool replicateRelationships) { if (container == null) { throw new ArgumentException("A container must be specified."); } ContainerInstance containerInstance = Model.AddContainerInstance(this, container, replicateRelationships); _containerInstances.Add(containerInstance); return(containerInstance); }
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."); } } }
internal ContainerInstance AddContainerInstance(Container container) { if (container == null) { throw new ArgumentException("A container must be specified."); } long instanceNumber = GetElements().Count(e => e is ContainerInstance && ((ContainerInstance)e).Container.Equals(container)); instanceNumber++; ContainerInstance containerInstance = new ContainerInstance(container, (int)instanceNumber); containerInstance.Id = _idGenerator.GenerateId(containerInstance); // find all ContainerInstance objects IEnumerable <ContainerInstance> containerInstances = GetElements().OfType <ContainerInstance>(); // and replicate the container-container relationships foreach (ContainerInstance ci in containerInstances) { Container c = ci.Container; foreach (Relationship relationship in container.Relationships) { if (relationship.Destination.Equals(c)) { AddRelationship(containerInstance, ci, relationship.Description, relationship.Technology, relationship.InteractionStyle); } } foreach (Relationship relationship in c.Relationships) { if (relationship.Destination.Equals(container)) { AddRelationship(ci, containerInstance, relationship.Description, relationship.Technology, relationship.InteractionStyle); } } } AddElementToInternalStructures(containerInstance); return(containerInstance); }
internal ContainerInstance AddContainerInstance(DeploymentNode deploymentNode, Container container, string deploymentGroup) { if (container == null) { throw new ArgumentException("A container must be specified."); } long instanceNumber = deploymentNode.ContainerInstances.Count(ci => ci.Container.Equals(container)); instanceNumber++; ContainerInstance containerInstance = new ContainerInstance(container, (int)instanceNumber, deploymentNode.Environment, deploymentGroup); containerInstance.Parent = deploymentNode; containerInstance.Id = IdGenerator.GenerateId(containerInstance); ReplicateElementRelationships(containerInstance); AddElementToInternalStructures(containerInstance); return(containerInstance); }
/// <summary> /// Removes an container instance from this view. /// </summary> /// <param name="containerInstance">the ContainerInstance to remove</param> public void Remove(ContainerInstance containerInstance) { RemoveElement(containerInstance); }
internal string Generate(ContainerInstance containerInstance) { string deploymentNodeCanonicalName = Generate((DeploymentNode)containerInstance.Parent).Substring(DeploymentNodeType.Length); return(ContainerInstanceType + deploymentNodeCanonicalName + DeploymentCanonicalNameSeperator + Generate(containerInstance.Container).Substring(ContainerType.Length) + "[" + containerInstance.InstanceId + "]"); }