private DeploymentNode findDeploymentNode(Element e) { foreach (Element element in Model.GetElements()) { if (element is DeploymentNode) { DeploymentNode deploymentNode = (DeploymentNode)element; if (e is ContainerInstance) { if (deploymentNode.ContainerInstances.Contains(e)) { return(deploymentNode); } } if (e is InfrastructureNode) { if (deploymentNode.InfrastructureNodes.Contains(e)) { return(deploymentNode); } } } } return(null); }
private bool AddContainerInstancesAndDeploymentNodes(DeploymentNode deploymentNode) { bool hasContainers = false; foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { Container container = containerInstance.Container; if (SoftwareSystem == null || container.Parent.Equals(SoftwareSystem)) { AddElement(containerInstance, true); hasContainers = true; } } foreach (DeploymentNode child in deploymentNode.Children) { hasContainers = hasContainers | AddContainerInstancesAndDeploymentNodes(child); } if (hasContainers) { AddElement(deploymentNode, false); } return(hasContainers); }
private void HydrateDeploymentNode(DeploymentNode deploymentNode, DeploymentNode parent) { deploymentNode.Parent = parent; AddElementToInternalStructures(deploymentNode); deploymentNode.Children.ToList().ForEach(child => HydrateDeploymentNode(child, deploymentNode)); foreach (InfrastructureNode infrastructureNode in deploymentNode.InfrastructureNodes) { infrastructureNode.Parent = deploymentNode; AddElementToInternalStructures(infrastructureNode); } foreach (SoftwareSystemInstance softwareSystemInstance in deploymentNode.SoftwareSystemInstances) { softwareSystemInstance.SoftwareSystem = (SoftwareSystem)GetElement(softwareSystemInstance.SoftwareSystemId); softwareSystemInstance.Parent = deploymentNode; AddElementToInternalStructures(softwareSystemInstance); } foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { containerInstance.Container = (Container)GetElement(containerInstance.ContainerId); containerInstance.Parent = deploymentNode; AddElementToInternalStructures(containerInstance); } }
internal DeploymentNode AddDeploymentNode(DeploymentNode parent, string environment, string name, string description, string technology, int instances, Dictionary <string, string> properties) { if ((parent == null && GetDeploymentNodeWithName(name, environment) == null) || (parent != null && parent.GetDeploymentNodeWithName(name) == null)) { DeploymentNode deploymentNode = new DeploymentNode { Name = name, Description = description, Technology = technology, Parent = parent, Instances = instances, Environment = environment }; if (properties != null) { deploymentNode.Properties = properties; } if (parent == null) { _deploymentNodes.Add(deploymentNode); } deploymentNode.Id = _idGenerator.GenerateId(deploymentNode); AddElementToInternalStructures(deploymentNode); return(deploymentNode); } else { throw new ArgumentException("A deployment node named '" + name + "' already exists."); } }
internal InfrastructureNode AddInfrastructureNode(DeploymentNode parent, string name, string description, string technology, Dictionary <string, string> properties) { if (name == null || name.Trim().Length == 0) { throw new ArgumentException("A name must be specified."); } if (parent.GetDeploymentNodeWithName(name) == null && parent.GetInfrastructureNodeWithName(name) == null) { InfrastructureNode infrastructureNode = new InfrastructureNode { Name = name, Description = description, Technology = technology, Parent = parent, Environment = parent.Environment }; if (properties != null) { infrastructureNode.Properties = properties; } infrastructureNode.Id = IdGenerator.GenerateId(infrastructureNode); AddElementToInternalStructures(infrastructureNode); return(infrastructureNode); } else { throw new ArgumentException("A deployment/infrastructure node named '" + name + "' already exists."); } }
private bool AddContainerInstancesAndDeploymentNodesAndInfrastructureNodes(DeploymentNode deploymentNode, bool addRelationships) { bool hasContainersOrInfrastructureNodes = false; foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { Container container = containerInstance.Container; if (SoftwareSystem == null || container.Parent.Equals(SoftwareSystem)) { AddElement(containerInstance, addRelationships); hasContainersOrInfrastructureNodes = true; } } foreach (InfrastructureNode infrastructureNode in deploymentNode.InfrastructureNodes) { AddElement(infrastructureNode, addRelationships); hasContainersOrInfrastructureNodes = true; } foreach (DeploymentNode child in deploymentNode.Children) { hasContainersOrInfrastructureNodes = hasContainersOrInfrastructureNodes | AddContainerInstancesAndDeploymentNodesAndInfrastructureNodes(child, addRelationships); } if (hasContainersOrInfrastructureNodes) { AddElement(deploymentNode, addRelationships); } return(hasContainersOrInfrastructureNodes); }
/// <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 child deployment node. /// </summary> /// <param name="name">the name of the deployment node</param> /// <param name="description">a short description</param> /// <param name="technology">the technology</param> /// <param name="instances">the number of instances</param> /// <param name="properties">a Dictionary (string,string) describing name=value properties</param> /// <returns></returns> public DeploymentNode AddDeploymentNode(string name, string description, string technology, int instances, Dictionary <string, string> properties) { DeploymentNode deploymentNode = Model.AddDeploymentNode(this, this.Environment, name, description, technology, instances, properties); if (deploymentNode != null) { Children.Add(deploymentNode); } return(deploymentNode); }
/// <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; } }
/// <summary> /// Adds an infrastructure node (and its parent deployment nodes) to this view. /// </summary> /// <param name="infrastructureNode">the InfrastructureNode to add</param> public void Add(InfrastructureNode infrastructureNode) { AddElement(infrastructureNode, true); DeploymentNode parent = (DeploymentNode)infrastructureNode.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); }
private void HydrateDeploymentNode(DeploymentNode deploymentNode, DeploymentNode parent) { deploymentNode.Parent = parent; AddElementToInternalStructures(deploymentNode); deploymentNode.Children.ToList().ForEach(child => HydrateDeploymentNode(child, deploymentNode)); foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { containerInstance.Container = (Container)GetElement(containerInstance.ContainerId); AddElementToInternalStructures(containerInstance); } }
/// <summary> /// Adds a deployment node to this view. /// </summary> /// <param name="deploymentNode">the DeploymentNode to add</param> public void Add(DeploymentNode deploymentNode) { if (deploymentNode != null) { if (AddContainerInstancesAndDeploymentNodes(deploymentNode)) { Element parent = deploymentNode.Parent; while (parent != null) { AddElement(parent, false); parent = parent.Parent; } } } }
/// <summary> /// Adds a deployment node to this view. /// </summary> /// <param name="deploymentNode">the DeploymentNode to add</param> public void Add(DeploymentNode deploymentNode, bool addRelationships) { if (deploymentNode != null) { if (AddContainerInstancesAndDeploymentNodesAndInfrastructureNodes(deploymentNode, addRelationships)) { Element parent = deploymentNode.Parent; while (parent != null) { AddElement(parent, false); parent = parent.Parent; } } } }
private bool AddElementInstancesAndDeploymentNodesAndInfrastructureNodes(DeploymentNode deploymentNode, bool addRelationships) { bool hasElementsInstancesOrInfrastructureNodes = false; foreach (SoftwareSystemInstance softwareSystemInstance in deploymentNode.SoftwareSystemInstances) { try { AddElement(softwareSystemInstance, addRelationships); hasElementsInstancesOrInfrastructureNodes = true; } catch (ElementNotPermittedInViewException e) { // the element can't be added, so ignore it } } foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { Container container = containerInstance.Container; if (SoftwareSystem == null || container.Parent.Equals(SoftwareSystem)) { try { AddElement(containerInstance, addRelationships); hasElementsInstancesOrInfrastructureNodes = true; } catch (ElementNotPermittedInViewException e) { // the element can't be added, so ignore it } } } foreach (InfrastructureNode infrastructureNode in deploymentNode.InfrastructureNodes) { AddElement(infrastructureNode, addRelationships); hasElementsInstancesOrInfrastructureNodes = true; } foreach (DeploymentNode child in deploymentNode.Children) { hasElementsInstancesOrInfrastructureNodes = hasElementsInstancesOrInfrastructureNodes | AddElementInstancesAndDeploymentNodesAndInfrastructureNodes(child, addRelationships); } if (hasElementsInstancesOrInfrastructureNodes) { AddElement(deploymentNode, addRelationships); } return(hasElementsInstancesOrInfrastructureNodes); }
/// <summary> /// Adds a deployment node to this view. /// </summary> /// <param name="deploymentNode">the DeploymentNode to add</param> public void Add(DeploymentNode deploymentNode, bool addRelationships) { if (deploymentNode == null) { throw new ArgumentException("A deployment node must be specified."); } if (AddContainerInstancesAndDeploymentNodesAndInfrastructureNodes(deploymentNode, addRelationships)) { Element parent = deploymentNode.Parent; while (parent != null) { AddElement(parent, false); parent = parent.Parent; } } }
/// <summary> /// Removes a deployment node from this view. /// </summary> /// <param name="deploymentNode">the DeploymentNode to remove</param> public void Remove(DeploymentNode deploymentNode) { foreach (ContainerInstance containerInstance in deploymentNode.ContainerInstances) { Remove(containerInstance); } foreach (InfrastructureNode infrastructureNode in deploymentNode.InfrastructureNodes) { Remove(infrastructureNode); } foreach (DeploymentNode child in deploymentNode.Children) { Remove(child); } RemoveElement(deploymentNode); }
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 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); }
internal string Generate(DeploymentNode deploymentNode) { StringBuilder buf = new StringBuilder(); buf.Append(DeploymentNodeType); buf.Append(formatName(deploymentNode.Environment)); buf.Append(DeploymentCanonicalNameSeperator); string parents = ""; DeploymentNode parent = (DeploymentNode)deploymentNode.Parent; while (parent != null) { parents = formatName(parent) + DeploymentCanonicalNameSeperator + parents; parent = (DeploymentNode)parent.Parent; } buf.Append(parents); buf.Append(formatName(deploymentNode)); return(buf.ToString()); }
private void HydrateDeploymentNodeRelationships(DeploymentNode deploymentNode) { HydrateRelationships(deploymentNode); deploymentNode.Children.ToList().ForEach(HydrateDeploymentNodeRelationships); deploymentNode.ContainerInstances.ToList().ForEach(HydrateRelationships); }
/// <summary> /// Removes a deployment node from this view. /// </summary> /// <param name="deploymentNode">the DpeloymentNode to remove</param> public void Remove(DeploymentNode deploymentNode) { RemoveElement(deploymentNode); }
/// <summary> /// Adds a relationship between this and another deployment node. /// </summary> /// <param name="destination">the destination DeploymentNode</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(DeploymentNode destination, string description, string technology) { return(Model.AddRelationship(this, destination, description, technology)); }
/// <summary> /// Adds a deployment node to this view. /// </summary> /// <param name="deploymentNode">the DeploymentNode to add</param> public void Add(DeploymentNode deploymentNode) { Add(deploymentNode, true); }