Project

General

Profile

« Previous | Next » 

Revision db727ae6

Added by Andreas Müller almost 6 years ago

fix #7405 Rename WorkingSet to DescriptiveDataSet

View differences:

cdmlib-cache/src/main/resources/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml
122 122
      <mapping class="eu.etaxonomy.cdm.model.description.TaxonNameDescription"/>
123 123
      <mapping class="eu.etaxonomy.cdm.model.description.TextData"/>
124 124
      <mapping class="eu.etaxonomy.cdm.model.description.TextFormat"/>
125
      <mapping class="eu.etaxonomy.cdm.model.description.WorkingSet"/>
125
      <mapping class="eu.etaxonomy.cdm.model.description.DescriptiveDataSet"/>
126 126
      <!-- Location Package -->
127 127
      <mapping class="eu.etaxonomy.cdm.model.location.NamedArea"/>
128 128
      <mapping class="eu.etaxonomy.cdm.model.location.NamedAreaLevel"/>
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDImport.java
59 59
import eu.etaxonomy.cdm.model.common.TermVocabulary;
60 60
import eu.etaxonomy.cdm.model.common.VersionableEntity;
61 61
import eu.etaxonomy.cdm.model.description.CategoricalData;
62
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
62 63
import eu.etaxonomy.cdm.model.description.Feature;
63 64
import eu.etaxonomy.cdm.model.description.FeatureNode;
64 65
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
70 71
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
71 72
import eu.etaxonomy.cdm.model.description.TaxonDescription;
72 73
import eu.etaxonomy.cdm.model.description.TextData;
73
import eu.etaxonomy.cdm.model.description.WorkingSet;
74 74
import eu.etaxonomy.cdm.model.location.NamedArea;
75 75
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
76 76
import eu.etaxonomy.cdm.model.media.ImageFile;
......
132 132
	private Reference sourceReference = null;
133 133

  
134 134
	private Language datasetLanguage = null;
135
	private WorkingSet workingSet = null;
135
	private DescriptiveDataSet descriptiveDataSet = null;
136 136

  
137 137
	private final Namespace xmlNamespace = Namespace.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
138 138

  
......
269 269

  
270 270
		//new
271 271
		Representation representation = Representation.NewInstance(detail, label, null, datasetLanguage);
272
		workingSet.addRepresentation(representation);
272
		descriptiveDataSet.addRepresentation(representation);
273 273

  
274 274

  
275 275
		//old
......
569 569
	// imports the complete dataset information
570 570
	protected void importDataset(Element elDataset, Namespace sddNamespace, SDDImportState state){			// <Dataset xml:lang="en-us">
571 571

  
572
		workingSet = WorkingSet.NewInstance();
572
	    descriptiveDataSet = DescriptiveDataSet.NewInstance();
573 573
		importDatasetLanguage(elDataset,state);
574 574
		importDatasetRepresentation(elDataset, sddNamespace);
575 575
		importRevisionData(elDataset, sddNamespace);
......
678 678
		for (FeatureTree featureTree : featureTrees) {
679 679
			getFeatureTreeService().save(featureTree);
680 680
		}
681
		getWorkingSetService().save(workingSet);
681
		getDescriptiveDataSetService().save(descriptiveDataSet);
682 682
		for (Classification classification : classifications) {
683 683
			getClassificationService().save(classification);
684 684
		}
......
1198 1198
				taxon.addDescription(taxonDescription);
1199 1199
			}
1200 1200
//
1201
			workingSet.addDescription(taxonDescription);
1201
			descriptiveDataSet.addDescription(taxonDescription);
1202 1202

  
1203 1203
//OLD			taxonDescription.setDescriptiveSystem(featureSet);
1204 1204

  
......
1761 1761
						handleCharacterNodes(sddNamespace, root, elNodes);
1762 1762
					}
1763 1763
					featureTrees.add(featureTree);
1764
					if (workingSet.getDescriptiveSystem() != null){
1764
					if (descriptiveDataSet.getDescriptiveSystem() != null){
1765 1765
						//TODO how to handle multiple
1766 1766
						logger.warn("Multiple feature trees not yet supported");
1767 1767
					}else{
1768
						workingSet.setDescriptiveSystem(featureTree);
1768
					    descriptiveDataSet.setDescriptiveSystem(featureTree);
1769 1769
					}
1770 1770
				}
1771 1771

  
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/database/ClearDBDataSet.xml
442 442
  <USERACCOUNT_AUD />
443 443
  <USERACCOUNT_GRANTEDAUTHORITYIMPL/>
444 444
  <USERACCOUNT_PERMISSIONGROUP/>
445
  <WORKINGSET/>
446
  <WORKINGSET_ANNOTATION/>
447
  <WORKINGSET_ANNOTATION_AUD/>
448
  <WORKINGSET_AUD/>
449
  <WORKINGSET_DESCRIPTIONBASE/>
450
  <WORKINGSET_DESCRIPTIONBASE_AUD/>
451
  <WORKINGSET_MARKER/>
452
  <WORKINGSET_MARKER_AUD/>
453
  <WORKINGSET_REPRESENTATION/>
454
  <WORKINGSET_REPRESENTATION_AUD/>
445
  <DESCRIPTIVEDATASET/>
446
  <DESCRIPTIVEDATASET_ANNOTATION/>
447
  <DESCRIPTIVEDATASET_ANNOTATION_AUD/>
448
  <DESCRIPTIVEDATASET_AUD/>
449
  <DESCRIPTIVEDATASET_DESCRIPTIONBASE/>
450
  <DESCRIPTIVEDATASET_DESCRIPTIONBASE_AUD/>
451
  <DESCRIPTIVEDATASET_MARKER/>
452
  <DESCRIPTIVEDATASET_MARKER_AUD/>
453
  <DESCRIPTIVEDATASET_REPRESENTATION/>
454
  <DESCRIPTIVEDATASET_REPRESENTATION_AUD/>
455 455
  <MULTIACCESSKEY_COVEREDTAXON/>
456 456
  <MULTIACCESSKEY_COVEREDTAXON_AUD/>
457 457
</dataset>
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml
457 457
<USERACCOUNT_AUD />
458 458
<USERACCOUNT_GRANTEDAUTHORITYIMPL/>
459 459
<USERACCOUNT_PERMISSIONGROUP/>
460
<WORKINGSET/>
461
<WORKINGSET_ANNOTATION/>
462
<WORKINGSET_ANNOTATION_AUD/>
463
<WORKINGSET_AUD/>
464
<WORKINGSET_DESCRIPTIONBASE/>
465
<WORKINGSET_DESCRIPTIONBASE_AUD/>
466
<WORKINGSET_MARKER/>
467
<WORKINGSET_MARKER_AUD/>
468
<WORKINGSET_REPRESENTATION/>
469
<WORKINGSET_REPRESENTATION_AUD/>
460
<DESCRIPTIVEDATASET/>
461
<DESCRIPTIVEDATASET_ANNOTATION/>
462
<DESCRIPTIVEDATASET_ANNOTATION_AUD/>
463
<DESCRIPTIVEDATASET_AUD/>
464
<DESCRIPTIVEDATASET_DESCRIPTIONBASE/>
465
<DESCRIPTIVEDATASET_DESCRIPTIONBASE_AUD/>
466
<DESCRIPTIVEDATASET_MARKER/>
467
<DESCRIPTIVEDATASET_MARKER_AUD/>
468
<DESCRIPTIVEDATASET_REPRESENTATION/>
469
<DESCRIPTIVEDATASET_REPRESENTATION_AUD/>
470 470
</dataset>
471 471

  
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/specimen/abcd206/in/SpecimenImportConfiguratorTest.doInvoke2.xml
33 33
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="TaxonNode" NEXT_VAL="3020"/>
34 34
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="TermVocabulary" NEXT_VAL="55"/>
35 35
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="UserAccount" NEXT_VAL="3001"/>
36
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="WorkingSet" NEXT_VAL="3001"/>
36
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="DescriptiveDataSet" NEXT_VAL="3001"/>
37 37
</dataset>
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/package-info.java
203 203
        @MetaValue(value = "Primer", targetEntity = Primer.class),
204 204
        @MetaValue(value = "TaxonNode", targetEntity = TaxonNode.class),
205 205
        @MetaValue(value = "TaxonNodeAgentRelation", targetEntity = TaxonNodeAgentRelation.class),
206
        @MetaValue(value = "WorkingSet", targetEntity = WorkingSet.class),
206
        @MetaValue(value = "DescriptiveDataSet", targetEntity = DescriptiveDataSet.class),
207 207
        @MetaValue(value = "MultiAccessKey", targetEntity = MultiAccessKey.class),
208 208

  
209 209
        @MetaValue(value = "DescriptionElementSource", targetEntity = DescriptionElementSource.class),
......
229 229
import eu.etaxonomy.cdm.model.description.CategoricalData;
230 230
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
231 231
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
232
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
232 233
import eu.etaxonomy.cdm.model.description.Distribution;
233 234
import eu.etaxonomy.cdm.model.description.Feature;
234 235
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
248 249
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
249 250
import eu.etaxonomy.cdm.model.description.TextData;
250 251
import eu.etaxonomy.cdm.model.description.TextFormat;
251
import eu.etaxonomy.cdm.model.description.WorkingSet;
252 252
import eu.etaxonomy.cdm.model.location.Country;
253 253
import eu.etaxonomy.cdm.model.location.NamedArea;
254 254
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptionBase.java
72 72
@XmlType(name = "DescriptionBase", propOrder = {
73 73
    "describedSpecimenOrObservation",
74 74
    "descriptionSources",
75
    "workingSets",
75
    "descriptiveDataSets",
76 76
    "descriptionElements",
77 77
    "imageGallery",
78 78
    "isDefault"
......
106 106
    @ManyToMany(fetch = FetchType.LAZY)  //FIXME what is the difference between this and IdentifiableEntity.sources
107 107
    private Set<Reference> descriptionSources = new HashSet<Reference>();
108 108

  
109
    @XmlElementWrapper(name = "WorkingSets")
110
    @XmlElement(name = "WorkingSet")
109
    @XmlElementWrapper(name = "DescriptiveDataSets")
110
    @XmlElement(name = "DescriptiveDataSet")
111 111
    @XmlIDREF
112 112
    @XmlSchemaType(name = "IDREF")
113 113
    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "descriptions")
114 114
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
115
    private Set<WorkingSet> workingSets = new HashSet<WorkingSet>();
115
    private Set<DescriptiveDataSet> descriptiveDataSets = new HashSet<>();
116 116

  
117 117
    @XmlElementWrapper(name = "DescriptionElements")
118 118
    @XmlElements({
......
296 296
    }
297 297

  
298 298

  
299
    public Set<WorkingSet> getWorkingSets() {
300
        return workingSets;
299
    public Set<DescriptiveDataSet> getDescriptiveDataSets() {
300
        return descriptiveDataSets;
301 301
    }
302 302

  
303
    public boolean addWorkingSet(WorkingSet workingSet){
304
        boolean result = this.workingSets.add(workingSet);
305
        if (! workingSet.getDescriptions().contains(this)){
306
            workingSet.addDescription(this);
303
    public boolean addDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
304
        boolean result = this.descriptiveDataSets.add(descriptiveDataSet);
305
        if (! descriptiveDataSet.getDescriptions().contains(this)){
306
            descriptiveDataSet.addDescription(this);
307 307
        }
308 308
        return result;
309 309
    }
310 310

  
311
    public boolean removeWorkingSet(WorkingSet workingSet){
312
        boolean result = this.workingSets.remove(workingSet);
313
        if (workingSet.getDescriptions().contains(this)){
314
            workingSet.addDescription(this);
311
    public boolean removeDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
312
        boolean result = this.descriptiveDataSets.remove(descriptiveDataSet);
313
        if (descriptiveDataSet.getDescriptions().contains(this)){
314
            descriptiveDataSet.addDescription(this);
315 315
        }
316 316
        return result;
317 317
    }
318 318

  
319
    protected void setWorkingSets(Set<WorkingSet> workingSets) {
320
        this.workingSets = workingSets;
319
    protected void setDescriptiveDataSet(Set<DescriptiveDataSet> descriptiveDataSets) {
320
        this.descriptiveDataSets = descriptiveDataSets;
321 321
    }
322 322

  
323 323

  
......
358 358
            result = (DescriptionBase<?>)super.clone();
359 359

  
360 360
            //working set
361
            result.workingSets = new HashSet<WorkingSet>();
362
            for (WorkingSet workingSet : getWorkingSets()){
363
                workingSet.addDescription(result);
361
            result.descriptiveDataSets = new HashSet<DescriptiveDataSet>();
362
            for (DescriptiveDataSet descriptiveDataSet : getDescriptiveDataSets()){
363
                descriptiveDataSet.addDescription(result);
364 364
            }
365 365

  
366 366
            //descriptions
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptiveDataSet.java
1
/**
2
* Copyright (C) 2007 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

  
10
package eu.etaxonomy.cdm.model.description;
11

  
12
import java.util.HashSet;
13
import java.util.Iterator;
14
import java.util.List;
15
import java.util.Set;
16

  
17
import javax.persistence.Entity;
18
import javax.persistence.FetchType;
19
import javax.persistence.JoinTable;
20
import javax.persistence.ManyToMany;
21
import javax.persistence.ManyToOne;
22
import javax.persistence.OneToMany;
23
import javax.persistence.Transient;
24
import javax.validation.constraints.NotNull;
25
import javax.xml.bind.annotation.XmlAccessType;
26
import javax.xml.bind.annotation.XmlAccessorType;
27
import javax.xml.bind.annotation.XmlElement;
28
import javax.xml.bind.annotation.XmlElementWrapper;
29
import javax.xml.bind.annotation.XmlIDREF;
30
import javax.xml.bind.annotation.XmlRootElement;
31
import javax.xml.bind.annotation.XmlSchemaType;
32
import javax.xml.bind.annotation.XmlType;
33

  
34
import org.apache.log4j.Logger;
35
import org.hibernate.annotations.Cascade;
36
import org.hibernate.annotations.CascadeType;
37
import org.hibernate.envers.Audited;
38

  
39
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
40
import eu.etaxonomy.cdm.model.common.Language;
41
import eu.etaxonomy.cdm.model.common.Representation;
42
import eu.etaxonomy.cdm.model.location.NamedArea;
43
import eu.etaxonomy.cdm.model.name.Rank;
44
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
45
import eu.etaxonomy.cdm.strategy.cache.description.DescriptiveDataSetDefaultCacheStrategy;
46

  
47
/**
48
 *
49
 * The working set class allows the demarcation of a set of descriptions
50
 * associated with representations and a set of features and their
51
 * dependencies.
52
 *
53
 * @author h.fradin
54
 * @since 12.08.2009
55
 */
56

  
57
@XmlAccessorType(XmlAccessType.FIELD)
58
@XmlType(name = "DescriptiveDataSet", propOrder = {
59
    "representations",
60
    "descriptiveSystem",
61
    "descriptions",
62
    "taxonSubtreeFilter",
63
    "geoFilter",
64
    "minRank",
65
    "maxRank"
66
})
67
@XmlRootElement(name = "DescriptiveDataSet")
68
@Entity
69
@Audited
70
public class DescriptiveDataSet extends IdentifiableEntity<DescriptiveDataSetDefaultCacheStrategy> {
71
	private static final long serialVersionUID = 3256448866757415686L;
72
	private static final Logger logger = Logger.getLogger(DescriptiveDataSet.class);
73

  
74
	@XmlElementWrapper(name = "Representations")
75
	@XmlElement(name = "Representation")
76
    @OneToMany(fetch=FetchType.EAGER)
77
	@Cascade( { CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE })
78
	private Set<Representation> representations = new HashSet<>();
79

  
80
	@XmlElement(name = "DescriptiveSystem")
81
	@XmlIDREF
82
	@XmlSchemaType(name = "IDREF")
83
	@ManyToOne(fetch = FetchType.LAZY)
84
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
85
	private FeatureTree descriptiveSystem;
86

  
87
	@XmlElementWrapper(name = "Descriptions")
88
	@XmlElement(name = "Description")
89
    @XmlIDREF
90
    @XmlSchemaType(name = "IDREF")
91
    @ManyToMany(fetch = FetchType.LAZY)
92
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
93
	@NotNull
94
	private Set<DescriptionBase> descriptions = new HashSet<>();
95

  
96
    @XmlElementWrapper(name = "SubtreeTaxonFilter")
97
    @XmlElement(name = "Subtree")
98
    @XmlIDREF
99
    @XmlSchemaType(name = "IDREF")
100
    @ManyToMany(fetch = FetchType.LAZY)
101
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
102
    @NotNull
103
    //a positive filter that defines that all taxa in the subtree belong to
104
    //the dataset. If the filter is NOT set, taxa need to be explicitly defined
105
    //via the descriptions set. If the filter is set all taxa not having
106
    //a description in descriptions yet are considered to have an empty description
107
    //TODO what, if a taxon is removed from the subtree but a description exists in
108
    //descriptions
109
    private Set<TaxonNode> taxonSubtreeFilter = new HashSet<>();
110

  
111
    @XmlElementWrapper(name = "GeoFilter")
112
    @XmlElement(name = "FilteredArea")
113
    @XmlIDREF
114
    @XmlSchemaType(name = "IDREF")
115
    @ManyToMany(fetch = FetchType.LAZY)
116
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
117
    @JoinTable(name="DescriptiveDataSet_NamedArea")
118
    @NotNull
119
    private Set<NamedArea> geoFilter = new HashSet<>();
120

  
121
    @XmlElement(name = "minRank")
122
    @XmlIDREF
123
    @XmlSchemaType(name = "IDREF")
124
    @ManyToOne(fetch = FetchType.LAZY)
125
    private Rank minRank;
126

  
127
    @XmlElement(name = "maxRank")
128
    @XmlIDREF
129
    @XmlSchemaType(name = "IDREF")
130
    @ManyToOne(fetch = FetchType.LAZY)
131
    private Rank maxRank;
132

  
133
// ******************* FACTORY *********************************************/
134

  
135
	public static DescriptiveDataSet NewInstance(){
136
        return new DescriptiveDataSet();
137
    }
138

  
139

  
140
// *******************CONSTRUCTOR **********************************/
141
	/**
142
	 * Class constructor: creates a new empty working set instance.
143
	 */
144
	protected DescriptiveDataSet() {
145
		super();
146
		this.cacheStrategy = new DescriptiveDataSetDefaultCacheStrategy();
147
	}
148

  
149
// ******************** GETTER / SETTER ************************/
150

  
151

  
152
	public Set<TaxonNode> getTaxonSubtreeFilter() {
153
        return taxonSubtreeFilter;
154
    }
155

  
156
    public void setTaxonSubtreeFilter(Set<TaxonNode> taxonSubtreeFilter) {
157
        this.taxonSubtreeFilter = taxonSubtreeFilter;
158
    }
159

  
160
    public void  addTaxonSubtree(TaxonNode subtree) {
161
        this.taxonSubtreeFilter.add(subtree);
162
    }
163

  
164
    public void  removeTaxonSubtree(TaxonNode subtree) {
165
        this.taxonSubtreeFilter.remove(subtree);
166
    }
167

  
168
    //geo filter
169
    public Set<NamedArea> getGeoFilter() {
170
        return geoFilter;
171
    }
172
    public void setGeoFilter(Set<NamedArea> geoFilter) {
173
        this.geoFilter = geoFilter;
174
    }
175
    public void addGeoFilterArea(NamedArea area){
176
        this.geoFilter.add(area);
177
    }
178
    public boolean removeGeoFilterArea(NamedArea area) {
179
        return this.geoFilter.remove(area);
180
    }
181

  
182
    //min rank
183
    public Rank getMinRank() {
184
        return minRank;
185
    }
186
    public void setMinRank(Rank minRank) {
187
        this.minRank = minRank;
188
    }
189

  
190
    //max rank
191
    public Rank getMaxRank() {
192
        return maxRank;
193
    }
194
    public void setMaxRank(Rank maxRank) {
195
        this.maxRank = maxRank;
196
    }
197

  
198
    //representations
199
	public Set<Representation> getRepresentations() {
200
		return this.representations;
201
	}
202
	public void addRepresentation(Representation representation) {
203
		this.representations.add(representation);
204
	}
205
	public void removeRepresentation(Representation representation) {
206
		this.representations.remove(representation);
207
	}
208

  
209
	public Representation getRepresentation(Language lang) {
210
		for (Representation repr : representations){
211
			Language reprLanguage = repr.getLanguage();
212
			if (reprLanguage != null && reprLanguage.equals(lang)){
213
				return repr;
214
			}
215
		}
216
		return null;
217
	}
218

  
219
	/**
220
	 * @see #getPreferredRepresentation(Language)
221
	 * @param language
222
	 * @return
223
	 */
224
	public Representation getPreferredRepresentation(Language language) {
225
		Representation repr = getRepresentation(language);
226
		if(repr == null){
227
			repr = getRepresentation(Language.DEFAULT());
228
		}
229
		if(repr == null){
230
			repr = getRepresentations().iterator().next();
231
		}
232
		return repr;
233
	}
234

  
235
	/**
236
	 * Returns the Representation in the preferred language. Preferred languages
237
	 * are specified by the parameter languages, which receives a list of
238
	 * Language instances in the order of preference. If no representation in
239
	 * any preferred languages is found the method falls back to return the
240
	 * Representation in Language.DEFAULT() and if necessary further falls back
241
	 * to return the first element found if any.
242
	 *
243
	 * TODO think about this fall-back strategy &
244
	 * see also {@link TextData#getPreferredLanguageString(List)}
245
	 *
246
	 * @param languages
247
	 * @return
248
	 */
249
	public Representation getPreferredRepresentation(List<Language> languages) {
250
		Representation repr = null;
251
		if(languages != null){
252
			for(Language language : languages) {
253
				repr = getRepresentation(language);
254
				if(repr != null){
255
					return repr;
256
				}
257
			}
258
		}
259
		if(repr == null){
260
			repr = getRepresentation(Language.DEFAULT());
261
		}
262
		if(repr == null){
263
			Iterator<Representation> it = getRepresentations().iterator();
264
			if(it.hasNext()){
265
				repr = getRepresentations().iterator().next();
266
			}
267
		}
268
		return repr;
269
	}
270

  
271
	@Transient
272
	public String getLabel() {
273
		if(getLabel(Language.DEFAULT())!=null){
274
			Representation repr = getRepresentation(Language.DEFAULT());
275
			return (repr == null)? null :repr.getLabel();
276
		}else{
277
			for (Representation r : representations){
278
				return r.getLabel();
279
			}
280
		}
281
		return super.getUuid().toString();
282
	}
283

  
284
	public String getLabel(Language lang) {
285
		Representation repr = this.getRepresentation(lang);
286
		return (repr == null) ? null : repr.getLabel();
287
	}
288

  
289
	public void setLabel(String label){
290
		Language lang = Language.DEFAULT();
291
		setLabel(label, lang);
292
	}
293

  
294
	public void setLabel(String label, Language language){
295
		if (language != null){
296
			Representation repr = getRepresentation(language);
297
			if (repr != null){
298
				repr.setLabel(label);
299
			}else{
300
				repr = Representation.NewInstance(null, label, null, language);
301
			}
302
			this.addRepresentation(repr);
303
		}
304
	}
305

  
306
	public FeatureTree getDescriptiveSystem() {
307
		return descriptiveSystem;
308
	}
309
	public void setDescriptiveSystem(FeatureTree descriptiveSystem) {
310
		this.descriptiveSystem = descriptiveSystem;
311
	}
312

  
313
	/**
314
	 * Returns the {@link DescriptionBase descriptions} of
315
	 * <i>this</i> working set.
316
	 *
317
	 * @see    #addDescription(DescriptionBase)
318
	 * @see    #removeDescription(DescriptionBase)
319
	 */
320
	public Set<DescriptionBase> getDescriptions() {
321
		return descriptions;
322
	}
323

  
324
	/**
325
	 * Adds an existing {@link DescriptionBase description} to the set of
326
	 * {@link #getDescriptions() descriptions} of <i>this</i>
327
	 * working set.
328
	 *
329
	 * @param description	the description to be added to <i>this</i> working set
330
	 * @see    	   			#getDescriptions()
331
	 * @see    	   			DescriptiveDataSet#addDescription(DescriptionBase)
332
	 */
333
	public boolean addDescription(DescriptionBase description) {
334
		boolean result = this.descriptions.add(description);
335
		if (! description.getDescriptiveDataSets().contains(this)){
336
			description.addDescriptiveDataSet(this);
337
		}
338
		return result;
339
	}
340

  
341
	/**
342
	 * Removes one element from the set of {@link #getDescriptions() descriptions} involved
343
	 * in <i>this</i> working set.<BR>
344
	 *
345
	 * @param  description	the description which should be removed
346
	 * @see     		 	#getDescriptions()
347
	 * @see     		  	#addDescription(DescriptionBase)
348
	 * @see     		  	DescriptiveDataSet#removeDescription(DescriptionBase)
349
	 */
350
	public boolean removeDescription(DescriptionBase description) {
351
		boolean result = this.descriptions.remove(description);
352
		if (description.getDescriptiveDataSets().contains(this)){
353
			description.removeDescriptiveDataSet(this);
354
		}
355
		return result;
356
	}
357

  
358
	//*********************** CLONE ********************************************************/
359

  
360
	/**
361
	 * Clones <i>this</i> DescriptiveDataSet. This is a shortcut that enables to create
362
	 * a new instance that differs only slightly from <i>this</i> DescriptiveDataSet by
363
	 * modifying only some of the attributes.
364
	 * The descriptions and the descriptive system are the same, the representations
365
	 * are cloned.
366
	 *
367
	 * @see eu.etaxonomy.cdm.model.common.AnnotatableEntity#clone()
368
	 * @see java.lang.Object#clone()
369
	 */
370
	@Override
371
	public Object clone() {
372
		DescriptiveDataSet result;
373
		try {
374
			result = (DescriptiveDataSet)super.clone();
375

  
376
			//descriptions
377
			result.descriptions = new HashSet<>();
378
			for (DescriptionBase<?> desc: this.descriptions){
379
				result.addDescription(desc);
380
			}
381

  
382
			//representations
383
			result.representations = new HashSet<>();
384
			for (Representation rep : this.representations){
385
				result.addRepresentation((Representation)rep.clone());
386
			}
387

  
388
			//subtree filter
389
            result.taxonSubtreeFilter = new HashSet<>();
390
            for (TaxonNode subtree : this.taxonSubtreeFilter){
391
                result.addTaxonSubtree(subtree);
392
            }
393

  
394
            //geo filter
395
            result.geoFilter = new HashSet<>();
396
            for (NamedArea area : this.geoFilter){
397
                result.addGeoFilterArea(area);
398
            }
399

  
400
			return result;
401
		}catch (CloneNotSupportedException e) {
402
			logger.warn("Object does not implement cloneable");
403
			e.printStackTrace();
404
			return null;
405
		}
406
	}
407

  
408
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/MultiAccessKey.java
54 54
@XmlRootElement(name = "MultiAccessKey")
55 55
@Entity
56 56
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
57
//@Indexed(index = "eu.etaxonomy.cdm.model.media.WorkingSet")
57
//@Indexed(index = "eu.etaxonomy.cdm.model.description.DescriptiveDataSet")
58 58
@Audited
59 59

  
60
public class MultiAccessKey extends WorkingSet implements IIdentificationKey{
60
public class MultiAccessKey extends DescriptiveDataSet implements IIdentificationKey{
61 61
	private static final long serialVersionUID = -240407483572972239L;
62 62
	@SuppressWarnings("unused")
63 63
	private static final Logger logger = Logger.getLogger(MultiAccessKey.class);
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/WorkingSet.java
1
/**
2
* Copyright (C) 2007 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

  
10
package eu.etaxonomy.cdm.model.description;
11

  
12
import java.util.HashSet;
13
import java.util.Iterator;
14
import java.util.List;
15
import java.util.Set;
16

  
17
import javax.persistence.Entity;
18
import javax.persistence.FetchType;
19
import javax.persistence.JoinTable;
20
import javax.persistence.ManyToMany;
21
import javax.persistence.ManyToOne;
22
import javax.persistence.OneToMany;
23
import javax.persistence.Transient;
24
import javax.validation.constraints.NotNull;
25
import javax.xml.bind.annotation.XmlAccessType;
26
import javax.xml.bind.annotation.XmlAccessorType;
27
import javax.xml.bind.annotation.XmlElement;
28
import javax.xml.bind.annotation.XmlElementWrapper;
29
import javax.xml.bind.annotation.XmlIDREF;
30
import javax.xml.bind.annotation.XmlRootElement;
31
import javax.xml.bind.annotation.XmlSchemaType;
32
import javax.xml.bind.annotation.XmlType;
33

  
34
import org.apache.log4j.Logger;
35
import org.hibernate.annotations.Cascade;
36
import org.hibernate.annotations.CascadeType;
37
import org.hibernate.envers.Audited;
38

  
39
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
40
import eu.etaxonomy.cdm.model.common.Language;
41
import eu.etaxonomy.cdm.model.common.Representation;
42
import eu.etaxonomy.cdm.model.location.NamedArea;
43
import eu.etaxonomy.cdm.model.name.Rank;
44
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
45
import eu.etaxonomy.cdm.strategy.cache.description.WorkingSetDefaultCacheStrategy;
46

  
47
/**
48
 *
49
 * The working set class allows the demarcation of a set of descriptions
50
 * associated with representations and a set of features and their
51
 * dependencies.
52
 *
53
 * @author h.fradin
54
 * @since 12.08.2009
55
 */
56

  
57
@XmlAccessorType(XmlAccessType.FIELD)
58
@XmlType(name = "WorkingSet", propOrder = {
59
    "representations",
60
    "descriptiveSystem",
61
    "descriptions",
62
    "taxonSubtreeFilter",
63
    "geoFilter",
64
    "minRank",
65
    "maxRank"
66
})
67
@XmlRootElement(name = "WorkingSet")
68
@Entity
69
@Audited
70
public class WorkingSet extends IdentifiableEntity<WorkingSetDefaultCacheStrategy> {
71
	private static final long serialVersionUID = 3256448866757415686L;
72
	private static final Logger logger = Logger.getLogger(WorkingSet.class);
73

  
74
	@XmlElementWrapper(name = "Representations")
75
	@XmlElement(name = "Representation")
76
    @OneToMany(fetch=FetchType.EAGER)
77
	@Cascade( { CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE })
78
	private Set<Representation> representations = new HashSet<>();
79

  
80
	@XmlElement(name = "DescriptiveSystem")
81
	@XmlIDREF
82
	@XmlSchemaType(name = "IDREF")
83
	@ManyToOne(fetch = FetchType.LAZY)
84
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
85
	private FeatureTree descriptiveSystem;
86

  
87
	@XmlElementWrapper(name = "Descriptions")
88
	@XmlElement(name = "Description")
89
    @XmlIDREF
90
    @XmlSchemaType(name = "IDREF")
91
    @ManyToMany(fetch = FetchType.LAZY)
92
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
93
	@NotNull
94
	private Set<DescriptionBase> descriptions = new HashSet<>();
95

  
96
    @XmlElementWrapper(name = "SubtreeTaxonFilter")
97
    @XmlElement(name = "Subtree")
98
    @XmlIDREF
99
    @XmlSchemaType(name = "IDREF")
100
    @ManyToMany(fetch = FetchType.LAZY)
101
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
102
    @NotNull
103
    //a positive filter that defines that all taxa in the subtree belong to
104
    //the dataset. If the filter is NOT set, taxa need to be explicitly defined
105
    //via the descriptions set. If the filter is set all taxa not having
106
    //a description in descriptions yet are considered to have an empty description
107
    //TODO what, if a taxon is removed from the subtree but a description exists in
108
    //descriptions
109
    private Set<TaxonNode> taxonSubtreeFilter = new HashSet<>();
110

  
111
    @XmlElementWrapper(name = "GeoFilter")
112
    @XmlElement(name = "FilteredArea")
113
    @XmlIDREF
114
    @XmlSchemaType(name = "IDREF")
115
    @ManyToMany(fetch = FetchType.LAZY)
116
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
117
    @JoinTable(name="WorkingSet_NamedArea")
118
    @NotNull
119
    private Set<NamedArea> geoFilter = new HashSet<>();
120

  
121
    @XmlElement(name = "minRank")
122
    @XmlIDREF
123
    @XmlSchemaType(name = "IDREF")
124
    @ManyToOne(fetch = FetchType.LAZY)
125
    private Rank minRank;
126

  
127
    @XmlElement(name = "maxRank")
128
    @XmlIDREF
129
    @XmlSchemaType(name = "IDREF")
130
    @ManyToOne(fetch = FetchType.LAZY)
131
    private Rank maxRank;
132

  
133
// ******************* FACTORY *********************************************/
134

  
135
	public static WorkingSet NewInstance(){
136
        return new WorkingSet();
137
    }
138

  
139

  
140
// *******************CONSTRUCTOR **********************************/
141
	/**
142
	 * Class constructor: creates a new empty working set instance.
143
	 */
144
	protected WorkingSet() {
145
		super();
146
		this.cacheStrategy = new WorkingSetDefaultCacheStrategy();
147
	}
148

  
149
// ******************** GETTER / SETTER ************************/
150

  
151

  
152
	public Set<TaxonNode> getTaxonSubtreeFilter() {
153
        return taxonSubtreeFilter;
154
    }
155

  
156
    public void setTaxonSubtreeFilter(Set<TaxonNode> taxonSubtreeFilter) {
157
        this.taxonSubtreeFilter = taxonSubtreeFilter;
158
    }
159

  
160
    public void  addTaxonSubtree(TaxonNode subtree) {
161
        this.taxonSubtreeFilter.add(subtree);
162
    }
163

  
164
    public void  removeTaxonSubtree(TaxonNode subtree) {
165
        this.taxonSubtreeFilter.remove(subtree);
166
    }
167

  
168
    //geo filter
169
    public Set<NamedArea> getGeoFilter() {
170
        return geoFilter;
171
    }
172
    public void setGeoFilter(Set<NamedArea> geoFilter) {
173
        this.geoFilter = geoFilter;
174
    }
175
    public void addGeoFilterArea(NamedArea area){
176
        this.geoFilter.add(area);
177
    }
178
    public boolean removeGeoFilterArea(NamedArea area) {
179
        return this.geoFilter.remove(area);
180
    }
181

  
182
    //min rank
183
    public Rank getMinRank() {
184
        return minRank;
185
    }
186
    public void setMinRank(Rank minRank) {
187
        this.minRank = minRank;
188
    }
189

  
190
    //max rank
191
    public Rank getMaxRank() {
192
        return maxRank;
193
    }
194
    public void setMaxRank(Rank maxRank) {
195
        this.maxRank = maxRank;
196
    }
197

  
198
    //representations
199
	public Set<Representation> getRepresentations() {
200
		return this.representations;
201
	}
202
	public void addRepresentation(Representation representation) {
203
		this.representations.add(representation);
204
	}
205
	public void removeRepresentation(Representation representation) {
206
		this.representations.remove(representation);
207
	}
208

  
209
	public Representation getRepresentation(Language lang) {
210
		for (Representation repr : representations){
211
			Language reprLanguage = repr.getLanguage();
212
			if (reprLanguage != null && reprLanguage.equals(lang)){
213
				return repr;
214
			}
215
		}
216
		return null;
217
	}
218

  
219
	/**
220
	 * @see #getPreferredRepresentation(Language)
221
	 * @param language
222
	 * @return
223
	 */
224
	public Representation getPreferredRepresentation(Language language) {
225
		Representation repr = getRepresentation(language);
226
		if(repr == null){
227
			repr = getRepresentation(Language.DEFAULT());
228
		}
229
		if(repr == null){
230
			repr = getRepresentations().iterator().next();
231
		}
232
		return repr;
233
	}
234

  
235
	/**
236
	 * Returns the Representation in the preferred language. Preferred languages
237
	 * are specified by the parameter languages, which receives a list of
238
	 * Language instances in the order of preference. If no representation in
239
	 * any preferred languages is found the method falls back to return the
240
	 * Representation in Language.DEFAULT() and if necessary further falls back
241
	 * to return the first element found if any.
242
	 *
243
	 * TODO think about this fall-back strategy &
244
	 * see also {@link TextData#getPreferredLanguageString(List)}
245
	 *
246
	 * @param languages
247
	 * @return
248
	 */
249
	public Representation getPreferredRepresentation(List<Language> languages) {
250
		Representation repr = null;
251
		if(languages != null){
252
			for(Language language : languages) {
253
				repr = getRepresentation(language);
254
				if(repr != null){
255
					return repr;
256
				}
257
			}
258
		}
259
		if(repr == null){
260
			repr = getRepresentation(Language.DEFAULT());
261
		}
262
		if(repr == null){
263
			Iterator<Representation> it = getRepresentations().iterator();
264
			if(it.hasNext()){
265
				repr = getRepresentations().iterator().next();
266
			}
267
		}
268
		return repr;
269
	}
270

  
271
	@Transient
272
	public String getLabel() {
273
		if(getLabel(Language.DEFAULT())!=null){
274
			Representation repr = getRepresentation(Language.DEFAULT());
275
			return (repr == null)? null :repr.getLabel();
276
		}else{
277
			for (Representation r : representations){
278
				return r.getLabel();
279
			}
280
		}
281
		return super.getUuid().toString();
282
	}
283

  
284
	public String getLabel(Language lang) {
285
		Representation repr = this.getRepresentation(lang);
286
		return (repr == null) ? null : repr.getLabel();
287
	}
288

  
289
	public void setLabel(String label){
290
		Language lang = Language.DEFAULT();
291
		setLabel(label, lang);
292
	}
293

  
294
	public void setLabel(String label, Language language){
295
		if (language != null){
296
			Representation repr = getRepresentation(language);
297
			if (repr != null){
298
				repr.setLabel(label);
299
			}else{
300
				repr = Representation.NewInstance(null, label, null, language);
301
			}
302
			this.addRepresentation(repr);
303
		}
304
	}
305

  
306
	public FeatureTree getDescriptiveSystem() {
307
		return descriptiveSystem;
308
	}
309
	public void setDescriptiveSystem(FeatureTree descriptiveSystem) {
310
		this.descriptiveSystem = descriptiveSystem;
311
	}
312

  
313
	/**
314
	 * Returns the {@link DescriptionBase descriptions} of
315
	 * <i>this</i> working set.
316
	 *
317
	 * @see    #addDescription(DescriptionBase)
318
	 * @see    #removeDescription(DescriptionBase)
319
	 */
320
	public Set<DescriptionBase> getDescriptions() {
321
		return descriptions;
322
	}
323

  
324
	/**
325
	 * Adds an existing {@link DescriptionBase description} to the set of
326
	 * {@link #getDescriptions() descriptions} of <i>this</i>
327
	 * working set.
328
	 *
329
	 * @param description	the description to be added to <i>this</i> working set
330
	 * @see    	   			#getDescriptions()
331
	 * @see    	   			WorkingSet#addDescription(DescriptionBase)
332
	 */
333
	public boolean addDescription(DescriptionBase description) {
334
		boolean result = this.descriptions.add(description);
335
		if (! description.getWorkingSets().contains(this)){
336
			description.addWorkingSet(this);
337
		}
338
		return result;
339
	}
340

  
341
	/**
342
	 * Removes one element from the set of {@link #getDescriptions() descriptions} involved
343
	 * in <i>this</i> working set.<BR>
344
	 *
345
	 * @param  description	the description which should be removed
346
	 * @see     		 	#getDescriptions()
347
	 * @see     		  	#addDescription(DescriptionBase)
348
	 * @see     		  	WorkingSet#removeDescription(DescriptionBase)
349
	 */
350
	public boolean removeDescription(DescriptionBase description) {
351
		boolean result = this.descriptions.remove(description);
352
		if (description.getWorkingSets().contains(this)){
353
			description.removeWorkingSet(this);
354
		}
355
		return result;
356
	}
357

  
358
	//*********************** CLONE ********************************************************/
359

  
360
	/**
361
	 * Clones <i>this</i> WorkingSet. This is a shortcut that enables to create
362
	 * a new instance that differs only slightly from <i>this</i> WorkingSet by
363
	 * modifying only some of the attributes.
364
	 * The descriptions and the descriptive system are the same, the representations
365
	 * are cloned.
366
	 *
367
	 * @see eu.etaxonomy.cdm.model.common.AnnotatableEntity#clone()
368
	 * @see java.lang.Object#clone()
369
	 */
370
	@Override
371
	public Object clone() {
372
		WorkingSet result;
373
		try {
374
			result = (WorkingSet)super.clone();
375

  
376
			//descriptions
377
			result.descriptions = new HashSet<>();
378
			for (DescriptionBase<?> desc: this.descriptions){
379
				result.addDescription(desc);
380
			}
381

  
382
			//representations
383
			result.representations = new HashSet<>();
384
			for (Representation rep : this.representations){
385
				result.addRepresentation((Representation)rep.clone());
386
			}
387

  
388
			//subtree filter
389
            result.taxonSubtreeFilter = new HashSet<>();
390
            for (TaxonNode subtree : this.taxonSubtreeFilter){
391
                result.addTaxonSubtree(subtree);
392
            }
393

  
394
            //geo filter
395
            result.geoFilter = new HashSet<>();
396
            for (NamedArea area : this.geoFilter){
397
                result.addGeoFilterArea(area);
398
            }
399

  
400
			return result;
401
		}catch (CloneNotSupportedException e) {
402
			logger.warn("Object does not implement cloneable");
403
			e.printStackTrace();
404
			return null;
405
		}
406
	}
407

  
408
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/description/DescriptiveDataSetDefaultCacheStrategy.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.cdm.strategy.cache.description;
10

  
11
import java.util.UUID;
12

  
13
import eu.etaxonomy.cdm.model.common.Language;
14
import eu.etaxonomy.cdm.model.common.Representation;
15
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
16
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
17

  
18
/**
19
 * @author a.mueller
20
 * @since 07.05.2018
21
 *
22
 */
23
public class DescriptiveDataSetDefaultCacheStrategy
24
            extends IdentifiableEntityDefaultCacheStrategy<DescriptiveDataSet> {
25

  
26
    private static final long serialVersionUID = 3307740888390159983L;
27

  
28
    final static UUID uuid = UUID.fromString("4018e36d-6c6e-4f9e-950c-66e928b51a22");
29

  
30
    @Override
31
    public String getTitleCache(DescriptiveDataSet descriptiveDataSet) {
32
        Representation preferredRepresentation = descriptiveDataSet.getPreferredRepresentation(Language.DEFAULT());
33

  
34
        if (preferredRepresentation != null){
35
            if (isNotBlank(preferredRepresentation.getLabel())){
36
                return preferredRepresentation.getLabel();
37
            }
38
        }
39
        return super.getTitleCache(descriptiveDataSet);
40
    }
41

  
42
    @Override
43
    protected UUID getUuid() {
44
        return uuid;
45
    }
46
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/description/WorkingSetDefaultCacheStrategy.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.cdm.strategy.cache.description;
10

  
11
import java.util.UUID;
12

  
13
import eu.etaxonomy.cdm.model.common.Language;
14
import eu.etaxonomy.cdm.model.common.Representation;
15
import eu.etaxonomy.cdm.model.description.WorkingSet;
16
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
17

  
18
/**
19
 * @author a.mueller
20
 * @since 07.05.2018
21
 *
22
 */
23
public class WorkingSetDefaultCacheStrategy
24
            extends IdentifiableEntityDefaultCacheStrategy<WorkingSet> {
25

  
26
    private static final long serialVersionUID = 3307740888390159983L;
27

  
28
    final static UUID uuid = UUID.fromString("4018e36d-6c6e-4f9e-950c-66e928b51a22");
29

  
30
    @Override
31
    public String getTitleCache(WorkingSet workingSet) {
32
        Representation preferredRepresentation = workingSet.getPreferredRepresentation(Language.DEFAULT());
33

  
34
        if (preferredRepresentation != null){
35
            if (isNotBlank(preferredRepresentation.getLabel())){
36
                return preferredRepresentation.getLabel();
37
            }
38
        }
39
        return super.getTitleCache(workingSet);
40
    }
41

  
42
    @Override
43
    protected UUID getUuid() {
44
        return uuid;
45
    }
46
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/data/FullCoverageDataGenerator.java
45 45
import eu.etaxonomy.cdm.model.description.CategoricalData;
46 46
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
47 47
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
48
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
48 49
import eu.etaxonomy.cdm.model.description.Distribution;
49 50
import eu.etaxonomy.cdm.model.description.Feature;
50 51
import eu.etaxonomy.cdm.model.description.FeatureNode;
......
68 69
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
69 70
import eu.etaxonomy.cdm.model.description.TextData;
70 71
import eu.etaxonomy.cdm.model.description.TextFormat;
71
import eu.etaxonomy.cdm.model.description.WorkingSet;
72 72
import eu.etaxonomy.cdm.model.location.Country;
73 73
import eu.etaxonomy.cdm.model.location.NamedArea;
74 74
import eu.etaxonomy.cdm.model.location.Point;
......
422 422
		cdmBases.add(leaveLengthNode);
423 423

  
424 424

  
425
		WorkingSet workingSet = WorkingSet.NewInstance();
426
		workingSet.addDescription(taxonDescription);
427
		workingSet.setLabel("My Workingset");
428
		workingSet.getDescriptiveSystem();
429
		handleAnnotatableEntity(workingSet);
425
		DescriptiveDataSet descriptiveDataSet = DescriptiveDataSet.NewInstance();
426
		descriptiveDataSet.addDescription(taxonDescription);
427
		descriptiveDataSet.setLabel("My Descriptive Dataset");
428
		descriptiveDataSet.getDescriptiveSystem();
429
		handleAnnotatableEntity(descriptiveDataSet);
430 430

  
431 431

  
432 432
		//polytomous keys
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v36_40/ReferencedObjTypeUpdater.java
69 69
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
70 70
import eu.etaxonomy.cdm.model.description.TextData;
71 71
import eu.etaxonomy.cdm.model.description.TextFormat;
72
import eu.etaxonomy.cdm.model.description.WorkingSet;
72
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
73 73
import eu.etaxonomy.cdm.model.location.Country;
74 74
import eu.etaxonomy.cdm.model.location.NamedArea;
75 75
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
......
176 176
			    TaxonNameDescription.class,
177 177
			    TextData.class,
178 178
			    TextFormat.class,
179
			    WorkingSet.class,
179
			    DescriptiveDataSet.class,
180 180
			    Country.class,
181 181
			    NamedArea.class,
182 182
			    NamedAreaLevel.class,
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v41_47/SchemaUpdater_41_47.java
500 500
            step = ColumnNameChanger.NewIntegerInstance(stepName, newTableName, oldColumnName, newColumnName, INCLUDE_AUDIT);
501 501
            stepList.add(step);
502 502
        }
503

  
504 503
    }
505 504

  
506 505
    /**
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v47_49/SchemaUpdater_47_49.java
17 17

  
18 18
import eu.etaxonomy.cdm.database.update.ClassBaseTypeUpdater;
19 19
import eu.etaxonomy.cdm.database.update.ColumnAdder;
20
import eu.etaxonomy.cdm.database.update.ColumnNameChanger;
20 21
import eu.etaxonomy.cdm.database.update.ISchemaUpdater;
21 22
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep;
22 23
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase;
23 24
import eu.etaxonomy.cdm.database.update.SimpleSchemaUpdaterStep;
25
import eu.etaxonomy.cdm.database.update.TableNameChanger;
24 26
import eu.etaxonomy.cdm.database.update.TermRepresentationUpdater;
25 27
import eu.etaxonomy.cdm.database.update.v41_47.SchemaUpdater_41_47;
26 28

  
......
96 98
        step = SimpleSchemaUpdaterStep.NewAuditedInstance(stepName, query, tableName, -99);
97 99
        stepList.add(step);
98 100

  
101
        //#7405 Rename WorkingSet to DescriptiveDataSet
102
        String oldTableName = "WorkingSet";
103
        changeSingleWorkingSetTableName(stepList, oldTableName);
99 104

  
105
        oldTableName = "WorkingSet_Annotation";
106
        changeSingleWorkingSetTableName(stepList, oldTableName);
107

  
108
        oldTableName = "WorkingSet_DescriptionBase";
109
        changeSingleWorkingSetTableName(stepList, oldTableName);
110

  
111
        oldTableName = "WorkingSet_Marker";
112
        changeSingleWorkingSetTableName(stepList, oldTableName);
113

  
114
        oldTableName = "WorkingSet_NamedArea";
115
        changeSingleWorkingSetTableName(stepList, oldTableName);
116

  
117
        oldTableName = "WorkingSet_Representation";
118
        changeSingleWorkingSetTableName(stepList, oldTableName);
119

  
120
        oldTableName = "WorkingSet_TaxonNode";
121
        changeSingleWorkingSetTableName(stepList, oldTableName);
122

  
123
        stepName = "Update hibernate_sequences for WorkingSet renaming";
124
        query = " UPDATE hibernate_sequences "
125
                + " SET sequence_name = 'DescriptiveDataSet' "
126
                + " WHERE sequence_name = WorkingSet";
127
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
128
        stepList.add(step);
100 129

  
101 130
        //#2335 Make WorkingSet IdentifiableEntity
102
        stepName = "Make WorkingSet IdentifiableEntity";
103
        tableName = "WorkingSet";
131
        stepName = "Make DescriptiveDataSet IdentifiableEntity";
132
        tableName = "DescriptiveDataSet";
104 133
        step = ClassBaseTypeUpdater.NewAnnotatableToIdentifiableInstance(stepName, tableName, INCLUDE_AUDIT);
105 134
        stepList.add(step);
106 135

  
......
117 146
        stepList.add(step);
118 147

  
119 148

  
149
        return stepList;
150
    }
120 151

  
121
//        //#5149 remove unique index on Sequence_Reference.citations_id
122
//        tableName = "Sequence_Reference";
123
//        String columnName = "citations_id";
124
//        step = UniqueIndexDropper.NewInstance(tableName, columnName, !INCLUDE_AUDIT);
125
//        stepList.add(step);
126
//
127
//
128
//        //#6340 nom status invalid updater
129
//        step = NomStatusInvalidUpdater.NewInstance();
130
//        stepList.add(step);
131
//
132
//		//#6529
133
//		//Extend WorkingSet to allow a more fine grained definiton of taxon set
134
//		//min rank
135
//        stepName = "Add minRank column";
136
//        tableName = "WorkingSet";
137
//        newColumnName = "minRank_id";
138
//        String referencedTable = "DefinedTermBase";
139
//        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
140
//        stepList.add(step);
141
//
142
//        //max rank
143
//        stepName = "Add maxRank column";
144
//        tableName = "WorkingSet";
145
//        newColumnName = "maxRank_id";
146
//        referencedTable = "DefinedTermBase";
147
//        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
148
//        stepList.add(step);
149
//
150
//        //subtree filter
151
//        stepName= "Add geo filter MN table to WorkingSet";
152
//        String firstTableName = "WorkingSet";
153
//        String secondTableAlias = "NamedArea";
154
//        String secondTableName = "DefinedTermBase";
155
//        String attributeName = "geoFilter";
156
//        boolean isList = ! IS_LIST;
157
//        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
158
//        stepList.add(step);
159
//
160
//        //subtree filter
161
//        stepName= "Add subtree filter MN table to WorkingSet";
162
//        firstTableName = "WorkingSet";
163
//        secondTableName = "TaxonNode";
164
//        secondTableAlias = null;
165
//        attributeName = "taxonSubtreeFilter";
166
//        isList = ! IS_LIST;
167
//        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, secondTableAlias, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
168
//        stepList.add(step);
169
//
170
//        //#6258
171
//        stepName = "Add Registration table";
172
//        tableName = "Registration";
173
//        String[] columnNames = new String[]{"identifier","specificIdentifier","registrationDate","status",
174
//                "institution_id","name_id","submitter_id"};
175
//        String[] referencedTables = new String[]{null, null, null, null,
176
//                "AgentBase","TaxonNameBase","UserAccount"};
177
//        String[] columnTypes = new String[]{"string_255","string_255","datetime","string_10","int","int","int"};
178
//        step = TableCreator.NewAnnotatableInstance(stepName, tableName,
179
//                columnNames, columnTypes, referencedTables, INCLUDE_AUDIT);
180
//        stepList.add(step);
181
//
182
//        //add blockedBy_id
183
//        stepName= "Add blockedBy_id to Registration";
184
//        firstTableName = "Registration";
185
//        secondTableName = "Registration";
186
//        attributeName = "blockedBy";
187
//        isList = ! IS_LIST;
188
//        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
189
//        stepList.add(step);
190
//
191
//        //add type designations
192
//        stepName= "Add type designations to Registration";
193
//        firstTableName = "Registration";
194
//        String firstColumnName = "registrations";
195
//        secondTableName = "TypeDesignationBase";
196
//        attributeName = "typeDesignations";
197
//        isList = false;
198
//        step = MnTableCreator.NewMnInstance(stepName, firstTableName, null, firstColumnName, secondTableName, null, attributeName, INCLUDE_AUDIT, isList, IS_M_TO_M);
199
//        stepList.add(step);
200
//
201
//        //#5258
202
//        //Add "accessed" to Reference
203
//        stepName = "Add 'accessed' to Reference";
204
//        tableName = "Reference";
205
//        newColumnName = "accessed";
206
//        step = ColumnAdder.NewDateTimeInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL);
207
//        stepList.add(step);
208
//
209
//        //#6618 Add structure column to DefinedTermBase (Character)
210
//        stepName = "Add structure column to DefinedTermBase (Character)";
211
//        tableName = "DefinedTermBase";
212
//        newColumnName = "structure_id";
213
//        referencedTable = "FeatureNode";
214
//        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
215
//        stepList.add(step);
216
//
217
//        //#6618 Add property column to DefinedTermBase (Character)
218
//        stepName = "Add property column to DefinedTermBase (Character)";
219
//        tableName = "DefinedTermBase";
220
//        newColumnName = "property_id";
221
//        referencedTable = "FeatureNode";
222
//        step = ColumnAdder.NewIntegerInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
223
//        stepList.add(step);
224
//
225
//        //##6661 Add initials to agent base
226
//        stepName = "Add initials to AgentBase";
227
//        tableName = "AgentBase";
228
//        newColumnName = "initials";
229
//        int length = 80;
230
//        step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
231
//        stepList.add(step);
232
//
233
//        stepName = "Update initials and firstname";
234
//        step = InitialsUpdater.NewInstance();
235
//        stepList.add(step);
236
//
237
//        //#6663
238
//        //Add "lastRetrieved" to Reference
239
//        stepName = "Add 'lastRetrieved' to Reference";
240
//        tableName = "Reference";
241
//        newColumnName = "lastRetrieved";
242
//        step = ColumnAdder.NewDateTimeInstance(stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL);
243
//        stepList.add(step);
244
//
245
//        stepName = "Add externalId to Reference";
246
//        tableName = "Reference";
247
//        newColumnName = "externalId";
248
//        length = 255;
249
//        step = ColumnAdder.NewStringInstance(stepName, tableName, newColumnName, length, INCLUDE_AUDIT);
250
//        stepList.add(step);
251
//
252
//        stepName = "Add externalLink to Reference";
253
//        tableName = "Reference";
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff