public void check() { lexicalAnalizator.setDiagramElements(diagramElements); // прохождение по всем элементам и их проверка for (int i = 0; i < diagramElements.size(); i++) { BaseNode currentNode = diagramElements.get(i); switch (diagramElements.get(i).getType()) { case ElementType.FLOW: lexicalAnalizator.checkFlow((ControlFlow)diagramElements.get(i)); break; case ElementType.INITIAL_NODE: checkIfInPartion((DiagramElement)currentNode, "", diagramElements.getNode(i)); if (((DiagramElement)currentNode).outSize() == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_OUT], MistakeAdapter.toString(MISTAKES.NO_OUT), diagramElements.getNode(i), ALL_MISTAKES.NO_OUT); } checkInitial(); break; case ElementType.FINAL_NODE: checkIfInPartion((DiagramElement)currentNode, "", diagramElements.getNode(i)); if (((DiagramElement)currentNode).inSize() == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_OUT], MistakeAdapter.toString(MISTAKES.NO_IN), diagramElements.getNode(i), ALL_MISTAKES.NO_IN); } checkFinal(); break; case ElementType.FORK: checkIfInPartion((DiagramElement)currentNode, "", diagramElements.getNode(i)); checkInOut((DiagramElement)currentNode, "", diagramElements.getNode(i)); checkFork((ForkNode)currentNode, diagramElements.getNode(i)); break; case ElementType.JOIN: checkIfInPartion((DiagramElement)currentNode, "", diagramElements.getNode(i)); checkInOut((DiagramElement)currentNode, "", diagramElements.getNode(i)); break; case ElementType.MERGE: checkIfInPartion((DiagramElement)currentNode, "", diagramElements.getNode(i)); checkInOut((DiagramElement)currentNode, "", diagramElements.getNode(i)); break; case ElementType.ACTIVITY: lexicalAnalizator.checkActivity((ActivityNode)diagramElements.get(i), diagramElements.getNode(i)); checkIfInPartion((DiagramElement)currentNode, ((ActivityNode)currentNode).getName(), diagramElements.getNode(i)); checkInOut((DiagramElement)currentNode, ((ActivityNode)currentNode).getName(), diagramElements.getNode(i)); checkActivity((ActivityNode)diagramElements.get(i), diagramElements.getNode(i)); break; case ElementType.DECISION: lexicalAnalizator.checkDecision((DecisionNode)diagramElements.get(i), diagramElements.getNode(i)); checkIfInPartion((DiagramElement)currentNode, ((DecisionNode)currentNode).getQuestion(), diagramElements.getNode(i)); checkInOut((DiagramElement)currentNode, ((DecisionNode)currentNode).getQuestion(), diagramElements.getNode(i)); checkDecision((DecisionNode)diagramElements.get(i), diagramElements.getNode(i)); break; case ElementType.SWIMLANE: lexicalAnalizator.checkSwimlane((Swimlane)diagramElements.get(i)); break; case ElementType.UNKNOWN: break; } } if (finalCount == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_FINAL], MistakeAdapter.toString(MISTAKES.NO_FINAL), ALL_MISTAKES.NO_FINAL); } if (initialCount == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_INITIAL], MistakeAdapter.toString(MISTAKES.NO_INITIAL), ALL_MISTAKES.NO_INITIAL); } if (activityCount == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_ACTIVITIES], MistakeAdapter.toString(MISTAKES.NO_ACTIVITIES), ALL_MISTAKES.NO_ACTIVITIES); } if (lexicalAnalizator.swimlaneCount == 0) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.NO_SWIMLANE], MistakeAdapter.toString(MISTAKES.NO_SWIMLANE), ALL_MISTAKES.NO_SWIMLANE); } }
// проверка активности public void checkActivity(ActivityNode activity, ADNodesList.ADNode node) { if (activity.getName().Length == 0) { ADMistakeFactory.createMistake(Level.HARD, MistakeAdapter.toString(MISTAKES.NO_NAME), node, ALL_MISTAKES.NO_NAME); } else { // проверка на уникальность имени if (activityNames.Contains(activity.getName().ToLower())) { ADMistakeFactory.createMistake(MistakesSeriousness.mistakes[MISTAKES.REPEATED_NAME], MistakeAdapter.toString(MISTAKES.REPEATED_NAME), diagramElements.getNode(activity.getId()), ALL_MISTAKES.REPEATED_NAME); return; } else { activityNames.Add(activity.getName().ToLower()); } // проверка на заглавную букву if ((!activity.getName().Substring(0, 1).ToUpper().Equals(activity.getName().Substring(0, 1)))) { ADMistakeFactory.createMistake(Level.HARD, MistakeAdapter.toString(MISTAKES.SMALL_LETTER), node, ALL_MISTAKES.SMALL_LETTER); } // получаем первое слово существительного и проверяем, что оно не заканчивается на ь или т string firstWord = activity.getName().Split(' ')[0]; //Console.WriteLine(firstWord); if (firstWord.EndsWith("те") || firstWord.EndsWith("чи") || firstWord.EndsWith("ти") || firstWord.EndsWith("ть") || firstWord.EndsWith("чь") || firstWord.EndsWith("т")) { ADMistakeFactory.createMistake(Level.EASY, MistakeAdapter.toString(MISTAKES.NOT_NOUN), node, ALL_MISTAKES.NOT_NOUN); } } }