Revision 826a35b1
Added by Andreas Müller almost 2 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AnnotationType.java | ||
---|---|---|
23 | 23 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
24 | 24 |
import org.hibernate.envers.Audited; |
25 | 25 |
|
26 |
import eu.etaxonomy.cdm.model.term.AvailableForIdentifiableBase; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.term.TermType; |
27 | 28 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
28 | 29 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AvailableForIdentifiableBase.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 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.model.common; |
|
10 |
|
|
11 |
import javax.persistence.Entity; |
|
12 |
import javax.xml.bind.annotation.XmlElement; |
|
13 |
|
|
14 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
|
15 |
import org.hibernate.envers.Audited; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
18 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
19 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
20 |
import eu.etaxonomy.cdm.model.term.TermType; |
|
21 |
|
|
22 |
/** |
|
23 |
* This |
|
24 |
* |
|
25 |
* @author a.mueller |
|
26 |
* @since 22.04.2021 |
|
27 |
*/ |
|
28 |
@Entity |
|
29 |
@Audited |
|
30 |
public abstract class AvailableForIdentifiableBase<T extends DefinedTermBase> |
|
31 |
extends AvailableForTermBase<T>{ |
|
32 |
|
|
33 |
private static final long serialVersionUID = -8671887501681406910L; |
|
34 |
@SuppressWarnings("unused") |
|
35 |
private static final Logger logger = LogManager.getLogger(AvailableForIdentifiableBase.class); |
|
36 |
|
|
37 |
//for hibernate use only |
|
38 |
@Deprecated |
|
39 |
protected AvailableForIdentifiableBase() { |
|
40 |
super(); |
|
41 |
} |
|
42 |
@Deprecated |
|
43 |
protected AvailableForIdentifiableBase(TermType type) { |
|
44 |
super(type); |
|
45 |
} |
|
46 |
|
|
47 |
protected AvailableForIdentifiableBase(TermType type, String term, String label, String labelAbbrev) { |
|
48 |
super(type, term, label, labelAbbrev); |
|
49 |
} |
|
50 |
|
|
51 |
// ****************************** GETTER_SETTER *******************************/ |
|
52 |
|
|
53 |
/** |
|
54 |
* Whether this supplement is available for {@link TaxonName taxon names}. |
|
55 |
*/ |
|
56 |
@XmlElement(name = "AvailableForTaxonName") |
|
57 |
public boolean isAvailableForTaxonName() { |
|
58 |
return getAvailableFor().contains(CdmClass.TAXON_NAME); |
|
59 |
} |
|
60 |
/** |
|
61 |
* @see #isAvailableForTaxon() |
|
62 |
*/ |
|
63 |
public void setAvailableForTaxonName(boolean availableForTaxonName) { |
|
64 |
setAvailableFor(CdmClass.TAXON_NAME, availableForTaxonName); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Whether this supplement is available for {@link Taxon taxa}. |
|
69 |
*/ |
|
70 |
@XmlElement(name = "AvailableForTaxon") |
|
71 |
public boolean isAvailableForTaxon() { |
|
72 |
return getAvailableFor().contains(CdmClass.TAXON); |
|
73 |
} |
|
74 |
/** |
|
75 |
* @see #isAvailableForTaxon() |
|
76 |
*/ |
|
77 |
public void setAvailableForTaxon(boolean availableForTaxon) { |
|
78 |
setAvailableFor(CdmClass.TAXON, availableForTaxon); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Whether this supplement is available for {@link Reference references}. |
|
83 |
*/ |
|
84 |
@XmlElement(name = "AvailableForReference") |
|
85 |
public boolean isAvailableForReference() { |
|
86 |
return getAvailableFor().contains(CdmClass.REFERENCE); |
|
87 |
} |
|
88 |
/** |
|
89 |
* @see #isAvailableForReference() |
|
90 |
*/ |
|
91 |
public void setAvailableForReference(boolean availableForReference) { |
|
92 |
setAvailableFor(CdmClass.REFERENCE, availableForReference); |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AvailableForTermBase.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 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.model.common; |
|
10 |
|
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import javax.persistence.Entity; |
|
14 |
import javax.validation.constraints.NotNull; |
|
15 |
import javax.xml.bind.annotation.XmlAttribute; |
|
16 |
|
|
17 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
|
18 |
import org.hibernate.annotations.Parameter; |
|
19 |
import org.hibernate.annotations.Type; |
|
20 |
import org.hibernate.envers.Audited; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
23 |
import eu.etaxonomy.cdm.model.term.TermType; |
|
24 |
|
|
25 |
/** |
|
26 |
* This |
|
27 |
* |
|
28 |
* @author a.mueller |
|
29 |
* @since 22.04.2021 |
|
30 |
*/ |
|
31 |
@Entity |
|
32 |
@Audited |
|
33 |
public abstract class AvailableForTermBase<T extends DefinedTermBase> |
|
34 |
extends DefinedTermBase<T>{ |
|
35 |
|
|
36 |
private static final long serialVersionUID = 7991846649037898325L; |
|
37 |
@SuppressWarnings("unused") |
|
38 |
private static final Logger logger = LogManager.getLogger(AvailableForTermBase.class); |
|
39 |
|
|
40 |
@XmlAttribute(name ="availableFor") |
|
41 |
@NotNull |
|
42 |
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumSetUserType", |
|
43 |
parameters = {@Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.common.CdmClass")} |
|
44 |
) |
|
45 |
private EnumSet<CdmClass> availableFor = EnumSet.noneOf(CdmClass.class); |
|
46 |
|
|
47 |
//for hibernate use only |
|
48 |
@Deprecated |
|
49 |
protected AvailableForTermBase() { |
|
50 |
super(); |
|
51 |
} |
|
52 |
@Deprecated |
|
53 |
protected AvailableForTermBase(TermType type) { |
|
54 |
super(type); |
|
55 |
} |
|
56 |
|
|
57 |
protected AvailableForTermBase(TermType type, String term, String label, String labelAbbrev) { |
|
58 |
super(type, term, label, labelAbbrev); |
|
59 |
} |
|
60 |
|
|
61 |
// ****************************** GETTER_SETTER *******************************/ |
|
62 |
|
|
63 |
protected EnumSet<CdmClass> getAvailableFor() { |
|
64 |
return availableFor; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* for know it is private and the boolean getters and setters should be used instead. |
|
69 |
* If you make it public make sure to guarantee that any change to the enum set results |
|
70 |
* in a new enum set (see also {@link #newEnumSet(EnumSet, CdmClass, CdmClass)} |
|
71 |
* and that the client is aware of the enum set being immutable. |
|
72 |
*/ |
|
73 |
private void setAvailableFor(EnumSet<CdmClass> availableFor){ |
|
74 |
this.availableFor = availableFor; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Sets the value for supported classes |
|
79 |
* @param cdmClass the supported class |
|
80 |
* @param value the value if it is supported (<code>true</code>) or not (<code>false</code>) |
|
81 |
*/ |
|
82 |
protected void setAvailableFor(CdmClass cdmClass, boolean value) { |
|
83 |
if (value && !this.availableFor.contains(cdmClass)){ |
|
84 |
setAvailableFor(newEnumSet(this.availableFor, cdmClass, null)); |
|
85 |
}else if (!value && this.availableFor.contains(cdmClass)){ |
|
86 |
setAvailableFor(newEnumSet(this.availableFor, null, cdmClass)); |
|
87 |
}else{ |
|
88 |
return; |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
// ****************************** CLONE *********************************** |
|
93 |
|
|
94 |
/** |
|
95 |
* @see java.lang.Object#clone() |
|
96 |
*/ |
|
97 |
@Override |
|
98 |
public AvailableForTermBase<T> clone() { |
|
99 |
AvailableForTermBase<T> result; |
|
100 |
|
|
101 |
result = (AvailableForTermBase<T>)super.clone(); |
|
102 |
|
|
103 |
result.availableFor = this.availableFor.clone(); |
|
104 |
|
|
105 |
return result; |
|
106 |
} |
|
107 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ExtensionType.java | ||
---|---|---|
22 | 22 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
23 | 23 |
import org.hibernate.envers.Audited; |
24 | 24 |
|
25 |
import eu.etaxonomy.cdm.model.term.AvailableForIdentifiableBase; |
|
25 | 26 |
import eu.etaxonomy.cdm.model.term.TermType; |
26 | 27 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
27 | 28 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/MarkerType.java | ||
---|---|---|
25 | 25 |
import org.hibernate.search.annotations.Analyze; |
26 | 26 |
import org.hibernate.search.annotations.Field; |
27 | 27 |
|
28 |
import eu.etaxonomy.cdm.model.term.AvailableForIdentifiableBase; |
|
28 | 29 |
import eu.etaxonomy.cdm.model.term.TermType; |
29 | 30 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
30 | 31 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Feature.java | ||
---|---|---|
41 | 41 |
import org.hibernate.annotations.Type; |
42 | 42 |
import org.hibernate.envers.Audited; |
43 | 43 |
|
44 |
import eu.etaxonomy.cdm.model.common.AvailableForTermBase; |
|
45 | 44 |
import eu.etaxonomy.cdm.model.common.CdmClass; |
46 | 45 |
import eu.etaxonomy.cdm.model.common.Language; |
47 | 46 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
48 | 47 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
48 |
import eu.etaxonomy.cdm.model.term.AvailableForTermBase; |
|
49 | 49 |
import eu.etaxonomy.cdm.model.term.DefinedTerm; |
50 | 50 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
51 | 51 |
import eu.etaxonomy.cdm.model.term.Representation; |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/AvailableForIdentifiableBase.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 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.model.term; |
|
10 |
|
|
11 |
import javax.persistence.Entity; |
|
12 |
import javax.xml.bind.annotation.XmlElement; |
|
13 |
|
|
14 |
import org.apache.logging.log4j.LogManager; |
|
15 |
import org.apache.logging.log4j.Logger; |
|
16 |
import org.hibernate.envers.Audited; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.model.common.CdmClass; |
|
19 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
20 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
21 |
|
|
22 |
/** |
|
23 |
* This |
|
24 |
* |
|
25 |
* @author a.mueller |
|
26 |
* @since 22.04.2021 |
|
27 |
*/ |
|
28 |
@Entity |
|
29 |
@Audited |
|
30 |
public abstract class AvailableForIdentifiableBase<T extends DefinedTermBase> |
|
31 |
extends AvailableForTermBase<T>{ |
|
32 |
|
|
33 |
private static final long serialVersionUID = -8671887501681406910L; |
|
34 |
@SuppressWarnings("unused") |
|
35 |
private static final Logger logger = LogManager.getLogger(AvailableForIdentifiableBase.class); |
|
36 |
|
|
37 |
//for hibernate use only, *packet* private required by bytebuddy |
|
38 |
@Deprecated |
|
39 |
AvailableForIdentifiableBase() {} |
|
40 |
@Deprecated |
|
41 |
protected AvailableForIdentifiableBase(TermType type) { |
|
42 |
super(type); |
|
43 |
} |
|
44 |
|
|
45 |
protected AvailableForIdentifiableBase(TermType type, String term, String label, String labelAbbrev) { |
|
46 |
super(type, term, label, labelAbbrev); |
|
47 |
} |
|
48 |
|
|
49 |
// ****************************** GETTER_SETTER *******************************/ |
|
50 |
|
|
51 |
/** |
|
52 |
* Whether this supplement is available for {@link TaxonName taxon names}. |
|
53 |
*/ |
|
54 |
@XmlElement(name = "AvailableForTaxonName") |
|
55 |
public boolean isAvailableForTaxonName() { |
|
56 |
return getAvailableFor().contains(CdmClass.TAXON_NAME); |
|
57 |
} |
|
58 |
/** |
|
59 |
* @see #isAvailableForTaxon() |
|
60 |
*/ |
|
61 |
public void setAvailableForTaxonName(boolean availableForTaxonName) { |
|
62 |
setAvailableFor(CdmClass.TAXON_NAME, availableForTaxonName); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Whether this supplement is available for {@link Taxon taxa}. |
|
67 |
*/ |
|
68 |
@XmlElement(name = "AvailableForTaxon") |
|
69 |
public boolean isAvailableForTaxon() { |
|
70 |
return getAvailableFor().contains(CdmClass.TAXON); |
|
71 |
} |
|
72 |
/** |
|
73 |
* @see #isAvailableForTaxon() |
|
74 |
*/ |
|
75 |
public void setAvailableForTaxon(boolean availableForTaxon) { |
|
76 |
setAvailableFor(CdmClass.TAXON, availableForTaxon); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Whether this supplement is available for {@link Reference references}. |
|
81 |
*/ |
|
82 |
@XmlElement(name = "AvailableForReference") |
|
83 |
public boolean isAvailableForReference() { |
|
84 |
return getAvailableFor().contains(CdmClass.REFERENCE); |
|
85 |
} |
|
86 |
/** |
|
87 |
* @see #isAvailableForReference() |
|
88 |
*/ |
|
89 |
public void setAvailableForReference(boolean availableForReference) { |
|
90 |
setAvailableFor(CdmClass.REFERENCE, availableForReference); |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/AvailableForTermBase.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 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.model.term; |
|
10 |
|
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import javax.persistence.Entity; |
|
14 |
import javax.validation.constraints.NotNull; |
|
15 |
import javax.xml.bind.annotation.XmlAttribute; |
|
16 |
|
|
17 |
import org.apache.logging.log4j.LogManager; |
|
18 |
import org.apache.logging.log4j.Logger; |
|
19 |
import org.hibernate.annotations.Parameter; |
|
20 |
import org.hibernate.annotations.Type; |
|
21 |
import org.hibernate.envers.Audited; |
|
22 |
|
|
23 |
import eu.etaxonomy.cdm.model.common.CdmClass; |
|
24 |
|
|
25 |
/** |
|
26 |
* This |
|
27 |
* |
|
28 |
* @author a.mueller |
|
29 |
* @since 22.04.2021 |
|
30 |
*/ |
|
31 |
@Entity |
|
32 |
@Audited |
|
33 |
public abstract class AvailableForTermBase<T extends DefinedTermBase> |
|
34 |
extends DefinedTermBase<T>{ |
|
35 |
|
|
36 |
private static final long serialVersionUID = 7991846649037898325L; |
|
37 |
@SuppressWarnings("unused") |
|
38 |
private static final Logger logger = LogManager.getLogger(AvailableForTermBase.class); |
|
39 |
|
|
40 |
@XmlAttribute(name ="availableFor") |
|
41 |
@NotNull |
|
42 |
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumSetUserType", |
|
43 |
parameters = {@Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.common.CdmClass")} |
|
44 |
) |
|
45 |
private EnumSet<CdmClass> availableFor = EnumSet.noneOf(CdmClass.class); |
|
46 |
|
|
47 |
//for hibernate use only, *packet* private required by bytebuddy |
|
48 |
@Deprecated |
|
49 |
AvailableForTermBase() {} |
|
50 |
|
|
51 |
@Deprecated |
|
52 |
protected AvailableForTermBase(TermType type) { |
|
53 |
super(type); |
|
54 |
} |
|
55 |
|
|
56 |
protected AvailableForTermBase(TermType type, String term, String label, String labelAbbrev) { |
|
57 |
super(type, term, label, labelAbbrev); |
|
58 |
} |
|
59 |
|
|
60 |
// ****************************** GETTER_SETTER *******************************/ |
|
61 |
|
|
62 |
protected EnumSet<CdmClass> getAvailableFor() { |
|
63 |
return availableFor; |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* for now it is private and the boolean getters and setters should be used instead. |
|
68 |
* If you make it public make sure to guarantee that any change to the enum set results |
|
69 |
* in a new enum set (see also {@link #newEnumSet(EnumSet, CdmClass, CdmClass)} |
|
70 |
* and that the client is aware of the enum set being immutable. |
|
71 |
*/ |
|
72 |
private void setAvailableFor(EnumSet<CdmClass> availableFor){ |
|
73 |
this.availableFor = availableFor; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Sets the value for supported classes |
|
78 |
* @param cdmClass the supported class |
|
79 |
* @param value the value if it is supported (<code>true</code>) or not (<code>false</code>) |
|
80 |
*/ |
|
81 |
protected void setAvailableFor(CdmClass cdmClass, boolean value) { |
|
82 |
if (value && !this.availableFor.contains(cdmClass)){ |
|
83 |
setAvailableFor(newEnumSet(this.availableFor, cdmClass, null)); |
|
84 |
}else if (!value && this.availableFor.contains(cdmClass)){ |
|
85 |
setAvailableFor(newEnumSet(this.availableFor, null, cdmClass)); |
|
86 |
}else{ |
|
87 |
return; |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
// ****************************** CLONE *********************************** |
|
92 |
|
|
93 |
/** |
|
94 |
* @see java.lang.Object#clone() |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public AvailableForTermBase<T> clone() { |
|
98 |
AvailableForTermBase<T> result; |
|
99 |
|
|
100 |
result = (AvailableForTermBase<T>)super.clone(); |
|
101 |
|
|
102 |
result.availableFor = this.availableFor.clone(); |
|
103 |
|
|
104 |
return result; |
|
105 |
} |
|
106 |
} |
Also available in: Unified diff
move AvailableFor to term package