Revision 45768
Added by Michele Artini almost 8 years ago
modules/dnet-springboot-apps/trunk/dnet-is-application/src/main/java/eu/dnetlib/enabling/is/controller/DatasourceManagerController.java | ||
---|---|---|
1 |
package eu.dnetlib.enabling.is.controller; |
|
2 |
|
|
3 |
import org.springframework.beans.factory.annotation.Autowired; |
|
4 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
5 |
import org.springframework.web.bind.annotation.RestController; |
|
6 |
|
|
7 |
import eu.dnetlib.clients.dsManager.DsManagerClient; |
|
8 |
import eu.dnetlib.enabling.annotations.DnetService; |
|
9 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
|
10 |
import eu.dnetlib.services.BaseService; |
|
11 |
|
|
12 |
@RestController |
|
13 |
@RequestMapping("/dsManager") |
|
14 |
@DnetService(DnetServiceType.dsManager) |
|
15 |
public class DatasourceManagerController extends BaseService { |
|
16 |
|
|
17 |
@Autowired |
|
18 |
private DsManagerClient core; |
|
19 |
|
|
20 |
// TODO |
|
21 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/AbstractRepoModule.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
import java.util.stream.Collectors; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
|
|
10 |
import com.google.gson.Gson; |
|
11 |
|
|
12 |
import eu.dnetlib.administration.uis.modules.UIModule; |
|
13 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
14 |
import eu.dnetlib.clients.msro.MsroClient; |
|
15 |
import eu.dnetlib.clients.msro.ProtocolParameter; |
|
16 |
import eu.dnetlib.exceptions.InformationServiceException; |
|
17 |
|
|
18 |
public abstract class AbstractRepoModule extends UIModule { |
|
19 |
|
|
20 |
private final Map<String, List<ProtocolParameter>> parametersMap = new HashMap<>(); |
|
21 |
|
|
22 |
@Autowired |
|
23 |
private InformationServiceClient isClient; |
|
24 |
|
|
25 |
@Autowired |
|
26 |
private MsroClient msroClient; |
|
27 |
|
|
28 |
protected List<VocabularyEntry> fetchVocabularyTerms(final String voc) throws InformationServiceException { |
|
29 |
final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '" |
|
30 |
+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)"; |
|
31 |
|
|
32 |
return isClient.find(xquery) |
|
33 |
.stream() |
|
34 |
.map(s -> s.split("@@@")) |
|
35 |
.map(arr -> new VocabularyEntry(arr[0].trim(), arr[1].trim())) |
|
36 |
.sorted() |
|
37 |
.collect(Collectors.toList()); |
|
38 |
} |
|
39 |
|
|
40 |
protected String fetchVocabularyTermsAsJson(final String voc) throws InformationServiceException { |
|
41 |
return (new Gson()).toJson(fetchVocabularyTerms(voc)); |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
protected List<ProtocolParameter> listParametersForProtocol(final String protocol) { |
|
46 |
return getMapProtocolParameters().get(protocol.toLowerCase()); |
|
47 |
} |
|
48 |
|
|
49 |
protected Map<String, List<ProtocolParameter>> getMapProtocolParameters() { |
|
50 |
if (parametersMap.isEmpty()) { |
|
51 |
msroClient.listProtocols().forEach(d -> parametersMap.put(d.getName().toLowerCase(), d.getParams())); |
|
52 |
} |
|
53 |
return parametersMap; |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/RepoHIWorkflow.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import eu.dnetlib.miscutils.collections.Pair; |
|
7 |
|
|
8 |
public class RepoHIWorkflow implements Comparable<RepoHIWorkflow> { |
|
9 |
|
|
10 |
private final String id; |
|
11 |
private final String name; |
|
12 |
private final String description; |
|
13 |
private final Set<String> ifaceTypes; |
|
14 |
private final Set<String> compliances; |
|
15 |
private List<Pair<String, String>> fields; |
|
16 |
|
|
17 |
public RepoHIWorkflow(final String id, final String name, final String description, final Set<String> ifaceTypes, final Set<String> compliances, |
|
18 |
final List<Pair<String, String>> fields) { |
|
19 |
this.id = id; |
|
20 |
this.name = name; |
|
21 |
this.description = description; |
|
22 |
this.ifaceTypes = ifaceTypes; |
|
23 |
this.compliances = compliances; |
|
24 |
this.fields = fields; |
|
25 |
} |
|
26 |
|
|
27 |
public String getId() { |
|
28 |
return id; |
|
29 |
} |
|
30 |
|
|
31 |
public String getName() { |
|
32 |
return name; |
|
33 |
} |
|
34 |
|
|
35 |
public String getDescription() { |
|
36 |
return description; |
|
37 |
} |
|
38 |
|
|
39 |
public Set<String> getIfaceTypes() { |
|
40 |
return ifaceTypes; |
|
41 |
} |
|
42 |
|
|
43 |
public Set<String> getCompliances() { |
|
44 |
return compliances; |
|
45 |
} |
|
46 |
|
|
47 |
public List<Pair<String, String>> getFields() { |
|
48 |
return fields; |
|
49 |
} |
|
50 |
|
|
51 |
public void setFields(final List<Pair<String, String>> fields) { |
|
52 |
this.fields = fields; |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public int compareTo(final RepoHIWorkflow o) { |
|
57 |
return getName().compareTo(o.getName()); |
|
58 |
} |
|
59 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/RepoWorkflowEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
public class RepoWorkflowEntry implements Comparable<RepoWorkflowEntry> { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String name; |
|
7 |
private String status; |
|
8 |
private String destroyWorkflow; |
|
9 |
private int progress; |
|
10 |
|
|
11 |
public RepoWorkflowEntry(final String id, final String name, final String status, final String destroyWorkflow, final int progress) { |
|
12 |
this.id = id; |
|
13 |
this.name = name; |
|
14 |
this.status = status; |
|
15 |
this.destroyWorkflow = destroyWorkflow; |
|
16 |
this.progress = progress; |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
public int compareTo(final RepoWorkflowEntry o) { |
|
21 |
return getName().compareTo(o.getName()); |
|
22 |
} |
|
23 |
|
|
24 |
public String getId() { |
|
25 |
return id; |
|
26 |
} |
|
27 |
|
|
28 |
public String getName() { |
|
29 |
return name; |
|
30 |
} |
|
31 |
|
|
32 |
public String getStatus() { |
|
33 |
return status; |
|
34 |
} |
|
35 |
|
|
36 |
public String getDestroyWorkflow() { |
|
37 |
return destroyWorkflow; |
|
38 |
} |
|
39 |
|
|
40 |
public int getProgress() { |
|
41 |
return progress; |
|
42 |
} |
|
43 |
|
|
44 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/AddRepoModule.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import org.springframework.beans.factory.annotation.Autowired; |
|
4 |
import org.springframework.ui.ModelMap; |
|
5 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
6 |
import org.springframework.web.bind.annotation.RestController; |
|
7 |
|
|
8 |
import eu.dnetlib.administration.uis.annotations.Authorization; |
|
9 |
import eu.dnetlib.administration.uis.annotations.MenuEntry; |
|
10 |
import eu.dnetlib.administration.uis.annotations.MenuGroup; |
|
11 |
import eu.dnetlib.administration.uis.annotations.PermissionLevel; |
|
12 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
13 |
|
|
14 |
@RestController |
|
15 |
@RequestMapping("/ajax/newRepo") |
|
16 |
@MenuEntry(value = "Add new datasource", order = 10, urlSection = "newRepo") |
|
17 |
@MenuGroup(value = "DataSource Management", order = 5) |
|
18 |
@Authorization(PermissionLevel.DS_ADMIN) |
|
19 |
public class AddRepoModule extends AbstractRepoModule { |
|
20 |
|
|
21 |
@Autowired |
|
22 |
private InformationServiceClient isClient; |
|
23 |
|
|
24 |
@Autowired |
|
25 |
private DatasourceVocabularies vocs; |
|
26 |
|
|
27 |
@Override |
|
28 |
public void populateModelMap(final ModelMap map) throws Exception { |
|
29 |
map.addAttribute("types", fetchVocabularyTermsAsJson(vocs.getDsTypes())); |
|
30 |
map.addAttribute("countries", fetchVocabularyTermsAsJson(vocs.getCountries())); |
|
31 |
} |
|
32 |
|
|
33 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/RepoInternalController.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import javax.annotation.Resource; |
|
8 |
|
|
9 |
import org.apache.commons.lang3.StringUtils; |
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
|
13 |
import org.springframework.stereotype.Controller; |
|
14 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
15 |
import org.springframework.web.bind.annotation.RequestParam; |
|
16 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
17 |
|
|
18 |
import com.google.gson.Gson; |
|
19 |
|
|
20 |
import eu.dnetlib.clients.dsManager.BrowseTerm; |
|
21 |
import eu.dnetlib.clients.dsManager.DatasourceDesc; |
|
22 |
import eu.dnetlib.clients.dsManager.DatasourcePoint; |
|
23 |
import eu.dnetlib.clients.dsManager.DsManagerClient; |
|
24 |
import eu.dnetlib.clients.dsManager.IfaceDesc; |
|
25 |
import eu.dnetlib.clients.dsManager.SearchInterfacesEntry; |
|
26 |
import eu.dnetlib.clients.dsManager.SimpleDatasourceDesc; |
|
27 |
import eu.dnetlib.clients.is.InformationServiceClient; |
|
28 |
import eu.dnetlib.clients.msro.MsroClient; |
|
29 |
import eu.dnetlib.clients.msro.ProtocolParameterValue; |
|
30 |
import eu.dnetlib.exceptions.DnetGenericException; |
|
31 |
import net.sf.ehcache.Cache; |
|
32 |
import net.sf.ehcache.Element; |
|
33 |
|
|
34 |
@Controller |
|
35 |
public class RepoInternalController { |
|
36 |
|
|
37 |
private static final Log log = LogFactory.getLog(RepoInternalController.class); |
|
38 |
|
|
39 |
@Autowired |
|
40 |
private DsManagerClient dsManager; |
|
41 |
|
|
42 |
@Autowired |
|
43 |
private InformationServiceClient isClient; |
|
44 |
|
|
45 |
@Autowired |
|
46 |
private MsroClient msroClient; |
|
47 |
|
|
48 |
@Resource(name = "repoUIJsonCache") |
|
49 |
private Cache repoUIJsonCache; // TODO: https://spring.io/guides/gs/caching/ , rimuovere la dipendenza da ehcache in common-utils |
|
50 |
|
|
51 |
@RequestMapping(value = "/ui/browseRepoField.do") |
|
52 |
public @ResponseBody List<BrowseTerm> browseRepoField(@RequestParam(value = "field", required = true) final String field) throws Exception { |
|
53 |
return dsManager.browseField(field); |
|
54 |
} |
|
55 |
|
|
56 |
@SuppressWarnings("unchecked") |
|
57 |
@RequestMapping(value = "/ui/listApis.do") |
|
58 |
public @ResponseBody List<SearchInterfacesEntry> listApis( |
|
59 |
@RequestParam(value = "param", required = true) final String param, |
|
60 |
@RequestParam(value = "value", required = true) final String value, |
|
61 |
@RequestParam(value = "refresh", required = false) final String refresh) throws Exception { |
|
62 |
|
|
63 |
final String cacheKey = "list@@@" + param + "@@@" + value; |
|
64 |
|
|
65 |
final Element elem = repoUIJsonCache.get(cacheKey); |
|
66 |
|
|
67 |
if ((elem != null) && (refresh == null)) { |
|
68 |
return (List<SearchInterfacesEntry>) elem.getObjectValue(); |
|
69 |
} else { |
|
70 |
log.info("Refreshing " + cacheKey + " cache..."); |
|
71 |
final List<SearchInterfacesEntry> list = dsManager.searchInterface(param, value); |
|
72 |
repoUIJsonCache.put(new Element(cacheKey, list)); |
|
73 |
return list; |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
@RequestMapping(value = "/ui/listRepositories.map") |
|
78 |
public @ResponseBody List<DatasourcePoint> listRepositories_asMap() throws Exception { |
|
79 |
return dsManager.getRepositoryMap(); |
|
80 |
} |
|
81 |
|
|
82 |
@RequestMapping(value = "/ui/listRepositories.json") |
|
83 |
public @ResponseBody List<SimpleDatasourceDesc> listRepositories(@RequestParam(value = "type", required = true) final String type) throws Exception { |
|
84 |
return dsManager.simpleListDatasourcesByType(type); |
|
85 |
} |
|
86 |
|
|
87 |
@SuppressWarnings("unchecked") |
|
88 |
@RequestMapping("/ui/repo/repoApi.update") |
|
89 |
public @ResponseBody boolean updateRepoApi( |
|
90 |
@RequestParam(value = "id", required = true) final String repoId, |
|
91 |
@RequestParam(value = "iface", required = true) final String ifaceId, |
|
92 |
@RequestParam(value = "accessParams", required = true) final String accessParamsJson) throws Exception { |
|
93 |
if (!StringUtils.isEmpty(accessParamsJson)) { |
|
94 |
dsManager.bulkUpdateApiAccessParams(repoId, ifaceId, new Gson().fromJson(accessParamsJson, Map.class)); |
|
95 |
} |
|
96 |
return true; |
|
97 |
} |
|
98 |
|
|
99 |
@RequestMapping("/ui/repo/repoApiCompliance.update") |
|
100 |
public @ResponseBody boolean updateRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId, |
|
101 |
@RequestParam(value = "iface", required = true) final String ifaceId, |
|
102 |
@RequestParam(value = "compliance", required = true) final String compliance) throws Exception { |
|
103 |
|
|
104 |
log.debug("SET COMPLIANCE TO " + compliance); |
|
105 |
|
|
106 |
dsManager.overrideCompliance(repoId, ifaceId, compliance); |
|
107 |
|
|
108 |
repoUIJsonCache.removeAll(); |
|
109 |
|
|
110 |
return true; |
|
111 |
} |
|
112 |
|
|
113 |
@RequestMapping("/ui/repo/repoApiCompliance.reset") |
|
114 |
public @ResponseBody boolean resetRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId, |
|
115 |
@RequestParam(value = "iface", required = true) final String ifaceId) throws Exception { |
|
116 |
|
|
117 |
log.debug("RESET COMPLIANCE"); |
|
118 |
|
|
119 |
dsManager.overrideCompliance(repoId, ifaceId, null); |
|
120 |
|
|
121 |
repoUIJsonCache.removeAll(); |
|
122 |
|
|
123 |
return true; |
|
124 |
} |
|
125 |
|
|
126 |
@RequestMapping("/ui/repoApi.new") |
|
127 |
public @ResponseBody boolean addRepoApi(@RequestParam(value = "repoId", required = true) final String repoId, |
|
128 |
@RequestParam(value = "iface", required = true) final String ifaceJson) throws DnetGenericException { |
|
129 |
final IfaceDesc iface = new Gson().fromJson(ifaceJson, IfaceDesc.class); |
|
130 |
|
|
131 |
log.info("Adding interface " + iface.getId() + " to repository " + repoId); |
|
132 |
|
|
133 |
return dsManager.addInterface(repoId, iface); |
|
134 |
} |
|
135 |
|
|
136 |
@RequestMapping("/ui/repo.new") |
|
137 |
public @ResponseBody boolean addRepoApi(@RequestParam(value = "repo", required = true) final String repoJson) throws DnetGenericException { |
|
138 |
final DatasourceDesc ds = new Gson().fromJson(repoJson, DatasourceDesc.class); |
|
139 |
ds.setDateOfCollection(new Date()); |
|
140 |
|
|
141 |
if (StringUtils.isBlank(ds.getEnglishName())) { |
|
142 |
ds.setEnglishName(ds.getOfficialName()); |
|
143 |
} |
|
144 |
|
|
145 |
log.info("Adding datasource " + ds.getId() + " - name " + ds.getOfficialName()); |
|
146 |
|
|
147 |
return dsManager.addDatasource(ds); |
|
148 |
} |
|
149 |
|
|
150 |
@RequestMapping("/ui/listValidValuesForParam.do") |
|
151 |
public @ResponseBody List<ProtocolParameterValue> listValidValuesForParam( |
|
152 |
@RequestParam(value = "protocol", required = true) final String protocol, |
|
153 |
@RequestParam(value = "param", required = true) final String param, |
|
154 |
@RequestParam(value = "baseUrl", required = true) final String baseUrl) throws DnetGenericException { |
|
155 |
|
|
156 |
return msroClient.listValidValuesForParam(protocol, baseUrl, param, null); |
|
157 |
} |
|
158 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/RepoApisModule.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import org.springframework.beans.factory.annotation.Autowired; |
|
4 |
import org.springframework.ui.ModelMap; |
|
5 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
6 |
import org.springframework.web.bind.annotation.RestController; |
|
7 |
|
|
8 |
import com.google.gson.Gson; |
|
9 |
|
|
10 |
import eu.dnetlib.administration.uis.annotations.Authorization; |
|
11 |
import eu.dnetlib.administration.uis.annotations.MenuEntry; |
|
12 |
import eu.dnetlib.administration.uis.annotations.MenuGroup; |
|
13 |
import eu.dnetlib.administration.uis.annotations.PermissionLevel; |
|
14 |
import eu.dnetlib.clients.dsManager.DsManagerClient; |
|
15 |
|
|
16 |
@RestController |
|
17 |
@RequestMapping("/ajax/apis") |
|
18 |
@MenuEntry(value = "Overview", order = 1, urlSection = "apis") |
|
19 |
@MenuGroup(value = "DataSource Management", order = 5) |
|
20 |
@Authorization(PermissionLevel.DS_ADMIN) |
|
21 |
public class RepoApisModule extends AbstractRepoModule { |
|
22 |
|
|
23 |
@Autowired |
|
24 |
private DsManagerClient dsManager; |
|
25 |
|
|
26 |
@Autowired |
|
27 |
private DatasourceVocabularies vocs; |
|
28 |
|
|
29 |
@Override |
|
30 |
public void populateModelMap(final ModelMap map) throws Exception { |
|
31 |
final Gson gson = new Gson(); |
|
32 |
map.addAttribute("compatibilityLevels", fetchVocabularyTermsAsJson(vocs.getCompatibilityLevels())); |
|
33 |
map.addAttribute("browseFields", gson.toJson(dsManager.listBrowsableFields())); |
|
34 |
} |
|
35 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/VocabularyEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
public class VocabularyEntry implements Comparable<VocabularyEntry> { |
|
4 |
|
|
5 |
private String name; |
|
6 |
private String desc; |
|
7 |
|
|
8 |
public VocabularyEntry() {} |
|
9 |
|
|
10 |
public VocabularyEntry(final String name, final String desc) { |
|
11 |
this.name = name; |
|
12 |
this.desc = desc; |
|
13 |
} |
|
14 |
|
|
15 |
public String getName() { |
|
16 |
return name; |
|
17 |
} |
|
18 |
|
|
19 |
public void setName(final String name) { |
|
20 |
this.name = name; |
|
21 |
} |
|
22 |
|
|
23 |
public String getDesc() { |
|
24 |
return desc; |
|
25 |
} |
|
26 |
|
|
27 |
public void setDesc(final String desc) { |
|
28 |
this.desc = desc; |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public int compareTo(final VocabularyEntry o) { |
|
33 |
return getName().compareTo(o.getName()); |
|
34 |
} |
|
35 |
|
|
36 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/DatasourceVocabularies.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import javax.validation.constraints.NotNull; |
|
4 |
|
|
5 |
import org.springframework.boot.context.properties.ConfigurationProperties; |
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
|
|
8 |
@Component |
|
9 |
@ConfigurationProperties(prefix = "ds.vocabulary") |
|
10 |
public class DatasourceVocabularies { |
|
11 |
|
|
12 |
@NotNull |
|
13 |
private String dsTypes; |
|
14 |
@NotNull |
|
15 |
private String compatibilityLevels; |
|
16 |
@NotNull |
|
17 |
private String contentDescriptions; |
|
18 |
@NotNull |
|
19 |
private String protocols; |
|
20 |
@NotNull |
|
21 |
private String countries; |
|
22 |
|
|
23 |
public String getDsTypes() { |
|
24 |
return dsTypes; |
|
25 |
} |
|
26 |
|
|
27 |
public void setDsTypes(final String dsTypes) { |
|
28 |
this.dsTypes = dsTypes; |
|
29 |
} |
|
30 |
|
|
31 |
public String getCompatibilityLevels() { |
|
32 |
return compatibilityLevels; |
|
33 |
} |
|
34 |
|
|
35 |
public void setCompatibilityLevels(final String compatibilityLevels) { |
|
36 |
this.compatibilityLevels = compatibilityLevels; |
|
37 |
} |
|
38 |
|
|
39 |
public String getContentDescriptions() { |
|
40 |
return contentDescriptions; |
|
41 |
} |
|
42 |
|
|
43 |
public void setContentDescriptions(final String contentDescriptions) { |
|
44 |
this.contentDescriptions = contentDescriptions; |
|
45 |
} |
|
46 |
|
|
47 |
public String getProtocols() { |
|
48 |
return protocols; |
|
49 |
} |
|
50 |
|
|
51 |
public void setProtocols(final String protocols) { |
|
52 |
this.protocols = protocols; |
|
53 |
} |
|
54 |
|
|
55 |
public String getCountries() { |
|
56 |
return countries; |
|
57 |
} |
|
58 |
|
|
59 |
public void setCountries(final String countries) { |
|
60 |
this.countries = countries; |
|
61 |
} |
|
62 |
|
|
63 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/SimpleParamEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
public class SimpleParamEntry implements Comparable<SimpleParamEntry> { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String name; |
|
7 |
private Object value; |
|
8 |
private Object otherValue; |
|
9 |
|
|
10 |
public SimpleParamEntry(final String name, final Object value) { |
|
11 |
this(name, name, value, null); |
|
12 |
} |
|
13 |
|
|
14 |
public SimpleParamEntry(final String id, final String name, final Object value) { |
|
15 |
this(id, name, value, null); |
|
16 |
} |
|
17 |
|
|
18 |
public SimpleParamEntry(final String id, final String name, final Object value, final Object otherValue) { |
|
19 |
this.id = id; |
|
20 |
this.name = name; |
|
21 |
this.value = value; |
|
22 |
setOtherValue(otherValue); |
|
23 |
} |
|
24 |
|
|
25 |
public String getId() { |
|
26 |
return id; |
|
27 |
} |
|
28 |
|
|
29 |
public void setId(final String id) { |
|
30 |
this.id = id; |
|
31 |
} |
|
32 |
|
|
33 |
public Object getValue() { |
|
34 |
return value; |
|
35 |
} |
|
36 |
|
|
37 |
public void setValue(final Object value) { |
|
38 |
this.value = value; |
|
39 |
} |
|
40 |
|
|
41 |
public String getName() { |
|
42 |
return name; |
|
43 |
} |
|
44 |
|
|
45 |
public void setName(final String name) { |
|
46 |
this.name = name; |
|
47 |
} |
|
48 |
|
|
49 |
public Object getOtherValue() { |
|
50 |
return otherValue; |
|
51 |
} |
|
52 |
|
|
53 |
public void setOtherValue(final Object otherValue) { |
|
54 |
this.otherValue = otherValue; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public int compareTo(final SimpleParamEntry o) { |
|
59 |
return getName().compareTo(o.getName()); |
|
60 |
} |
|
61 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/repos/AddRepoApiModule.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.repos; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
import java.util.stream.Collectors; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
import org.springframework.ui.ModelMap; |
|
10 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
11 |
import org.springframework.web.bind.annotation.RestController; |
|
12 |
|
|
13 |
import com.google.gson.Gson; |
|
14 |
|
|
15 |
import eu.dnetlib.administration.uis.annotations.Authorization; |
|
16 |
import eu.dnetlib.administration.uis.annotations.MenuEntry; |
|
17 |
import eu.dnetlib.administration.uis.annotations.MenuGroup; |
|
18 |
import eu.dnetlib.administration.uis.annotations.PermissionLevel; |
|
19 |
import eu.dnetlib.clients.msro.ProtocolDescriptor; |
|
20 |
import eu.dnetlib.clients.msro.ProtocolParameter; |
|
21 |
import eu.dnetlib.exceptions.InformationServiceException; |
|
22 |
|
|
23 |
@RestController |
|
24 |
@RequestMapping("/ajax/newApi") |
|
25 |
@MenuEntry(value = "Add new API", urlSection = "newApi", order = 20) |
|
26 |
@MenuGroup(value = "DataSource Management", order = 5) |
|
27 |
@Authorization(PermissionLevel.DS_ADMIN) |
|
28 |
public class AddRepoApiModule extends AbstractRepoModule { |
|
29 |
|
|
30 |
@Autowired |
|
31 |
private DatasourceVocabularies vocs; |
|
32 |
|
|
33 |
@Override |
|
34 |
public void populateModelMap(final ModelMap map) throws Exception { |
|
35 |
map.addAttribute("types", fetchVocabularyTermsAsJson(vocs.getDsTypes())); |
|
36 |
map.addAttribute("compliances", fetchVocabularyTermsAsJson(vocs.getCompatibilityLevels())); |
|
37 |
map.addAttribute("contentDescriptions", fetchVocabularyTermsAsJson(vocs.getContentDescriptions())); |
|
38 |
map.addAttribute("protocols", listProtocolsAsJson()); |
|
39 |
} |
|
40 |
|
|
41 |
private String listProtocolsAsJson() throws InformationServiceException { |
|
42 |
final Map<String, List<ProtocolParameter>> mapParams = getMapProtocolParameters(); |
|
43 |
|
|
44 |
return (new Gson()).toJson(fetchVocabularyTerms(vocs.getProtocols()) |
|
45 |
.stream() |
|
46 |
.map(e -> { |
|
47 |
final ProtocolDescriptor pd = new ProtocolDescriptor(); |
|
48 |
pd.setName(e.getName()); |
|
49 |
if (mapParams.containsKey(e.getName().toLowerCase().trim())) { |
|
50 |
pd.setParams(mapParams.get(e.getName().toLowerCase().trim())); |
|
51 |
} else { |
|
52 |
pd.setParams(new ArrayList<ProtocolParameter>()); |
|
53 |
} |
|
54 |
return pd; |
|
55 |
}).collect(Collectors.toList())); |
|
56 |
} |
|
57 |
|
|
58 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/application.properties | ||
---|---|---|
11 | 11 |
ui.ribbonAccent = turquoise |
12 | 12 |
ui.authorization = mock |
13 | 13 |
|
14 |
spring.velocity.dateToolAttribute = dateTool |
|
14 |
spring.velocity.dateToolAttribute = dateTool |
|
15 |
|
|
16 |
ds.vocabulary.dsTypes = dnet:datasource_typologies |
|
17 |
ds.vocabulary.compatibilityLevels = dnet:compatibilityLevels |
|
18 |
ds.vocabulary.countries = dnet:countries |
|
19 |
ds.vocabulary.contentDescriptions = dnet:content_description_typologies |
|
20 |
ds.vocabulary.protocols = dnet:protocols |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/enabling/annotations/DnetServiceType.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.enabling.annotations; |
2 | 2 |
|
3 | 3 |
public enum DnetServiceType { |
4 |
is, hcm, msro, msroWorker, mdstore, objstore, index, dbService |
|
4 |
is, hcm, msro, msroWorker, mdstore, objstore, index, dbService, dsManager
|
|
5 | 5 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/MsroClient.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.springframework.stereotype.Component; |
|
6 |
|
|
7 |
import eu.dnetlib.enabling.annotations.DnetServiceClient; |
|
8 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
|
9 |
|
|
10 |
@Component |
|
11 |
@DnetServiceClient(DnetServiceType.msro) |
|
12 |
public class MsroClient { |
|
13 |
|
|
14 |
public List<ProtocolParameterValue> listValidValuesForParam(final String protocol, final String baseUrl, final String param, final Object object) { |
|
15 |
// TODO Auto-generated method stub |
|
16 |
return null; |
|
17 |
} |
|
18 |
|
|
19 |
public List<ProtocolDescriptor> listProtocols() { |
|
20 |
// TODO Auto-generated method stub |
|
21 |
return null; |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/ProtocolParameterValue.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
|
|
4 |
public class ProtocolParameterValue { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/ProtocolDescriptor.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public class ProtocolDescriptor { |
|
6 |
|
|
7 |
private String name; |
|
8 |
private List<ProtocolParameter> params; |
|
9 |
|
|
10 |
public ProtocolDescriptor() {} |
|
11 |
|
|
12 |
public ProtocolDescriptor(final String name, final List<ProtocolParameter> params) { |
|
13 |
this.name = name; |
|
14 |
this.params = params; |
|
15 |
} |
|
16 |
|
|
17 |
public String getName() { |
|
18 |
return name; |
|
19 |
} |
|
20 |
|
|
21 |
public void setName(final String name) { |
|
22 |
this.name = name; |
|
23 |
} |
|
24 |
|
|
25 |
public List<ProtocolParameter> getParams() { |
|
26 |
return params; |
|
27 |
} |
|
28 |
|
|
29 |
public void setParams(final List<ProtocolParameter> params) { |
|
30 |
this.params = params; |
|
31 |
} |
|
32 |
|
|
33 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/ProtocolParameter.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
|
|
4 |
public class ProtocolParameter { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/DsManagerClient.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
|
|
8 |
@Component |
|
9 |
public class DsManagerClient { |
|
10 |
|
|
11 |
public List<BrowsableField> listBrowsableFields() { |
|
12 |
return null; |
|
13 |
} |
|
14 |
|
|
15 |
public List<BrowseTerm> browseField(final String field) { |
|
16 |
return null; |
|
17 |
} |
|
18 |
|
|
19 |
public List<SearchInterfacesEntry> searchInterface(final String param, final String value) { |
|
20 |
return null; |
|
21 |
} |
|
22 |
|
|
23 |
public List<DatasourcePoint> getRepositoryMap() { |
|
24 |
return null; |
|
25 |
} |
|
26 |
|
|
27 |
public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) { |
|
28 |
return null; |
|
29 |
} |
|
30 |
|
|
31 |
public void bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, Object> fromJson) {} |
|
32 |
|
|
33 |
public void overrideCompliance(final String repoId, final String ifaceId, final String compliance) {} |
|
34 |
|
|
35 |
public boolean addInterface(final String repoId, final IfaceDesc iface) { |
|
36 |
return false; |
|
37 |
} |
|
38 |
|
|
39 |
public boolean addDatasource(final DatasourceDesc ds) { |
|
40 |
return false; |
|
41 |
} |
|
42 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/SimpleDatasourceDesc.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
|
|
4 |
public class SimpleDatasourceDesc { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/BrowsableField.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
|
|
4 |
public class BrowsableField { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/DatasourcePoint.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
|
|
4 |
public class DatasourcePoint { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/IfaceDesc.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
public class IfaceDesc { |
|
4 |
|
|
5 |
public String getId() { |
|
6 |
// TODO Auto-generated method stub |
|
7 |
return null; |
|
8 |
} |
|
9 |
|
|
10 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/BrowseTerm.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
|
|
4 |
public class BrowseTerm { |
|
5 |
|
|
6 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/DatasourceDesc.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
public class DatasourceDesc { |
|
6 |
|
|
7 |
public void setDateOfCollection(final Date date) { |
|
8 |
// TODO Auto-generated method stub |
|
9 |
|
|
10 |
} |
|
11 |
|
|
12 |
public CharSequence getEnglishName() { |
|
13 |
// TODO Auto-generated method stub |
|
14 |
return null; |
|
15 |
} |
|
16 |
|
|
17 |
public String getId() { |
|
18 |
// TODO Auto-generated method stub |
|
19 |
return null; |
|
20 |
} |
|
21 |
|
|
22 |
public Object getOfficialName() { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
return null; |
|
25 |
} |
|
26 |
|
|
27 |
public void setEnglishName(final Object officialName) { |
|
28 |
// TODO Auto-generated method stub |
|
29 |
|
|
30 |
} |
|
31 |
|
|
32 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/dsManager/SearchInterfacesEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.dsManager; |
|
2 |
|
|
3 |
|
|
4 |
public class SearchInterfacesEntry { |
|
5 |
|
|
6 |
} |
Also available in: Unified diff