Project

General

Profile

1
package eu.dnetlib.oai;
2

    
3
import java.util.List;
4
import java.util.function.Function;
5

    
6
import eu.dnetlib.oai.info.RecordInfo;
7

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

    
16
	/**
17
	 * Returns the identifier of this store.
18
	 *
19
	 * @return a String that identifies this store
20
	 */
21
	String getId();
22

    
23
	/**
24
	 * Gets the metadata format of this store.
25
	 *
26
	 * @return String
27
	 */
28
	String getMetadataFormat();
29

    
30
	/**
31
	 * Gets the interpretation of this store.
32
	 *
33
	 * @return String
34
	 */
35
	String getInterpretation();
36

    
37
	/**
38
	 * Gets the layout of this store.
39
	 *
40
	 * @return String
41
	 */
42
	String getLayout();
43

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

    
52
	/**
53
	 * Retrieves the record with the given identifier from this store and apply the given unary function before delivering.
54
	 *
55
	 * @param recordId      identifier of the record to retrieve
56
	 * @param unaryFunction mapping from String to String
57
	 * @return a RecordInfo instance representing the XML record
58
	 */
59
	RecordInfo getRecord(final String recordId, final Function<String, String> unaryFunction);
60

    
61
	/**
62
	 * Retrieves the records matching the given query string.
63
	 *
64
	 * @param queryString  search criterion
65
	 * @param bodyIncluded false to get only identifiers, true to also get the body of records
66
	 * @param limit        max number of records to return. 0 means no limit.
67
	 * @return an instance of T that can be used to iterate over the results.
68
	 */
69
	T getRecords(final String queryString, final boolean bodyIncluded, final int limit);
70

    
71
	/**
72
	 * Retrieves the records matching the given query string and apply the given unary function before delivering.
73
	 *
74
	 * @param queryString   search criterion
75
	 * @param unaryFunction mapping from String to String
76
	 * @param bodyIncluded  false to get only identifiers, true to also get the body of records
77
	 * @param limit         max number of records to return. 0 means no limit.
78
	 * @return an instance of T that can be used to iterate over the results.
79
	 */
80
	T getRecords(final String queryString, final Function<String, String> unaryFunction, final boolean bodyIncluded, final int limit);
81

    
82
	/**
83
	 * Gets informaton about the indices available on this store.
84
	 *
85
	 * @return a List with information about the indices of this store.
86
	 */
87
	List<PublisherField> getIndices();
88

    
89
	/**
90
	 * Ensures the indices on this store.
91
	 */
92
	void ensureIndices();
93

    
94
	/**
95
	 * Feeds the store with the given records.
96
	 *
97
	 * @param records XML records to store.
98
	 * @param source  String that identifies the record source.
99
	 * @return the number of stored records.
100
	 */
101
	int feed(final Iterable<String> records, final String source);
102

    
103
	/**
104
	 * Drops the content of the store.
105
	 */
106
	void drop();
107

    
108
	/**
109
	 * Drops the elements matching the query from the store.
110
	 *
111
	 * @param queryString
112
	 */
113
	void drop(final String queryString);
114

    
115
	/**
116
	 * Counts the number of records in this store.
117
	 *
118
	 * @return the size of the store.
119
	 */
120
	int count();
121

    
122
	/**
123
	 * Counts the number of records in this store matching the query.
124
	 *
125
	 * @param queryString query
126
	 * @return the size of the store.
127
	 */
128
	int count(final String queryString);
129

    
130
}
(11-11/13)