forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
452 lines (366 loc) · 12.3 KB
/
Project.java
File metadata and controls
452 lines (366 loc) · 12.3 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata.project;
import com.gooddata.md.Meta;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.springframework.web.util.UriTemplate;
import java.util.HashSet;
import java.util.Set;
import static java.util.Arrays.asList;
/**
* Project in GoodData platform
*/
@JsonTypeName("project")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Project {
public static final String PROJECTS_URI = "/gdc/account/profile/{id}/projects";
public static final String PROJECT_URI = Projects.URI + "/{id}";
public static final UriTemplate PROJECT_TEMPLATE = new UriTemplate(PROJECT_URI);
private static final Set<String> PREPARING_STATES = new HashSet<>(asList("PREPARING", "PREPARED", "LOADING"));
@JsonProperty("content")
private ProjectContent content;
@JsonProperty("meta")
private ProjectMeta meta;
@JsonIgnore
private Links links;
public Project(String title, String authorizationToken) {
content = new ProjectContent(authorizationToken);
meta = new ProjectMeta(title);
}
public Project(String title, String summary, String authorizationToken) {
content = new ProjectContent(authorizationToken);
meta = new ProjectMeta(title, summary);
}
@JsonCreator
private Project(@JsonProperty("content") ProjectContent content, @JsonProperty("meta") ProjectMeta meta,
@JsonProperty("links") Links links) {
this.content = content;
this.meta = meta;
this.links = links;
}
public void setProjectTemplate(String uri) {
meta.setProjectTemplate(uri);
}
@JsonIgnore
public String getId() {
return PROJECT_TEMPLATE.match(getSelfLink()).get("id");
}
@JsonIgnore
public String getState() {
return content.getState();
}
@JsonIgnore
public String getAuthorizationToken() {
return content.getAuthorizationToken();
}
@JsonIgnore
public String getDriver() {
return content.getDriver();
}
@JsonIgnore
public String getGuidedNavigation() {
return content.getGuidedNavigation();
}
@JsonIgnore
public String getCluster() {
return content.getCluster();
}
@JsonIgnore
public Boolean isPublic() {
return "1".equals(content.getIsPublic());
}
@JsonIgnore
public String getTitle() {
return meta.getTitle();
}
@JsonIgnore
public String getSummary() {
return meta.getSummary();
}
@JsonIgnore
public String getAuthor() {
return meta.getAuthor();
}
@JsonIgnore
public String getContributor() {
return meta.getContributor();
}
@JsonIgnore
public String getCreated() {
return meta.getCreated();
}
@JsonIgnore
public String getUpdated() {
return meta.getUpdated();
}
@JsonIgnore
public String getSelfLink() {
return links.getSelf();
}
@JsonIgnore
public String getUsersLink() {
return links.getUsers();
}
@JsonIgnore
public String getRolesLink() {
return links.getRoles();
}
@JsonIgnore
public String getGroupsLink() {
return links.getGroups();
}
@JsonIgnore
public String getInvitationsLink() {
return links.getInvitations();
}
@JsonIgnore
public String getLdmLink() {
return links.getLdm();
}
@JsonIgnore
public String getLdmThumbnailLink() {
return links.getLdmThumbnail();
}
@JsonIgnore
public String getMetadataLink() {
return links.getMetadata();
}
@JsonIgnore
public String getPublicArtifactsLink() {
return links.getPublicArtifacts();
}
@JsonIgnore
public String getTemplatesLink() {
return links.getTemplates();
}
@JsonIgnore
public String getConnectorsLink() {
return links.getConnectors();
}
@JsonIgnore
public String getDataLoadLink() {
return links.getDataLoad();
}
@JsonIgnore
public String getSchedulesLink() {
return links.getSchedules();
}
@JsonIgnore
public String getExecuteLink() {
return links.getExecute();
}
@JsonIgnore
public String getEventStoresLink() {
return links.getEventStores();
}
@JsonIgnore
public String getClearCachesLink() {
return links.getClearCaches();
}
@JsonIgnore
public String getUploadsLink() {
return links.getUploads();
}
@JsonIgnore
public boolean isPreparing() {
return PREPARING_STATES.contains(getState());
}
@JsonIgnore
public boolean isEnabled() {
return "ENABLED".equals(getState());
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
private static class ProjectContent {
@JsonProperty("authorizationToken")
private String authorizationToken;
@JsonProperty("driver")
private String driver;
@JsonProperty("guidedNavigation")
private String guidedNavigation;
@JsonIgnore
private String cluster;
@JsonIgnore
private String isPublic;
@JsonIgnore
private String state;
@JsonCreator
public ProjectContent(@JsonProperty("authorizationToken") String authorizationToken,
@JsonProperty("driver") String driver,
@JsonProperty("cluster") String cluster,
@JsonProperty("guidedNavigation") String guidedNavigation,
@JsonProperty("isPublic") String isPublic,
@JsonProperty("state") String state) {
this.authorizationToken = authorizationToken;
this.guidedNavigation = guidedNavigation;
this.driver = driver;
this.cluster = cluster;
this.isPublic = isPublic;
this.state = state;
}
public ProjectContent(final String authorizationToken) {
this.authorizationToken = authorizationToken;
guidedNavigation = "1";
driver = "Pg";
}
public String getState() {
return state;
}
public String getAuthorizationToken() {
return authorizationToken;
}
public String getDriver() {
return driver;
}
public String getGuidedNavigation() {
return guidedNavigation;
}
public String getCluster() {
return cluster;
}
public String getIsPublic() {
return isPublic;
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
private static class Links {
private final String self;
private final String users;
private final String roles;
private final String groups;
private final String invitations;
private final String ldm;
private final String ldmThumbnail;
private final String metadata;
private final String publicArtifacts;
private final String templates;
private final String connectors;
private final String dataLoad;
private final String schedules;
private final String execute;
private final String eventStores;
private final String clearCaches;
private final String uploads;
@JsonCreator
public Links(@JsonProperty("self") String self,
@JsonProperty("users") String users,
@JsonProperty("roles") String roles,
@JsonProperty("groups") String groups,
@JsonProperty("invitations") String invitations,
@JsonProperty("ldm") String ldm,
@JsonProperty("ldm_thumbnail") String ldmThumbnail,
@JsonProperty("metadata") String metadata,
@JsonProperty("publicartifacts") String publicArtifacts,
@JsonProperty("templates") String templates,
@JsonProperty("connectors") String connectors,
@JsonProperty("dataload") String dataLoad,
@JsonProperty("schedules") String schedules,
@JsonProperty("execute") String execute,
@JsonProperty("eventstores") String eventStores,
@JsonProperty("clearCaches") String clearCaches,
@JsonProperty("uploads") String uploads) {
this.self = self;
this.users = users;
this.roles = roles;
this.groups = groups;
this.invitations = invitations;
this.ldm = ldm;
this.ldmThumbnail = ldmThumbnail;
this.metadata = metadata;
this.publicArtifacts = publicArtifacts;
this.templates = templates;
this.connectors = connectors;
this.dataLoad = dataLoad;
this.schedules = schedules;
this.execute = execute;
this.eventStores = eventStores;
this.clearCaches = clearCaches;
this.uploads = uploads;
}
public String getSelf() {
return self;
}
public String getUsers() {
return users;
}
public String getRoles() {
return roles;
}
public String getGroups() {
return groups;
}
public String getInvitations() {
return invitations;
}
public String getLdm() {
return ldm;
}
public String getLdmThumbnail() {
return ldmThumbnail;
}
public String getMetadata() {
return metadata;
}
public String getPublicArtifacts() {
return publicArtifacts;
}
public String getTemplates() {
return templates;
}
public String getConnectors() {
return connectors;
}
public String getDataLoad() {
return dataLoad;
}
public String getSchedules() {
return schedules;
}
public String getExecute() {
return execute;
}
public String getEventStores() {
return eventStores;
}
public String getClearCaches() {
return clearCaches;
}
public String getUploads() {
return uploads;
}
}
private static class ProjectMeta extends Meta {
private String projectTemplate;
@JsonCreator
private ProjectMeta(@JsonProperty("author") String author, @JsonProperty("contributor") String contributor,
@JsonProperty("created") String created, @JsonProperty("updated") String updated,
@JsonProperty("summary") String summary, @JsonProperty("title") String title,
@JsonProperty("category") String category, @JsonProperty("tags") String tags,
@JsonProperty("uri") String uri, @JsonProperty("deprecated") String deprecated,
@JsonProperty("identifier") String identifier,
@JsonProperty("locked") Integer locked, @JsonProperty("unlisted") Integer unlisted) {
super(author, contributor, created, updated, summary, title, category, tags, uri, deprecated, identifier, locked, unlisted);
}
private ProjectMeta(String title) {
super(title);
}
private ProjectMeta(String title, String summary) {
super(title, summary);
}
public String getProjectTemplate() {
return projectTemplate;
}
public void setProjectTemplate(String projectTemplate) {
this.projectTemplate = projectTemplate;
}
}
}