=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceFavoritesTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceFavoritesTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceFavoritesTest.java 2016-03-15 08:49:11 +0000 @@ -0,0 +1,106 @@ +package org.hisp.dhis.dxf2.metadata2.objectbundle; + +/* + * Copyright (c) 2004-2016, 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.DhisSpringTest; +import org.hisp.dhis.chart.Chart; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.common.IdentifiableObjectManager; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.render.RenderFormat; +import org.hisp.dhis.render.RenderService; +import org.hisp.dhis.user.UserService; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Morten Olav Hansen + */ +public class ObjectBundleServiceFavoritesTest + extends DhisSpringTest +{ + @Autowired + private ObjectBundleService objectBundleService; + + @Autowired + private IdentifiableObjectManager manager; + + @Autowired + private RenderService _renderService; + + @Autowired + private UserService _userService; + + @Override + protected void setUpTest() throws Exception + { + renderService = _renderService; + userService = _userService; + } + + @Test + @Ignore + public void testCreateMetadataWithCharts1() throws IOException + { + Map, List> metadata = renderService.fromMetadata( + new ClassPathResource( "dxf2/metadata_with_charts1.json" ).getInputStream(), RenderFormat.JSON ); + + ObjectBundleParams params = new ObjectBundleParams(); + params.setObjectBundleMode( ObjectBundleMode.COMMIT ); + params.setImportMode( ImportStrategy.CREATE_AND_UPDATE ); + params.setObjects( metadata ); + + ObjectBundle bundle = objectBundleService.create( params ); + ObjectBundleValidation validate = objectBundleService.validate( bundle ); + assertTrue( validate.getObjectErrorReports().isEmpty() ); + objectBundleService.commit( bundle ); + + List dataSets = manager.getAll( DataSet.class ); + List organisationUnits = manager.getAll( OrganisationUnit.class ); + List dataElements = manager.getAll( DataElement.class ); + List charts = manager.getAll( Chart.class ); + + assertEquals( 2, dataSets.size() ); + assertEquals( 1, organisationUnits.size() ); + assertEquals( 4, dataElements.size() ); + assertEquals( 2, charts.size() ); + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/dxf2/metadata_with_charts1.json' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/dxf2/metadata_with_charts1.json 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/dxf2/metadata_with_charts1.json 2016-03-15 08:49:11 +0000 @@ -0,0 +1,560 @@ +{ + "organisationUnitLevels": [ + { + "lastUpdated": "2016-03-14T10:31:05.867+0000", + "level": 1, + "name": "Level 1", + "id": "LEN4A8VwYz6", + "created": "2016-03-14T10:31:05.866+0000" + } + ], + "categoryOptionCombos": [ + { + "categoryOptions": [ + { + "id": "xYerKDKCefk" + } + ], + "name": "default", + "code": "default", + "created": "2016-03-14T10:26:13.837+0000", + "id": "HllvX50cXC0", + "ignoreApproval": false, + "categoryCombo": { + "id": "bjDvmb4bfuf" + }, + "lastUpdated": "2016-03-14T10:26:13.837+0000" + } + ], + "categories": [ + { + "dataDimensionType": "DISAGGREGATION", + "name": "default", + "categoryOptions": [ + { + "id": "xYerKDKCefk" + } + ], + "lastUpdated": "2016-03-14T10:26:14.040+0000", + "publicAccess": "--------", + "dataDimension": true, + "code": "default", + "created": "2016-03-14T10:26:13.834+0000", + "userGroupAccesses": [ ], + "id": "GLevLNI9wkl" + } + ], + "dataElements": [ + { + "zeroIsSignificant": false, + "domainType": "AGGREGATE", + "created": "2016-03-14T10:28:24.014+0000", + "code": "DataElementCodeA", + "aggregationType": "SUM", + "lastUpdated": "2016-03-14T10:28:24.019+0000", + "name": "DataElementA", + "userGroupAccesses": [ ], + "attributeValues": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "id": "L5kP66sGI1q", + "aggregationLevels": [ ], + "categoryCombo": { + "id": "bjDvmb4bfuf" + }, + "publicAccess": "rw------", + "shortName": "DataElementShortA", + "valueType": "NUMBER" + }, + { + "name": "DataElementB", + "aggregationLevels": [ ], + "attributeValues": [ ], + "userGroupAccesses": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "id": "c6CtsJCClHn", + "valueType": "NUMBER", + "shortName": "DataElementShortB", + "publicAccess": "rw------", + "categoryCombo": { + "id": "bjDvmb4bfuf" + }, + "zeroIsSignificant": false, + "domainType": "AGGREGATE", + "created": "2016-03-14T10:28:44.117+0000", + "code": "DataElementCodeB", + "lastUpdated": "2016-03-14T10:28:44.118+0000", + "aggregationType": "SUM" + }, + { + "code": "DataElementCodeC", + "created": "2016-03-14T10:29:04.513+0000", + "aggregationType": "SUM", + "lastUpdated": "2016-03-14T10:29:04.516+0000", + "zeroIsSignificant": false, + "domainType": "AGGREGATE", + "aggregationLevels": [ ], + "attributeValues": [ ], + "userGroupAccesses": [ ], + "id": "qjHP8fHrPtp", + "user": { + "id": "M5zQapPyTZI" + }, + "shortName": "DataElementShortC", + "valueType": "NUMBER", + "categoryCombo": { + "id": "bjDvmb4bfuf" + }, + "publicAccess": "rw------", + "name": "DataElementC" + }, + { + "name": "DataElementD", + "categoryCombo": { + "id": "bjDvmb4bfuf" + }, + "publicAccess": "rw------", + "shortName": "DataElementShortD", + "valueType": "NUMBER", + "userGroupAccesses": [ ], + "attributeValues": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "id": "QvcHWEhvyJz", + "aggregationLevels": [ ], + "domainType": "AGGREGATE", + "zeroIsSignificant": false, + "aggregationType": "SUM", + "lastUpdated": "2016-03-14T10:29:20.649+0000", + "created": "2016-03-14T10:29:20.647+0000", + "code": "DataElementCodeD" + } + ], + "charts": [ + { + "id": "LR06Bqu0Rur", + "organisationUnitGroups": [ ], + "categoryOptionGroups": [ ], + "regression": false, + "dataElementGroups": [ ], + "organisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "categoryDimensions": [ ], + "dataDimensionItems": [ + { + "dataElement": { + "id": "L5kP66sGI1q" + }, + "dataDimensionItemType": "AGGREGATE_DATA_ELEMENT" + }, + { + "dataDimensionItemType": "AGGREGATE_DATA_ELEMENT", + "dataElement": { + "id": "c6CtsJCClHn" + } + } + ], + "itemOrganisationUnitGroups": [ ], + "created": "2016-03-14T10:54:15.592+0000", + "externalAccess": false, + "hideSubtitle": false, + "periods": [ ], + "userOrganisationUnitGrandChildren": false, + "relativePeriods": { + "last12Months": false, + "monthsThisYear": false, + "lastWeek": false, + "thisMonth": false, + "last5Years": false, + "thisFinancialYear": false, + "last6Months": true, + "last4Quarters": false, + "quartersLastYear": false, + "last6BiMonths": false, + "lastMonth": false, + "last3Months": false, + "lastQuarter": false, + "monthsLastYear": false, + "lastSixMonth": false, + "lastBimonth": false, + "lastFinancialYear": false, + "thisQuarter": false, + "last2SixMonths": false, + "thisWeek": false, + "thisYear": false, + "lastYear": false, + "last52Weeks": false, + "quartersThisYear": false, + "last4Weeks": false, + "last12Weeks": false, + "thisSixMonth": false, + "thisBimonth": false, + "last5FinancialYears": false + }, + "filterDimensions": [ + "ou" + ], + "aggregationType": "DEFAULT", + "hideEmptyRows": false, + "completedOnly": false, + "organisationUnitLevels": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "userGroupAccesses": [ ], + "hideLegend": false, + "sortOrder": 0, + "hideTitle": false, + "publicAccess": "rw------", + "type": "COLUMN", + "series": "dx", + "name": "ChartA", + "showData": true, + "category": "pe", + "lastUpdated": "2016-03-14T10:54:15.593+0000", + "userOrganisationUnitChildren": false, + "userOrganisationUnit": false + }, + { + "hideSubtitle": false, + "externalAccess": false, + "created": "2016-03-14T10:54:39.655+0000", + "periods": [ ], + "relativePeriods": { + "last4Quarters": false, + "last6BiMonths": false, + "lastMonth": false, + "quartersLastYear": false, + "last3Months": false, + "lastQuarter": false, + "monthsLastYear": false, + "lastSixMonth": false, + "last2SixMonths": false, + "lastBimonth": false, + "lastFinancialYear": false, + "thisQuarter": false, + "thisWeek": false, + "lastYear": false, + "thisYear": false, + "last12Months": false, + "monthsThisYear": false, + "lastWeek": true, + "thisMonth": false, + "last5Years": false, + "thisFinancialYear": false, + "last6Months": false, + "last4Weeks": false, + "last12Weeks": false, + "thisSixMonth": false, + "thisBimonth": false, + "last5FinancialYears": false, + "last52Weeks": false, + "quartersThisYear": false + }, + "userOrganisationUnitGrandChildren": false, + "aggregationType": "DEFAULT", + "filterDimensions": [ + "ou" + ], + "hideEmptyRows": false, + "completedOnly": false, + "organisationUnitGroups": [ ], + "id": "y6lH8sHglwg", + "categoryOptionGroups": [ ], + "regression": false, + "organisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "dataElementGroups": [ ], + "itemOrganisationUnitGroups": [ ], + "dataDimensionItems": [ + { + "dataElement": { + "id": "qjHP8fHrPtp" + }, + "dataDimensionItemType": "AGGREGATE_DATA_ELEMENT" + }, + { + "dataDimensionItemType": "AGGREGATE_DATA_ELEMENT", + "dataElement": { + "id": "QvcHWEhvyJz" + } + } + ], + "categoryDimensions": [ ], + "category": "pe", + "lastUpdated": "2016-03-14T10:54:39.655+0000", + "userOrganisationUnitChildren": false, + "userOrganisationUnit": false, + "userGroupAccesses": [ ], + "organisationUnitLevels": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "hideTitle": false, + "sortOrder": 0, + "hideLegend": false, + "publicAccess": "rw------", + "type": "COLUMN", + "name": "ChartB", + "series": "dx", + "showData": true + } + ], + "organisationUnits": [ + { + "name": "Country", + "uuid": "7077b124-4e48-4f3c-adf8-e654eb7876a4", + "description": "", + "created": "2016-03-14T10:26:44.419+0000", + "attributeValues": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "id": "Ku3wiLhVBkw", + "path": "/Ku3wiLhVBkw", + "featureType": "NONE", + "lastUpdated": "2016-03-14T10:26:44.434+0000", + "openingDate": "2016-03-14", + "shortName": "Country" + } + ], + "userRoles": [ + { + "lastUpdated": "2016-03-14T10:26:27.162+0000", + "publicAccess": "--------", + "programs": [ ], + "code": "Superuser", + "created": "2016-03-14T10:26:27.162+0000", + "userGroupAccesses": [ ], + "id": "yrB6vc5Ip3r", + "dataSets": [ ], + "description": "Superuser", + "name": "Superuser", + "authorities": [ + "F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS", + "ALL", + "F_USERGROUP_MANAGING_RELATIONSHIPS_ADD", + "F_REPORTTABLE_PUBLIC_ADD", + "F_TRACKED_ENTITY_INSTANCE_DELETE", + "F_USER_GROUPS_READ_ONLY_ADD_MEMBERS", + "F_MAP_PUBLIC_ADD", + "F_USER_ADD_WITHIN_MANAGED_GROUP", + "F_TRACKED_ENTITY_INSTANCE_SEARCH", + "F_PROGRAM_ENROLLMENT", + "F_REPORTTABLE_EXTERNAL", + "F_SQLVIEW_EXTERNAL", + "F_GIS_ADMIN", + "F_REPLICATE_USER", + "F_INSERT_CUSTOM_JS_CSS", + "F_DASHBOARD_PUBLIC_ADD", + "F_METADATA_IMPORT", + "F_CHART_PUBLIC_ADD", + "F_VIEW_UNAPPROVED_DATA", + "F_CHART_EXTERNAL", + "F_USERGROUP_MANAGING_RELATIONSHIPS_VIEW", + "F_METADATA_EXPORT", + "F_PROGRAM_UNENROLLMENT", + "F_APPROVE_DATA", + "F_ACCEPT_DATA_LOWER_LEVELS", + "F_TRACKED_ENTITY_INSTANCE_ADD", + "F_USERGROUP_PUBLIC_ADD", + "F_OAUTH2_CLIENT_MANAGE", + "F_TRACKED_ENTITY_DATAVALUE_ADD", + "F_PROGRAM_DASHBOARD_CONFIG_ADMIN", + "F_MAP_EXTERNAL", + "F_APPROVE_DATA_LOWER_LEVELS", + "F_TRACKED_ENTITY_DATAVALUE_DELETE" + ] + } + ], + "categoryOptions": [ + { + "shortName": "default", + "lastUpdated": "2016-03-14T10:26:13.843+0000", + "publicAccess": "--------", + "code": "default", + "userGroupAccesses": [ ], + "attributeValues": [ ], + "id": "xYerKDKCefk", + "created": "2016-03-14T10:26:13.821+0000", + "organisationUnits": [ ], + "name": "default" + } + ], + "trackedEntities": [ + { + "lastUpdated": "2016-03-13T17:00:00.000+0000", + "description": "Person", + "name": "Person", + "code": "Person", + "attributeValues": [ ], + "created": "2016-03-13T17:00:00.000+0000", + "id": "MCPQUTHX1Ze" + } + ], + "users": [ + { + "surname": "admin", + "code": "admin", + "created": "2016-03-14T10:26:27.141+0000", + "id": "M5zQapPyTZI", + "attributeValues": [ ], + "lastUpdated": "2016-03-14T10:27:40.595+0000", + "organisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "firstName": "admin", + "userCredentials": { + "created": "2016-03-14T10:26:27.177+0000", + "code": "admin", + "invitation": false, + "externalAuth": false, + "lastUpdated": "2016-03-14T10:27:40.592+0000", + "passwordLastUpdated": "2016-03-14T10:26:27.178+0000", + "catDimensionConstraints": [ ], + "username": "admin", + "disabled": false, + "selfRegistered": false, + "user": { + "id": "M5zQapPyTZI" + }, + "id": "Wzwcfu5Wwvx", + "lastLogin": "2016-03-14T10:26:27.177+0000", + "cogsDimensionConstraints": [ ], + "userRoles": [ + { + "id": "yrB6vc5Ip3r" + } + ], + "userInfo": { + "id": "M5zQapPyTZI" + } + }, + "dataViewOrganisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "teiSearchOrganisationUnits": [ ] + } + ], + "categoryCombos": [ + { + "name": "default", + "skipTotal": false, + "dataDimensionType": "DISAGGREGATION", + "userGroupAccesses": [ ], + "created": "2016-03-14T10:26:13.836+0000", + "id": "bjDvmb4bfuf", + "code": "default", + "lastUpdated": "2016-03-14T10:26:13.839+0000", + "categories": [ + { + "id": "GLevLNI9wkl" + } + ], + "publicAccess": "--------" + } + ], + "dataSets": [ + { + "code": "DataSetCodeA", + "created": "2016-03-14T10:29:58.832+0000", + "version": 0, + "periodType": "Monthly", + "fieldCombinationRequired": false, + "lastUpdated": "2016-03-14T10:30:54.761+0000", + "mobile": false, + "dataElementDecoration": false, + "noValueRequiresComment": false, + "indicators": [ ], + "attributeValues": [ ], + "id": "EhbRc6ME5fb", + "userGroupAccesses": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "validCompleteOnly": false, + "openFuturePeriods": 0, + "expiryDays": 0, + "publicAccess": "rw------", + "skipOffline": false, + "dataElements": [ + { + "id": "c6CtsJCClHn" + }, + { + "id": "L5kP66sGI1q" + } + ], + "shortName": "DataSetShortA", + "timelyDays": 0, + "renderAsTabs": false, + "organisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "name": "DataSetA", + "notifyCompletingUser": false, + "renderHorizontally": false, + "compulsoryDataElementOperands": [ ] + }, + { + "notifyCompletingUser": false, + "compulsoryDataElementOperands": [ ], + "renderHorizontally": false, + "timelyDays": 0, + "renderAsTabs": false, + "organisationUnits": [ + { + "id": "Ku3wiLhVBkw" + } + ], + "name": "DataSetB", + "skipOffline": false, + "expiryDays": 0, + "publicAccess": "rw------", + "shortName": "DataSetShortB", + "dataElements": [ + { + "id": "QvcHWEhvyJz" + }, + { + "id": "qjHP8fHrPtp" + } + ], + "attributeValues": [ ], + "id": "kS0QOOZbxEe", + "userGroupAccesses": [ ], + "user": { + "id": "M5zQapPyTZI" + }, + "validCompleteOnly": false, + "openFuturePeriods": 0, + "mobile": false, + "dataElementDecoration": false, + "indicators": [ ], + "noValueRequiresComment": false, + "lastUpdated": "2016-03-14T10:31:00.598+0000", + "code": "DataSetCodeB", + "created": "2016-03-14T10:29:58.832+0000", + "version": 0, + "periodType": "Monthly", + "fieldCombinationRequired": false + } + ], + "date": "2016-03-14T10:55:35.567+0000" +}