def m = [
[id: 7144, name: "Test załącznika.docx", group: "3#Gotowe do akceptacji"],
[id: 7145, name: "Test załącznika 2.docx", group: "3#Gotowe do akceptacji"],
[id: 7146, name: "Test integracji dział prawny cd..docx", group: "3#Gotowe do akceptacji"],
[id: 7147, name: "Test załącznika 3.docx", group: "3#Gotowe do akceptacji"],
[id: 7153, name: "Z.8.DRWS.P.01.F.01.PL.01 Wykaz dokumentów związanych i załączników.docx", group: "3#Gotowe do akceptacji"]
]
def mj = [
[id: 24930, name: "Test integracji dział prawny cd. nowy.docx"],
[id: 24931, name: "Test załącznika nowy.docx"],
[id: 24932, name: "Test załącznika 3 nowa.docx"],
[id: 23432, name: "xoxoxoxx.docx"],
[id: 24933, name: "Test załącznika 2 nowy.docx"]
]
m.each { webcFile ->
def webcName = webcFile.name
def webcGroup = webcFile.group
def webcNameWithoutExtension = webcName.take(webcName.lastIndexOf('.'))
mj.each { jiraFile ->
def jiraName = jiraFile.name
def jiraNameWithoutExtension = jiraName.take(jiraName.lastIndexOf('.'))
if (jiraNameWithoutExtension.contains(webcNameWithoutExtension) && webcGroup == "3#Gotowe do akceptacji") {
} else if (!jiraNameWithoutExtension.contains(webcNameWithoutExtension)) {
println(jiraNameWithoutExtension)
}
}
}
I have to compare two collection of map and print if value from first of map contains value from second or dont.
if statement works fine but else if dont. it should print only xoxoxoxx but prints
Test integracji dział prawny cd. nowy
xoxoxoxx
Test integracji dział prawny cd. nowy
Test załącznika nowy
Test załącznika 3 nowa
xoxoxoxx
Test załącznika nowy
Test załącznika 3 nowa
xoxoxoxx
Test załącznika 2 nowy
Test integracji dział prawny cd. nowy
Test załącznika nowy
xoxoxoxx
Test załącznika 2 nowy
Test integracji dział prawny cd. nowy
Test załącznika nowy
Test załącznika 3 nowa
xoxoxoxx
Test załącznika 2 nowy
from script point of view everything is correct but prints to much. Could you help me a little?
First of all, I think part of the problem is, that all the file names from
mjare all post-fixed withnow[ya]so there actually are no duplicated with the rules you put in play here.Next
eachcan not (really) short-circuit, so with two nestedeachyou will pay for some useless work and maybe some wrong output (assuming, you are not supposed to print possible duplicates).So I'd suggest to make a look-up first, of what you are looking (note, that maybe you want to take care about the
novw[ay]situation there too).Then iterate the list, you want to find the dupes in.