Updated Accounting Manager

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117365 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-07-20 16:44:45 +00:00
parent 012eb588cb
commit d1fcba4a42
5 changed files with 102 additions and 67 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="accounting-manager-theme-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/accounting-manager-theme/accounting-manager-theme">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/tabular-data-manager/target/tabular-data-manager-2.6.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/tabular-data-manager/target/tabular-data-manager-2.6.0-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="accounting-manager"/> <property name="context-root" value="accounting-manager"/>
</wb-module> </wb-module>

View File

@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gdt.eclipse.suite.webapp"> <launchConfiguration type="com.google.gdt.eclipse.suite.webapp">
<stringAttribute key="com.google.gwt.eclipse.core.URL" value="accountingman.html"/> <stringAttribute key="com.google.gdt.eclipse.suiteMainTypeProcessor.PREVIOUSLY_SET_MAIN_TYPE_NAME" value="com.google.gwt.dev.GWTShell"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <stringAttribute key="com.google.gwt.eclipse.core.URL" value="accountingman.html"/>
<listEntry value="/accounting-manager"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
</listAttribute> <listEntry value="/accounting-manager"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> </listAttribute>
<listEntry value="4"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
</listAttribute> <listEntry value="4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/> </listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="accounting-manager"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dgwt.nowarn.legacy.tools"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -logLevel INFO -codeServerPort 9997 -port 8888 accountingman.html"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="accounting-manager"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m -Dgwt.nowarn.legacy.tools"/>
</launchConfiguration> </launchConfiguration>

40
pom.xml
View File

@ -95,6 +95,8 @@
<version>${gwtVersion}</version> <version>${gwtVersion}</version>
</dependency> </dependency>
<!-- <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId> <!-- <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version> </dependency> --> <version>${gwtVersion}</version> </dependency> -->
@ -105,14 +107,27 @@
<version>${gxtVersion}</version> <version>${gxtVersion}</version>
</dependency> </dependency>
<!-- Accounting Manager Theme -->
<dependency>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager-theme</artifactId>
<version>[0.0.1-SNAPSHOT,
2.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency> <groupId>com.sencha.gxt</groupId> <artifactId>gxt-theme-neptune</artifactId>
<version>${gxtVersion}</version> <scope>system</scope> <systemPath>${basedir}/lib/gxt-theme-neptune-3.1.1.jar</systemPath> <!-- GXT-Theme-Neptune
</dependency> --> <dependency>
<groupId>com.sencha.gxt</groupId>
<!-- <dependency> <groupId>com.sencha.gxt</groupId> <artifactId>gxt-theme-neptune</artifactId> <artifactId>gxt-theme-neptune</artifactId>
<version>${gxtVersion}</version> </dependency> --> <version>${gxtVersion}</version>
</dependency> -->
<dependency> <dependency>
<groupId>com.sencha.gxt</groupId> <groupId>com.sencha.gxt</groupId>
@ -126,8 +141,6 @@
<version>0.0.7</version> <version>0.0.7</version>
</dependency> </dependency>
<!-- <dependency> <groupId>org.gcube.portlets.admin</groupId> <artifactId>accounting-manager-highcharts</artifactId>
<version>0.0.1-SNAPSHOT</version> </dependency> -->
<!-- Portlet --> <!-- Portlet -->
<dependency> <dependency>
@ -195,15 +208,8 @@
<version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version> <version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<!-- Accounting Manager Theme <dependency> <groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager-theme</artifactId> <version>[0.0.1-SNAPSHOT,
2.0.0-SNAPSHOT)</version> </dependency> -->
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt-theme-neptune</artifactId>
<version>3.1.1</version>
</dependency>
<!-- Accounting Analytics --> <!-- Accounting Analytics -->

View File

@ -88,9 +88,7 @@ public class AccountingPeriodPanel extends SimpleContainer {
FieldLabel startDateLabel = new FieldLabel(startDate, "Start Date"); FieldLabel startDateLabel = new FieldLabel(startDate, "Start Date");
endDate = new DateField(); endDate = new DateField();
endDate.addValidator(new MaxDateValidator(new Date()));
endDate.addValidator(new EmptyValidator<Date>()); endDate.addValidator(new EmptyValidator<Date>());
endDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() { endDate.addParseErrorHandler(new ParseErrorEvent.ParseErrorHandler() {
@Override @Override
public void onParseError(ParseErrorEvent event) { public void onParseError(ParseErrorEvent event) {
@ -125,7 +123,7 @@ public class AccountingPeriodPanel extends SimpleContainer {
comboPeriodMode.setTriggerAction(TriggerAction.ALL); comboPeriodMode.setTriggerAction(TriggerAction.ALL);
comboPeriodMode.setValue(AccountingPeriodMode.DAILY); comboPeriodMode.setValue(AccountingPeriodMode.DAILY);
addHandlersForComboPeriodMode(props.label()); addHandlersForComboPeriodMode(props.label());
Log.debug("ComboPeriodMode created"); Log.debug("ComboPeriodMode created");
FieldLabel periodModeLabel = new FieldLabel(comboPeriodMode, FieldLabel periodModeLabel = new FieldLabel(comboPeriodMode,
@ -158,23 +156,26 @@ public class AccountingPeriodPanel extends SimpleContainer {
} }
}); });
} }
private void addHandlersForComboPeriodMode( private void addHandlersForComboPeriodMode(
final LabelProvider<AccountingPeriodMode> labelProvider) { final LabelProvider<AccountingPeriodMode> labelProvider) {
comboPeriodMode.addSelectionHandler(new SelectionHandler<AccountingPeriodMode>() { comboPeriodMode
public void onSelection(SelectionEvent<AccountingPeriodMode> event) { .addSelectionHandler(new SelectionHandler<AccountingPeriodMode>() {
Info.display( public void onSelection(
"Aggregation", SelectionEvent<AccountingPeriodMode> event) {
"You selected " Info.display(
+ (event.getSelectedItem() == null ? "nothing" "Aggregation",
: labelProvider.getLabel(event "You selected "
.getSelectedItem()) + "!")); + (event.getSelectedItem() == null ? "nothing"
Log.debug("ComboPeriodMode selected: " + event.getSelectedItem()); : labelProvider.getLabel(event
.getSelectedItem())
} + "!"));
Log.debug("ComboPeriodMode selected: "
+ event.getSelectedItem());
}); }
});
} }
private void doStateChangeCommand(StateChangeEvent event) { private void doStateChangeCommand(StateChangeEvent event) {
@ -195,12 +196,15 @@ public class AccountingPeriodPanel extends SimpleContainer {
} }
private void onRestoreStateChange(StateChangeEvent event) { private void onRestoreStateChange(StateChangeEvent event) {
if (event.getAccountingStateData()!=null&&event.getAccountingStateData().getSeriesRequest() != null if (event.getAccountingStateData() != null
&& event.getAccountingStateData().getSeriesRequest().getAccountingPeriod() != null) { && event.getAccountingStateData().getSeriesRequest() != null
AccountingPeriod accountingPeriod = event.getAccountingStateData().getSeriesRequest() && event.getAccountingStateData().getSeriesRequest()
.getAccountingPeriod(); .getAccountingPeriod() != null) {
AccountingPeriod accountingPeriod = event.getAccountingStateData()
.getSeriesRequest().getAccountingPeriod();
startDate.setValue(accountingPeriod.getStartDate()); startDate.setValue(accountingPeriod.getStartDate());
endDate.setValue(accountingPeriod.getEndDate()); endDate.setValue(accountingPeriod.getEndDate());
comboPeriodMode.setValue(accountingPeriod.getPeriod()); comboPeriodMode.setValue(accountingPeriod.getPeriod());
} else { } else {
startDate.reset(); startDate.reset();
@ -213,31 +217,51 @@ public class AccountingPeriodPanel extends SimpleContainer {
} }
public AccountingPeriod getAccountingPeriod() { public AccountingPeriod getAccountingPeriod() {
try {
if (startDate.validate() && endDate.validate()) { if (startDate.validate() && endDate.validate()) {
Date startD = startDate.getCurrentValue(); if (endDate.getCurrentValue().compareTo(new Date()) <= 0) {
Date endD = endDate.getCurrentValue();
if (startD.compareTo(endD) <= 0) { Date startD = startDate.getCurrentValue();
if (comboPeriodMode.validate() Date endD = endDate.getCurrentValue();
&& comboPeriodMode.getCurrentValue() != null) { if (startD.compareTo(endD) <= 0) {
AccountingPeriod accountingPeriod = new AccountingPeriod( if (comboPeriodMode.validate()
startD, endD, comboPeriodMode.getCurrentValue()); && comboPeriodMode.getCurrentValue() != null) {
return accountingPeriod; AccountingPeriod accountingPeriod = new AccountingPeriod(
startD, endD, comboPeriodMode.getCurrentValue());
return accountingPeriod;
} else {
UtilsGXT3.alert("Attention",
"Select a valid aggregation mode!");
return null;
}
} else { } else {
UtilsGXT3.alert("Attention", UtilsGXT3
"Select a valid aggregation mode!"); .alert("Attention",
"The start date must be less than or equal to the end date!");
return null; return null;
} }
} else { } else {
String endD=DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date());
UtilsGXT3 UtilsGXT3
.alert("Attention", .alert("Attention",
"The start date must be less than or equal to the end date!"); "The end date must be "+endD+" or earlier!");
return null; return null;
} }
} else { } else {
return null; return null;
} }
} catch(Throwable e){
Log.error(e.getLocalizedMessage());
e.printStackTrace();
UtilsGXT3
.alert("Attention",
e.getLocalizedMessage());
return null;
}
} }
} }

View File

@ -3,8 +3,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice;
import java.util.List; import java.util.List;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.ResourceRecordQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery; 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.AccountingQuery4Job;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Portlet; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Portlet;
@ -45,9 +44,9 @@ public class AccountingCaller {
SeriesRequest seriesRequest) SeriesRequest seriesRequest)
throws AccountingManagerServiceException { throws AccountingManagerServiceException {
try { try {
logger.debug("getSeries(): [AccountingType="+accountingType+" , seriesRequest=" + seriesRequest+"]"); logger.debug("getSeries(): [AccountingType=" + accountingType
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory + " , seriesRequest=" + seriesRequest + "]");
.getInstance(); ResourceRecordQuery rrq = new ResourceRecordQuery();
AccountingQueryBuilder queryBuilder = getAccountQueryBuilder( AccountingQueryBuilder queryBuilder = getAccountQueryBuilder(
accountingType, seriesRequest); accountingType, seriesRequest);
@ -62,14 +61,14 @@ public class AccountingCaller {
"Error in invocation: Operation not supported"); "Error in invocation: Operation not supported");
} }
List<Info> infos = apq.query(query.getType(), List<Info> infos = rrq.getInfo(query.getType(),
query.getTemporalConstraint(), null); query.getTemporalConstraint(), null);
if (infos == null) { if (infos == null) {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error retrieving list of info: list is null!"); "Error retrieving list of info: list is null!");
} }
logger.debug("Retrieved Infos"); logger.debug("Retrieved Infos");
SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder( SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
accountingType, infos); accountingType, infos);