-
Notifications
You must be signed in to change notification settings - Fork 234
/
Client.java
191 lines (173 loc) · 6.03 KB
/
Client.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*******************************************************************************
* * Copyright 2012 Impetus Infotech.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
******************************************************************************/
package com.impetus.kundera.client;
import java.util.List;
import java.util.Map;
import com.impetus.kundera.db.RelationHolder;
import com.impetus.kundera.persistence.context.jointable.JoinTableData;
/**
* Client API. Defines methods which are required for to be implemented by
* various clients(pelops, Mongo). Any new addition of new client must implement
* this API to integrate new client with existing Kundera API. It's an extension
* API to support extension of new client.
*
* @author vivek.mishra
*/
public interface Client
{
/**
* Method to be implemented by inherited classes. On receiving persist event
* specific client need to implement this method.
* @param entity
* entity object.
* @param key
* entity id.
* @param rlHolders
* relation holders. This field is only required in case Entity
* is holding up any associations with other entities.
*/
void persist(Object entity, Object key, List<RelationHolder> rlHolders);
/**
* Retrieve columns from a column-family row.
*
* @param the
* element type
* @param entityClass
* the entity class
* @param key
* The key of the row
* @return A list of matching columns
* @throws Exception
* the exception
*/
Object find(Class entityClass, Object key);
/**
* Delete.
*
* @param entity
* the entity
* @param pKey
* the key
* @throws Exception
* the exception
*/
void delete(Object entity, Object pKey, List<RelationHolder> rlHolders);
/**
* Retrieve columns from multiple rows of a column-family.
*
* @param <E>
* the element type
* @param entityClass
* the entity class
* @param keys
* Array of row keys
* @return A Map of row and corresponding list of columns.
* @throws Exception
* the exception
*/
<E> List<E> findAll(Class<E> entityClass, Object... keys);
/**
* Load data.
*
* @param <E>
* the element type
* @param entityClass
* the entity class
* @param embeddedColumnMap
* the col
* @return the list
* @throws Exception
* the exception
*/
List find(Class<?> entityClass, Map<String, String> embeddedColumnMap);
/**
* Shutdown.
*/
void close();
void persistJoinTable(JoinTableData joinTableData);
/**
* Returns List of column values for given primary key and column name.
*
* @param <E>
* Type cast
* @param schemaName
* Schema/Keyspace name.
* @param tableName
* Table/column family name.
* @param pKeyColumnName
* Primary key column name.
* @param columnName
* Name of column to be fetched.
* @param pKeyColumnValue
* primary key value.
* @return list of values fetched for <columnName>
*/
<E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName, String columnName,
Object pKeyColumnValue);
/**
* Returns array of primary key for given column name and it's value.
*
* @param schemaName
* Schema/Keyspace name.
* @param tableName
* table/column family name.
* @param pKeyName
* primary key column name.
* @param columnName
* column name to be used for search.
* @param columnValue
* value for parameterised <columnName>.
* @param entity
* class entity class
* @return array containing fetched primary keys.
*/
Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
Object columnValue, Class entityClazz);
/**
* Delete rows from given table for given column name and corresponding
* value..
*
* @param schemaName
* Schema Name
* @param tableName
* Name of the table
* @param columnName
* Name of the column
* @param columnValue
* Name of column value
*/
void deleteByColumn(String schemaName, String tableName, String columnName, Object columnValue);
/**
* Find list of entities for given column name and column value, if index
* support is provided..
*
* @param colName
* the column name
* @param colValue
* the column value
* @param entityClass
* the entity class
* @return the list list of entities.
*/
List<Object> findByRelation(String colName, Object colValue, Class entityClazz);
/**
* Returns query implementor class, required for initializing client
* specific query interface.
*
* @return class instance of configured query interface.
*/
Class getDefaultQueryImplementor();
}