Project

General

Profile

1
package eu.dnetlib.data.oai.store;
2

    
3
import java.util.List;
4

    
5
import eu.dnetlib.data.information.oai.publisher.PublisherField;
6
import eu.dnetlib.data.information.oai.publisher.info.RecordInfo;
7
import eu.dnetlib.miscutils.functional.UnaryFunction;
8

    
9
/**
10
 * Interface for store used by the publisher. Different back-ends require different implementation.
11
 * 
12
 * @author alessia
13
 * 
14
 * @param <T>
15
 *            class of the object that can be used to iterate results of a bulk request of records from the store.
16
 */
17
public interface PublisherStore<T extends Cursor> {
18

    
19
	/**
20
	 * Returns the identifier of this store.
21
	 * 
22
	 * @return a String that identifies this store
23
	 */
24
	String getId();
25

    
26
	/**
27
	 * Gets the metadata format of this store.
28
	 * 
29
	 * @return String
30
	 */
31
	String getMetadataFormat();
32

    
33
	/**
34
	 * Gets the interpretation of this store.
35
	 * 
36
	 * @return String
37
	 */
38
	String getInterpretation();
39

    
40
	/**
41
	 * Gets the layout of this store.
42
	 * 
43
	 * @return String
44
	 */
45
	String getLayout();
46

    
47
	/**
48
	 * Retrieves the record with the given identifier from this store.
49
	 * 
50
	 * @param recordId
51
	 *            identifier of the record to retrieve
52
	 * @return a RecordInfo instance representing the XML record
53
	 */
54
	RecordInfo getRecord(final String recordId);
55

    
56
	/**
57
	 * Retrieves the record with the given identifier from this store and apply the given unary function before delivering.
58
	 * 
59
	 * @param recordId
60
	 *            identifier of the record to retrieve
61
	 * @param unaryFunction
62
	 *            mapping from String to String
63
	 * @return a RecordInfo instance representing the XML record
64
	 */
65
	RecordInfo getRecord(final String recordId, final UnaryFunction<String, String> unaryFunction);
66

    
67
	/**
68
	 * Retrieves the records matching the given query string.
69
	 * 
70
	 * @param queryString
71
	 *            search criterion
72
	 * @param bodyIncluded
73
	 *            false to get only identifiers, true to also get the body of records
74
	 * @param limit
75
	 *            max number of records to return. 0 means no limit.
76
	 * @return an instance of T that can be used to iterate over the results.
77
	 */
78
	T getRecords(final String queryString, final boolean bodyIncluded, final int limit);
79

    
80
	/**
81
	 * Retrieves the records matching the given query string and apply the given unary function before delivering.
82
	 * 
83
	 * @param queryString
84
	 *            search criterion
85
	 * @param unaryFunction
86
	 *            mapping from String to String
87
	 * @param bodyIncluded
88
	 *            false to get only identifiers, true to also get the body of records
89
	 * @param limit
90
	 *            max number of records to return. 0 means no limit.
91
	 * @return an instance of T that can be used to iterate over the results.
92
	 */
93
	T getRecords(final String queryString, final UnaryFunction<String, String> unaryFunction, final boolean bodyIncluded, final int limit);
94

    
95
	/**
96
	 * Gets informaton about the indices available on this store.
97
	 * 
98
	 * @return a List with information about the indices of this store.
99
	 */
100
	List<PublisherField> getIndices();
101

    
102
	/**
103
	 * Ensures the indices on this store.
104
	 */
105
	void ensureIndices();
106

    
107
	/**
108
	 * Feeds the store with the given records.
109
	 * 
110
	 * @param records
111
	 *            XML records to store.
112
	 * @param source
113
	 *            String that identifies the record source.
114
	 * @return the number of stored records.
115
	 */
116
	int feed(final Iterable<String> records, final String source);
117

    
118
	/**
119
	 * Drops the content of the store.
120
	 * 
121
	 */
122
	void drop();
123

    
124
	/**
125
	 * Drops the elements matching the query from the store.
126
	 * 
127
	 * @param queryString
128
	 */
129
	void drop(final String queryString);
130

    
131
	/**
132
	 * Counts the number of records in this store.
133
	 * 
134
	 * @return the size of the store.
135
	 */
136
	int count();
137

    
138
	/**
139
	 * Counts the number of records in this store matching the query.
140
	 * 
141
	 * @param queryString
142
	 *            query
143
	 * @return the size of the store.
144
	 */
145
	int count(final String queryString);
146

    
147
}
(4-4/6)