=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java' --- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java 2012-02-12 13:16:57 +0000 @@ -31,7 +31,6 @@ import java.util.HashSet; import java.util.Set; -import org.hisp.dhis.common.ProcessState; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; /** @@ -57,5 +56,5 @@ */ void export( Collection dataElementIds, Collection indicatorIds, Collection periodIds, Collection organisationUnitIds, Collection organisationUnitGroupIds, - boolean completeExport, ProcessState processState ); + boolean completeExport ); } === modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java' --- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2012-02-02 20:01:36 +0000 +++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2012-02-12 17:11:20 +0000 @@ -37,7 +37,6 @@ import org.hisp.dhis.aggregation.AggregatedDataValueService; import org.hisp.dhis.aggregation.AggregatedOrgUnitDataValueService; -import org.hisp.dhis.common.ProcessState; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementOperand; @@ -64,6 +63,7 @@ import org.hisp.dhis.system.filter.AggregatableDataElementFilter; import org.hisp.dhis.system.filter.OrganisationUnitAboveOrEqualToLevelFilter; import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; +import org.hisp.dhis.system.notification.Notifier; import org.hisp.dhis.system.util.Clock; import org.hisp.dhis.system.util.ConcurrentUtils; import org.hisp.dhis.system.util.ConversionUtils; @@ -73,6 +73,7 @@ import org.springframework.transaction.annotation.Transactional; import static org.hisp.dhis.setting.SystemSettingManager.*; +import static org.hisp.dhis.system.notification.NotificationCategory.DATAMART; /** * @author Lars Helge Overland @@ -174,6 +175,13 @@ { this.systemSettingManager = systemSettingManager; } + + private Notifier notifier; + + public void setNotifier( Notifier notifier ) + { + this.notifier = notifier; + } // ------------------------------------------------------------------------- // DataMartEngine implementation @@ -182,11 +190,12 @@ @Transactional public void export( Collection dataElementIds, Collection indicatorIds, Collection periodIds, Collection organisationUnitIds, Collection organisationUnitGroupIds, - boolean completeExport, ProcessState state ) + boolean completeExport ) { final int cpuCores = SystemUtils.getCpuCores(); Clock clock = new Clock().startClock().logTime( "Data mart export process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Process started" ); // --------------------------------------------------------------------- // Replace null with empty collection @@ -208,7 +217,8 @@ final Collection organisationUnitGroups = organisationUnitGroupService.getOrganisationUnitGroups( organisationUnitGroupIds ); final Collection dataElements = dataElementService.getDataElements( dataElementIds ); - clock.logTime( "Retrieved objects" ); + clock.logTime( "Retrieved meta-data objects" ); + notifier.notify( DATAMART, "Filtering meta-data" ); // --------------------------------------------------------------------- // Filter objects @@ -220,6 +230,7 @@ expressionService.filterInvalidIndicators( indicators ); clock.logTime( "Filtered objects" ); + notifier.notify( DATAMART, "Loading indicator formulas" ); // --------------------------------------------------------------------- // Explode indicator expressions @@ -232,6 +243,7 @@ } clock.logTime( "Exploded indicator expressions" ); + notifier.notify( DATAMART, "Loading data elements" ); // --------------------------------------------------------------------- // Get operands @@ -245,6 +257,7 @@ allOperands.addAll( indicatorOperands ); clock.logTime( "Retrieved operands: " + allOperands.size() ); + notifier.notify( DATAMART, "Loading periods" ); // --------------------------------------------------------------------- // Filter out future periods @@ -253,6 +266,7 @@ FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); clock.logTime( "Number of periods: " + periods.size() ); + notifier.notify( DATAMART, "Filtering data elements without data" ); // --------------------------------------------------------------------- // Remove operands without data @@ -263,13 +277,12 @@ indicatorOperands.retainAll( allOperands ); clock.logTime( "Number of operands with data: " + allOperands.size() + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Populating crosstabulation table" ); // --------------------------------------------------------------------- // Create crosstabtable // --------------------------------------------------------------------- - state.setMessage( "crosstabulating_data" ); - final Collection intersectingPeriodIds = ConversionUtils.getIdentifiers( Period.class, periodService.getIntersectionPeriods( periods ) ); final Set childrenIds = organisationUnitService.getOrganisationUnitHierarchy().getChildren( organisationUnitIds ); final List> childrenPages = new PaginatedList( childrenIds ).setNumberOfPages( cpuCores ).getPages(); @@ -288,15 +301,16 @@ clock.logTime( "Populated crosstab table, " + SystemUtils.getMemoryString() ); + // --------------------------------------------------------------------- + // 1. Create aggregated data cache + // --------------------------------------------------------------------- + final boolean isIndicators = indicators != null && indicators.size() > 0; - // --------------------------------------------------------------------- - // 1. Create aggregated data cache - // --------------------------------------------------------------------- - crossTabService.createAggregatedDataCache( indicatorOperands, key ); clock.logTime( "Created aggregated data cache, number of indicator operands: " + indicatorOperands.size() + ", operands with data: " + allOperands.size() ); + notifier.notify( DATAMART, "Dropping database indexes" ); // --------------------------------------------------------------------- // 2. Drop potential indexes @@ -305,6 +319,7 @@ aggregatedDataValueService.dropIndex( true, isIndicators ); clock.logTime( "Dropped potential indexes" ); + notifier.notify( DATAMART, "Deleting existing data element data" ); // --------------------------------------------------------------------- // 3. Delete existing aggregated datavalues @@ -320,13 +335,12 @@ } clock.logTime( "Deleted existing aggregated datavalues" ); + notifier.notify( DATAMART, "Exporting data for data elements" ); // --------------------------------------------------------------------- // 4. Export data element values // --------------------------------------------------------------------- - state.setMessage( "exporting_data_for_data_elements" ); - List> organisationUnitPages = new PaginatedList( organisationUnits ).setNumberOfPages( cpuCores ).getPages(); if ( allOperands.size() > 0 ) @@ -342,10 +356,11 @@ } ConcurrentUtils.waitForCompletion( futures ); - - clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); } - + + clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Deleting existing indicator data" ); + // --------------------------------------------------------------------- // 5. Delete existing aggregated indicatorvalues // --------------------------------------------------------------------- @@ -360,13 +375,12 @@ } clock.logTime( "Deleted existing aggregated indicatorvalues" ); + notifier.notify( DATAMART, "Exporting data for indicators" ); // --------------------------------------------------------------------- // 6. Export indicator values // --------------------------------------------------------------------- - state.setMessage( "exporting_data_for_indicators" ); - if ( isIndicators ) { List> futures = new ArrayList>(); @@ -378,9 +392,10 @@ } ConcurrentUtils.waitForCompletion( futures ); - - clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); } + + clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Creating database indexes" ); // --------------------------------------------------------------------- // 7. Drop aggregated data cache @@ -416,6 +431,7 @@ crossTabService.createAggregatedOrgUnitDataCache( indicatorOperands, key ); clock.logTime( "Created aggregated org unit data cache" ); + notifier.notify( DATAMART, "Dropping database indexes" ); // ----------------------------------------------------------------- // 2. Drop potential indexes @@ -424,6 +440,7 @@ aggregatedOrgUnitDataValueService.dropIndex( true, isIndicators ); clock.logTime( "Dropped potential org unit indexes" ); + notifier.notify( DATAMART, "Deleting existing data element data" ); // --------------------------------------------------------------------- // 3. Delete existing aggregated datavalues @@ -439,13 +456,12 @@ } clock.logTime( "Deleted existing aggregated org unit datavalues" ); + notifier.notify( DATAMART, "Exporting data for data elements" ); // --------------------------------------------------------------------- // 4. Export data element values // --------------------------------------------------------------------- - state.setMessage( "exporting_data_for_data_elements" ); - Collection groupOrganisationUnits = new HashSet( organisationUnits ); FilterUtils.filter( groupOrganisationUnits, new OrganisationUnitAboveOrEqualToLevelFilter( groupLevel ) ); @@ -465,10 +481,11 @@ } ConcurrentUtils.waitForCompletion( futures ); - - clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); } - + + clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Deleting existing indicator data" ); + // --------------------------------------------------------------------- // 5. Delete existing aggregated indicatorvalues // --------------------------------------------------------------------- @@ -483,13 +500,12 @@ } clock.logTime( "Deleted existing aggregated org unit indicatorvalues" ); + notifier.notify( DATAMART, "Exporting data for indicators" ); // --------------------------------------------------------------------- // 6. Export indicator values // --------------------------------------------------------------------- - state.setMessage( "exporting_data_for_indicators" ); - if ( isIndicators ) { List> futures = new ArrayList>(); @@ -501,9 +517,10 @@ } ConcurrentUtils.waitForCompletion( futures ); - - clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); } + + clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() ); + notifier.notify( DATAMART, "Creating database indexes" ); // --------------------------------------------------------------------- // 7. Drop aggregated data cache @@ -534,7 +551,7 @@ crossTabService.dropCrossTabTable( key ); clock.logTime( "Dropped crosstab table" ); - clock.logTime( "Data mart export process completed" ); + notifier.notify( DATAMART, "Data mart process completed" ); } } === modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java' --- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java 2012-02-12 13:16:57 +0000 @@ -42,7 +42,6 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.RelativePeriods; -import org.hisp.dhis.system.process.OutputHolderState; import org.springframework.transaction.annotation.Transactional; /** @@ -97,14 +96,14 @@ getIdentifiers( Indicator.class, dataMartExport.getIndicators() ), getIdentifiers( Period.class, allPeriods ), getIdentifiers( OrganisationUnit.class, dataMartExport.getOrganisationUnits() ), - null, false, new OutputHolderState() ); + null, false ); } public void export( Collection dataElementIds, Collection indicatorIds, Collection periodIds, Collection organisationUnitIds ) { - dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, null, false, new OutputHolderState() ); + dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, null, false ); } public void export( Collection dataElementIds, Collection indicatorIds, @@ -122,7 +121,7 @@ periodIds.addAll( getIdentifiers( Period.class, periodService.reloadPeriods( relatives.getRelativePeriods() ) ) ); } - dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, organisationUnitGroupIds, completeExport, new OutputHolderState() ); + dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, organisationUnitGroupIds, completeExport ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2012-02-02 20:01:36 +0000 +++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2012-02-12 13:16:57 +0000 @@ -36,6 +36,7 @@ + === added directory 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification' === added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-02-12 17:11:20 +0000 @@ -0,0 +1,73 @@ +package org.hisp.dhis.system.notification; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.annotation.PostConstruct; + +public class InMemoryNotifier + implements Notifier +{ + private int MAX_SIZE = 1000; + + private List notifications; + + @PostConstruct + public void init() + { + notifications = new ArrayList(); + } + + // ------------------------------------------------------------------------- + // Notifier implementation + // ------------------------------------------------------------------------- + + @Override + public void notify( NotificationCategory category, String message ) + { + notify( NotificationLevel.INFO, category, message ); + } + + @Override + public void notify( NotificationLevel level, NotificationCategory category, String message ) + { + Notification notification = new Notification( level, category, new Date(), message ); + + notifications.add( 0, notification ); + + if ( notifications.size() > MAX_SIZE ) + { + notifications.remove( MAX_SIZE ); + } + } + + @Override + public List getNotifications( int max ) + { + max = max > notifications.size() ? notifications.size() : max; + + return notifications.subList( 0, max ); + } + + @Override + public List getNotifications( NotificationCategory category, int max ) + { + List list = new ArrayList(); + + for ( Notification notification : notifications ) + { + if ( list.size() == max ) + { + break; + } + + if ( category.equals( notification.getCategory() ) ) + { + list.add( notification ); + } + } + + return list; + } +} === added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java 2012-02-12 13:16:57 +0000 @@ -0,0 +1,129 @@ +package org.hisp.dhis.system.notification; + +import java.util.Date; + +import org.hisp.dhis.common.CodeGenerator; + +public class Notification +{ + private String uid; + + private NotificationLevel level; + + private NotificationCategory category; + + private Date time; + + private String message; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public Notification() + { + this.uid = CodeGenerator.generateCode(); + } + + public Notification( NotificationLevel level, NotificationCategory category, Date time, String message ) + { + this.uid = CodeGenerator.generateCode(); + this.level = level; + this.category = category; + this.time = time; + this.message = message; + } + + // ------------------------------------------------------------------------- + // Get and set + // ------------------------------------------------------------------------- + + public NotificationLevel getLevel() + { + return level; + } + + public String getUid() + { + return uid; + } + + public void setUid( String uid ) + { + this.uid = uid; + } + + public void setLevel( NotificationLevel level ) + { + this.level = level; + } + + public NotificationCategory getCategory() + { + return category; + } + + public void setCategory( NotificationCategory category ) + { + this.category = category; + } + + public Date getTime() + { + return time; + } + + public void setTime( Date time ) + { + this.time = time; + } + + public String getMessage() + { + return message; + } + + public void setMessage( String message ) + { + this.message = message; + } + + // ------------------------------------------------------------------------- + // equals, hashCode, toString + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + return uid.hashCode(); + } + + @Override + public boolean equals( Object object ) + { + if ( this == object ) + { + return true; + } + + if ( object == null ) + { + return false; + } + + if ( getClass() != object.getClass() ) + { + return false; + } + + final Notification other = (Notification) object; + + return uid.equals( other.uid ); + } + + @Override + public String toString() + { + return "[Level: " + level + ", category: " + category + ", time: " + time + ", message: " + message + "]"; + } +} === added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationCategory.java 2012-02-12 13:16:57 +0000 @@ -0,0 +1,7 @@ +package org.hisp.dhis.system.notification; + +public enum NotificationCategory +{ + DATAMART, + IMPORT +} === added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationLevel.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationLevel.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/NotificationLevel.java 2012-02-12 13:16:57 +0000 @@ -0,0 +1,8 @@ +package org.hisp.dhis.system.notification; + +public enum NotificationLevel +{ + INFO, + WARN, + ERROR +} === added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-02-12 13:38:06 +0000 @@ -0,0 +1,14 @@ +package org.hisp.dhis.system.notification; + +import java.util.List; + +public interface Notifier +{ + void notify( NotificationCategory category, String message ); + + void notify( NotificationLevel level, NotificationCategory category, String message ); + + List getNotifications( int max ); + + List getNotifications( NotificationCategory category, int max ); +} === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java 2012-02-11 13:10:26 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java 2012-02-12 13:38:06 +0000 @@ -86,6 +86,17 @@ private SystemSettingManager systemSettingManager; + // ------------------------------------------------------------------------- + // Params + // ------------------------------------------------------------------------- + + private List periods; + + public void setPeriods( List periods ) + { + this.periods = periods; + } + private boolean last6Months; public void setLast6Months( boolean last6Months ) @@ -100,6 +111,10 @@ this.from6To12Months = from6To12Months; } + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + public DataMartTask() { } @@ -119,7 +134,11 @@ this.dataSetService = dataSetService; this.systemSettingManager = systemSettingManager; } - + + // ------------------------------------------------------------------------- + // Runnable implementation + // ------------------------------------------------------------------------- + @Override @SuppressWarnings("unchecked") public void run() @@ -142,23 +161,35 @@ completenessService.exportDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds ); } + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + /** - * Generates periods based on parameters and period types argument. + * Generates periods based on parameters and period types argument. Returns + * the list of periods with class scope if it has been set and has one or + * more periods. Returns a list of relative periods based on the given set + * of period types otherwise. */ public List getPeriods( Set periodTypes ) { - List periods = new RelativePeriods().getRelativePeriods( periodTypes ).getRelativePeriods( 1 ); + if ( periods != null && periods.size() > 0 ) + { + return periods; + } + + List relativePeriods = new RelativePeriods().getRelativePeriods( periodTypes ).getRelativePeriods( 1 ); if ( periodTypes.contains( YearlyPeriodType.NAME ) ) // Add last year { - periods.addAll( new RelativePeriods().setLastYear( true ).getRelativePeriods( 1 ) ); + relativePeriods.addAll( new RelativePeriods().setLastYear( true ).getRelativePeriods( 1 ) ); } final Date date = new Cal().now().subtract( Calendar.MONTH, 7 ).time(); if ( last6Months ) { - FilterUtils.filter( periods, new Filter() + FilterUtils.filter( relativePeriods, new Filter() { public boolean retain( Period period ) { @@ -168,7 +199,7 @@ } else if ( from6To12Months ) { - FilterUtils.filter( periods, new Filter() + FilterUtils.filter( relativePeriods, new Filter() { public boolean retain( Period period ) { @@ -177,6 +208,6 @@ } ); } - return periods; + return relativePeriods; } } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Clock.java 2012-02-12 13:16:57 +0000 @@ -54,6 +54,11 @@ return this; } + public String time() + { + return DurationFormatUtils.formatDurationHMS( super.getSplitTime() ); + } + public Clock logTime( String message ) { super.split(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2012-01-05 20:39:23 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2012-02-12 13:16:57 +0000 @@ -28,4 +28,6 @@ + + === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm 2012-02-12 17:11:30 +0000 @@ -0,0 +1,23 @@ + + + +++#foreach( $notification in $notifications ) + + + + +#end +
${format.formatDateTime( $notification.time )}:${encoder.htmlEncode( $notification.message )} #if( $velocityCount == 1 ) #end
\ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java 2012-02-12 17:11:30 +0000 @@ -0,0 +1,107 @@ +package org.hisp.dhis.commons.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.List; + +import org.hisp.dhis.system.notification.Notification; +import org.hisp.dhis.system.notification.NotificationCategory; +import org.hisp.dhis.system.notification.Notifier; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public class GetNotificationsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private Notifier notifier; + + public void setNotifier( Notifier notifier ) + { + this.notifier = notifier; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String category; + + public void setCategory( String category ) + { + this.category = category; + } + + private Integer max; + + public void setMax( Integer max ) + { + this.max = max; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List notifications; + + public List getNotifications() + { + return notifications; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + max = max != null ? max : 20; + + if ( category != null ) + { + NotificationCategory notificationCategory = NotificationCategory.valueOf( category.toUpperCase() ); + + notifications = notifier.getNotifications( notificationCategory, max ); + } + else + { + notifications = notifier.getNotifications( max ); + } + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-02-02 20:01:36 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-02-12 17:11:20 +0000 @@ -318,6 +318,10 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-01-20 10:38:11 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-02-12 17:11:20 +0000 @@ -315,6 +315,11 @@ + + /dhis-web-commons/ajax/htmlNotifications.vm + plainTextError + + /dhis-web-commons/ajax/xmlCategoryOptionCombos.vm === added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart' === added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action' === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java 2012-02-12 14:40:54 +0000 @@ -0,0 +1,80 @@ +package org.hisp.dhis.reporting.datamart.action; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.system.scheduling.DataMartTask; +import org.hisp.dhis.system.scheduling.Scheduler; +import org.hisp.dhis.system.util.DateUtils; + +import com.opensymphony.xwork2.Action; + +public class StartExportAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private Scheduler scheduler; + + public void setScheduler( Scheduler scheduler ) + { + this.scheduler = scheduler; + } + + private DataMartTask dataMartTask; + + public void setDataMartTask( DataMartTask dataMartTask ) + { + this.dataMartTask = dataMartTask; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String startDate; + + public void setStartDate( String startDate ) + { + this.startDate = startDate; + } + + private String endDate; + + public void setEndDate( String endDate ) + { + this.endDate = endDate; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + Date start = DateUtils.getMediumDate( startDate ); + Date end = DateUtils.getMediumDate( endDate ); + + List periods = new ArrayList( periodService.getPeriodsBetweenDates( start, end ) ); + + dataMartTask.setPeriods( periods ); + + scheduler.executeTask( dataMartTask ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-02-12 12:21:49 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-02-12 14:40:54 +0000 @@ -242,6 +242,15 @@
+ + + + + + + + + + + + /main.vm + /dhis-web-reporting/viewDataMartForm.vm + /dhis-web-reporting/menu.vm + javascript/dataMart.js + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + plainTextError + + === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 2012-02-12 17:11:20 +0000 @@ -0,0 +1,20 @@ + +$( document ).ready( function() { + datePickerInRange( 'startDate' , 'endDate' ); +} ); + +function startExport() +{ + var url = 'startExport.action'; + var startDate = $( '#startDate' ).val(); + var endDate = $( '#endDate' ).val(); + + $.get( url, { startDate:startDate, endDate:endDate }, pingNotifications ); +} + +function pingNotifications() +{ + $( '#notificationDiv' ).load( '../dhis-web-commons-ajax/getNotifications.action?category=DATAMART' ); + + setTimeout( "pingNotifications()", 2000 ); +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2012-02-05 13:28:15 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2012-02-12 14:40:54 +0000 @@ -9,3 +9,8 @@
  • $i18n.getString( "report_table" ) 
  • $i18n.getString( "pivot_table" ) 
  • + +

    $i18n.getString( "data_mart" ) 

    + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm 2012-02-12 17:11:20 +0000 @@ -0,0 +1,23 @@ + +

    $i18n.getString( "data_mart_management" )

    + +
    + +++ + + + + + + + + + + + +
    $i18n.getString( "start_date" )
    $i18n.getString( "end_date" )
    +
    + +
    \ No newline at end of file