Revision 47420
Added by Michele Artini almost 7 years ago
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/objects/PublicationEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api.objects; |
|
2 |
|
|
3 |
import java.text.SimpleDateFormat; |
|
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; |
|
9 |
import java.util.concurrent.TimeUnit; |
|
10 |
|
|
11 |
import org.apache.commons.lang.StringUtils; |
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.apache.velocity.app.VelocityEngine; |
|
15 |
import org.apache.velocity.tools.generic.EscapeTool; |
|
16 |
import org.springframework.ui.velocity.VelocityEngineUtils; |
|
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 |
|
|
24 |
/** |
|
25 |
* Created by michele on 02/12/15. |
|
26 |
*/ |
|
27 |
public class PublicationEntry { |
|
28 |
|
|
29 |
private String originalId; |
|
30 |
private String title; |
|
31 |
private List<String> authors = new ArrayList<String>(); |
|
32 |
private String publisher; |
|
33 |
private String description; |
|
34 |
private String language; |
|
35 |
private List<PidEntry> pids = new ArrayList<PidEntry>(); |
|
36 |
private String licenseCode; |
|
37 |
private String embargoEndDate; |
|
38 |
private String type = "publication"; |
|
39 |
private String resourceType; |
|
40 |
private String url; |
|
41 |
private String collectedFromId; |
|
42 |
private String hostedById; |
|
43 |
|
|
44 |
// String according to openaire guidelines: |
|
45 |
// info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym] |
|
46 |
private List<String> contexts = new ArrayList<String>(); |
|
47 |
|
|
48 |
// String according to the EGI context profile, example: egi::classification::natsc::math |
|
49 |
private List<String> linksToProjects = new ArrayList<String>(); |
|
50 |
|
|
51 |
private static long last_cache_update = 0; |
|
52 |
private static final Map<String, Map<String, String>> cached_vocabularies = new HashMap<String, Map<String, String>>(); |
|
53 |
private static final Map<String, DatasourceEntry> cached_datasources = new HashMap<String, DatasourceEntry>(); |
|
54 |
private static final Map<String, String> cached_contexts = new HashMap<String, String>(); |
|
55 |
|
|
56 |
private static final Log log = LogFactory.getLog(PublicationEntry.class); |
|
57 |
|
|
58 |
public PublicationEntry() {} |
|
59 |
|
|
60 |
public String getOriginalId() { |
|
61 |
return originalId; |
|
62 |
} |
|
63 |
|
|
64 |
public void setOriginalId(final String originalId) { |
|
65 |
this.originalId = originalId; |
|
66 |
} |
|
67 |
|
|
68 |
public String getTitle() { |
|
69 |
return title; |
|
70 |
} |
|
71 |
|
|
72 |
public void setTitle(final String title) { |
|
73 |
this.title = title; |
|
74 |
} |
|
75 |
|
|
76 |
public List<String> getAuthors() { |
|
77 |
return authors; |
|
78 |
} |
|
79 |
|
|
80 |
public void setAuthors(final List<String> authors) { |
|
81 |
this.authors = authors; |
|
82 |
} |
|
83 |
|
|
84 |
public String getPublisher() { |
|
85 |
return publisher; |
|
86 |
} |
|
87 |
|
|
88 |
public void setPublisher(final String publisher) { |
|
89 |
this.publisher = publisher; |
|
90 |
} |
|
91 |
|
|
92 |
public String getDescription() { |
|
93 |
return description; |
|
94 |
} |
|
95 |
|
|
96 |
public void setDescription(final String description) { |
|
97 |
this.description = description; |
|
98 |
} |
|
99 |
|
|
100 |
public String getLanguage() { |
|
101 |
return language; |
|
102 |
} |
|
103 |
|
|
104 |
public void setLanguage(final String language) { |
|
105 |
this.language = language; |
|
106 |
} |
|
107 |
|
|
108 |
public List<PidEntry> getPids() { |
|
109 |
return pids; |
|
110 |
} |
|
111 |
|
|
112 |
public void setPids(final List<PidEntry> pids) { |
|
113 |
this.pids = pids; |
|
114 |
} |
|
115 |
|
|
116 |
public String getLicenseCode() { |
|
117 |
return licenseCode; |
|
118 |
} |
|
119 |
|
|
120 |
public void setLicenseCode(final String licenseCode) { |
|
121 |
this.licenseCode = licenseCode; |
|
122 |
} |
|
123 |
|
|
124 |
public String getResourceType() { |
|
125 |
return resourceType; |
|
126 |
} |
|
127 |
|
|
128 |
public void setResourceType(final String resourceType) { |
|
129 |
this.resourceType = resourceType; |
|
130 |
} |
|
131 |
|
|
132 |
public String getUrl() { |
|
133 |
return url; |
|
134 |
} |
|
135 |
|
|
136 |
public void setUrl(final String url) { |
|
137 |
this.url = url; |
|
138 |
} |
|
139 |
|
|
140 |
public String getCollectedFromId() { |
|
141 |
return collectedFromId; |
|
142 |
} |
|
143 |
|
|
144 |
public void setCollectedFromId(final String collectedFromId) { |
|
145 |
this.collectedFromId = collectedFromId; |
|
146 |
} |
|
147 |
|
|
148 |
public String getHostedById() { |
|
149 |
return hostedById; |
|
150 |
} |
|
151 |
|
|
152 |
public void setHostedById(final String hostedById) { |
|
153 |
this.hostedById = hostedById; |
|
154 |
} |
|
155 |
|
|
156 |
public List<String> getContexts() { |
|
157 |
return contexts; |
|
158 |
} |
|
159 |
|
|
160 |
public void setContexts(final List<String> contexts) { |
|
161 |
this.contexts = contexts; |
|
162 |
} |
|
163 |
|
|
164 |
public List<String> getLinksToProjects() { |
|
165 |
return linksToProjects; |
|
166 |
} |
|
167 |
|
|
168 |
public void setLinksToProjects(final List<String> linksToProjects) { |
|
169 |
this.linksToProjects = linksToProjects; |
|
170 |
} |
|
171 |
|
|
172 |
public String getType() { |
|
173 |
return type; |
|
174 |
} |
|
175 |
|
|
176 |
public void setType(final String type) { |
|
177 |
this.type = type; |
|
178 |
} |
|
179 |
|
|
180 |
public String getEmbargoEndDate() { |
|
181 |
return embargoEndDate; |
|
182 |
} |
|
183 |
|
|
184 |
public void setEmbargoEndDate(final String embargoEndDate) { |
|
185 |
this.embargoEndDate = embargoEndDate; |
|
186 |
} |
|
187 |
|
|
188 |
public String asOafRecord(final VelocityEngine ve, |
|
189 |
final ISLookUpService lookupService, |
|
190 |
final String oafSchemaLocation) throws Exception { |
|
191 |
|
|
192 |
final DatasourceEntry collectedFromEntry = getDatasourceInfo(collectedFromId, lookupService); |
|
193 |
final DatasourceEntry hostedByEntry = getDatasourceInfo(hostedById, lookupService); |
|
194 |
|
|
195 |
final String objId = calculateObjId(originalId, collectedFromEntry); |
|
196 |
|
|
197 |
final Map<String, Object> model = new HashMap<String, Object>(); |
|
198 |
model.put("esc", new EscapeTool()); |
|
199 |
model.put("util", new SinglePublicationSubmitterUtils()); |
|
200 |
model.put("pub", this); |
|
201 |
model.put("objIdentifier", objId); |
|
202 |
model.put("oafSchemaLocation", oafSchemaLocation); |
|
203 |
model.put("resultTypes", getVocabulary("dnet:result_typologies", lookupService)); |
|
204 |
model.put("licenses", getVocabulary("dnet:access_modes", lookupService)); |
|
205 |
model.put("resourceTypes", getVocabulary("dnet:publication_resource", lookupService)); |
|
206 |
model.put("pidTypes", getVocabulary("dnet:pid_types", lookupService)); |
|
207 |
model.put("languages", getVocabulary("dnet:languages", lookupService)); |
|
208 |
model.put("contexts", getContexts(lookupService)); |
|
209 |
model.put("dateOfCollection", (new SimpleDateFormat("yyyy-MM-dd\'T\'hh:mm:ss\'Z\'")).format(new Date())); |
|
210 |
model.put("collectedFrom", collectedFromEntry); |
|
211 |
model.put("hostedBy", hostedByEntry); |
|
212 |
|
|
213 |
return VelocityEngineUtils.mergeTemplateIntoString(ve, "/eu/dnetlib/msro/openaireplus/api/indexRecord.xml.vm", "UTF-8", model); |
|
214 |
} |
|
215 |
|
|
216 |
public static String calculateObjId(final String originalId, final DatasourceEntry collectedFromEntry) { |
|
217 |
return collectedFromEntry.getPrefix() + "::" + Hashing.md5(originalId); |
|
218 |
} |
|
219 |
|
|
220 |
public static String calculateObjId(final String originalId, final String collectedFromId, final ISLookUpService lookupService) throws ISLookUpException { |
|
221 |
return calculateObjId(originalId, getDatasourceInfo(collectedFromId, lookupService)); |
|
222 |
} |
|
223 |
|
|
224 |
private synchronized static DatasourceEntry getDatasourceInfo(final String dsId, final ISLookUpService lookupService) throws ISLookUpException { |
|
225 |
if (StringUtils |
|
226 |
.isBlank(dsId)) { return new DatasourceEntry("openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18", "Unknown Repository", "unknown_____"); } |
|
227 |
|
|
228 |
if (!cached_datasources.containsKey(dsId)) { |
|
229 |
final String query = |
|
230 |
"collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//CONFIGURATION[./DATASOURCE_ORIGINAL_ID='" + dsId |
|
231 |
+ "']/concat(./OFFICIAL_NAME, ' @@@ ', .//FIELD/value[../key='NamespacePrefix'])"; |
|
232 |
final String s = lookupService.getResourceProfileByQuery(query); |
|
233 |
final String[] arr = s.split("@@@"); |
|
234 |
|
|
235 |
final DatasourceEntry ds = new DatasourceEntry(dsId, arr[0].trim(), arr[1].trim()); |
|
236 |
|
|
237 |
if (StringUtils.isBlank(ds.getName()) || StringUtils.isBlank(ds.getPrefix())) { |
|
238 |
log.error("Invalid datasource id: " + dsId); |
|
239 |
throw new ISLookUpException("Invalid datasource id: " + dsId); |
|
240 |
} else { |
|
241 |
cached_datasources.put(dsId, ds); |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
return cached_datasources.get(dsId); |
|
246 |
|
|
247 |
} |
|
248 |
|
|
249 |
private synchronized static Map<String, String> getVocabulary(final String voc, final ISLookUpService lookupService) throws ISLookUpException { |
|
250 |
|
|
251 |
if (((DateUtils.now() - last_cache_update) < TimeUnit.MINUTES.toMillis(15)) && cached_vocabularies.containsKey(voc)) { |
|
252 |
return cached_vocabularies.get(voc); |
|
253 |
} else { |
|
254 |
final String query = "collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code='" + voc |
|
255 |
+ "']//TERM/concat(@code, ' @@@ ', @english_name)"; |
|
256 |
|
|
257 |
final Map<String, String> map = new HashMap<String, String>(); |
|
258 |
for (final String s : lookupService.quickSearchProfile(query)) { |
|
259 |
final String[] arr = s.split("@@@"); |
|
260 |
map.put(arr[0].trim(), arr[1].trim()); |
|
261 |
} |
|
262 |
|
|
263 |
cached_vocabularies.put(voc, map); |
|
264 |
|
|
265 |
last_cache_update = DateUtils.now(); |
|
266 |
|
|
267 |
return map; |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
private synchronized static Map<String, String> getContexts(final ISLookUpService lookupService) throws ISLookUpException { |
|
272 |
if (((DateUtils.now() - last_cache_update) > TimeUnit.MINUTES.toMillis(15)) || cached_contexts.isEmpty()) { |
|
273 |
final String query = |
|
274 |
"collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')[.//context/@type='community']//*[name()='context' or name()='category' or name()='concept']/concat(@id, ' @@@ ', @label)"; |
|
275 |
|
|
276 |
cached_contexts.clear(); |
|
277 |
for (final String s : lookupService.quickSearchProfile(query)) { |
|
278 |
final String[] arr = s.split("@@@"); |
|
279 |
cached_contexts.put(arr[0].trim(), arr[1].trim()); |
|
280 |
} |
|
281 |
last_cache_update = DateUtils.now(); |
|
282 |
} |
|
283 |
return cached_contexts; |
|
284 |
} |
|
285 |
|
|
286 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/objects/DatasourceEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api.objects; |
|
2 |
|
|
3 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
4 |
import org.apache.commons.lang.StringUtils; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by michele on 02/12/15. |
|
8 |
*/ |
|
9 |
public class DatasourceEntry { |
|
10 |
|
|
11 |
private String id; |
|
12 |
private String name; |
|
13 |
private String prefix; |
|
14 |
|
|
15 |
public DatasourceEntry() { |
|
16 |
} |
|
17 |
|
|
18 |
public DatasourceEntry(final String id, final String name, final String prefix) { |
|
19 |
this.id = id; |
|
20 |
this.name = name; |
|
21 |
this.prefix = prefix; |
|
22 |
} |
|
23 |
|
|
24 |
public String getId() { |
|
25 |
return id; |
|
26 |
} |
|
27 |
|
|
28 |
public void setId(final String id) { |
|
29 |
this.id = id; |
|
30 |
} |
|
31 |
|
|
32 |
public String getName() { |
|
33 |
return name; |
|
34 |
} |
|
35 |
|
|
36 |
public void setName(final String name) { |
|
37 |
this.name = name; |
|
38 |
} |
|
39 |
|
|
40 |
public String getPrefix() { |
|
41 |
return prefix; |
|
42 |
} |
|
43 |
|
|
44 |
public void setPrefix(final String prefix) { |
|
45 |
this.prefix = prefix; |
|
46 |
} |
|
47 |
|
|
48 |
public String calculateOpenaireId() { |
|
49 |
if (StringUtils.isNotBlank(id)) { |
|
50 |
final String[] arr = id.split("::"); |
|
51 |
if (arr.length == 2) { |
|
52 |
return String.format("%s::%s", arr[0], Hashing.md5(arr[1])); |
|
53 |
} |
|
54 |
} |
|
55 |
return ""; |
|
56 |
} |
|
57 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/objects/PidEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api.objects; |
|
2 |
|
|
3 |
/** |
|
4 |
* Created by michele on 02/12/15. |
|
5 |
*/ |
|
6 |
public class PidEntry { |
|
7 |
|
|
8 |
private String type; |
|
9 |
private String value; |
|
10 |
|
|
11 |
public PidEntry() { |
|
12 |
} |
|
13 |
|
|
14 |
public PidEntry(final String type, final String value) { |
|
15 |
this.type = type; |
|
16 |
this.value = value; |
|
17 |
} |
|
18 |
|
|
19 |
public String getType() { |
|
20 |
return type; |
|
21 |
} |
|
22 |
|
|
23 |
public void setType(final String type) { |
|
24 |
this.type = type; |
|
25 |
} |
|
26 |
|
|
27 |
public String getValue() { |
|
28 |
return value; |
|
29 |
} |
|
30 |
|
|
31 |
public void setValue(final String value) { |
|
32 |
this.value = value; |
|
33 |
} |
|
34 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/SinglePublicationSubmitter.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api; |
|
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
|
|
5 |
import org.apache.commons.io.IOUtils; |
|
6 |
import org.apache.commons.lang.StringUtils; |
|
7 |
import org.apache.commons.lang.exception.ExceptionUtils; |
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
import org.apache.velocity.app.VelocityEngine; |
|
11 |
import org.springframework.beans.factory.annotation.Value; |
|
12 |
import org.springframework.core.io.ClassPathResource; |
|
13 |
import org.springframework.http.HttpStatus; |
|
14 |
import org.springframework.stereotype.Controller; |
|
15 |
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
16 |
import org.springframework.web.bind.annotation.RequestBody; |
|
17 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
18 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
19 |
import org.springframework.web.bind.annotation.RequestParam; |
|
20 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
21 |
import org.springframework.web.bind.annotation.ResponseStatus; |
|
22 |
|
|
23 |
import com.google.gson.Gson; |
|
24 |
|
|
25 |
import eu.dnetlib.data.index.CloudIndexClient; |
|
26 |
import eu.dnetlib.data.index.CloudIndexClientFactory; |
|
27 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
28 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
29 |
import eu.dnetlib.msro.openaireplus.api.objects.PublicationEntry; |
|
30 |
import eu.dnetlib.msro.openaireplus.utils.OafToIndexRecordFactory; |
|
31 |
import eu.dnetlib.msro.rmi.MSROException; |
|
32 |
|
|
33 |
/** |
|
34 |
* Created by michele on 11/11/15. |
|
35 |
*/ |
|
36 |
@Controller |
|
37 |
public class SinglePublicationSubmitter { |
|
38 |
|
|
39 |
private static final Log log = LogFactory.getLog(SinglePublicationSubmitter.class); |
|
40 |
|
|
41 |
public class IndexDsInfo { |
|
42 |
|
|
43 |
private final String indexBaseUrl; |
|
44 |
private final String indexDsId; |
|
45 |
private final String format; |
|
46 |
private final String coll; |
|
47 |
|
|
48 |
public IndexDsInfo(final String indexBaseUrl, final String indexDsId, final String format, final String coll) { |
|
49 |
this.indexBaseUrl = indexBaseUrl; |
|
50 |
this.indexDsId = indexDsId; |
|
51 |
this.format = format; |
|
52 |
this.coll = coll; |
|
53 |
} |
|
54 |
|
|
55 |
public String getIndexBaseUrl() { |
|
56 |
return indexBaseUrl; |
|
57 |
} |
|
58 |
|
|
59 |
public String getIndexDsId() { |
|
60 |
return indexDsId; |
|
61 |
} |
|
62 |
|
|
63 |
public String getFormat() { |
|
64 |
return format; |
|
65 |
} |
|
66 |
|
|
67 |
public String getColl() { |
|
68 |
return coll; |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
@Value(value = "oaf.schema.location") |
|
74 |
private String oafSchemaLocation; |
|
75 |
|
|
76 |
@Resource |
|
77 |
private UniqueServiceLocator serviceLocator; |
|
78 |
|
|
79 |
@Resource |
|
80 |
private OafToIndexRecordFactory oafToIndexRecordFactory; |
|
81 |
|
|
82 |
@Resource |
|
83 |
private RecentPublicationsQueue recentPublicationsQueue; |
|
84 |
|
|
85 |
@Resource(name = "openaireplusApisVelocityEngine") |
|
86 |
private VelocityEngine velocityEngine; |
|
87 |
|
|
88 |
@Value(value = "${openaireplus.msro.api.findSolrIndexUrl.xquery}") |
|
89 |
private ClassPathResource findSolrIndexUrl; |
|
90 |
|
|
91 |
@Value(value = "${openaireplus.msro.api.findIndexDsInfo.xquery}") |
|
92 |
private ClassPathResource findIndexDsInfo; |
|
93 |
|
|
94 |
@RequestMapping(value = "/api/publications/feedJson", method = RequestMethod.POST) |
|
95 |
public @ResponseBody boolean addPublication(@RequestParam(value = "json", required = true) final String json, |
|
96 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws MSROException { |
|
97 |
final PublicationEntry pub = new Gson().fromJson(json, PublicationEntry.class); |
|
98 |
return addPublication(pub, commit); |
|
99 |
} |
|
100 |
|
|
101 |
@RequestMapping(value = "/api/publications/feedObject", method = RequestMethod.POST) |
|
102 |
public @ResponseBody boolean addPublication(@RequestBody final PublicationEntry pub, |
|
103 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
104 |
throws MSROException { |
|
105 |
|
|
106 |
if (StringUtils.isBlank(pub.getOriginalId())) { throw new MSROException("A required field is missing: originalId"); } |
|
107 |
if (StringUtils.isBlank(pub.getTitle())) { throw new MSROException("A required field is missing: title"); } |
|
108 |
if (StringUtils.isBlank(pub.getUrl())) { throw new MSROException("A required field is missing: url"); } |
|
109 |
if (StringUtils.isBlank(pub.getLicenseCode())) { throw new MSROException("A required field is missing: licenseCode"); } |
|
110 |
if (StringUtils.isBlank(pub.getResourceType())) { throw new MSROException("A required field is missing: resourceType"); } |
|
111 |
if (StringUtils.isBlank(pub.getCollectedFromId())) { throw new MSROException("A required field is missing: collectedFromId"); } |
|
112 |
if (StringUtils.isBlank(pub.getType())) { throw new MSROException("A required field is missing: type"); } |
|
113 |
|
|
114 |
/* |
|
115 |
* if (StringUtils.isBlank(pub.getHostedById())) { throw new MSROException("A required field is missing: hostedById"); } |
|
116 |
*/ |
|
117 |
|
|
118 |
CloudIndexClient idxClient = null; |
|
119 |
|
|
120 |
try { |
|
121 |
final IndexDsInfo idx = calculateCurrentIndexDsInfo(); |
|
122 |
|
|
123 |
idxClient = CloudIndexClientFactory.newIndexClient(idx.getIndexBaseUrl(), idx.getColl(), false); |
|
124 |
|
|
125 |
final String oafRecord = pub.asOafRecord(velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation); |
|
126 |
|
|
127 |
recentPublicationsQueue.add(oafRecord); |
|
128 |
|
|
129 |
return (idxClient.feed(oafRecord, idx.getIndexDsId(), oafToIndexRecordFactory.newTransformer(idx.getFormat()), commit) == 0); |
|
130 |
} catch (final Throwable e) { |
|
131 |
throw new MSROException("Error adding publication: " + e.getMessage(), e); |
|
132 |
} finally { |
|
133 |
if (idxClient != null) { |
|
134 |
idxClient.close(); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
@RequestMapping(value = "/api/publications/deleteObject", method = RequestMethod.POST) |
|
140 |
public @ResponseBody boolean deletePublication( |
|
141 |
@RequestParam(value = "originalId", required = true) final String originalId, |
|
142 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
|
143 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws MSROException { |
|
144 |
|
|
145 |
CloudIndexClient idxClient = null; |
|
146 |
try { |
|
147 |
final IndexDsInfo idx = calculateCurrentIndexDsInfo(); |
|
148 |
|
|
149 |
final String objId = PublicationEntry.calculateObjId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
150 |
|
|
151 |
idxClient = CloudIndexClientFactory.newIndexClient(idx.getIndexBaseUrl(), idx.getColl(), false); |
|
152 |
|
|
153 |
idxClient.remove(objId, commit); |
|
154 |
|
|
155 |
recentPublicationsQueue.remove(objId); |
|
156 |
|
|
157 |
return true; |
|
158 |
} catch (final Throwable e) { |
|
159 |
throw new MSROException("Error adding publication: " + e.getMessage(), e); |
|
160 |
} finally { |
|
161 |
if (idxClient != null) { |
|
162 |
idxClient.close(); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
@ExceptionHandler(Exception.class) |
|
168 |
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) |
|
169 |
public @ResponseBody ErrorMessage handleException(final Exception e) { |
|
170 |
log.error("Error in direct index API", e); |
|
171 |
return new ErrorMessage(e); |
|
172 |
} |
|
173 |
|
|
174 |
private IndexDsInfo calculateCurrentIndexDsInfo() throws Exception { |
|
175 |
final String queryUrl = IOUtils.toString(findSolrIndexUrl.getInputStream()); |
|
176 |
final String queryDs = IOUtils.toString(findIndexDsInfo.getInputStream()); |
|
177 |
|
|
178 |
final ISLookUpService lu = serviceLocator.getService(ISLookUpService.class); |
|
179 |
final String indexBaseUrl = lu.getResourceProfileByQuery(queryUrl); |
|
180 |
final String[] arr = lu.getResourceProfileByQuery(queryDs).split("@@@"); |
|
181 |
|
|
182 |
return new IndexDsInfo(indexBaseUrl, arr[0].trim(), arr[1].trim(), arr[2].trim()); |
|
183 |
} |
|
184 |
|
|
185 |
public class ErrorMessage { |
|
186 |
|
|
187 |
private final String message; |
|
188 |
private final String stacktrace; |
|
189 |
|
|
190 |
public ErrorMessage(final Exception e) { |
|
191 |
this(e.getMessage(), ExceptionUtils.getStackTrace(e)); |
|
192 |
} |
|
193 |
|
|
194 |
public ErrorMessage(final String message, final String stacktrace) { |
|
195 |
this.message = message; |
|
196 |
this.stacktrace = stacktrace; |
|
197 |
} |
|
198 |
|
|
199 |
public String getMessage() { |
|
200 |
return this.message; |
|
201 |
} |
|
202 |
|
|
203 |
public String getStacktrace() { |
|
204 |
return this.stacktrace; |
|
205 |
} |
|
206 |
|
|
207 |
} |
|
208 |
|
|
209 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/SinglePublicationSubmitterUtils.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api; |
|
2 |
|
|
3 |
import java.io.StringWriter; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import org.apache.commons.lang.StringUtils; |
|
10 |
|
|
11 |
import com.google.common.base.Function; |
|
12 |
import com.google.common.collect.Lists; |
|
13 |
|
|
14 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
15 |
|
|
16 |
/** |
|
17 |
* Created by michele on 15/01/16. |
|
18 |
*/ |
|
19 |
public class SinglePublicationSubmitterUtils { |
|
20 |
|
|
21 |
public Map<String, String> calculateProjectInfo(final String link) { |
|
22 |
final Map<String, String> info = new HashMap<String, String>(); |
|
23 |
final String[] arr = link.split("/"); |
|
24 |
// info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble |
|
25 |
|
|
26 |
final String funderId = calculateFunderId(arr[2]); |
|
27 |
info.put("id", calculateProjectId(arr[2], arr[3], arr[4])); |
|
28 |
info.put("funderShortName", arr[2]); |
|
29 |
info.put("fundingName", arr[3]); |
|
30 |
info.put("code", arr[4]); |
|
31 |
info.put("jurisdiction", arr[5]); |
|
32 |
info.put("title", StringUtils.isNotBlank(arr[6]) ? arr[6] : arr[7]); |
|
33 |
info.put("acronym", arr[7]); |
|
34 |
info.put("funderId", funderId); |
|
35 |
info.put("funderName", calculateFunderName(arr[2])); |
|
36 |
info.put("fundingId", funderId + "::" + arr[3]); |
|
37 |
|
|
38 |
return info; |
|
39 |
} |
|
40 |
|
|
41 |
private String calculateProjectId(final String funderShortName, final String funding, final String code) { |
|
42 |
final String suffix = Hashing.md5(code); |
|
43 |
|
|
44 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
45 |
if (funding.equalsIgnoreCase("fp7")) { |
|
46 |
return "corda_______::" + suffix; |
|
47 |
} else { |
|
48 |
return "corda__h2020::" + suffix; |
|
49 |
} |
|
50 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
51 |
return "arc_________::" + suffix; |
|
52 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
53 |
return "fct_________::" + suffix; |
|
54 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
55 |
return "nhmrc_______::" + suffix; |
|
56 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
57 |
return "wt__________::" + suffix; |
|
58 |
} else { |
|
59 |
return ""; |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
private String calculateFunderId(final String funderShortName) { |
|
64 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
65 |
return "ec__________::EC"; |
|
66 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
67 |
return "arc_________::ARC"; |
|
68 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
69 |
return "fct_________::FCT"; |
|
70 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
71 |
return "nhmrc_______::NHMRC"; |
|
72 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
73 |
return "wt__________::WT"; |
|
74 |
} else { |
|
75 |
return ""; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
private String calculateFunderName(final String funderShortName) { |
|
80 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
81 |
return "European Commission"; |
|
82 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
83 |
return "Australian Research Council (ARC)"; |
|
84 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
85 |
return "Fundação para a Ciência e a Tecnologia"; |
|
86 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
87 |
return "National Health and Medical Research Council (NHMRC)"; |
|
88 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
89 |
return "Wellcome Trust"; |
|
90 |
} else { |
|
91 |
return ""; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
public List<ContextInfo> processContexts(final List<String> list) { |
|
96 |
return Lists.newArrayList(Lists.transform(list, new Function<String, ContextInfo>() { |
|
97 |
|
|
98 |
@Override |
|
99 |
public ContextInfo apply(final String s) { |
|
100 |
return createContextInfo(s.split("::"), 0); |
|
101 |
} |
|
102 |
|
|
103 |
private ContextInfo createContextInfo(final String[] arr, final int pos) { |
|
104 |
final StringWriter id = new StringWriter(); |
|
105 |
id.write(arr[0]); |
|
106 |
for (int i = 0; i < pos; i++) { |
|
107 |
id.write("::"); |
|
108 |
id.write(arr[i + 1]); |
|
109 |
} |
|
110 |
final String elem = (pos == 0) ? "context" : (pos == 1) ? "category" : "concept"; |
|
111 |
final ContextInfo info = new ContextInfo(elem, id.toString()); |
|
112 |
if ((pos + 1) < arr.length) { |
|
113 |
info.getChildren().add(createContextInfo(arr, pos + 1)); |
|
114 |
} |
|
115 |
return info; |
|
116 |
} |
|
117 |
})); |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
public class ContextInfo { |
|
122 |
|
|
123 |
private String elem; |
|
124 |
private String id; |
|
125 |
private List<ContextInfo> children = new ArrayList<ContextInfo>(); |
|
126 |
|
|
127 |
public ContextInfo(final String elem, |
|
128 |
final String id) { |
|
129 |
this.elem = elem; |
|
130 |
this.id = id; |
|
131 |
} |
|
132 |
|
|
133 |
public String getElem() { |
|
134 |
return elem; |
|
135 |
} |
|
136 |
|
|
137 |
public void setElem(final String elem) { |
|
138 |
this.elem = elem; |
|
139 |
} |
|
140 |
|
|
141 |
public String getId() { |
|
142 |
return id; |
|
143 |
} |
|
144 |
|
|
145 |
public void setId(final String id) { |
|
146 |
this.id = id; |
|
147 |
} |
|
148 |
|
|
149 |
public List<ContextInfo> getChildren() { |
|
150 |
return children; |
|
151 |
} |
|
152 |
|
|
153 |
public void setChildren(final List<ContextInfo> children) { |
|
154 |
this.children = children; |
|
155 |
} |
|
156 |
|
|
157 |
public boolean isRoot() { |
|
158 |
return elem.equals("context"); |
|
159 |
} |
|
160 |
} |
|
161 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/RecentPublicationsQueue.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.api; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.dom4j.io.SAXReader; |
|
10 |
import org.springframework.beans.factory.annotation.Required; |
|
11 |
|
|
12 |
import com.mongodb.BasicDBObject; |
|
13 |
import com.mongodb.BasicDBObjectBuilder; |
|
14 |
import com.mongodb.DB; |
|
15 |
import com.mongodb.DBCollection; |
|
16 |
import com.mongodb.DBCursor; |
|
17 |
import com.mongodb.DBObject; |
|
18 |
|
|
19 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
20 |
|
|
21 |
/** |
|
22 |
* Created by michele on 11/11/15. |
|
23 |
*/ |
|
24 |
public class RecentPublicationsQueue implements Iterable<String> { |
|
25 |
|
|
26 |
private static final Log log = LogFactory.getLog(RecentPublicationsQueue.class); |
|
27 |
|
|
28 |
private DB db; |
|
29 |
private String collection; |
|
30 |
|
|
31 |
public void init() { |
|
32 |
if (!db.collectionExists(collection)) { |
|
33 |
log.info(String.format("creating collection %s", collection)); |
|
34 |
db.createCollection(collection, new BasicDBObject()); |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Iterator<String> iterator() { |
|
40 |
|
|
41 |
final DBCursor cursor = db.getCollection(collection).find(); |
|
42 |
|
|
43 |
return new Iterator<String>() { |
|
44 |
|
|
45 |
@Override |
|
46 |
public boolean hasNext() { |
|
47 |
return cursor.hasNext(); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public String next() { |
|
52 |
final DBObject obj = cursor.next(); |
|
53 |
return ((obj != null) && obj.containsField("record")) ? obj.get("record").toString() : ""; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public void remove() { |
|
58 |
throw new RuntimeException("NOT IMPLEMENTED"); |
|
59 |
} |
|
60 |
}; |
|
61 |
} |
|
62 |
|
|
63 |
synchronized public void add(final String oaf) throws Exception { |
|
64 |
final String id = (new SAXReader()).read(new StringReader(oaf)).valueOf("//*[local-name() = 'objIdentifier']"); |
|
65 |
|
|
66 |
log.info("Saving record " + id + " in db: " + db.getName() + ", coll: " + collection); |
|
67 |
|
|
68 |
final DBCollection coll = db.getCollection(collection); |
|
69 |
final DBObject obj = BasicDBObjectBuilder.start() |
|
70 |
.append("id", id) |
|
71 |
.append("record", oaf) |
|
72 |
.append("date", DateUtils.now()) |
|
73 |
.get(); |
|
74 |
coll.update(new BasicDBObject("id", id), obj, true, false); |
|
75 |
} |
|
76 |
|
|
77 |
public void remove(final List<String> list) { |
|
78 |
final DBCollection coll = db.getCollection(collection); |
|
79 |
for (final String id : list) { |
|
80 |
coll.remove(new BasicDBObject("id", id)); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
public void remove(final String... ids) { |
|
85 |
final DBCollection coll = db.getCollection(collection); |
|
86 |
for (final String id : ids) { |
|
87 |
coll.remove(new BasicDBObject("id", id)); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
public DB getDb() { |
|
92 |
return db; |
|
93 |
} |
|
94 |
|
|
95 |
@Required |
|
96 |
public void setDb(final DB db) { |
|
97 |
this.db = db; |
|
98 |
} |
|
99 |
|
|
100 |
public String getCollection() { |
|
101 |
return collection; |
|
102 |
} |
|
103 |
|
|
104 |
@Required |
|
105 |
public void setCollection(final String collection) { |
|
106 |
this.collection = collection; |
|
107 |
} |
|
108 |
} |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/api/applicationContext-api.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xmlns:p="http://www.springframework.org/schema/p" |
|
4 |
xmlns="http://www.springframework.org/schema/beans" |
|
5 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |
|
6 |
|
|
7 |
<bean id="recentPublicationsQueue" class="eu.dnetlib.msro.openaireplus.api.RecentPublicationsQueue" |
|
8 |
p:db-ref="msroApiMongoDB" p:collection="${openaireplus.msro.api.mongo.collection}" |
|
9 |
init-method="init"/> |
|
10 |
|
|
11 |
|
|
12 |
<bean id="apiMongoServer" class="com.mongodb.Mongo"> |
|
13 |
<constructor-arg index="0" type="com.mongodb.ServerAddress"> |
|
14 |
<bean class="com.mongodb.ServerAddress"> |
|
15 |
<constructor-arg index="0" |
|
16 |
value="${openaireplus.msro.api.mongo.host}"/> |
|
17 |
<constructor-arg index="1" |
|
18 |
value="${openaireplus.msro.api.mongo.port}"/> |
|
19 |
</bean> |
|
20 |
</constructor-arg> |
|
21 |
</bean> |
|
22 |
|
|
23 |
<bean id="apiOafToIndexRecordFactory" class="eu.dnetlib.msro.openaireplus.utils.OafToIndexRecordFactory" |
|
24 |
p:layoutToRecord="${openaireplus.msro.api.layoutToRecord.xslt}"/> |
|
25 |
|
|
26 |
|
|
27 |
<bean id="msroApiMongoDB" factory-bean="apiMongoServer" |
|
28 |
factory-method="getDB"> |
|
29 |
<constructor-arg index="0" value="${openaireplus.msro.api.mongo.db}"/> |
|
30 |
</bean> |
|
31 |
|
|
32 |
<bean id="openaireplusApisVelocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> |
|
33 |
<property name="velocityProperties"> |
|
34 |
<value> |
|
35 |
resource.loader=class |
|
36 |
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader |
|
37 |
runtime.log.logsystem.class=org.apache.velocity.runtime.log.Log4JLogChute |
|
38 |
</value> |
|
39 |
</property> |
|
40 |
</bean> |
|
41 |
|
|
42 |
</beans> |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/api/indexRecord.xml.vm | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<!-- |
|
4 |
#macro(context $ctx) |
|
5 |
<$!ctx.elem id="$!esc.xml($!ctx.id)" label="$!esc.xml($contexts.get($!ctx.id))" #if($!ctx.isRoot()) type="community"#end> |
|
6 |
#foreach($child in $!ctx.children)#context($child)#end |
|
7 |
</$!ctx.elem> |
|
8 |
#end |
|
9 |
--> |
|
10 |
|
|
11 |
<record xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaf="http://namespace.openaire.eu/oaf"> |
|
12 |
<result> |
|
13 |
<header> |
|
14 |
<dri:objIdentifier>$!esc.xml($!objIdentifier)</dri:objIdentifier> |
|
15 |
<dri:dateOfCollection>$!esc.xml($!dateOfCollection)</dri:dateOfCollection> |
|
16 |
<dri:status>under curation</dri:status> |
|
17 |
<counters/> |
|
18 |
</header> |
|
19 |
<metadata> |
|
20 |
<oaf:entity schemaLocation="http://namespace.openaire.eu/oaf $!oafSchemaLocation"> |
|
21 |
<oaf:result> |
|
22 |
<title classid="main title" classname="main title" schemeid="dnet:dataCite_title" schemename="dnet:dataCite_title"> |
|
23 |
$!esc.xml($!pub.title) |
|
24 |
</title> |
|
25 |
<dateofacceptance/> |
|
26 |
<resulttype classid="$!esc.xml($!pub.type)" classname="$!esc.xml($!resultTypes.get($!pub.type))" schemeid="dnet:result_typologies" schemename="dnet:result_typologies"/> |
|
27 |
<language classid="$!esc.xml($!pub.language)" classname="$!esc.xml($!languages.get($!pub.language))" schemeid="dnet:languages" |
|
28 |
schemename="dnet:languages"/> |
|
29 |
<description> |
|
30 |
$!esc.xml($!pub.description) |
|
31 |
</description> |
|
32 |
<country classid="" classname="" schemeid="" schemename=""/> |
|
33 |
<subject classid="" classname="" schemeid="" schemename=""/> |
|
34 |
<relevantdate classid="" classname="" schemeid="" schemename=""/> |
|
35 |
<publisher>$!esc.xml($!pub.publisher)</publisher> |
|
36 |
<embargoenddate>$!esc.xml($!pub.embargoEndDate)</embargoenddate> |
|
37 |
<source/> |
|
38 |
<fulltext/> |
|
39 |
<format/> |
|
40 |
<storagedate/> |
|
41 |
<resourcetype classid="" classname="" schemeid="" schemename=""/> |
|
42 |
<device/> |
|
43 |
<size/> |
|
44 |
<version/> |
|
45 |
<lastmetadataupdate/> |
|
46 |
<metadataversionnumber/> |
|
47 |
<originalId>$!esc.xml($!pub.originalId)</originalId> |
|
48 |
<collectedfrom name="$!esc.xml($!collectedFrom.name)" id="$!esc.xml($!collectedFrom.calculateOpenaireId())"/> |
|
49 |
|
|
50 |
#foreach($pid in $!pub.pids) |
|
51 |
<pid classid="$!esc.xml($!pid.type)" classname="$!esc.xml($!pidTypes.get($!pid.type))" schemeid="dnet:pid_types" |
|
52 |
schemename="dnet:pid_types">$!esc.xml($pid.value)</pid> |
|
53 |
#end |
|
54 |
|
|
55 |
<bestlicense classid="$!esc.xml($!pub.licenseCode)" classname="$!esc.xml($!licenses.get($!pub.licenseCode))" |
|
56 |
schemeid="dnet:access_modes" schemename="dnet:access_modes"/> |
|
57 |
|
|
58 |
#foreach($ctx in $util.processContexts($!pub.contexts)) |
|
59 |
#context($ctx) |
|
60 |
#end |
|
61 |
|
|
62 |
<datainfo> |
|
63 |
<inferred>false</inferred> |
|
64 |
<deletedbyinference>false</deletedbyinference> |
|
65 |
<trust>0.9</trust> |
|
66 |
<inferenceprovenance/> |
|
67 |
<provenanceaction classid="user:insert" classname="user:insert" schemeid="dnet:provenanceActions" schemename="dnet:provenanceActions"/> |
|
68 |
</datainfo> |
|
69 |
|
|
70 |
<rels> |
|
71 |
#foreach($author in $!pub.authors) |
|
72 |
<rel inferred="false" trust="0.9" inferenceprovenance="" provenanceaction="sysimport:crosswalk:repository"> |
|
73 |
<to class="hasAuthor" scheme="dnet:personroles" type="person"/> |
|
74 |
<ranking>$velocityCount</ranking> |
|
75 |
<fullname>$!author</fullname> |
|
76 |
</rel> |
|
77 |
#end |
|
78 |
#foreach($link in $!pub.linksToProjects) |
|
79 |
|
|
80 |
#set( $info = $!util.calculateProjectInfo($!link) ) |
|
81 |
<rel inferred="false" trust="0.9" inferenceprovenance="" provenanceaction="user:claim:search"> |
|
82 |
<to class="isProducedBy" scheme="dnet:result_project_relations" type="project">$!esc.xml($!info.id)</to> |
|
83 |
<code>$!esc.xml($!info.code)</code> |
|
84 |
<acronym>$!esc.xml($!info.acronym)</acronym> |
|
85 |
<title>$!esc.xml($!info.title)</title> |
|
86 |
<contracttype classid="" classname="" schemeid="" schemename=""/> |
|
87 |
|
|
88 |
<funding> |
|
89 |
<funder id="$!esc.xml($!info.funderId)" |
|
90 |
shortname="$!esc.xml($!info.funderShortName)" |
|
91 |
name="$!esc.xml($!info.funderName)" |
|
92 |
jurisdiction="$!esc.xml($!info.jurisdiction)"/> |
|
93 |
<funding_level_0 name="$!esc.xml($!info.fundingName)">$!esc.xml($!info.fundingId)</funding_level_0> |
|
94 |
</funding> |
|
95 |
</rel> |
|
96 |
#end |
|
97 |
|
|
98 |
</rels> |
|
99 |
<children> |
|
100 |
<instance id="$!esc.xml($!objIdentifier)"> |
|
101 |
|
|
102 |
<licence classid="$!esc.xml($!pub.licenseCode)" classname="$!esc.xml($licenses.get($!pub.licenseCode))" |
|
103 |
schemeid="dnet:access_modes" schemename="dnet:access_modes"/> |
|
104 |
|
|
105 |
<instancetype classid="$!esc.xml($!pub.resourceType)" classname="$!esc.xml($resourceTypes.get($!pub.resourceType))" |
|
106 |
schemeid="dnet:publication_resource" schemename="dnet:publication_resource"/> |
|
107 |
<hostedby name="$!esc.xml($!hostedBy.name)" id="$!esc.xml($!hostedBy.calculateOpenaireId())"/> |
|
108 |
<webresource> |
|
109 |
<url>$!esc.xml($!pub.url)</url> |
|
110 |
</webresource> |
|
111 |
</instance> |
|
112 |
</children> |
|
113 |
</oaf:result> |
|
114 |
</oaf:entity> |
|
115 |
</metadata> |
|
116 |
</result> |
|
117 |
</record> |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/api/findIndexDsInfo.xquery | ||
---|---|---|
1 |
let $format := collection('/db/DRIVER/ServiceResources/SearchServiceResourceType')//SERVICE_PROPERTIES[./PROPERTY[@key = 'infrastructure' and @value = 'public']]/PROPERTY[@key = "mdformat"]/@value/string() |
|
2 |
|
|
3 |
for $x in collection('/db/DRIVER/IndexDSResources/IndexDSResourceType') |
|
4 |
where |
|
5 |
$x//METADATA_FORMAT = $format and |
|
6 |
$x//METADATA_FORMAT_INTERPRETATION = 'openaire' and |
|
7 |
$x//METADATA_FORMAT_LAYOUT = 'index' |
|
8 |
return |
|
9 |
concat($x//RESOURCE_IDENTIFIER/@value/string(), ' @@@ ', $format, ' @@@ ', $format, '-index-openaire') |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/api/findSolrIndexUrl.xquery | ||
---|---|---|
1 |
collection("/db/DRIVER/ServiceResources/IndexServiceResourceType")//PROTOCOL[@name = "solr" or @name = "SOLR"]/@address/string() |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/api/applicationContext-api.properties | ||
---|---|---|
1 |
openaireplus.msro.api.mongo.host = localhost |
|
2 |
openaireplus.msro.api.mongo.port = 27017 |
|
3 |
openaireplus.msro.api.mongo.db = openaireplus_apis |
|
4 |
openaireplus.msro.api.mongo.collection = recent_publications |
|
5 |
|
|
6 |
openaireplus.msro.api.layoutToRecord.xslt = /eu/dnetlib/msro/openaireplus/workflows/index/openaireLayoutToRecordStylesheet.xsl |
|
7 |
openaireplus.msro.api.findSolrIndexUrl.xquery = /eu/dnetlib/msro/openaireplus/api/findSolrIndexUrl.xquery |
|
8 |
openaireplus.msro.api.findIndexDsInfo.xquery = /eu/dnetlib/msro/openaireplus/api/findIndexDsInfo.xquery |
Also available in: Unified diff
removed an invalid migration of the apis