1 /*
2 *
3 * Fosstrak LLRP Commander (www.fosstrak.org)
4 *
5 * Copyright (C) 2008 ETH Zurich
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>
19 *
20 */
21
22 package org.fosstrak.llrp.client;
23
24 import java.sql.Connection;
25 import java.util.ArrayList;
26 import java.util.Map;
27
28 import org.fosstrak.llrp.adaptor.exception.LLRPRuntimeException;
29
30 /**
31 * This single access point for Reader Management module to access the message
32 * repository. The instance class will be initiated in ResourceCenter.
33 *
34 * @author Haoning Zhang
35 * @version 1.0
36 */
37
38 public interface Repository {
39
40 /** flag to set the retrieval of messages to all messages in the repo. */
41 public static final int RETRIEVE_ALL = -1;
42
43 /**
44 * Initializer method for the repository. The method will be called directly
45 * after instantiation.
46 * @param args hash-map with the parameters.
47 * @throws when there is a problem with initialization (eg. missing param).
48 */
49 public void initialize(Map<String, String> args)
50 throws LLRPRuntimeException;
51
52 /**
53 * @return a hash map with the properties passed by the initializer.
54 */
55 public Map<String, String> getArgs();
56
57 /**
58 * Closing the repository.
59 */
60 public void close();
61
62 /**
63 * @return true if the repository is OK, false otherwise.
64 */
65 public boolean isHealth();
66
67 /**
68 * Get the LLRP Message Item from repository according to the unique Message ID.
69 *
70 * @param aMsgSysId The unique message ID
71 * @return LLRP Message Wrapper Item
72 */
73 public LLRPMessageItem get(String aMsgSysId);
74
75 /**
76 * Put the LLRP Message Item to the repository
77 *
78 * @param aMessage LLRP Message Wrapper Item
79 */
80 public void put(LLRPMessageItem aMessage);
81
82 /**
83 * returns all the messages from the specified adaptor and the reader
84 * limited by num. if you set num to RETRIEVE_ALL all messages get returned.
85 * if you set readerName to null, all the messages of all the readers with
86 * adaptor adaptorName will be returned.
87 * @param adaptorName the name of the adaptor.
88 * @param readerName the name of the reader.
89 * @param num how many messages to retrieve.
90 * @param content if true retrieve the message content, false no content.
91 * @return a list of messages.
92 */
93 public ArrayList<LLRPMessageItem> get(
94 String adaptorName, String readerName, int num, boolean content);
95
96 /**
97 * returns the number of messages in the repository to a given filter.
98 * @param adaptor the name of the adaptor to filter. if null all the
99 * messages in the repository get return.
100 * @param reader the name of the reader to filter. if null all the
101 * messages of the given adaptor will be returned.
102 * @return the number of messages in the repository.
103 */
104 public int count(String adaptor, String reader);
105
106 /**
107 * Clear all the items in repository.
108 */
109 public void clearAll();
110
111 /**
112 * clear all the items that belong to a given adapter.
113 * @param adapter the name of the adapter to clear.
114 */
115 public void clearAdapter(String adapter);
116
117 /**
118 * clear all the items that belong to a given reader on a given adapter.
119 * @param adapter the name of the adapter where the reader belongs to.
120 * @param reader the name of the reader to clear.
121 */
122 public void clearReader(String adapter, String reader);
123
124 /**
125 * @return a handle to the database connection. users of the repository are
126 * allowed to use the database for their own purposes.
127 */
128 public Connection getDBConnection();
129
130 /**
131 * The {@link ROAccessReportsRepository} is implemented via the strategy
132 * pattern. Depending on the type of the repository, you will get a
133 * different implementation of this handle at runtime. The respective
134 * implementation will setup the data-structures used to log
135 * RO_ACCESS_REPORTS and ease the access to the stored information.
136 *
137 * @return a handle to the RO_ACCESS_REPORTS repository. if the
138 * implementation of the repository does not implement this functionality,
139 * it shall return <code>null</code>.
140 */
141 public ROAccessReportsRepository getROAccessRepository();
142 }