Project

General

Profile

1 28448 sandro.lab
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 35863 claudio.at
import eu.dnetlib.functionality.index.utils.MetadataReference;
10 29687 sandro.lab
import eu.dnetlib.functionality.index.utils.ServiceTools;
11 28448 sandro.lab
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 29109 sandro.lab
	 *
24 28448 sandro.lab
	 * @return the service address
25
	 */
26 29687 sandro.lab
	public String getServiceAddress(final String backendId) {
27
		return serviceTools.getServiceAddress(backendId);
28 28448 sandro.lab
	}
29
30
	/**
31 29687 sandro.lab
	 * Gets the service address.
32
	 *
33
	 * @return the service address
34
	 */
35
	// public String getServiceAddress() {
36
	// return serviceTools.getServiceAddress();
37
	// }
38
39
	/**
40 28448 sandro.lab
	 * Gets the MD format fields.
41 29109 sandro.lab
	 *
42 28448 sandro.lab
	 * @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 29109 sandro.lab
	 *
53 28448 sandro.lab
	 * @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 29109 sandro.lab
	 *
64 28448 sandro.lab
	 * @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 29109 sandro.lab
	 *
75 28448 sandro.lab
	 * @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 29109 sandro.lab
	 *
86 28448 sandro.lab
	 * @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 29109 sandro.lab
	protected MetadataReference getMetadataReference(final BlackboardJob job) {
97
98 35863 claudio.at
		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 29109 sandro.lab
102
		return new MetadataReference(format, layout, interpretation);
103
	}
104
105 28529 sandro.lab
	/**
106
	 * Gets the backend.
107 29109 sandro.lab
	 *
108 28529 sandro.lab
	 * @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 35863 claudio.at
	/**
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 28448 sandro.lab
}