// HERZUM SPRINT 1.0 private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition; if (commentMetadataDefinition != null) { data.Metadata = new CommentMetadata(commentMetadataDefinition.Label); string commentNodeId = Guid.NewGuid().ToString(); // HERZUM SPRINT 1.2 COMMENT // newCreatedNode = new CommentNode(commentNodeId, data); var data_with_size = new SerializedVertexDataWithSize(); data_with_size.X = data.X; data_with_size.Y = data.Y; data_with_size.Metadata = data.Metadata; data_with_size.Width = 160; data_with_size.Height = 160; data_with_size.WidgetStatus = "normal"; newCreatedNode = new CommentNode(commentNodeId, data_with_size); // END SPRINT 1.2 COMMENT experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return isCreated; }
/// <summary> /// Adds the component from definition to experiment. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param> /// <param name="positionX">The position X at where new component is added</param> /// <param name="positionY">The position Y at where new comopnent is added</param> /// <returns>The newly constucted node</returns> public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY) { if (metadataDefinition == null) throw new ArgumentNullException("metadataDefinition"); ExperimentNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; // case 1. Primitive Component bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode); // case 2. Composite Component if(!isCreated) isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode); // case 3. Decision if (!isCreated) isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode); // case 4. Loop if (!isCreated) isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode); return newNode; }
public ComponentNode(string id, SerializedVertexData data) : base(id, data) { if (id == null) throw new ArgumentNullException("id"); if (data == null) throw new ArgumentNullException("data"); ID = id; ComponentMetadata metadata = data.Metadata as ComponentMetadata; }
/// <summary> /// Generates the exit decision node. /// </summary> /// <param name="positionX">The position X.</param> /// <param name="positionY">The position Y.</param> /// <returns></returns> private static ExitDecisionNode GenerateExitDecisionNode(double positionX, double positionY) { var data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; data.Metadata = new ExitDecisionMetadata(); var exitDecisionNode = new ExitDecisionNode(Guid.NewGuid().ToString(), data); return(exitDecisionNode); }
public virtual SerializedVertexData Clone() { SerializedVertexData clone = new SerializedVertexData(); clone.X = X; clone.Y = Y; clone.Metadata = Metadata.Clone(); clone.m_isInitialized = m_isInitialized; return(clone); }
public ComponentNode(string id, SerializedVertexData data) : base(id, data) { if (id == null) { throw new ArgumentNullException("id"); } if (data == null) { throw new ArgumentNullException("data"); } ID = id; ComponentMetadata metadata = data.Metadata as ComponentMetadata; }
/// <summary> /// Generates the correct node based on metadata contained in serialized vertex data /// </summary> /// <param name="id">The id.</param> /// <param name="nodeData">The node data.</param> /// <returns>Experiment node</returns> private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData) { if (id == null) { throw new ArgumentNullException("id"); } if (nodeData == null) { throw new ArgumentNullException("nodeData"); } ExperimentNode node; if (nodeData.Metadata is StartNodeMetadata) { node = new ExperimentStartNode(id, nodeData); } else if (nodeData.Metadata is EndNodeMetadata) { node = new ExperimentEndNode(id, nodeData); } else if (nodeData.Metadata is DecisionMetadata) { node = new ExperimentDecisionNode(id, nodeData); } else if (nodeData.Metadata is ScopeMetadata) { node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is LoopScopeMetadata) { node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is CompositeComponentMetadata) { node = new CompositeComponentNode(id, nodeData); } else if (nodeData.Metadata is ExitDecisionMetadata) { node = new ExitDecisionNode(id, nodeData); } else { ComponentNode componentNode = new ComponentNode(id, nodeData); node = componentNode; } return(node); }
private static void GenerateScopesAndExit(IEditableExperiment experiment, SerializedVertexData data, ExperimentDecisionNode decisionNode) { ExitDecisionNode exitDecisionNode = GenerateExitDecisionNode(data.X, data.Y + 240); experiment.AddVertex(exitDecisionNode); //add invisible fixed connection between decision and exit - so that if scope can be skipped upon condition experiment.AddFixedConnection(decisionNode, exitDecisionNode, true); //set the log settings of all new nodes experiment.SetLogLevelSettings(decisionNode); experiment.SetLogLevelSettings(exitDecisionNode); AddScopeToDecision("Scope 1", data.X - 90, data.Y + 120, decisionNode, exitDecisionNode, experiment); AddScopeToDecision("Scope 2", data.X + 90, data.Y + 120, decisionNode, exitDecisionNode, experiment); }
public override bool Equals(object obj) { SerializedVertexData other = obj as SerializedVertexData; if (other == null) { return(false); } bool isEqual = true; isEqual &= object.Equals(X, other.X); isEqual &= object.Equals(Y, other.Y); return(isEqual); }
/// <summary> /// Adds the component from definition to experiment. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param> /// <param name="positionX">The position X at where new component is added</param> /// <param name="positionY">The position Y at where new comopnent is added</param> /// <returns>The newly constucted node</returns> public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY) { if (metadataDefinition == null) throw new ArgumentNullException("metadataDefinition"); ExperimentNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; // case 1. Primitive Component bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode); // case 2. Composite Component if(!isCreated) isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode); // case 3. Decision if (!isCreated) isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode); // case 4. Loop if (!isCreated) isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode); // HERZUM SPRINT 0.0 // case 5. Scope if (!isCreated) isCreated = TryCreateScopeComponent(experiment, metadataDefinition, data, out newNode); // END HERZUM 0.0 // HERZUM SPRINT 1.0 if (!isCreated) isCreated = TryCreateComment(experiment, metadataDefinition, data, out newNode); // END HERZUM SPRINT 1.0 // HERZUM SPRINT 2.0: TLAB-65 // case 5. Challenge if (!isCreated) isCreated = TryCreateChallengeComponent(experiment, metadataDefinition, data, out newNode); // END HERZUM SPRINT 2.0: TLAB-65 return newNode; }
/// <summary> /// Constructs experiment node from given xml xpath navigator to the node. /// </summary> /// <param name="reader">The reader with a root to the node.</param> /// <returns>Experiment Node</returns> public ExperimentNode NodeFactory(XPathNavigator reader) { string id = reader.GetAttribute("id", String.Empty); SerializedVertexData nodeData = null; XPathNavigator serializedNodeData = reader.SelectSingleNode("SerializedVertexData"); if (serializedNodeData != null) { nodeData = (SerializedVertexData)m_nodeSerializer.Deserialize(serializedNodeData.ReadSubtree()); nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot); } else { //it may be serialized vertex data with size serializedNodeData = reader.SelectSingleNode("SerializedVertexDataWithSize"); if (serializedNodeData != null) { nodeData = (SerializedVertexDataWithSize)m_nodeSerializerWithSize.Deserialize(serializedNodeData.ReadSubtree()); nodeData.PostProcessReadXml(m_library, m_experimentLocationRoot); } } ExperimentNode vert = null; if (nodeData != null) { vert = NodeGenerator(id, nodeData); if (nodeData.Metadata != null) { if (nodeData.Metadata.HasDeserializationError) { vert.SetError(nodeData.Metadata.DeserializationErrorMessage); } } m_vertices[id] = vert; } return(vert); }
/// <summary> /// Attempts to create the primitive component. Component is created only if definition is a ComponentMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a ComponentMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ComponentMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ComponentMetadataDefinition componentMetadataDefinition = metadataDefinition as ComponentMetadataDefinition; if (componentMetadataDefinition != null) { data.Metadata = new ComponentMetadata(componentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath)); string componentNodeId = Guid.NewGuid().ToString(); newCreatedNode = new ComponentNode(componentNodeId, data); experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return isCreated; }
/// <summary> /// Adds the component from definition to experiment. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param> /// <param name="positionX">The position X at where new component is added</param> /// <param name="positionY">The position Y at where new comopnent is added</param> /// <returns>The newly constucted node</returns> public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY) { if (metadataDefinition == null) { throw new ArgumentNullException("metadataDefinition"); } ExperimentNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; // case 1. Primitive Component bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode); // case 2. Composite Component if (!isCreated) { isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode); } // case 3. Decision if (!isCreated) { isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode); } // case 4. Loop if (!isCreated) { isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode); } return(newNode); }
// END HERZUM SPRINT 1.0 /// <summary> /// Attempts to create the primitive component. Component is created only if definition is a ComponentMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a ComponentMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ComponentMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ComponentMetadataDefinition componentMetadataDefinition = metadataDefinition as ComponentMetadataDefinition; if (componentMetadataDefinition != null) { data.Metadata = new ComponentMetadata(componentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath)); string componentNodeId = Guid.NewGuid().ToString(); newCreatedNode = new ComponentNode(componentNodeId, data); experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
// HERZUM SPRINT 1.0 private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition; if (commentMetadataDefinition != null) { data.Metadata = new CommentMetadata(commentMetadataDefinition.Label); string commentNodeId = Guid.NewGuid().ToString(); // HERZUM SPRINT 1.2 COMMENT // newCreatedNode = new CommentNode(commentNodeId, data); var data_with_size = new SerializedVertexDataWithSize(); data_with_size.X = data.X; data_with_size.Y = data.Y; data_with_size.Metadata = data.Metadata; data_with_size.Width = 160; data_with_size.Height = 160; data_with_size.WidgetStatus = "normal"; newCreatedNode = new CommentNode(commentNodeId, data_with_size); // END SPRINT 1.2 COMMENT experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
public CompositeComponentNode(string id, SerializedVertexData data, TraceLab.Core.Settings.Settings settings) : base(id, data) { InitializeComponentGraph(settings); }
// END HERZUM 0.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS /// <summary> /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition; if (challengeMetadataDefinition != null) { newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return(isCreated); }
/// <summary> /// Generates the correct node based on metadata contained in serialized vertex data /// </summary> /// <param name="id">The id.</param> /// <param name="nodeData">The node data.</param> /// <returns>Experiment node</returns> private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData) { if (id == null) throw new ArgumentNullException("id"); if (nodeData == null) throw new ArgumentNullException("nodeData"); ExperimentNode node; if (nodeData.Metadata is StartNodeMetadata) { node = new ExperimentStartNode(id, nodeData); } else if (nodeData.Metadata is EndNodeMetadata) { node = new ExperimentEndNode(id, nodeData); } else if (nodeData.Metadata is DecisionMetadata) { node = new ExperimentDecisionNode(id, nodeData); } else if (nodeData.Metadata is ScopeMetadata) { node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is LoopScopeMetadata) { node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is CompositeComponentMetadata) { node = new CompositeComponentNode(id, nodeData); } else if (nodeData.Metadata is ExitDecisionMetadata) { node = new ExitDecisionNode(id, nodeData); } else { ComponentNode componentNode = new ComponentNode(id, nodeData); node = componentNode; } return node; }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a LoopMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a LoopMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateLoopComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; LoopMetadataDefinition loopMetadataDefinition = metadataDefinition as LoopMetadataDefinition; if (loopMetadataDefinition != null) { newCreatedNode = CreateLoopScopeNode(loopMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return(isCreated); }
public ExperimentStartNode(string id, SerializedVertexData nodeData) : base(id, nodeData) { }
/// <summary> /// Creates the decision component. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="decisionMetadataDefinition">The decision metadata definition.</param> /// <param name="data">The data containing position of new vertex</param> /// <returns>Newly added desicion node (note, that in case of decision additional nodes are constructed, two scopes and exit decision node). They are not returned.</returns> private static ExperimentDecisionNode CreateDecisionComponent(IEditableExperiment experiment, DecisionMetadataDefinition decisionMetadataDefinition, SerializedVertexData data) { data.Metadata = new DecisionMetadata(decisionMetadataDefinition.Label); ExperimentDecisionNode decisionNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data); experiment.AddVertex(decisionNode); if (decisionMetadataDefinition.ID == DecisionMetadataDefinition.DecisionGuid) { //generate corresponding scopes and exit nodes GenerateScopesAndExit(experiment, data, decisionNode); } //otherwise it is GoTo decision that does not have corresponding scopes, so simply return it return decisionNode; }
public CompositeComponentNode(string id, SerializedVertexData data) : base(id, data) { InitializeComponentGraph(); }
protected ExperimentNode(string id, SerializedVertexData data) { ID = id; Data = data; }
// END HERZUM 0.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS /// <summary> /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition; if (challengeMetadataDefinition != null) { newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return isCreated; }
/// <summary> /// Generates the correct node based on metadata contained in serialized vertex data /// </summary> /// <param name="id">The id.</param> /// <param name="nodeData">The node data.</param> /// <returns>Experiment node</returns> private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData) { if (id == null) throw new ArgumentNullException("id"); if (nodeData == null) throw new ArgumentNullException("nodeData"); ExperimentNode node; if (nodeData.Metadata is StartNodeMetadata) { node = new ExperimentStartNode(id, nodeData); } else if (nodeData.Metadata is EndNodeMetadata) { node = new ExperimentEndNode(id, nodeData); } else if (nodeData.Metadata is DecisionMetadata) { node = new ExperimentDecisionNode(id, nodeData); } else if (nodeData.Metadata is ScopeMetadata) { node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is LoopScopeMetadata) { node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is CompositeComponentMetadata) { node = new CompositeComponentNode(id, nodeData); } else if (nodeData.Metadata is ExitDecisionMetadata) { node = new ExitDecisionNode(id, nodeData); } // HERZUM SPRINT 1.0 else if (nodeData.Metadata is CommentMetadata) { // HERZUM SPRINT 1.2 // node = new CommentNode(id, nodeData); node = new CommentNode(id, (SerializedVertexDataWithSize) nodeData); // END HERZUM SPRINT 1.2 } // END HERZUM SPRINT 1.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS else if (nodeData.Metadata is ChallengeMetadata) { node = new ChallengeNode(id, (SerializedVertexDataWithSize) nodeData); } // END HERZUM SPRINT 2.0: TLAB-65 CLASS else { ComponentNode componentNode = new ComponentNode(id, nodeData); node = componentNode; } return node; }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition; if (decisionMetadataDefinition != null) { newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data); isCreated = true; } return isCreated; }
public virtual SerializedVertexData Clone() { SerializedVertexData clone = new SerializedVertexData(); clone.X = X; clone.Y = Y; clone.Metadata = Metadata.Clone(); clone.m_isInitialized = m_isInitialized; return clone; }
/// <summary> /// Generates the exit decision node. /// </summary> /// <param name="positionX">The position X.</param> /// <param name="positionY">The position Y.</param> /// <returns></returns> private static ExitDecisionNode GenerateExitDecisionNode(double positionX, double positionY) { var data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; data.Metadata = new ExitDecisionMetadata(); var exitDecisionNode = new ExitDecisionNode(Guid.NewGuid().ToString(), data); return exitDecisionNode; }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a LoopMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a LoopMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateLoopComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; LoopMetadataDefinition loopMetadataDefinition = metadataDefinition as LoopMetadataDefinition; if (loopMetadataDefinition != null) { newCreatedNode = CreateLoopScopeNode(loopMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return isCreated; }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition; if (decisionMetadataDefinition != null) { newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data); isCreated = true; } return(isCreated); }
/// <summary> /// Adds a new decision node at the specified coordinates /// </summary> public ExperimentDecisionNode AddDecisionToExperiment(Experiment experiment, double positionX, double positionY) { ExperimentDecisionNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; data.Metadata = new DecisionMetadata("Decision"); newNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data); experiment.AddVertex(newNode); return newNode; }
/// <summary> /// Creates the decision component. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="decisionMetadataDefinition">The decision metadata definition.</param> /// <param name="data">The data containing position of new vertex</param> /// <returns>Newly added desicion node (note, that in case of decision additional nodes are constructed, two scopes and exit decision node). They are not returned.</returns> private static ExperimentDecisionNode CreateDecisionComponent(IEditableExperiment experiment, DecisionMetadataDefinition decisionMetadataDefinition, SerializedVertexData data) { data.Metadata = new DecisionMetadata(decisionMetadataDefinition.Label); ExperimentDecisionNode decisionNode = new ExperimentDecisionNode(Guid.NewGuid().ToString(), data); experiment.AddVertex(decisionNode); if (decisionMetadataDefinition.ID == DecisionMetadataDefinition.DecisionGuid) { //generate corresponding scopes and exit nodes GenerateScopesAndExit(experiment, data, decisionNode); } //otherwise it is GoTo decision that does not have corresponding scopes, so simply return it return(decisionNode); }
/// <summary> /// Generates the correct node based on metadata contained in serialized vertex data /// </summary> /// <param name="id">The id.</param> /// <param name="nodeData">The node data.</param> /// <returns>Experiment node</returns> private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData) { if (id == null) { throw new ArgumentNullException("id"); } if (nodeData == null) { throw new ArgumentNullException("nodeData"); } ExperimentNode node; if (nodeData.Metadata is StartNodeMetadata) { node = new ExperimentStartNode(id, nodeData); } else if (nodeData.Metadata is EndNodeMetadata) { node = new ExperimentEndNode(id, nodeData); } else if (nodeData.Metadata is DecisionMetadata) { node = new ExperimentDecisionNode(id, nodeData); } else if (nodeData.Metadata is ScopeMetadata) { node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is LoopScopeMetadata) { node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData); } else if (nodeData.Metadata is CompositeComponentMetadata) { node = new CompositeComponentNode(id, nodeData); } else if (nodeData.Metadata is ExitDecisionMetadata) { node = new ExitDecisionNode(id, nodeData); } // HERZUM SPRINT 1.0 else if (nodeData.Metadata is CommentMetadata) { // HERZUM SPRINT 1.2 // node = new CommentNode(id, nodeData); node = new CommentNode(id, (SerializedVertexDataWithSize)nodeData); // END HERZUM SPRINT 1.2 } // END HERZUM SPRINT 1.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS else if (nodeData.Metadata is ChallengeMetadata) { node = new ChallengeNode(id, (SerializedVertexDataWithSize)nodeData); } // END HERZUM SPRINT 2.0: TLAB-65 CLASS else { ComponentNode componentNode = new ComponentNode(id, nodeData); node = componentNode; } return(node); }