Project

General

Profile

Revision d88833a9

IDd88833a999f271bfa5cc70106fd11e820c700f0d
Parent 0c1dd4b9
Child 264a8b3c

Added by Patrick Plitzner over 1 year ago

ref #8011 Fix serialization problem

  • Use Map.Entry instead of hibernate.envers.Pair

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java
8 8
*/
9 9
package eu.etaxonomy.cdm.api.service.dto;
10 10

  
11
import java.io.Serializable;
12
import java.util.AbstractMap;
11 13
import java.util.ArrayList;
12 14
import java.util.Comparator;
13 15
import java.util.HashSet;
......
15 17
import java.util.Set;
16 18
import java.util.TreeSet;
17 19

  
18
import org.hibernate.envers.tools.Pair;
19

  
20 20
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
21 21
import eu.etaxonomy.cdm.model.description.DescriptionBase;
22 22
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
41 41

  
42 42
    private static final long serialVersionUID = -7597690654462090732L;
43 43

  
44
    private TreeSet<Pair<String, String>> characterData;
44
    private TreeSet<AbstractMap.SimpleEntry<String, String>> characterData;
45 45
    private DerivateDataDTO derivateDataDTO;
46 46
    protected String taxonName;
47 47
    protected String listLabel;
......
139 139
    }
140 140

  
141 141
    public void setSpecimenTypeDesignations(Set<SpecimenTypeDesignation> specimenTypeDesignations) {
142
        this.specimenTypeDesignations = new HashSet();
142
        this.specimenTypeDesignations = new HashSet<>();
143 143
        for (SpecimenTypeDesignation typeDes: specimenTypeDesignations){
144 144
            this.specimenTypeDesignations.add(typeDes);
145 145
        }
......
173 173
    /**
174 174
     * @return the characterData
175 175
     */
176
    public TreeSet<Pair<String, String>> getCharacterData() {
176
    public TreeSet<AbstractMap.SimpleEntry<String, String>> getCharacterData() {
177 177
        return characterData;
178 178
    }
179 179

  
180 180
    public void addCharacterData(String character, String state){
181 181
      if(characterData==null){
182
          characterData = new TreeSet<Pair<String,String>>(new Comparator<Pair<String,String>>() {
182
          characterData = new TreeSet<AbstractMap.SimpleEntry<String,String>>(new PairComparator());
183
      }
184
      characterData.add(new AbstractMap.SimpleEntry<>(character, state));
185
    }
183 186

  
184
            @Override
185
            public int compare(Pair<String, String> o1, Pair<String, String> o2) {
186
                if(o1==null && o2!=null){
187
                    return -1;
188
                }
189
                if(o1!=null && o2==null){
190
                    return 1;
191
                }
192
                if(o1!=null && o2!=null){
193
                    return o1.getFirst().compareTo(o2.getFirst());
194
                }
195
                return 0;
187
    private class PairComparator implements Comparator<AbstractMap.SimpleEntry<String,String>>, Serializable {
188

  
189
        private static final long serialVersionUID = -8589392050761963540L;
190

  
191
        @Override
192
        public int compare(AbstractMap.SimpleEntry<String, String> o1, AbstractMap.SimpleEntry<String, String> o2) {
193
            if(o1==null && o2!=null){
194
                return -1;
196 195
            }
197
        });
198
      }
199
      characterData.add(new Pair<String, String>(character, state));
196
            if(o1!=null && o2==null){
197
                return 1;
198
            }
199
            if(o1!=null && o2!=null){
200
                return o1.getKey().compareTo(o2.getKey());
201
            }
202
            return 0;
203
        }
200 204
    }
201 205

  
202 206
    /**
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java
101 101
        detailImageUuids.add(uuid);
102 102
    }
103 103

  
104
    public class MolecularData{
104
    public class MolecularData implements Serializable{
105

  
106
        private static final long serialVersionUID = -3509828381796659200L;
107

  
105 108
        private final Link providerLink;
106 109
        private List<ContigFile> contigFiles;
107 110

  
......
129 132

  
130 133
    }
131 134

  
132
    public class ContigFile{
135
    public class ContigFile implements Serializable{
136

  
133 137
        private final Link contigLink;
134 138
        private List<Link> primerLinks;
135 139

  
......
154 158

  
155 159
    }
156 160

  
157
    public static class Link{
161
    public static class Link implements Serializable{
162

  
163
        private static final long serialVersionUID = 6635385359662624579L;
164

  
158 165
        private String linkText;
159 166
        private URI uri;
160 167

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/PreservedSpecimenDTO.java
9 9
package eu.etaxonomy.cdm.api.service.dto;
10 10

  
11 11
import java.net.URI;
12
import java.util.AbstractMap;
12 13
import java.util.ArrayList;
13 14
import java.util.HashMap;
14 15
import java.util.List;
15 16
import java.util.Map;
16 17
import java.util.UUID;
17 18

  
18
import org.hibernate.envers.tools.Pair;
19

  
20 19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
21 20
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
22 21
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
......
35 34
    private String accessionNumber;
36 35
    private URI preferredStableUri;
37 36

  
38
    private List<Pair<UUID, String>> associatedTaxa;
37
    private List<AbstractMap.SimpleEntry<UUID, String>> associatedTaxa;
39 38
    private Map<String, List<String>> types;
40 39

  
41 40

  
......
116 115
        types.put(typeStatus, typedTaxa);
117 116
    }
118 117

  
119
    public List<Pair<UUID, String>> getAssociatedTaxa() {
118
    public List<AbstractMap.SimpleEntry<UUID, String>> getAssociatedTaxa() {
120 119
        return associatedTaxa;
121 120
    }
122 121
    public void addAssociatedTaxon(Taxon taxon){
123 122
        if(associatedTaxa==null){
124
            associatedTaxa = new ArrayList<Pair<UUID, String>>();
123
            associatedTaxa = new ArrayList<AbstractMap.SimpleEntry<UUID, String>>();
125 124
        }
126
        associatedTaxa.add(new Pair<UUID, String>(taxon.getUuid(), taxon.getTitleCache()));
125
        associatedTaxa.add(new AbstractMap.SimpleEntry<UUID, String>(taxon.getUuid(), taxon.getTitleCache()));
127 126
    }
128 127

  
129 128
    public void setPreferredStableUri(URI preferredStableUri) {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)