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
108 lines (88 loc) · 3.08 KB
/
Project.java
File metadata and controls
108 lines (88 loc) · 3.08 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
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata.project;
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;
/**
*/
@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 Content content;
private Meta meta;
private Links links;
public Project(String title, String authorizationToken) {
content = new Content(authorizationToken);
meta = new Meta(title);
}
@JsonCreator
public Project(@JsonProperty("content") Content content, @JsonProperty("meta") Meta meta, @JsonProperty("links") Links links) {
this.content = content;
this.meta = meta;
this.links = links;
}
public Content getContent() {
return content;
}
@JsonIgnore
public String getId() {
return PROJECT_TEMPLATE.match(getLinks().getSelf()).get("id");
}
public Meta getMeta() {
return meta;
}
public Links getLinks() {
return links;
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public static class Content {
private @JsonProperty String authorizationToken;
private @JsonProperty Integer guidedNavigation = 1;
private String state;
@JsonCreator
public Content(@JsonProperty("authorizationToken") String authorizationToken) {
this.authorizationToken = authorizationToken;
}
public String getState() {
return state;
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public static class Meta {
private @JsonProperty String title;
@JsonCreator
public Meta(@JsonProperty("title") String title) {
this.title = title;
}
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Links {
private final String self;
private final String uploads;
@JsonCreator
public Links(@JsonProperty("self") String self, @JsonProperty("uploads") String uploads) {
this.self = self;
this.uploads = uploads;
}
public String getSelf() {
return self;
}
public String getUploads() {
return uploads;
}
}
}