Revision 62946
Added by Michele Artini 11 months ago
modules/dnet-modular-repositories-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoInternalController.java | ||
---|---|---|
44 | 44 |
import eu.dnetlib.enabling.datasources.common.Api; |
45 | 45 |
import eu.dnetlib.enabling.datasources.common.ApiParam; |
46 | 46 |
import eu.dnetlib.enabling.datasources.common.ApiParamImpl; |
47 |
import eu.dnetlib.enabling.datasources.common.BrowsableField; |
|
47 | 48 |
import eu.dnetlib.enabling.datasources.common.BrowseTerm; |
48 | 49 |
import eu.dnetlib.enabling.datasources.common.Datasource; |
49 | 50 |
import eu.dnetlib.enabling.datasources.common.DsmException; |
... | ... | |
317 | 318 |
listRemoteApis(api.getDatasource(), response); |
318 | 319 |
} |
319 | 320 |
|
321 |
@ResponseBody |
|
322 |
@RequestMapping(value = "/ui/updateRepoTickets.do", method = RequestMethod.POST) |
|
323 |
public List<BrowsableField> updateRepoTickets(@RequestParam(name = "id", required = true) final String repoId, @RequestBody final List<Integer> tickets) { |
|
324 |
return repoUIUtils.updateTicketsForDatasource(repoId, tickets); |
|
325 |
} |
|
326 |
|
|
320 | 327 |
@ExceptionHandler(Exception.class) |
321 | 328 |
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) |
322 | 329 |
public @ResponseBody ErrorMessage handleException(final HttpServletRequest req, final Exception e) { |
modules/dnet-modular-repositories-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/RepoUIUtils.java | ||
---|---|---|
17 | 17 |
import org.dom4j.Node; |
18 | 18 |
import org.dom4j.io.SAXReader; |
19 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
20 |
import org.springframework.beans.factory.annotation.Value; |
|
20 | 21 |
|
21 | 22 |
import com.google.common.collect.Lists; |
22 | 23 |
import com.google.common.collect.Maps; |
... | ... | |
28 | 29 |
import eu.dnetlib.enabling.datasources.DatasourceFunctions; |
29 | 30 |
import eu.dnetlib.enabling.datasources.common.Api; |
30 | 31 |
import eu.dnetlib.enabling.datasources.common.ApiParam; |
32 |
import eu.dnetlib.enabling.datasources.common.BrowsableField; |
|
31 | 33 |
import eu.dnetlib.enabling.datasources.common.Datasource; |
32 | 34 |
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager; |
33 | 35 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
... | ... | |
46 | 48 |
private UniqueServiceLocator serviceLocator; |
47 | 49 |
@Autowired |
48 | 50 |
private LocalDatasourceManager<Datasource<?, ?, ?>, Api<?>> dsManager; |
51 |
@Value("${repo.ui.tickets.baseUrl}") |
|
52 |
private String ticketBaseUrl; |
|
49 | 53 |
|
50 | 54 |
private static final Log log = LogFactory.getLog(RepoUIUtils.class); |
51 | 55 |
|
... | ... | |
123 | 127 |
ifc.setDownloadObjId(api.getLastDownloadObjid()); |
124 | 128 |
} |
125 | 129 |
|
130 |
ifc.setTickets(findTicketsForDatasource(dsId)); |
|
131 |
|
|
126 | 132 |
final StringTemplate st = new StringTemplate(IOUtils.toString(getClass() |
127 | 133 |
.getResourceAsStream("/eu/dnetlib/functionality/modular/ui/repositories/templates/getMetaWfs.xquery.st"))); |
128 | 134 |
st.setAttribute("dsId", dsId); |
... | ... | |
168 | 174 |
return ifc; |
169 | 175 |
} |
170 | 176 |
|
177 |
private List<BrowsableField> findTicketsForDatasource(final String dsId) { |
|
178 |
// TODO |
|
179 |
final List<BrowsableField> list = new ArrayList<>(); |
|
180 |
for (int i = 0; i < 10; i++) { |
|
181 |
list.add(new BrowsableField(ticketBaseUrl + i, "#" + i)); |
|
182 |
} |
|
183 |
|
|
184 |
return list; |
|
185 |
} |
|
186 |
|
|
187 |
public List<BrowsableField> updateTicketsForDatasource(final String dsId, final List<Integer> tickets) { |
|
188 |
// TODO |
|
189 |
final List<BrowsableField> list = new ArrayList<>(); |
|
190 |
for (final Integer i : tickets) { |
|
191 |
list.add(new BrowsableField(ticketBaseUrl + i, "#" + i)); |
|
192 |
} |
|
193 |
return list; |
|
194 |
} |
|
195 |
|
|
171 | 196 |
public List<VocabularyEntry> fetchVocabularyTerms(final String voc) throws ISLookUpException { |
172 | 197 |
final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '" |
173 | 198 |
+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)"; |
modules/dnet-modular-repositories-ui/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/repositories/objects/RepoInterfaceEntry.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 |
import eu.dnetlib.enabling.datasources.common.BrowsableField; |
|
6 | 7 |
import eu.dnetlib.enabling.datasources.common.SearchApisEntry; |
7 | 8 |
|
8 | 9 |
public class RepoInterfaceEntry extends SearchApisEntry { |
... | ... | |
21 | 22 |
private boolean complianceOverrided = false; |
22 | 23 |
private String consentTermsOfUseLabel; |
23 | 24 |
private String fullTextDownloadLabel; |
24 |
private List<String> tickets;
|
|
25 |
private List<BrowsableField> tickets;
|
|
25 | 26 |
|
26 | 27 |
private List<SimpleParamEntry> accessParams = new ArrayList<>(); |
27 | 28 |
|
... | ... | |
157 | 158 |
this.fullTextDownloadLabel = fullTextDownloadLabel; |
158 | 159 |
} |
159 | 160 |
|
160 |
public List<String> getTickets() {
|
|
161 |
public List<BrowsableField> getTickets() {
|
|
161 | 162 |
return tickets; |
162 | 163 |
} |
163 | 164 |
|
164 |
public void setTickets(final List<String> tickets) {
|
|
165 |
public void setTickets(final List<BrowsableField> tickets) {
|
|
165 | 166 |
this.tickets = tickets; |
166 | 167 |
} |
167 | 168 |
|
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/repositories/applicationContext-modular-ui-repositories.properties | ||
---|---|---|
13 | 13 |
repo.ui.mdstore.sync.remote.api.baseUrl = |
14 | 14 |
repo.ui.mdstore.sync.remote.is.baseUrl = |
15 | 15 |
repo.ui.mdstore.sync.local.mongodb.url = |
16 |
repo.ui.tickets.baseUrl = https://support.openaire.eu/issues/ |
|
16 | 17 |
|
17 | 18 |
#repo.ui.mdstore.sync.button = sync with DEV |
18 | 19 |
#repo.ui.mdstore.sync.remote.desc = OpenAIRE DEV Infrastructure |
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/repos/repoApi.st | ||
---|---|---|
40 | 40 |
'label-success': currentRepoApi.fullTextDownloadLabel == 'YES', |
41 | 41 |
'label-danger' : currentRepoApi.fullTextDownloadLabel == 'NO' |
42 | 42 |
}">{{currentRepoApi.fullTextDownloadLabel}}</span></div> |
43 |
<div class="input-group"> |
|
44 |
<div class="form-control"> |
|
45 |
<b>related ticket(s):</b> |
|
46 |
<span ng-repeat="t in currentRepoApi.tickets"> |
|
47 |
<span ng-show="!\$first">, </span> |
|
48 |
<a href="{{t.id}}" target="_blank">{{t.label}}</a> |
|
49 |
</span> |
|
50 |
</div> |
|
51 |
<span class="input-group-btn"> |
|
52 |
<button type="button" class="btn btn-primary" ng-click="editDatasourceTickets(currentRepoApi)">edit</button> |
|
53 |
</span> |
|
54 |
</div> |
|
43 | 55 |
</div> |
44 | 56 |
|
45 | 57 |
<div class="input-group input-group-sm col-xs-12" style="padding: 10px; float: left;" ng-show="validatorDetailsAddress || validatorBlacklistAddress"> |
modules/dnet-modular-repositories-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/reposCommon.js | ||
---|---|---|
45 | 45 |
); |
46 | 46 |
} |
47 | 47 |
|
48 |
$scope.editDatasourceTickets = function(api) { |
|
49 |
|
|
50 |
var current = ""; |
|
51 |
|
|
52 |
angular.forEach(api.tickets, function(t) { |
|
53 |
if (current) current += ', '; |
|
54 |
current += t.label.replace(/\D/g,''); |
|
55 |
}); |
|
56 |
|
|
57 |
var newValue = prompt("Edit ticket numbers (integer, comma separeted)", current); |
|
58 |
|
|
59 |
if (newValue != null) { |
|
60 |
var list = []; |
|
61 |
|
|
62 |
angular.forEach(newValue.split(','), function(t) { |
|
63 |
var n = t.replace(/\D/g,''); |
|
64 |
if (n) { |
|
65 |
list.push(parseInt(n)); |
|
66 |
} |
|
67 |
}); |
|
68 |
|
|
69 |
$scope.showSpinner(); |
|
70 |
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"; |
|
71 |
$http.post('updateRepoTickets.do?id=' + api.repoId, list).success(function(data) { |
|
72 |
api.tickets = data; |
|
73 |
$scope.hideSpinner(); |
|
74 |
}).error(function(err) { |
|
75 |
$scope.showError("Error updating tickets"); |
|
76 |
$scope.hideSpinner(); |
|
77 |
}); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
48 | 81 |
$scope.resizeMainElement = function(elem) { |
49 | 82 |
var height = 0; |
50 | 83 |
var body = window.document.body; |
Also available in: Unified diff
prepare ui to show tickets