Project

General

Profile

Revision ba5f20eb

IDba5f20eb7e9fe2f87bace2832819dc8dc269ca23
Parent 68baf399
Child a9fcc7a1

Added by Katja Luther over 3 years ago

fix problem with titleCache comparator in user and group bulkeditor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
9 9
package eu.etaxonomy.taxeditor.bulkeditor.input;
10 10

  
11 11
import java.util.ArrayList;
12
import java.util.Comparator;
12 13
import java.util.HashMap;
13 14
import java.util.HashSet;
14 15
import java.util.List;
......
36 37
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
37 38
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
38 39
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider;
40
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator;
39 41
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
40 42
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
41 43
import eu.etaxonomy.taxeditor.event.EventUtility;
......
108 110

  
109 111
	protected abstract T loadEntity(UUID entityUuid);
110 112

  
113
	public Comparator<T> getTitleComparator(){
114
	    return new TitleCacheComparator();
115
	}
116

  
111 117
	public void setMergeTarget(T t){
112 118
	    markedMergeTarget = t;
113 119
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12 12
import java.util.Arrays;
13
import java.util.Comparator;
13 14
import java.util.List;
14 15
import java.util.UUID;
15 16

  
......
24 25
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
25 26
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
26 27
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
28
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.GroupNameComparator;
27 29
import eu.etaxonomy.taxeditor.store.CdmStore;
28 30

  
29 31
/**
......
124 126
		return HibernateProxyHelper.deproxy(CdmStore.getService(IAgentService.class).load(entityUuid, propertyPaths), Group.class);
125 127
	}
126 128

  
129
	@Override
130
	public Comparator<Group> getTitleComparator(){
131
        return new GroupNameComparator();
132
    }
133

  
134

  
127 135

  
128 136

  
129 137
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12 12
import java.util.Arrays;
13
import java.util.Comparator;
13 14
import java.util.List;
14 15
import java.util.UUID;
15 16

  
......
22 23
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
23 24
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
24 25
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.UserCreator;
26
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.UserNameComparator;
25 27
import eu.etaxonomy.taxeditor.store.CdmStore;
26 28

  
27 29
/**
......
123 125
		return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
124 126
	}
125 127

  
128
	@Override
129
	public Comparator<User> getTitleComparator(){
130
        return new UserNameComparator();
131
    }
132

  
133

  
126 134

  
127 135

  
128 136
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/GroupNameComparator.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider;
10

  
11
import java.util.Comparator;
12

  
13
import eu.etaxonomy.cdm.model.common.Group;
14

  
15
/**
16
 * @author k.luther
17
 * @since 02.07.2018
18
 *
19
 */
20
public class GroupNameComparator implements Comparator<Group> {
21
    private boolean fIgnoreCase;
22
    /**
23
     * {@inheritDoc}
24
     */
25
    @Override
26
    public int compare(Group o1, Group o2) {
27
        String groupName0 = o1.getName();
28
        String groupName1 = o2.getName();
29
        if (groupName0 == null && groupName1 == null) {
30
            return 0;
31
        }
32
        if (groupName0 == null) {
33
            return -1;
34
        }
35
        if (groupName1 == null) {
36
            return 1;
37
        }
38
        int result =  fIgnoreCase ? groupName0.compareToIgnoreCase(groupName1) :
39
            groupName0.compareTo(groupName1);
40

  
41
        if (result == 0){
42
            result = o1.getUuid().compareTo(o2.getUuid());
43
        }
44
        return result;
45
    }
46

  
47
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/UserNameComparator.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider;
10

  
11
import java.util.Comparator;
12

  
13
import eu.etaxonomy.cdm.model.common.User;
14

  
15
/**
16
 * @author k.luther
17
 * @since 02.07.2018
18
 *
19
 */
20
public class UserNameComparator implements Comparator<User> {
21
    private boolean fIgnoreCase;
22
    /**
23
     * {@inheritDoc}
24
     */
25
    @Override
26
    public int compare(User user0, User user1) {
27
        String userName0 = user0.getUsername();
28
        String userName1 = user1.getUsername();
29
        if (userName0 == null && userName1 == null) {
30
            return 0;
31
        }
32
        if (userName0 == null) {
33
            return -1;
34
        }
35
        if (userName1 == null) {
36
            return 1;
37
        }
38
        int result =  fIgnoreCase ? userName0.compareToIgnoreCase(userName1) :
39
            userName0.compareTo(userName1);
40

  
41
        if (result == 0){
42
            result = user0.getUuid().compareTo(user1.getUuid());
43
        }
44
        return result;
45

  
46
    }
47

  
48
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)