Project

General

Profile

« Previous | Next » 

Revision 61190

Added by Alessia Bardi 11 months ago

[maven-release-plugin] copy for tag dnet-modular-vocabularies-ui-2.0.9

View differences:

modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet45-parent</artifactId>
6
		<version>1.0.0</version>
7
		<relativePath />
8
	</parent>
9
	<modelVersion>4.0.0</modelVersion>
10
	<groupId>eu.dnetlib</groupId>
11
	<artifactId>dnet-modular-vocabularies-ui</artifactId>
12
	<packaging>jar</packaging>
13
	<version>2.0.9</version>
14
	<scm>
15
	   <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9</developerConnection>
16
	</scm>
17
	<dependencies>
18
		<dependency>
19
			<groupId>eu.dnetlib</groupId>
20
			<artifactId>dnet-modular-ui</artifactId>
21
			<version>[3.0.0,4.0.0)</version>
22
		</dependency>
23
		<dependency>
24
			<groupId>javax.servlet</groupId>
25
			<artifactId>javax.servlet-api</artifactId>
26
			<version>${javax.servlet.version}</version>
27
			<scope>provided</scope>
28
		</dependency>
29
	</dependencies>
30
	<properties>
31
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32
	</properties>
33
</project>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/js/modalSynonym.js
1
var module = angular.module('modalSynonym', []);
2

  
3
module.directive('modalSynonym', function(){
4
	return {
5
		restrict: 'E',
6
		templateUrl: '../resources/html/vocabularies/modalSynonym.html',
7
		controller: function($scope){
8
			$scope.showSynonymModal = function(term, synonym) {
9
				$scope.selectedTermIndex = $scope.entries.indexOf(term);
10
				$scope.selectedSynonymIndex = $scope.entries[$scope.selectedTermIndex].synonyms.indexOf(synonym);
11
				if (synonym != null) {
12
					// edit existing synonym
13
					$scope.modalSynonym.refTerm = $scope.entries[$scope.selectedTermIndex].englishName;
14
					$scope.modalSynonym.term = $scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].term;
15
					$scope.modalSynonym.encoding = $scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].encoding;
16
				} else {
17
					// new synonym
18
					$scope.modalSynonym.refTerm = $scope.entries[$scope.selectedTermIndex].englishName;
19
					$scope.modalSynonym.term = '';
20
					$scope.modalSynonym.encoding = '';
21
				}
22
				$('#synonymModal').modal();
23
			};
24
			
25
			$scope.editSynonym = function() {
26
				if ($scope.selectedSynonymIndex == -1) {
27
					$scope.entries[$scope.selectedTermIndex].synonyms.push({
28
						"term" : $scope.modalSynonym.term,
29
						"encoding" : $scope.modalSynonym.encoding
30
					});
31
				} else {
32
					$scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].term = $scope.modalSynonym.term;
33
					$scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].encoding = $scope.modalSynonym.encoding;
34
				}
35
				// dismiss modal
36
				$('.modal').modal('hide');
37
				if ($scope.autocommit) {
38
					$scope.commit();
39
				} else {
40
					showPermanotice("Uncommitted changes!");
41
				}
42
			}
43
		},
44
		controllerAs: 'modalSynonym'
45
	}
46
});
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Term.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.model;
2

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

  
6
public class Term implements Comparable<Term> {
7

  
8
	public static String DEFAULT_ENCODING = "OPENAIRE";
9
	private String englishName;
10
	private String nativeName;
11
	private String encoding;
12
	private String code;
13
	private List<Synonym> synonyms = new ArrayList<Synonym>();
14
	private List<Relation> relations = new ArrayList<Relation>();
15
	
16
	public Term() {}
17
	
18
	public Term(String englishName, String nativeName, String encoding,
19
			String code, List<Synonym> synonyms, List<Relation> relations) {
20
		super();
21
		this.englishName = englishName;
22
		this.nativeName = nativeName;
23
		this.encoding = encoding;
24
		this.code = code;
25
		this.synonyms = synonyms;
26
		this.relations = relations;
27
	}
28

  
29
	public String getEnglishName() {
30
		return englishName;
31
	}
32

  
33
	public void setEnglishName(String englishName) {
34
		this.englishName = englishName;
35
	}
36

  
37
	public String getNativeName() {
38
		return nativeName;
39
	}
40

  
41
	public void setNativeName(String nativeName) {
42
		this.nativeName = nativeName;
43
	}
44

  
45
	public String getEncoding() {
46
		return encoding;
47
	}
48

  
49
	public void setEncoding(String encoding) {
50
		this.encoding = encoding;
51
	}
52

  
53
	public String getCode() {
54
		return code;
55
	}
56

  
57
	public void setCode(String code) {
58
		this.code = code;
59
	}
60

  
61
	public List<Synonym> getSynonyms() {
62
		return synonyms;
63
	}
64

  
65
	public void setSynonyms(List<Synonym> synonyms) {
66
		this.synonyms = synonyms;
67
	}
68

  
69
	public List<Relation> getRelations() {
70
		return relations;
71
	}
72

  
73
	public void setRelations(List<Relation> relations) {
74
		this.relations = relations;
75
	}
76

  
77
	@Override
78
	public int compareTo(Term o) {
79
		return englishName.compareTo(o.getEnglishName());
80
	}
81

  
82
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/js/modalInfo.js
1
var module = angular.module('modalInfo', []);
2

  
3
module.directive('modalInfo', function(){
4
	return {
5
		restrict: 'E',
6
		templateUrl: '../resources/html/vocabularies/modalInfo.html',
7
		controller: function($scope, $http){
8
			$scope.showInfoModal = function() {
9
				if ($scope.selectedVocabularyIndex != null) {
10
					// show modal for editing info of existing vocabulary
11
					$scope.modalInfo.id = $scope.vocabularies[$scope.selectedVocabularyIndex].id;
12
					$scope.modalInfo.name = $scope.vocabularies[$scope.selectedVocabularyIndex].name;
13
					$scope.modalInfo.code = $scope.vocabularies[$scope.selectedVocabularyIndex].code;
14
					$scope.modalInfo.description = $scope.vocabularies[$scope.selectedVocabularyIndex].description;
15
				} else {
16
					// show modal for new vocabulary
17
					$scope.modalInfo.id = '';
18
					$scope.modalInfo.name = '';
19
					$scope.modalInfo.code = '';
20
					$scope.modalInfo.description = '';
21
					hidePermanotice();
22
				}
23
				$('#infoModal').modal();
24
			}
25
			
26
			$scope.editInfo = function() {
27
				showSpinner();
28
				if ($scope.selectedVocabularyIndex == null) {
29
					// new vocabulary
30
					$http.post('createVocabulary', 
31
								{"name" : $scope.modalInfo.name, 
32
								"code" : $scope.modalInfo.code, 
33
								"description" : $scope.modalInfo.description})
34
						.success(
35
							function(data) {
36
								show_notification("success", "Vocabulary created successfully!");
37
								$scope.vocabularies.push({
38
									"id" : data,
39
									"name" : $scope.modalInfo.name,
40
									"code" : $scope.modalInfo.code,
41
									"description" : $scope.modalInfo.description
42
								});
43
								hideSpinner();
44
								$scope.loadVocabularies();
45
							})
46
						.error(
47
							function() {
48
								show_notification("error", "Cannot edit info..");
49
								hideSpinner();
50
							});
51
				} else {
52
					// edit vocabulary
53
					$http.post('commitVocabularyInfo?vocabularyId=' + $scope.vocabularies[$scope.selectedVocabularyIndex].id, 
54
								{"name" : $scope.modalInfo.name, 
55
								"code" : $scope.modalInfo.code, 
56
								"description" : $scope.modalInfo.description})
57
						.success(
58
							function() {
59
								// update model
60
								$scope.vocabularies[$scope.selectedVocabularyIndex].id = $scope.modalInfo.id;
61
								$scope.vocabularies[$scope.selectedVocabularyIndex].name = $scope.modalInfo.name;
62
								$scope.vocabularies[$scope.selectedVocabularyIndex].code = $scope.modalInfo.code;
63
								$scope.vocabularies[$scope.selectedVocabularyIndex].description = $scope.modalInfo.description;
64
								show_notification("success", "Vocabulary information saved correctly!");
65
								hideSpinner();
66
								$scope.loadVocabularies();
67
							})
68
						.error(
69
							function() {
70
								show_notification("error", "Cannot edit info..");
71
								hideSpinner();
72
							});
73
				}
74
				// dismiss modal
75
				$('.modal').modal('hide');
76
			}
77
		},
78
		controllerAs: 'modalInfo'
79
	};
80
});
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Synonym.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.model;
2

  
3
public class Synonym implements Comparable<Synonym> {
4
	public static String DEFAULT_ENCODING = "OPENAIRE";
5

  
6
	private String term;
7
	private String encoding;
8
	
9
	public Synonym() {}
10
	
11
	public Synonym(String term, String encoding) {
12
		super();
13
		this.term = term;
14
		this.encoding = encoding;
15
	}
16

  
17
	public String getTerm() {
18
		return term;
19
	}
20

  
21
	public void setTerm(String term) {
22
		this.term = term;
23
	}
24

  
25
	public String getEncoding() {
26
		return encoding;
27
	}
28

  
29
	public void setEncoding(String encoding) {
30
		this.encoding = encoding;
31
	}
32
	
33
	@Override
34
	public int compareTo(Synonym o) {
35
		return term.compareTo(o.getTerm());
36
	}
37
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Relation.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.model;
2

  
3
public class Relation implements Comparable<Relation> {
4

  
5
	private String type;
6
	private String code;
7

  
8
	public Relation() {}
9

  
10
	public Relation(final String type, final String code) {
11
		super();
12
		this.type = type;
13
		this.code = code;
14
	}
15

  
16
	public String getType() {
17
		return type;
18
	}
19

  
20
	public void setType(final String type) {
21
		this.type = type;
22
	}
23

  
24
	@Override
25
	public int compareTo(final Relation o) {
26
		return code.compareTo(o.getCode());
27
	}
28

  
29
	public String getCode() {
30
		return code;
31
	}
32

  
33
	public void setCode(final String code) {
34
		this.code = code;
35
	}
36
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-vocabularies-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-vocabularies-ui"}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/model/Vocabulary.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.model;
2

  
3
public class Vocabulary implements Comparable<Vocabulary> {
4
	private String id;
5
	private String name;
6
	private String description;
7
	private String code;
8

  
9
	public Vocabulary() {}
10
	
11
	public Vocabulary(String id, String name, String description, String code) {
12
		super();
13
		this.id = id;
14
		this.name = name;
15
		this.description = description;
16
		this.code = code;
17
	}
18

  
19
	public String getId() {
20
		return id;
21
	}
22

  
23
	public void setId(String id) {
24
		this.id = id;
25
	}
26

  
27
	public String getName() {
28
		return name;
29
	}
30

  
31
	public void setName(String name) {
32
		this.name = name;
33
	}
34

  
35
	public String getDescription() {
36
		return description;
37
	}
38

  
39
	public void setDescription(String description) {
40
		this.description = description;
41
	}
42

  
43
	public String getCode() {
44
		return code;
45
	}
46

  
47
	public void setCode(String code) {
48
		this.code = code;
49
	}
50

  
51
	@Override
52
	public int compareTo(Vocabulary o) {
53
		return name.compareTo(o.getName());
54
	}
55
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/RegistryServiceVocabularyDAO.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
7
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
8
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
9
import eu.dnetlib.enabling.is.registry.ISRegistryDocumentNotFoundException;
10
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
11
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
12
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Relation;
13
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Synonym;
14
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term;
15
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary;
16
import eu.dnetlib.miscutils.datetime.DateUtils;
17
import org.antlr.stringtemplate.StringTemplate;
18
import org.apache.commons.io.IOUtils;
19
import org.apache.commons.lang.StringEscapeUtils;
20
import org.apache.commons.lang.StringUtils;
21
import org.dom4j.Document;
22
import org.dom4j.DocumentException;
23
import org.dom4j.Element;
24
import org.dom4j.io.SAXReader;
25

  
26
import java.io.IOException;
27
import java.io.StringReader;
28
import java.util.ArrayList;
29
import java.util.Collections;
30
import java.util.List;
31
import java.util.Map;
32

  
33
public class RegistryServiceVocabularyDAO extends VocabularyDAO {
34

  
35
	@Override
36
	public List<Vocabulary> getVocabularies() throws VocabularyException {
37
		try {
38
			final String query =
39
					"for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') order by $x//VOCABULARY_NAME "
40
							+ "return concat ($x//RESOURCE_IDENTIFIER/@value,' §§§ ',$x//VOCABULARY_NAME,' §§§ ',$x//VOCABULARY_DESCRIPTION,' §§§ ',$x//VOCABULARY_NAME/@code)";
41

  
42
			List<Vocabulary> vocabularies = Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query),
43
					new Function<String, Vocabulary>() {
44

  
45
				@Override
46
				public Vocabulary apply(final String s) {
47
					String[] tokens = s.split("§§§");
48
					return new Vocabulary(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim());
49
				}
50
			});
51
			return vocabularies;
52
		} catch (ISLookUpException e) {
53
			throw new VocabularyException(e);
54
		}
55
	}
56

  
57
	@Override
58
	public List<Term> getTerms(final String vocabularyId) throws VocabularyException {
59
		try {
60
			String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(vocabularyId);
61
			final Document doc = new SAXReader().read(new StringReader(profile));
62
			final Map<String, Term> terms = Maps.newHashMap();
63

  
64
			for (Object t : doc.selectNodes("//TERM")) {
65
				final Element termNode = (Element) t;
66
				final String code = termNode.valueOf("@code");
67

  
68
				if (!terms.containsKey(code)) {
69
					final Term term = new Term();
70
					term.setEnglishName(termNode.valueOf("@english_name"));
71
					term.setNativeName(termNode.valueOf("@native_name"));
72
					term.setEncoding(termNode.valueOf("@encoding"));
73
					term.setCode(code);
74
					term.setSynonyms(new ArrayList<Synonym>());
75
					term.setRelations(new ArrayList<Relation>());
76
					terms.put(code, term);
77
				}
78
				final Term term = terms.get(code);
79

  
80
				for (Object s : termNode.selectNodes(".//SYNONYM")) {
81
					final Element synNode = (Element) s;
82
					final Synonym syn = new Synonym();
83
					syn.setTerm(synNode.valueOf("@term"));
84
					syn.setEncoding(synNode.valueOf("@encoding"));
85
					term.getSynonyms().add(syn);
86
				}
87

  
88
				for (Object r : termNode.selectNodes(".//RELATION")) {
89
					final Element relNode = (Element) r;
90
					final Relation rel = new Relation();
91
					rel.setCode(relNode.valueOf("@code"));
92
					rel.setType(relNode.valueOf("@type"));
93
					term.getRelations().add(rel);
94
				}
95

  
96
				Collections.sort(term.getSynonyms());
97
				Collections.sort(term.getRelations());
98
			}
99

  
100
			final List<Term> list = Lists.newArrayList(terms.values());
101
			Collections.sort(list);
102

  
103
			return list;
104
		} catch (ISLookUpDocumentNotFoundException e) {
105
			throw new VocabularyException(e);
106
		} catch (ISLookUpException e) {
107
			throw new VocabularyException(e);
108
		} catch (DocumentException e) {
109
			throw new VocabularyException(e);
110
		}
111
	}
112

  
113
	@Override
114
	public void commitTerms(final List<Term> terms, final String vocabularyId) throws VocabularyException {
115
		try {
116
			// prepare terms for XML
117
			for (Term t : terms) {
118
				t.setCode(StringEscapeUtils.escapeXml(t.getCode()));
119
				if(StringUtils.isBlank(t.getEncoding())) t.setEncoding(Term.DEFAULT_ENCODING);
120
				t.setEncoding(StringEscapeUtils.escapeXml(t.getEncoding()));
121
				t.setEnglishName(StringEscapeUtils.escapeXml(t.getEnglishName()));
122
				t.setNativeName(StringEscapeUtils.escapeXml(t.getNativeName()));
123
				for (Synonym s : t.getSynonyms()) {
124
					if(StringUtils.isBlank(s.getEncoding())) s.setEncoding(Synonym.DEFAULT_ENCODING);
125
					s.setEncoding(StringEscapeUtils.escapeXml(s.getEncoding()));
126
					s.setTerm(StringEscapeUtils.escapeXml(s.getTerm()));
127
				}
128
				for (Relation r : t.getRelations()) {
129
					r.setType(StringEscapeUtils.escapeXml(r.getType()));
130
					r.setCode(StringEscapeUtils.escapeXml(r.getCode()));
131
				}
132
			}
133

  
134
			StringTemplate st =
135
					new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/terms.xml.st")));
136
			st.setAttribute("terms", terms);
137
			serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//TERMS", st.toString());
138
		} catch (IOException e) {
139
			throw new VocabularyException(e);
140
		} catch (ISRegistryException e) {
141
			throw new VocabularyException(e);
142
		}
143

  
144
	}
145

  
146
	@Override
147
	public void commitVocabularyInfo(final Vocabulary voc, final String vocabularyId) throws VocabularyException {
148
		try {
149
			String xml = "<VOCABULARY_DESCRIPTION>{desc}</VOCABULARY_DESCRIPTION>";
150
			xml = xml.replace("{desc}", StringEscapeUtils.escapeXml(voc.getDescription()));
151
			serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//VOCABULARY_DESCRIPTION", xml);
152
		} catch (ISRegistryException e) {
153
			throw new VocabularyException(e);
154
		}
155
	}
156

  
157
	@Override
158
	public String createVocabulary(final Vocabulary voc) throws VocabularyException {
159
		try {
160
			StringTemplate st = new StringTemplate(
161
					IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/vocabulary.xml.st")));
162
			st.setAttribute("name", voc.getName());
163
			st.setAttribute("description", voc.getDescription());
164
			st.setAttribute("code", voc.getCode());
165
			st.setAttribute("date", DateUtils.now_ISO8601());
166
			String newVocabularyId = serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString());
167

  
168
			return newVocabularyId;
169
		} catch (IOException e) {
170
			throw new VocabularyException(e);
171
		} catch (ISRegistryException e) {
172
			throw new VocabularyException(e);
173
		}
174
	}
175

  
176
	@Override
177
	public void dropVocabulary(final String vocabularyId) throws VocabularyException {
178
		try {
179
			serviceLocator.getService(ISRegistryService.class).deleteProfile(vocabularyId);
180
		} catch (ISRegistryDocumentNotFoundException e) {
181
			throw new VocabularyException(e);
182
		} catch (ISRegistryException e) {
183
			throw new VocabularyException(e);
184
		}
185
	}
186

  
187
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/VocabularyDAO.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.Resource;
6

  
7
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
8
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term;
9
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary;
10

  
11
public abstract class VocabularyDAO {
12

  
13
	@Resource
14
	protected UniqueServiceLocator serviceLocator;
15

  
16
	public abstract List<Vocabulary> getVocabularies() throws VocabularyException;
17

  
18
	public abstract List<Term> getTerms(final String vocabularyId) throws VocabularyException;
19

  
20
	public abstract void commitTerms(final List<Term> terms, final String vocabularyId) throws VocabularyException;
21

  
22
	public abstract void commitVocabularyInfo(final Vocabulary voc, final String vocabularyId) throws VocabularyException;
23

  
24
	public abstract String createVocabulary(final Vocabulary voc) throws VocabularyException;
25

  
26
	public abstract void dropVocabulary(final String vocabularyId) throws VocabularyException;
27

  
28
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/persistence/VocabularyException.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.persistence;
2

  
3

  
4
public class VocabularyException extends Exception {
5

  
6
	/**
7
	 *
8
	 */
9
	private static final long serialVersionUID = 1L;
10

  
11
	Exception exception;
12

  
13
	public VocabularyException(final Exception e) {
14
		this.exception = e;
15
	}
16
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/controllers/VocabulariesController.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.controllers;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.Resource;
6

  
7
import org.apache.commons.logging.Log;
8
import org.apache.commons.logging.LogFactory;
9
import org.springframework.stereotype.Controller;
10
import org.springframework.web.bind.annotation.RequestBody;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestMethod;
13
import org.springframework.web.bind.annotation.RequestParam;
14
import org.springframework.web.bind.annotation.ResponseBody;
15

  
16
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Term;
17
import eu.dnetlib.functionality.modular.ui.vocabularies.model.Vocabulary;
18
import eu.dnetlib.functionality.modular.ui.vocabularies.persistence.VocabularyDAO;
19
import eu.dnetlib.functionality.modular.ui.vocabularies.persistence.VocabularyException;
20

  
21
/**
22
 * Web controller for the UI
23
 *
24
 * @author Andrea Mannocci
25
 */
26
@Controller
27
public class VocabulariesController extends VocabularyDAO {
28

  
29
	private static final Log log = LogFactory.getLog(VocabulariesController.class);
30

  
31
	@Resource(name = "vocabularyDao")
32
	private VocabularyDAO dao;
33

  
34
	/**
35
	 * Returns all vocabularies serialized in json. Invoked by angularJS
36
	 */
37
	@Override
38
	@RequestMapping("/ui/vocabularies.json")
39
	public @ResponseBody List<Vocabulary> getVocabularies() throws VocabularyException {
40
		log.info("vocabularies.json");
41
		return dao.getVocabularies();
42
	}
43

  
44
	/**
45
	 * Returns all terms and their synonyms belonging to a vocabulary. Invoked by AngularJS
46
	 */
47
	@Override
48
	@RequestMapping("/ui/terms.json")
49
	public @ResponseBody List<Term> getTerms(@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException {
50
		log.info("terms.json?vocabularyId=" + vocabularyId);
51
		return dao.getTerms(vocabularyId);
52
	}
53

  
54
	@Override
55
	@RequestMapping(value = "/ui/commitVocabulary", method = RequestMethod.POST)
56
	public @ResponseBody void commitTerms(@RequestBody(required = true) final List<Term> terms,
57
			@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException {
58
		log.info("committing vocabulary id = " + vocabularyId);
59
		dao.commitTerms(terms, vocabularyId);
60
	}
61

  
62
	@Override
63
	@RequestMapping(value = "/ui/commitVocabularyInfo", method = RequestMethod.POST)
64
	public @ResponseBody void commitVocabularyInfo(@RequestBody(required = true) final Vocabulary voc,
65
			@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException {
66
		log.info("committing vocabulary info id = " + vocabularyId);
67
		dao.commitVocabularyInfo(voc, vocabularyId);
68
	}
69

  
70
	@Override
71
	@RequestMapping(value = "/ui/createVocabulary", method = RequestMethod.POST)
72
	public @ResponseBody String createVocabulary(@RequestBody(required = true) final Vocabulary voc) throws VocabularyException {
73
		log.info("create vocabulary");
74
		String vocId = dao.createVocabulary(voc);
75
		return vocId;
76
	}
77

  
78
	@Override
79
	@RequestMapping(value = "/ui/dropVocabulary", method = RequestMethod.GET)
80
	public @ResponseBody void dropVocabulary(@RequestParam(value = "vocabularyId", required = true) final String vocabularyId) throws VocabularyException {
81
		log.info("delete vocabulary id=" + vocabularyId);
82
		dao.dropVocabulary(vocabularyId);
83
	}
84
}
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/java/eu/dnetlib/functionality/modular/ui/vocabularies/controllers/EntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.vocabularies.controllers;
2

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

  
6
import org.apache.commons.io.IOUtils;
7
import org.springframework.ui.ModelMap;
8

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

  
11
public class EntryPointController extends ModuleEntryPoint {
12
	
13
	@Override
14
	protected void initialize(ModelMap map, HttpServletRequest request,	HttpServletResponse response) throws Exception {
15
		map.addAttribute("validRelations", IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/ui/term_relations.json"))); 
16
	}
17
}	
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/vocabularies.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/vocabularies.js"></script>
4
	<script type="text/javascript" src="../resources/js/uniqueChecker.js"></script>
5
	<script type="text/javascript" src="../resources/js/modalTerm.js"></script>
6
	<script type="text/javascript" src="../resources/js/modalInfo.js"></script>
7
	<script type="text/javascript" src="../resources/js/modalSynonym.js"></script>
8
	<script type="text/javascript" src="../resources/js/modalRelation.js"></script>
9
	<script type="text/javascript">
10
		function getValidRelations() {
11
			return $if(validRelations)$$validRelations$$else$[]$endif$;
12
		}
13
	</script>
14
}, body={
15
	<div ng-app="vocabulariesUI" ng-controller="vocabulariesCtrl">
16
		<div class="row">
17
			<vocabulary-list></vocabulary-list>
18
			
19
			<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9" ng-show="entries != null && selectedVocabularyIndex != null" >
20
				<form role="form" class="form-inline">
21
                    <button type="button" class="btn btn-primary" ng-click="openCloseAllTerms()">
22
						Open/close all terms
23
					</button>
24
					<div class="btn-group">
25
						<button type="button" class="btn btn-default" ng-click="showInfoModal()">
26
							Edit info <span class="glyphicon glyphicon-book"></span>
27
						</button>
28
						<button type="button" class="btn btn-default" ng-click="showTermModal(null)">
29
							New Term <span class="glyphicon glyphicon-pencil"></span>
30
						</button>
31
						<button type="button" class="btn btn-default" ng-click="commit()" ng-show="!autocommit">
32
							Commit <span class="glyphicon glyphicon-floppy-saved"></span>
33
						</button>
34
						<button type="button" class="btn btn-default" ng-click="reloadTerms()" ng-show="!autocommit">
35
							Discard all <span class="glyphicon glyphicon-repeat"></span>
36
						</button>
37
						<button type="button" class="btn btn-default" ng-click="reloadTerms()" ng-show="autocommit">
38
                            Refresh from IS <span class="glyphicon glyphicon-refresh"></span>
39
                        </button>
40
						<button type="button" class="btn btn-default" ng-click="dropVocabulary()">
41
							Drop vocabulary <span class="glyphicon glyphicon-trash"></span>
42
						</button>
43
					</div>
44
					<div class="checkbox">
45
                        <label><input type="checkbox" ng-model="autocommit"> Auto-commit</label>
46
                    </div>
47
					<div class="form-group pull-right">
48
						<input type="text" class="form-control" ng-model="termFilter" placeholder="Filter by...">
49
					</div>
50
				</form>
51
				<br><br>
52
				
53
				<term-list></term-list>
54
			</div>
55
		</div>
56
			
57
		<!-- infoModal -->
58
		<modal-info></modal-info>
59
		
60
		<!-- term Modal -->
61
		<modal-term></modal-term>
62
		
63
		<!-- synonymModal -->
64
		<modal-synonym></modal-synonym>
65

  
66
		<!-- relModal -->
67
		<modal-relation></modal-relation>
68
		
69
	</div>
70
} )$
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/ui/term_relations.json
1
[
2
	{ "id": "owl:complementOf",         "label": "complementOf" },
3
	{ "id": "owl:differentFrom",        "label": "differentFrom" },
4
	{ "id": "owl:disjointUnionOf",      "label": "disjointUnionOf" },
5
	{ "id": "owl:disjointWith",         "label": "disjointWith" },
6
	{ "id": "owl:equivalentClass",      "label": "equivalentClass" },
7
	{ "id": "owl:incompatibleWith",     "label": "incompatibleWith" },
8
	{ "id": "owl:inverseOf",            "label": "inverseOf" },
9
	{ "id": "owl:propertyDisjointWith", "label": "propertyDisjointWith" },
10
	{ "id": "owl:sameAs",               "label": "sameAs" },
11
	{ "id": "owl:someValuesFrom",       "label": "someValuesFrom" },
12
	{ "id": "owl:unionOf",              "label": "unionOf" },
13
	{ "id": "skos:broader",       		"label": "broaderConcept" },
14
	{ "id": "skos:narrower",       		"label": "narrowerConcept" }
15
]
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-vocabularies.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

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

  
7
	<bean name="registryServiceVocabularyDAO" class="eu.dnetlib.functionality.modular.ui.vocabularies.persistence.RegistryServiceVocabularyDAO" />
8
	<alias name="${dnet.modular.ui.vocabulary.dao}" alias="vocabularyDao"/>
9
</beans>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-vocabularies.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

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

  
7
	<bean name="/ui/vocabularies.do"
8
		class="eu.dnetlib.functionality.modular.ui.vocabularies.controllers.EntryPointController"
9
		p:menu="Vocabulary editor" 
10
		p:title="D-NET vocabulary editor"
11
		p:description="D-NET vocabulary editor" 
12
		p:group="Configuration">
13
		<property name="permissionLevels">
14
			<set>
15
				<value>USER</value>
16
			</set>
17
		</property>
18
	</bean>
19
	
20
</beans>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui-vocabularies.properties
1
dnet.modular.ui.vocabulary.dao = registryServiceVocabularyDAO
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/templates/terms.xml.st
1
<TERMS>
2
	$terms:{t|
3
	<TERM native_name="$t.nativeName$" code="$t.code$" english_name="$t.englishName$" encoding="$t.encoding$">
4
        <SYNONYMS>
5
        	$t.synonyms:{s|
6
            <SYNONYM term="$s.term$" encoding="$s.encoding$"/>
7
            }$
8
        </SYNONYMS>
9
        <RELATIONS>
10
        	$t.relations:{r|
11
            <RELATION type="$r.type$" code="$r.code$"/>
12
            }$
13
        </RELATIONS>
14
    </TERM>
15
	}$
16
</TERMS>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/functionality/modular/templates/vocabulary.xml.st
1
<?xml version="1.0" encoding="UTF-8"?>
2
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
	<HEADER>
4
		<RESOURCE_IDENTIFIER value="" />
5
		<RESOURCE_TYPE value="VocabularyDSResourceType" />
6
		<RESOURCE_KIND value="VocabularyDSResources" />
7
		<RESOURCE_URI value="String" />
8
		<DATE_OF_CREATION value="$date$" />
9
	</HEADER>
10
	<BODY>
11
		<CONFIGURATION>
12
			<VOCABULARY_NAME code="$code$">$name$</VOCABULARY_NAME>
13
			<VOCABULARY_DESCRIPTION>$description$</VOCABULARY_DESCRIPTION>
14
			<TERMS>
15
				<TERM english_name="Example" encoding="en" native_name="Example" code="0000">
16
					<SYNONYMS>
17
						<SYNONYM encoding="it" term="Esempio" />
18
						<SYNONYM encoding="es" term="Ejemplo" />
19
						<SYNONYM encoding="el" term="μάθημα" />
20
						<SYNONYM encoding="zh" term="鉴戒" />
21
						<SYNONYM encoding="ja" term="事例" />
22
						<SYNONYM encoding="ru" term="пример" />
23
					</SYNONYMS>
24
					<RELATIONS />
25
				</TERM>
26
			</TERMS>
27
		</CONFIGURATION>
28
		<STATUS>
29
			<LAST_UPDATE value="$date$" />
30
		</STATUS>
31
		<SECURITY_PARAMETERS />
32
	</BODY>
33
</RESOURCE_PROFILE>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/term-list.html
1
<div class="panel-group" id="TermsAccordion">
2
	<div class="panel panel-default"
3
		ng-repeat="term in entries | filter:termFilter">
4
		<div class="panel-heading">
5
			<h4 class="panel-title">
6
				 <a data-toggle="collapse" data-parent="#accordion"
7
					href="#accordionTerm{{$index}}"><strong>{{term.code}}</strong> <br/> <span class="text-muted">{{term.englishName}}</span></a> <span
8
					class="pull-right">
9
					<button type="button" class="btn btn-xs btn-primary " ng-click="showTermModal(term)">
10
						<span class="glyphicon glyphicon-pencil"></span>
11
					</button>
12
					<button type="button" class="btn btn-xs btn-danger " ng-click="deleteTerm(term)">
13
						<span class="glyphicon glyphicon-trash"></span>
14
					</button>
15
				</span>
16
			</h4>
17
		</div>
18
		<div id="accordionTerm{{$index}}" class="panel-collapse collapse">
19
			<div class="panel-body">
20
				<ul class="nav nav-tabs">
21
					<li class="active"><a href="#accordionTerm{{$index}}_synonyms"
22
						data-toggle="tab">Synonyms</a></li>
23
					<li><a href="#accordionTerm{{$index}}_rels" data-toggle="tab">Relations</a></li>
24
				</ul>
25
				<div class="tab-content" style="margin-top: 10px;">
26
					<div class="tab-pane active" id="accordionTerm{{$index}}_synonyms">
27
						<p class="text-muted" ng-hide="term.synonyms.length > 0">No synonyms</p>
28
						<table class="table table-bordered table-striped" ng-show="term.synonyms.length > 0">
29
							<th>Synonym</th>
30
							<th>Encoding</th>
31
							<th>Operation</th>
32
							<tr ng-repeat="synonym in term.synonyms">
33
								<td class="col-md-8">{{synonym.term}}</td>
34
								<td class="col-md-4">{{synonym.encoding}}</td>
35
								<td class="col-md-1">
36
									<button type="button" class="btn btn-xs btn-primary" ng-click="showSynonymModal(term, synonym)">
37
										<span class="glyphicon glyphicon-pencil"></span>
38
									</button>
39
									<button type="button" class="btn btn-xs btn-danger" ng-click="deleteSynonym(term, synonym)">
40
										<span class="glyphicon glyphicon-trash"></span>
41
									</button>
42
								</td>
43
							</tr>
44
						</table>
45
						<button class="btn btn-xs btn-primary" type="button"
46
							ng-click="showSynonymModal(term, null)">
47
							<span class="glyphicon glyphicon-plus"></span>
48
						</button>
49
					</div>
50
					<div class="tab-pane" id="accordionTerm{{$index}}_rels">
51
						<p class="text-muted" ng-hide="term.relations.length > 0">No relations</p>
52
						<table class="table table-bordered table-striped" ng-show="term.relations.length > 0">
53
							<th>Related Term</th>
54
							<th>Relation Type</th>
55
							<th>Operation</th>
56
							<tr ng-repeat="rel in term.relations">
57
								<td class="col-md-8">{{rel.code}}</td>
58
								<td class="col-md-4">{{rel.type}}</td>
59
								<td class="col-md-1">
60
									<button type="button" class="btn btn-xs btn-primary" ng-click="showRelModal(term, rel)">
61
										<span class="glyphicon glyphicon-pencil"></span>
62
									</button>
63
									<button type="button" class="btn btn-xs btn-danger" ng-click="deleteRel(term, rel)">
64
										<span class="glyphicon glyphicon-trash"></span>
65
									</button>
66
								</td>
67
							</tr>
68
						</table>
69
						<button class="btn btn-xs btn-primary" type="button" ng-click="showRelModal(term, null)">
70
							<span class="glyphicon glyphicon-plus"></span>
71
						</button>
72
					</div>
73
				</div>
74
			</div>
75
		</div>
76
	</div>
77
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/modalTerm.html
1
<div class="modal fade" id="termModal" tabindex="-1" role="dialog" aria-labelledby="termModalLabel" aria-hidden="true">
2
	<div class="modal-dialog">
3
		<div class="modal-content">
4
			<div class="modal-header">
5
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
6
				<h4 id="termModalLabel">Term editor</h4>
7
			</div>
8
			<div class="modal-body">
9
				<form name="termForm" class="form-horizontal" role="form">
10
					<div class="form-group" ng-class="{'has-error': termForm.code.$error.unique, 'has-warning': !modalTerm.code}">
11
						<label class="col-sm-4 control-label" for="code">Code</label>
12
						<div class="col-sm-8">
13
							<input class="form-control" unique-code ng-disabled="selectedTermIndex != -1" type="text" name="code" placeholder="code" ng-model="modalTerm.code">
14
						</div>
15
					</div>
16
					<div class="form-group" ng-class="{'has-warning': !modalTerm.englishName}">
17
						<label class="col-sm-4 control-label" for="englishName">English name</label>
18
					    <div class="col-sm-8">
19
					    	<input class="form-control" unique-term type="text" name="englishName" placeholder="english name" ng-model="modalTerm.englishName">
20
					    </div>
21
					</div>
22
					<div class="form-group" ng-class="{'has-warning': !modalTerm.nativeName}">
23
						<label class="col-sm-4 control-label" for="nativeName">Native name</label>
24
						<div class="col-sm-8">
25
							<input class="form-control" type="text" name="nativeName" placeholder="native name" ng-model="modalTerm.nativeName">
26
						</div>
27
					</div>
28
					<div class="form-group" ng-class="{'has-warning': !modalTerm.encoding}">
29
						<label class="col-sm-4 control-label" for="encoding">Encoding</label>
30
						<div class="col-sm-8">
31
							<input class="form-control" type="text" name="encoding" placeholder="encoding" ng-model="modalTerm.encoding">
32
						</div>
33
					</div>
34
				</form>				
35
			</div>
36
			<div class="modal-footer">
37
				<button type="button" class="btn btn-primary" ng-disabled="(termForm.code.$error.unique)||(!modalTerm.code)||(!modalTerm.englishName)"
38
				        ng-click="editTerm()">Add to vocabulary
39
				</button>
40
			</div>
41
		</div>
42
	</div>
43
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/modalSynonym.html
1
<div class="modal fade" id="synonymModal" tabindex="-1" role="dialog" aria-labelledby="synonymModalLabel" aria-hidden="true">
2
	<div class="modal-dialog">
3
		<div class="modal-content">
4
			<div class="modal-header">
5
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
6
				<h4 id="synonymModalLabel">Synonym editor</h4>
7
			</div>
8
			<div class="modal-body">
9
				<form name="synonymForm" class="form-horizontal" role="form">
10
					<div class="form-group">
11
						<label class="col-sm-4 control-label" for="refterm">Ref. Term</label>
12
					    <div class="col-sm-8">
13
							<span id="refterm" class="form-control" type="text" disabled>{{modalSynonym.refTerm}}</span>
14
					    </div>
15
					</div>
16
					<div class="form-group" ng-class="{'has-error': synonymForm.term.$error.unique, 'has-warning': !modalSynonym.term}">
17
						<label class="col-sm-4 control-label" for="term">Term</label>
18
						<div class="col-sm-8">
19
							<input class="form-control" unique-synonym name="term" type="text" placeholder="new synonym" ng-model="modalSynonym.term">
20
						</div>
21
					</div>
22
					<div class="form-group" ng-class="{'has-warning': !modalSynonym.encoding}">
23
						<label class="col-sm-4 control-label" for="encoding">Encoding</label>
24
						<div class="col-sm-8">
25
							<input class="form-control" name="encoding" type="text" placeholder="encoding" ng-model="modalSynonym.encoding">
26
						</div>
27
					</div>
28
				</form>				
29
			</div>
30
			<div class="modal-footer">
31
				<button type="button" class="btn btn-primary" ng-disabled="(synonymForm.term.$error.unique)||(!modalSynonym.term) " ng-click="editSynonym()">Add
32
					to vocabulary
33
				</button>
34
			</div>
35
		</div>
36
	</div>
37
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/modalRelation.html
1
<div class="modal fade" id="relModal" tabindex="-1" role="dialog" aria-labelledby="relModalLabel" aria-hidden="true">
2
	<div class="modal-dialog">
3
		<div class="modal-content">
4
			<div class="modal-header">
5
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
6
				<h4 id="relModalLabel">Relation editor</h4>
7
			</div>
8
			<div class="modal-body">
9
				<form name="relForm" class="form-horizontal" role="form">
10
					<div class="form-group">
11
						<label class="col-sm-4 control-label" for="refterm">Ref. Term</label>
12
					    <div class="col-sm-8">
13
							<span id="refterm" class="form-control" type="text" disabled>{{modalRel.refTerm}}</span>
14
					    </div>
15
					</div>
16
					<div class="form-group" ng-class="{'has-warning': !modalRel.code}">
17
						<label class="col-sm-4 control-label" for="term">Related term</label>
18
						<div class="col-sm-8">
19
							<select class="form-control" ng-model="modalRel.code">
20
								<option value="">-- choose related term --</option>
21
								<option value="{{term.code}}" ng-repeat="term in entries" ng-selected="term.code == modalRel.code">{{term.code}}</option>
22
							</select>								
23
						</div>
24
					</div>
25
					<div class="form-group" ng-class="{'has-warning': !modalRel.type}">
26
						<label class="col-sm-4 control-label" for="encoding">Relation type</label>
27
						<div class="col-sm-8">
28
							<select class="form-control" ng-model="modalRel.type">
29
								<option value="">-- choose relation type --</option>
30
								<option value="{{rt.id}}" ng-repeat="rt in validRelations" ng-selected="rt.id == modalRel.type">{{rt.label}}</option>
31
							</select>
32
						</div>
33
					</div>
34
				</form>				
35
			</div>
36
			<div class="modal-footer">
37
				<button type="button" class="btn btn-primary" ng-disabled="!(modalRel.type && modalRel.code) " ng-click="editRel()">Save</button>
38
			</div>
39
		</div>
40
	</div>
41
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/modalInfo.html
1
<div class="modal fade" id="infoModal" tabindex="-1" role="dialog" aria-labelledby="infoModalLabel" aria-hidden="true">
2
	<div class="modal-dialog">
3
		<div class="modal-content">
4
			<div class="modal-header">
5
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
6
				<h4 id="infoModalLabel">Vocabulary information</h4>
7
			</div>
8
			<div class="modal-body">
9
				<form name="infoForm" class="form-horizontal" role="form">
10
					<div class="form-group">
11
						<label class="col-sm-4 control-label" for="vocabularyId">Vocabulary ID &#160;<a href="isManager.do#/profile/{{modalInfo.id}}"><span class="glyphicon glyphicon-link"></span></a></label>
12
					    <div class="col-sm-8">
13
					      	<input class="form-control" ng-disabled="true" type="text" name="vocabularyId" ng-model="modalInfo.id">
14
					    </div>
15
					</div>
16
					<div class="form-group" ng-class="{'has-warning': !modalInfo.name}">
17
						<label class="col-sm-4 control-label" for="vocabularyName">Vocabulary name</label>
18
					    <div class="col-sm-8">
19
					      	<input class="form-control" ng-disabled="selectedVocabularyIndex != null" type="text" name="vocabularyName" placeholder="vocabulary name" ng-model="modalInfo.name">
20
					    </div>
21
					</div>
22
					<div class="form-group" ng-class="{'has-warning': !modalInfo.code}">
23
						<label class="col-sm-4 control-label" for="vocabularyCode">Vocabulary code</label>
24
						<div class="col-sm-8">
25
							<input class="form-control" ng-disabled="selectedVocabularyIndex != null" type="text" name="vocabularyCode" placeholder="vocabulary code" ng-model="modalInfo.code">
26
						</div>
27
					</div>
28
					<div class="form-group">
29
						<label class="col-sm-4 control-label" for="vocabularyDescription">Vocabulary description</label>
30
						<div class="col-sm-8">
31
							<textarea class="col-sm-12" rows="3" type="text" name="vocabularyDescription" placeholder="vocabulary description" ng-model="modalInfo.description"></textarea>
32
						</div>
33
					</div>
34
				</form>				
35
			</div>
36
			<div class="modal-footer">
37
				<button type="button" class="btn btn-primary" ng-disabled="(!modalInfo.name)||(!modalInfo.code)" ng-click="editInfo()">Save</button>
38
			</div>
39
		</div>
40
	</div>
41
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/html/vocabularies/vocabulary-list.html
1
<div class="column col-xs-12 col-sm-12 col-md-3 col-lg-3">
2
	<form role="form" class="form-inline">
3
		<button type="button" class="btn btn-default" ng-click="selectedVocabularyIndex = null; showInfoModal()">
4
			New vocabulary <span class="glyphicon glyphicon-plus"></span>
5
		</button>
6
		<div class="form-group pull-right">
7
			<input type="text" class="form-control" ng-model="vocabularyFilter" placeholder="Filter by...">
8
		</div>
9
	</form>
10
	<br/><br/>
11
	<ul class="nav nav-pills nav-stacked">
12
		<li ng-repeat="voc in vocabularies | filter:vocabularyFilter"
13
			ng-class="{'active': (selectedVocabularyIndex != null) && (voc.id == vocabularies[selectedVocabularyIndex].id)}"
14
			ng-click="loadTerms(voc)">
15
				<a>{{voc.name}}<span class="glyphicon glyphicon-chevron-right pull-right"/></a>
16
		</li>
17
	</ul>
18
</div>
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/js/vocabularies.js
1
var module = angular.module('vocabulariesUI', ['uniqueChecker', 'modalTerm', 'modalInfo', 'modalSynonym', 'modalRelation']);
2

  
3
module.directive('vocabularyList', function(){
4
	return {
5
		restrict: 'E',
6
		templateUrl: '../resources/html/vocabularies/vocabulary-list.html'
7
	};
8
});
9

  
10
module.directive('termList', function(){
11
	return {
12
		restrict: 'E',
13
		templateUrl: '../resources/html/vocabularies/term-list.html'
14
	};
15
});
16

  
17
module.controller('vocabulariesCtrl', function ($scope, $http) {
18
	$scope.entries = [];
19
	$scope.modalSynonym = {};
20
	$scope.modalRel = {};
21
	$scope.modalTerm = {};
22
	$scope.modalInfo = {};
23
	
24
	$scope.validRelations = getValidRelations();
25

  
26
	$scope.autocommit = false;
27
	
28
	$scope.allTermsOpened = false;
29
	
30
	initSpinner();
31
	showSpinner();
32
	
33
	$scope.loadVocabularies = function() {
34
		$http.get('vocabularies.json')
35
		.success(
36
			function(data) {
37
				$scope.vocabularies = data;
38
				hideSpinner();
39
			})
40
		.error(
41
			function() {
42
				show_notification("error", "An error occurred while loading registered vocabulary profiles..");
43
				hideSpinner();
44
			});
45
	};
46
	
47
	$scope.loadVocabularies();
48
	
49
	
50
	$scope.openCloseAllTerms = function() {
51
	
52
		$scope.allTermsOpened = !$scope.allTermsOpened;
53

  
54
		if ($scope.allTermsOpened) {
55
			jQuery('#TermsAccordion .collapse').collapse('show');
56
		} else {
57
			jQuery('#TermsAccordion .collapse').collapse('hide');
58
		}
59
	
60
	};
61
	
62
	
63
	/*---------LOAD TERMS---------*/
64
	$scope.loadTerms = function(vocabulary) {
65
		//		// check if same vocabulary
66
		//		if ($scope.selectedVocabularyIndex != null && vocabulary.id == $scope.vocabularies[$scope.selectedVocabularyIndex].id) {
67
		//			return;
68
		//		}
69
		// prompt for uncommitted changes
70
		if (probePermanotice() == true) {
71
			var r=confirm("Switching vocabulary means losing uncommitted changes.. Are you fine with that?");
72
			if (r == false) {
73
				return;
74
			}
75
		}
76
		//actually load terms
77
		showSpinner();
78
		$http.get('terms.json?vocabularyId=' + vocabulary.id)
79
			.success(
80
				function(data) {
81
					$scope.selectedVocabularyIndex = $scope.vocabularies.indexOf(vocabulary);
82
					$scope.entries = data;
83
					$scope.termFilter = "";
84
					hidePermanotice();
85
					hideSpinner();
86
				})
87
			.error(
88
				function() {
89
					show_notification("error","An error occurred while fetching terms of vocabulary d"+vocabulary.name);
90
					hideSpinner();
91
				});
92
	};
93
	
94
	$scope.reloadTerms = function() {
95
		$scope.loadTerms($scope.vocabularies[$scope.selectedVocabularyIndex]);
96
	};
97

  
98
	/*---------DELETE---------*/
99
	$scope.deleteTerm = function(term) {
100
		if ($scope.autocommit) {
101
			var retVal = confirm("Do you want to continue ?");
102
		}
103
		if (!$scope.autocommit || retVal == true) {
104
			var index = $scope.entries.indexOf(term);
105
			$scope.entries.splice(index, 1);
106
			if ($scope.autocommit) {
107
				$scope.commit();
108
			} else {
109
				showPermanotice("Uncommitted changes!");
110
			}
111
		}
112
	};
113

  
114
	$scope.deleteSynonym = function(term, synonym) {
115
		if ($scope.autocommit) {
116
			var retVal = confirm("Do you want to continue ?");
117
		}
118
		if (!$scope.autocommit || retVal == true) {
119
			var termIndex = $scope.entries.indexOf(term);
120
			var synonymIndex = $scope.entries[termIndex].synonyms.indexOf(synonym);
121
			$scope.entries[termIndex].synonyms.splice(synonymIndex, 1);
122
			if ($scope.autocommit) {
123
				$scope.commit();
124
			} else {
125
				showPermanotice("Uncommitted changes!");
126
			}
127
		}
128
	};
129
	
130
	$scope.deleteRel = function(term, rel) {
131
		if ($scope.autocommit) {
132
			var retVal = confirm("Do you want to continue ?");
133
		}
134
		if (!$scope.autocommit || retVal == true) {
135
			var termIndex = $scope.entries.indexOf(term);
136
			var relIndex = $scope.entries[termIndex].relations.indexOf(rel);
137
			$scope.entries[termIndex].relations.splice(relIndex, 1);
138
			if ($scope.autocommit) {
139
				$scope.commit();
140
			} else {
141
				showPermanotice("Uncommitted changes!");
142
			}
143
		}
144
	};
145

  
146
	$scope.dropVocabulary = function() {
147
		var retVal = confirm("Do you want to continue ?");
148
		if (retVal == true) {
149
			showSpinner();
150
			$http.get('dropVocabulary?vocabularyId=' + $scope.vocabularies[$scope.selectedVocabularyIndex].id)
151
				.success(
152
					function () {
153
						$scope.vocabularies.splice($scope.selectedVocabularyIndex, 1);
154
						$scope.selectedVocabularyIndex = null;
155
						show_notification("success", "Vocabulary deleted successfully!");
156
						hideSpinner();
157
					})
158
				.error(
159
					function () {
160
						hideSpinner();
161
						show_notification("error", "An error occurred while dropping vocabulary " + $scope.vocabularies[$scope.selectedVocabularyIndex].name);
162
					});
163
		}
164
	};
165

  
166
	/*---------COMMIT---------*/
167
	$scope.commit = function() {
168
		showSpinner();
169
		$http.post('commitVocabulary?vocabularyId=' + $scope.vocabularies[$scope.selectedVocabularyIndex].id, $scope.entries)
170
			.success(
171
				function() {
172
					show_notification("success", "Vocabulary successfully committed!");
173
					hideSpinner();
174
					hidePermanotice();
175
					if (!$scope.autocommit) {
176
						$scope.reloadTerms();
177
					}
178
				})
179
			.error(
180
				function() {
181
					show_notification("error", "An error occurred while saving the modifications..");
182
					showPermanotice("Uncommitted changes!");
183
					hideSpinner();
184
				});
185
	}
186
});
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.9/src/main/resources/eu/dnetlib/web/resources/js/modalTerm.js
1
var module = angular.module('modalTerm', []);
2

  
3
module.directive('modalTerm', function() {
4
	return {
5
		restrict: 'E',
6
		templateUrl: '../resources/html/vocabularies/modalTerm.html',
7
		controller: function($scope){
8
			$scope.showTermModal = function(term) {
9
				$scope.selectedTermIndex = $scope.entries.indexOf(term);
10
				if (term != null) {
11
					// edit existing term
12
					$scope.modalTerm.englishName = term.englishName;
13
					$scope.modalTerm.nativeName = term.nativeName;
14
					$scope.modalTerm.encoding = term.encoding;
15
					$scope.modalTerm.code = term.code;
16
				} else {
17
					// edit new term
18
					$scope.modalTerm.englishName = '';
19
					$scope.modalTerm.nativeName = '';
20
					$scope.modalTerm.encoding = '';
21
					$scope.modalTerm.code = '';
22
				}
23
				$('#termModal').modal();
24
			};
25
			
26
			$scope.editTerm = function() {
27
				if ($scope.selectedTermIndex == -1) {
28
					// new term
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff