1
|
package eu.dnetlib.functionality.index.action;
|
2
|
|
3
|
import org.apache.commons.codec.binary.Base64;
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
5
|
|
6
|
import eu.dnetlib.data.provision.index.rmi.IndexServiceException;
|
7
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
8
|
import eu.dnetlib.functionality.index.feed.FeedMode;
|
9
|
import eu.dnetlib.functionality.index.utils.MetadataReference;
|
10
|
import eu.dnetlib.functionality.index.utils.ServiceTools;
|
11
|
|
12
|
/**
|
13
|
* The Class AbstractIndexAction.
|
14
|
*/
|
15
|
public class AbstractIndexAction {
|
16
|
|
17
|
/** The serivce tools. */
|
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
|
43
|
* the md ref
|
44
|
* @return the MD format fields
|
45
|
*/
|
46
|
protected String getMDFormatFields(final MetadataReference mdRef) {
|
47
|
return serviceTools.getIndexFields(mdRef);
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* Gets the epr.
|
52
|
*
|
53
|
* @param job
|
54
|
* the job
|
55
|
* @return the epr
|
56
|
*/
|
57
|
protected String getEpr(final BlackboardJob job) {
|
58
|
return new String(Base64.decodeBase64(job.getParameters().get(BBParam.RS_EPR).getBytes()));
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* Gets the index ds id.
|
63
|
*
|
64
|
* @param job
|
65
|
* the job
|
66
|
* @return the index ds id
|
67
|
*/
|
68
|
protected String getIndexDSId(final BlackboardJob job) {
|
69
|
return job.getParameters().get(BBParam.INDEX_DS_ID);
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Gets the feed mode.
|
74
|
*
|
75
|
* @param job
|
76
|
* the job
|
77
|
* @return the feed mode
|
78
|
*/
|
79
|
protected FeedMode getFeedMode(final BlackboardJob job) {
|
80
|
return FeedMode.valueOf(job.getParameters().get(BBParam.FEEDING_TYPE));
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Gets the metadata reference.
|
85
|
*
|
86
|
* @param indexDSId
|
87
|
* the index ds id
|
88
|
* @return the metadata reference
|
89
|
* @throws IndexServiceException
|
90
|
* the index service exception
|
91
|
*/
|
92
|
protected MetadataReference getMetadataReference(final String indexDSId) throws IndexServiceException {
|
93
|
return serviceTools.getMetadataRef(indexDSId);
|
94
|
}
|
95
|
|
96
|
protected MetadataReference getMetadataReference(final BlackboardJob job) {
|
97
|
|
98
|
final String format = job.getParameters().get(BBParam.FORMAT);
|
99
|
final String layout = job.getParameters().get(BBParam.LAYOUT);
|
100
|
final String interpretation = job.getParameters().get(BBParam.INTERP);
|
101
|
|
102
|
return new MetadataReference(format, layout, interpretation);
|
103
|
}
|
104
|
|
105
|
/**
|
106
|
* Gets the backend.
|
107
|
*
|
108
|
* @param job
|
109
|
* the job
|
110
|
* @return the backend
|
111
|
*/
|
112
|
protected String getBackend(final BlackboardJob job) {
|
113
|
return job.getParameters().get(BBParam.BACKEND);
|
114
|
}
|
115
|
|
116
|
/**
|
117
|
* Gets the query.
|
118
|
*
|
119
|
* @param job
|
120
|
* the job
|
121
|
* @return the query
|
122
|
*/
|
123
|
protected String getQuery(final BlackboardJob job) {
|
124
|
return job.getParameters().get(BBParam.QUERY);
|
125
|
}
|
126
|
|
127
|
}
|