=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/options' === added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/options/setting' === added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java 2011-09-30 13:48:31 +0000 @@ -0,0 +1,147 @@ +package org.hisp.dhis.options.setting; + +/* + * Copyright (c) 2004-2010, 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.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.options.SystemSetting; +import org.hisp.dhis.options.SystemSettingManager; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Stian Strandli + * @author Lars Helge Overland + */ +@Transactional +public class DefaultSystemSettingManager + implements SystemSettingManager +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private GenericIdentifiableObjectStore systemSettingStore; + + public void setSystemSettingStore( GenericIdentifiableObjectStore systemSettingStore ) + { + this.systemSettingStore = systemSettingStore; + } + + private List flags; + + public void setFlags( List flags ) + { + this.flags = flags; + } + + // ------------------------------------------------------------------------- + // SystemSettingManager implementation + // ------------------------------------------------------------------------- + + public void saveSystemSetting( String name, Serializable value ) + { + SystemSetting setting = systemSettingStore.getByName( name ); + + if ( setting == null ) + { + setting = new SystemSetting(); + + setting.setName( name ); + setting.setValue( value ); + + systemSettingStore.save( setting ); + } + else + { + setting.setValue( value ); + + systemSettingStore.update( setting ); + } + } + + public Serializable getSystemSetting( String name ) + { + SystemSetting setting = systemSettingStore.getByName( name ); + + return setting != null && setting.hasValue() ? setting.getValue() : null; + } + + public Serializable getSystemSetting( String name, Serializable defaultValue ) + { + SystemSetting setting = systemSettingStore.getByName( name ); + + return setting != null && setting.hasValue() ? setting.getValue() : defaultValue; + } + + public Collection getAllSystemSettings() + { + return systemSettingStore.getAll(); + } + + public void deleteSystemSetting( String name ) + { + SystemSetting setting = systemSettingStore.getByName( name ); + + if ( setting != null ) + { + systemSettingStore.delete( setting ); + } + } + + // ------------------------------------------------------------------------- + // Specific methods + // ------------------------------------------------------------------------- + + public List getFlags() + { + Collections.sort( flags ); + return flags; + } + + public List getAggregationStrategies() + { + return Arrays.asList( AGGREGATION_STRATEGY_REAL_TIME, AGGREGATION_STRATEGY_BATCH ); + } + + public String getSystemIdentifier() + { + return (String) getSystemSetting( KEY_SYSTEM_IDENTIFIER ); + } + + public String getFlagImage() + { + String flag = (String) getSystemSetting( KEY_FLAG ); + + return flag != null ? flag + ".png" : null; + } +} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserSettingService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserSettingService.java 2011-09-30 09:19:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserSettingService.java 2011-09-30 13:48:31 +0000 @@ -29,6 +29,7 @@ import java.io.Serializable; import java.util.Collection; +import java.util.Collections; import org.springframework.transaction.annotation.Transactional; @@ -134,7 +135,7 @@ if ( currentUser == null ) { - return null; + return Collections.emptySet(); } return userService.getAllUserSettings( currentUser ); @@ -144,11 +145,9 @@ { User currentUser = currentUserService.getCurrentUser(); - if ( currentUser == null ) + if ( currentUser != null ) { - return; - } - - userService.deleteUserSetting( userService.getUserSetting( currentUser, name ) ); + userService.deleteUserSetting( userService.getUserSetting( currentUser, name ) ); + } } } === 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 2011-09-27 10:12:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-09-30 13:48:31 +0000 @@ -247,6 +247,12 @@ + + + + + + @@ -466,6 +472,56 @@ + + + + + armenia + bangladesh + benin + botswana + burkina_faso + cambodia + ethiopia + gambia + ghana + guinea + guinea_bissau + india + indonesia + irc + ivory_coast + kenya + lesotho + liberia + malawi + mali + mozambique + namibia + nigeria + norway + philippines + rwanda + senegal + sierra_leone + sierra_leone_coat_of_arms + south_africa + south_africa_department_of_health + sri_lanka + swaziland + tajikistan + tanzania + togo + uganda + vietnam + zambia + zanzibar + zimbabwe + who + + + + === added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/options' === added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/options/setting' === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/options/setting/SystemSetting.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/options/setting/SystemSetting.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/options/setting/SystemSetting.hbm.xml 2011-09-30 13:48:31 +0000 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + === added directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options' === added directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting' === added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingManagerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingManagerTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingManagerTest.java 2011-09-30 13:48:31 +0000 @@ -0,0 +1,86 @@ +package org.hisp.dhis.options.setting; + +/* + * Copyright (c) 2004-2010, 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 static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.util.Collection; + +import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.options.SystemSetting; +import org.hisp.dhis.options.SystemSettingManager; +import org.junit.Test; + +/** + * @author Stian Strandli + * @author Lars Helge Overland + * @version $Id: SystemSettingManagerTest.java 4866 2008-04-11 10:40:35Z larshelg $ + */ +public class SystemSettingManagerTest + extends DhisSpringTest +{ + private SystemSettingManager systemSettingManager; + + @Override + public void setUpTest() + throws Exception + { + systemSettingManager = (SystemSettingManager) getBean( SystemSettingManager.ID ); + } + + @Test + public void testSaveGetSystemSetting() + { + systemSettingManager.saveSystemSetting( "settingA", new String( "valueA" ) ); + systemSettingManager.saveSystemSetting( "settingB", new String( "valueB" ) ); + + assertEquals( new String( "valueA" ), systemSettingManager.getSystemSetting( "settingA" ) ); + assertEquals( new String( "valueB" ), systemSettingManager.getSystemSetting( "settingB" ) ); + } + + @Test + public void testGetDefaultSystemSetting() + { + assertEquals( new String( "valueA" ), systemSettingManager.getSystemSetting( "settingA", new String( "valueA" ) ) ); + assertEquals( new String( "valueB" ), systemSettingManager.getSystemSetting( "settingB", new String( "valueB" ) ) ); + } + + @Test + public void testGetAllSystemSettings() + { + systemSettingManager.saveSystemSetting( "settingA", new String( "valueA" ) ); + systemSettingManager.saveSystemSetting( "settingB", new String( "valueB" ) ); + systemSettingManager.saveSystemSetting( "settingC", new String( "valueC" ) ); + + Collection settings = systemSettingManager.getAllSystemSettings(); + + assertNotNull( settings ); + assertEquals( 3, settings.size() ); + } +} === added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingStoreTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/options/setting/SystemSettingStoreTest.java 2011-09-30 13:48:31 +0000 @@ -0,0 +1,155 @@ +package org.hisp.dhis.options.setting; + +/* + * Copyright (c) 2004-2010, 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 static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; + +import java.util.Collection; + +import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.options.SystemSetting; +import org.junit.Test; + +/** + * @author Stian Strandli + * @version $Id: SystemSettingStoreTest.java 4866 2008-04-11 10:40:35Z larshelg $ + */ +public class SystemSettingStoreTest + extends DhisSpringTest +{ + private GenericIdentifiableObjectStore systemSettingStore; + + private SystemSetting settingA; + private SystemSetting settingB; + private SystemSetting settingC; + + @Override + @SuppressWarnings( "unchecked" ) + public void setUpTest() + throws Exception + { + systemSettingStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.options.SystemSettingStore" ); + + settingA = new SystemSetting(); + settingA.setName( "Setting1" ); + settingA.setValue( new String( "Value1" ) ); + + settingB = new SystemSetting(); + settingB.setName( "Setting2" ); + settingB.setValue( new String( "Value2" ) ); + + settingC = new SystemSetting(); + settingC.setName( "Setting3" ); + settingC.setValue( new String( "Value3" ) ); + } + + @Test + public void testAddSystemSetting() + { + systemSettingStore.save( settingA ); + systemSettingStore.save( settingB ); + systemSettingStore.save( settingC ); + + SystemSetting s = systemSettingStore.getByName( settingA.getName() ); + assertNotNull( s ); + assertEquals( "Setting1", s.getName() ); + assertEquals( "Value1", s.getValue() ); + + settingA.setValue( new String( "Value1.1" ) ); + systemSettingStore.save( settingA ); + + s = systemSettingStore.getByName( settingA.getName() ); + assertNotNull( s ); + assertEquals( "Setting1", s.getName() ); + assertEquals( "Value1.1", s.getValue() ); + } + + @Test + public void testUpdateSystemSetting() + { + systemSettingStore.save( settingA ); + + settingA = systemSettingStore.getByName( "Setting1" ); + + assertEquals( "Value1", (String) settingA.getValue() ); + + settingA.setValue( new String( "Value2" ) ); + + systemSettingStore.update( settingA ); + + settingA = systemSettingStore.getByName( "Setting1" ); + + assertEquals( "Value2", (String) settingA.getValue() ); + } + + @Test + public void testDeleteSystemSetting() + { + systemSettingStore.save( settingA ); + systemSettingStore.save( settingB ); + systemSettingStore.save( settingC ); + + systemSettingStore.delete( systemSettingStore.getByName( settingA.getName() ) ); + + assertNull( systemSettingStore.getByName( settingA.getName() ) ); + assertEquals( 2, systemSettingStore.getAll().size() ); + } + + @Test + public void testGetSystemSetting() + { + systemSettingStore.save( settingA ); + systemSettingStore.save( settingB ); + + SystemSetting s = systemSettingStore.getByName( "Setting1" ); + assertNotNull( s ); + assertEquals( "Setting1", s.getName() ); + assertEquals( "Value1", s.getValue() ); + + s = systemSettingStore.getByName( "Setting3" ); + assertNull( s ); + } + + @Test + public void testGetAllSystemSettings() + { + Collection m = systemSettingStore.getAll(); + assertNotNull( m ); + assertEquals( 0, m.size() ); + + systemSettingStore.save( settingA ); + systemSettingStore.save( settingB ); + + m = systemSettingStore.getAll(); + assertNotNull( m ); + assertEquals( 2, m.size() ); + } +} === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting' === removed file 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java' --- dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java 2011-09-30 13:18:24 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java 1970-01-01 00:00:00 +0000 @@ -1,147 +0,0 @@ -package org.hisp.dhis.options.setting; - -/* - * Copyright (c) 2004-2010, 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.io.Serializable; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.hisp.dhis.common.GenericIdentifiableObjectStore; -import org.hisp.dhis.options.SystemSetting; -import org.hisp.dhis.options.SystemSettingManager; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Stian Strandli - * @author Lars Helge Overland - */ -@Transactional -public class DefaultSystemSettingManager - implements SystemSettingManager -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private GenericIdentifiableObjectStore systemSettingStore; - - public void setSystemSettingStore( GenericIdentifiableObjectStore systemSettingStore ) - { - this.systemSettingStore = systemSettingStore; - } - - private List flags; - - public void setFlags( List flags ) - { - this.flags = flags; - } - - // ------------------------------------------------------------------------- - // SystemSettingManager implementation - // ------------------------------------------------------------------------- - - public void saveSystemSetting( String name, Serializable value ) - { - SystemSetting setting = systemSettingStore.getByName( name ); - - if ( setting == null ) - { - setting = new SystemSetting(); - - setting.setName( name ); - setting.setValue( value ); - - systemSettingStore.save( setting ); - } - else - { - setting.setValue( value ); - - systemSettingStore.update( setting ); - } - } - - public Serializable getSystemSetting( String name ) - { - SystemSetting setting = systemSettingStore.getByName( name ); - - return setting != null && setting.hasValue() ? setting.getValue() : null; - } - - public Serializable getSystemSetting( String name, Serializable defaultValue ) - { - SystemSetting setting = systemSettingStore.getByName( name ); - - return setting != null && setting.hasValue() ? setting.getValue() : defaultValue; - } - - public Collection getAllSystemSettings() - { - return systemSettingStore.getAll(); - } - - public void deleteSystemSetting( String name ) - { - SystemSetting setting = systemSettingStore.getByName( name ); - - if ( setting != null ) - { - systemSettingStore.delete( setting ); - } - } - - // ------------------------------------------------------------------------- - // Specific methods - // ------------------------------------------------------------------------- - - public List getFlags() - { - Collections.sort( flags ); - return flags; - } - - public List getAggregationStrategies() - { - return Arrays.asList( AGGREGATION_STRATEGY_REAL_TIME, AGGREGATION_STRATEGY_BATCH ); - } - - public String getSystemIdentifier() - { - return (String) getSystemSetting( KEY_SYSTEM_IDENTIFIER ); - } - - public String getFlagImage() - { - String flag = (String) getSystemSetting( KEY_FLAG ); - - return flag != null ? flag + ".png" : null; - } -} === modified file 'dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml 2011-09-30 13:18:24 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml 2011-09-30 13:48:31 +0000 @@ -12,62 +12,6 @@ - - - - - - - - - - - armenia - bangladesh - benin - botswana - burkina_faso - cambodia - ethiopia - gambia - ghana - guinea - guinea_bissau - india - indonesia - irc - ivory_coast - kenya - lesotho - liberia - malawi - mali - mozambique - namibia - nigeria - norway - philippines - rwanda - senegal - sierra_leone - sierra_leone_coat_of_arms - south_africa - south_africa_department_of_health - sri_lanka - swaziland - tajikistan - tanzania - togo - uganda - vietnam - zambia - zanzibar - zimbabwe - who - - - - === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org' === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp' === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis' === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option' === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option/setting' === removed directory 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option/setting/hibernate' === removed file 'dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option/setting/hibernate/SystemSetting.hbm.xml' --- dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option/setting/hibernate/SystemSetting.hbm.xml 2011-05-28 21:25:46 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/main/resources/org/hisp/dhis/option/setting/hibernate/SystemSetting.hbm.xml 1970-01-01 00:00:00 +0000 @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - === removed file 'dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingManagerTest.java' --- dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingManagerTest.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingManagerTest.java 1970-01-01 00:00:00 +0000 @@ -1,84 +0,0 @@ -package org.hisp.dhis.options; - -/* - * Copyright (c) 2004-2010, 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 static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; - -import java.util.Collection; - -import org.hisp.dhis.DhisSpringTest; -import org.junit.Test; - -/** - * @author Stian Strandli - * @author Lars Helge Overland - * @version $Id: SystemSettingManagerTest.java 4866 2008-04-11 10:40:35Z larshelg $ - */ -public class SystemSettingManagerTest - extends DhisSpringTest -{ - private SystemSettingManager systemSettingManager; - - @Override - public void setUpTest() - throws Exception - { - systemSettingManager = (SystemSettingManager) getBean( SystemSettingManager.ID ); - } - - @Test - public void testSaveGetSystemSetting() - { - systemSettingManager.saveSystemSetting( "settingA", new String( "valueA" ) ); - systemSettingManager.saveSystemSetting( "settingB", new String( "valueB" ) ); - - assertEquals( new String( "valueA" ), systemSettingManager.getSystemSetting( "settingA" ) ); - assertEquals( new String( "valueB" ), systemSettingManager.getSystemSetting( "settingB" ) ); - } - - @Test - public void testGetDefaultSystemSetting() - { - assertEquals( new String( "valueA" ), systemSettingManager.getSystemSetting( "settingA", new String( "valueA" ) ) ); - assertEquals( new String( "valueB" ), systemSettingManager.getSystemSetting( "settingB", new String( "valueB" ) ) ); - } - - @Test - public void testGetAllSystemSettings() - { - systemSettingManager.saveSystemSetting( "settingA", new String( "valueA" ) ); - systemSettingManager.saveSystemSetting( "settingB", new String( "valueB" ) ); - systemSettingManager.saveSystemSetting( "settingC", new String( "valueC" ) ); - - Collection settings = systemSettingManager.getAllSystemSettings(); - - assertNotNull( settings ); - assertEquals( 3, settings.size() ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingStoreTest.java' --- dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingStoreTest.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/test/java/org/hisp/dhis/options/SystemSettingStoreTest.java 1970-01-01 00:00:00 +0000 @@ -1,154 +0,0 @@ -package org.hisp.dhis.options; - -/* - * Copyright (c) 2004-2010, 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 static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; - -import java.util.Collection; - -import org.hisp.dhis.DhisSpringTest; -import org.hisp.dhis.common.GenericIdentifiableObjectStore; -import org.junit.Test; - -/** - * @author Stian Strandli - * @version $Id: SystemSettingStoreTest.java 4866 2008-04-11 10:40:35Z larshelg $ - */ -@SuppressWarnings( "unchecked" ) -public class SystemSettingStoreTest - extends DhisSpringTest -{ - private GenericIdentifiableObjectStore systemSettingStore; - - private SystemSetting settingA; - private SystemSetting settingB; - private SystemSetting settingC; - - @Override - public void setUpTest() - throws Exception - { - systemSettingStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.options.SystemSettingStore" ); - - settingA = new SystemSetting(); - settingA.setName( "Setting1" ); - settingA.setValue( new String( "Value1" ) ); - - settingB = new SystemSetting(); - settingB.setName( "Setting2" ); - settingB.setValue( new String( "Value2" ) ); - - settingC = new SystemSetting(); - settingC.setName( "Setting3" ); - settingC.setValue( new String( "Value3" ) ); - } - - @Test - public void testAddSystemSetting() - { - systemSettingStore.save( settingA ); - systemSettingStore.save( settingB ); - systemSettingStore.save( settingC ); - - SystemSetting s = systemSettingStore.getByName( settingA.getName() ); - assertNotNull( s ); - assertEquals( "Setting1", s.getName() ); - assertEquals( "Value1", s.getValue() ); - - settingA.setValue( new String( "Value1.1" ) ); - systemSettingStore.save( settingA ); - - s = systemSettingStore.getByName( settingA.getName() ); - assertNotNull( s ); - assertEquals( "Setting1", s.getName() ); - assertEquals( "Value1.1", s.getValue() ); - } - - @Test - public void testUpdateSystemSetting() - { - systemSettingStore.save( settingA ); - - settingA = systemSettingStore.getByName( "Setting1" ); - - assertEquals( "Value1", (String) settingA.getValue() ); - - settingA.setValue( new String( "Value2" ) ); - - systemSettingStore.update( settingA ); - - settingA = systemSettingStore.getByName( "Setting1" ); - - assertEquals( "Value2", (String) settingA.getValue() ); - } - - @Test - public void testDeleteSystemSetting() - { - systemSettingStore.save( settingA ); - systemSettingStore.save( settingB ); - systemSettingStore.save( settingC ); - - systemSettingStore.delete( systemSettingStore.getByName( settingA.getName() ) ); - - assertNull( systemSettingStore.getByName( settingA.getName() ) ); - assertEquals( 2, systemSettingStore.getAll().size() ); - } - - @Test - public void testGetSystemSetting() - { - systemSettingStore.save( settingA ); - systemSettingStore.save( settingB ); - - SystemSetting s = systemSettingStore.getByName( "Setting1" ); - assertNotNull( s ); - assertEquals( "Setting1", s.getName() ); - assertEquals( "Value1", s.getValue() ); - - s = systemSettingStore.getByName( "Setting3" ); - assertNull( s ); - } - - @Test - public void testGetAllSystemSettings() - { - Collection m = systemSettingStore.getAll(); - assertNotNull( m ); - assertEquals( 0, m.size() ); - - systemSettingStore.save( settingA ); - systemSettingStore.save( settingB ); - - m = systemSettingStore.getAll(); - assertNotNull( m ); - assertEquals( 2, m.size() ); - } -}