source: main/trunk/greenstone3/web/interfaces/default/js/GSMetadata.js@ 32838

Last change on this file since 32838 was 31529, checked in by ak19, 7 years ago

Committing what I think are bugfixes. These methods could surely not have worked before, as the parameters they were called with were incorrect.

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1function GSMetadata(collection, site, documentID, name, indexPosition, archivesPosition, value)
2{
3 var _collection = collection;
4 var _site = site;
5 var _documentID = documentID;
6 var _name = name;
7 var _value = value;
8 var _indexPosition = indexPosition;
9 var _archivesPosition = archivesPosition;
10
11
12 //The setImport, setArchives and setIndex parameters are optional flags that specify the places you want the metadata to be set
13 this.setMetadata = function(newValue, setImport, setArchives, setIndex)
14 {
15 if((setImport && setArchives && setIndex) || (!setImport && !setArchives && !setIndex))
16 {
17 gs.functions.setMetadata(_collection, _site, _documentID, _name, _value);
18 }
19 else
20 {
21 if(setImport)
22 {
23 gs.functions.setImportMetadata(_collection, _site, _documentID, _name, _value);
24 }
25 else if(setArchives)
26 {
27 if(_archivesPosition != null)
28 {
29 gs.functions.setArchivesMetadata(_collection, _site, _documentID, _name, _archivesPosition, _value);
30 }
31 else
32 {
33 gs.functions.setArchivesMetadata(_collection, _site, _documentID, _name, null, _value);
34 }
35 }
36 else if(setIndex)
37 {
38 if(_indexPosition != null)
39 {
40 gs.functions.setIndexMetadata(_collection, _site, _documentID, _name, _indexPosition, _value);
41 }
42 else
43 {
44 gs.functions.setIndexMetadata(_collection, _site, _documentID, _name, null, _value);
45 }
46 }
47 }
48 }
49
50 //The removeImport, removeArchives and removeIndex parameters are optional flags that specify the places you want the metadata to be removed from
51 this.removeMetadata = function(removeImport, removeArchives, removeIndex)
52 {
53 if((removeImport && removeArchives && removeIndex) || (!removeImport && !removeArchives && !removeIndex))
54 {
55 gs.functions.removeMetadata(_collection, _site, _documentID, _name, _value);
56 }
57 else
58 {
59 if(removeImport)
60 {
61 gs.functions.removeImportMetadata(_collection, _site, _documentID, _name, _value);
62 }
63 else if(removeArchives)
64 {
65 if(_archivesPosition != null)
66 {
67 gs.functions.removeArchivesMetadata(_collection, _site, _documentID, _name, _archivesPosition);
68 }
69 else
70 {
71 gs.functions.removeArchivesMetadata(_collection, _site, _documentID, _name, null, _value);
72 }
73 }
74 else if(removeIndex)
75 {
76 if(_indexPosition != null)
77 {
78 gs.functions.removeIndexMetadata(_collection, _site, _documentID, _name, _indexPosition);
79 }
80 else
81 {
82 gs.functions.removeIndexMetadata(_collection, _site, _documentID, _name, null, _value);
83 }
84 }
85 }
86 }
87
88 this.getValue = function()
89 {
90 return _value;
91 }
92
93}
Note: See TracBrowser for help on using the repository browser.