public void ValidateElement(UmlDiagram diagram, UmlBase element) { foreach (KeyValuePair <string, string> pair in element.TaggedValues) { String name = diagram.GetType().Name + "_" + element.GetType().Name + "_" + pair.Key; if (pair.Key.Contains("jude.hyperlink")) { name = pair.Key.Replace('.', '_'); } MethodInfo method = this.GetType().GetMethod(name); String info; if (element is UmlUseCase) { UmlUseCase aux = (UmlUseCase)element; info = diagram.Name + " >> " + aux.Name + " >> " + pair.Key; } else { info = diagram.Name + " >> " + element.Name + " >> " + pair.Key; } if (method != null) { method.Invoke(this, new object[] { pair.Value, info }); } } }
private void ValidateUseCase(UmlModel model, UmlDiagram diagram, UmlUseCase uCase) { Boolean existeAC = false; String aux = uCase.GetTaggedValue("jude.hyperlink"); if (aux != null) { foreach (UmlActivityDiagram actD in model.Diagrams.OfType <UmlActivityDiagram> ()) { if ((aux == uCase.Name) && (aux == actD.Name)) { existeAC = true; break; } } } if (!existeAC) { log("[WARNING] Missing activity diagram for { " + HttpUtility.UrlDecode(uCase.Name) + " } use case.", 2); } if (String.IsNullOrEmpty(uCase.GetTaggedValue("TDPRECONDITIONS"))) { log("[WARNING] Missing TDpreConditions in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(uCase.Name) + " element.", 2); } if (String.IsNullOrEmpty(uCase.GetTaggedValue("TDPOSTCONDITIONS"))) { log("[WARNING] Missing TDpostConditions in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(uCase.Name) + " element.", 2); } }
private void ValidateActionStateTransitionsTags(UmlDiagram diagram, UmlModel model, String fileName) { String[] path = fileName.Split('\\'); path = path.Where(w => w != path[path.Length - 1]).ToArray(); String pathNew = String.Join(@"\", path); foreach (UmlActionState s in diagram.UmlObjects.OfType <UmlActionState>()) { if (s.TaggedValues.Count > 1) { if (s.TaggedValues.Keys.Contains("cycles")) { String aux = s.GetTaggedValue("jude.hyperlink"); if (s.TaggedValues.Count - 1 > 1) { log("[WARNING] Invalid tagged values at {" + HttpUtility.UrlDecode(s.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } //ValidateLineExcel(diagram, model, fileName, populate, s); } else if (s.TaggedValues.Count == 0) { continue; } else if (!s.TaggedValues.Keys.Contains("jude.hyperlink")) { log("[WARNING] Invalid tagged values at {" + HttpUtility.UrlDecode(s.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } } }
private void ValidateActionStateTransitions(UmlDiagram diagram) { foreach (UmlActionState s in diagram.UmlObjects.OfType <UmlActionState> ()) { if (!(s is UmlFinalState)) { int cnt = diagram.UmlObjects.OfType <UmlTransition> ().Where(x => x.Source.Name.Equals(s.Name)).Count(); switch (cnt) { case 0: log("[ERROR] {" + HttpUtility.UrlDecode(s.Name) + "} doesn't have outgoing transition.", 3); break; case 1: //default break; default: if (!(s is UmlDecision || s is UmlFork)) { log("[ERROR] {" + HttpUtility.UrlDecode(s.Name) + "} has " + cnt + " outgoing transitions.", 3); } break; } } int cnt2 = diagram.UmlObjects.OfType <UmlTransition> ().Where(x => x.Target.Name.Equals(s.Name)).Count(); if (!(s is UmlInitialState) && (cnt2 == 0)) { log("[ERROR] {" + HttpUtility.UrlDecode(s.Name) + "} is unreacheable.", 3); } } }
private void ValidateAssociation(UmlDiagram diagram, UmlBase item) { UmlAssociation association = (UmlAssociation)item; if (association.End1 == null || association.End2 == null) { log("[ERROR] Association " + HttpUtility.UrlDecode(diagram.Name) + "#" + HttpUtility.UrlDecode(association.Name) + " is invalid.", 3); } else if (association.End1 is UmlActor && association.End2 is UmlActor) { log("[ERROR] Actors cannot be connected together. Found at" + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3); } else if (association.End1 is UmlUseCase && association.End2 is UmlUseCase) { Boolean isIncExt = false; foreach (String s in association.Stereotypes) { if (s.Equals("Extend") || s.Equals("Include")) { isIncExt = true; break; } } if (!isIncExt) { log("[ERROR] Use cases cannot be connected together. Found at" + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3); } } }
private void ValidateAssociation(UmlDiagram diagram, UmlBase item) { UmlAssociation association = (UmlAssociation)item; if (association.End1 == null || association.End2 == null) { log("[ERROR] Association " + HttpUtility.UrlDecode(diagram.Name) + "#" + HttpUtility.UrlDecode(association.Name) + " is invalid.", 3); } else if (association.End1 is UmlActor && association.End2 is UmlActor) { log("[ERROR] Actors cannot be connected together. Found at " + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3); } else if (association.End1 is UmlUseCase && association.End2 is UmlUseCase) { bool isIncExt = false; foreach (String s in association.Stereotypes) { if (s.Equals("Extend") || s.Equals("Include")) { isIncExt = true; break; } } if (!isIncExt) { log("[ERROR] Use cases cannot be connected together. Found at " + HttpUtility.UrlDecode(association.End1.Name) + "#" + HttpUtility.UrlDecode(association.End2.Name), 3); } } //TODO: Change TDprob validation //else if (association.GetTaggedValue("TDprob") == null) //{ // log("[ERROR] Missing TDprob in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(association.Name) + " element.", 3); //} }
private void ValidateActor(UmlDiagram diagram, UmlBase item) { UmlActor actor = (UmlActor)item; //store requires tags for Actor element String[] requiresTags = new String[] { "TDHOST" }; foreach (String tag in requiresTags) { String value = actor.GetTaggedValue(tag); if (value == null) { log("[ERROR] Missing " + tag + " in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(actor.Name) + " element.", 3); } else { switch (tag) { case "TDHOST": if (tag.Length < 1) { log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } break; } } } }
private void ValidateUseCaseDiagram(UmlModel model, UmlDiagram diagram) { foreach (UmlUseCase uCase in diagram.UmlObjects.OfType <UmlUseCase> ()) { ValidateUseCase(model, diagram, uCase); } //checks for actors if (diagram.UmlObjects.OfType <UmlActor> ().Count() < 1) { log("[ERROR] Missing actor in " + HttpUtility.UrlDecode(diagram.Name) + ". At least 1 actor is required to continue.", 3); } //checks for Use Cases if (diagram.UmlObjects.OfType <UmlUseCase> ().Count() < 1) { log("[ERROR] No use case found in " + HttpUtility.UrlDecode(diagram.Name) + ". At least 1 use case is required to continue.", 3); } //validate diagram's elements foreach (UmlBase item in diagram.UmlObjects) { //validate by type if (item is UmlAssociation) { ValidateAssociation(diagram, item); } if (item is UmlActor) { ValidateActor(diagram, item); } } }
/// <summary> /// Valida um elemento de acordo com o tipo e diagrama ao qual pertence /// </summary> public void ValidateElement(UmlDiagram diagram, UmlBase element) { foreach (KeyValuePair <string, string> pair in element.TaggedValues) { MethodInfo method = this.GetType().GetMethod( diagram.GetType().Name + "_" + element.GetType().Name + "_" + pair.Key); String info; if (element is UmlUseCase) { UmlUseCase aux = (UmlUseCase)element; info = diagram.Name + " >> " + aux.Name + " >> " + pair.Key; } else { info = diagram.Name + " >> " + element.Name + " >> " + pair.Key; } if (method != null) { method.Invoke(this, new object[] { pair.Value, info }); } } }
public void Visit(UmlDiagram diagram, UmlEntity info) { if (info.Name == info.Type.Name) { info.Name = info.Name.CamelToNormal(OnlyFirstUpper); } }
protected override void VisitInternal(UmlDiagram diagram, UmlEntity info, UmlStartingLinesAttribute att) { var append = att.StartingLines; if (string.IsNullOrEmpty(append)) { return; } switch (att.LineKind) { case ClassLineKind.Dot: append += "\n.."; break; case ClassLineKind.Double: append += "\n=="; break; case ClassLineKind.Single: append += "\n--"; break; case ClassLineKind.SingleBold: append += "\n__"; break; } info.AppendStartingLines(append); }
static void Main(string[] args) { UmlDiagram newDiagram = new UmlDiagram(); newDiagram.DrawDiagram(); Console.ReadKey(); }
private void ValidateTransitionTags(UmlDiagram diagram, UmlTransition transition) { String[] validTagNames = { "TDACTION", "TDEXPECTEDRESULT" }; String[] mandatoryTagNames = { "TDACTION" }; String[] optionalTag = { "TDEXPECTEDRESULT" }; //Acuse any unexpected tagged value. foreach (KeyValuePair <String, String> tagvalue in transition.TaggedValues) { if (!validTagNames.Contains(tagvalue.Key)) { log("[WARNING] Unexpected tag {" + tagvalue.Key + "} tagged in transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } //Acuse any missing tag. foreach (String tagvalue in mandatoryTagNames) { String value = transition.GetTaggedValue(tagvalue); if (value == null) { log("[ERROR] Missing TDaction in {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } else { //valid value by tag switch (tagvalue) { case "TDACTION": if (value.Length < 1) { log("[ERROR] Tag {TDaction} has no valid value for transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } break; } } } foreach (String tagvalue in optionalTag) { String value = transition.GetTaggedValue(tagvalue); if (value == null) { log("[WARNING] Missing TDexpectedResult in {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } else { //valid value by tag switch (tagvalue) { case "TDEXPECTEDRESULT": if (value.Length < 1) { log("[WARNING] Tag {TDexpectedResult} has no valid value for transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "}. Found at diagram {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } break; } } } }
private Boolean ValidateTDmethod(UmlDiagram diagram, UmlTransition transition, KeyValuePair <String, String> taggedValue) { if ((taggedValue.Value != "POST") && (taggedValue.Value != "GET")) { return(false); } return(true); }
protected override void VisitInternal(UmlDiagram diagram, UmlEntity info, UmlAddImplementedInterfacesToDiagramAttribute att) { var typesToAdd = info.Type.GetInterfaces(); foreach (var type in typesToAdd) { diagram.UpdateTypeInfo(type, null); } }
public override void WriteTo(CodeWriter cf, UmlDiagram diagram) { var txt = string.Join(" ", Symbols); if (string.IsNullOrEmpty(txt)) { return; } cf.Writeln(txt); cf.Writeln("=="); }
protected override void VisitInternal(UmlDiagram diagram, UmlEntity info, UmlAddTypesToDiagramAttribute att) { if (att.Types == null || att.Types.Length == 0) { return; } foreach (var type in att.Types) { diagram.UpdateTypeInfo(type, null); } }
public void Visit(UmlDiagram diagram, UmlEntity info) { var isStruct = info.Type.IsStruct(); if (!isStruct) { return; } info.Spot = info.Spot ?? new UmlSpot(); info.Spot.InCircle = "S"; info.Spot.CircleBackgroundColor = CircleBackgroundColor; }
public override void Visit(UmlDiagram diagram, UmlEntity info) { if (!info.Type.IsSealed) { return; } var el = OpenIconicKind.Paperclip.AsPlantUmlText(); el = AddStyle(el); var s = new SymbolInfo("sealed", el, "Sealed class"); AddIcon(diagram, s); AddIcon(info, s); }
private void ValidateActionStateTransitions(UmlDiagram diagram) { foreach (UmlActionState s in diagram.UmlObjects.OfType <UmlActionState> ()) { if (!(s is UmlFinalState)) { int cnt = diagram.UmlObjects.OfType <UmlTransition> ().Where(x => x.Source.Id.Equals(s.Id)).Count(); if (s is UmlDecision) { List <UmlTransition> decisionOutgoingList = new List <UmlTransition> (); List <String> decisionOutgoingInputList = new List <String> (); decisionOutgoingList = diagram.UmlObjects.OfType <UmlTransition> ().Where(x => x.Source.Name.Equals(s.Name)).ToList(); foreach (UmlTransition t in decisionOutgoingList) { if (!decisionOutgoingInputList.Contains(t.GetTaggedValue("TDACTION"))) { decisionOutgoingInputList.Add(t.GetTaggedValue("TDACTION")); } else { log("[ERROR] Decision element { " + HttpUtility.UrlDecode(s.Name) + " } has the same TDaction { " + HttpUtility.UrlDecode(t.GetTaggedValue("TDACTION")) + " } value for the outgoing transitions. Found at { " + HttpUtility.UrlDecode(diagram.Name) + " } diagram.", 3); } } } switch (cnt) { case 0: log("[ERROR] { " + HttpUtility.UrlDecode(s.Name) + " } doesn't have outgoing transition.", 3); break; case 1: //default... break; default: if (!(s is UmlDecision)) { log("[ERROR] { " + HttpUtility.UrlDecode(s.Name) + " } has {" + cnt + "} outgoing transitions.", 3); } break; } } if (!(s is UmlInitialState) && diagram.UmlObjects.OfType <UmlTransition> ().Where(x => x.Target.Name.Equals(s.Name)).Count() == 0) { log("[ERROR] { " + HttpUtility.UrlDecode(s.Name) + " } is unreacheable.", 3); } } }
private void ValidateDuplicatedActivities(UmlModel model, UmlDiagram diagram) { UmlUseCaseDiagram ucDiagram = (UmlUseCaseDiagram)diagram; foreach (UmlUseCase useCase in ucDiagram.UmlObjects.OfType <UmlUseCase>()) { UmlActivityDiagram actDiagram = model.Diagrams.OfType <UmlActivityDiagram>().Where(x => x.Name.Equals(useCase.Name)).FirstOrDefault(); if (actDiagram != null && ContainsInclude(ucDiagram, useCase) == false) { List <String> listActionForSingleUseCase = new List <String>(); ValidateDuplicatedActivitiesRecCall(actDiagram, model, listActionForSingleUseCase, useCase); } } }
private void ValidateTransition(UmlDiagram diagram) { //transition validation foreach (UmlTransition transition in diagram.UmlObjects.OfType <UmlTransition>()) { //target cannot be null if (transition.Target == null) { log("[ERROR] Missing target of Transition {" + HttpUtility.UrlDecode(transition.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } //source cannot be null if (transition.Source == null) { log("[ERROR] Missing source of Transition {" + HttpUtility.UrlDecode(transition.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } //transition pointing to pseudo-state cannot be tagged if (transition.Target is UmlPseudoState) { if (transition.TaggedValues.Count > 0) { log("[WARNING] Transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "} points to pseudo-state and may not be tagged. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } //transition pointing to linked states cannot be tagged else if (transition.Target is UmlActionState && !String.IsNullOrEmpty(transition.Target.GetTaggedValue("jude.hyperlink"))) { if (transition.TaggedValues.Count > 0) { log("[WARNING] Transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "} points to linked state and may not be tagged. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } //no transition can point to initial state else if (transition.Target is UmlInitialState) { if (transition.TaggedValues.Count > 0) { log("[WARNING] Transition {" + HttpUtility.UrlDecode(transition.Source.Name + "->" + transition.Target.Name) + "} points to initial state. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } //validate tagged values else if (!(transition.Target is UmlFinalState)) { ValidateTransitionTags(diagram, transition); } } }
public static void AddIcon(UmlDiagram diagram, SymbolInfo symbol) { var list = diagram.Legend.Items; var existing = list .OfType <SymbolTableUmlDiagramLegendItem>() .FirstOrDefault(); if (existing is null) { existing = new SymbolTableUmlDiagramLegendItem(); list.Add(existing); } existing.AddSymbol(symbol); //============= }
private void ValidateInitialStateCount(UmlDiagram diagram) { switch (diagram.UmlObjects.OfType <UmlInitialState>().Count()) { case 0: log("[ERROR] Missing Initial State for {" + HttpUtility.UrlDecode(diagram.Name) + "} diagram.", 3); break; case 1: //default. no statement. break; default: log("[ERROR] Duplicated Initial State found in {" + HttpUtility.UrlDecode(diagram.Name) + "} diagram.", 3); break; } }
private void ValidateActivityDiagram(UmlDiagram diagram, UmlModel model, String fileName) { //initial state must appear only once in activity diagrams. ValidateInitialStateCount(diagram); //final state must appear only once in activity diagrams. ValidateFinalStateCount(diagram); //ActionState must not have tagged values, unless jude.hyperlink ValidateActionStateTransitionsTags(diagram, model, fileName); //ActionState must have at least one outgoing OR incoming transition ValidateActionStateTransitions(diagram); //transition validation ValidateTransition(diagram); }
//TODO: Review TDACTION and TDREFERER validation private Boolean ValidateTDaction(UmlDiagram diagram, UmlTransition transition, String auxURL, String tagName, String value) { String auxTD = ""; auxTD = HttpUtility.UrlDecode(value); try { auxTD = auxTD.Substring(0, 22); } catch { return(false); } if (!auxTD.Equals(auxURL)) { return(false); } return(true); }
private void ValidateActionStateTransitionsTags(UmlDiagram diagram) { foreach (UmlActionState s in diagram.UmlObjects.OfType <UmlActionState> ()) { if (s.TaggedValues.Count > 1) { log("[WARNING] Invalid tagged values at {" + HttpUtility.UrlDecode(s.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } else if (s.TaggedValues.Count == 0) { continue; } else if (!s.TaggedValues.Keys.Contains("jude.hyperlink")) { log("[WARNING] Invalid tagged values at {" + HttpUtility.UrlDecode(s.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 2); } } }
private void ValidateActor(UmlDiagram diagram, UmlBase item) { UmlActor actor = (UmlActor)item; //store required tags for Actor element String[] requiredTags = new String[] { "TDHOST", "TDRAMPUPTIME", "TDRAMPDOWNTIME", "TDPOPULATION" }; foreach (String tag in requiredTags) { String value = actor.GetTaggedValue(tag); if (value == null) { log("[ERROR] Missing " + tag + " in " + HttpUtility.UrlDecode(diagram.Name) + " # " + HttpUtility.UrlDecode(actor.Name) + " element. Using empty string as value.", 3); } else { switch (tag) { case "TDHOST": if (tag.Length < 1) { log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } break; default: Double val = 0; try { val = Convert.ToDouble(actor.GetTaggedValue(tag)); } catch { log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } if (val <= 0) { log("[ERROR] Tag {" + tag + "} has no valid value for Actor {" + HttpUtility.UrlDecode(actor.Name) + "}. Found at {" + HttpUtility.UrlDecode(diagram.Name) + "}.", 3); } break; } } } }
protected override void VisitInternal(UmlDiagram diagram, UmlEntity info, UmlAddRelationAttribute att) { var rel = new UmlRelation { Left = new UmlRelationEnd(diagram.GetTypeName(info.Type)), Right = new UmlRelationEnd(diagram.GetTypeName(att.RelatedType)), Arrow = UmlRelationArrow.MkArrow(att, att.Multiple), Label = att.Name } .WitCreatorMeta <UmlAddRelationAttributeVisitor>(info.Type, att.RelatedType) .WithNote(att); rel.Tag = att.Tag; diagram.Relations.Add(rel); if (att.ForceAddToDiagram) { diagram.UpdateTypeInfo(att.RelatedType, null); } }
private void ValidateUseCase(UmlModel model, UmlDiagram diagram, UmlBase item) { UmlUseCase uCase = (UmlUseCase)item; bool existeAC = false; foreach (UmlActivityDiagram actD in model.Diagrams.OfType <UmlActivityDiagram> ()) { if (actD.Name == uCase.Name) { existeAC = true; break; } } if (!existeAC) { log("[ERROR] Missing activity diagram for \"" + HttpUtility.UrlDecode(uCase.Name) + "\" use case.", 3); } }