1 |
28540
|
michele.ar
|
package eu.dnetlib.functionality.modular.ui.lightui.clients;
|
2 |
|
|
|
3 |
28965
|
andrea.man
|
import java.util.ArrayList;
|
4 |
28540
|
michele.ar
|
import java.util.List;
|
5 |
|
|
|
6 |
42659
|
sandro.lab
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
7 |
|
|
import eu.dnetlib.functionality.modular.ui.lightui.menu.LightUiMenuEntry;
|
8 |
|
|
import eu.dnetlib.rmi.enabling.ISLookUpException;
|
9 |
|
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
10 |
28540
|
michele.ar
|
import org.apache.commons.logging.Log;
|
11 |
|
|
import org.apache.commons.logging.LogFactory;
|
12 |
42659
|
sandro.lab
|
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
28540
|
michele.ar
|
|
14 |
42659
|
sandro.lab
|
public class ISLookupLightUIClient {
|
15 |
28540
|
michele.ar
|
|
16 |
42659
|
sandro.lab
|
private static final Log log = LogFactory.getLog(ISLookupLightUIClient.class);
|
17 |
|
|
@Autowired
|
18 |
32597
|
andrea.man
|
private UniqueServiceLocator serviceLocator;
|
19 |
|
|
|
20 |
28540
|
michele.ar
|
public List<LightUiMenuEntry> listMenuEntries() {
|
21 |
28965
|
andrea.man
|
final String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') order by $x//UI_NAME "
|
22 |
|
|
+ "return concat ($x//UI_NAME/@id, '§§§', $x//UI_NAME, '§§§', $x//UI_DESCRIPTION)";
|
23 |
42659
|
sandro.lab
|
List<LightUiMenuEntry> result = new ArrayList<>();
|
24 |
28540
|
michele.ar
|
try {
|
25 |
32597
|
andrea.man
|
List<String> uiProfiles = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQuery);
|
26 |
28965
|
andrea.man
|
int i = 1;
|
27 |
|
|
for (String profile : uiProfiles) {
|
28 |
|
|
String[] tokens = profile.split("§§§");
|
29 |
|
|
result.add(new LightUiMenuEntry(tokens[0].trim(), tokens[1].trim(), tokens[1].trim(), tokens[2].trim(), i++));
|
30 |
|
|
}
|
31 |
|
|
return result;
|
32 |
|
|
} catch (ISLookUpException e) {
|
33 |
28540
|
michele.ar
|
log.error("Error calculating lightui menu entries", e);
|
34 |
28965
|
andrea.man
|
return result;
|
35 |
28540
|
michele.ar
|
}
|
36 |
|
|
}
|
37 |
32597
|
andrea.man
|
|
38 |
42659
|
sandro.lab
|
public String getLightUiProfile(final String lightuiId) throws ISLookUpException {
|
39 |
28965
|
andrea.man
|
String xQuery = "for $x in collection('/db/DRIVER/LightUiDSResources/LightUiDSResourceType') where $x//UI_NAME/@id = '{id}' return $x";
|
40 |
32597
|
andrea.man
|
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery.replace("{id}", lightuiId));
|
41 |
28540
|
michele.ar
|
}
|
42 |
|
|
|
43 |
|
|
}
|