Project

General

Profile

« Previous | Next » 

Revision 45237

codebase used to migrate to java8 the production system

View differences:

modules/dnet-oai-modular-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-oai-modular-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-oai-modular-ui"}
modules/dnet-oai-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/OAIIndex.java
1
package eu.dnetlib.functionality.modular.ui.oai;
2

  
3
import java.util.List;
4

  
5
public class OAIIndex {
6

  
7
	private String name;
8
	private boolean repeatable;
9
	private List<IndexPath> paths;
10

  
11
	public String getName() {
12
		return name;
13
	}
14

  
15
	public void setName(final String name) {
16
		this.name = name;
17
	}
18

  
19
	public boolean isRepeatable() {
20
		return repeatable;
21
	}
22

  
23
	public void setRepeatable(final boolean repeat) {
24
		this.repeatable = repeat;
25
	}
26

  
27
	public List<IndexPath> getPaths() {
28
		return paths;
29
	}
30

  
31
	public void setPaths(final List<IndexPath> paths) {
32
		this.paths = paths;
33
	}
34

  
35
	@Override
36
	public String toString() {
37
		return "OAIIndex [name=" + name + ", repeatable=" + repeatable + ", paths=" + paths + "]";
38
	}
39

  
40
}
modules/dnet-oai-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/TDSRule.java
1
package eu.dnetlib.functionality.modular.ui.oai;
2

  
3
public class TDSRule {
4

  
5
	private String id;
6
	private String title;
7

  
8
	public TDSRule(final String id, final String title) {
9
		super();
10
		this.title = title;
11
		this.id = id;
12
	}
13

  
14
	public TDSRule() {
15
		super();
16
		// TODO Auto-generated constructor stub
17
	}
18

  
19
	public String getTitle() {
20
		return title;
21
	}
22

  
23
	public void setTitle(final String title) {
24
		this.title = title;
25
	}
26

  
27
	public String getId() {
28
		return id;
29
	}
30

  
31
	public void setId(final String id) {
32
		this.id = id;
33
	}
34

  
35
	@Override
36
	public String toString() {
37
		return "TDSRule [id=" + id + ", title=" + title + "]";
38
	}
39

  
40
	@Override
41
	public int hashCode() {
42
		final int prime = 31;
43
		int result = 1;
44
		result = (prime * result) + ((id == null) ? 0 : id.hashCode());
45
		result = (prime * result) + ((title == null) ? 0 : title.hashCode());
46
		return result;
47
	}
48

  
49
	@Override
50
	public boolean equals(final Object obj) {
51
		if (this == obj) return true;
52
		if (obj == null) return false;
53
		if (!(obj instanceof TDSRule)) return false;
54
		TDSRule other = (TDSRule) obj;
55
		if (id == null) {
56
			if (other.id != null) return false;
57
		} else if (!id.equals(other.id)) return false;
58
		if (title == null) {
59
			if (other.title != null) return false;
60
		} else if (!title.equals(other.title)) return false;
61
		return true;
62
	}
63

  
64
}
modules/dnet-oai-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/IndexPath.java
1
package eu.dnetlib.functionality.modular.ui.oai;
2

  
3
/*
4
 * Need this class to let angularjs allow edit the content See
5
 * http://stackoverflow.com/questions/13714884/difficulty-with-ng-model-ng-repeat-and-inputs
6
 */
7
public class IndexPath {
8

  
9
	private String path;
10

  
11
	public IndexPath() {
12
		super();
13
		// TODO Auto-generated constructor stub
14
	}
15

  
16
	public IndexPath(final String path) {
17
		super();
18
		this.path = path;
19
	}
20

  
21
	public String getPath() {
22
		return path;
23
	}
24

  
25
	public void setPath(final String path) {
26
		this.path = path;
27
	}
28
}
modules/dnet-oai-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/OAIInternalController.java
1
package eu.dnetlib.functionality.modular.ui.oai;
2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.io.StringWriter;
6
import java.lang.reflect.Type;
7
import java.util.Collection;
8
import java.util.List;
9

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

  
14
import org.apache.commons.io.IOUtils;
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.springframework.stereotype.Controller;
18
import org.springframework.web.bind.annotation.RequestMapping;
19
import org.springframework.web.bind.annotation.RequestMethod;
20
import org.springframework.web.bind.annotation.RequestParam;
21

  
22
import com.google.common.base.Function;
23
import com.google.common.collect.ArrayListMultimap;
24
import com.google.common.collect.ImmutableList;
25
import com.google.common.collect.ImmutableSet;
26
import com.google.common.collect.Iterables;
27
import com.google.common.collect.Lists;
28
import com.google.common.collect.Multimap;
29
import com.google.gson.Gson;
30
import com.google.gson.reflect.TypeToken;
31

  
32
import eu.dnetlib.data.information.oai.publisher.PublisherField;
33
import eu.dnetlib.data.information.oai.publisher.conf.OAIConfigurationExistReader;
34
import eu.dnetlib.data.information.oai.publisher.conf.OAIConfigurationWriter;
35
import eu.dnetlib.data.information.oai.publisher.info.MDFInfo;
36
import eu.dnetlib.data.information.oai.publisher.info.SetInfo;
37

  
38
@Controller
39
public class OAIInternalController {
40

  
41
	private static final Log log = LogFactory.getLog(OAIInternalController.class); // NOPMD by marko on 11/24/08 5:02 PM
42

  
43
	@Resource
44
	private OAIConfigurationExistReader configuration;
45
	@Resource
46
	private OAIConfigurationWriter configurationWriter;
47

  
48
	@RequestMapping(value = "/ui/getExportMDFs.do")
49
	public void getExportMDFs(final HttpServletResponse response) throws Exception {
50
		List<MDFInfo> exportMDFs = configuration.getMetadataFormatInfo();
51
		String json = new Gson().toJson(exportMDFs);
52
		IOUtils.copy(new StringReader(json), response.getOutputStream());
53
	}
54

  
55
	@RequestMapping(value = "/ui/getSourceMDFs.do")
56
	public void getSourceMDFs(final HttpServletResponse response) throws Exception {
57
		List<MDFInfo> exportMDFs = configuration.getMetadataFormatInfo();
58
		List<MDFInfo> srcMDFList = Lists.transform(exportMDFs, new Function<MDFInfo, MDFInfo>() {
59

  
60
			@Override
61
			public MDFInfo apply(final MDFInfo mdf) {
62
				MDFInfo srcOnly = new MDFInfo();
63
				srcOnly.setSourceFormatName(mdf.getSourceFormatName());
64
				srcOnly.setSourceFormatLayout(mdf.getSourceFormatLayout());
65
				srcOnly.setSourceFormatInterpretation(mdf.getSourceFormatInterpretation());
66
				return srcOnly;
67
			}
68
		});
69
		// using ImmutableSet to remove duplicates
70
		ImmutableList<MDFInfo> srcMDFs = ImmutableSet.copyOf(srcMDFList).asList();
71
		String json = new Gson().toJson(srcMDFs);
72
		log.debug(json);
73
		IOUtils.copy(new StringReader(json), response.getOutputStream());
74
	}
75

  
76
	@RequestMapping(value = "/ui/getSetSpecs.do")
77
	public void getSetSpecs(final HttpServletResponse response) throws Exception {
78
		String json = new Gson().toJson(configuration.getSetSpecs());
79
		IOUtils.copy(new StringReader(json), response.getOutputStream());
80
	}
81

  
82
	@RequestMapping(value = "/ui/getMetadataFormat.do")
83
	public void getMetadataFormat(final HttpServletResponse response, @RequestParam(value = "mdPrefix", required = true) final String mdPrefix)
84
			throws Exception {
85
		MDFInfo mdf = this.configuration.getMetadataFormatInfo(mdPrefix);
86
		String mdfJson = new Gson().toJson(mdf);
87
		IOUtils.copy(new StringReader(mdfJson), response.getOutputStream());
88
	}
89

  
90
	@RequestMapping(value = "/ui/saveMetadataFormat.do", method = RequestMethod.POST)
91
	public void saveMetadataFormat(final HttpServletResponse response,
92
			final HttpServletRequest request,
93
			@RequestParam(value = "mdPrefix", required = true) final String mdPrefix) throws Exception {
94

  
95
		MDFInfo update = new Gson().fromJson(request.getReader(), MDFInfo.class);
96
		if (update.getBaseQuery() == null) {
97
			update.setBaseQuery("");
98
		}
99
		if (update.getTransformationRuleID() == null) {
100
			update.setTransformationRuleID("");
101
		}
102
		log.debug("Update to object" + update);
103
		boolean result = false;
104
		if (this.configuration.getMetadataFormatInfo(mdPrefix) != null) {
105
			log.debug("UPDATING mdPrefix = " + mdPrefix);
106
			result = this.configurationWriter.updateMetadataFormat(mdPrefix, update);
107
		} else {
108
			// ADD NEW mdf
109
			log.debug("CREATING new mdPrefix = " + mdPrefix);
110
			result = this.configurationWriter.addMetadataFormat(update);
111
		}
112
		response.getWriter().print(result);
113
	}
114

  
115
	@RequestMapping(value = "/ui/deleteMetadataFormat.do")
116
	public void deleteMetadataFormat(final HttpServletResponse response, @RequestParam(value = "mdPrefix", required = true) final String mdPrefix)
117
			throws Exception {
118
		boolean result = this.configurationWriter.deleteMetadataFormat(mdPrefix);
119
		response.getWriter().print(result);
120
	}
121

  
122
	@RequestMapping(value = "/ui/showSetDetails.do")
123
	public void showSetDetails(final HttpServletResponse response, @RequestParam(value = "setSpec", required = true) final String setSpec) throws Exception {
124
		SetInfo set = this.configuration.getSetInfo(setSpec);
125
		String json = new Gson().toJson(set);
126
		IOUtils.copy(new StringReader(json), response.getOutputStream());
127
	}
128

  
129
	@RequestMapping(value = "/ui/saveOAISet.do", method = RequestMethod.POST)
130
	public void saveOAISet(final HttpServletResponse response,
131
			final HttpServletRequest request,
132
			@RequestParam(value = "setSpec", required = true) final String setSpec) throws Exception {
133

  
134
		log.debug("setSpec = " + setSpec);
135
		SetInfo update = new Gson().fromJson(request.getReader(), SetInfo.class);
136
		log.debug("Update to object" + update);
137
		boolean result = false;
138
		if (this.configuration.getSetInfo(setSpec) != null) {
139
			log.debug("UPDATING set = " + setSpec);
140
			result = this.configurationWriter.updateOAISet(setSpec, update);
141
		} else {
142
			// ADD NEW mdf
143
			log.debug("CREATING new OAIset = " + setSpec);
144
			result = this.configurationWriter.addOAISet(update);
145
		}
146
		response.getWriter().print(result);
147
	}
148

  
149
	@RequestMapping(value = "/ui/deleteOAISet.do")
150
	public void deleteOAISet(final HttpServletResponse response, @RequestParam(value = "setSpec", required = true) final String setSpec) throws Exception {
151
		boolean result = this.configurationWriter.deleteOAISet(setSpec);
152
		response.getWriter().print(result);
153
	}
154

  
155
	@RequestMapping(value = "/ui/showIndices.do")
156
	public void showIndices(final HttpServletResponse response,
157
			@RequestParam(value = "format", required = true) final String format,
158
			@RequestParam(value = "layout", required = true) final String layout,
159
			@RequestParam(value = "interpretation", required = true) final String interpretation) throws Exception {
160

  
161
		List<PublisherField> fields = this.configuration.getFields(format, interpretation, layout);
162

  
163
		// Need to iterate over the values to build an object otherwise angularjs does not allow me to edit the content!
164
		// See http://stackoverflow.com/questions/13714884/difficulty-with-ng-model-ng-repeat-and-inputs
165
		List<OAIIndex> indices = Lists.newArrayList();
166
		for (PublisherField field : fields) {
167
			Collection<String> paths = field.getSources().get(format + "-" + layout + "-" + interpretation);
168
			List<IndexPath> pathList = Lists.newArrayList();
169
			for (String p : paths) {
170
				pathList.add(new IndexPath(p));
171
			}
172
			OAIIndex idx = new OAIIndex();
173
			idx.setRepeatable(field.isRepeatable());
174
			idx.setName(field.getFieldName());
175
			idx.setPaths(pathList);
176
			indices.add(idx);
177
		}
178
		String json = new Gson().toJson(indices);
179
		log.debug("The map of indices: " + json);
180
		IOUtils.copy(new StringReader(json), response.getOutputStream());
181
	}
182

  
183
	@RequestMapping(value = "/ui/saveIndices.do", method = RequestMethod.POST)
184
	public void saveIndices(final HttpServletResponse response,
185
			final HttpServletRequest request,
186
			@RequestParam(value = "format", required = true) final String format,
187
			@RequestParam(value = "layout", required = true) final String layout,
188
			@RequestParam(value = "interpretation", required = true) final String interpretation) throws Exception {
189

  
190
		StringWriter sw = new StringWriter();
191
		IOUtils.copy(request.getInputStream(), sw);
192
		Type collectionType = new TypeToken<List<OAIIndex>>() {}.getType();
193
		List<OAIIndex> indexes = new Gson().fromJson(sw.toString(), collectionType);
194
		final String mdformatKey = format + "-" + layout + "-" + interpretation;
195
		List<PublisherField> updatedIndices = Lists.transform(indexes, new Function<OAIIndex, PublisherField>() {
196

  
197
			@Override
198
			public PublisherField apply(final OAIIndex oaiIndex) {
199
				PublisherField f = new PublisherField();
200
				f.setFieldName(oaiIndex.getName());
201
				f.setRepeatable(oaiIndex.isRepeatable());
202
				Multimap<String, String> paths = ArrayListMultimap.create();
203
				for (IndexPath path : oaiIndex.getPaths()) {
204
					paths.put(mdformatKey, path.getPath());
205
				}
206
				f.setSources(paths);
207
				return f;
208
			}
209

  
210
		});
211

  
212
		log.debug("Updating indices" + indexes);
213
		boolean result = this.configurationWriter.updateIndices(format, layout, interpretation, updatedIndices);
214
		response.getWriter().print(result);
215
	}
216

  
217
	@RequestMapping(value = "/ui/saveNewIndex.do")
218
	public void saveNewIndex(final HttpServletResponse response,
219
			@RequestParam(value = "format", required = true) final String format,
220
			@RequestParam(value = "layout", required = true) final String layout,
221
			@RequestParam(value = "interpretation", required = true) final String interpretation,
222
			@RequestParam(value = "indexName", required = true) final String indexName,
223
			@RequestParam(value = "repeatable", required = true) final boolean repeatable,
224
			@RequestParam(value = "paths", required = true) final String paths) throws Exception {
225

  
226
		String[] thePaths = paths.split(",");
227
		boolean result = this.configurationWriter.addNewIndex(format, layout, interpretation, indexName, repeatable, thePaths);
228
		response.getWriter().print(result);
229
	}
230

  
231
	@RequestMapping(value = "/ui/saveNewPathIndex.do")
232
	public void saveNewPathIndex(final HttpServletResponse response,
233
			@RequestParam(value = "format", required = true) final String format,
234
			@RequestParam(value = "layout", required = true) final String layout,
235
			@RequestParam(value = "interpretation", required = true) final String interpretation,
236
			@RequestParam(value = "indexName", required = true) final String indexName,
237
			@RequestParam(value = "newPath", required = true) final String newPath) throws Exception {
238

  
239
		List<PublisherField> fields = this.configurationWriter.getConfiguration().getFields(format, interpretation, layout);
240
		Iterable<PublisherField> updated = Iterables.transform(fields, new Function<PublisherField, PublisherField>() {
241

  
242
			@Override
243
			public PublisherField apply(final PublisherField field) {
244
				if (field.getFieldName().equals(indexName)) {
245
					field.getSources().get(format + "-" + layout + "-" + interpretation).add(newPath);
246
				}
247
				return field;
248
			}
249
		});
250
		boolean result = this.configurationWriter.updateIndices(format, layout, interpretation, Lists.newArrayList(updated));
251
		response.getWriter().print(result);
252
	}
253

  
254
	@RequestMapping(value = "/ui/getTransformationRules.do")
255
	public void getTransformationRules(final HttpServletResponse response) throws IOException {
256

  
257
		final String query = "for $x in collection('/db/DRIVER/TransformationRuleDSResources/TransformationRuleDSResourceType')"
258
				+ " return concat($x//RESOURCE_IDENTIFIER/@value/string(), ':-:', $x//CONFIGURATION//TITLE)";
259
		Iterable<TDSRule> rules = this.configuration.getQueryExecutor().query(TDSRule.class, query);
260
		String json = new Gson().toJson(Lists.newArrayList(rules));
261
		IOUtils.copy(new StringReader(json), response.getOutputStream());
262
	}
263

  
264
}
modules/dnet-oai-modular-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/oai/OAIConfigEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.oai;
2

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

  
6
import org.springframework.ui.ModelMap;
7

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

  
10
public class OAIConfigEntryPointController extends ModuleEntryPoint {
11

  
12
	@Override
13
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
14
		// empty entry point intialization: everything is done via angular js and the Internal Controller.
15
	}
16

  
17
}
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/oai/webContext-modular-ui-oai.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:p="http://www.springframework.org/schema/p"
4
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5

  
6
	<bean name="/ui/oaiConfig.do"
7
		class="eu.dnetlib.functionality.modular.ui.oai.OAIConfigEntryPointController"
8
		p:group="Configuration" p:menu="OAI Configuration" p:title="OAI Configuration" 
9
		p:description="OAI configuration page" p:order="1" p:groupOrder="60" >
10
		<property name="permissionLevels">
11
			<set>
12
				<value>DS_ADMIN</value>
13
			</set>
14
		</property>
15
		</bean>
16

  
17
</beans>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oaiConfig.st
1
$common/master( header={ $ui/oai/header()$
2
<script type="text/javascript" src="../resources/js/oaiCommon.js"></script>
3
<script type="text/javascript" src="../resources/js/oai.js"></script>
4
}, onLoad={}, body={
5
<div ng-app="oaiUI" ng-controller="oaiCtrl">
6
	<div class="row">
7
		<!-- Sidebar content -->
8
		<div class="col-xs-12 col-sm-12 col-md-4 col-lg-3" id="sidebar">
9
			<label>Export Metadata Formats</label>
10
			<ul class="nav nav-pills nav-stacked">
11
				<li ng-repeat="mdformat in exportFormats"
12
					ng-click="showExportMetadataFormat(mdformat)"><a href="#">{{mdformat.prefix}}
13
						<span class="glyphicon glyphicon-chevron-right pull-right"></span>
14
				</a></li>
15
				<li ng-click="showMDFModal()"><a href="#"><span
16
						class="label label-info">Add</span></a>
17
			</ul>
18

  
19
			<label>Source Metadata Formats</label>
20
			<ul class="nav nav-pills nav-stacked">
21
				<li ng-repeat="mdformat in srcFormats"
22
					ng-click="showSrcMetadataFormat(mdformat)"><a href="#">{{mdformat.sourceFormatName}}
23
						- {{mdformat.sourceFormatLayout}} -
24
						{{mdformat.sourceFormatInterpretation}} <span
25
						class="glyphicon glyphicon-chevron-right pull-right"></span>
26
				</a></li>
27
			</ul>
28

  
29
			<label>OAI Sets</label>
30
			<ul class="nav nav-pills nav-stacked">
31
				<li ng-repeat="setSpec in setSpecs" ng-click="showOAISet(setSpec)"><a
32
					href="#">{{setSpec}} <span
33
						class="glyphicon glyphicon-chevron-right pull-right"></span>
34
				</a></li>
35
				<li ng-click="showSetModal()"><a href="#"><span
36
						class="label label-info">Add</span></a>
37
			</ul>
38
		</div>
39

  
40
		<!-- right pane with the actual content based on the item selected on the sidebar -->
41
		<div
42
			class="animate-switch-container col-xs-12 col-sm-12 col-md-8 col-lg-9"
43
			ng-switch on="show">
44
			<div class="animate-switch" ng-switch-when="mdformat">$ui/oai/mdfDetails()$</div>
45
			<div class="animate-switch" ng-switch-when="source">$ui/oai/srcMdfDetails()$</div>
46
			<div class="animate-switch" ng-switch-when="set">$ui/oai/setDetails()$</div>
47
		</div>
48
	</div>
49
	$ui/oai/common()$
50
</div>
51

  
52
} )$
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/mdfDetails.st
1
<div class="well">
2
	<form class="form-horizontal">
3
		<fieldset>
4
			<legend>Metadata Format: {{currentMdf.prefix}}</legend>
5
			<div class="form-group">
6
				<label class="control-label col-sm-2" for="enabled">Enabled</label>
7
				<div class="col-sm-10">
8
					<div class="checkbox">
9
						<input type="checkbox" ng-model="currentMdf.enabled" id="enabled" />
10
					</div>
11
				</div>
12
			</div>
13
			<div class="form-group">
14
				<label class="control-label col-sm-2" for="prefix">Prefix</label>
15
				<div class="col-sm-10">
16
					<input class="form-control" ng-model="currentMdf.prefix"
17
						id="prefix" type="text" />
18
				</div>
19
			</div>
20
			<div class="form-group">
21
				<label class="control-label col-sm-2" for="schema">Schema</label>
22
				<div class="col-sm-10">
23
					<input class="form-control" ng-model="currentMdf.schema"
24
						id="schema" type="text" />
25
				</div>
26
			</div>
27
			<div class="form-group">
28
				<label class="control-label col-sm-2" for="namespace">Namespace</label>
29
				<div class="col-sm-10">
30
					<input class="form-control" ng-model="currentMdf.namespace"
31
						id="namespace" type="text" />
32
				</div>
33
			</div>
34

  
35
			<!-- Source metadata format div -->
36
			$ui/oai/srcFormatDiv(mdf={currentMdf})$
37
			
38
			
39
			<!--
40
			<div class="form-group">
41
	<label class="control-label col-sm-2">Source Format: $currentMdf$</label>
42
	<div class="col-sm-3">
43
		<div class="input-group">
44
			<span class="input-group-addon">Name:</span> <input
45
				class="form-control" ng-model="currentMdf.sourceFormatName"
46
				placeholder="name" type="text" />
47
		</div>
48
	</div>
49
	<div class="col-sm-3">
50
		<div class="input-group">
51
			<span class="input-group-addon">Layout:</span> <input
52
				class="form-control" ng-model="currentMdf.sourceFormatLayout"
53
				placeholder="layout" type="text" />
54
		</div>
55
	</div>
56
	<div class="col-sm-4">
57
		<div class="input-group">
58
			<span class="input-group-addon">Interpretation:</span> <input
59
				ng-model="currentMdf.sourceFormatInterpretation"
60
				class="form-control" placeholder="interpretation" type="text" />
61
		</div>
62
	</div>
63
</div>
64
			-->
65
			
66

  
67
			<div class="form-group">
68
				<label class="control-label col-sm-2" for="query">Base query</label>
69
				<div class="col-sm-10">
70
					<input class="form-control" ng-model="currentMdf.baseQuery"
71
						id="query" type="text" />
72
				</div>
73
			</div>
74
			<div class="form-group">
75
				<label class="control-label col-sm-2" for="tds">Transformation
76
					Rule</label>
77
				<div class="col-sm-10">
78
					<div class="select">
79
						<select ng-model="currentMdf.transformationRuleID" id="tds"
80
							class="form-control">
81
							<option value=""
82
								ng-selected="equals(currentMdf.transformationRuleID,'')">--
83
								no rule --</option>
84
							<option ng-repeat="rule in tdsRules" value="{{rule.id}}"
85
								ng-selected="equals(rule.id,currentMdf.transformationRuleID)">{{rule.title}}</option>
86
						</select>
87
					</div>
88
				</div>
89
			</div>
90

  
91
			<div class="form-group">
92
				<div class="col-sm-offset-2 col-sm-10">
93
					<button class="btn btn-lg btn-success"
94
						ng-click="saveExportMetadataFormat(currentPrefix, currentMdf)"
95
						tooltip rel="tooltip" data-placement="left" title="Save changes">
96
						<span class="glyphicon glyphicon-ok"></span>
97

  
98
					</button>
99
					<button class="btn btn-lg btn-info"
100
						ng-click="loadExportMetadataFormat(currentPrefix)" tooltip
101
						rel="tooltip" data-placement="bottom" title="Discard changes">
102
						<span class="glyphicon glyphicon-repeat"></span>
103
					</button>
104
					<button class="btn btn-lg btn-danger"
105
						ng-click="deleteExportMetadataFormat(currentPrefix)" tooltip
106
						rel="tooltip" data-placement="right" title="Delete format">
107
						<span class="glyphicon glyphicon-remove"></span>
108
					</button>
109
				</div>
110
			</div>
111
		</fieldset>
112
	</form>
113
</div>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/indexDetails.st
1
<form class="form-horizontal">
2
	<fieldset>
3
		<legend>Indices on OAI store:</legend>
4
		<div ng-repeat="oaiIndex in indices"
5
			ng-init="indexPathList = oaiIndex.paths">
6
			<div class="form-group">
7
				<div class="col-sm-12">
8
					<span class="label label-primary">{{oaiIndex.name}}</span>
9
					<div class="select">
10
						<select ng-model="oaiIndex.repeatable">
11
							<option value="true" ng-selected="oaiIndex.repeatable">Repeatable</option>
12
							<option value="false" ng-selected="!oaiIndex.repeatable">Single
13
								value</option>
14
						</select>
15
					</div>
16
				</div>
17
			</div>
18
			<div class="form-group">
19
				<div class="col-sm-12">
20
					<p class="form-control-static">
21
						Paths:
22
						<button ng-hide="!oaiIndex.repeatable" class="btn btn-link"
23
							type="button" ng-click="showNewPathModal(oaiIndex)">add
24
							new path</button>
25
					</p>
26
				</div>
27
			</div>
28
			<div class="form-group">
29
				<div class="col-sm-12">
30
					<div ng-repeat="p in indexPathList">
31
						<input ng-model="p.path" type="text" class="form-control" />
32
						<button class="btn btn-link" type="button"
33
							ng-click="deleteIndexPath(indexPathList, p)">remove path</button>
34
					</div>
35
				</div>
36
			</div>
37
			<hr />
38
		</div>
39

  
40
		<div class="form-group">
41
			<div class="col-sm-10">
42
				<button class="btn btn-large btn-success"
43
					ng-click="saveIndexes(currentMdf.sourceFormatName, currentMdf.sourceFormatLayout, currentMdf.sourceFormatInterpretation, indices)"
44
					tooltip rel="tooltip" data-placement="left" title="Save changes">
45
					<span class="glyphicon glyphicon-ok"></span>
46
				</button>
47
				<button class="btn btn-large btn-info"
48
					ng-click="showStoreIndexes(currentMdf.sourceFormatName, currentMdf.sourceFormatLayout, currentMdf.sourceFormatInterpretation)"
49
					tooltip rel="tooltip" data-placement="bottom"
50
					title="Discard changes">
51
					<span class="glyphicon glyphicon-repeat"></span>
52
				</button>
53
				<button class="btn btn-large btn-primary"
54
					ng-click="showIndexModal()" tooltip rel="tooltip"
55
					data-placement="right" title="Add new index">
56
					<span class="glyphicon glyphicon-plus"></span>
57
				</button>
58

  
59
			</div>
60
		</div>
61
	</fieldset>
62
</form>
63

  
64

  
65

  
66

  
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/setDetails.st
1
<div class="well">
2
	<form class="form-horizontal">
3
		<fieldset>
4
			<legend>{{currentSetSpec}} OAI Set</legend>
5

  
6
			<div class="form-group">
7
				<label class="control-label col-sm-2" for="enabled">Enabled</label>
8
				<div class="col-sm-10">
9
					<input type="checkbox" ng-model="currentSet.enabled" id="enabled" />
10
				</div>
11
			</div>
12
			<div class="form-group">
13
				<label class="control-label col-sm-2" for="spec">SetSpec</label>
14
				<div class="col-sm-10">
15
					<input ng-model="currentSet.setSpec" id="spec" type="text"
16
						class="form-control" />
17
				</div>
18
			</div>
19
			<div class="form-group">
20
				<label class="control-label col-sm-2" for="name">Name</label>
21
				<div class="col-sm-10">
22
					<input class="form-control" ng-model="currentSet.setName" id="name"
23
						type="text" />
24
				</div>
25
			</div>
26
			<div class="form-group">
27
				<label class="control-label col-sm-2" for="descr">Description</label>
28
				<div class="col-sm-10">
29
					<textarea rows="10" ng-model="currentSet.setDescription" id="descr"
30
						class="form-control"></textarea>
31
				</div>
32
			</div>
33
			<div class="form-group">
34
				<label class="control-label col-sm-2" for="prefix">Query</label>
35
				<div class="col-sm-10">
36
					<input class="form-control" ng-model="currentSet.query" id="query"
37
						type="text" />
38
				</div>
39
			</div>
40

  
41
			<div class="form-group">
42
				<div class="col-sm-offset-2 col-sm-10">
43
					<button class="btn btn-large btn-success"
44
						ng-click="saveOAISet(currentSetSpec, currentSet)" tooltip
45
						rel="tooltip" data-placement="left" title="Save changes">
46
						<span class="glyphicon glyphicon-ok"></span>
47
					</button>
48
					<button class="btn btn-large btn-info"
49
						ng-click="showOAISet(currentSetSpec)" tooltip rel="tooltip"
50
						data-placement="bottom" title="Discard changes">
51
						<span class="glyphicon glyphicon-repeat"></span>
52
					</button>
53
					<button class="btn btn-large btn-danger"
54
						ng-click="deleteOAISet(currentSetSpec)" tooltip rel="tooltip"
55
						data-placement="right" title="Delete OAI set">
56
						<span class="glyphicon glyphicon-remove"></span>
57
					</button>
58
				</div>
59
			</div>
60

  
61
		</fieldset>
62
	</form>
63
</div>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/srcFormatDiv.st
1
<div class="form-group">
2
	<label class="control-label col-sm-2">Source Format:</label>
3
	<div class="col-sm-3">
4
		<div class="input-group">
5
			<span class="input-group-addon">Name:</span> <input
6
				class="form-control" ng-model="$mdf$.sourceFormatName"
7
				placeholder="name" type="text" />
8
		</div>
9
	</div>
10
	<div class="col-sm-3">
11
		<div class="input-group">
12
			<span class="input-group-addon">Layout:</span> <input
13
				class="form-control" ng-model="$mdf$.sourceFormatLayout"
14
				placeholder="layout" type="text" />
15
		</div>
16
	</div>
17
	<div class="col-sm-4">
18
		<div class="input-group">
19
			<span class="input-group-addon">Interpretation:</span> <input
20
				ng-model="$mdf$.sourceFormatInterpretation"
21
				class="form-control" placeholder="interpretation" type="text" />
22
		</div>
23
	</div>
24
</div>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/srcMdfDetails.st
1
<div class="well">
2
	<form class="form-horizontal">
3
		<fieldset>
4
			<legend>Source Metadata Format:
5
				{{currentMdf.sourceFormatName}}</legend>
6

  
7
			<div class="form-group">
8
				<label class="control-label col-sm-2" for="name">Name:</label>
9
				<div class="col-sm-2">
10
					<p class="form-control-static">{{currentMdf.sourceFormatName}}</p>
11
				</div>
12
				<label class="control-label col-sm-2" for="name">Layout:</label>
13
				<div class="col-sm-2">
14
					<p class="form-control-static">{{currentMdf.sourceFormatLayout}}</p>
15
				</div>
16
				<label class="control-label col-sm-2" for="name">Interpretation:</label>
17
				<div class="col-sm-2">
18
					<p class="form-control-static">{{currentMdf.sourceFormatInterpretation}}</p>
19
				</div>
20

  
21
			</div>
22
		</fieldset>
23
	</form>
24
</div>
25
<div class="well">$ui/oai/indexDetails()$</div>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/common.st
1
<!-- Modal to add new metadata format -->
2
<div id="mdfModal" class="modal fade" tabindex="-1" role="dialog">
3
	<div class="modal-dialog modal-lg">
4
		<form class="form-horizontal"
5
			ng-submit="saveExportMetadataFormat(modalMdf.prefix, modalMdf)">
6
			<div class="modal-content">
7
				<div class="modal-header">
8
					<button type="button" class="close" data-dismiss="modal">&times;</button>
9
					<h4 class="modal-title">New OAI Metadata Format</h4>
10
				</div>
11
				<div class="modal-body">
12

  
13

  
14
					<div class="form-group">
15
						<label for="prefix" class="control-label col-lg-2">Prefix</label>
16
						<div class="col-lg-10">
17
							<input class="form-control" ng-model="modalMdf.prefix"
18
								id="prefix" type="text" />
19
						</div>
20
					</div>
21

  
22
					<div class="form-group">
23
						<label for="schema" class="control-label col-lg-2">Schema</label>
24
						<div class="col-lg-10">
25
							<input class="form-control" ng-model="modalMdf.schema"
26
								id="schema" type="text" />
27
						</div>
28
					</div>
29

  
30
					<div class="form-group">
31
						<label for="namespace" class="control-label col-lg-2">Namespace</label>
32
						<div class="col-lg-10">
33
							<input class="form-control" ng-model="modalMdf.namespace"
34
								id="namespace" type="text" />
35
						</div>
36
					</div>
37

  
38
					<div class="form-group">
39
						<label class="control-label col-lg-2">Source Format</label>
40
						<div class="col-lg-3">
41
							<div class="input-group">
42
								<span class="input-group-addon">Name:</span> <input
43
									class="form-control" ng-model="modalMdf.sourceFormatName"
44
									placeholder="name" type="text" />
45
							</div>
46
						</div>
47
						<div class="col-lg-3">
48
							<div class="input-group">
49
								<span class="input-group-addon">Layout:</span> <input
50
									class="form-control" ng-model="modalMdf.sourceFormatLayout"
51
									placeholder="layout" type="text" />
52
							</div>
53
						</div>
54
						<div class="col-lg-4">
55
							<div class="input-group">
56
								<span class="input-group-addon">Interpretation:</span> <input
57
									class="form-control"
58
									ng-model="modalMdf.sourceFormatInterpretation"
59
									placeholder="interpretation" type="text" />
60
							</div>
61
						</div>
62
					</div>
63

  
64
					<div class="form-group">
65
						<label for="query" class="control-label col-lg-2">Base
66
							query</label>
67
						<div class="col-lg-10">
68
							<input class="form-control" ng-model="modalMdf.baseQuery"
69
								id="query" type="text" />
70
						</div>
71

  
72
					</div>
73
					<div class="form-group">
74
						<label class="control-label col-lg-2" for="tds">Transformation
75
							Rule</label>
76
						<div class="col-lg-10">
77
							<div class="select">
78
								<select id="tds" ng-model="modalMdf.transformationRuleID"
79
									class="form-control">
80
									<option value=""
81
										ng-selected="equals(modalMdf.transformationRuleID,'')">--
82
										no rule --</option>
83
									<option ng-repeat="rule in tdsRules" value="{{rule.id}}"
84
										ng-selected="equals(rule.id,modalMdf.transformationRuleID)">{{rule.title}}</option>
85
								</select>
86
							</div>
87
						</div>
88
					</div>
89

  
90
					<div class="form-group">
91
						<label class="control-label col-lg-2" for="enabled">Enabled</label>
92
						<div class="col-lg-10">
93
							<input type="checkbox" ng-model="modalMdf.enabled" id="enabled" />
94
						</div>
95
					</div>
96
				</div>
97

  
98
				<div class="modal-footer">
99
					<button class="btn btn-primary" type="submit">Save</button>
100
				</div>
101
			</div>
102
		</form>
103
	</div>
104
</div>
105

  
106
<!-- Modal to add new set  -->
107
<div id="setModal" class="modal fade" tabindex="-1" role="dialog">
108
	<div class="modal-dialog modal-lg">
109
		<form class="form-horizontal"
110
			ng-submit="saveOAISet(modalSet.setSpec, modalSet)">
111
			<div class="modal-content">
112
				<div class="modal-header">
113
					<button type="button" class="close" data-dismiss="modal">&times;</button>
114
					<h4 class="modal-title">New OAI Set</h4>
115
				</div>
116
				<div class="modal-body">
117

  
118
					<div class="form-group">
119
						<label class="control-label col-lg-2" for="enabled">Enabled</label>
120
						<div class="col-lg-10">
121
							<div class="checkbox">
122
								<input type="checkbox" ng-model="modalSet.enabled" id="enabled" />
123
							</div>
124
						</div>
125
					</div>
126
					<div class="form-group">
127
						<label class="control-label col-lg-2" for="spec">SetSpec</label>
128
						<div class="col-lg-10">
129
							<input class="form-control" ng-model="modalSet.setSpec" id="spec"
130
								type="text" />
131
						</div>
132

  
133
					</div>
134
					<div class="form-group">
135
						<label for="name" class="control-label col-lg-2">Name</label>
136
						<div class="col-lg-10">
137
							<input class="form-control" ng-model="modalSet.setName" id="name"
138
								type="text" />
139
						</div>
140

  
141
					</div>
142
					<div class="form-group">
143
						<label for="descr" class="control-label col-lg-2">Description</label>
144
						<div class="col-lg-10">
145
							<textarea rows="10" ng-model="modalSet.setDescription" id="descr"
146
								class="input-xxlarge"></textarea>
147
						</div>
148

  
149
					</div>
150
					<div class="form-group">
151
						<label for="prefix" class="control-label col-lg-2">Query</label>
152
						<div class="col-lg-10">
153
							<input class="form-control" ng-model="modalSet.query" id="query"
154
								type="text" />
155
						</div>
156
					</div>
157
				</div>
158
				<div class="modal-footer">
159
					<div class="form-group">
160
						<div class="col-lg-offset-2 col-lg-10">
161
							<button class="btn btn-primary" type="submit">Save</button>
162
						</div>
163
					</div>
164
				</div>
165
			</div>
166
		</form>
167
	</div>
168
</div>
169

  
170

  
171
<!-- Modal to add new index TODO: add link that opens this! -->
172
<div id="indexModal" class="modal fade" tabindex="-1" role="dialog">
173
	<div class="modal-dialog modal-lg">
174
		<form class="form-horizontal"
175
			ng-submit="saveNewIndex(currentMdf.sourceFormatName, currentMdf.sourceFormatLayout, currentMdf.sourceFormatInterpretation, modalIndex)">
176

  
177
			<div class="modal-content">
178
				<div class="modal-header">
179
					<button type="button" class="close" data-dismiss="modal">&times;</button>
180
					<h4 class="modal-title">New Index</h4>
181
				</div>
182
				<div class="modal-body">
183
					<div class="form-group">
184
						<label class="control-label col-lg-2" for="idxName">Index
185
							name</label>
186
						<div class="col-lg-10">
187
							<input ng-model="modalIndex.name" id="idxName" type="text" /> <select
188
								ng-model="modalIndex.repeatable" class="form-control">
189
								<option value="true" ng-selected="modalIndex.repeatable">Repeatable</option>
190
								<option value="false" ng-selected="!modalIndex.repeatable">Single
191
									value</option>
192
							</select>
193
						</div>
194
					</div>
195
					<div class="form-group">
196
						<label class="control-label col-lg-2" for="path">Path
197
							(multiple paths as ',' separated field)</label>
198
						<div class="col-lg-10">
199
							<input class="form-control" ng-model="modalIndex.paths" id="path"
200
								type="text" />
201
						</div>
202
					</div>
203
				</div>
204

  
205
				<div class="modal-footer">
206
					<div class="form-group">
207
						<div class="col-lg-offset-2 col-lg-10">
208
							<button class="btn btn-primary" type="submit">Save</button>
209
						</div>
210
					</div>
211
				</div>
212
			</div>
213
		</form>
214
	</div>
215
</div>
216

  
217
<!-- Modal to add new path to an index  -->
218
<div id="indexPathModal" class="modal fade" tabindex="-1" role="dialog">
219
	<div class="modal-dialog modal-lg">
220
		<form class="form-horizontal"
221
			ng-submit="saveNewPathIndex(currentMdf.sourceFormatName, currentMdf.sourceFormatLayout, currentMdf.sourceFormatInterpretation, modalIndex.name, newPath)">
222

  
223
			<div class="modal-content">
224
				<div class="modal-header">
225
					<button type="button" class="close" data-dismiss="modal">&times;</button>
226
					<h4 class="modal-title">New path for index {{modalIndex.name}}</h4>
227
				</div>
228
				<div class="modal-body">
229

  
230
					<div class="form-group">
231
						<label class="control-label col-lg-2" for="path">Path:</label>
232
						<div class="col-lg-10">
233
							<input class="form-control" ng-model="newPath" id="newPath"
234
								type="text" />
235
						</div>
236
					</div>
237
				</div>
238
				<div class="modal-footer">
239
					<div class="form-group">
240
						<div class="col-lg-offset-2 col-lg-10">
241
							<button class="btn btn-primary" type="submit">Save</button>
242
						</div>
243
					</div>
244
				</div>
245
			</div>
246
		</form>
247
	</div>
248
</div>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/oai/header.st
1
<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
2

  
3
<style>
4
	.gridStyle {
5
		width: 100%; 
6
		height: 150px;
7
		margin-bottom: 20px;
8
		font-size: 11px;
9
	}
10
	
11
	.gridStyle-big {
12
		width: 100%; 
13
		height: 300px;
14
		margin-bottom: 20px;
15
		font-size: 11px;
16
	}
17
		
18
	.modal-large {
19
		width: 60%;
20
		left: 20%;
21
		margin-left: auto;
22
		margin-right: auto;
23
		margin-top: 50px;
24
		margin-bottom: 50px;
25
	}
26
</style>
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/oai.js
1
var module = angular.module('oaiUI', []);
2

  
3
function oaiCtrl($scope, $http) {
4

  
5
	common_init($scope, $http);
6
	
7
	$scope.loadTransformationRules = function (){
8
		$http.get('getTransformationRules.do')
9
	    .success(
10
	        function(data) {
11
	        	$scope.tdsRules = data;
12
	        }
13
	    )
14
	    .error(
15
	        function() {
16
	        	show_notification('error', 'Cannot load info about trasnformation rules');
17
	        }
18
	    );
19
	}
20
	
21
	$scope.equals = function(s1,s2){
22
		return s1 == s2;
23
	}
24
	
25
	//EXPORT METADATA FORMAT//
26

  
27
	$scope.showExportMetadataFormat = function(mdFormat) {
28
		showSpinner();
29
		$scope.show='mdformat';
30
		$scope.currentMdf = mdFormat;
31
		$scope.currentPrefix = mdFormat.prefix;
32
		$scope.loadTransformationRules();
33
		hideSpinner();
34
	}
35
	
36
	$scope.loadExportMetadataFormat = function(mdPrefix){
37
		showSpinner();
38
		$http.get('getMetadataFormat.do?mdPrefix='+mdPrefix)
39
        .success(
40
            function(data) {
41
            	$scope.currentMdf = data;
42
            	$scope.currentPrefix = mdPrefix;
43
            }
44
        )
45
        .error(
46
            function() {
47
            	show_notification('error', 'Cannot load info about export metadata format '+mdPrefix);
48
            }
49
        );
50
		$scope.loadTransformationRules();
51
		hideSpinner();
52
	}
53
	
54
	$scope.saveExportMetadataFormat = function(mdPrefix, mdf, isNew) {
55
		$('.modal').modal('hide');
56
		showSpinner();
57
		$http.post('saveMetadataFormat.do?mdPrefix='+mdPrefix, mdf)
58
        .success(
59
            function(data) {
60
            	if(data) {
61
            		var newSourceMdf = {"sourceFormatName":mdf.sourceFormatName, "sourceFormatLayout":mdf.sourceFormatLayout, "sourceFormatInterpretation":mdf.sourceFormatInterpretation};
62
            		if(isNew){
63
            			$scope.exportFormats.push(mdf);
64
            			if(!contains($scope.srcFormats, newSourceMdf)) $scope.srcFormats.push(newSourceMdf);
65
            			show_notification('success', "Metadata format successfully added"); 
66
            		}
67
            		else{
68
            			//did we updated the mdprefix? We have to remove the old mdPrefix!
69
            			if(mdPrefix != mdf.prefix){
70
                			removeFromList($scope.exportFormats, $scope.currentMdf);
71
                		}
72
            			//did we updated the source? We have to add the new source, if it is not there yet
73
            			if(!contains($scope.srcFormats, newSourceMdf)) $scope.srcFormats.push(newSourceMdf);
74
                		
75
                		upsertExportFormat($scope.exportFormats, mdf, mdPrefix);
76
                		show_notification('success', "Metadata format successfully updated"); 
77
            		}
78
            	}
79
            	else show_notification('error', 'Cannot update mdformat '+mdPrefix);
80
            }
81
        ).error(
82
            function() {show_notification('error', 'Cannot update mdformat '+mdPrefix);}
83
        );
84
		hideSpinner();
85
	}
86
	
87
	$scope.deleteExportMetadataFormat = function(mdPrefix){
88
		showSpinner();
89
		$http.post('deleteMetadataFormat.do?mdPrefix='+mdPrefix)
90
        .success(
91
            function(data) {
92
            	if(data) {
93
            		show_notification('success', "Metadata format successfully removed"); 
94
            		removeFromList($scope.exportFormats, $scope.currentMdf);
95
            		$scope.show='';
96
            		$scope.currentMdf = '';
97
            		$scope.currentPrefix = '';
98
            	}
99
            	else show_notification('error', 'Cannot delete mdformat '+mdPrefix);
100
            	
101
            }
102
        ).error(
103
            function() {
104
            	show_notification('error', 'Cannot delete mdformat '+mdPrefix);
105
            }
106
        );
107
		hideSpinner();
108
	}
109
	
110
	//SOURCE METADATA FORMATS and INDEXES//
111
	
112
	$scope.showSrcMetadataFormat = function(mdFormat){
113
		showSpinner();
114
		$scope.show='source';
115
		$scope.currentMdf = mdFormat
116
		$scope.currentPrefix = mdFormat.sourceFormatName
117
		$scope.showStoreIndexes($scope.currentMdf.sourceFormatName, $scope.currentMdf.sourceFormatLayout, $scope.currentMdf.sourceFormatInterpretation);
118
		hideSpinner();
119
	}
120
	
121
	$scope.saveIndexes = function(sourceFormatName, sourceFormatLayout, sourceFormatInterpretation, indices) {
122
		showSpinner();
123
		$http.post('saveIndices.do?format='+sourceFormatName+'&layout='+sourceFormatLayout+'&interpretation='+sourceFormatInterpretation, indices)
124
        .success(
125
            function(data) {
126
            	if(data) show_notification('success', "Indexes successfully updated");
127
            	else show_notification('error', 'Cannot update indices for metadata format '+sourceFormatName);
128
            	hideSpinner();
129
            }
130
        ).error(
131
            function() {
132
            	hideSpinner();
133
            	show_notification('error', 'Cannot update indexes ');
134
            }
135
        );
136
	}
137
	
138
	$scope.saveNewIndex = function(sourceFormatName, sourceFormatLayout, sourceFormatInterpretation, index){
139
		$('.modal').modal('hide');
140
		showSpinner();
141
		$http.post('saveNewIndex.do?format='+sourceFormatName+'&layout='+sourceFormatLayout+'&interpretation='+sourceFormatInterpretation+'&indexName='+index.name+'&paths='+index.paths+'&repeatable='+index.repeatable)
142
		 .success(
143
		            function(data) {
144
		            	if(data) {
145
		            		show_notification('success', "Index successfully created"); 
146
		            	}
147
		            	else show_notification('error', 'Cannot create index for metadata format '+sourceFormatName);
148
		            	
149
		            }
150
		        ).error(
151
		            function() {
152
		            	
153
		            	show_notification('error', 'Cannot create index on mdf '+sourceFormatName+" - "+sourceFormatLayout+ " - "+sourceFormatInterpretation);
154
		            }
155
		        );
156
		hideSpinner();
157
	}
158
	
159
	$scope.saveNewPathIndex = function(sourceFormatName, sourceFormatLayout, sourceFormatInterpretation, indexName, newPath){
160
		$('.modal').modal('hide');
161
		showSpinner();
162
		$http.post('saveNewPathIndex.do?format='+sourceFormatName+'&layout='+sourceFormatLayout+'&interpretation='+sourceFormatInterpretation+'&indexName='+indexName+'&newPath='+newPath)
163
		 .success(
164
		            function(data) {
165
		            	if(data) {
166
		            		show_notification('success', "Path successfully added"); 
167
		            	}
168
		            	else show_notification('error', 'Cannot add path to index '+indexName);
169
		            	
170
		            }
171
		        ).error(
172
		            function() {
173
		            	
174
		            	show_notification('error', 'Cannot add path to index '+indexName);
175
		            }
176
		        );
177
		hideSpinner();
178
	}
179
	
180
	$scope.showStoreIndexes = function(sourceFormatName, sourceFormatLayout, sourceFormatInterpretation){
181
		showSpinner();
182
		$http.get('showIndices.do?format='+sourceFormatName+'&layout='+sourceFormatLayout+'&interpretation='+sourceFormatInterpretation)
183
        .success(
184
            function(data) {
185
            	$scope.indices = data;
186
            }
187
        )
188
        .error(
189
            function() {
190
            	show_notification('error', 'Cannot show info about indices of metadata format='+sourceFormatName+' layout='+sourceFormatLayout+' interpretation='+sourceFormatInterpretation);
191
            }
192
        );
193
		hideSpinner();
194
	}
195
	
196
	
197
	$scope.deleteIndexPath = function(indexPathList, indexPath){
198
		removeFromList(indexPathList, indexPath);
199
	}
200
	
201
	//OAI SETS//
202
	
203
	$scope.showOAISet = function(setSpec){
204
		showSpinner();
205
		$scope.show='set';
206
		$http.get('showSetDetails.do?setSpec='+setSpec)
207
		.success(
208
			function(data){
209
				$scope.currentSet = data;
210
				$scope.currentSetSpec = setSpec;
211
			}
212
		).error( 
213
			function() {
214
				show_notification('error', 'Cannot show info about OAI set '+setSpec);
215
			}
216
		);
217
		hideSpinner();
218
	}
219
	
220
	$scope.deleteOAISet = function(setSpec){
221
		showSpinner();
222
		$http.post('deleteOAISet.do?setSpec='+setSpec)
223
        .success(
224
            function(data) {
225
            	if(data) {
226
            		removeFromList($scope.setSpecs, setSpec);
227
            		$scope.show = '';
228
            		$scope.currentSetSpec = '';
229
            		$scope.currentSet = '';
230
            		show_notification('success', "OAI set successfully removed"); 
231
            	}
232
            	else show_notification('error', 'Cannot delete OAI set '+setSpec);
233
            }
234
        ).error(
235
            function() {
236
            	show_notification('error', 'Cannot delete OAI set '+setSpec);
237
            }
238
        );
239
		hideSpinner();
240
	}
241
	
242
	$scope.saveOAISet = function(setSpec, set) {
243
		$('.modal').modal('hide');
244
		showSpinner();
245
		$http.post('saveOAISet.do?setSpec='+setSpec, set)
246
        .success(
247
            function(data) {
248
            	if(data) {
249
            		show_notification('success',"OAI set configuration successfully updated");
250
            		//did we updated the setSpec?
251
            		if(setSpec != set.setSpec){
252
            			$scope.setSpecs.push(set.setSpec);
253
            			removeFromList($scope.setSpecs, setSpec);
254
            		}
255
            		else{
256
            			//add it: we created a new set!
257
            		if(!contains($scope.setSpecs, set.setSpec)) $scope.setSpecs.push(set.setSpec)
258
            		}
259
            		
260
            	}
261
            	else show_notification('error', 'Cannot update configuration for OAI set '+setSpec);
262
            	$scope.showOAISet(set.setSpec);
263
            }
264
        ).error(
265
            function() {show_notification('error', 'Cannot update OAI Set '+setSpec);}
266
        );
267
		hideSpinner();
268
	}
269
	
270
	/*---------ADD NEW MDPREFIX--------*/
271
	$scope.showMDFModal = function() {
272
		$scope.modalMdf='';
273
		$('#mdfModal').modal();
274
	}
275
	
276
	/*---------ADD NEW SET--------*/
277
	$scope.showSetModal = function() {
278
		$scope.modalMdf='';
279
		$('#setModal').modal();
280
	}
281
	
282
	/*---------ADD NEW INDEX--------*/
283
	$scope.showIndexModal = function() {
284
		$scope.modalIndex={'repeatable':false};
285
		$('#indexModal').modal();
286
	}
287
	
288
	/*---------ADD NEW INDEX PATH--------*/
289
	$scope.showNewPathModal = function(oaiIndex) {
290
		$scope.newPath='';
291
		$scope.modalIndex = oaiIndex;
292
		$('#indexPathModal').modal();
293
	}
294
}
modules/dnet-oai-modular-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/oaiCommon.js
1
function common_init($scope, $http) {
2
	initSpinner();
3
	showSpinner();
4
	$scope.show='';
5
	
6
	//load export metadata formats
7
	$http.get('getExportMDFs.do')
8
    .success(
9
        function(data) {
10
        	$scope.exportFormats = data;
11
        }
12
    )
13
    .error(
14
        function() {
15
        	show_notification('error', 'Cannot load info about export metadata formats ');
16
        }
17
    );
18
	
19
	//load source metadata formats
20
	$http.get('getSourceMDFs.do')
21
    .success(
22
        function(data) {
23
        	$scope.srcFormats = data;
24
        }
25
    )
26
    .error(
27
        function() {
28
        	show_notification('error', 'Cannot load info about source metadata formats ');
29
        }
30
    );
31
	
32
	//load OAI set names
33
	$http.get('getSetSpecs.do')
34
    .success(
35
        function(data) {
36
        	$scope.setSpecs = data;
37
        }
38
    )
39
    .error(
40
        function() {
41
        	show_notification('error', 'Cannot load info about OAI sets ');
42
        }
43
    );
44
	hideSpinner();
45
}
46

  
47
function removeFromList(list, object) {
48
	var index = list.indexOf(object);
49
	list.splice(index, 1);
50
}
51

  
52
function contains(list, object) {
53
	 return!!~list.indexOf(object);
54
}
55

  
56
function upsertExportFormat(list, format, formatPrefix){
57
	for (var i = 0; i < list.length; i++) {
58
	    if(list[i].prefix == formatPrefix) {
59
	    	list[i] = format;
60
	    	return i;
61
	    }
62
	}
63
	//if I haven't found it, then let's add it
64
	list[i] = format;
65
	return -1;
66
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff