Project

General

Profile

« Previous | Next » 

Revision 55815

[maven-release-plugin] copy for tag dnet-modular-index-ui-2.0.8

View differences:

modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/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-index-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-index-ui"}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/java/eu/dnetlib/functionality/modular/ui/index/models/IndexInfo.java
1
package eu.dnetlib.functionality.modular.ui.index.models;
2

  
3
/**
4
 * The Class IndexInfo.
5
 */
6
public class IndexInfo {
7

  
8
	/** The Constant SEPARATOR. */
9
	private static final String SEPARATOR = ":-:";
10

  
11
	/** The id. */
12
	private String id;
13

  
14
	/** The forma. */
15
	private String format;
16

  
17
	/** The layout. */
18
	private String layout;
19

  
20
	/** The interpretation. */
21
	private String interpretation;
22

  
23
	/** The backend id. */
24
	private String backendId;
25

  
26
	private int size;
27

  
28
	/**
29
	 * The Constructor.
30
	 */
31
	public IndexInfo() {
32

  
33
	}
34

  
35
	/**
36
	 * The Constructor.
37
	 *
38
	 * @param id
39
	 *            the id
40
	 * @param forma
41
	 *            the forma
42
	 * @param layout
43
	 *            the layout
44
	 * @param interpretation
45
	 *            the interpretation
46
	 * @param backendId
47
	 *            the backend id
48
	 */
49
	public IndexInfo(final String id, final String forma, final String layout, final String interpretation, final String backendId) {
50
		super();
51
		this.id = id;
52
		this.format = forma;
53
		this.layout = layout;
54
		this.interpretation = interpretation;
55
		this.backendId = backendId;
56
	}
57

  
58
	/**
59
	 * Gets the id.
60
	 *
61
	 * @return the id
62
	 */
63
	public String getId() {
64
		return id;
65
	}
66

  
67
	/**
68
	 * Sets the id.
69
	 *
70
	 * @param id
71
	 *            the id
72
	 */
73
	public void setId(final String id) {
74
		this.id = id;
75
	}
76

  
77
	/**
78
	 * Gets the forma.
79
	 *
80
	 * @return the forma
81
	 */
82
	public String getFormat() {
83
		return format;
84
	}
85

  
86
	/**
87
	 * Sets the forma.
88
	 *
89
	 * @param forma
90
	 *            the forma
91
	 */
92
	public void setFormat(final String format) {
93
		this.format = format;
94
	}
95

  
96
	/**
97
	 * Gets the layout.
98
	 *
99
	 * @return the layout
100
	 */
101
	public String getLayout() {
102
		return layout;
103
	}
104

  
105
	/**
106
	 * Sets the layout.
107
	 *
108
	 * @param layout
109
	 *            the layout
110
	 */
111
	public void setLayout(final String layout) {
112
		this.layout = layout;
113
	}
114

  
115
	/**
116
	 * Gets the interpretation.
117
	 *
118
	 * @return the interpretation
119
	 */
120
	public String getInterpretation() {
121
		return interpretation;
122
	}
123

  
124
	/**
125
	 * Sets the interpretation.
126
	 *
127
	 * @param interpretation
128
	 *            the interpretation
129
	 */
130
	public void setInterpretation(final String interpretation) {
131
		this.interpretation = interpretation;
132
	}
133

  
134
	/**
135
	 * Gets the backend id.
136
	 *
137
	 * @return the backend id
138
	 */
139
	public String getBackendId() {
140
		return backendId;
141
	}
142

  
143
	/**
144
	 * Sets the backend id.
145
	 *
146
	 * @param backendId
147
	 *            the backend id
148
	 */
149
	public void setBackendId(final String backendId) {
150
		this.backendId = backendId;
151
	}
152

  
153
	public int getSize() {
154
		return size;
155
	}
156

  
157
	public void setSize(final int size) {
158
		this.size = size;
159
	}
160

  
161
	/**
162
	 * New instance from string. the string must have the form format:-:layout:-:interpretation:-:id:-:backendid:-:size
163
	 *
164
	 * @param serialized
165
	 *            the serialized
166
	 * @return the index info
167
	 */
168
	public static IndexInfo newInstanceFromString(final String serialized) {
169
		String[] values = serialized.split(SEPARATOR);
170
		if ((values == null) || (values.length != 6)) return null;
171
		IndexInfo tmp = new IndexInfo();
172
		tmp.format = values[0];
173
		tmp.layout = values[1];
174
		tmp.interpretation = values[2];
175
		tmp.id = values[3];
176
		tmp.backendId = values[4];
177
		tmp.size = Integer.parseInt(values[5]);
178
		return tmp;
179

  
180
	}
181
}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/java/eu/dnetlib/functionality/modular/ui/index/models/MdFormatInfo.java
1
package eu.dnetlib.functionality.modular.ui.index.models;
2

  
3
// TODO: Auto-generated Javadoc
4
/**
5
 * The Class MdFormatInfo.
6
 */
7
public class MdFormatInfo {
8

  
9
	/** The Constant SplitCharachters. */
10
	private static final String SplitCharachters = "::";
11

  
12
	/** The id. */
13
	private String id;
14

  
15
	/** The format. */
16
	private String format;
17

  
18
	/** The layout. */
19
	private String layout;
20

  
21
	/** The interpretation. */
22
	private String interpretation;
23

  
24
	/**
25
	 * The Constructor.
26
	 */
27
	public MdFormatInfo() {
28

  
29
	}
30

  
31
	/**
32
	 * The Constructor.
33
	 *
34
	 * @param id
35
	 *            the id
36
	 * @param format
37
	 *            the format
38
	 * @param layout
39
	 *            the layout
40
	 * @param interpretation
41
	 *            the interpretation
42
	 */
43
	public MdFormatInfo(final String id, final String format, final String layout, final String interpretation) {
44
		super();
45
		this.id = id;
46
		this.format = format;
47
		this.layout = layout;
48
		this.interpretation = interpretation;
49
	}
50

  
51
	/**
52
	 * Gets the id.
53
	 *
54
	 * @return the id
55
	 */
56
	public String getId() {
57
		return id;
58
	}
59

  
60
	/**
61
	 * Sets the id.
62
	 *
63
	 * @param id
64
	 *            the id
65
	 */
66
	public void setId(final String id) {
67
		this.id = id;
68
	}
69

  
70
	/**
71
	 * Gets the format.
72
	 *
73
	 * @return the format
74
	 */
75
	public String getFormat() {
76
		return format;
77
	}
78

  
79
	/**
80
	 * Sets the format.
81
	 *
82
	 * @param format
83
	 *            the format
84
	 */
85
	public void setFormat(final String format) {
86
		this.format = format;
87
	}
88

  
89
	/**
90
	 * Gets the layout.
91
	 *
92
	 * @return the layout
93
	 */
94
	public String getLayout() {
95
		return layout;
96
	}
97

  
98
	/**
99
	 * Sets the layout.
100
	 *
101
	 * @param layout
102
	 *            the layout
103
	 */
104
	public void setLayout(final String layout) {
105
		this.layout = layout;
106
	}
107

  
108
	/**
109
	 * Gets the interpretation.
110
	 *
111
	 * @return the interpretation
112
	 */
113
	public String getInterpretation() {
114
		return interpretation;
115
	}
116

  
117
	/**
118
	 * Sets the interpretation.
119
	 *
120
	 * @param interpretation
121
	 *            the interpretation
122
	 */
123
	public void setInterpretation(final String interpretation) {
124
		this.interpretation = interpretation;
125
	}
126

  
127
	/**
128
	 * Create a new MdFormatInfo starting from the xquery result the string MUST be in this forma $format-$layout-$interpretation::$id
129
	 *
130
	 * @param result
131
	 *            the result
132
	 * @return the md format info
133
	 */
134
	public static MdFormatInfo initFromXqueryResult(final String result) {
135
		String[] values = result.split(SplitCharachters);
136
		if ((values == null) || (values.length != 2)) return null;
137

  
138
		String[] mdref = values[0].split("-");
139
		if ((mdref == null) || (mdref.length != 3)) return null;
140

  
141
		return new MdFormatInfo(values[1], mdref[0], mdref[1], mdref[2]);
142

  
143
	}
144

  
145
}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexClientMap.java
1
package eu.dnetlib.functionality.modular.ui.index;
2

  
3
import java.io.IOException;
4
import java.util.Map;
5

  
6
import org.apache.commons.logging.Log;
7
import org.apache.commons.logging.LogFactory;
8

  
9
import com.google.common.collect.Maps;
10

  
11
import eu.dnetlib.functionality.index.client.IndexClient;
12
import eu.dnetlib.functionality.index.client.IndexClientException;
13

  
14
public class IndexClientMap {
15

  
16
	private static final Log log = LogFactory.getLog(IndexClientMap.class);
17

  
18
	private Map<String, IndexClient> map = Maps.newHashMap();
19

  
20
	public void shutdown() throws IOException {
21
		log.debug("shutdown index clients");
22
		for (IndexClient client : map.values()) {
23
			client.close();
24
		}
25
	}
26

  
27
	public Map<String, IndexClient> getMap() {
28
		return map;
29
	}
30

  
31
	public void setMap(final Map<String, IndexClient> map) {
32
		this.map = map;
33
	}
34

  
35
}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexServiceEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.index;
2

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

  
7
import org.springframework.ui.ModelMap;
8

  
9
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
10
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
11

  
12
public class IndexServiceEntryPointController extends ModuleEntryPoint {
13

  
14
	@Resource
15
	private UniqueServiceLocator serviceLocator;
16

  
17
	@Override
18
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
19

  
20
	}
21

  
22
}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.index;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Set;
6
import java.util.stream.Collectors;
7
import javax.annotation.Resource;
8

  
9
import com.google.common.collect.Lists;
10
import com.google.common.collect.Sets;
11
import com.google.gson.Gson;
12
import com.google.gson.reflect.TypeToken;
13
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
14
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
15
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
16
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
17
import eu.dnetlib.functionality.index.client.IndexClient;
18
import eu.dnetlib.functionality.index.client.IndexClientException;
19
import eu.dnetlib.functionality.index.client.response.BrowseEntry;
20
import eu.dnetlib.functionality.index.client.response.LookupResponse;
21
import eu.dnetlib.functionality.index.client.solr.SolrIndexClientFactory;
22
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController;
23
import eu.dnetlib.functionality.modular.ui.index.models.IndexInfo;
24
import eu.dnetlib.functionality.modular.ui.index.models.MdFormatInfo;
25
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
26
import org.apache.commons.lang.StringUtils;
27
import org.apache.commons.logging.Log;
28
import org.apache.commons.logging.LogFactory;
29
import org.springframework.beans.factory.annotation.Autowired;
30
import org.springframework.core.io.ClassPathResource;
31
import org.springframework.stereotype.Controller;
32
import org.springframework.ui.ModelMap;
33
import org.springframework.web.bind.annotation.RequestMapping;
34
import org.springframework.web.bind.annotation.RequestMethod;
35
import org.springframework.web.bind.annotation.RequestParam;
36
import org.springframework.web.bind.annotation.ResponseBody;
37

  
38
/**
39
 * The Class IndexServiceInternalController.
40
 */
41
@Controller
42
public class IndexServiceInternalController extends AbstractAjaxController {
43

  
44
	/** The Constant log. */
45
	private static final Log log = LogFactory.getLog(IndexServiceInternalController.class);
46

  
47
	/** The lookup locator. */
48
	@Resource
49
	private UniqueServiceLocator serviceLocator;
50

  
51
	/** The index client factory. */
52
	@Autowired
53
	private SolrIndexClientFactory indexClientFactory;
54

  
55
	@Autowired
56
	private IndexClientMap clientMap;
57

  
58
	/**
59
	 * Index metadata formats.
60
	 *
61
	 * @param map
62
	 *            the map
63
	 * @return the list< md format info>
64
	 * @throws Exception
65
	 *             the exception
66
	 */
67
	@RequestMapping(value = "/ui/index/indexMetadataFormats.do")
68
	@ResponseBody
69
	public List<MdFormatInfo> indexMetadataFormats(final ModelMap map) throws Exception {
70
		final String xquery =
71
				"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='MDFormatDSResourceType'] "
72
						+ "let $format:= $x//CONFIGURATION/NAME/string()  for $y in $x//LAYOUTS/LAYOUT  let $layout:= $y/@name/string() "
73
						+ "let $interpretation:= $x//CONFIGURATION/INTERPRETATION/text() let $id:=$x//RESOURCE_IDENTIFIER/@value/string() "
74
						+ " return concat($format,'-',$layout,'-',$interpretation,'::', $id) ";
75
		log.debug("Executing lookup query" + xquery);
76

  
77
		return quickSearchProfile(xquery).stream()
78
				.map(MdFormatInfo::initFromXqueryResult)
79
				.collect(Collectors.toList());
80
	}
81

  
82
	/**
83
	 * Index datastructures.
84
	 *
85
	 * @param backend
86
	 *            the backend
87
	 * @return the list< index info>
88
	 * @throws Exception
89
	 *             the exception
90
	 */
91
	@RequestMapping(value = "/ui/index/indexDatastructures.do")
92
	@ResponseBody
93
	public List<IndexInfo> indexDatastructures(@RequestParam(value = "backend", required = true) final String backend) throws Exception {
94
		final String xquery =
95
				"for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType' and .//BACKEND/@ID='%s'] let $format := $x//METADATA_FORMAT "
96
						+ "let $layout := $x//METADATA_FORMAT_LAYOUT let $interpretation :=$x//METADATA_FORMAT_INTERPRETATION "
97
						+ "let $id :=$x//RESOURCE_IDENTIFIER/@value let $backendid := $x//BACKEND/@ID let $size := $x//INDEX_SIZE "
98
						+ "return concat($format, ':-:',$layout,':-:',$interpretation,':-:',$id,':-:',$backendid,':-:',$size)";
99
		log.debug("Executing lookup query" + String.format(xquery, backend));
100

  
101
		return quickSearchProfile(String.format(xquery, backend)).stream()
102
				.map(IndexInfo::newInstanceFromString)
103
				.collect(Collectors.toList());
104
	}
105

  
106
	/**
107
	 * Md format info.
108
	 *
109
	 * @param id
110
	 *            the id
111
	 * @param layout
112
	 *            the layout
113
	 * @return the list< string>
114
	 * @throws Exception
115
	 *             the exception
116
	 */
117
	@RequestMapping(value = "/ui/index/mdFormatInfo.do")
118
	@ResponseBody
119
	public List<String> mdFormatInfo(@RequestParam(value = "id", required = true) final String id,
120
			@RequestParam(value = "layout", required = true) final String layout) throws Exception {
121

  
122
		String xqueryTemplate =
123
				"//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s']" + "//LAYOUT[./@name/string()='%s'] "
124
						+ "//FIELD[./@tokenizable/string()='false' or ./@type = 'int' or ./@type = 'date']/@name/string()";
125
		log.debug("executing query: " + String.format(xqueryTemplate, id, layout));
126
		return quickSearchProfile(String.format(xqueryTemplate, id, layout));
127
	}
128

  
129
	/**
130
	 * Gets the backend available.
131
	 *
132
	 * @return the backend available
133
	 * @throws Exception
134
	 *             the exception
135
	 */
136
	@RequestMapping(value = "/ui/index/backend.do")
137
	@ResponseBody
138
	public Set<String> getBackendAvailable() throws Exception {
139

  
140
		String xquery = "for $x in //RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IndexDSResourceType'] return distinct-values($x//BACKEND/@ID/string())";
141
		log.debug("executing query: " + xquery);
142
		return Sets.newHashSet(quickSearchProfile(xquery));
143

  
144
	}
145

  
146
	/**
147
	 * Browse.
148
	 *
149
	 * @param map
150
	 *            the map
151
	 * @param backend
152
	 *            the backend
153
	 * @param format
154
	 *            the format
155
	 * @param layout
156
	 *            the layout
157
	 * @param interpretation
158
	 *            the interpretation
159
	 * @return the list< string>
160
	 * @throws IndexClientException
161
	 *             the index client exception
162
	 */
163
	@RequestMapping(value = "/ui/index/browse.do", method = RequestMethod.POST)
164
	@ResponseBody
165
	public List<BrowseEntry> browse(final ModelMap map,
166
			@RequestParam(value = "backend", required = true) final String backend,
167
			@RequestParam(value = "format", required = true) final String format,
168
			@RequestParam(value = "layout", required = true) final String layout,
169
			@RequestParam(value = "interpretation", required = true) final String interpretation,
170
			@RequestParam(value = "fields", required = true) final String fields,
171
			@RequestParam(value = "query", required = true) final String query) throws IndexClientException {
172

  
173
		List<String> browseFields = new Gson().fromJson(fields, new TypeToken<List<String>>() {}.getType());
174

  
175
		if (browseFields != null) {
176
			for (String s : browseFields) {
177
				log.debug("Browse field " + s);
178
			}
179
		}
180

  
181
		String indexClientKeys = format + "-" + layout + "-" + interpretation;
182

  
183
		IndexClient client = null;
184
		if (clientMap.getMap().containsKey(indexClientKeys)) {
185
			client = clientMap.getMap().get(indexClientKeys);
186
		} else {
187
			client = indexClientFactory.getClient(format, layout, interpretation);
188
			clientMap.getMap().put(indexClientKeys, client);
189
		}
190

  
191
		// LookupResponse result = client.lookup("*=*", null, 0, 10);
192

  
193
		List<BrowseEntry> result = client.browse(query, browseFields, 99);
194
		return result;
195
	}
196

  
197
	@RequestMapping(value = "/ui/index/delete.do", method = RequestMethod.POST)
198
	@ResponseBody
199
	public long delete(final ModelMap map,
200
			@RequestParam(value = "backend", required = true) final String backend,
201
			@RequestParam(value = "format", required = true) final String format,
202
			@RequestParam(value = "layout", required = true) final String layout,
203
			@RequestParam(value = "interpretation", required = true) final String interpretation,
204
			@RequestParam(value = "query", required = true) final String query,
205
			@RequestParam(value = "indexidentifier", required = false) final String indexId) throws IndexServiceException {
206

  
207
		String indexClientKeys = format + "-" + layout + "-" + interpretation;
208

  
209
		IndexClient client = null;
210
		if (clientMap.getMap().containsKey(indexClientKeys)) {
211
			client = clientMap.getMap().get(indexClientKeys);
212
		} else {
213
			client = indexClientFactory.getClient(format, layout, interpretation);
214
			clientMap.getMap().put(indexClientKeys, client);
215
		}
216
		String mquery = query;
217

  
218
		if (!StringUtils.isEmpty(indexId)) {
219
			mquery = query + " and __dsid exact \"" + indexId + "\"";
220
		}
221

  
222
		return client.delete(mquery);
223
	}
224

  
225
	@RequestMapping(value = "/ui/index/search.do", method = RequestMethod.POST)
226
	@ResponseBody
227
	public LookupResponse search(final ModelMap map,
228
			@RequestParam(value = "backend", required = true) final String backend,
229
			@RequestParam(value = "format", required = true) final String format,
230
			@RequestParam(value = "layout", required = true) final String layout,
231
			@RequestParam(value = "interpretation", required = true) final String interpretation,
232
			@RequestParam(value = "query", required = true) final String query,
233
			@RequestParam(value = "from", required = true) final int from,
234
			@RequestParam(value = "number", required = true) final int number,
235
			@RequestParam(value = "indexidentifier", required = false) final String indexId
236

  
237
			) throws IndexClientException {
238

  
239
		String indexClientKeys = format + "-" + layout + "-" + interpretation;
240

  
241
		log.debug(indexClientKeys);
242

  
243
		IndexClient client = null;
244

  
245
		if (!clientMap.getMap().containsKey(indexClientKeys)) {
246
			clientMap.getMap().put(indexClientKeys, indexClientFactory.getClient(format, layout, interpretation));
247
		}
248
		client = clientMap.getMap().get(indexClientKeys);
249

  
250
		List<String> filterId = null;
251
		if (indexId != null && !indexId.isEmpty()) {
252
			filterId = Lists.newArrayList("__dsid:\"" + indexId + "\"");
253
		}
254

  
255
		log.debug(String.format("query: '%s', filter: '%s', from: '%d', number: '%d'", query, filterId, from, number));
256

  
257
		LookupResponse result = client.lookup(query, filterId, from, number);
258

  
259
		ClassPathResource cpr = new ClassPathResource("/eu/dnetlib/functionality/modular/ui/xslt/gmf2document.xslt");
260
		ApplyXslt xslt = new ApplyXslt(cpr);
261
		List<String> convertedList = new ArrayList<String>();
262

  
263
		for (String s : result.getRecords()) {
264
			log.debug("response record: \n" + s);
265
			convertedList.add(xslt.evaluate(s));
266
		}
267
		result.setRecords(convertedList);
268
		return result;
269
	}
270

  
271
	/**
272
	 * Quick search profile.
273
	 *
274
	 * @param xquery
275
	 *            the xquery
276
	 * @return the list< string>
277
	 * @throws Exception
278
	 *             the exception
279
	 */
280
	private List<String> quickSearchProfile(final String xquery) throws Exception {
281
		try {
282
			return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
283
		} catch (ISLookUpException e) {
284
			throw new Exception(e);
285
		}
286
	}
287
}
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-index.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
4
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
5
	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
6
	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
7
	xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
8
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
9
						http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
10
						http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
11
						http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
12
						http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
13
						http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
14
						http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
15
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
16

  
17

  
18
	<bean name="/ui/indexInspector.do"
19
		class="eu.dnetlib.functionality.modular.ui.index.IndexServiceEntryPointController"
20
		p:menu="Index Service Inspector" 
21
		p:title="Index Service Inspector"
22
		p:description="Index Service Inspector"
23
		p:order="3" 
24
		p:group="Tools">
25
		<property name="permissionLevels">
26
			<set>
27
				<value>IS_ADMIN</value>
28
			</set>
29
		</property>
30
	</bean>
31
	
32
	<bean id="indexClientMap" class="eu.dnetlib.functionality.modular.ui.index.IndexClientMap"
33
		destroy-method="shutdown"/>
34

  
35
</beans>
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/functionality/modular/ui/xslt/gmf2document.xslt
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<xsl:stylesheet version="2.0" 
4
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
5
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
6

  
7
	<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
8

  
9
	<xsl:template match="/">
10
		<xsl:for-each select="//*[local-name()='record']">
11
			<div
12
				style="color:black; font-family:'Courier New', Courier, monospace; font-size:small">
13
				<xsl:call-template name="xmlItem">
14
					<xsl:with-param name="indent" select="string('')" />
15
				</xsl:call-template>
16
			</div>
17
		</xsl:for-each>
18
	</xsl:template>
19
	
20
	<xsl:template name="xmlAttr">
21
		<span style='color:red'><xsl:value-of select="concat(' ', local-name())"/></span>
22
		<xsl:value-of select="concat('=&quot;', ., '&quot;')"/>
23
	</xsl:template>
24
	
25
	<xsl:template name="xmlItem">
26
		<xsl:param name="indent" />
27
		<xsl:variable name="tag" select="local-name()" />
28
		<xsl:variable name="newindent"><xsl:value-of select="$indent" />&#160;&#160;&#160;&#160;</xsl:variable>
29

  
30
		<xsl:if test="string-length($tag)">
31
			<br/><xsl:value-of select="$indent" /><span style='color:blue'><xsl:value-of select="concat('&lt;',$tag)" /></span> 
32
			<xsl:for-each select="@*">
33
				<xsl:call-template name="xmlAttr"/>
34
			</xsl:for-each>
35

  
36
			<xsl:choose>
37
				<xsl:when test="count(child::*) = 0 and count(child::text()) = 1">
38
					<span style='color:blue'>&gt;</span>
39
					<xsl:value-of select="normalize-space(.)" />
40
					<span style='color:blue'><xsl:value-of select="concat('&lt;/',$tag,'&gt;')" /></span>
41
				</xsl:when>
42
				<xsl:when test="count(child::* | child::text()) &gt; 0">
43
					<span style='color:blue'>&gt;</span>
44
					<xsl:for-each select="child::* | child::text()">
45
						<xsl:choose>
46
							<xsl:when test="self::text() and string-length(normalize-space(.)) &gt; 0">
47
								<xsl:value-of select="normalize-space(.)" />
48
							</xsl:when>
49
							<xsl:otherwise>
50
								<xsl:call-template name="xmlItem">
51
									<xsl:with-param name="indent" select="$newindent" />
52
								</xsl:call-template>
53
							</xsl:otherwise>
54
						</xsl:choose>
55
					</xsl:for-each>
56
					<br /><xsl:value-of select="$indent" /><span style='color:blue'><xsl:value-of select="concat('&lt;/',$tag,'&gt;')" /></span>
57
				</xsl:when>
58
				<xsl:otherwise>
59
				 	<span style='color:blue'>&#160;/&gt;</span>
60
				</xsl:otherwise>
61
			</xsl:choose>
62
		</xsl:if>
63
	</xsl:template>
64

  
65
</xsl:stylesheet>
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/indexInspector.st
1
$common/master( header={
2
	<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
3
	<script type="text/javascript" src="../resources/js/angular-route.min.js"></script>
4
	<script type="text/javascript" src="../resources/js/angular-local-storage.min.js"></script>
5
	
6
	<script type="text/javascript" src="../resources/js/index_inspector_controllers.js"></script>
7
	<script type="text/javascript" src="../resources/js/index_inspector.js"></script>
8
}, body={
9
	<div ng-app="indexInspector" class="row">
10
		<div class="col-sm-3 col-lg-2" ng-controller="moduleMenuCtrl">
11
			<ul class="nav nav-pills nav-stacked">
12
				<li ng-class="{active : isActive('^\/q')}"><a href="#/query">Query</a></li>
13
				<li ng-class="{active : isActive('^\/(schemas|schema)')}"><a href="#/deletebyquery">Delete By Query</a></li>
14
				<li ng-class="{active : isActive('^\/browse')}"><a href="#/browse">Browse</a></li>
15
				<li ng-class="{active : isActive('^\/register')}"><a href="#/manage">Manage Index DS</a></li>				
16
			</ul>
17
		</div>
18
		<div ng-view class="col-sm-9 col-lg-10"></div>
19
		<script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
20
		<script>
21
function reload(){
22
	alert("prima");
23
	prettyPrint();
24
	alert("dopo");
25
}
26

  
27
</script>
28
	</div>
29
} )$
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/html/index/indexQuery.html
1

  
2

  
3
<div class="row">
4
	<div class="col-md-12">
5
		<label for="xqueryInput" class="control-label">Cql Query</label>
6
	</div>
7
</div>
8
<div class="row">
9
	<div class="col-md-12">
10
		<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea>	
11
	</div>
12
</div>
13
<div class="row">
14
	<div class="col-md-3">
15
		<label for="xqueryInput" class="control-label">Metadata
16
			Format</label>
17
	</div>
18
	<div class="col-md-3">
19
		<label for="xqueryInput" class="control-label">Backend</label>
20
	</div>
21
	<div class="col-md-3">
22
		<label for="xqueryInput" class="control-label">Index</label>
23
	</div>
24
</div>
25
<div class="row">
26

  
27
	<div class="col-md-3">
28
		<select class="form-control" ng-model="selectedMdref"
29
			ng-change="metadataFormatSelected({{item.layout}})"
30
			ng-options="(item.format +'-' + item.layout + '-' + item.interpretation) for item in mdFormats">
31
			<option value="" selected="selected">--Select Metadata
32
				Format--</option>
33
		</select>
34

  
35

  
36
	</div>
37
	<div class="col-md-3">
38
		<select class="form-control" ng-model="selectedbackend"
39
			ng-change="backendSelected()" ng-options="item for item in backends">
40
			<option value="" selected="selected">--Select Backend--</option>
41
		</select>
42
	</div>
43
	<div class="col-md-3">
44
		<select class="form-control" ng-model="selectedIndex"
45
			ng-options="item.id for item in indices">
46
			<option value="" selected="selected">--ALL --</option>
47
		</select>
48
	</div>
49
</div>
50

  
51
<div class="row" style="padding-top: 10px">
52
	<div class="col-md-4">
53
		<button class="btn btn-info" ng-click="startSearch()">Search</button>
54
	</div>
55

  
56
	<div class="col-md-6">
57
		<button class="btn btn-info" ng-click="share()">Share</button>
58
	</div>
59
</div>
60

  
61
<div class="container-fluid" style="padding-top: 10px">
62

  
63
<div class="row" ng-show="error">
64
		<div class="panel panel-default" >
65
			<div class="panel-heading">
66
				<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_error"><b>Error:</b> <i>{{error.message}}</i></a>
67
			</div>
68
			<div id="collapse_error" class="panel-collapse collapse in">
69
				<div class="panel-body">
70
					<pre>{{error.stacktrace}}</pre>
71
				</div>			
72
			</div>
73
		</div>
74
	</div>
75

  
76
<div class="row" ng-show="searchResult">
77
	<div class="col-md-12 ">
78
		<h3>Number of results: {{searchResult.total}}</h3>
79
	</div>
80
	<div class="col-md-12 text-center">
81
		<ul class="pagination">
82
			<li><a href="" ng-click="prevPage()">&laquo;</a></li>			
83
			<li><a href="" ng-click="nextPage()">&raquo;</a></li>
84
		</ul>
85
	</div>
86
</div>
87

  
88

  
89

  
90
<div class="row" ng-repeat="item in searchResult.records">
91
	<div class="col-md-12">
92
		<div class="panel panel-default">
93
			<div class="panel-heading">
94
				<a class="accordion-toggle" data-toggle="collapse"
95
					data-target="#collapse_{{$index}}"><b>{{$index+1 + from}}</b></a>
96
			</div>
97
			<div id="collapse_{{$index}}" class="panel-collapse collapse in">
98
				<div class="panel-body">
99
					<div ng-bind-html="to_trusted(item)" compile-template></div>
100
				</div>
101

  
102

  
103
			</div>
104
		</div>
105
	</div>
106
</div>
107
</div>
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/html/index/indexManage.html
1
<h1>IT WORKSSS!</h1>
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/html/index/browse.html
1
<form>
2
<div class="container-fluid">
3
<div class="row">
4
  <div class="col-md-12"><label for="xqueryInput" class="control-label">CQL Query</label></div> 
5
</div>
6
<div class="row">
7
  <div class="col-md-12">
8
  	<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea>	
9
  </div>
10
</div>
11
<div class="row">
12
	<div class="col-md-4"><label for="xqueryInput" class="control-label">Metadata Format:</label></div>
13
	<div class="col-md-4"><label for="xqueryInput" class="control-label">Backend:</label></div>
14
	<div class="col-md-4"><label for="xqueryInput" class="control-label">Index::</label></div>
15
</div>
16
<div class="row">
17

  
18
  <div class="col-md-4">
19
  <select class="form-control" ng-model="selectedMdref"  ng-change="metadataFormatSelected({{item.layout}})" ng-options="(item.format +'-' + item.layout + '-' + item.interpretation) for item in mdFormats" >
20
		<option value="" selected="selected">--Select Metadata Format--</option>				
21
	</select>
22
	
23

  
24
	</div>
25
	<div class="col-md-4">
26
	<select class="form-control" ng-model="selectedbackend" ng-change="backendSelected()" ng-options="item for item in backends">		
27
		<option value="" selected="selected">--Select Backend--</option>		
28
	</select>
29
	</div>
30
	<div class="col-md-4">
31
	<select class="form-control" ng-model="selectedIndex" ng-options="item.id for item in indices" >
32
			<option  value="" selected="selected" >--ALL --</option>			
33
		</select>
34
	</div>	
35
</div>
36

  
37

  
38

  
39
<div class="row" style="padding-top: 10px">
40
<div class ="col-md-6">
41
	<table class="table table-striped table-bordered">
42
	<thead>
43
      <tr>
44
         <th width="80%">Browse Field</th>
45
         <th width="20%">delete</th>         
46
      </tr>
47
   </thead>
48
   <tbody>
49
   	<tr ng-repeat="item in addedBrowseFields">
50
   		<td>{{item}}</td>
51
   		<td><a href="" ng-click="deleteBrowseField(item)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a></td>
52
   	</tr>   	   
53
   </tbody>
54
   
55
		
56
	</table>
57
</div>
58
</div>
59

  
60
<div class="row" style="padding-top: 10px">
61
<div class="col-md-4">
62
   		<select class="form-control" ng-model="selectedBrowser" ng-options="item for item in browseFields">
63
   			<option value="" selected="selected">--- Add Field --</option>			
64
		</select> </td>
65
</div>
66
<div class="col-md-1">
67
		<a href="" ng-click="browseFieldAdded()" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></a>
68
</div>
69

  
70
</div>
71

  
72

  
73
<div class="row" style="padding-top: 10px">
74
	<div class="col-md-4">
75
		<input type="submit" class="btn btn-info" ng-click="startBrowse()" value="Browse" >
76
	</div>
77
</div>
78
</div>
79
</form>
80

  
81

  
82
<div class="container-fluid" style="padding-top: 10px">
83

  
84
	<div class="row" ng-show="error">
85
		<div class="panel panel-default" >
86
			<div class="panel-heading">
87
				<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_error"><b>Error:</b> <i>{{error.message}}</i></a>
88
			</div>
89
			<div id="collapse_error" class="panel-collapse collapse in">
90
				<div class="panel-body">
91
					<pre>{{error.stacktrace}}</pre>
92
				</div>			
93
			</div>
94
		</div>
95
	</div>
96

  
97
	<div class="row" ng-repeat="item in browseResult">
98
		<div class ="col-md-6">
99
			<div class="panel panel-default"  >
100
				<div class="panel-heading">
101
					<a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}"><b>{{item.label}} :</b></a>
102
				</div>
103
				<div id="collapse_{{$index}}" class="panel-collapse collapse in">
104
					<table class="table">						
105
							<tbody>
106
								<tr ng-repeat="value in item.values">						
107
									<td>{{value.value}}</td>
108
									<td class="text-right">{{value.size}}</td>
109
								</tr>
110
							</tbody>
111
					</table>
112
				</div>
113
			</div>
114
		</div>
115
	</div>
116
</div>
117

  
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/html/index/deletebyquery.html
1
<h3>Delete By Query</h3>
2

  
3

  
4
<div class="row">
5
	<div class="col-md-12">
6
		<label for="xqueryInput" class="control-label">Cql Query</label>
7
	</div>
8
</div>
9
<div class="row">
10
	<div class="col-md-12">
11
		<textarea class="form-control" id="xqueryInput" ng-model="query"></textarea>	
12
	</div>
13
</div>
14
<div class="row">
15
	<div class="col-md-3">
16
		<label for="xqueryInput" class="control-label">Metadata
17
			Format</label>
18
	</div>
19
	<div class="col-md-3">
20
		<label for="xqueryInput" class="control-label">Backend</label>
21
	</div>
22
	<div class="col-md-3">
23
		<label for="xqueryInput" class="control-label">Index</label>
24
	</div>
25
</div>
26
<div class="row">
27

  
28
	<div class="col-md-3">
29
		<select class="form-control" ng-model="selectedMdref"
30
			ng-change="metadataFormatSelected({{item.layout}})"
31
			ng-options="(item.format +'-' + item.layout + '-' + item.interpretation) for item in mdFormats">
32
			<option value="" selected="selected">--Select Metadata
33
				Format--</option>
34
		</select>
35

  
36

  
37
	</div>
38
	<div class="col-md-3">
39
		<select class="form-control" ng-model="selectedbackend"
40
			ng-change="backendSelected()" ng-options="item for item in backends">
41
			<option value="" selected="selected">--Select Backend--</option>
42
		</select>
43
	</div>
44
	<div class="col-md-3">
45
		<select class="form-control" ng-model="selectedIndex"
46
			ng-options="item.id for item in indices">
47
			<option value="" selected="selected">--ALL --</option>
48
		</select>
49
	</div>
50
</div>
51

  
52
<div class="row" style="padding-top: 10px">
53
	<div class="col-md-4">
54
		<button class="btn btn-danger" ng-click="startDelete()">Delete</button>
55
	</div>
56
</div>
57

  
58

  
59
<div class="row" ng-show="searchResult">
60
	<div class="col-md-12 ">
61
		<h3>Number of record deleted : {{searchResult}}</h3>
62
	</div>	
63
</div>
64

  
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/js/index_inspector.js
1
var module = angular.module('indexInspector', ['ngRoute', 'indexInspectorControllers']);
2

  
3
module.config([
4
	'$routeProvider',
5
	function($routeProvider) {
6
		$routeProvider
7
			.when('/query',		                                    { templateUrl: '../resources/html/index/indexQuery.html', controller: 'indexQueryController' })
8
			.when('/query/:mdformat/:backend/:index/:start/:query', { templateUrl: '../resources/html/index/indexQuery.html', controller: 'indexQueryController' })
9
			.when('/browse',	{ templateUrl: '../resources/html/index/browse.html', controller: 'indexBrowseController' })
10
			.when('/manage',	{ templateUrl: '../resources/html/index/indexManage.html', controller: 'indexmanageController' })
11
			.when('/deletebyquery',	{ templateUrl: '../resources/html/index/deletebyquery.html', controller: 'indexdbqController' })			
12
			.otherwise({ redirectTo: '/query' });
13
	}
14
]);
15

  
16

  
17
module.controller('moduleMenuCtrl', [ '$scope', '$location',  
18
	function ($scope, $location) {
19
		$scope.isActive = function(regex) {
20
			var re = new RegExp(regex);			
21
			return re.test($location.path());
22
		}
23
	}
24
]);
25

  
26
module.filter('encodeURIComponent', function() {
27
    return window.encodeURIComponent;
28
});
modules/dnet-modular-index-ui/tags/dnet-modular-index-ui-2.0.8/src/main/resources/eu/dnetlib/web/resources/js/index_inspector_controllers.js
1
var indexInspectorControllers = angular.module('indexInspectorControllers', ['LocalStorageModule']);
2

  
3
function common_init($scope, $http, $sce, $location) {
4
	initSpinner();
5
	$scope.showError = function (error) {
6
		show_notification("error", error);
7
	}
8
	$scope.showNotification = function (message) {
9
		show_notification("info", message);
10
	}
11
	$scope.showSpinner = function () {
12
		showSpinner();
13
	}
14
	$scope.hideSpinner = function () {
15
		hideSpinner();
16
	}
17
	$scope.to_trusted = function (html) {
18
		return $sce.trustAsHtml(html);
19
	}
20
	$scope.go = function (path) {
21
		$location.path(path);
22
	}
23
	$scope.encodeValue = function (val) {
24
		return val;
25
	}
26
}
27

  
28
indexInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
29
	return {
30
		link: function (scope, element, attr) {
31
			var parsed = $parse(attr.ngBindHtml);
32

  
33
			function getStringValue() {
34
				return (parsed(scope) || '').toString();
35
			}
36

  
37
			//Recompile if the template changes
38
			scope.$watch(getStringValue, function () {
39
				$compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
40
			});
41
		}
42
	}
43
});
44

  
45

  
46
indexInspectorControllers.controller('indexmanageController', [
47
	'$scope', '$http', '$sce', '$location',
48
	function ($scope, $http, $sce, $location) {
49
		common_init($scope, $http, $sce, $location);
50

  
51

  
52
	}]);
53

  
54
indexInspectorControllers.controller('indexdbqController', ['$scope',
55
	'$http', '$sce', '$location', function ($scope, $http, $sce, $location) {
56
		common_init($scope, $http, $sce, $location);
57
		$scope.mdFormats = []
58
		$scope.backends = []
59
		$scope.indices = []
60
		$scope.query = '*=*'
61
		$scope.from = 0
62
		$scope.size = 10
63
		$scope.error = null;
64

  
65
		$scope.showSpinner();
66

  
67
		$scope.to_trusted = function (html_code) {
68
			return $sce.trustAsHtml(html_code);
69
		}
70

  
71

  
72
		$http.get('index/indexMetadataFormats.do').success(function (data) {
73
			$scope.hideSpinner();
74
			$scope.mdFormats = data;
75
		}).error(function () {
76
			$scope.showError('Error listing xmldb collections');
77
			$scope.hideSpinner();
78
		});
79

  
80
		$http.get('index/backend.do').success(function (data) {
81
			$scope.hideSpinner();
82
			$scope.backends = data;
83
		}).error(function (error) {
84
			$scope.showError(error.message);
85
			$scope.hideSpinner();
86
		});
87

  
88
		$scope.backendSelected = function (index) {
89

  
90
			if ($scope.selectedbackend != null) {
91
				$http.get('index/indexDatastructures.do', {
92
					params: {
93
						backend: $scope.selectedbackend
94
					}
95
				}).success(function (data) {
96
					$scope.hideSpinner();
97
					$scope.indices = data
98

  
99
				}).error(function () {
100
					$scope.showError('Error listing xmldb collections');
101
					$scope.hideSpinner();
102
				});
103
			}
104

  
105

  
106
		}
107

  
108

  
109
		$scope.hideSpinner();
110

  
111
		$scope.startDelete = function () {
112
			$scope.from = 0;
113
			$scope.size = 10
114
			$scope.deleteByQuery()
115
		}
116

  
117

  
118
		$scope.deleteByQuery = function () {
119

  
120
			if (($scope.selectedMdref == null) || ($scope.selectedbackend == null)) {
121
				alert("You must select a metadata format and a backend identifier")
122
				return;
123
			}
124

  
125
			$scope.showSpinner();
126
			$scope.error = null;
127
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
128
			var selectedId = null;
129
			if ($scope.selectedIndex != null)
130
				selectedId = $scope.selectedIndex.id
131
			$http.post('index/delete.do', $.param({
132

  
133
				'backend': $scope.selectedbackend,
134
				'format': $scope.selectedMdref.format,
135
				'layout': $scope.selectedMdref.layout,
136
				'interpretation': $scope.selectedMdref.interpretation,
137
				'query': $scope.query,
138
				'indexidentifier': selectedId
139

  
140
			}))
141
				.success(function (data) {
142
					$scope.hideSpinner();
143
					$scope.searchResult = data
144
					console.log(data)
145
				}).error(function (error) {
146
				$scope.error = error;
147
				$scope.hideSpinner();
148
			});
149
		}
150

  
151
		$scope.nextPage = function () {
152
			if ($scope.searchResult == null)
153
				return;
154
			if ($scope.from > $scope.searchResult.total)
155
				return;
156
			$scope.from += 10;
157
			$scope.size = $scope.from + 10
158
			$scope.search()
159
		}
160

  
161
		$scope.prevPage = function () {
162
			if ($scope.from <= 0) {
163
				return;
164
			}
165

  
166
			$scope.from -= 10;
167
			$scope.size -= 10
168
			$scope.search()
169
		}
170

  
171
		$scope.range = function (n) {
172
			return new Array(n);
173
		};
174

  
175

  
176
	}]);
177

  
178

  
179
indexInspectorControllers.controller('indexBrowseController', [
180
	'$scope', '$http', '$sce', '$location',
181
	function ($scope, $http, $sce, $location) {
182
		common_init($scope, $http, $sce, $location);
183
		$scope.showSpinner();
184
		$scope.mdFormats = []
185
		$scope.backends = []
186
		$scope.indices = []
187
		$scope.query = '*=*'
188
		$scope.error = null;
189

  
190
		$scope.browseFields = [];
191
		$scope.addedBrowseFields = [];
192
		$scope.selectedMdref = "";
193

  
194
		$http.get('index/indexMetadataFormats.do').success(function (data) {
195
			$scope.hideSpinner();
196
			$scope.mdFormats = data;
197
		}).error(function () {
198
			$scope.showError('Error listing xmldb collections');
199
			$scope.hideSpinner();
200
		});
201

  
202
		$http.get('index/backend.do').success(function (data) {
203
			$scope.hideSpinner();
204
			$scope.backends = data;
205
		}).error(function (error) {
206
			$scope.showError(error.message);
207
			$scope.hideSpinner();
208
		});
209

  
210
		$scope.backendSelected = function (index) {
211

  
212
			if ($scope.selectedbackend != null) {
213
				$http.get('index/indexDatastructures.do', {
214
					params: {
215
						backend: $scope.selectedbackend
216
					}
217
				}).success(function (data) {
218
					$scope.hideSpinner();
219
					$scope.indices = data
220

  
221
				}).error(function () {
222
					$scope.showError('Error listing xmldb collections');
223
					$scope.hideSpinner();
224
				});
225
			}
226

  
227

  
228
		}
229

  
230
		$scope.metadataFormatSelected = function (index) {
231
			if ($scope.selectedMdref == null) {
232
				$scope.addedBrowseFields = [];
233
				$scope.browseFields = []
234
				return;
235
			}
236

  
237
			$http.get('index/mdFormatInfo.do', {
238
				params: {
239
					id: $scope.selectedMdref.id,
240
					layout: $scope.selectedMdref.layout
241
				}
242
			}).success(function (data) {
243
				$scope.hideSpinner();
244
				$scope.browseFields = data;
245
				$scope.browseFields.sort()
246
				$scope.addedBrowseFields = [];
247
				$scope.selectedBrowser = '--- Add Field --'
248
			}).error(function () {
249
				$scope.showError('Error listing xmldb collections');
250
				$scope.hideSpinner();
251
			});
252
		};
253

  
254
		$scope.startBrowse = function () {
255

  
256
			if (($scope.selectedMdref == null) || ($scope.selectedbackend == null)) {
257
				alert("You must select a metadata format and a backend identifier")
258
				return;
259
			}
260
			if ($scope.addedBrowseFields.length == 0) {
261
				alert("You must select at least one browse field")
262
				return;
263
			}
264
			$scope.showSpinner();
265
			$scope.error = null;
266
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
267
			$http.post('index/browse.do', $.param({
268

  
269
				'backend': $scope.selectedbackend,
270
				'format': $scope.selectedMdref.format,
271
				'layout': $scope.selectedMdref.layout,
272
				'interpretation': $scope.selectedMdref.interpretation,
273
				'fields': JSON.stringify($scope.addedBrowseFields),
274
				'query': $scope.query
275
			}))
276
				.success(function (data) {
277
					$scope.hideSpinner();
278
					$scope.browseResult = data
279
				}).error(function (error) {
280
				$scope.error = error;
281
				$scope.hideSpinner();
282
			});
283
		}
284

  
285

  
286
		$scope.deleteBrowseField = function (item) {
287
			var i = 0
288

  
289
			for (; i < $scope.addedBrowseFields.length; i++) {
290
				if ($scope.addedBrowseFields[i] == item)
291
					break;
292
			}
293
			$scope.addedBrowseFields.splice(i, 1)
294
			$scope.browseFields = $scope.browseFields.concat(item)
295
			$scope.browseFields.sort();
296

  
297
		}
298

  
299
		$scope.browseFieldAdded = function () {
300
			for (i = 0; i < $scope.browseFields.length; i++) {
301
				if ($scope.browseFields[i] == $scope.selectedBrowser) {
302
					var data = $scope.browseFields[i];
303
					$scope.addedBrowseFields = $scope.addedBrowseFields.concat(data)
304
					$scope.browseFields.splice(i, 1)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff