forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpload.java
More file actions
130 lines (113 loc) · 3.84 KB
/
Copy pathUpload.java
File metadata and controls
130 lines (113 loc) · 3.84 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
/**
* Copyright (C) 2004-2016, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.dataset;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.gooddata.util.BooleanDeserializer;
import com.gooddata.util.GDDateTimeDeserializer;
import com.gooddata.util.GoodDataToStringBuilder;
import org.joda.time.DateTime;
import org.springframework.web.util.UriTemplate;
/**
* Contains information about single dataset upload.
* Deserialization only.
*/
@JsonTypeName("dataUpload")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Upload {
public static final String URI = "/gdc/md/{projectId}/data/upload/{uploadId}";
public static final UriTemplate URI_TEMPLATE = new UriTemplate(URI);
private final String uri;
private final String status;
private final double progress;
private final String message;
private final UploadMode uploadMode;
private final Integer size;
private final DateTime createdAt;
private final DateTime processedAt;
Upload(@JsonProperty("msg") String message,
@JsonProperty("progress") Double progress,
@JsonProperty("status") String status,
@JsonProperty("fullUpload") @JsonDeserialize(using = BooleanDeserializer.class) Boolean fullUpload,
@JsonProperty("uri") String uri,
@JsonProperty("createdAt") @JsonDeserialize(using = GDDateTimeDeserializer.class) DateTime createdAt,
@JsonProperty("fileSize") Integer size,
@JsonProperty("processedAt") @JsonDeserialize(using = GDDateTimeDeserializer.class) DateTime processedAt) {
this.uri = uri;
this.status = status;
this.progress = progress != null ? progress : 0;
this.message = message;
this.uploadMode = toUploadMode(fullUpload);
this.size = size;
this.createdAt = createdAt;
this.processedAt = processedAt;
}
/**
* @return uri link to self
*/
public String getUri() {
return uri;
}
/**
* @return upload status
*/
public String getStatus() {
return status;
}
/**
* @return upload progress in percent as floating point number
*/
public double getProgress() {
return progress;
}
/**
* @return error message if the upload failed, {@code null} otherwise
*/
public String getMessage() {
return message;
}
/**
* @return {@link UploadMode} of this upload
*/
public UploadMode getUploadMode() {
return uploadMode;
}
/**
* @return size of the data uploaded by this upload
*/
public Integer getSize() {
return size;
}
/**
* @return date of creation of this upload
*/
public DateTime getCreatedAt() {
return createdAt;
}
/**
* @return date when the upload was processed or {@code null} if upload is still being processed
*/
public DateTime getProcessedAt() {
return processedAt;
}
/**
* Converts boolean value containing if the upload is full or incremental load to {@link UploadMode} enum.
*/
private UploadMode toUploadMode(Boolean fullUpload) {
if (fullUpload == null) {
return null;
}
return fullUpload ? UploadMode.FULL : UploadMode.INCREMENTAL;
}
@Override
public String toString() {
return GoodDataToStringBuilder.defaultToString(this);
}
}