Project

General

Profile

« Previous | Next » 

Revision 55097

[maven-release-plugin] copy for tag dnet-modular-repositories-ui-4.0.23

View differences:

modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-repositories-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-repositories-ui"}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoApisEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import java.io.StringReader;
4
import java.util.ArrayList;
5
import java.util.Collections;
6
import java.util.List;
7
import java.util.Set;
8

  
9
import javax.annotation.Resource;
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletResponse;
12

  
13
import org.dom4j.Document;
14
import org.dom4j.Node;
15
import org.dom4j.io.SAXReader;
16
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.beans.factory.annotation.Required;
18
import org.springframework.ui.ModelMap;
19

  
20
import com.google.common.base.Splitter;
21
import com.google.common.collect.Lists;
22
import com.google.common.collect.Sets;
23
import com.google.gson.Gson;
24

  
25
import eu.dnetlib.enabling.datasources.common.Api;
26
import eu.dnetlib.enabling.datasources.common.Datasource;
27
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager;
28
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
29
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
30
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
31
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
32
import eu.dnetlib.miscutils.collections.Pair;
33

  
34
public class RepoApisEntryPointController extends ModuleEntryPoint {
35

  
36
	@Resource
37
	private UniqueServiceLocator serviceLocator;
38

  
39
	@Resource
40
	private RepoUIUtils repoUIUtils;
41

  
42
	private String compatibilityLevelsVocabulary;
43

  
44
	private String validatorAddress;
45
	private String validatorServiceAddress;
46

  
47
	@Autowired
48
	private LocalDatasourceManager<Datasource<?, ?>, Api<?>> dsManager;
49

  
50
	public class RepoHIWorkflow implements Comparable<RepoHIWorkflow> {
51

  
52
		private final String id;
53
		private final String name;
54
		private final Set<String> ifaceTypes;
55
		private final Set<String> compliances;
56
		private List<Pair<String, String>> fields;
57

  
58
		/**
59
		 * Instantiates a new repo hi workflow.
60
		 *
61
		 * @param id
62
		 *            the id
63
		 * @param name
64
		 *            the name
65
		 * @param ifaceTypes
66
		 *            the iface types
67
		 * @param compliances
68
		 *            the compliances
69
		 * @param fields
70
		 *            the fields
71
		 */
72
		public RepoHIWorkflow(final String id, final String name, final Set<String> ifaceTypes, final Set<String> compliances,
73
				final List<Pair<String, String>> fields) {
74
			super();
75
			this.id = id;
76
			this.name = name;
77
			this.ifaceTypes = ifaceTypes;
78
			this.compliances = compliances;
79
			this.fields = fields;
80
		}
81

  
82
		public String getId() {
83
			return id;
84
		}
85

  
86
		public String getName() {
87
			return name;
88
		}
89

  
90
		public Set<String> getIfaceTypes() {
91
			return ifaceTypes;
92
		}
93

  
94
		public Set<String> getCompliances() {
95
			return compliances;
96
		}
97

  
98
		@Override
99
		public int compareTo(final RepoHIWorkflow o) {
100
			return getName().compareTo(o.getName());
101
		}
102

  
103
		/**
104
		 * @return the fields
105
		 */
106
		public List<Pair<String, String>> getFields() {
107
			return fields;
108
		}
109

  
110
		/**
111
		 * @param fields
112
		 *            the fields to set
113
		 */
114
		public void setFields(final List<Pair<String, String>> fields) {
115
			this.fields = fields;
116
		}
117

  
118
	}
119

  
120
	private RepoHIWorkflow parseQuery(final String input) {
121
		final SAXReader reader = new SAXReader();
122
		try {
123
			final Document doc = reader.read(new StringReader(input));
124

  
125
			final String id = doc.valueOf("//id");
126
			final String name = doc.valueOf("//name");
127
			final String type = doc.valueOf("//types");
128
			final String compliance = doc.valueOf("//compliances");
129
			final Set<String> ifcTypes = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(type));
130
			final Set<String> compliances = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(compliance));
131

  
132
			final List<Pair<String, String>> fields = new ArrayList<>();
133
			for (final Object o : doc.selectNodes(".//FIELD")) {
134
				final Node currentNode = (Node) o;
135
				final String key = currentNode.valueOf("@name");
136
				final String value = currentNode.getText();
137
				fields.add(new Pair<>(key, value));
138
			}
139
			return new RepoHIWorkflow(id, name, ifcTypes, compliances, fields);
140
		} catch (final Exception e) {
141
			return null;
142
		}
143
	}
144

  
145
	private List<RepoHIWorkflow> listRepoHIWorkflows() throws ISLookUpException {
146

  
147
		final String xquery =
148
				"for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') where $x//WORKFLOW_TYPE='REPO_HI' return <result> <id>{$x//RESOURCE_IDENTIFIER/@value/string()}</id> <name>{$x//WORKFLOW_NAME/text()}</name> <types>{$x//PARAM[@name='expectedInterfaceTypologyPrefixes']/text()}</types> <compliances>{$x//PARAM[@name='expectedCompliancePrefixes']/text()}</compliances> {$x//FIELD} </result>";
149
		final List<RepoHIWorkflow> list = Lists.newArrayList();
150
		for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
151
			final RepoHIWorkflow repoHiInfo = parseQuery(s);
152
			if (repoHiInfo != null) {
153
				list.add(repoHiInfo);
154
			}
155
		}
156
		Collections.sort(list);
157
		return list;
158
	}
159

  
160
	@Override
161
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
162
		final Gson gson = new Gson();
163
		map.addAttribute("availableRepohiWfs", gson.toJson(listRepoHIWorkflows()));
164
		map.addAttribute("compatibilityLevels", gson.toJson(repoUIUtils.fetchVocabularyTerms(getCompatibilityLevelsVocabulary())));
165
		map.addAttribute("browseFields", gson.toJson(dsManager.listBrowsableFields()));
166
		map.addAttribute("validatorAddress", getValidatorAddress());
167
		map.addAttribute("validatorServiceAddress", getValidatorServiceAddress());
168
	}
169

  
170
	public String getCompatibilityLevelsVocabulary() {
171
		return compatibilityLevelsVocabulary;
172
	}
173

  
174
	@Required
175
	public void setCompatibilityLevelsVocabulary(final String compatibilityLevelsVocabulary) {
176
		this.compatibilityLevelsVocabulary = compatibilityLevelsVocabulary;
177
	}
178

  
179
	public String getValidatorAddress() {
180
		return validatorAddress;
181
	}
182

  
183
	@Required
184
	public void setValidatorAddress(final String validatorAddress) {
185
		this.validatorAddress = validatorAddress;
186
	}
187

  
188
	public String getValidatorServiceAddress() {
189
		return validatorServiceAddress;
190
	}
191

  
192
	@Required
193
	public void setValidatorServiceAddress(final String validatorServiceAddress) {
194
		this.validatorServiceAddress = validatorServiceAddress;
195
	}
196

  
197
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepositoriesGoogleMapEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5

  
6
import org.springframework.ui.ModelMap;
7

  
8
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
9

  
10
@Deprecated
11
public class RepositoriesGoogleMapEntryPointController extends ModuleEntryPoint {
12

  
13
	@Override
14
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {}
15

  
16
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoUIUtils.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import java.io.StringReader;
4
import java.util.Collections;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Set;
8

  
9
import javax.annotation.Resource;
10

  
11
import org.antlr.stringtemplate.StringTemplate;
12
import org.apache.commons.io.IOUtils;
13
import org.apache.commons.lang.StringEscapeUtils;
14
import org.apache.commons.lang.math.NumberUtils;
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.dom4j.Document;
18
import org.dom4j.Node;
19
import org.dom4j.io.SAXReader;
20
import org.springframework.core.io.ClassPathResource;
21

  
22
import com.google.common.collect.Lists;
23
import com.google.common.collect.Maps;
24
import com.google.common.collect.Sets;
25

  
26
import eu.dnetlib.data.collector.rmi.CollectorService;
27
import eu.dnetlib.data.collector.rmi.ProtocolDescriptor;
28
import eu.dnetlib.data.collector.rmi.ProtocolParameter;
29
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
30
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
31
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
32
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoInterfaceEntry;
33
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoMetaWfEntry;
34
import eu.dnetlib.functionality.modular.ui.repositories.objects.SimpleParamEntry;
35
import eu.dnetlib.functionality.modular.ui.repositories.objects.VocabularyEntry;
36
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus;
37

  
38
public class RepoUIUtils {
39

  
40
	@Resource
41
	private UniqueServiceLocator serviceLocator;
42

  
43
	private final ClassPathResource getRepoApiQueryTmpl =
44
			new ClassPathResource("/eu/dnetlib/functionality/modular/ui/repositories/templates/getRepoApi.xquery.st");
45

  
46
	private static final Log log = LogFactory.getLog(RepoUIUtils.class);
47

  
48
	private final Map<String, List<ProtocolParameter>> parametersMap = Maps.newHashMap();
49

  
50
	public RepoInterfaceEntry getApi(final String repoId, final String ifaceId) throws Exception {
51
		final RepoInterfaceEntry ifc = new RepoInterfaceEntry();
52

  
53
		final StringTemplate st = new StringTemplate(IOUtils.toString(getRepoApiQueryTmpl.getInputStream()));
54
		st.setAttribute("dsId", repoId);
55
		st.setAttribute("ifaceId", ifaceId);
56

  
57
		final String query = st.toString();
58

  
59
		final SAXReader reader = new SAXReader();
60

  
61
		final String s = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query);
62

  
63
		final Document doc = reader.read(new StringReader(s));
64

  
65
		ifc.setId(doc.valueOf("/api/id"));
66
		ifc.setLabel(doc.valueOf("/api/label"));
67
		ifc.setRemovable(doc.valueOf("/api/removable").equalsIgnoreCase("true") && doc.selectNodes("//metaWF").isEmpty());
68
		ifc.setRepoId(doc.valueOf("/api/repo/@id"));
69
		ifc.setRepoName(StringEscapeUtils.unescapeHtml(doc.valueOf("/api/repo")));
70
		ifc.setRepoCountry(doc.valueOf("/api/repo/@country"));
71
		ifc.setRepoPrefix(doc.valueOf("/api/repo/@prefix"));
72
		ifc.setRepoType(doc.valueOf("/api/repo/@type"));
73
		ifc.setEmail(doc.valueOf("/api/repo/@email"));
74
		final String protocol = doc.valueOf("/api/protocol");
75
		ifc.setProtocol(protocol);
76

  
77
		final Set<String> toVerifyParams = getParameterNamesForProtocol(ifc.getProtocol());
78
		for (final Object o : doc.selectNodes("/api/commonParams/param")) {
79
			final Node n = (Node) o;
80
			ifc.getCommonParams().add(new SimpleParamEntry(n.valueOf("@name"), n.getText()));
81
		}
82

  
83
		log.debug("****** " + toVerifyParams);
84
		for (final Object o : doc.selectNodes("/api/accessParams/param")) {
85
			final Node n = (Node) o;
86
			final String pname = n.valueOf("@name");
87
			if (toVerifyParams.contains(pname)) {
88
				ifc.getAccessParams().add(new SimpleParamEntry(pname, n.getText()));
89
				toVerifyParams.remove(pname);
90
			} else {
91
				log.warn("Invalid param [" + pname + "] for protocol " + protocol + " in repo " + repoId);
92
			}
93
		}
94
		for (final String pname : toVerifyParams) {
95
			ifc.getAccessParams().add(new SimpleParamEntry(pname, ""));
96
			log.info("Adding missing param [" + pname + "] for protocol " + protocol + " in repo " + repoId);
97
		}
98

  
99
		for (final Object o : doc.selectNodes("/api/extraFields/field")) {
100
			final Node n = (Node) o;
101
			final String name = n.valueOf("@name");
102
			final String value = n.getText();
103
			if (name.equalsIgnoreCase("overriding_compliance")) {
104
				for (final SimpleParamEntry e : ifc.getCommonParams()) {
105
					if (e.getName().equals("compliance")) {
106
						// The original compliance (assigned by the validator) is stored in otherValue
107
						e.setOtherValue(value);
108
					}
109
				}
110
			} else if (name.equalsIgnoreCase("last_aggregation_date")) {
111
				ifc.setAggrDate(value);
112
			} else if (name.equalsIgnoreCase("last_aggregation_total")) {
113
				ifc.setAggrTotal(NumberUtils.toInt(value, 0));
114
			} else if (name.equalsIgnoreCase("last_aggregation_mdId")) {
115
				ifc.setAggrMdId(value);
116
			} else if (name.equalsIgnoreCase("last_collection_date")) {
117
				ifc.setCollDate(value);
118
			} else if (name.equalsIgnoreCase("last_collection_total")) {
119
				ifc.setCollTotal(NumberUtils.toInt(value, 0));
120
			} else if (name.equalsIgnoreCase("last_collection_mdId")) {
121
				ifc.setCollMdId(value);
122
			} else if (name.equalsIgnoreCase("last_download_date")) {
123
				ifc.setDownloadDate(value);
124
			} else if (name.equalsIgnoreCase("last_download_total")) {
125
				ifc.setDownloadTotal(NumberUtils.toInt(value, 0));
126
			} else if (name.equalsIgnoreCase("last_download_objId")) {
127
				ifc.setDownloadObjId(value);
128
			} else {
129
				ifc.getOtherParams().add(new SimpleParamEntry(name, value));
130
			}
131
		}
132

  
133
		if (doc.selectNodes("/api/extraFields/field[@name='metadata_identifier_path']").isEmpty()) {
134
			ifc.getOtherParams().add(new SimpleParamEntry("metadata_identifier_path", ""));
135
		}
136

  
137
		for (final Object o : doc.selectNodes("//metaWF")) {
138
			final Node n = (Node) o;
139

  
140
			final String id = n.valueOf("./id");
141
			final String name = n.valueOf("./name");
142
			final String status = n.valueOf("./status");
143
			final String repoByeWfId = n.valueOf("./destroyWorkflow");
144

  
145
			int progress = 0;
146
			try {
147
				switch (WorkflowStatus.valueOf(status)) {
148
				case MISSING:
149
					progress = 0;
150
					break;
151
				case ASSIGNED:
152
					progress = 25;
153
					break;
154
				case WAIT_SYS_SETTINGS:
155
					progress = 50;
156
					break;
157
				case WAIT_USER_SETTINGS:
158
					progress = 75;
159
					break;
160
				case EXECUTABLE:
161
					progress = 100;
162
					break;
163
				}
164
			} catch (final Exception e) {
165
				progress = 0;
166
			}
167
			ifc.getMetaWFs().add(new RepoMetaWfEntry(id, name, status, repoByeWfId, progress));
168
		}
169

  
170
		return ifc;
171
	}
172

  
173
	public List<VocabularyEntry> fetchVocabularyTerms(final String voc) throws ISLookUpException {
174
		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
175
				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
176

  
177
		final List<VocabularyEntry> list = Lists.newArrayList();
178
		for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
179
			final String[] arr = s.split("@@@");
180
			list.add(new VocabularyEntry(arr[0].trim(), arr[1].trim()));
181
		}
182
		Collections.sort(list);
183

  
184
		return list;
185
	}
186

  
187
	private Set<String> getParameterNamesForProtocol(final String protocol) {
188
		if (parametersMap.isEmpty()) {
189
			for (final ProtocolDescriptor d : serviceLocator.getService(CollectorService.class).listProtocols()) {
190
				parametersMap.put(d.getName().toLowerCase(), d.getParams());
191
			}
192
		}
193
		final Set<String> res = Sets.newHashSet();
194
		if (parametersMap.containsKey(protocol.toLowerCase())) {
195
			res.add("baseUrl");
196
			for (final ProtocolParameter p : parametersMap.get(protocol.toLowerCase())) {
197
				res.add(p.getName());
198
			}
199
		}
200

  
201
		return res;
202
	}
203

  
204
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoInternalController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import java.io.StringReader;
4
import java.util.Date;
5
import java.util.List;
6
import java.util.Map;
7

  
8
import javax.annotation.Resource;
9
import javax.servlet.http.HttpServletRequest;
10
import javax.servlet.http.HttpServletResponse;
11

  
12
import org.apache.commons.io.IOUtils;
13
import org.apache.commons.lang.StringUtils;
14
import org.apache.commons.lang.exception.ExceptionUtils;
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.cache.annotation.CacheEvict;
19
import org.springframework.cache.annotation.Cacheable;
20
import org.springframework.http.HttpStatus;
21
import org.springframework.stereotype.Controller;
22
import org.springframework.ui.ModelMap;
23
import org.springframework.web.bind.annotation.ExceptionHandler;
24
import org.springframework.web.bind.annotation.RequestMapping;
25
import org.springframework.web.bind.annotation.RequestParam;
26
import org.springframework.web.bind.annotation.ResponseBody;
27
import org.springframework.web.bind.annotation.ResponseStatus;
28

  
29
import com.google.common.collect.Maps;
30
import com.google.gson.Gson;
31
import com.google.gson.reflect.TypeToken;
32

  
33
import eu.dnetlib.data.collector.rmi.CollectorService;
34
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
35
import eu.dnetlib.data.collector.rmi.ProtocolParameterValue;
36
import eu.dnetlib.enabling.datasources.common.Api;
37
import eu.dnetlib.enabling.datasources.common.ApiParam;
38
import eu.dnetlib.enabling.datasources.common.ApiParamImpl;
39
import eu.dnetlib.enabling.datasources.common.BrowseTerm;
40
import eu.dnetlib.enabling.datasources.common.Datasource;
41
import eu.dnetlib.enabling.datasources.common.DsmException;
42
import eu.dnetlib.enabling.datasources.common.Identity;
43
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager;
44
import eu.dnetlib.enabling.datasources.common.Organization;
45
import eu.dnetlib.enabling.datasources.common.SearchApisEntry;
46
import eu.dnetlib.enabling.datasources.common.SimpleDatasource;
47
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
48
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
49
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
50
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
51
import eu.dnetlib.functionality.modular.ui.error.ErrorMessage;
52
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoInterfaceEntry;
53
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper;
54
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
55
import eu.dnetlib.msro.workflows.sarasvati.loader.WorkflowExecutor;
56
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
57

  
58
@Controller
59
public class RepoInternalController {
60

  
61
	@Autowired
62
	private LocalDatasourceManager<Datasource<?, ?>, Api<?>> dsManager;
63

  
64
	@Resource
65
	private UniqueServiceLocator serviceLocator;
66

  
67
	@Resource
68
	private WorkflowSectionGrouper workflowSectionGrouper;
69

  
70
	@Resource
71
	private WorkflowExecutor workflowExecutor;
72

  
73
	@Resource
74
	private RepoUIUtils repoUIUtils;
75

  
76
	private static final Log log = LogFactory.getLog(RepoInternalController.class);
77

  
78
	@RequestMapping(value = "/ui/browseRepoField.do")
79
	public @ResponseBody List<? extends BrowseTerm> browseRepoField(@RequestParam(value = "field", required = true) final String field) throws Exception {
80
		return dsManager.browseField(field);
81
	}
82

  
83
	@Cacheable(cacheNames = "repoUIJsonCache", key = "#param, #value", condition = "#refresh == false")
84
	@RequestMapping(value = "/ui/listApis.do")
85
	public @ResponseBody List<? extends SearchApisEntry> listApis(
86
			@RequestParam(value = "param", required = true) final String param,
87
			@RequestParam(value = "value", required = true) final String value,
88
			@RequestParam(value = "refresh", required = false) final String refresh) throws Exception {
89

  
90
		return dsManager.searchApis(param, value);
91
	}
92

  
93
	@RequestMapping(value = "/ui/listRepositories.json")
94
	public @ResponseBody List<SimpleDatasource> listRepositories(@RequestParam(value = "type", required = true) final String type) throws Exception {
95
		return dsManager.searchDatasourcesByType(type);
96
	}
97

  
98
	@CacheEvict("repoUIJsonCache")
99
	@RequestMapping(value = "/ui/validateRepo.do")
100
	public @ResponseBody String listRepositories(@RequestParam(value = "id", required = true) final String id,
101
			@RequestParam(value = "b", required = true) final boolean b) throws Exception {
102

  
103
		final String query = "count(/*[.//RESOURCE_TYPE/@value='MetaWorkflowDSResourceType' and .//DATAPROVIDER/@id='" + id + "'])";
104
		if (!b && Integer.parseInt(serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query)) > 0) { throw new Exception("Repo " + id
105
				+ " can be invalidated: it is related to some metawfs"); }
106

  
107
		final String newId = b ? serviceLocator.getService(ISRegistryService.class).validateProfile(id)
108
				: serviceLocator.getService(ISRegistryService.class).invalidateProfile(id);
109

  
110
		return newId;
111
	}
112

  
113
	@RequestMapping(value = "/ui/getRepoDetails.do")
114
	public void getRepoDetails(final HttpServletResponse response, @RequestParam(value = "id", required = true) final String id) throws Exception {
115
		String profile;
116
		try {
117
			profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(id);
118
		} catch (final ISLookUpDocumentNotFoundException e) {
119
			profile = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
120
					"collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')/*[.//DATASOURCE_ORIGINAL_ID='" + id + "']");
121
		}
122

  
123
		final ApplyXslt xslt = new ApplyXslt(IOUtils.toString(getClass().getResourceAsStream(
124
				"/eu/dnetlib/functionality/modular/ui/repositories/xslt/repoDetails.xslt")));
125

  
126
		IOUtils.copy(new StringReader(xslt.evaluate(profile)), response.getOutputStream());
127
	}
128

  
129
	@RequestMapping("/ui/repoMetaWf.new")
130
	public @ResponseBody String newDataProviderWorkflow(@RequestParam(value = "id", required = true) final String repoId,
131
			@RequestParam(value = "name", required = true) final String repoName,
132
			@RequestParam(value = "iface", required = true) final String ifaceId,
133
			@RequestParam(value = "wf", required = true) final String wfId) throws Exception {
134

  
135
		final Map<String, Object> params = Maps.newHashMap();
136
		params.put(WorkflowsConstants.DATAPROVIDER_ID, repoId);
137
		params.put(WorkflowsConstants.DATAPROVIDER_NAME, repoName);
138
		params.put(WorkflowsConstants.DATAPROVIDER_INTERFACE, ifaceId);
139

  
140
		return workflowExecutor.startProcess(wfId, params);
141
	}
142

  
143
	@RequestMapping("/ui/repoMetaWf.destroy")
144
	public @ResponseBody String destroyDataProviderWorkflow(@RequestParam(value = "destroyWf", required = true) final String destroyWfId)
145
			throws Exception {
146
		return workflowExecutor.startProcess(destroyWfId, null);
147
	}
148

  
149
	@RequestMapping("/ui/repoApi.get")
150
	public @ResponseBody RepoInterfaceEntry getRepoApi(@RequestParam(value = "repoId", required = true) final String repoId,
151
			@RequestParam(value = "ifaceId", required = true) final String ifaceId) throws Exception {
152
		return repoUIUtils.getApi(repoId, ifaceId);
153
	}
154

  
155
	@RequestMapping("/ui/repoApi.update")
156
	public @ResponseBody boolean updateRepoApi(
157
			@RequestParam(value = "id", required = true) final String repoId,
158
			@RequestParam(value = "iface", required = true) final String ifaceId,
159
			@RequestParam(value = "accessParams", required = false) final String accessParamsJson,
160
			@RequestParam(value = "mdIdPath", required = false) final String mdIdPath) throws Exception {
161

  
162
		if (!StringUtils.isEmpty(accessParamsJson)) {
163
			final Map<String, String> params = new Gson().fromJson(accessParamsJson, new TypeToken<Map<String, String>>() {}.getType());
164
			final String baseUrl = params.remove("baseUrl");
165
			dsManager.updateApiDetails(repoId, ifaceId, mdIdPath, baseUrl, params);
166
		}
167

  
168
		return true;
169
	}
170

  
171
	@RequestMapping("/ui/repoApi.delete")
172
	public @ResponseBody boolean updateRepoApi(
173
			@RequestParam(value = "repo", required = true) final String repoId,
174
			@RequestParam(value = "iface", required = true) final String ifaceId) throws Exception {
175
		dsManager.deleteApi(repoId, ifaceId);
176
		return true;
177
	}
178

  
179
	@CacheEvict("repoUIJsonCache")
180
	@RequestMapping("/ui/repoApiCompliance.update")
181
	public @ResponseBody boolean updateRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId,
182
			@RequestParam(value = "iface", required = true) final String ifaceId,
183
			@RequestParam(value = "compliance", required = true) final String compliance) throws Exception {
184

  
185
		log.debug("SET COMPLIANCE TO " + compliance);
186

  
187
		dsManager.updateCompliance(repoId, ifaceId, compliance, true);
188

  
189
		return true;
190
	}
191

  
192
	@CacheEvict("repoUIJsonCache")
193
	@RequestMapping("/ui/repoApiCompliance.reset")
194
	public @ResponseBody boolean resetRepoApiCompliance(@RequestParam(value = "id", required = true) final String repoId,
195
			@RequestParam(value = "iface", required = true) final String ifaceId) throws Exception {
196

  
197
		log.debug("RESET COMPLIANCE");
198

  
199
		dsManager.updateCompliance(repoId, ifaceId, null, true);
200

  
201
		return true;
202
	}
203

  
204
	@RequestMapping("/ui/repos/repoApi.html")
205
	public void resetRepoApiCompliance(final ModelMap map) throws Exception {}
206

  
207
	@RequestMapping("/ui/repoApi.new")
208
	public @ResponseBody boolean addRepoApi(@RequestParam(value = "repoId", required = true) final String repoId,
209
			@RequestParam(value = "iface", required = true) final String ifaceJson) throws DsmException {
210
		final Api<ApiParam> iface = new Gson().fromJson(ifaceJson, new TypeToken<Api<ApiParamImpl>>() {}.getType());
211

  
212
		iface.setDatasource(repoId);
213

  
214
		log.info("Adding api " + iface.getId() + " to repository " + repoId);
215

  
216
		dsManager.addApi(iface);
217

  
218
		return true;
219
	}
220

  
221
	@RequestMapping("/ui/repo.new")
222
	public @ResponseBody boolean addRepoApi(@RequestParam(value = "repo", required = true) final String repoJson) throws DsmException {
223
		final Datasource<Organization<?>, Identity> ds = new Gson().fromJson(repoJson, new TypeToken<Datasource<Organization<?>, Identity>>() {}.getType());
224
		final Date now = new Date();
225
		ds.setDateofcollection(new java.sql.Date(now.getTime()));
226

  
227
		if (StringUtils.isBlank(ds.getEnglishname())) {
228
			ds.setEnglishname(ds.getOfficialname());
229
		}
230

  
231
		log.info("Adding datasource " + ds.getId() + " - name " + ds.getOfficialname());
232

  
233
		dsManager.saveDs(ds);
234

  
235
		return true;
236
	}
237

  
238
	@RequestMapping("/ui/listValidValuesForParam.do")
239
	public @ResponseBody List<ProtocolParameterValue> listValidValuesForParam(
240
			@RequestParam(value = "protocol", required = true) final String protocol,
241
			@RequestParam(value = "param", required = true) final String param,
242
			@RequestParam(value = "baseUrl", required = true) final String baseUrl) throws CollectorServiceException {
243

  
244
		return serviceLocator.getService(CollectorService.class).listValidValuesForParam(protocol, baseUrl, param, null);
245
	}
246

  
247
	@ExceptionHandler(Exception.class)
248
	@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
249
	public @ResponseBody ErrorMessage handleException(final HttpServletRequest req, final Exception e) {
250
		log.error("Error processing " + req.getRequestURI(), e);
251
		return new ErrorMessage(e.getMessage(), ExceptionUtils.getStackTrace(e));
252
	}
253

  
254
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/AddRepoApiEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

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

  
7
import javax.annotation.Resource;
8
import javax.servlet.http.HttpServletRequest;
9
import javax.servlet.http.HttpServletResponse;
10

  
11
import org.springframework.beans.factory.annotation.Required;
12
import org.springframework.ui.ModelMap;
13

  
14
import com.google.common.base.Function;
15
import com.google.common.collect.Lists;
16
import com.google.common.collect.Maps;
17
import com.google.gson.Gson;
18

  
19
import eu.dnetlib.data.collector.rmi.CollectorService;
20
import eu.dnetlib.data.collector.rmi.ProtocolDescriptor;
21
import eu.dnetlib.data.collector.rmi.ProtocolParameter;
22
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
23
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
24
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
25
import eu.dnetlib.functionality.modular.ui.repositories.objects.VocabularyEntry;
26

  
27
public class AddRepoApiEntryPointController extends ModuleEntryPoint {
28

  
29
	private String datasourceTypeVocabulary;
30
	private String complianceVocabulary;
31
	private String contentDescriptionsVocabulary;
32
	private String protocolsVocabulary;
33

  
34
	@Resource
35
	private UniqueServiceLocator serviceLocator;
36

  
37
	@Resource
38
	private RepoUIUtils repoUIUtils;
39

  
40
	@Override
41
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
42
		final Gson gson = new Gson();
43
		map.addAttribute("types", gson.toJson(repoUIUtils.fetchVocabularyTerms(datasourceTypeVocabulary)));
44
		map.addAttribute("compliances", gson.toJson(repoUIUtils.fetchVocabularyTerms(complianceVocabulary)));
45
		map.addAttribute("contentDescriptions", gson.toJson(repoUIUtils.fetchVocabularyTerms(contentDescriptionsVocabulary)));
46
		map.addAttribute("protocols", gson.toJson(listProtocols()));
47
	}
48

  
49
	private List<ProtocolDescriptor> listProtocols() throws ISLookUpException {
50
		final Map<String, List<ProtocolParameter>> mapParams = Maps.newHashMap();
51
		for (ProtocolDescriptor pd : serviceLocator.getService(CollectorService.class).listProtocols()) {
52
			mapParams.put(pd.getName().trim().toLowerCase(), pd.getParams());
53
		}
54

  
55
		return Lists.transform(repoUIUtils.fetchVocabularyTerms(protocolsVocabulary), new Function<VocabularyEntry, ProtocolDescriptor>() {
56

  
57
			@Override
58
			public ProtocolDescriptor apply(final VocabularyEntry e) {
59
				final ProtocolDescriptor pd = new ProtocolDescriptor();
60
				pd.setName(e.getName());
61
				if (mapParams.containsKey(e.getName().toLowerCase().trim())) {
62
					pd.setParams(mapParams.get(e.getName().toLowerCase().trim()));
63
				} else {
64
					pd.setParams(new ArrayList<ProtocolParameter>());
65
				}
66
				return pd;
67
			}
68

  
69
		});
70
	}
71

  
72
	public String getDatasourceTypeVocabulary() {
73
		return datasourceTypeVocabulary;
74
	}
75

  
76
	@Required
77
	public void setDatasourceTypeVocabulary(final String datasourceTypeVocabulary) {
78
		this.datasourceTypeVocabulary = datasourceTypeVocabulary;
79
	}
80

  
81
	public String getComplianceVocabulary() {
82
		return complianceVocabulary;
83
	}
84

  
85
	@Required
86
	public void setComplianceVocabulary(final String complianceVocabulary) {
87
		this.complianceVocabulary = complianceVocabulary;
88
	}
89

  
90
	public String getContentDescriptionsVocabulary() {
91
		return contentDescriptionsVocabulary;
92
	}
93

  
94
	@Required
95
	public void setContentDescriptionsVocabulary(final String contentDescriptionsVocabulary) {
96
		this.contentDescriptionsVocabulary = contentDescriptionsVocabulary;
97
	}
98

  
99
	public String getProtocolsVocabulary() {
100
		return protocolsVocabulary;
101
	}
102

  
103
	@Required
104
	public void setProtocolsVocabulary(final String protocolsVocabulary) {
105
		this.protocolsVocabulary = protocolsVocabulary;
106
	}
107

  
108
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/objects/RepoInterfaceEntry.java
1
package eu.dnetlib.functionality.modular.ui.repositories.objects;
2

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

  
6
import eu.dnetlib.enabling.datasources.common.SearchApisEntry;
7

  
8
public class RepoInterfaceEntry extends SearchApisEntry {
9

  
10
	private String label;
11
	private boolean removable = false;
12
	private String collDate = "";
13
	private int collTotal = 0;
14
	private String collMdId = "";
15
	private String aggrMdId = "";
16
	private String downloadDate = "";
17
	private int downloadTotal = 0;
18
	private String downloadObjId = "";
19
	private String repoType;
20
	private String email;
21
	private List<SimpleParamEntry> commonParams = new ArrayList<>();
22
	private List<SimpleParamEntry> accessParams = new ArrayList<>();
23
	private List<SimpleParamEntry> otherParams = new ArrayList<>();
24
	private List<RepoMetaWfEntry> metaWFs = new ArrayList<>();
25

  
26
	public String getLabel() {
27
		return label;
28
	}
29

  
30
	public void setLabel(final String label) {
31
		this.label = label;
32
	}
33

  
34
	public String getCollDate() {
35
		return collDate;
36
	}
37

  
38
	public void setCollDate(final String collDate) {
39
		this.collDate = collDate;
40
	}
41

  
42
	public int getCollTotal() {
43
		return collTotal;
44
	}
45

  
46
	public void setCollTotal(final int collTotal) {
47
		this.collTotal = collTotal;
48
	}
49

  
50
	public List<SimpleParamEntry> getCommonParams() {
51
		return commonParams;
52
	}
53

  
54
	public void setCommonParams(final List<SimpleParamEntry> commonParams) {
55
		this.commonParams = commonParams;
56
	}
57

  
58
	public List<SimpleParamEntry> getAccessParams() {
59
		return accessParams;
60
	}
61

  
62
	public void setAccessParams(final List<SimpleParamEntry> accessParams) {
63
		this.accessParams = accessParams;
64
	}
65

  
66
	public List<SimpleParamEntry> getOtherParams() {
67
		return otherParams;
68
	}
69

  
70
	public void setOtherParams(final List<SimpleParamEntry> otherParams) {
71
		this.otherParams = otherParams;
72
	}
73

  
74
	public List<RepoMetaWfEntry> getMetaWFs() {
75
		return metaWFs;
76
	}
77

  
78
	public void setMetaWFs(final List<RepoMetaWfEntry> metaWFs) {
79
		this.metaWFs = metaWFs;
80
	}
81

  
82
	public String getAggrMdId() {
83
		return aggrMdId;
84
	}
85

  
86
	public void setAggrMdId(final String aggrMdId) {
87
		this.aggrMdId = aggrMdId;
88
	}
89

  
90
	public String getCollMdId() {
91
		return collMdId;
92
	}
93

  
94
	public void setCollMdId(final String collMdId) {
95
		this.collMdId = collMdId;
96
	}
97

  
98
	public String getDownloadDate() {
99
		return downloadDate;
100
	}
101

  
102
	public void setDownloadDate(final String downloadDate) {
103
		this.downloadDate = downloadDate;
104
	}
105

  
106
	public int getDownloadTotal() {
107
		return downloadTotal;
108
	}
109

  
110
	public void setDownloadTotal(final int downloadTotal) {
111
		this.downloadTotal = downloadTotal;
112
	}
113

  
114
	public String getDownloadObjId() {
115
		return downloadObjId;
116
	}
117

  
118
	public void setDownloadObjId(final String downloadObjId) {
119
		this.downloadObjId = downloadObjId;
120
	}
121

  
122
	public String getRepoType() {
123
		return repoType;
124
	}
125

  
126
	public void setRepoType(final String repoType) {
127
		this.repoType = repoType;
128
	}
129

  
130
	public String getEmail() {
131
		return email;
132
	}
133

  
134
	public void setEmail(final String email) {
135
		this.email = email;
136
	}
137

  
138
	public boolean isRemovable() {
139
		return removable;
140
	}
141

  
142
	public void setRemovable(final boolean removable) {
143
		this.removable = removable;
144
	}
145

  
146
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/objects/VocabularyEntry.java
1
package eu.dnetlib.functionality.modular.ui.repositories.objects;
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-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/objects/RepoMetaWfEntry.java
1
package eu.dnetlib.functionality.modular.ui.repositories.objects;
2

  
3
public class RepoMetaWfEntry implements Comparable<RepoMetaWfEntry> {
4

  
5
	private String id;
6
	private String name;
7
	private String status;
8
	private String destroyWorkflow;
9
	private int progress;
10

  
11
	public RepoMetaWfEntry(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 RepoMetaWfEntry 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-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/objects/SimpleParamEntry.java
1
package eu.dnetlib.functionality.modular.ui.repositories.objects;
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
		this.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

  
50
	public Object getOtherValue() {
51
		return otherValue;
52
	}
53

  
54
	public void setOtherValue(Object otherValue) {
55
		this.otherValue = otherValue;
56
	}
57

  
58
	@Override
59
	public int compareTo(final SimpleParamEntry o) {
60
		return getName().compareTo(o.getName());
61
	}
62
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/AddRepoEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import javax.annotation.Resource;
4
import javax.servlet.http.HttpServletRequest;
5
import javax.servlet.http.HttpServletResponse;
6

  
7
import org.springframework.beans.factory.annotation.Required;
8
import org.springframework.ui.ModelMap;
9

  
10
import com.google.gson.Gson;
11

  
12
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
13
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
14

  
15
public class AddRepoEntryPointController extends ModuleEntryPoint {
16

  
17
	private String datasourceTypeVocabulary;
18
	private String datasourceCountryVocabulary;
19

  
20
	@Resource
21
	private UniqueServiceLocator serviceLocator;
22

  
23
	@Resource
24
	private RepoUIUtils repoUIUtils;
25

  
26
	@Override
27
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
28
		final Gson gson = new Gson();
29
		map.addAttribute("types", gson.toJson(repoUIUtils.fetchVocabularyTerms(datasourceTypeVocabulary)));
30
		map.addAttribute("countries", gson.toJson(repoUIUtils.fetchVocabularyTerms(datasourceCountryVocabulary)));
31
	}
32

  
33
	public String getDatasourceTypeVocabulary() {
34
		return datasourceTypeVocabulary;
35
	}
36

  
37
	@Required
38
	public void setDatasourceTypeVocabulary(final String datasourceTypeVocabulary) {
39
		this.datasourceTypeVocabulary = datasourceTypeVocabulary;
40
	}
41

  
42
	public String getDatasourceCountryVocabulary() {
43
		return datasourceCountryVocabulary;
44
	}
45

  
46
	@Required
47
	public void setDatasourceCountryVocabulary(final String datasourceCountryVocabulary) {
48
		this.datasourceCountryVocabulary = datasourceCountryVocabulary;
49
	}
50

  
51
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoEnablerEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.repositories;
2

  
3
import javax.annotation.Resource;
4
import javax.servlet.http.HttpServletRequest;
5
import javax.servlet.http.HttpServletResponse;
6

  
7
import org.springframework.beans.factory.annotation.Required;
8
import org.springframework.ui.ModelMap;
9

  
10
import com.google.gson.Gson;
11

  
12
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
13

  
14
public class RepoEnablerEntryPointController extends ModuleEntryPoint {
15

  
16
	private String datasourceTypeVocabulary;
17

  
18
	@Resource
19
	private RepoUIUtils repoUIUtils;
20

  
21
	@Override
22
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
23
		map.addAttribute("types", new Gson().toJson(repoUIUtils.fetchVocabularyTerms(getDatasourceTypeVocabulary())));
24
	}
25

  
26
	public String getDatasourceTypeVocabulary() {
27
		return datasourceTypeVocabulary;
28
	}
29

  
30
	@Required
31
	public void setDatasourceTypeVocabulary(final String datasourceTypeVocabulary) {
32
		this.datasourceTypeVocabulary = datasourceTypeVocabulary;
33
	}
34

  
35
}
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/test/profiles/ModularUILabels.xml
1
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="1f3dacf7-2cbb-4b88-9afd-43a3fbd03042_Vm9jYWJ1bGFyeURTUmVzb3VyY2VzL1ZvY2FidWxhcnlEU1Jlc291cmNlVHlwZQ==" />
4
		<RESOURCE_TYPE value="VocabularyDSResourceType" />
5
		<RESOURCE_KIND value="VocabularyDSResources" />
6
		<RESOURCE_URI value="String" />
7
		<DATE_OF_CREATION value="2014-07-10T12:24:17+02:00" />
8
	</HEADER>
9
	<BODY>
10
		<CONFIGURATION>
11
			<VOCABULARY_NAME code="ModularUiLabels">ModularUiLabels</VOCABULARY_NAME>
12
			<VOCABULARY_DESCRIPTION>Labels used by the Modular UI</VOCABULARY_DESCRIPTION>
13
			<TERMS>
14
				<TERM native_name="Pending datasource" code="PendingRepositoryResources" english_name="Pending datasource" encoding="DNET">
15
					<SYNONYMS />
16
					<RELATIONS />
17
				</TERM>
18
				<TERM native_name="Valid datasource" code="RepositoryServiceResources" english_name="Valid datasource" encoding="DNET">
19
					<SYNONYMS />
20
					<RELATIONS />
21
				</TERM>
22
			</TERMS>
23
		</CONFIGURATION>
24
		<STATUS>
25
			<LAST_UPDATE value="2014-07-10T12:24:16+02:00" />
26
		</STATUS>
27
		<SECURITY_PARAMETERS />
28
	</BODY>
29
</RESOURCE_PROFILE>
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/webContext-modular-ui-repositories.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<beans xmlns="http://www.springframework.org/schema/beans"
4
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
6
		
7
	<bean name="/ui/repoApis.do"
8
		class="eu.dnetlib.functionality.modular.ui.repositories.RepoApisEntryPointController"
9
		p:menu="Overview" p:title="DataSource API Management"
10
		p:description="DataSource API configuration page" p:group="DataSource Management"
11
		p:order="5"
12
		p:groupOrder="10"
13
		p:compatibilityLevelsVocabulary="${repo.ui.compatibilityLevels.vocabulary}"
14
		p:validatorAddress="${repo.ui.validator.address}"
15
		p:validatorServiceAddress="${repo.ui.validatorService.address}">
16
		<property name="permissionLevels">
17
			<set>
18
				<value>DS_ADMIN</value>
19
			</set>
20
		</property>
21
	</bean>
22

  
23
	<bean name="/ui/addRepo.do"
24
		class="eu.dnetlib.functionality.modular.ui.repositories.AddRepoEntryPointController"
25
		p:menu="Add new Datasource" p:title="Create a new Datasource"
26
		p:description="Create a new dataSource" p:group="DataSource Management"
27
		p:order="6"
28
		p:groupOrder="10"
29
		p:datasourceTypeVocabulary="${repo.ui.datasourceTypes.vocabulary}"
30
		p:datasourceCountryVocabulary="${repo.ui.datasourceCountries.vocabulary}"
31
		p:validMenuEntry="${repo.ui.addRepo.show}">
32
		<property name="permissionLevels">
33
			<set>
34
				<value>DS_ADMIN</value>
35
			</set>
36
		</property>
37
	</bean>
38
	
39
	<bean name="/ui/addRepoApi.do"
40
		class="eu.dnetlib.functionality.modular.ui.repositories.AddRepoApiEntryPointController"
41
		p:menu="Add new API" p:title="Create a new API"
42
		p:description="Create a new dataSource API" p:group="DataSource Management"
43
		p:order="7"
44
		p:groupOrder="10"
45
		p:datasourceTypeVocabulary="${repo.ui.datasourceTypes.vocabulary}"
46
		p:complianceVocabulary="${repo.ui.compatibilityLevels.vocabulary}"
47
		p:contentDescriptionsVocabulary="${repo.ui.contentDescriptions.vocabulary}"
48
		p:protocolsVocabulary="${repo.ui.protocols.vocabulary}"
49
		p:validMenuEntry="${repo.ui.addApi.show}">
50
		<property name="permissionLevels">
51
			<set>
52
				<value>DS_ADMIN</value>
53
			</set>
54
		</property>
55
	</bean>
56

  
57
	<bean name="/ui/repos.do"
58
		class="eu.dnetlib.functionality.modular.ui.repositories.RepoEnablerEntryPointController"
59
		p:menu="DataSource Enabler" p:title="DataSource Enabler"
60
		p:description="DataSource Enabler" p:group="DataSource Management"
61
		p:order="8"
62
		p:groupOrder="10"
63
		p:datasourceTypeVocabulary="${repo.ui.datasourceTypes.vocabulary}"
64
		p:validMenuEntry="${repo.ui.validation.show}">
65
		<property name="permissionLevels">
66
			<set>
67
				<value>DS_ADMIN</value>
68
			</set>
69
		</property>
70
	</bean>
71

  
72
	<!--<bean name="/ui/reposMap.do"-->
73
		<!--class="eu.dnetlib.functionality.modular.ui.repositories.RepositoriesGoogleMapEntryPointController"-->
74
		<!--p:menu="DataSource Map" p:title="Datasource Map"-->
75
		<!--p:description="The map of the managed datasources" p:group="DataSource Management"-->
76
		<!--p:order="10"-->
77
		<!--p:groupOrder="10">-->
78
		<!--<property name="permissionLevels">-->
79
			<!--<set>-->
80
				<!--<value>USER</value>-->
81
				<!--<value>DS_ADMIN</value>-->
82
			<!--</set>-->
83
		<!--</property>-->
84
	<!--</bean>-->
85
</beans>
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/applicationContext-modular-ui-repositories.properties
1
repo.ui.compatibilityLevels.vocabulary 	= dnet:compatibilityLevel
2
repo.ui.datasourceTypes.vocabulary		= dnet:datasource_typologies
3
repo.ui.contentDescriptions.vocabulary 	= dnet:content_description_typologies
4
repo.ui.protocols.vocabulary 			= dnet:protocols
5
repo.ui.datasourceCountries.vocabulary  = dnet:countries
6
repo.ui.validation.show 				= false
7
repo.ui.addApi.show 					= true
8
repo.ui.addRepo.show 					= true
9
repo.ui.validator.address               = http://dev.openaire.research-infrastructures.eu:8880/validator
10
repo.ui.validatorService.address        = http://dev.openaire.research-infrastructures.eu:8880/validator-service
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/applicationContext-modular-ui-repositories.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<beans xmlns="http://www.springframework.org/schema/beans"
4
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
6

  
7
	<bean name="repoUIUtils" class="eu.dnetlib.functionality.modular.ui.repositories.RepoUIUtils" />
8
	
9
</beans>
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/xslt/repoDetails.xslt
1
<?xml version="1.0"?>
2

  
3
<xsl:stylesheet version="1.0"
4
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5

  
6
	<xsl:output omit-xml-declaration="yes" method="html" />
7

  
8
	<xsl:template match="/">
9
		<div>
10
			<div class="well">
11
				<fieldset>
12
					<legend><h4>General</h4></legend>
13
					<table class="table table-bordered table-striped">
14
						<tbody>
15
							<tr>
16
								<td width="25%">Name</td>
17
								<td><xsl:value-of select=".//OFFICIAL_NAME" /></td>
18
							</tr><tr>
19
								<td width="25%">Typology</td>
20
								<td><xsl:value-of select=".//DATASOURCE_TYPE" /></td>
21
							</tr><tr>
22
								<td width="25%">Level of compliance</td>
23
								<td><xsl:value-of select=".//DATASOURCE_COMPLIANCE_DEGREE" /></td>
24
							</tr><tr>
25
								<td width="25%">Country</td>
26
								<td><xsl:value-of select=".//COUNTRY" /></td>
27
							</tr><tr>
28
								<td width="25%">Institution</td>
29
								<td><a href="{.//REPOSITORY_WEBPAGE}"><xsl:value-of select=".//REPOSITORY_INSTITUTION" /></a></td>
30
							</tr><tr>
31
								<td width="25%">Contact email</td>
32
								<td><a href="mailto:{.//ADMIN_INFO}"><xsl:value-of select=".//ADMIN_INFO" /></a></td>
33
							</tr>
34
						</tbody>
35
					</table>
36
				</fieldset>
37
			</div>
38
			<div class="well">
39
				<fieldset>
40
					<legend><h4>Status</h4></legend>
41
					<table class="table table-bordered table-striped">
42
						<tbody>
43
							<tr>
44
								<td width="25%">Size</td>
45
								<td><xsl:value-of select=".//NUMBER_OF_OBJECTS" /></td>
46
							</tr><tr>
47
								<td width="25%">Last update</td>
48
								<td><xsl:value-of select=".//LAST_UPDATE" /></td>
49
							</tr><tr>
50
								<td width="25%">Registered By</td>
51
								<td><xsl:value-of select=".//REGISTERED_BY" /></td>
52
							</tr>
53
						</tbody>
54
					</table>
55
				</fieldset>
56
			</div>
57
			<div class="well">
58
				<fieldset>
59
					<legend><h4>Configuration parameters</h4></legend>
60
					<table class="table table-bordered table-striped">
61
						<tbody>
62
							<xsl:for-each select=".//EXTRA_FIELDS/FIELD">
63
								<tr>
64
									<td width="25%"><xsl:value-of select="./key" /></td>
65
									<td><xsl:value-of select="./value" /></td>
66
								</tr>
67
							</xsl:for-each>
68
						</tbody>
69
					</table>
70
				</fieldset>
71
			</div>
72
			<xsl:for-each select="//INTERFACE">
73
				<div class="well">
74
					<fieldset>
75
						<legend><h4>Interface: <xsl:value-of select="./@typology" /></h4></legend>
76
						<table class="table table-bordered table-striped">
77
							<tbody>
78
								<xsl:for-each select="@*|.//*[string-length(normalize-space(text())) &gt; 0]|.//*[name() != 'INTERFACE_EXTRA_FIELD']/@*">
79
									<tr>
80
										<td width="25%">
81
											<xsl:choose>
82
												<xsl:when test="name() = 'INTERFACE_EXTRA_FIELD'">
83
													<xsl:value-of select="@name" />
84
												</xsl:when>
85
												<xsl:otherwise>
86
													<xsl:value-of select="local-name(.)" />		
87
												</xsl:otherwise>
88
											</xsl:choose>
89
										</td>
90
										<td><xsl:value-of select="." /></td>
91
									</tr>
92
								</xsl:for-each>
93
							</tbody>
94
						</table>
95
					</fieldset>
96
				</div>
97
			</xsl:for-each>
98
		</div>
99
	</xsl:template>
100

  
101
</xsl:stylesheet> 
modules/dnet-modular-repositories-ui/tags/dnet-modular-repositories-ui-4.0.23/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/templates/getRepoApi.xquery.st
1
for \$x in 
2
	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')[.//RESOURCE_IDENTIFIER/@value='$dsId$' or .//DATASOURCE_ORIGINAL_ID = '$dsId$']//INTERFACE[@id='$ifaceId$']
3
let \$repoId := \$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()
4
return 
5
	<api>
6
		<id>{\$x/@id/string()}</id>
7
		<label>{\$x/@label/string()}</label>
8
		<removable>{\$x/@removable/string()}</removable>
9
		<protocol>{\$x/ACCESS_PROTOCOL/text()}</protocol>
10
		<repo 
11
			id="{\$repoId}" 
12
			country="{\$x/../../COUNTRY/text()}" 
13
			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}"
14
			type="{\$x/../../TYPOLOGY/text()}"
15
			email="{\$x/../../ADMIN_INFO/text()}">
16
			{\$x/../../OFFICIAL_NAME/text()}
17
		</repo>
18
		<commonParams>
19
			<param name="id">{\$x/@id/string()}</param>
20
			<param name="label">{\$x/@label/string()}</param>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff