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:
Giancarlo Panichi 2015-10-14 17:01:35 +00:00
parent 69ebfaed81
commit 8bb95fa2f5
15 changed files with 327 additions and 80 deletions

View File

@ -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(

View File

@ -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 {

View File

@ -46,7 +46,8 @@ 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;
private HighchartsLayoutPanel highchartsLayoutPanel;
@ -248,9 +249,10 @@ public class ServiceChart extends SimpleContainer {
double interval = ChartTimeMeasure
.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);
@ -454,9 +456,10 @@ public class ServiceChart extends SimpleContainer {
double interval = ChartTimeMeasure
.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);

View File

@ -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;
@ -221,9 +222,10 @@ public class StorageChart extends SimpleContainer {
double interval = ChartTimeMeasure
.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: "

View File

@ -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);

View File

@ -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;
@ -222,27 +218,22 @@ public class AccountingCaller {
throw new AccountingManagerServiceException(
"Error accounting type is null");
}
Calendar startTempCalendar = new GregorianCalendar();
startTempCalendar.setTime(seriesRequest.getAccountingPeriod()
.getStartDate());
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);
/*
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 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);
logger.debug("StartCalendar: " + sdf.format(startCalendar.getTime()));
@ -251,7 +242,11 @@ 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:
return new AccountingQuery4Job(seriesRequest);

View File

@ -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;
@ -26,10 +30,32 @@ 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()));

View File

@ -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()));

View File

@ -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;
@ -30,10 +33,31 @@ 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()));

View File

@ -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;
@ -30,10 +33,31 @@ 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()));

View File

@ -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;
@ -26,10 +30,31 @@ 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()));

View File

@ -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;

View File

@ -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";
}

View File

@ -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 {
}

View File

@ -48,7 +48,7 @@
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
/> <set-property-fallback name="locale" value="en" /> -->
<!--
<!--
<set-property name="log_ConsoleLogger" value="ENABLED" />
<set-property name="log_DivLogger" value="ENABLED" />
<set-property name="log_GWTLogger" value="ENABLED" />
@ -56,11 +56,11 @@
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
/> -->