1 |
1 |
package eu.dnetlib.msro.openaireplus.api.objects;
|
2 |
2 |
|
3 |
3 |
import java.text.SimpleDateFormat;
|
4 |
|
import java.util.*;
|
|
4 |
import java.util.ArrayList;
|
|
5 |
import java.util.Date;
|
|
6 |
import java.util.HashMap;
|
|
7 |
import java.util.List;
|
|
8 |
import java.util.Map;
|
5 |
9 |
import java.util.concurrent.TimeUnit;
|
6 |
10 |
|
7 |
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
8 |
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
9 |
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
10 |
|
import eu.dnetlib.miscutils.functional.hash.Hashing;
|
11 |
|
import eu.dnetlib.msro.openaireplus.api.SinglePublicationSubmitterUtils;
|
12 |
11 |
import org.apache.commons.lang.StringUtils;
|
13 |
12 |
import org.apache.commons.logging.Log;
|
14 |
13 |
import org.apache.commons.logging.LogFactory;
|
... | ... | |
16 |
15 |
import org.apache.velocity.tools.generic.EscapeTool;
|
17 |
16 |
import org.springframework.ui.velocity.VelocityEngineUtils;
|
18 |
17 |
|
|
18 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
|
19 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
|
20 |
import eu.dnetlib.miscutils.datetime.DateUtils;
|
|
21 |
import eu.dnetlib.miscutils.functional.hash.Hashing;
|
|
22 |
import eu.dnetlib.msro.openaireplus.api.SinglePublicationSubmitterUtils;
|
|
23 |
|
19 |
24 |
/**
|
20 |
25 |
* Created by michele on 02/12/15.
|
21 |
26 |
*/
|
... | ... | |
29 |
34 |
private String language;
|
30 |
35 |
private List<PidEntry> pids = new ArrayList<PidEntry>();
|
31 |
36 |
private String licenseCode;
|
|
37 |
private String embargoEndDate;
|
|
38 |
|
|
39 |
public String getEmbargoEndDate() {
|
|
40 |
return embargoEndDate;
|
|
41 |
}
|
|
42 |
|
|
43 |
public void setEmbargoEndDate(final String embargoEndDate) {
|
|
44 |
this.embargoEndDate = embargoEndDate;
|
|
45 |
}
|
|
46 |
|
32 |
47 |
private String resourceType;
|
33 |
48 |
private String url;
|
34 |
49 |
private String collectedFromId;
|
35 |
50 |
private String hostedById;
|
36 |
51 |
|
37 |
|
// String according to openaire guidelines: info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym]
|
|
52 |
// String according to openaire guidelines:
|
|
53 |
// info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym]
|
38 |
54 |
private List<String> contexts = new ArrayList<String>();
|
39 |
55 |
|
40 |
56 |
// String according to the EGI context profile, example: egi::classification::natsc::math
|
... | ... | |
47 |
63 |
|
48 |
64 |
private static final Log log = LogFactory.getLog(PublicationEntry.class);
|
49 |
65 |
|
50 |
|
public PublicationEntry() {
|
51 |
|
}
|
|
66 |
public PublicationEntry() {}
|
52 |
67 |
|
53 |
68 |
public String getOriginalId() {
|
54 |
69 |
return originalId;
|
... | ... | |
190 |
205 |
}
|
191 |
206 |
|
192 |
207 |
private synchronized static DatasourceEntry getDatasourceInfo(final String dsId, final ISLookUpService lookupService) throws ISLookUpException {
|
193 |
|
if (StringUtils.isBlank(dsId)) {
|
194 |
|
return new DatasourceEntry("openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18", "Unknown Repository", "unknown_____");
|
195 |
|
}
|
|
208 |
if (StringUtils
|
|
209 |
.isBlank(dsId)) { return new DatasourceEntry("openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18", "Unknown Repository", "unknown_____"); }
|
196 |
210 |
|
197 |
211 |
if (!cached_datasources.containsKey(dsId)) {
|
198 |
212 |
final String query =
|
... | ... | |
217 |
231 |
|
218 |
232 |
private synchronized static Map<String, String> getVocabulary(final String voc, final ISLookUpService lookupService) throws ISLookUpException {
|
219 |
233 |
|
220 |
|
if (DateUtils.now() - last_cache_update < TimeUnit.MINUTES.toMillis(15) && cached_vocabularies.containsKey(voc)) {
|
|
234 |
if (((DateUtils.now() - last_cache_update) < TimeUnit.MINUTES.toMillis(15)) && cached_vocabularies.containsKey(voc)) {
|
221 |
235 |
return cached_vocabularies.get(voc);
|
222 |
236 |
} else {
|
223 |
237 |
final String query = "collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code='" + voc
|
224 |
238 |
+ "']//TERM/concat(@code, ' @@@ ', @english_name)";
|
225 |
239 |
|
226 |
240 |
final Map<String, String> map = new HashMap<String, String>();
|
227 |
|
for (String s : lookupService.quickSearchProfile(query)) {
|
|
241 |
for (final String s : lookupService.quickSearchProfile(query)) {
|
228 |
242 |
final String[] arr = s.split("@@@");
|
229 |
243 |
map.put(arr[0].trim(), arr[1].trim());
|
230 |
244 |
}
|
... | ... | |
238 |
252 |
}
|
239 |
253 |
|
240 |
254 |
private synchronized static Map<String, String> getContexts(final ISLookUpService lookupService) throws ISLookUpException {
|
241 |
|
if (DateUtils.now() - last_cache_update > TimeUnit.MINUTES.toMillis(15) || cached_contexts.isEmpty()) {
|
|
255 |
if (((DateUtils.now() - last_cache_update) > TimeUnit.MINUTES.toMillis(15)) || cached_contexts.isEmpty()) {
|
242 |
256 |
final String query =
|
243 |
257 |
"collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')[.//context/@type='community']//*[name()='context' or name()='category' or name()='concept']/concat(@id, ' @@@ ', @label)";
|
244 |
258 |
|
245 |
259 |
cached_contexts.clear();
|
246 |
|
for (String s : lookupService.quickSearchProfile(query)) {
|
|
260 |
for (final String s : lookupService.quickSearchProfile(query)) {
|
247 |
261 |
final String[] arr = s.split("@@@");
|
248 |
262 |
cached_contexts.put(arr[0].trim(), arr[1].trim());
|
249 |
263 |
}
|
... | ... | |
251 |
265 |
}
|
252 |
266 |
return cached_contexts;
|
253 |
267 |
}
|
254 |
|
}
|
|
268 |
}
|
Added embargoEndDate field