-
Notifications
You must be signed in to change notification settings - Fork 477
/
CTLService.java
277 lines (247 loc) · 9.89 KB
/
CTLService.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
* Copyright 2014-2016 CyberVision, Inc.
*
* 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 org.kaaproject.kaa.server.common.dao;
import org.apache.avro.Schema;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto;
import org.kaaproject.kaa.common.dto.file.FileData;
import java.util.List;
/**
* Common type library service.
*/
public interface CTLService {
public static final String DEFAULT_SYSTEM_EMPTY_SCHEMA_FQN =
"org.kaaproject.kaa.schema.system.EmptyData";
public static final int DEFAULT_SYSTEM_EMPTY_SCHEMA_VERSION = 1;
/**
* Get or create empty CTL schema with system scope.
*
* @param createdUsername the name of user.
* @return CTLSchemaDto the empty schema with system scope.
*/
CTLSchemaDto getOrCreateEmptySystemSchema(String createdUsername);
/**
* Update existing CTL schema by the given CTL schema object.
*
* @param ctlSchema the CTL schema object.
* @return CTLSchemaDto the updated object.
*/
CTLSchemaDto updateCtlSchema(CTLSchemaDto ctlSchema);
/**
* Update existing CTL schema meta info scope by the given CTL schema meta info object.
*
* @param ctlSchemaMetaInfo the CTL schema meta info object.
* @return CTLSchemaMetaInfoDto the updated CTL schema meta info object.
*/
CTLSchemaMetaInfoDto updateCtlSchemaMetaInfoScope(CTLSchemaMetaInfoDto ctlSchemaMetaInfo);
/**
* Find CTL schema meta infos which are the application level siblings to the CTL
* of the given fully qualified name, tenant and application identifiers.
*
* @param fqn the fully qualified.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the CTL schema meta information objects which are the siblings to the given CTL.
*/
List<CTLSchemaMetaInfoDto> findSiblingsByFqnTenantIdAndApplicationId(
String fqn, String tenantId, String applicationId);
/**
* Remove a CTL schema of the given tenant or application with the given fully qualified
* name and version number.
*
* @param fqn the fully qualified name.
* @param version the schema version.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
*/
void removeCtlSchemaByFqnAndVerAndTenantIdAndApplicationId(
String fqn, Integer version, String tenantId, String applicationId);
/**
* Find a CTL schema with the given identifier.
*
* @param schemaId the CTL schema identifier.
* @return CTLSchemaDto the CTL schema with the given identifier.
*/
CTLSchemaDto findCtlSchemaById(String schemaId);
/**
* Saves the given CTL schema to the database.
*
* @param ctlSchemaDto the CTL schema to save.
* @return CTLSchemaDto the saved CTL schema.
*/
CTLSchemaDto saveCtlSchema(CTLSchemaDto ctlSchemaDto);
/**
* Find CTL schema with the given meta info id and version.
*
* @param metaInfoId the id of meta info object.
* @param version the schema version.
* @return the CTL schema with the given meta info id and version.
*/
CTLSchemaDto findByMetaInfoIdAndVer(String metaInfoId, Integer version);
/**
* Find a CTL schema of the given tenant or application with the given fully qualified name
* and version number.
*
* @param fqn the fully qualified name.
* @param version the CTL schema version.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the CTL schema with the given fully qualified name and version number.
*/
CTLSchemaDto findCtlSchemaByFqnAndVerAndTenantIdAndApplicationId(
String fqn, Integer version, String tenantId, String applicationId);
/**
* Find any CTL schema of the given tenant or application with the given fully qualified name
* and version number.
*
* @param fqn the fully qualified name.
* @param version the CTL schema version.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the any CTL schema with the given fully qualified name and version number.
*/
CTLSchemaDto findAnyCtlSchemaByFqnAndVerAndTenantIdAndApplicationId(
String fqn, Integer version, String tenantId, String applicationId);
/**
* Find system CTL schemas available in the database.
*
* @return the list of available system CTL schemas in the database.
*/
List<CTLSchemaDto> findSystemCtlSchemas();
/**
* Find system CTL schemas meta info available in the database.
*
* @return the list of available system CTL schemas meta info in the database.
*/
List<CTLSchemaMetaInfoDto> findSystemCtlSchemasMetaInfo();
/**
* Find available CTL schemas meta info for tenant(include
* system scope) with the given tenant identifier.
*
* @param tenantId the tenant identifier.
* @return the list of available CTL schemas meta info for tenant with given identifier.
*/
List<CTLSchemaMetaInfoDto> findAvailableCtlSchemasMetaInfoForTenant(String tenantId);
/**
* Find available CTL schemas meta info for application(include
* system and tenant scope) with the given tenant and application identifier.
*
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the list of available CTL schemas meta info for application with given identifier.
*/
List<CTLSchemaMetaInfoDto> findAvailableCtlSchemasMetaInfoForApplication(
String tenantId, String applicationId);
/**
* Find the last version of CTL schema with the given fully qualified name, tenant and application
* identifier.
*
* @param fqn the fully qualified name.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the latest version of CTL schema with the given fully qualified name, tenant and
* application identifier.
*/
CTLSchemaDto findLatestCtlSchemaByFqnAndTenantIdAndApplicationId(
String fqn, String tenantId, String applicationId);
/**
* Find the last version of CTL schema with the given meta info id.
*
* @param metaInfoId the id of meta info object.
* @return the latest version of CTL schema with the given meta info id.
*/
CTLSchemaDto findLatestByMetaInfoId(String metaInfoId);
/**
* Find all available versions of CTL schema with the given fully qualified name, tenant and
* application identifier.
*
* @param fqn the fully qualified name.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the list of available versions of CTL schema with the given fully qualified name,
* tenant and application identifier.
*/
List<CTLSchemaDto> findAllCtlSchemasByFqnAndTenantIdAndApplicationId(
String fqn, String tenantId, String applicationId);
/**
* Find CTL schemas available in the database.
*
* @return the list of available CTL schemas in the database.
*/
List<CTLSchemaDto> findCtlSchemas();
/**
* Find the dependents CTL schemas from CTL schema with the given schema
* identifier
*
* @param schemaId the schema identifier.
* @return the list of dependents CTL schemas from CTL schema with the given identifier.
*/
List<CTLSchemaDto> findCtlSchemaDependents(String schemaId);
/**
* Find the dependents CTL schemas from CTL schema with the given tenant, application,
* fully qualified name and version number.
*
* @param fqn the fully qualified name.
* @param version the schema version.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the list of dependents CTL schemas from CTL schema with the given tenant, application,
* fully qualified name and version.
*/
List<CTLSchemaDto> findCtlSchemaDependents(
String fqn, Integer version, String tenantId, String applicationId);
/**
* Exports the body of a CTL schema.
*
* @param schema A CTL schema to export
* @return A file containing the body of a CTL schema
*/
FileData shallowExport(CTLSchemaDto schema);
/**
* Exports the body of a CTL schema with all dependencies inline,
* recursively.
*
* @param schema A CTL schema to export
* @return A string containing the body of a CTL schema with all dependencies inline, recursively
*/
String flatExportAsString(CTLSchemaDto schema);
/**
* Exports the body of a CTL schema with all dependencies inline,
* recursively.
*
* @param schema A CTL schema to export
* @return A Schema object containing the body of a CTL schema with all dependencies inline,
* recursively
*/
Schema flatExportAsSchema(CTLSchemaDto schema);
/**
* Exports the body of a CTL schema with all dependencies inline,
* recursively.
*
* @param schema A CTL schema to export
* @return A file containing the body of a CTL schema with all dependencies inline, recursively
*/
FileData flatExport(CTLSchemaDto schema);
/**
* Exports the body of a CTL schema with all dependencies as different
* files, recursively.
*
* @param schema A CTL schema to export
* @return An archive containing the body of a CTL schema as a file and all dependencies as
* different files, recursively.
*/
FileData deepExport(CTLSchemaDto schema);
}