1
|
package eu.dnetlib.data.transformation.ui;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.stream.Collectors;
|
5
|
|
6
|
import javax.annotation.Resource;
|
7
|
|
8
|
import org.springframework.stereotype.Component;
|
9
|
|
10
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
11
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
12
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
13
|
|
14
|
@Component
|
15
|
public class TransformerUtils {
|
16
|
|
17
|
@Resource
|
18
|
private UniqueServiceLocator serviceLocator;
|
19
|
|
20
|
public List<SelectOption> obtainRuleProfiles(final String currentId) throws ISLookUpException {
|
21
|
final String xquery = "for $x " +
|
22
|
"in collection('/db/DRIVER/TransformationRuleDSResources/TransformationRuleDSResourceType') " +
|
23
|
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//TITLE)";
|
24
|
|
25
|
return serviceLocator.getService(ISLookUpService.class)
|
26
|
.quickSearchProfile(xquery)
|
27
|
.stream()
|
28
|
.map(s -> {
|
29
|
final String[] arr = s.split("@@@");
|
30
|
final String id = arr[0].trim();
|
31
|
final String name = arr[1].trim();
|
32
|
return new SelectOption(id, name, id.equals(currentId));
|
33
|
})
|
34
|
.sorted()
|
35
|
.collect(Collectors.toList());
|
36
|
|
37
|
}
|
38
|
}
|