=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PresetProvider.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PresetProvider.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PresetProvider.java 1970-01-01 00:00:00 +0000 @@ -1,38 +0,0 @@ -package org.hisp.dhis.common; - -/* - * Copyright (c) 2004-2015, 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; - -/** - * @author Morten Olav Hansen - */ -public interface PresetProvider extends NamedProvider> -{ -} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java 2015-11-12 04:47:12 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java 2015-12-22 10:31:26 +0000 @@ -32,11 +32,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.hisp.dhis.common.PresetProvider; import org.hisp.dhis.node.AbstractNode; import org.hisp.dhis.node.Node; import org.hisp.dhis.node.NodePropertyConverter; import org.hisp.dhis.node.NodeTransformer; +import org.hisp.dhis.node.Preset; import org.hisp.dhis.node.types.CollectionNode; import org.hisp.dhis.node.types.ComplexNode; import org.hisp.dhis.node.types.SimpleNode; @@ -70,15 +70,12 @@ private SchemaService schemaService; @Autowired( required = false ) - private Set presetProviders = Sets.newHashSet(); - - @Autowired( required = false ) private Set nodePropertyConverters = Sets.newHashSet(); @Autowired( required = false ) private Set nodeTransformers = Sets.newHashSet(); - private ImmutableMap presets = ImmutableMap.of(); + private ImmutableMap presets = ImmutableMap.of(); private ImmutableMap converters = ImmutableMap.of(); @@ -87,11 +84,11 @@ @PostConstruct public void init() { - ImmutableMap.Builder presetBuilder = ImmutableMap.builder(); + ImmutableMap.Builder presetBuilder = ImmutableMap.builder(); - for ( PresetProvider presetProvider : presetProviders ) + for ( Preset preset : Preset.values() ) { - presetBuilder.put( presetProvider.name(), presetProvider ); + presetBuilder.put( preset.getName(), preset ); } presets = presetBuilder.build(); @@ -224,7 +221,7 @@ } else if ( fieldValue.isEmpty() ) { - List fields = presets.get( "identifiable" ).provide(); + List fields = Preset.defaultPreset().getFields(); if ( property.isCollection() ) { @@ -343,13 +340,9 @@ { if ( "*".equals( fieldKey ) ) { - for ( String mapKey : schema.getPropertyMap().keySet() ) - { - if ( !fieldMap.containsKey( mapKey ) ) - { - fieldMap.put( mapKey, new FieldMap() ); - } - } + schema.getPropertyMap().keySet().stream() + .filter( mapKey -> !fieldMap.containsKey( mapKey ) ) + .forEach( mapKey -> fieldMap.put( mapKey, new FieldMap() ) ); cleanupFields.add( fieldKey ); } @@ -357,13 +350,9 @@ { List properties = schema.getProperties(); - for ( Property property : properties ) - { - if ( !fieldMap.containsKey( property.key() ) && property.isPersisted() ) - { - fieldMap.put( property.key(), new FieldMap() ); - } - } + properties.stream() + .filter( property -> !fieldMap.containsKey( property.key() ) && property.isPersisted() ) + .forEach( property -> fieldMap.put( property.key(), new FieldMap() ) ); cleanupFields.add( fieldKey ); } @@ -371,34 +360,26 @@ { List properties = schema.getProperties(); - for ( Property property : properties ) - { - if ( !fieldMap.containsKey( property.key() ) && property.isPersisted() && property.isOwner() ) - { - fieldMap.put( property.key(), new FieldMap() ); - } - } + properties.stream() + .filter( property -> !fieldMap.containsKey( property.key() ) && property.isPersisted() && property.isOwner() ) + .forEach( property -> fieldMap.put( property.key(), new FieldMap() ) ); cleanupFields.add( fieldKey ); } else if ( fieldKey.startsWith( ":" ) ) { - PresetProvider presetProvider = presets.get( fieldKey.substring( 1 ) ); + Preset preset = presets.get( fieldKey.substring( 1 ) ); - if ( presetProvider == null ) + if ( preset == null ) { continue; } - List fields = presetProvider.provide(); + List fields = preset.getFields(); - for ( String field : fields ) - { - if ( !fieldMap.containsKey( field ) ) - { - fieldMap.put( field, new FieldMap() ); - } - } + fields.stream() + .filter( field -> !fieldMap.containsKey( field ) ) + .forEach( field -> fieldMap.put( field, new FieldMap() ) ); cleanupFields.add( fieldKey ); } === added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/Preset.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/Preset.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/Preset.java 2015-12-22 10:31:26 +0000 @@ -0,0 +1,69 @@ +package org.hisp.dhis.node; + +/* + * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists; + +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +public enum Preset +{ + ID( "id", Lists.newArrayList( "id" ) ), + ALL( "all", Lists.newArrayList( "*" ) ), + IDENTIFIABLE( "identifiable", Lists.newArrayList( "id", "name", "code", "created", "lastUpdated", "href" ) ), + NAMEABLE( "nameable", Lists.newArrayList( "id", "name", "shortName", "description", "code", "created", "lastUpdated", "href" ) ); + + private String name; + + private List fields; + + Preset( String name, List fields ) + { + this.name = name; + this.fields = fields; + } + + public String getName() + { + return name; + } + + public List getFields() + { + return fields; + } + + public static Preset defaultPreset() + { + return Preset.ID; + } +} === removed directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets' === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/AllPresetProvider.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/AllPresetProvider.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/AllPresetProvider.java 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ -package org.hisp.dhis.node.presets; - -/* - * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists; -import org.hisp.dhis.common.PresetProvider; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author Morten Olav Hansen - */ -@Component -public class AllPresetProvider implements PresetProvider -{ - @Override - public String name() - { - return "all"; - } - - @Override - public List provide() - { - return Lists.newArrayList( "*" ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/IdentifiablePresetProvider.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/IdentifiablePresetProvider.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/IdentifiablePresetProvider.java 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ -package org.hisp.dhis.node.presets; - -/* - * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists; -import org.hisp.dhis.common.PresetProvider; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author Morten Olav Hansen - */ -@Component -public class IdentifiablePresetProvider implements PresetProvider -{ - @Override - public String name() - { - return "identifiable"; - } - - @Override - public List provide() - { - return Lists.newArrayList( "id", "name", "code", "created", "lastUpdated", "href" ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/NameablePresetProvider.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/NameablePresetProvider.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/presets/NameablePresetProvider.java 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ -package org.hisp.dhis.node.presets; - -/* - * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists; -import org.hisp.dhis.common.PresetProvider; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author Morten Olav Hansen - */ -@Component -public class NameablePresetProvider implements PresetProvider -{ - @Override - public String name() - { - return "nameable"; - } - - @Override - public List provide() - { - return Lists.newArrayList( "id", "name", "shortName", "description", "code", "created", "lastUpdated", "href" ); - } -} === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-12-01 10:48:27 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-12-22 10:31:26 +0000 @@ -174,7 +174,7 @@ if ( fields.isEmpty() ) { - fields.add( ":identifiable" ); + fields.add( ":id" ); } List entities = getEntityList( metaData, options, filters, orders ); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-12-15 08:08:01 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-12-22 10:31:26 +0000 @@ -114,7 +114,7 @@ if ( fields.isEmpty() ) { - fields.add( ":identifiable" ); + fields.add( ":id" ); } List items = dimensionService.getCanReadDimensionItems( uid ); === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-09-15 10:26:47 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-12-22 10:31:26 +0000 @@ -391,7 +391,7 @@ $l.empty(); - $.getJSON( "../api/dashboards.json?paging=false&links=false&" + dhis2.util.cacheBust(), function( data ) + $.getJSON( "../api/dashboards.json?fields=id,displayName&paging=false&links=false&" + dhis2.util.cacheBust(), function( data ) { if ( undefined !== data.dashboards ) { @@ -399,9 +399,9 @@ $.each( data.dashboards, function( index, dashboard ) { - $l.append( $.tmpl( dhis2.db.tmpl.dashboardLink, { "id": dashboard.id, "name": dashboard.name } ) ); + $l.append( $.tmpl( dhis2.db.tmpl.dashboardLink, { "id": dashboard.id, "name": dashboard.displayName } ) ); - if ( index == 0 ) + if ( index == 0 ) { first = dashboard.id; }