69: Create new Accounting Portlet
Task-Url: https://support.d4science.org/issues/69 Added constraints on start and end date git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@119779 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
69ebfaed81
commit
8bb95fa2f5
|
@ -243,8 +243,10 @@ public class AccountingManagerController {
|
|||
Date date=dtf.parse(currentDate);
|
||||
Date lastMonth=new Date(date.getTime());
|
||||
CalendarUtil.addMonthsToDate(lastMonth, -1);
|
||||
SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(lastMonth,
|
||||
date, AccountingPeriodMode.DAILY), null);
|
||||
SeriesRequest seriesRequest = new SeriesRequest(new AccountingPeriod(dtf.format(lastMonth),
|
||||
dtf.format(date), AccountingPeriodMode.DAILY), null);
|
||||
Log.debug("DefaultSeriesRequest: "+seriesRequest);
|
||||
Log.debug("LastMoth= "+dtf.format(lastMonth)+" , date="+dtf.format(date));
|
||||
this.accountingType = accountingType;
|
||||
|
||||
AccountingStateData accountingStateData = new AccountingStateData(
|
||||
|
|
|
@ -40,17 +40,24 @@ import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
|
|||
*
|
||||
*/
|
||||
public class AccountingPeriodPanel extends SimpleContainer {
|
||||
|
||||
private DateTimeFormat dtf = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
private DateTimeFormat dtfYear = DateTimeFormat
|
||||
.getFormat(PredefinedFormat.YEAR);
|
||||
private DateTimeFormat dtfYearMonthDay = DateTimeFormat
|
||||
.getFormat("yyyy-MM-dd");
|
||||
private EventBus eventBus;
|
||||
private DateField startDate;
|
||||
private DateField endDate;
|
||||
private ListStore<AccountingPeriodMode> storeCombo;
|
||||
private ComboBox<AccountingPeriodMode> comboPeriodMode;
|
||||
private AccountingPeriodPanel thisPanel;
|
||||
|
||||
public AccountingPeriodPanel(EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("AccountingPeriodPanel");
|
||||
this.eventBus = eventBus;
|
||||
thisPanel=this;
|
||||
init();
|
||||
create();
|
||||
bindToEvents();
|
||||
|
@ -103,6 +110,48 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
|
||||
.format(event.getValue());
|
||||
Log.debug("Start Date Selected " + v);
|
||||
if (comboPeriodMode.getCurrentValue() == null) {
|
||||
UtilsGXT3.alert("Attention", "Select Aggregation!");
|
||||
startDate.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comboPeriodMode.getCurrentValue()) {
|
||||
case DAILY:
|
||||
case HOURLY:
|
||||
case MINUTELY:
|
||||
break;
|
||||
case MONTHLY:
|
||||
Date monthStartDate = event.getValue();
|
||||
CalendarUtil.setToFirstDayOfMonth(monthStartDate);
|
||||
startDate.setValue(monthStartDate);
|
||||
startDate.redraw();
|
||||
break;
|
||||
case YEARLY:
|
||||
Date yearStartDate = event.getValue();
|
||||
String currentYearS = dtfYear.format(yearStartDate);
|
||||
Log.debug("YearStartSet=" + currentYearS + "-01-01");
|
||||
Date currentYearGen;
|
||||
try {
|
||||
currentYearGen = dtfYearMonthDay.parse(currentYearS
|
||||
+ "-01-01");
|
||||
} catch (Exception e) {
|
||||
Log.debug("Error: "+e.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Error creating Start Date at begin of year!");
|
||||
startDate.reset();
|
||||
return;
|
||||
}
|
||||
Log.debug("CurrentYearGen="+dtf.format(currentYearGen));
|
||||
startDate.setValue(currentYearGen);
|
||||
startDate.redraw();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
thisPanel.forceLayout();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -125,6 +174,50 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
: DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)
|
||||
.format(event.getValue());
|
||||
Log.debug("End Date Selected " + v);
|
||||
if (comboPeriodMode.getCurrentValue() == null) {
|
||||
UtilsGXT3.alert("Attention", "Select Aggregation!");
|
||||
endDate.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comboPeriodMode.getCurrentValue()) {
|
||||
case DAILY:
|
||||
case HOURLY:
|
||||
case MINUTELY:
|
||||
break;
|
||||
case MONTHLY:
|
||||
Date monthEndDate = event.getValue();
|
||||
CalendarUtil.setToFirstDayOfMonth(monthEndDate);
|
||||
CalendarUtil.addMonthsToDate(monthEndDate, 1);
|
||||
CalendarUtil.addDaysToDate(monthEndDate, -1);
|
||||
endDate.setValue(monthEndDate);
|
||||
endDate.redraw();
|
||||
break;
|
||||
case YEARLY:
|
||||
Date yearEndDate = event.getValue();
|
||||
String currentYearS = dtfYear.format(yearEndDate);
|
||||
Log.debug("YearEndSet=" + currentYearS + "-12-31");
|
||||
Date yearEndDec;
|
||||
try {
|
||||
yearEndDec = dtfYearMonthDay.parse(currentYearS
|
||||
+ "-12-31");
|
||||
} catch (Exception e) {
|
||||
Log.debug("Error: "+e.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Error creating End Date at end of year!");
|
||||
endDate.reset();
|
||||
return;
|
||||
}
|
||||
Log.debug("YearEndDec="+dtf.format(yearEndDec));
|
||||
endDate.setValue(yearEndDec);
|
||||
endDate.redraw();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
thisPanel.forceLayout();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -200,17 +293,25 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
startDate.enable();
|
||||
endDate.enable();
|
||||
Date lastYear = new Date();
|
||||
CalendarUtil.setToFirstDayOfMonth(lastYear);
|
||||
CalendarUtil.addMonthsToDate(lastYear, -12);
|
||||
startDate.setValue(lastYear);
|
||||
endDate.setValue(new Date());
|
||||
Date currentMonth = new Date();
|
||||
CalendarUtil.setToFirstDayOfMonth(currentMonth);
|
||||
CalendarUtil.addMonthsToDate(currentMonth, 1);
|
||||
CalendarUtil.addDaysToDate(currentMonth, -1);
|
||||
endDate.setValue(currentMonth);
|
||||
break;
|
||||
case YEARLY:
|
||||
startDate.enable();
|
||||
endDate.enable();
|
||||
Date last3Year = new Date();
|
||||
CalendarUtil.addMonthsToDate(last3Year, -36);
|
||||
Date currentYear = new Date();
|
||||
String currentYearS = dtfYear.format(currentYear);
|
||||
int yearLast3 = Integer.parseInt(currentYearS) - 3;
|
||||
Date last3Year = dtfYearMonthDay.parse(yearLast3 + "-01-01");
|
||||
startDate.setValue(last3Year);
|
||||
endDate.setValue(new Date());
|
||||
Date endOfYear = dtfYearMonthDay.parse(currentYearS + "-12-31");
|
||||
endDate.setValue(endOfYear);
|
||||
break;
|
||||
default:
|
||||
startDate.disable();
|
||||
|
@ -247,8 +348,8 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
.getAccountingPeriod() != null) {
|
||||
AccountingPeriod accountingPeriod = event.getAccountingStateData()
|
||||
.getSeriesRequest().getAccountingPeriod();
|
||||
startDate.setValue(accountingPeriod.getStartDate());
|
||||
endDate.setValue(accountingPeriod.getEndDate());
|
||||
startDate.setValue(dtf.parse(accountingPeriod.getStartDate()));
|
||||
endDate.setValue(dtf.parse(accountingPeriod.getEndDate()));
|
||||
|
||||
comboPeriodMode.setValue(accountingPeriod.getPeriod());
|
||||
} else {
|
||||
|
@ -266,7 +367,11 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
|
||||
if (startDate.validate() && endDate.validate()) {
|
||||
if (startDate.getCurrentValue().compareTo(new Date()) <= 0) {
|
||||
if (endDate.getCurrentValue().compareTo(new Date()) <= 0) {
|
||||
if (endDate.getCurrentValue().compareTo(new Date()) <= 0
|
||||
|| comboPeriodMode.getCurrentValue().compareTo(
|
||||
AccountingPeriodMode.MONTHLY) == 0
|
||||
|| comboPeriodMode.getCurrentValue().compareTo(
|
||||
AccountingPeriodMode.YEARLY) == 0) {
|
||||
|
||||
Date startD = startDate.getCurrentValue();
|
||||
Date endD = endDate.getCurrentValue();
|
||||
|
@ -302,6 +407,8 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
break;
|
||||
case MONTHLY:
|
||||
Date maximumDistantMonth = new Date();
|
||||
CalendarUtil
|
||||
.setToFirstDayOfMonth(maximumDistantMonth);
|
||||
CalendarUtil.addMonthsToDate(
|
||||
maximumDistantMonth, -60);
|
||||
CalendarUtil.addDaysToDate(
|
||||
|
@ -313,7 +420,16 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (maximumDistantMonth.compareTo(endD) >= 0) {
|
||||
Date maximumDistantMonthFuture = new Date();
|
||||
CalendarUtil
|
||||
.setToFirstDayOfMonth(maximumDistantMonthFuture);
|
||||
CalendarUtil.addMonthsToDate(
|
||||
maximumDistantMonthFuture, 1);
|
||||
Log.debug("[EndDate=" + endD
|
||||
+ ", maximumDistant="
|
||||
+ maximumDistantMonthFuture + "");
|
||||
if (maximumDistantMonthFuture
|
||||
.compareTo(endD) < 0) {
|
||||
UtilsGXT3
|
||||
.alert("Attention",
|
||||
"Invalid End Date (Monthly: the max interval should in the last 5 years)!");
|
||||
|
@ -328,7 +444,7 @@ public class AccountingPeriodPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
AccountingPeriod accountingPeriod = new AccountingPeriod(
|
||||
startD, endD,
|
||||
dtf.format(startD), dtf.format(endD),
|
||||
comboPeriodMode.getCurrentValue());
|
||||
return accountingPeriod;
|
||||
} else {
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*
|
||||
*/
|
||||
public class ServiceChart extends SimpleContainer {
|
||||
private DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
private static final String SINGLE_AXIS = "Single Axis";
|
||||
private AccountingStateData accountingStateData;
|
||||
|
@ -249,8 +250,9 @@ public class ServiceChart extends SimpleContainer {
|
|||
.calculateInterval(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
Date dateStart = new Date(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate().getTime());
|
||||
Date dateStart=dtf.parse(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate());
|
||||
|
||||
dateStart.setTime(dateStart.getTime()
|
||||
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
||||
|
||||
|
@ -455,8 +457,9 @@ public class ServiceChart extends SimpleContainer {
|
|||
.calculateInterval(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
Date dateStart = new Date(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate().getTime());
|
||||
Date dateStart=dtf.parse(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate());
|
||||
|
||||
dateStart.setTime(dateStart.getTime()
|
||||
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*/
|
||||
public class StorageChart extends SimpleContainer {
|
||||
|
||||
private DateTimeFormat dtf=DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
|
||||
private AccountingStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
@ -222,8 +223,9 @@ public class StorageChart extends SimpleContainer {
|
|||
.calculateInterval(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
Date dateStart = new Date(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate().getTime());
|
||||
Date dateStart=dtf.parse(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate());
|
||||
|
||||
dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset()*ChartTimeMeasure.MINUTE);
|
||||
|
||||
Log.debug("BuildChart DateStart: "
|
||||
|
|
|
@ -8,7 +8,6 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,9 +29,9 @@ public class SessionUtil {
|
|||
ASLSession session;
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, use test user");
|
||||
/*throw new AccountingManagerSessionExpiredException("Session Expired!");*/
|
||||
|
||||
throw new AccountingManagerSessionExpiredException("Session Expired!");
|
||||
|
||||
/*
|
||||
// Remove comment for Test
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
@ -41,7 +40,7 @@ public class SessionUtil {
|
|||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
|
||||
*/
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.accounting.analytics.Info;
|
||||
import org.gcube.accounting.analytics.ResourceRecordQuery;
|
||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Job;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Portlet;
|
||||
|
@ -223,25 +219,20 @@ public class AccountingCaller {
|
|||
"Error accounting type is null");
|
||||
}
|
||||
|
||||
Calendar startTempCalendar = new GregorianCalendar();
|
||||
startTempCalendar.setTime(seriesRequest.getAccountingPeriod()
|
||||
.getStartDate());
|
||||
/*
|
||||
SimpleDateFormat stz = new SimpleDateFormat("Z");
|
||||
String timeZone=stz.format(seriesRequest.getAccountingPeriod().getStartDate());
|
||||
int tzOffSet=TimeZone.getTimeZone(timeZone).getRawOffset()-TemporalConstraint.DEFAULT_TIME_ZONE.getRawOffset();
|
||||
logger.debug("TimeZone[zone="+timeZone+", offset="+tzOffSet+"]");
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
long startTime=seriesRequest.getAccountingPeriod()
|
||||
.getStartDate().getTime()+tzOffSet;
|
||||
startCalendar.setTimeInMillis(startTime);
|
||||
|
||||
Calendar startCalendar = new GregorianCalendar(
|
||||
startTempCalendar.get(GregorianCalendar.YEAR),
|
||||
startTempCalendar.get(GregorianCalendar.MONTH),
|
||||
startTempCalendar.get(GregorianCalendar.DATE));
|
||||
startCalendar.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
||||
Calendar endTempCalendar = new GregorianCalendar();
|
||||
endTempCalendar.setTime(seriesRequest.getAccountingPeriod()
|
||||
.getEndDate());
|
||||
|
||||
Calendar endCalendar = new GregorianCalendar(
|
||||
endTempCalendar.get(GregorianCalendar.YEAR),
|
||||
endTempCalendar.get(GregorianCalendar.MONTH),
|
||||
endTempCalendar.get(GregorianCalendar.DATE));
|
||||
endCalendar.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
long endTime=seriesRequest.getAccountingPeriod()
|
||||
.getEndDate().getTime()+tzOffSet;
|
||||
endCalendar.setTimeInMillis(endTime);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
sdf.setTimeZone(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
@ -251,6 +242,10 @@ public class AccountingCaller {
|
|||
seriesRequest.getAccountingPeriod().setStartDate(
|
||||
startCalendar.getTime());
|
||||
seriesRequest.getAccountingPeriod().setEndDate(endCalendar.getTime());
|
||||
*/
|
||||
|
||||
logger.debug("StartCalendar: " + seriesRequest.getAccountingPeriod().getStartDate());
|
||||
logger.debug("EndCalendar: " + seriesRequest.getAccountingPeriod().getEndDate());
|
||||
|
||||
switch (accountingType) {
|
||||
case JOB:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
|
||||
|
@ -27,9 +31,31 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
|
|||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
endCalendar.set(GregorianCalendar.MINUTE, 59);
|
||||
endCalendar.set(GregorianCalendar.SECOND, 59);
|
||||
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
|
||||
|
||||
|
||||
TemporalConstraint temporalConstraint = new TemporalConstraint(
|
||||
seriesRequest.getAccountingPeriod().getStartDate().getTime(),
|
||||
seriesRequest.getAccountingPeriod().getEndDate().getTime(),
|
||||
startCalendar.getTimeInMillis(),
|
||||
endCalendar.getTimeInMillis(),
|
||||
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()));
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedPortletUsageRecord;
|
||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
|
||||
|
@ -26,10 +30,31 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
|
|||
|
||||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
endCalendar.set(GregorianCalendar.MINUTE, 59);
|
||||
endCalendar.set(GregorianCalendar.SECOND, 59);
|
||||
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
|
||||
|
||||
|
||||
TemporalConstraint temporalConstraint = new TemporalConstraint(
|
||||
seriesRequest.getAccountingPeriod().getStartDate().getTime(),
|
||||
seriesRequest.getAccountingPeriod().getEndDate().getTime(),
|
||||
startCalendar.getTimeInMillis(),
|
||||
endCalendar.getTimeInMillis(),
|
||||
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()));
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.analytics.Filter;
|
||||
|
@ -31,9 +34,30 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
|
|||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
endCalendar.set(GregorianCalendar.MINUTE, 59);
|
||||
endCalendar.set(GregorianCalendar.SECOND, 59);
|
||||
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
|
||||
|
||||
TemporalConstraint temporalConstraint = new TemporalConstraint(
|
||||
seriesRequest.getAccountingPeriod().getStartDate().getTime(),
|
||||
seriesRequest.getAccountingPeriod().getEndDate().getTime(),
|
||||
startCalendar.getTimeInMillis(),
|
||||
endCalendar.getTimeInMillis(),
|
||||
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()));
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.accounting.analytics.Filter;
|
||||
|
@ -31,9 +34,30 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
|
|||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
endCalendar.set(GregorianCalendar.MINUTE, 59);
|
||||
endCalendar.set(GregorianCalendar.SECOND, 59);
|
||||
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
|
||||
|
||||
TemporalConstraint temporalConstraint = new TemporalConstraint(
|
||||
seriesRequest.getAccountingPeriod().getStartDate().getTime(),
|
||||
seriesRequest.getAccountingPeriod().getEndDate().getTime(),
|
||||
startCalendar.getTimeInMillis(),
|
||||
endCalendar.getTimeInMillis(),
|
||||
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()));
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.gcube.accounting.aggregation.AggregatedTaskUsageRecord;
|
||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
|
||||
|
@ -27,9 +31,30 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
|
|||
@Override
|
||||
public void buildOpEx() throws AccountingManagerServiceException {
|
||||
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
endCalendar.set(GregorianCalendar.HOUR_OF_DAY, 23);
|
||||
endCalendar.set(GregorianCalendar.MINUTE, 59);
|
||||
endCalendar.set(GregorianCalendar.SECOND, 59);
|
||||
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
|
||||
|
||||
TemporalConstraint temporalConstraint = new TemporalConstraint(
|
||||
seriesRequest.getAccountingPeriod().getStartDate().getTime(),
|
||||
seriesRequest.getAccountingPeriod().getEndDate().getTime(),
|
||||
startCalendar.getTimeInMillis(),
|
||||
endCalendar.getTimeInMillis(),
|
||||
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()));
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +13,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingMan
|
|||
*/
|
||||
public abstract class AccountingQueryBuilder {
|
||||
protected AccountingQuerySpec accountingQuerySpec;
|
||||
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd");
|
||||
|
||||
public AccountingQuerySpec getAccountingQuerySpec(){
|
||||
return accountingQuerySpec;
|
||||
|
|
|
@ -12,9 +12,11 @@ public class Constants {
|
|||
public static final String ACCOUNTING_MANAGER_ID = "AccountingManagerId";
|
||||
public static final String AM_LANG_COOKIE = "AMLangCookie";
|
||||
public static final String AM_LANG = "AMLang";
|
||||
public final static String DEFAULT_USER = "test.user";
|
||||
public final static String DEFAULT_USER = "giancarlo.panichi";
|
||||
//public final static String DEFAULT_USER = "test.user";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||
public final static String DEFAULT_SCOPE = "/gcube";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -13,15 +12,15 @@ public class AccountingPeriod implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 4241461469179338817L;
|
||||
|
||||
private Date startDate;
|
||||
private Date endDate;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private AccountingPeriodMode period;
|
||||
|
||||
public AccountingPeriod(){
|
||||
super();
|
||||
}
|
||||
|
||||
public AccountingPeriod(Date startDate, Date endDate,
|
||||
public AccountingPeriod(String startDate, String endDate,
|
||||
AccountingPeriodMode period) {
|
||||
super();
|
||||
this.startDate = startDate;
|
||||
|
@ -29,19 +28,19 @@ public class AccountingPeriod implements Serializable {
|
|||
this.period = period;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
|
@ -62,4 +61,6 @@ public class AccountingPeriod implements Serializable {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue