Revision 53031
Added by Argiro Kokogiannaki over 5 years ago
ContextUtils.java | ||
---|---|---|
13 | 13 |
private static final Logger logger = Logger.getLogger(ClaimHandler.class); |
14 | 14 |
private SearchUtils searchUtils = new SearchUtils(); |
15 | 15 |
|
16 |
public static String extractLabel(String code) throws Exception { |
|
16 |
public static String extractLabel(String code, Boolean production) throws Exception {
|
|
17 | 17 |
String[] codeParts = code.split("::"); |
18 | 18 |
String level0 = ""; |
19 | 19 |
String level1 = ""; |
20 | 20 |
String level2 = ""; |
21 | 21 |
String level3 = ""; |
22 | 22 |
if (codeParts.length >0) { |
23 |
String json = SearchUtils.fetchContext("s/"); |
|
23 |
String json = SearchUtils.fetchContext("s/", production);
|
|
24 | 24 |
level0 = getLabel(json, codeParts[0]); |
25 | 25 |
} |
26 | 26 |
if (codeParts.length >1) { |
27 |
String json = SearchUtils.fetchContext("/"+codeParts[0]); |
|
27 |
String json = SearchUtils.fetchContext("/"+codeParts[0], production);
|
|
28 | 28 |
level1 = getLabel(json, codeParts[0]+"::"+codeParts[1]); |
29 | 29 |
} |
30 | 30 |
if (codeParts.length >2) { |
31 |
String json = SearchUtils.fetchContext("/category/"+codeParts[0]+"::"+codeParts[1]); |
|
31 |
String json = SearchUtils.fetchContext("/category/"+codeParts[0]+"::"+codeParts[1], production);
|
|
32 | 32 |
level2 = getLabel(json, codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]); |
33 | 33 |
} |
34 | 34 |
if (codeParts.length >3) { |
35 |
String json = SearchUtils.fetchContext("/category/concept/"+codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]); |
|
35 |
String json = SearchUtils.fetchContext("/category/concept/"+codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2], production);
|
|
36 | 36 |
level3 = getSubLabel(json, codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2], codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]+"::"+codeParts[3],((codeParts.length>4)?(codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]+"::"+codeParts[3]+"::"+codeParts[4]):null)); |
37 | 37 |
} |
38 | 38 |
|
... | ... | |
173 | 173 |
} |
174 | 174 |
|
175 | 175 |
public static void main(String[] args) throws Exception { |
176 |
System.out.println(ContextUtils.extractLabel("egi::classification::natsc::math::applied")); |
|
176 |
// System.out.println(ContextUtils.extractLabel("egi::classification::natsc::math::applied", false)); |
|
177 |
System.out.println(ContextUtils.extractLabel("aginfra::projects::10", false)); |
|
178 |
|
|
177 | 179 |
} |
178 | 180 |
} |
Also available in: Unified diff
Parameterize context utils methods with a boolean parameter for productionIndex, add production url
In delete claims method add check for deleting record