1
package org.hisp.dhis.importexport.converter;
3
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
4
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
7
* Copyright (c) 2004-2007, University of Oslo
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions are met:
12
* * Redistributions of source code must retain the above copyright notice, this
13
* list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above copyright notice,
15
* this list of conditions and the following disclaimer in the documentation
16
* and/or other materials provided with the distribution.
17
* * Neither the name of the HISP project nor the names of its contributors may
18
* be used to endorse or promote products derived from this software without
19
* specific prior written permission.
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
public class AbstractOrganisationUnitGroupConverter
34
extends AbstractConverter<OrganisationUnitGroup>
36
protected OrganisationUnitGroupService organisationUnitGroupService;
38
// -------------------------------------------------------------------------
40
// -------------------------------------------------------------------------
42
protected void importUnique( OrganisationUnitGroup object )
44
batchHandler.addObject( object );
47
protected void importMatching( OrganisationUnitGroup object, OrganisationUnitGroup match )
49
match.setUuid( object.getUuid() );
50
match.setName( object.getName() );
52
organisationUnitGroupService.updateOrganisationUnitGroup( match );
55
protected OrganisationUnitGroup getMatching( OrganisationUnitGroup object )
57
return organisationUnitGroupService.getOrganisationUnitGroupByName( object.getName() );
60
protected boolean isIdentical( OrganisationUnitGroup object, OrganisationUnitGroup existing )
62
return object.getName().equals( existing.getName() );