@Override public void addTagsToTestExecutions( Collection<String> tags, Collection<TestExecution> testExecutions) { for (TestExecution testExecutionItem : testExecutions) { TestExecution testExecution = testExecutionDAO.get(testExecutionItem.getId()); if (testExecution == null) { continue; } for (String tagName : tags) { if (!testExecution.getTags().contains(tagName)) { Tag tag = tagDAO.findByName(tagName); if (tag == null) { Tag newTag = new Tag(); newTag.setName(tagName); tag = tagDAO.create(newTag); } Collection<TestExecution> tagTestExecutions = tag.getTestExecutions(); if (tagTestExecutions == null) { tag.setTestExecutions(new ArrayList<>()); } tag.getTestExecutions().add(testExecution); testExecution.getTags().add(tag); } } testExecutionDAO.update(testExecution); } }
@Override public void removeTagsFromTestExecutions( Collection<String> tags, Collection<TestExecution> testExecutions) { for (TestExecution testExecutionItem : testExecutions) { TestExecution testExecution = testExecutionDAO.get(testExecutionItem.getId()); if (testExecution == null) { continue; } for (Tag tag : testExecution.getTags()) { if (tags.contains(tag.getName())) { testExecution.getTags().remove(tag); } } testExecutionDAO.update(testExecution); } }