dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26752
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13225: proper deletion of datasets, wip
------------------------------------------------------------
revno: 13225
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-13 17:03:24 +0100
message:
proper deletion of datasets, wip
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroupStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SMSCommandDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserAuthorityGroupStore.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserAuthorityGroupDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2013-12-13 16:03:24 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -112,4 +113,6 @@
int getChartCountByName( String name );
Collection<Chart> getChartsByUser( User user );
+
+ int countDataSetCharts( DataSet dataSet );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 2013-12-13 16:03:24 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.user.User;
/**
@@ -40,4 +41,6 @@
extends GenericIdentifiableObjectStore<Chart>
{
Collection<Chart> getSystemAndUserCharts( User user );
+
+ int countDataSetCharts( DataSet dataSet );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2013-12-13 16:03:24 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.user.User;
import java.util.Collection;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2013-11-20 04:03:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2013-12-13 16:03:24 +0000
@@ -28,13 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Map;
-import java.util.Set;
-
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.user.UserGroup;
+import java.util.Set;
+
public class SMSCommand
{
private int id;
@@ -54,13 +53,13 @@
private String codeSeparator;
private String defaultMessage;
-
+
private String receivedMessage;
-
+
private UserGroup userGroup;
-
+
private Set<SMSSpecialCharacter> specialCharacters;
-
+
private boolean currentPeriodUsedForReporting = false; // default is prev
public SMSCommand( String name, String parser, ParserType parserType, String separator, DataSet dataset,
@@ -79,7 +78,7 @@
this.receivedMessage = receivedMessage;
this.specialCharacters = specialCharacters;
}
-
+
public SMSCommand( String name, String parser, ParserType parserType, String separator, DataSet dataset,
Set<SMSCode> codes, String codeSeparator, String defaultMessage, UserGroup userGroup, String receivedMessage )
{
@@ -95,9 +94,9 @@
this.userGroup = userGroup;
this.receivedMessage = receivedMessage;
}
-
+
public SMSCommand( String name, String parser, ParserType parserType, String separator, DataSet dataset,
- Set<SMSCode> codes, String codeSeparator, String defaultMessage)
+ Set<SMSCode> codes, String codeSeparator, String defaultMessage )
{
super();
this.name = name;
@@ -296,5 +295,5 @@
{
this.specialCharacters = specialCharacters;
}
-
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java 2013-11-22 04:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandService.java 2013-12-13 16:03:24 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import java.util.Set;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.sms.parse.ParserType;
public interface SMSCommandService
@@ -56,4 +57,6 @@
void deleteSpecialCharacterSet( Set<SMSSpecialCharacter> specialCharacters );
void deleteCodeSet( Set<SMSCode> codes );
+
+ int countDataSetSmsCommands( DataSet dataSet );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java 2013-11-22 04:59:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommandStore.java 2013-12-13 16:03:24 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import java.util.Set;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.sms.parse.ParserType;
public interface SMSCommandStore
@@ -54,4 +55,6 @@
void deleteSpecialCharacterSet( Set<SMSSpecialCharacter> specialCharacters );
void deleteCodeSet( Set<SMSCode> codes );
+
+ int countDataSetSmsCommands( DataSet dataSet );
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroupStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroupStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroupStore.java 2013-12-13 16:03:24 +0000
@@ -0,0 +1,41 @@
+package org.hisp.dhis.user;
+
+/*
+ * Copyright (c) 2004-2013, 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 org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.dataset.DataSet;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface UserAuthorityGroupStore
+ extends GenericIdentifiableObjectStore<UserAuthorityGroup>
+{
+ int countDataSetUserAuthorityGroups( DataSet dataSet );
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java 2013-10-21 17:17:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java 2013-12-13 16:03:24 +0000
@@ -400,5 +400,6 @@
Collection<User> getUsersByName( String name );
Collection<String> getUsernames( String query, Integer max );
-
+
+ int countDataSetUserAuthorityGroups( DataSet dataSet );
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SMSCommandDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SMSCommandDeletionHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SMSCommandDeletionHandler.java 2013-12-13 16:03:24 +0000
@@ -0,0 +1,56 @@
+package org.hisp.dhis.sms;
+
+/*
+ * Copyright (c) 2004-2013, 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 org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.smscommand.SMSCommand;
+import org.hisp.dhis.smscommand.SMSCommandService;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class SMSCommandDeletionHandler extends DeletionHandler
+{
+ @Autowired
+ private SMSCommandService smsCommandService;
+
+ @Override
+ protected String getClassName()
+ {
+ return SMSCommand.class.getSimpleName();
+ }
+
+ @Override
+ public String allowDeleteDataSet( DataSet dataSet )
+ {
+ return smsCommandService.countDataSetSmsCommands( dataSet ) == 0 ? null : ERROR;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java 2013-11-22 04:59:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java 2013-12-13 16:03:24 +0000
@@ -28,14 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.Set;
-
import org.hibernate.Criteria;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.smscommand.SMSCode;
import org.hisp.dhis.smscommand.SMSCommand;
@@ -44,6 +43,9 @@
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Collection;
+import java.util.Set;
+
public class HibernateSMSCommandStore
implements SMSCommandStore
{
@@ -55,7 +57,7 @@
this.sessionFactory = sessionFactory;
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
@Override
public Collection<SMSCommand> getSMSCommands()
{
@@ -76,7 +78,7 @@
public void save( Set<SMSCode> codes )
{
Session session = sessionFactory.getCurrentSession();
-
+
for ( SMSCode x : codes )
{
session.saveOrUpdate( x );
@@ -100,21 +102,21 @@
public void delete( SMSCommand cmd )
{
Session session = sessionFactory.getCurrentSession();
-
+
for ( SMSCode x : cmd.getCodes() )
{
session.delete( x );
}
-
+
for ( SMSSpecialCharacter x : cmd.getSpecialCharacters() )
{
session.delete( x );
}
-
+
session.delete( cmd );
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
@Override
public Collection<SMSCommand> getJ2MESMSCommands()
{
@@ -128,8 +130,8 @@
{
Criteria criteria = sessionFactory.getCurrentSession().createCriteria( SMSCommand.class );
criteria.add( Restrictions.eq( "parserType", parserType ) );
- criteria.add( Restrictions.ilike( "name", "%"+commandName+"%") );
-
+ criteria.add( Restrictions.ilike( "name", "%" + commandName + "%" ) );
+
if ( criteria.list() != null && criteria.list().size() > 0 )
{
return (SMSCommand) criteria.list().get( 0 );
@@ -142,7 +144,7 @@
public void saveSpecialCharacterSet( Set<SMSSpecialCharacter> specialCharacters )
{
Session session = sessionFactory.getCurrentSession();
-
+
for ( SMSSpecialCharacter x : specialCharacters )
{
session.saveOrUpdate( x );
@@ -154,7 +156,7 @@
public void deleteCodeSet( Set<SMSCode> codes )
{
Session session = sessionFactory.getCurrentSession();
-
+
for ( SMSCode x : codes )
{
session.delete( x );
@@ -162,13 +164,27 @@
}
@Override
+ public int countDataSetSmsCommands( DataSet dataSet )
+ {
+ Query query = getQuery( "select count(distinct c) from SMSCommand c where c.dataSet=:dataSet", true );
+ query.setEntity( "dataSet", dataSet );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
+
+ @Override
public void deleteSpecialCharacterSet( Set<SMSSpecialCharacter> specialCharacters )
{
Session session = sessionFactory.getCurrentSession();
-
+
for ( SMSSpecialCharacter x : specialCharacters )
{
session.delete( x );
}
}
+
+ public Query getQuery( String hql, boolean cacheable )
+ {
+ return sessionFactory.getCurrentSession().createQuery( hql ).setCacheable( cacheable );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java 2013-11-22 04:59:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/smscommand/DefaultSMSCommandService.java 2013-12-13 16:03:24 +0000
@@ -31,6 +31,7 @@
import java.util.Collection;
import java.util.Set;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.smscommand.SMSCommandStore;
@@ -101,6 +102,12 @@
}
@Override
+ public int countDataSetSmsCommands( DataSet dataSet )
+ {
+ return smsCommandStore.countDataSetSmsCommands(dataSet);
+ }
+
+ @Override
public void deleteSpecialCharacterSet( Set<SMSSpecialCharacter> specialCharacters )
{
smsCommandStore.deleteSpecialCharacterSet( specialCharacters );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-10-21 17:17:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-12-13 16:03:24 +0000
@@ -28,15 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.AuditLogUtil;
@@ -47,8 +38,18 @@
import org.hisp.dhis.system.filter.UserCredentialsCanUpdateFilter;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Chau Thu Tran
*/
@@ -70,15 +71,15 @@
}
private UserCredentialsStore userCredentialsStore;
-
+
public void setUserCredentialsStore( UserCredentialsStore userCredentialsStore )
{
this.userCredentialsStore = userCredentialsStore;
}
- private GenericIdentifiableObjectStore<UserAuthorityGroup> userAuthorityGroupStore;
-
- public void setUserAuthorityGroupStore( GenericIdentifiableObjectStore<UserAuthorityGroup> userAuthorityGroupStore )
+ private UserAuthorityGroupStore userAuthorityGroupStore;
+
+ public void setUserAuthorityGroupStore( UserAuthorityGroupStore userAuthorityGroupStore )
{
this.userAuthorityGroupStore = userAuthorityGroupStore;
}
@@ -118,7 +119,7 @@
{
return false; // Cannot be last if not super user
}
-
+
Collection<UserCredentials> users = userCredentialsStore.getAllUserCredentials();
for ( UserCredentials user : users )
@@ -180,10 +181,10 @@
AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), user, AuditLogUtil.ACTION_DELETE );
userCredentialsStore.deleteUserCredentials( user.getUserCredentials() );
-
+
userStore.delete( user );
}
-
+
public Collection<User> getAllUsers()
{
return userStore.getAll();
@@ -194,7 +195,7 @@
{
return userStore.getAllOrderedName( first, max );
}
-
+
@Override
public List<User> getAllUsersBetweenByName( String name, int first, int max )
{
@@ -232,12 +233,12 @@
}
} );
}
-
+
public List<User> getUsersByUid( List<String> uids )
{
return userStore.getByUid( uids );
}
-
+
public Collection<UserCredentials> getUsersByOrganisationUnitBetween( OrganisationUnit unit, int first, int max )
{
return userCredentialsStore.getUsersByOrganisationUnitBetween( unit, first, max );
@@ -263,7 +264,7 @@
{
return userStore.getUsersByPhoneNumber( phoneNumber );
}
-
+
public Collection<User> getUsersByName( String name )
{
return userStore.getUsersByName( name );
@@ -283,33 +284,33 @@
{
return userCredentialsStore.getUsersWithoutOrganisationUnitCountByName( userName );
}
-
+
public User searchForUser( String query )
{
User user = userStore.getByUid( query );
-
+
if ( user == null )
{
UserCredentials credentials = userCredentialsStore.getUserCredentialsByUsername( query );
user = credentials != null ? credentials.getUser() : null;
}
-
+
return user;
}
-
+
public List<User> queryForUsers( String query )
{
List<User> users = new ArrayList<User>();
-
+
User uidUser = userStore.getByUid( query );
-
+
if ( uidUser != null )
{
users.add( uidUser );
}
-
+
users.addAll( userStore.getAllLikeNameOrderedName( query, 0, 1000 ) ); //TODO
-
+
return users;
}
@@ -469,7 +470,7 @@
{
return userCredentialsStore.getSelfRegisteredUserCredentialsCount();
}
-
+
public Collection<UserCredentials> getInactiveUsers( int months )
{
Calendar cal = PeriodType.createCalendarInstance();
@@ -501,7 +502,7 @@
return userCredentialsStore.getActiveUsersCount( cal.getTime() );
}
-
+
public int getActiveUsersCount( Date since )
{
return userCredentialsStore.getActiveUsersCount( since );
@@ -515,11 +516,11 @@
{
userCredentialsStore.addUserSetting( userSetting );
}
-
+
public void addOrUpdateUserSetting( UserSetting userSetting )
{
UserSetting setting = getUserSetting( userSetting.getUser(), userSetting.getName() );
-
+
if ( setting != null )
{
setting.mergeWith( userSetting );
@@ -545,7 +546,7 @@
{
return userCredentialsStore.getAllUserSettings( user );
}
-
+
public Collection<UserSetting> getUserSettings( String name )
{
return userCredentialsStore.getUserSettings( name );
@@ -555,11 +556,11 @@
{
return userCredentialsStore.getUserSetting( user, name );
}
-
+
public Serializable getUserSettingValue( User user, String name, Serializable defaultValue )
{
UserSetting setting = getUserSetting( user, name );
-
+
return setting != null && setting.getValue() != null ? setting.getValue() : defaultValue;
}
@@ -579,14 +580,20 @@
{
return userStore.getUsersByOrganisationUnits( units );
}
-
+
public void removeUserSettings( User user )
{
userStore.removeUserSettings( user );
}
-
+
public Collection<String> getUsernames( String query, Integer max )
{
return userCredentialsStore.getUsernames( query, max );
- }
+ }
+
+ @Override
+ public int countDataSetUserAuthorityGroups( DataSet dataSet )
+ {
+ return userAuthorityGroupStore.countDataSetUserAuthorityGroups( dataSet );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserAuthorityGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserAuthorityGroupDeletionHandler.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserAuthorityGroupDeletionHandler.java 2013-12-13 16:03:24 +0000
@@ -28,11 +28,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Iterator;
-
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.deletion.DeletionHandler;
+import java.util.Iterator;
+
/**
* @author Lars Helge Overland
* @version $Id$
@@ -50,7 +50,7 @@
{
this.userService = userService;
}
-
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -72,14 +72,14 @@
}
}
}
-
+
@Override
public void deleteUser( User user )
{
UserCredentials credentials = user.getUserCredentials();
-
+
Iterator<UserAuthorityGroup> iterator = credentials.getUserAuthorityGroups().iterator();
-
+
while ( iterator.hasNext() )
{
UserAuthorityGroup group = iterator.next();
@@ -87,4 +87,10 @@
userService.updateUserAuthorityGroup( group );
}
}
+
+ @Override
+ public String allowDeleteDataSet( DataSet dataSet )
+ {
+ return userService.countDataSetUserAuthorityGroups( dataSet ) == 0 ? null : ERROR;
+ }
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserAuthorityGroupStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserAuthorityGroupStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserAuthorityGroupStore.java 2013-12-13 16:03:24 +0000
@@ -0,0 +1,52 @@
+package org.hisp.dhis.user.hibernate;
+
+/*
+ * Copyright (c) 2004-2013, 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 org.hibernate.Query;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.user.UserAuthorityGroup;
+import org.hisp.dhis.user.UserAuthorityGroupStore;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class HibernateUserAuthorityGroupStore
+ extends HibernateIdentifiableObjectStore<UserAuthorityGroup>
+ implements UserAuthorityGroupStore
+{
+ @Override
+ public int countDataSetUserAuthorityGroups( DataSet dataSet )
+ {
+ Query query = getQuery( "select count(distinct c) from UserAuthorityGroup c where :dataSet in elements(c.dataSets)" );
+ query.setEntity( "dataSet", dataSet );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-11-20 13:31:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-12-13 16:03:24 +0000
@@ -215,6 +215,12 @@
<property name="cacheable" value="true" />
</bean>
+ <bean id="org.hisp.dhis.user.UserAuthorityGroupStore" class="org.hisp.dhis.user.hibernate.HibernateUserAuthorityGroupStore">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="clazz" value="org.hisp.dhis.user.UserAuthorityGroup" />
+ <property name="cacheable" value="true" />
+ </bean>
+
<bean id="org.hisp.dhis.user.UserCredentialsStore" class="org.hisp.dhis.user.hibernate.HibernateUserCredentialsStore">
<property name="sessionFactory" ref="sessionFactory" />
<property name="userService" ref="org.hisp.dhis.user.UserService" />
@@ -251,12 +257,6 @@
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
- <bean id="org.hisp.dhis.user.UserAuthorityGroupStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
- <property name="clazz" value="org.hisp.dhis.user.UserAuthorityGroup" />
- <property name="sessionFactory" ref="sessionFactory" />
- <property name="cacheable" value="true" />
- </bean>
-
<bean id="org.hisp.dhis.message.MessageConversationStore" class="org.hisp.dhis.message.hibernate.HibernateMessageConversationStore">
<property name="clazz" value="org.hisp.dhis.message.MessageConversation" />
<property name="sessionFactory" ref="sessionFactory" />
@@ -1076,7 +1076,9 @@
<bean id="org.hisp.dhis.mapping.MapDeletionHandler" class="org.hisp.dhis.mapping.MapDeletionHandler">
<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
</bean>
-
+
+ <bean id="org.hisp.dhis.sms.SMSCommandDeletionHandler" class="org.hisp.dhis.sms.SMSCommandDeletionHandler" />
+
<!-- DeletionManager -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -1118,6 +1120,7 @@
<ref local="org.hisp.dhis.attribute.AttributeValueDeletionHandler" />
<ref local="org.hisp.dhis.mapping.MapLegendSetDeletionHandler" />
<ref local="org.hisp.dhis.mapping.MapViewDeletionHandler" />
+ <ref local="org.hisp.dhis.sms.SMSCommandDeletionHandler" />
</list>
</list>
</property>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml 2013-11-20 04:03:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml 2013-12-13 16:03:24 +0000
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
- [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
- >
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+ >
<hibernate-mapping package="org.hisp.dhis.smscommand">
<class name="SMSCommand" table="smscommands">
@@ -33,14 +33,14 @@
<key column="id" />
<many-to-many class="org.hisp.dhis.smscommand.SMSCode" column="codeid" unique="true" />
</set>
-
+
<set name="specialCharacters" table="smscommandspecialcharacters">
<key column="smscommandid" />
<many-to-many class="org.hisp.dhis.smscommand.SMSSpecialCharacter" column="specialcharacterid" unique="true" />
</set>
-
- <many-to-one name="userGroup" class="org.hisp.dhis.user.UserGroup" column="usergroupid" foreign-key="fk_smscommand_usergroup"/>
+
+ <many-to-one name="userGroup" class="org.hisp.dhis.user.UserGroup" column="usergroupid" foreign-key="fk_smscommand_usergroup" />
</class>
-</hibernate-mapping>
\ No newline at end of file
+</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2013-12-12 13:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2013-12-13 16:03:24 +0000
@@ -137,6 +137,11 @@
types = Lists.newArrayList( ExchangeClasses.getImportMap().values() );
}
+ /*
+ types.clear();
+ types.add( "dataSets" );
+ */
+
for ( String type : types )
{
Object value = ReflectionUtils.invokeGetterMethod( type, metaData );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2013-12-13 16:03:24 +0000
@@ -67,16 +67,9 @@
}
@Override
- public void deleteUser( User user )
+ public String allowDeleteDataSet( DataSet dataSet )
{
- for ( Chart chart : chartService.getAllCharts() )
- {
- if ( chart.getUser() != null && chart.getUser().equals( user ) )
- {
- chart.setUser( null );
- chartService.updateChart( chart );
- }
- }
+ return chartService.countDataSetCharts( dataSet ) == 0 ? null : ERROR;
}
@Override
@@ -89,11 +82,24 @@
return chart.getName();
}
}
-
+
return null;
}
@Override
+ public void deleteUser( User user )
+ {
+ for ( Chart chart : chartService.getAllCharts() )
+ {
+ if ( chart.getUser() != null && chart.getUser().equals( user ) )
+ {
+ chart.setUser( null );
+ chartService.updateChart( chart );
+ }
+ }
+ }
+
+ @Override
public void deleteIndicator( Indicator indicator )
{
for ( Chart chart : chartService.getAllCharts() )
@@ -128,7 +134,7 @@
}
}
}
-
+
@Override
public void deleteOrganisationUnit( OrganisationUnit unit )
{
@@ -140,7 +146,7 @@
}
}
}
-
+
@Override
public void deleteDataElementGroup( DataElementGroup group )
{
@@ -152,7 +158,7 @@
}
}
}
-
+
@Override
public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
{
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2013-12-13 16:03:24 +0000
@@ -28,14 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-
+import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartStore;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.user.User;
+import java.util.Collection;
+
/**
* @author Lars Helge Overland
*/
@@ -45,8 +47,17 @@
@SuppressWarnings("unchecked")
public Collection<Chart> getSystemAndUserCharts( User user )
{
- return getCriteria(
- Restrictions.or( Restrictions.isNull( "user" ),
- Restrictions.eq( "user", user ) ) ).list();
+ return getCriteria(
+ Restrictions.or( Restrictions.isNull( "user" ),
+ Restrictions.eq( "user", user ) ) ).list();
+ }
+
+ @Override
+ public int countDataSetCharts( DataSet dataSet )
+ {
+ Query query = getQuery( "select count(distinct c) from Chart c where :dataSet in elements(c.dataSets)" );
+ query.setEntity( "dataSet", dataSet );
+
+ return ((Long) query.uniqueResult()).intValue();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-12-13 16:03:24 +0000
@@ -28,27 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.chart.Chart.TYPE_AREA;
-import static org.hisp.dhis.chart.Chart.TYPE_BAR;
-import static org.hisp.dhis.chart.Chart.TYPE_COLUMN;
-import static org.hisp.dhis.chart.Chart.TYPE_LINE;
-import static org.hisp.dhis.chart.Chart.TYPE_PIE;
-import static org.hisp.dhis.chart.Chart.TYPE_STACKED_BAR;
-import static org.hisp.dhis.chart.Chart.TYPE_STACKED_COLUMN;
-import static org.hisp.dhis.chart.Chart.TYPE_RADAR;
-import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP;
-import static org.hisp.dhis.system.util.ConversionUtils.getArray;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Font;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.commons.math.MathException;
import org.apache.commons.math.analysis.SplineInterpolator;
import org.apache.commons.math.analysis.UnivariateRealFunction;
@@ -63,6 +42,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.i18n.I18nFormat;
@@ -106,6 +86,18 @@
import org.jfree.util.TableOrder;
import org.springframework.transaction.annotation.Transactional;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.hisp.dhis.chart.Chart.*;
+import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP;
+import static org.hisp.dhis.system.util.ConversionUtils.getArray;
+
/**
* @author Lars Helge Overland
*/
@@ -125,7 +117,7 @@
Color.decode( "#b7404c" ), Color.decode( "#ff9f3a" ), Color.decode( "#968f8f" ), Color.decode( "#b7409f" ),
Color.decode( "#ffda64" ), Color.decode( "#4fbdae" ), Color.decode( "#b78040" ), Color.decode( "#676767" ),
Color.decode( "#6a33cf" ), Color.decode( "#4a7833" ) };
-
+
private static final Color COLOR_TRANSPARENT = new Color( 255, 255, 255, 0 );
// -------------------------------------------------------------------------
@@ -168,7 +160,7 @@
}
private OrganisationUnitService organisationUnitService;
-
+
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
@@ -212,17 +204,17 @@
List<OrganisationUnit> atLevels = new ArrayList<OrganisationUnit>();
List<OrganisationUnit> inGroups = new ArrayList<OrganisationUnit>();
-
+
if ( chart.hasOrganisationUnitLevels() )
{
atLevels.addAll( organisationUnitService.getOrganisationUnitsAtLevels( chart.getOrganisationUnitLevels(), chart.getOrganisationUnits() ) );
}
-
+
if ( chart.hasItemOrganisationUnitGroups() )
{
inGroups.addAll( organisationUnitService.getOrganisationUnits( chart.getItemOrganisationUnitGroups(), chart.getOrganisationUnits() ) );
}
-
+
chart.init( user, date, organisationUnit, atLevels, inGroups, format );
return getJFreeChart( chart );
@@ -478,7 +470,7 @@
/**
* Returns an area renderer.
- *
+ * <p/>
* TODO centralize these renderer methods.
*/
private AreaRenderer getAreaRenderer()
@@ -614,41 +606,41 @@
private JFreeChart getAreaChart( Chart chart, CategoryDataset dataSet )
{
- JFreeChart areaChart = ChartFactory.createAreaChart( chart.getName(), chart.getDomainAxisLabel(),
+ JFreeChart areaChart = ChartFactory.createAreaChart( chart.getName(), chart.getDomainAxisLabel(),
chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, true, false, false );
-
+
CategoryPlot plot = (CategoryPlot) areaChart.getPlot();
plot.setOrientation( PlotOrientation.VERTICAL );
plot.setRenderer( getAreaRenderer() );
plot.setBackgroundPaint( COLOR_TRANSPARENT );
plot.setOutlinePaint( COLOR_TRANSPARENT );
-
+
CategoryAxis xAxis = plot.getDomainAxis();
xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );
xAxis.setLabelFont( labelFont );
-
+
areaChart.getTitle().setFont( titleFont );
areaChart.addSubtitle( getSubTitle( chart ) );
areaChart.setBackgroundPaint( COLOR_TRANSPARENT );
areaChart.setAntiAlias( true );
-
+
return areaChart;
}
-
+
private JFreeChart getRadarChart( Chart chart, CategoryDataset dataSet )
{
SpiderWebPlot plot = new SpiderWebPlot( dataSet, TableOrder.BY_ROW );
plot.setBackgroundPaint( COLOR_TRANSPARENT );
plot.setOutlinePaint( COLOR_TRANSPARENT );
plot.setLabelFont( labelFont );
-
+
JFreeChart radarChart = new JFreeChart( chart.getName(), titleFont, plot, !chart.isHideLegend() );
radarChart.setAntiAlias( true );
radarChart.setBackgroundPaint( COLOR_TRANSPARENT );
-
+
return radarChart;
}
-
+
private JFreeChart getStackedBarChart( Chart chart, CategoryDataset dataSet, boolean horizontal )
{
JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( chart.getName(), chart.getDomainAxisLabel(),
@@ -710,7 +702,7 @@
private CategoryDataset[] getCategoryDataSet( Chart chart )
{
Map<String, Double> valueMap = analyticsService.getAggregatedDataValueMapping( chart, chart.getFormat() );
-
+
DefaultCategoryDataset regularDataSet = new DefaultCategoryDataset();
DefaultCategoryDataset regressionDataSet = new DefaultCategoryDataset();
@@ -727,11 +719,11 @@
String key = series.getUid() + DIMENSION_SEP + category.getUid();
// Replace potential operand separator with dimension separator
-
+
key = key.replace( DataElementOperand.SEPARATOR, DIMENSION_SEP );
Double value = valueMap.get( key );
-
+
regularDataSet.addValue( value, series.getShortName(), category.getShortName() );
if ( chart.isRegression() && value != null && !MathUtils.isEqual( value, MathUtils.ZERO ) )
@@ -794,7 +786,7 @@
{
return chartStore.getByUid( uid );
}
-
+
public Chart getChartNoAcl( String uid )
{
return chartStore.getByUidNoAcl( uid );
@@ -852,4 +844,10 @@
{
return chartStore.getByUser( user );
}
+
+ @Override
+ public int countDataSetCharts( DataSet dataSet )
+ {
+ return chartStore.countDataSetCharts( dataSet );
+ }
}