Fixed map padding
This commit is contained in:
parent
766df57d5f
commit
38b741dbb1
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.accounting.analytics;
|
package org.gcube.accounting.analytics;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
@ -15,6 +16,18 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
*/
|
*/
|
||||||
public class Info {
|
public class Info {
|
||||||
|
|
||||||
|
public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS Z";
|
||||||
|
|
||||||
|
public static DateFormat getDateFormat() {
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATETIME_PATTERN);
|
||||||
|
simpleDateFormat.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||||
|
return simpleDateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String format(Calendar calendar) {
|
||||||
|
return getDateFormat().format(calendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
protected Calendar calendar;
|
protected Calendar calendar;
|
||||||
protected JsonNode value;
|
protected JsonNode value;
|
||||||
|
|
||||||
|
@ -58,8 +71,6 @@ public class Info {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS z");
|
return String.format("Date : %s, Value : %s", format(calendar), value.toString());
|
||||||
simpleDateFormat.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
|
||||||
return String.format("Date : %s, Value : %s", simpleDateFormat.format(calendar.getTime()), value.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case AggregatedRecord.START_TIME:
|
case AggregatedRecord.START_TIME:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AggregatedRecord.END_TIME:
|
case AggregatedRecord.END_TIME:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -170,7 +170,9 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
for (Calendar progressTime : sequence) {
|
for (Calendar progressTime : sequence) {
|
||||||
Info info = unpaddedData.get(progressTime);
|
Info info = unpaddedData.get(progressTime);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info = new Info(progressTime, jsonNode);
|
ObjectNode objectNode = jsonNode.deepCopy();
|
||||||
|
objectNode.put(AggregatedStorageUsageRecord.START_TIME, Info.format(progressTime));
|
||||||
|
info = new Info(progressTime, objectNode);
|
||||||
unpaddedData.put(progressTime, info);
|
unpaddedData.put(progressTime, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue