Struts 2 Multiple Keys in Multiple Resource Bundles [ How-To ] - struts2

I am using
struts.custom.i18n.resources=file1,file2
file1
enter.user = User name
file2
enter.user = User name1
What will be the output for enter.user ?

It has to do with the order you write the resources in struts.custom.i18n.resources property.
The last one 'wins'.
Now you have
struts.custom.i18n.resources=file1,file2
file2 is the last so file2 wins and the output will be 'User name1'
if you had
struts.custom.i18n.resources=file2,file1
file1 would be the last so the output would be 'User name'

Related

How to put condition in extensible choice

Hi I have recently started learning jenkins. I would like to know
how to put a condition for the extensible choice.
I have
Extensible Choice:
Name: DB
Description: DB to load for option 1 and 2
File1
File2
File3
Choice Provider: Textarea Choice Parameter
Choices: File1
File2
File3
Default Choice : File1
When the OS is Linux it should choose the File1 and when it is Unix it should choose File2
Since the default choice is given as File1 it is taking the same File1 for both OS versions. Is there a way that I can put condition for this type of scenario
I want to choose a file which is related to that particular OS

grep or awk? : Find similar substring and output in two fields

I Have two files, I want to find the strings of file1 as substring in file2,
but want the output of the results (when matching) containing both strings in two fields divided by ':'
So that my output of matches has "file1string:file2string"
Example
file 1
464697uifs4h44yy
48oo895i6iu8gg11
j4h5y7yu4g655h44
jyyuthvcxx22zerc
File 2
j4h5y7yu4g655h447ijj651cvpijgtkk
strxzdokui464697uifs4rdffgjfudjh
kjhbdfgfx1154m87gjgbgcsqubyu6u3k
gfhgysj4h5y7yu4g655h44jkhgfhhfhu
Desired Output
j4h5y7yu4g655h44:j4h5y7yu4g655h447ijj651cvpijgtkk
j4h5y7yu4g655h44:gfhgysj4h5y7yu4g655h44jkhgfhhfhu
j4h5y7yu4g655h44:j4h5y7yu4g655h447ijj651cvpijgtkk
j4h5y7yu4g655h44:gfhgysj4h5y7yu4g655h44jkhgfhhfhu
I used :
fgrep -f file1 file2 >output
but this gives only results from file 2

Sort columns while keeping rows intact

Let say I have three columns, each column has over 1,000 entries
A B C
1 2 6
5 3 7
7 4 8
Now I reorder the elements in column A as
5
1
7
...
How can I sort columns B and C so that I have
5 3 7
1 2 6
7 4 8
...
Excel has the "custom list" sort feature that can do exactly what I want. All I need to do is enter column 1 as "5, 1, 7, ..." into the "custom list". However, it doesn't work if my column 1 has 1,000+ entries (I cannot paste the list there). I am looking for a solution with awk or grep.
If you're open to a Perl solution:
($in, $list) = #ARGV;
open IN, "< $in" or die;
while ($line = <IN>) {
#F = split /\s+/, $line;
if (defined $h{$F[0]}) {
die "ERROR: multiple input lines have first column $F[0]\n";
}
$h{$F[0]} = $line;
}
open LIST, "< $list" or die;
while ($line = <LIST>) {
#F = split /\s+/, $line;
if (defined $h{$F[0]}) {
print $h{$F[0]};
} else {
die "ERROR: no match found for $F[0]\n";
}
}
Save this file as "script"
Save your input data as "input"
Save your custom list as "list"
Run: perl script input list
How it works:
Iterate through the input file which contains columns of data, separated by whitespace. If your input file is comma-separated, change /\s+/ to /,/
Split line into fields array #F
Store line into hash h, keyed based on first field $F[0]
Iterate through the list file
Split line into fields (this handles trailing whitespace)
Print contents of hash for that key
Sanity checking is also done

How do we generate all parameter combination to form a URL

Suppose I have a url
xyz.com/param1=abc&param2=123&param3=!##
Each parameter can have many values like:
param1 = abc, xyz, qwe
param2 = 123, 456, 789
param3 = !##, $%^, &*(
All the parameters and values will be read from an excel file. There can be n number of parameters and each may have any number of values.
I want to generate all the combinations which can be formed using all values of each parameters.
Output will be like:
xyz.com/param1=abc&param2=123&param3=!##
xyz.com/param1=xyz&param2=456&param3=!##
xyz.com/param1=qwe&param2=123&param3=!##
xyz.com/param1=qwe&param2=456&param3=!##
xyz.com/param1=xyz&param2=789&param3=$%^
...
..
and so on
besides the previous comment in your post, you need construct some nested loops.
I will assume you have a bash shell available (since you hadn't specified your wanted language).
for I in 'abc' 'xyz' 'qwe'
do
for J in '123' '456' '789'
do
for K in '!##' '$%^' '&*('
do
echo "xyz.com/param1=${I}&param2=${J}&param3=${K}"
done
done
done
Note that:
that '&*(' will bring you problems, since & is the character that you use to delimit each parameter.
double quotes " around echo, will make a double quote character to make this program to fail miserably
the same apply to ', \ and some others

Trying to output all possible combinations of joining two files

I have a folder of 24 different files that all have the same tab-separated format:
This is an example:
zinc-n with-iodide-n 8.0430 X
zinc-n with-amount-of-supplement-n 12.7774 X
zinc-n with-value-of-horizon-n 14.5585 X
zirconium-n as-valence-n 11.3255 X
zirconium-n for-form-of-norm-n 15.4607 X
I want to join the files in every possible combination of 2.
For instance, I want to join File 1 and File 2, File 1 and File 3, File 1 and File 4... and so on until I have an output of 552 files joining EACH file with EACH other file considering all the UNIQUE combinations
I know this can be done for instance in the Terminal with cat.
i.e.
cat File1 File2 > File1File2
cat File1 File3 > File1File3
... and so on.
But, to do this for each unique combination would be an extremely laborious process.
Is there a possible to automatize this process to join all of the unique combination using a command line in Terminal with grep for instance? or perhaps another suggestion for a more optimized solution than CAT.
You can try with python. I use the combinations() function from the itertools module and join() the contents of each pair of files. Note that I use a cache to avoid reading each file many times, but you could exhaust your memory, so use the best approach for you:
import sys
import itertools
seen = {}
for files in itertools.combinations(sys.argv[1:], 2):
outfile = ''.join(files)
oh = open(outfile, 'w')
if files[0] in seen:
f1_data = seen[files[0]]
else:
f1_data = open(files[0], 'r').read()
seen[files[0]] = f1_data
if files[1] in seen:
f2_data = seen[files[1]]
else:
f2_data = open(files[1], 'r').read()
seen[files[1]] = f2_data
print('\n'.join([f1_data, f2_data]), file=oh)
A test:
Assuming following content of three files:
==> file1 <==
file1 one
f1 two
==> file2 <==
file2 one
file2 two
==> file3 <==
file3 one
f3 two
f3 three
Run the script like:
python3 script.py file[123]
And it will create three new files with content:
==> file1file2 <==
file1 one
f1 two
file2 one
file2 two
==> file1file3 <==
file1 one
f1 two
file3 one
f3 two
f3 three
==> file2file3 <==
file2 one
file2 two
file3 one
f3 two
f3 three

Resources