Project

General

Profile

1
package eu.dnetlib.data.objectstore.modular;
2

    
3
import javax.annotation.Resource;
4
import javax.xml.ws.wsaddressing.W3CEndpointReference;
5

    
6
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
7
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
8
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
9
import eu.dnetlib.enabling.resultset.ResultSetFactory;
10
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
11
import org.springframework.beans.factory.annotation.Required;
12

    
13
/**
14
 * The Class ModularObjectStoreDeliver is responsible of delivering data from the object Store.
15
 */
16
public class ModularObjectStoreDeliver {
17

    
18
	/** The dao. */
19
	private ObjectStoreDao dao;
20

    
21
	/** The result set factory. */
22
	@Resource
23
	private ResultSetFactory resultSetFactory;
24

    
25
	/** The result set client factory. */
26
	private ResultSetClientFactory resultSetClientFactory;
27

    
28
	/**
29
	 * Gets the dao.
30
	 *
31
	 * @return the dao
32
	 */
33
	public ObjectStoreDao getDao() {
34
		return dao;
35
	}
36

    
37
	/**
38
	 * Sets the dao.
39
	 *
40
	 * @param dao
41
	 *            the new dao
42
	 */
43
	@Required
44
	public void setDao(final ObjectStoreDao dao) {
45
		this.dao = dao;
46
	}
47

    
48
	/**
49
	 * Deliver.
50
	 *
51
	 * @param objectStoreID
52
	 *            the object store id
53
	 * @param from
54
	 *            the from
55
	 * @param until
56
	 *            the until
57
	 * @return the w3 c endpoint reference
58
	 * @throws ObjectStoreServiceException
59
	 */
60
	public W3CEndpointReference deliver(final String objectStoreID, final Long from, final Long until) throws ObjectStoreServiceException {
61
		return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliver(from, until));
62
	}
63

    
64
	/**
65
	 * Deliver ids.
66
	 *
67
	 * @param objectStoreID
68
	 *            the object store id
69
	 * @param eprId
70
	 *            the epr id
71
	 * @return the w3 c endpoint reference
72
	 * @throws ObjectStoreServiceException
73
	 */
74
	public W3CEndpointReference deliverIds(final String objectStoreID, final W3CEndpointReference eprId) throws ObjectStoreServiceException {
75

    
76
		Iterable<String> ids = resultSetClientFactory.getClient(eprId);
77
		return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliverIds(ids));
78
	}
79

    
80
	/**
81
	 * Exist id starts with.
82
	 *
83
	 * @param obsId
84
	 *            the obs id
85
	 * @param startId
86
	 *            the start id
87
	 * @return true, if successful
88
	 * @throws ObjectStoreServiceException
89
	 */
90
	public boolean existIDStartsWith(final String obsId, final String startId) throws ObjectStoreServiceException {
91
		return dao.getObjectStore(obsId).existIDStartsWith(startId);
92
	}
93

    
94
	/**
95
	 * Deliver object.
96
	 *
97
	 * @param objectStoreID
98
	 *            the object store id
99
	 * @param objectId
100
	 *            the object id
101
	 * @return the object store file
102
	 * @throws ObjectStoreServiceException
103
	 */
104
	public ObjectStoreFile deliverObject(final String objectStoreID, final String objectId) throws ObjectStoreServiceException {
105
		return dao.getObjectStore(objectStoreID).deliverObject(objectId);
106
	}
107

    
108
	/**
109
	 * Gets the result set client factory.
110
	 *
111
	 * @return the result set client factory
112
	 */
113
	public ResultSetClientFactory getResultSetClientFactory() {
114
		return resultSetClientFactory;
115
	}
116

    
117
	/**
118
	 * Sets the result set client factory.
119
	 *
120
	 * @param resultSetClientFactory
121
	 *            the new result set client factory
122
	 */
123
	@Required
124
	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
125
		this.resultSetClientFactory = resultSetClientFactory;
126
	}
127

    
128
}
(7-7/15)