Revision 55230
Added by Michele Artini about 5 years ago
DataTransformationController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.transformation.inspector; |
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 |
import java.util.stream.Collectors; |
|
4 | 5 |
|
5 | 6 |
import javax.annotation.Resource; |
6 | 7 |
|
... | ... | |
9 | 10 |
import org.springframework.web.bind.annotation.RequestMapping; |
10 | 11 |
import org.springframework.web.bind.annotation.RequestParam; |
11 | 12 |
|
12 |
import com.google.common.base.Function; |
|
13 |
import com.google.common.collect.Lists; |
|
14 |
|
|
15 | 13 |
import eu.dnetlib.data.transformation.service.DataTransformerFactory; |
16 | 14 |
import eu.dnetlib.data.transformation.service.SimpleDataTransformer; |
17 | 15 |
import eu.dnetlib.enabling.inspector.AbstractInspectorController; |
... | ... | |
28 | 26 |
@Resource |
29 | 27 |
private UniqueServiceLocator serviceLocator; |
30 | 28 |
|
31 |
public static class SelectOption { |
|
29 |
public static class SelectOption implements Comparable<SelectOption> {
|
|
32 | 30 |
|
33 |
private String id; |
|
34 |
private String name; |
|
35 |
private boolean selected; |
|
31 |
private final String id;
|
|
32 |
private final String name;
|
|
33 |
private final boolean selected;
|
|
36 | 34 |
|
37 | 35 |
public SelectOption(final String id, final String name, final boolean selected) { |
38 | 36 |
this.id = id; |
... | ... | |
51 | 49 |
public boolean isSelected() { |
52 | 50 |
return selected; |
53 | 51 |
} |
52 |
|
|
53 |
@Override |
|
54 |
public int compareTo(final SelectOption o) { |
|
55 |
return getName().toLowerCase().compareTo(o.getName().toLowerCase()); |
|
56 |
} |
|
54 | 57 |
} |
55 | 58 |
|
56 | 59 |
@RequestMapping(value = "/inspector/transform.do") |
... | ... | |
68 | 71 |
} |
69 | 72 |
|
70 | 73 |
private List<SelectOption> obtainRuleProfiles(final String currentId) throws ISLookUpException { |
71 |
String xquery = "for $x " + |
|
74 |
final String xquery = "for $x " +
|
|
72 | 75 |
"in collection('/db/DRIVER/TransformationRuleDSResources/TransformationRuleDSResourceType') " + |
73 | 76 |
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//TITLE)"; |
74 | 77 |
|
75 |
return Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery), new Function<String, SelectOption>() { |
|
78 |
return serviceLocator.getService(ISLookUpService.class) |
|
79 |
.quickSearchProfile(xquery) |
|
80 |
.stream() |
|
81 |
.map(s -> { |
|
82 |
final String[] arr = s.split("@@@"); |
|
83 |
final String id = arr[0].trim(); |
|
84 |
final String name = arr[1].trim(); |
|
85 |
return new SelectOption(id, name, id.equals(currentId)); |
|
86 |
}) |
|
87 |
.sorted() |
|
88 |
.collect(Collectors.toList()); |
|
76 | 89 |
|
77 |
@Override |
|
78 |
public SelectOption apply(final String value) { |
|
79 |
final String[] arr = value.split("@@@"); |
|
80 |
final String id = arr[0].trim(); |
|
81 |
final String name = arr[1].trim(); |
|
82 |
return new SelectOption(id, name, id.equals(currentId)); |
|
83 |
} |
|
84 |
}); |
|
85 | 90 |
} |
86 | 91 |
} |
Also available in: Unified diff
Sort transformation scripts alphabetically