Revision 47904
Added by Alessia Bardi about 7 years ago
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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 |
private String englishName; |
|
8 |
private String nativeName; |
|
9 |
private String encoding; |
|
10 |
private String code; |
|
11 |
private List<Synonym> synonyms = new ArrayList<Synonym>(); |
|
12 |
private List<Relation> relations = new ArrayList<Relation>(); |
|
13 |
|
|
14 |
public Term() {} |
|
15 |
|
|
16 |
public Term(String englishName, String nativeName, String encoding, |
|
17 |
String code, List<Synonym> synonyms, List<Relation> relations) { |
|
18 |
super(); |
|
19 |
this.englishName = englishName; |
|
20 |
this.nativeName = nativeName; |
|
21 |
this.encoding = encoding; |
|
22 |
this.code = code; |
|
23 |
this.synonyms = synonyms; |
|
24 |
this.relations = relations; |
|
25 |
} |
|
26 |
|
|
27 |
public String getEnglishName() { |
|
28 |
return englishName; |
|
29 |
} |
|
30 |
|
|
31 |
public void setEnglishName(String englishName) { |
|
32 |
this.englishName = englishName; |
|
33 |
} |
|
34 |
|
|
35 |
public String getNativeName() { |
|
36 |
return nativeName; |
|
37 |
} |
|
38 |
|
|
39 |
public void setNativeName(String nativeName) { |
|
40 |
this.nativeName = nativeName; |
|
41 |
} |
|
42 |
|
|
43 |
public String getEncoding() { |
|
44 |
return encoding; |
|
45 |
} |
|
46 |
|
|
47 |
public void setEncoding(String encoding) { |
|
48 |
this.encoding = encoding; |
|
49 |
} |
|
50 |
|
|
51 |
public String getCode() { |
|
52 |
return code; |
|
53 |
} |
|
54 |
|
|
55 |
public void setCode(String code) { |
|
56 |
this.code = code; |
|
57 |
} |
|
58 |
|
|
59 |
public List<Synonym> getSynonyms() { |
|
60 |
return synonyms; |
|
61 |
} |
|
62 |
|
|
63 |
public void setSynonyms(List<Synonym> synonyms) { |
|
64 |
this.synonyms = synonyms; |
|
65 |
} |
|
66 |
|
|
67 |
public List<Relation> getRelations() { |
|
68 |
return relations; |
|
69 |
} |
|
70 |
|
|
71 |
public void setRelations(List<Relation> relations) { |
|
72 |
this.relations = relations; |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public int compareTo(Term o) { |
|
77 |
return englishName.compareTo(o.getEnglishName()); |
|
78 |
} |
|
79 |
|
|
80 |
} |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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 |
private String term; |
|
5 |
private String encoding; |
|
6 |
|
|
7 |
public Synonym() {} |
|
8 |
|
|
9 |
public Synonym(String term, String encoding) { |
|
10 |
super(); |
|
11 |
this.term = term; |
|
12 |
this.encoding = encoding; |
|
13 |
} |
|
14 |
|
|
15 |
public String getTerm() { |
|
16 |
return term; |
|
17 |
} |
|
18 |
|
|
19 |
public void setTerm(String term) { |
|
20 |
this.term = term; |
|
21 |
} |
|
22 |
|
|
23 |
public String getEncoding() { |
|
24 |
return encoding; |
|
25 |
} |
|
26 |
|
|
27 |
public void setEncoding(String encoding) { |
|
28 |
this.encoding = encoding; |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public int compareTo(Synonym o) { |
|
33 |
return term.compareTo(o.getTerm()); |
|
34 |
} |
|
35 |
} |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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.dom4j.Document; |
|
21 |
import org.dom4j.DocumentException; |
|
22 |
import org.dom4j.Element; |
|
23 |
import org.dom4j.io.SAXReader; |
|
24 |
|
|
25 |
import java.io.IOException; |
|
26 |
import java.io.StringReader; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Collections; |
|
29 |
import java.util.List; |
|
30 |
import java.util.Map; |
|
31 |
|
|
32 |
public class RegistryServiceVocabularyDAO extends VocabularyDAO { |
|
33 |
|
|
34 |
@Override |
|
35 |
public List<Vocabulary> getVocabularies() throws VocabularyException { |
|
36 |
try { |
|
37 |
final String query = |
|
38 |
"for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') order by $x//VOCABULARY_NAME " |
|
39 |
+ "return concat ($x//RESOURCE_IDENTIFIER/@value,' §§§ ',$x//VOCABULARY_NAME,' §§§ ',$x//VOCABULARY_DESCRIPTION,' §§§ ',$x//VOCABULARY_NAME/@code)"; |
|
40 |
|
|
41 |
List<Vocabulary> vocabularies = Lists.transform(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query), |
|
42 |
new Function<String, Vocabulary>() { |
|
43 |
|
|
44 |
@Override |
|
45 |
public Vocabulary apply(final String s) { |
|
46 |
String[] tokens = s.split("§§§"); |
|
47 |
return new Vocabulary(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim()); |
|
48 |
} |
|
49 |
}); |
|
50 |
return vocabularies; |
|
51 |
} catch (ISLookUpException e) { |
|
52 |
throw new VocabularyException(e); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public List<Term> getTerms(final String vocabularyId) throws VocabularyException { |
|
58 |
try { |
|
59 |
String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(vocabularyId); |
|
60 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
|
61 |
final Map<String, Term> terms = Maps.newHashMap(); |
|
62 |
|
|
63 |
for (Object t : doc.selectNodes("//TERM")) { |
|
64 |
final Element termNode = (Element) t; |
|
65 |
final String code = termNode.valueOf("@code"); |
|
66 |
|
|
67 |
if (!terms.containsKey(code)) { |
|
68 |
final Term term = new Term(); |
|
69 |
term.setEnglishName(termNode.valueOf("@english_name")); |
|
70 |
term.setNativeName(termNode.valueOf("@native_name")); |
|
71 |
term.setEncoding(termNode.valueOf("@encoding")); |
|
72 |
term.setCode(code); |
|
73 |
term.setSynonyms(new ArrayList<Synonym>()); |
|
74 |
term.setRelations(new ArrayList<Relation>()); |
|
75 |
terms.put(code, term); |
|
76 |
} |
|
77 |
final Term term = terms.get(code); |
|
78 |
|
|
79 |
for (Object s : termNode.selectNodes(".//SYNONYM")) { |
|
80 |
final Element synNode = (Element) s; |
|
81 |
final Synonym syn = new Synonym(); |
|
82 |
syn.setTerm(synNode.valueOf("@term")); |
|
83 |
syn.setEncoding(synNode.valueOf("@encoding")); |
|
84 |
term.getSynonyms().add(syn); |
|
85 |
} |
|
86 |
|
|
87 |
for (Object r : termNode.selectNodes(".//RELATION")) { |
|
88 |
final Element relNode = (Element) r; |
|
89 |
final Relation rel = new Relation(); |
|
90 |
rel.setCode(relNode.valueOf("@code")); |
|
91 |
rel.setType(relNode.valueOf("@type")); |
|
92 |
term.getRelations().add(rel); |
|
93 |
} |
|
94 |
|
|
95 |
Collections.sort(term.getSynonyms()); |
|
96 |
Collections.sort(term.getRelations()); |
|
97 |
} |
|
98 |
|
|
99 |
final List<Term> list = Lists.newArrayList(terms.values()); |
|
100 |
Collections.sort(list); |
|
101 |
|
|
102 |
return list; |
|
103 |
} catch (ISLookUpDocumentNotFoundException e) { |
|
104 |
throw new VocabularyException(e); |
|
105 |
} catch (ISLookUpException e) { |
|
106 |
throw new VocabularyException(e); |
|
107 |
} catch (DocumentException e) { |
|
108 |
throw new VocabularyException(e); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public void commitTerms(final List<Term> terms, final String vocabularyId) throws VocabularyException { |
|
114 |
try { |
|
115 |
// prepare terms for XML |
|
116 |
for (Term t : terms) { |
|
117 |
t.setCode(StringEscapeUtils.escapeXml(t.getCode())); |
|
118 |
t.setEncoding(StringEscapeUtils.escapeXml(t.getEncoding())); |
|
119 |
t.setEnglishName(StringEscapeUtils.escapeXml(t.getEnglishName())); |
|
120 |
t.setNativeName(StringEscapeUtils.escapeXml(t.getNativeName())); |
|
121 |
for (Synonym s : t.getSynonyms()) { |
|
122 |
s.setEncoding(StringEscapeUtils.escapeXml(s.getEncoding())); |
|
123 |
s.setTerm(StringEscapeUtils.escapeXml(s.getTerm())); |
|
124 |
} |
|
125 |
for (Relation r : t.getRelations()) { |
|
126 |
r.setType(StringEscapeUtils.escapeXml(r.getType())); |
|
127 |
r.setCode(StringEscapeUtils.escapeXml(r.getCode())); |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
StringTemplate st = |
|
132 |
new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/terms.xml.st"))); |
|
133 |
st.setAttribute("terms", terms); |
|
134 |
serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//TERMS", st.toString()); |
|
135 |
} catch (IOException e) { |
|
136 |
throw new VocabularyException(e); |
|
137 |
} catch (ISRegistryException e) { |
|
138 |
throw new VocabularyException(e); |
|
139 |
} |
|
140 |
|
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public void commitVocabularyInfo(final Vocabulary voc, final String vocabularyId) throws VocabularyException { |
|
145 |
try { |
|
146 |
String xml = "<VOCABULARY_DESCRIPTION>{desc}</VOCABULARY_DESCRIPTION>"; |
|
147 |
xml = xml.replace("{desc}", StringEscapeUtils.escapeXml(voc.getDescription())); |
|
148 |
serviceLocator.getService(ISRegistryService.class).updateProfileNode(vocabularyId, "//VOCABULARY_DESCRIPTION", xml); |
|
149 |
} catch (ISRegistryException e) { |
|
150 |
throw new VocabularyException(e); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public String createVocabulary(final Vocabulary voc) throws VocabularyException { |
|
156 |
try { |
|
157 |
StringTemplate st = new StringTemplate( |
|
158 |
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/functionality/modular/templates/vocabulary.xml.st"))); |
|
159 |
st.setAttribute("name", voc.getName()); |
|
160 |
st.setAttribute("description", voc.getDescription()); |
|
161 |
st.setAttribute("code", voc.getCode()); |
|
162 |
st.setAttribute("date", DateUtils.now_ISO8601()); |
|
163 |
String newVocabularyId = serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString()); |
|
164 |
|
|
165 |
return newVocabularyId; |
|
166 |
} catch (IOException e) { |
|
167 |
throw new VocabularyException(e); |
|
168 |
} catch (ISRegistryException e) { |
|
169 |
throw new VocabularyException(e); |
|
170 |
} |
|
171 |
} |
|
172 |
|
|
173 |
@Override |
|
174 |
public void dropVocabulary(final String vocabularyId) throws VocabularyException { |
|
175 |
try { |
|
176 |
serviceLocator.getService(ISRegistryService.class).deleteProfile(vocabularyId); |
|
177 |
} catch (ISRegistryDocumentNotFoundException e) { |
|
178 |
throw new VocabularyException(e); |
|
179 |
} catch (ISRegistryException e) { |
|
180 |
throw new VocabularyException(e); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
} |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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.6/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.6/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.6/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.6/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.6/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.6/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.6/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 |
<div class="btn-group"> |
|
22 |
<button type="button" class="btn btn-default" ng-click="showInfoModal()"> |
|
23 |
Edit info <span class="glyphicon glyphicon-book"></span> |
|
24 |
</button> |
|
25 |
<button type="button" class="btn btn-default" ng-click="showTermModal(null)"> |
|
26 |
New Term <span class="glyphicon glyphicon-pencil"></span> |
|
27 |
</button> |
|
28 |
<button type="button" class="btn btn-default" ng-click="commit()" ng-show="!autocommit"> |
|
29 |
Commit <span class="glyphicon glyphicon-floppy-saved"></span> |
|
30 |
</button> |
|
31 |
<button type="button" class="btn btn-default" ng-click="reloadTerms()" ng-show="!autocommit"> |
|
32 |
Discard all <span class="glyphicon glyphicon-repeat"></span> |
|
33 |
</button> |
|
34 |
<button type="button" class="btn btn-default" ng-click="reloadTerms()" ng-show="autocommit"> |
|
35 |
Refresh from IS <span class="glyphicon glyphicon-refresh"></span> |
|
36 |
</button> |
|
37 |
<button type="button" class="btn btn-default" ng-click="dropVocabulary()"> |
|
38 |
Drop vocabulary <span class="glyphicon glyphicon-trash"></span> |
|
39 |
</button> |
|
40 |
</div> |
|
41 |
<div class="checkbox"> |
|
42 |
<label><input type="checkbox" ng-model="autocommit"> Auto-commit</label> |
|
43 |
</div> |
|
44 |
<div class="form-group pull-right"> |
|
45 |
<input type="text" class="form-control" ng-model="termFilter" placeholder="Filter by..."> |
|
46 |
</div> |
|
47 |
</form> |
|
48 |
<br><br> |
|
49 |
|
|
50 |
<term-list></term-list> |
|
51 |
</div> |
|
52 |
</div> |
|
53 |
|
|
54 |
<!-- infoModal --> |
|
55 |
<modal-info></modal-info> |
|
56 |
|
|
57 |
<!-- term Modal --> |
|
58 |
<modal-term></modal-term> |
|
59 |
|
|
60 |
<!-- synonymModal --> |
|
61 |
<modal-synonym></modal-synonym> |
|
62 |
|
|
63 |
<!-- relModal --> |
|
64 |
<modal-relation></modal-relation> |
|
65 |
|
|
66 |
</div> |
|
67 |
} )$ |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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.6/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.6/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.6/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">×</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.6/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">×</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  <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.6/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">×</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.6/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">×</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.6/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 |
|
29 |
$scope.entries.push({ |
|
30 |
"englishName" : $scope.modalTerm.englishName, |
|
31 |
"nativeName" : $scope.modalTerm.nativeName, |
|
32 |
"encoding" : $scope.modalTerm.encoding, |
|
33 |
"synonyms" : [], |
|
34 |
"code" : $scope.modalTerm.code |
|
35 |
}); |
|
36 |
} else { |
|
37 |
// term update |
|
38 |
$scope.entries[$scope.selectedTermIndex].englishName = $scope.modalTerm.englishName; |
|
39 |
$scope.entries[$scope.selectedTermIndex].nativeName = $scope.modalTerm.nativeName; |
|
40 |
$scope.entries[$scope.selectedTermIndex].encoding = $scope.modalTerm.encoding; |
|
41 |
$scope.entries[$scope.selectedTermIndex].code = $scope.modalTerm.code; |
|
42 |
} |
|
43 |
// dismiss modal |
|
44 |
$('.modal').modal('hide'); |
|
45 |
if ($scope.autocommit) { |
|
46 |
$scope.commit(); |
|
47 |
} else { |
|
48 |
showPermanotice("Uncommitted changes!"); |
|
49 |
} |
|
50 |
} |
|
51 |
}, |
|
52 |
controllerAs: 'modalTerm' |
|
53 |
}; |
|
54 |
|
|
55 |
}); |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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.6/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.6/src/main/resources/eu/dnetlib/web/resources/js/modalRelation.js | ||
---|---|---|
1 |
var module = angular.module('modalRelation', []); |
|
2 |
|
|
3 |
module.directive('modalRelation', function(){ |
|
4 |
return { |
|
5 |
restrict: 'E', |
|
6 |
templateUrl: '../resources/html/vocabularies/modalRelation.html', |
|
7 |
controller: function($scope) { |
|
8 |
$scope.showRelModal = function(term, rel) { |
|
9 |
$scope.selectedTermIndex = $scope.entries.indexOf(term); |
|
10 |
$scope.selectedRelIndex = $scope.entries[$scope.selectedTermIndex].relations.indexOf(rel); |
|
11 |
if (rel != null) { |
|
12 |
// edit existing synonym |
|
13 |
$scope.modalRel.refTerm = $scope.entries[$scope.selectedTermIndex].englishName; |
|
14 |
$scope.modalRel.code = $scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].code; |
|
15 |
$scope.modalRel.type = $scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].type; |
|
16 |
} else { |
|
17 |
// new synonym |
|
18 |
$scope.modalRel.refTerm = $scope.entries[$scope.selectedTermIndex].englishName; |
|
19 |
$scope.modalRel.code = ''; |
|
20 |
$scope.modalRel.type = ''; |
|
21 |
} |
|
22 |
$('#relModal').modal(); |
|
23 |
}; |
|
24 |
|
|
25 |
$scope.editRel = function() { |
|
26 |
if ($scope.selectedRelIndex == -1) { |
|
27 |
$scope.entries[$scope.selectedTermIndex].relations.push({ |
|
28 |
"code" : $scope.modalRel.code, |
|
29 |
"type" : $scope.modalRel.type |
|
30 |
}); |
|
31 |
} else { |
|
32 |
$scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].code = $scope.modalRel.code; |
|
33 |
$scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].type = $scope.modalRel.type; |
|
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: 'modalRelation' |
|
45 |
}; |
|
46 |
}); |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/src/main/resources/eu/dnetlib/web/resources/js/uniqueChecker.js | ||
---|---|---|
1 |
var module = angular.module('uniqueChecker', []); |
|
2 |
|
|
3 |
module.directive('uniqueTerm', function() { |
|
4 |
return { |
|
5 |
restrict: 'A', |
|
6 |
require: 'ngModel', |
|
7 |
link: function (scope, element, attrs, ngModel) { |
|
8 |
function validateTerm() { |
|
9 |
ngModel.$setValidity('unique', true); |
|
10 |
if (!scope.modalTerm.englishName || (scope.selectedTermIndex != -1 && scope.modalTerm.englishName.toLowerCase() == scope.entries[scope.selectedTermIndex].englishName.toLowerCase())) { |
|
11 |
return; |
|
12 |
} |
|
13 |
for (i in scope.entries) { |
|
14 |
if (scope.entries[i].englishName.toLowerCase() == scope.modalTerm.englishName.toLowerCase()) { |
|
15 |
ngModel.$setValidity('unique', false); |
|
16 |
return; |
|
17 |
} |
|
18 |
for (j in scope.entries[i].synonyms) { |
|
19 |
if (scope.entries[i].synonyms[j].term.toLowerCase() == scope.modalTerm.englishName.toLowerCase()) { |
|
20 |
ngModel.$setValidity('unique', false); |
|
21 |
return; |
|
22 |
} |
|
23 |
} |
|
24 |
} |
|
25 |
} |
|
26 |
|
|
27 |
// register callback (validate) for $scope.modalTerm.englishName |
|
28 |
scope.$watch( |
|
29 |
function() { |
|
30 |
return scope.modalTerm.englishName; |
|
31 |
}, validateTerm); |
|
32 |
} |
|
33 |
}; |
|
34 |
}); |
|
35 |
|
|
36 |
module.directive('uniqueCode', function() { |
|
37 |
return { |
|
38 |
restrict: 'A', |
|
39 |
require: 'ngModel', |
|
40 |
link: function (scope, element, attrs, ngModel) { |
|
41 |
function validateCode() { |
|
42 |
ngModel.$setValidity('unique', true); |
|
43 |
if (!scope.modalTerm.code || (scope.selectedTermIndex != -1 && scope.modalTerm.code.toLowerCase() == scope.entries[scope.selectedTermIndex].code.toLowerCase())) { |
|
44 |
return; |
|
45 |
} |
|
46 |
for (i in scope.entries) { |
|
47 |
if (scope.modalTerm.code.toLowerCase() == scope.entries[i].code.toLowerCase()) { |
|
48 |
ngModel.$setValidity('unique', false); |
|
49 |
} |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
// register callback (validate) for $scope.modalTerm.code |
|
54 |
scope.$watch( |
|
55 |
function() { |
|
56 |
return scope.modalTerm.code; |
|
57 |
}, validateCode); |
|
58 |
} |
|
59 |
}; |
|
60 |
}); |
|
61 |
|
|
62 |
module.directive('uniqueSynonym', function() { |
|
63 |
return { |
|
64 |
restrict: 'A', |
|
65 |
require: 'ngModel', |
|
66 |
link: function (scope, element, attrs, ngModel) { |
|
67 |
function validateSynonym() { |
|
68 |
ngModel.$setValidity('unique', true); |
|
69 |
if (!scope.modalSynonym.term || (scope.selectedSynonymIndex != -1 && scope.modalSynonym.term.toLowerCase() == scope.entries[scope.selectedTermIndex].synonyms[scope.selectedSynonymIndex].term.toLowerCase())) { |
|
70 |
return; |
|
71 |
} |
|
72 |
for (i in scope.entries) { |
|
73 |
for (j in scope.entries[i].synonyms) { |
|
74 |
if (scope.entries[i].synonyms[j].term.toLowerCase() == scope.modalSynonym.term.toLowerCase()) { |
|
75 |
ngModel.$setValidity('unique', false); |
|
76 |
return; |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
// register callback (validate) for $scope.modalTerm.englishName |
|
83 |
scope.$watch( |
|
84 |
function() { |
|
85 |
return scope.modalSynonym.term; |
|
86 |
}, validateSynonym); |
|
87 |
} |
|
88 |
}; |
|
89 |
}); |
modules/dnet-modular-vocabularies-ui/tags/dnet-modular-vocabularies-ui-2.0.6/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 |
initSpinner(); |
|
29 |
showSpinner(); |
|
30 |
|
|
31 |
$scope.loadVocabularies = function() { |
|
32 |
$http.get('vocabularies.json') |
|
33 |
.success( |
|
34 |
function(data) { |
|
35 |
$scope.vocabularies = data; |
|
36 |
hideSpinner(); |
|
37 |
}) |
|
38 |
.error( |
|
39 |
function() { |
|
40 |
show_notification("error", "An error occurred while loading registered vocabulary profiles.."); |
|
41 |
hideSpinner(); |
|
42 |
}); |
|
43 |
}; |
|
44 |
|
|
45 |
$scope.loadVocabularies(); |
|
46 |
|
|
47 |
/*---------LOAD TERMS---------*/ |
|
48 |
$scope.loadTerms = function(vocabulary) { |
|
49 |
// // check if same vocabulary |
|
50 |
// if ($scope.selectedVocabularyIndex != null && vocabulary.id == $scope.vocabularies[$scope.selectedVocabularyIndex].id) { |
|
51 |
// return; |
|
52 |
// } |
|
53 |
// prompt for uncommitted changes |
|
54 |
if (probePermanotice() == true) { |
|
55 |
var r=confirm("Switching vocabulary means losing uncommitted changes.. Are you fine with that?"); |
|
56 |
if (r == false) { |
|
57 |
return; |
|
58 |
} |
|
59 |
} |
|
60 |
//actually load terms |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-modular-vocabularies-ui-2.0.6