Project

General

Profile

« Previous | Next » 

Revision 45243

codebase used to migrate to java8 the production system

View differences:

modules/dnet-modular-index-ui/trunk/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-modular-index-ui/trunk/", "deploy_repository": "dnet4-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/dnet4-snapshots", "name": "dnet-modular-index-ui"}
modules/dnet-modular-index-ui/trunk/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/trunk/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/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/index/IndexClientMap.java
1
package eu.dnetlib.functionality.modular.ui.index;
2

  
3
import java.util.Map;
4

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

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

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

  
13
public class IndexClientMap {
14

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

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

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

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

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

  
34
}
modules/dnet-modular-index-ui/trunk/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/trunk/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

  
7
import javax.annotation.Resource;
8

  
9
import org.apache.commons.lang.StringUtils;
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.core.io.ClassPathResource;
14
import org.springframework.stereotype.Controller;
15
import org.springframework.ui.ModelMap;
16
import org.springframework.web.bind.annotation.RequestMapping;
17
import org.springframework.web.bind.annotation.RequestMethod;
18
import org.springframework.web.bind.annotation.RequestParam;
19
import org.springframework.web.bind.annotation.ResponseBody;
20

  
21
import com.google.common.base.Function;
22
import com.google.common.collect.Lists;
23
import com.google.common.collect.Sets;
24
import com.google.gson.Gson;
25
import com.google.gson.reflect.TypeToken;
26

  
27
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
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.index.client.IndexClient;
32
import eu.dnetlib.functionality.index.client.IndexClientException;
33
import eu.dnetlib.functionality.index.client.ResolvingIndexClientFactory;
34
import eu.dnetlib.functionality.index.client.response.BrowseEntry;
35
import eu.dnetlib.functionality.index.client.response.LookupResponse;
36
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController;
37
import eu.dnetlib.functionality.modular.ui.index.models.IndexInfo;
38
import eu.dnetlib.functionality.modular.ui.index.models.MdFormatInfo;
39
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
40

  
41
/**
42
 * The Class IndexServiceInternalController.
43
 */
44
@Controller
45
public class IndexServiceInternalController extends AbstractAjaxController {
46

  
47
	/** The Constant log. */
48
	private static final Log log = LogFactory.getLog(IndexServiceInternalController.class);
49

  
50
	/** The lookup locator. */
51
	@Resource
52
	private UniqueServiceLocator serviceLocator;
53

  
54
	/** The index client factory. */
55
	@Autowired
56
	private ResolvingIndexClientFactory indexClientFactory;
57

  
58
	@Autowired
59
	private IndexClientMap clientMap;
60

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

  
80
		return Lists.transform(quickSearchProfile(xquery), new Function<String, MdFormatInfo>() {
81

  
82
			@Override
83
			public MdFormatInfo apply(final String input) {
84
				return MdFormatInfo.initFromXqueryResult(input);
85
			}
86
		});
87
	}
88

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

  
110
		Function<String, IndexInfo> function = new Function<String, IndexInfo>() {
111

  
112
			@Override
113
			public IndexInfo apply(final String input) {
114
				return IndexInfo.newInstanceFromString(input);
115
			}
116
		};
117
		return Lists.transform(quickSearchProfile(String.format(xquery, backend)), function);
118
	}
119

  
120
	/**
121
	 * Md format info.
122
	 *
123
	 * @param map
124
	 *            the map
125
	 * @param id
126
	 *            the id
127
	 * @param layout
128
	 *            the layout
129
	 * @return the list< string>
130
	 * @throws Exception
131
	 *             the exception
132
	 */
133
	@RequestMapping(value = "/ui/index/mdFormatInfo.do")
134
	@ResponseBody
135
	public List<String> mdFormatInfo(@RequestParam(value = "id", required = true) final String id,
136
			@RequestParam(value = "layout", required = true) final String layout) throws Exception {
137

  
138
		String xqueryTemplate =
139
				"//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s']" + "//LAYOUT[./@name/string()='%s'] "
140
						+ "//FIELD[./@tokenizable/string()='false' or ./@type = 'int' or ./@type = 'date']/@name/string()";
141
		log.debug("executing query: " + String.format(xqueryTemplate, id, layout));
142
		return quickSearchProfile(String.format(xqueryTemplate, id, layout));
143
	}
144

  
145
	/**
146
	 * Gets the backend available.
147
	 *
148
	 * @param map
149
	 *            the map
150
	 * @param id
151
	 *            the id
152
	 * @param layout
153
	 *            the layout
154
	 * @return the backend available
155
	 * @throws Exception
156
	 *             the exception
157
	 */
158
	@RequestMapping(value = "/ui/index/backend.do")
159
	@ResponseBody
160
	public Set<String> getBackendAvailable() throws Exception {
161

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

  
166
	}
167

  
168
	/**
169
	 * Browse.
170
	 *
171
	 * @param map
172
	 *            the map
173
	 * @param backend
174
	 *            the backend
175
	 * @param format
176
	 *            the format
177
	 * @param layout
178
	 *            the layout
179
	 * @param interpretation
180
	 *            the interpretation
181
	 * @return the list< string>
182
	 * @throws IndexClientException
183
	 *             the index client exception
184
	 */
185
	@RequestMapping(value = "/ui/index/browse.do", method = RequestMethod.POST)
186
	@ResponseBody
187
	public List<BrowseEntry> browse(final ModelMap map,
188
			@RequestParam(value = "backend", required = true) final String backend,
189
			@RequestParam(value = "format", required = true) final String format,
190
			@RequestParam(value = "layout", required = true) final String layout,
191
			@RequestParam(value = "interpretation", required = true) final String interpretation,
192
			@RequestParam(value = "fields", required = true) final String fields,
193
			@RequestParam(value = "query", required = true) final String query) throws IndexClientException {
194

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

  
197
		if (browseFields != null) {
198
			for (String s : browseFields) {
199
				log.debug("Browse field " + s);
200
			}
201
		}
202

  
203
		String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation;
204

  
205
		IndexClient client = null;
206
		if (clientMap.getMap().containsKey(indexClientKeys)) {
207
			client = clientMap.getMap().get(indexClientKeys);
208
		} else {
209
			client = indexClientFactory.getClient(format, layout, interpretation, backend);
210
			clientMap.getMap().put(indexClientKeys, client);
211
		}
212

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

  
215
		List<BrowseEntry> result = client.browse(query, browseFields, 99);
216
		return result;
217
	}
218

  
219
	@RequestMapping(value = "/ui/index/delete.do", method = RequestMethod.POST)
220
	@ResponseBody
221
	public long delete(final ModelMap map,
222
			@RequestParam(value = "backend", required = true) final String backend,
223
			@RequestParam(value = "format", required = true) final String format,
224
			@RequestParam(value = "layout", required = true) final String layout,
225
			@RequestParam(value = "interpretation", required = true) final String interpretation,
226
			@RequestParam(value = "query", required = true) final String query,
227
			@RequestParam(value = "indexidentifier", required = false) final String indexId) throws IndexServiceException {
228

  
229
		String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation;
230

  
231
		IndexClient client = null;
232
		if (clientMap.getMap().containsKey(indexClientKeys)) {
233
			client = clientMap.getMap().get(indexClientKeys);
234
		} else {
235
			client = indexClientFactory.getClient(format, layout, interpretation, backend);
236
			clientMap.getMap().put(indexClientKeys, client);
237
		}
238
		String mquery = query;
239

  
240
		if (!StringUtils.isEmpty(indexId)) {
241
			mquery = query + " and __dsid exact \"" + indexId + "\"";
242
		}
243

  
244
		return client.delete(mquery);
245
	}
246

  
247
	@RequestMapping(value = "/ui/index/search.do", method = RequestMethod.POST)
248
	@ResponseBody
249
	public LookupResponse search(final ModelMap map,
250
			@RequestParam(value = "backend", required = true) final String backend,
251
			@RequestParam(value = "format", required = true) final String format,
252
			@RequestParam(value = "layout", required = true) final String layout,
253
			@RequestParam(value = "interpretation", required = true) final String interpretation,
254
			@RequestParam(value = "query", required = true) final String query,
255
			@RequestParam(value = "from", required = true) final int from,
256
			@RequestParam(value = "number", required = true) final int number,
257
			@RequestParam(value = "indexidentifier", required = false) final String indexId
258

  
259
			) throws IndexClientException {
260

  
261
		String indexClientKeys = backend + "-" + format + "-" + layout + "-" + interpretation;
262

  
263
		log.debug(indexClientKeys);
264

  
265
		IndexClient client = null;
266

  
267
		if (!clientMap.getMap().containsKey(indexClientKeys)) {
268
			clientMap.getMap().put(indexClientKeys, indexClientFactory.getClient(format, layout, interpretation, backend));
269
		}
270
		client = clientMap.getMap().get(indexClientKeys);
271

  
272
		List<String> filterId = null;
273
		if (indexId != null && !indexId.isEmpty()) {
274
			filterId = Lists.newArrayList("__dsid:\"" + indexId + "\"");
275
		}
276

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

  
279
		LookupResponse result = client.lookup(query, filterId, from, number);
280

  
281
		ClassPathResource cpr = new ClassPathResource("/eu/dnetlib/functionality/modular/ui/xslt/gmf2document.xslt");
282
		ApplyXslt xslt = new ApplyXslt(cpr);
283
		List<String> convertedList = new ArrayList<String>();
284

  
285
		for (String s : result.getRecords()) {
286
			log.debug("response record: \n" + s);
287
			convertedList.add(xslt.evaluate(s));
288
		}
289
		result.setRecords(convertedList);
290
		return result;
291
	}
292

  
293
	/**
294
	 * Quick search profile.
295
	 *
296
	 * @param xquery
297
	 *            the xquery
298
	 * @return the list< string>
299
	 * @throws Exception
300
	 *             the exception
301
	 */
302
	private List<String> quickSearchProfile(final String xquery) throws Exception {
303
		try {
304
			return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
305
		} catch (ISLookUpException e) {
306
			throw new Exception(e);
307
		}
308
	}
309
}
modules/dnet-modular-index-ui/trunk/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/trunk/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/trunk/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/trunk/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/trunk/src/main/resources/eu/dnetlib/web/resources/html/index/indexManage.html
1
<h1>IT WORKSSS!</h1>
modules/dnet-modular-index-ui/trunk/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/trunk/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/trunk/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/trunk/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
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff