Project

General

Profile

« Previous | Next » 

Revision 45877

View differences:

modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/datasources/AbstractDsModule.java
49 49

  
50 50
		final Map<String, List<ProtocolParameter>> res = new HashMap<>();
51 51

  
52
		for (final String s : isClient.find("for $x in collection('/dv/DRIVER/dnetService/msroWorker')//COLLECTOR_PLUGINS return $x")) {
52
		for (final String s : isClient.find("for $x in collection('/db/DRIVER/dnetService/msroWorker')//COLLECTOR_PLUGINS/PLUGIN return $x")) {
53 53
			try {
54 54
				final Document doc = reader.read(new StringReader(s));
55
				for (final Object o : doc.selectNodes("//PLUGIN")) {
56
					final String protocol = ((Element) o).valueOf("@protocol");
57
					if (!res.containsKey(protocol)) {
58
						res.put(protocol, new ArrayList<>());
59
						for (final Object o1 : doc.selectNodes("./PARAM")) {
60
							final String name = ((Element) o1).valueOf("@name");
61
							final boolean optional = "true".equalsIgnoreCase(((Element) o1).valueOf("@optional"));
62
							final String type = ((Element) o1).valueOf("@type");
63
							final String regex = ((Element) o1).valueOf("@regex");
64
							res.get(protocol).add(new ProtocolParameter(name, optional, type, regex));
65
						}
55
				final String protocol = doc.valueOf("/PLUGIN/@protocol").trim().toLowerCase();
56
				if (!res.containsKey(protocol)) {
57
					res.put(protocol, new ArrayList<>());
58
					for (final Object o : doc.selectNodes("/PLUGIN/PARAM")) {
59
						final String name = ((Element) o).valueOf("@name");
60
						final boolean optional = "true".equalsIgnoreCase(((Element) o).valueOf("@optional"));
61
						final String type = ((Element) o).valueOf("@type");
62
						final String regex = ((Element) o).valueOf("@regex");
63
						res.get(protocol).add(new ProtocolParameter(name, optional, type, regex));
66 64
					}
67 65
				}
68 66
			} catch (final Exception e) {
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/datasources/ProtocolDescriptor.java
1 1
package eu.dnetlib.administration.uis.modules.datasources;
2 2

  
3
import java.util.ArrayList;
3 4
import java.util.List;
4 5

  
5 6
public class ProtocolDescriptor {
6 7

  
7 8
	private String name;
8
	private List<ProtocolParameter> params;
9
	private List<ProtocolParameter> params = new ArrayList<>();
9 10

  
10 11
	public ProtocolDescriptor() {}
11 12

  
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/datasources/AddApiModule.java
1 1
package eu.dnetlib.administration.uis.modules.datasources;
2 2

  
3
import java.util.ArrayList;
4 3
import java.util.List;
5 4
import java.util.Map;
6 5
import java.util.stream.Collectors;
......
11 10
import org.springframework.web.bind.annotation.RequestMapping;
12 11
import org.springframework.web.bind.annotation.RestController;
13 12

  
13
import com.google.common.base.Joiner;
14 14
import com.google.gson.Gson;
15 15

  
16 16
import eu.dnetlib.administration.uis.annotations.Authorization;
......
45 45
	private String listProtocolsAsJson() throws InformationServiceException {
46 46
		final Map<String, List<ProtocolParameter>> mapParams = getMapProtocolParameters();
47 47

  
48
		System.out.println("MAPPARAMS : " + Joiner.on(",").join(mapParams.keySet()));
49

  
48 50
		return (new Gson()).toJson(fetchVocabularyTerms(vocs.getProtocols())
49 51
				.stream()
50 52
				.map(e -> {
......
52 54
					pd.setName(e.getName());
53 55
					if (mapParams.containsKey(e.getName().toLowerCase().trim())) {
54 56
						pd.setParams(mapParams.get(e.getName().toLowerCase().trim()));
55
					} else {
56
						pd.setParams(new ArrayList<ProtocolParameter>());
57 57
					}
58 58
					return pd;
59 59
				}).collect(Collectors.toList()));

Also available in: Unified diff