public void undefined(StructureType structureType, String name, StructureUsage usage, int line) { addStructureReference( _answerElement.getUndefinedReferences(), structureType, name, usage, line); }
@Override public TableAnswerElement answer() { UndefinedReferencesQuestion question = (UndefinedReferencesQuestion) _question; // Find all the filenames that produced the queried nodes. This might have false positives if // a file produced multiple nodes, but that was already mis-handled before. Need to rewrite // this question as a TableAnswerElement. Set<String> includeNodes = question.getNodes().getMatchingNodes(_batfish); Multimap<String, String> hostnameFilenameMap = _batfish.loadParseVendorConfigurationAnswerElement().getFileMap(); Set<String> includeFiles = hostnameFilenameMap.entries().stream() .filter(e -> includeNodes.contains(e.getKey())) .map(Entry::getValue) .collect(Collectors.toSet()); Multiset<Row> rows = LinkedHashMultiset.create(); SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>> undefinedReferences = _batfish.loadConvertConfigurationAnswerElementOrReparse().getUndefinedReferences(); undefinedReferences.entrySet().stream() .filter(e -> includeFiles.contains(e.getKey())) .forEach(e -> rows.addAll(processEntryToRows(e))); TableAnswerElement table = new TableAnswerElement(createMetadata()); table.postProcessAnswer(_question, rows); return table; }
answerElement.getUndefinedReferences().putAll(_answerElement.getUndefinedReferences()); answerElement.getReferencedStructures().putAll(_answerElement.getReferencedStructures());
@Override protected boolean matchesSafely( ConvertConfigurationAnswerElement item, Description mismatchDescription) { SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>> byFile = item.getUndefinedReferences(); if (!byFile.containsKey(_filename)) { mismatchDescription.appendText( String.format("File '%s' has no undefined references", _filename)); return false; } SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>> byType = byFile.get(_filename); if (!byType.containsKey(_type)) { mismatchDescription.appendText( String.format( "File '%s' has no undefined references to structures of type '%s'", _filename, _type)); return false; } SortedMap<String, SortedMap<String, SortedSet<Integer>>> byStructureName = byType.get(_type); if (!byStructureName.containsKey(_structureName)) { mismatchDescription.appendText( String.format( "File '%s' has no undefined references to structures of type '%s' named '%s'", _filename, _type, _structureName)); return false; } return true; } }
ConvertConfigurationAnswerElement item, Description mismatchDescription) { SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>> byFile = item.getUndefinedReferences(); if (!byFile.containsKey(_filename)) { mismatchDescription.appendText(
ConvertConfigurationAnswerElement item, Description mismatchDescription) { SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>> byFile = item.getUndefinedReferences(); if (!byFile.containsKey(_filename)) { mismatchDescription.appendText(