1
|
package eu.dnetlib.index.action;
|
2
|
|
3
|
import eu.dnetlib.clients.index.utils.MetadataReference;
|
4
|
import eu.dnetlib.clients.index.utils.ServiceTools;
|
5
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
6
|
import eu.dnetlib.index.feed.FeedMode;
|
7
|
import eu.dnetlib.rmi.provision.IndexServiceException;
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
|
10
|
/**
|
11
|
* The Class AbstractIndexAction.
|
12
|
*/
|
13
|
public class AbstractIndexAction {
|
14
|
|
15
|
/**
|
16
|
* The serivce tools.
|
17
|
*/
|
18
|
@Autowired
|
19
|
protected ServiceTools serviceTools;
|
20
|
|
21
|
/**
|
22
|
* Gets the service address.
|
23
|
*
|
24
|
* @return the service address
|
25
|
*/
|
26
|
public String getServiceAddress(final String backendId) {
|
27
|
return serviceTools.getServiceAddress(backendId);
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Gets the service address.
|
32
|
*
|
33
|
* @return the service address
|
34
|
*/
|
35
|
// public String getServiceAddress() {
|
36
|
// return serviceTools.getServiceAddress();
|
37
|
// }
|
38
|
|
39
|
/**
|
40
|
* Gets the MD format fields.
|
41
|
*
|
42
|
* @param mdRef the md ref
|
43
|
* @return the MD format fields
|
44
|
*/
|
45
|
protected String getMDFormatFields(final MetadataReference mdRef) {
|
46
|
return serviceTools.getIndexFields(mdRef);
|
47
|
}
|
48
|
|
49
|
/**
|
50
|
* Gets the epr.
|
51
|
*
|
52
|
* @param job the job
|
53
|
* @return the epr
|
54
|
*/
|
55
|
protected String getEpr(final BlackboardJob job) {
|
56
|
return job.getParameters().get(BBParam.RS_EPR);
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* Gets the index ds id.
|
61
|
*
|
62
|
* @param job the job
|
63
|
* @return the index ds id
|
64
|
*/
|
65
|
protected String getIndexDSId(final BlackboardJob job) {
|
66
|
return job.getParameters().get(BBParam.INDEX_DS_ID);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Gets the feed mode.
|
71
|
*
|
72
|
* @param job the job
|
73
|
* @return the feed mode
|
74
|
*/
|
75
|
protected FeedMode getFeedMode(final BlackboardJob job) {
|
76
|
return FeedMode.valueOf(job.getParameters().get(BBParam.FEEDING_TYPE));
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* Gets the metadata reference.
|
81
|
*
|
82
|
* @param indexDSId the index ds id
|
83
|
* @return the metadata reference
|
84
|
* @throws IndexServiceException the index service exception
|
85
|
*/
|
86
|
protected MetadataReference getMetadataReference(final String indexDSId) throws IndexServiceException {
|
87
|
return serviceTools.getMetadataRef(indexDSId);
|
88
|
}
|
89
|
|
90
|
protected MetadataReference getMetadataReference(final BlackboardJob job) {
|
91
|
|
92
|
final String format = job.getParameters().get(BBParam.FORMAT);
|
93
|
final String layout = job.getParameters().get(BBParam.LAYOUT);
|
94
|
final String interpretation = job.getParameters().get(BBParam.INTERP);
|
95
|
|
96
|
return new MetadataReference(format, layout, interpretation);
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Gets the backend.
|
101
|
*
|
102
|
* @param job the job
|
103
|
* @return the backend
|
104
|
*/
|
105
|
protected String getBackend(final BlackboardJob job) {
|
106
|
return job.getParameters().get(BBParam.BACKEND);
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* Gets the query.
|
111
|
*
|
112
|
* @param job the job
|
113
|
* @return the query
|
114
|
*/
|
115
|
protected String getQuery(final BlackboardJob job) {
|
116
|
return job.getParameters().get(BBParam.QUERY);
|
117
|
}
|
118
|
|
119
|
}
|