Revision 0ae18eec
Added by Anahit Babadshanjan about 16 years ago
.gitattributes | ||
---|---|---|
86 | 86 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/aspectj/PropertyChangeAspect.aj -text |
87 | 87 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/datagenerator/TaxonGenerator.java -text |
88 | 88 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmDocumentBuilder.java -text |
89 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmMarshallerListener.java -text |
|
89 | 90 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmResourceResolver.java -text |
90 | 91 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmSchemaGenerator.java -text |
91 | 92 |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/DataSet.java -text |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmDocumentBuilder.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
} |
49 | 49 |
|
50 |
public void marshal(Object object, Writer writer) throws JAXBException { |
|
51 |
|
|
52 |
Marshaller marshaller; |
|
53 |
marshaller = jaxbContext.createMarshaller(); |
|
54 |
|
|
55 |
// For test purposes insert newlines to make the XML output readable |
|
56 |
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); |
|
57 |
|
|
58 |
// UTF-8 encoding delivers error when unmarshalling |
|
59 |
//marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); |
|
60 |
marshaller.setProperty(Marshaller.JAXB_ENCODING, "ISO-8859-1"); |
|
61 |
|
|
62 |
// validate with explicit schema |
|
63 |
//marshaller.setSchema(cdmSchema); |
|
64 |
|
|
65 |
marshaller.marshal(object, writer); |
|
66 |
|
|
67 |
} |
|
68 |
|
|
50 | 69 |
public void marshal(DataSet dataSet, Writer writer) throws JAXBException { |
51 | 70 |
|
52 | 71 |
Marshaller marshaller; |
... | ... | |
59 | 78 |
//marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); |
60 | 79 |
marshaller.setProperty(Marshaller.JAXB_ENCODING, "ISO-8859-1"); |
61 | 80 |
|
81 |
CdmMarshallerListener marshallerListener = new CdmMarshallerListener(); |
|
82 |
marshaller.setListener(marshallerListener); |
|
83 |
|
|
62 | 84 |
// validate with explicit schema |
63 | 85 |
//marshaller.setSchema(cdmSchema); |
64 | 86 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/CdmMarshallerListener.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.jaxb; |
|
2 |
|
|
3 |
import javax.xml.bind.Marshaller; |
|
4 |
|
|
5 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
6 |
|
|
7 |
/** |
|
8 |
* @author a.babadshanjan |
|
9 |
* @created 19.08.2008 |
|
10 |
*/ |
|
11 |
public class CdmMarshallerListener extends Marshaller.Listener { |
|
12 |
|
|
13 |
public void beforeMarshal(Object target) { |
|
14 |
|
|
15 |
if (target instanceof DefinedTermBase) { |
|
16 |
|
|
17 |
((DefinedTermBase)target).setId(0); |
|
18 |
} |
|
19 |
} |
|
20 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/jaxb/DataSet.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
29 | 29 |
import eu.etaxonomy.cdm.model.description.Feature; |
30 | 30 |
import eu.etaxonomy.cdm.model.location.Continent; |
31 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
31 | 32 |
import eu.etaxonomy.cdm.model.location.NamedAreaLevel; |
32 | 33 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
33 | 34 |
import eu.etaxonomy.cdm.model.location.TdwgArea; |
... | ... | |
118 | 119 |
@XmlElement(name = "Keyword", namespace = "http://etaxonomy.eu/cdm/model/common/1.0", type = Keyword.class), |
119 | 120 |
@XmlElement(name = "Language", namespace = "http://etaxonomy.eu/cdm/model/common/1.0", type = Language.class), |
120 | 121 |
@XmlElement(name = "MarkerType", namespace = "http://etaxonomy.eu/cdm/model/common/1.0", type = MarkerType.class), |
122 |
@XmlElement(name = "NamedArea", namespace = "http://etaxonomy.eu/cdm/model/location/1.0", type = NamedArea.class), |
|
121 | 123 |
@XmlElement(name = "NamedAreaLevel", namespace = "http://etaxonomy.eu/cdm/model/location/1.0", type = NamedAreaLevel.class), |
122 | 124 |
@XmlElement(name = "NamedAreaType", namespace = "http://etaxonomy.eu/cdm/model/location/1.0", type = NamedAreaType.class), |
123 | 125 |
@XmlElement(name = "NameRelationshipType", namespace = "http://etaxonomy.eu/cdm/model/name/1.0", type = NameRelationshipType.class), |
... | ... | |
329 | 331 |
public Collection<TaxonBase> getTaxonBases() { |
330 | 332 |
|
331 | 333 |
Object obj = taxa; |
332 |
// FIXME: This is a dirty trick. |
|
334 |
// FIXME: This is a dirty trick. Replace by getTaxonBases_().
|
|
333 | 335 |
Collection<TaxonBase> taxonBases = (Collection<TaxonBase>)obj; |
334 | 336 |
return taxonBases; |
335 | 337 |
} |
... | ... | |
338 | 340 |
|
339 | 341 |
Collection<TaxonBase> taxonBases = new HashSet<TaxonBase>(); |
340 | 342 |
|
341 |
for (Taxon taxon: taxa) { |
|
342 |
taxonBases.add(taxon); |
|
343 |
if (taxa != null) { |
|
344 |
for (Taxon taxon: taxa) { |
|
345 |
taxonBases.add(taxon); |
|
346 |
} |
|
343 | 347 |
} |
344 |
for (Synonym synonym: synonyms) { |
|
345 |
taxonBases.add(synonym); |
|
348 |
if (synonyms != null) { |
|
349 |
for (Synonym synonym: synonyms) { |
|
350 |
taxonBases.add(synonym); |
|
351 |
} |
|
346 | 352 |
} |
347 | 353 |
return taxonBases; |
348 | 354 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/DefinedTermBase.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
@XmlElementWrapper(name = "Media") |
79 | 79 |
@XmlElement(name = "Medium") |
80 |
@XmlIDREF |
|
81 |
@XmlSchemaType(name = "IDREF") |
|
80 | 82 |
private Set<Media> media = new HashSet<Media>(); |
81 | 83 |
|
82 | 84 |
@XmlElement(name = "Vocabulary") |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptionBase.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import javax.persistence.OneToMany; |
21 | 21 |
import javax.persistence.Transient; |
22 |
import javax.xml.bind.annotation.XmlAccessType; |
|
23 |
import javax.xml.bind.annotation.XmlAccessorType; |
|
22 | 24 |
import javax.xml.bind.annotation.XmlElement; |
23 | 25 |
import javax.xml.bind.annotation.XmlElementWrapper; |
24 | 26 |
import javax.xml.bind.annotation.XmlElements; |
27 |
import javax.xml.bind.annotation.XmlType; |
|
25 | 28 |
|
26 | 29 |
import org.apache.log4j.Logger; |
27 | 30 |
import org.hibernate.annotations.Cascade; |
... | ... | |
43 | 46 |
* @created 08-Nov-2007 13:06:24 |
44 | 47 |
*/ |
45 | 48 |
|
49 |
@XmlAccessorType(XmlAccessType.FIELD) |
|
50 |
@XmlType(name = "DescriptionBase", propOrder = { |
|
51 |
"describedSpecimenOrObservations", |
|
52 |
"descriptionSources", |
|
53 |
"descriptionElements" |
|
54 |
}) |
|
46 | 55 |
@Entity |
47 | 56 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
48 | 57 |
public abstract class DescriptionBase extends IdentifiableEntity { |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptionElementBase.java | ||
---|---|---|
25 | 25 |
import java.util.*; |
26 | 26 |
|
27 | 27 |
import javax.persistence.*; |
28 |
import javax.xml.bind.annotation.XmlAccessType; |
|
29 |
import javax.xml.bind.annotation.XmlAccessorType; |
|
30 |
import javax.xml.bind.annotation.XmlElement; |
|
31 |
import javax.xml.bind.annotation.XmlElementWrapper; |
|
32 |
import javax.xml.bind.annotation.XmlType; |
|
28 | 33 |
|
29 | 34 |
/** |
30 | 35 |
* The upmost (abstract) class for a description element of a specimen |
... | ... | |
37 | 42 |
* @version 1.0 |
38 | 43 |
* @created 08-Nov-2007 13:06:24 |
39 | 44 |
*/ |
45 |
@XmlAccessorType(XmlAccessType.FIELD) |
|
46 |
@XmlType(name = "DescriptionElementBase", propOrder = { |
|
47 |
"feature", |
|
48 |
"modifiers", |
|
49 |
"modifyingText", |
|
50 |
"media" |
|
51 |
}) |
|
40 | 52 |
@Entity |
41 | 53 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
42 | 54 |
public abstract class DescriptionElementBase extends ReferencedEntityBase implements IMediaEntity{ |
... | ... | |
53 | 65 |
} |
54 | 66 |
|
55 | 67 |
//type, category of information. In structured descriptions characters |
68 |
@XmlElement(name = "Feature") |
|
56 | 69 |
private Feature feature; |
70 |
|
|
71 |
@XmlElementWrapper(name = "Modifiers") |
|
72 |
@XmlElement(name = "Modifier") |
|
57 | 73 |
private Set<Modifier> modifiers = new HashSet<Modifier>(); |
74 |
|
|
75 |
@XmlElement(name = "ModifyingText") |
|
58 | 76 |
private MultilanguageSet modifyingText; |
77 |
|
|
78 |
@XmlElementWrapper(name = "Media") |
|
79 |
@XmlElement(name = "Medium") |
|
59 | 80 |
private Set<Media> media = new HashSet<Media>(); |
60 | 81 |
|
61 | 82 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/TaxonDescription.java | ||
---|---|---|
40 | 40 |
"scopes", |
41 | 41 |
"geoScopes" |
42 | 42 |
}) |
43 |
@XmlRootElement(name = "TaxonDescription") |
|
44 | 43 |
@Entity |
45 | 44 |
public class TaxonDescription extends DescriptionBase { |
46 | 45 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/TaxonNameDescription.java | ||
---|---|---|
12 | 12 |
import javax.persistence.Entity; |
13 | 13 |
import javax.persistence.JoinColumn; |
14 | 14 |
import javax.persistence.ManyToOne; |
15 |
import javax.xml.bind.annotation.XmlAccessType; |
|
16 |
import javax.xml.bind.annotation.XmlAccessorType; |
|
17 |
import javax.xml.bind.annotation.XmlTransient; |
|
18 |
import javax.xml.bind.annotation.XmlType; |
|
15 | 19 |
|
16 | 20 |
import org.apache.log4j.Logger; |
17 | 21 |
import org.hibernate.annotations.Cascade; |
... | ... | |
28 | 32 |
* @version 1.0 |
29 | 33 |
* @created 08-Jul-2008 |
30 | 34 |
*/ |
35 |
@XmlAccessorType(XmlAccessType.FIELD) |
|
36 |
@XmlType(name = "TaxonNameDescription", propOrder = { |
|
37 |
}) |
|
31 | 38 |
@Entity |
32 | 39 |
public class TaxonNameDescription extends DescriptionBase { |
33 | 40 |
static Logger logger = Logger.getLogger(TaxonNameDescription.class); |
34 | 41 |
|
42 |
@XmlTransient |
|
35 | 43 |
private TaxonNameBase taxonName; |
36 | 44 |
|
37 | 45 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/Media.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import java.util.*; |
24 | 24 |
import javax.persistence.*; |
25 |
import javax.xml.bind.annotation.XmlElement; |
|
26 |
import javax.xml.bind.annotation.XmlElementWrapper; |
|
25 | 27 |
|
26 | 28 |
/** |
27 | 29 |
* @author m.doering |
... | ... | |
31 | 33 |
@Entity |
32 | 34 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
33 | 35 |
public class Media extends AnnotatableEntity { |
36 |
|
|
34 | 37 |
private static final Logger logger = Logger.getLogger(Media.class); |
35 | 38 |
|
39 |
@XmlElement(name = "Title") |
|
36 | 40 |
private MultilanguageSet title = new MultilanguageSet(); |
41 |
|
|
37 | 42 |
//creation date of the media (not of the record) |
43 |
@XmlElement(name = "MediaCreated") |
|
38 | 44 |
private Calendar mediaCreated; |
45 |
|
|
46 |
@XmlElement(name = "Description") |
|
39 | 47 |
private MultilanguageSet description = new MultilanguageSet(); |
40 |
//A single medium such as a picture can have multiple representations in files. Common are multiple resolutions or file |
|
41 |
//formats for images for example |
|
48 |
|
|
49 |
//A single medium such as a picture can have multiple representations in files. |
|
50 |
//Common are multiple resolutions or file formats for images for example |
|
51 |
@XmlElementWrapper(name = "MediaRepresentations") |
|
52 |
@XmlElement(name = "MediaRepresentation") |
|
42 | 53 |
private Set<MediaRepresentation> representations = new HashSet<MediaRepresentation>(); |
54 |
|
|
55 |
@XmlElementWrapper(name = "Rights") |
|
56 |
@XmlElement(name = "Right") |
|
43 | 57 |
private Set<Rights> rights = new HashSet<Rights>(); |
58 |
|
|
44 | 59 |
private Agent artist; |
45 | 60 |
|
46 | 61 |
/** |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaRepresentation.java | ||
---|---|---|
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
20 | 20 |
import javax.persistence.*; |
21 |
import javax.xml.bind.annotation.XmlElement; |
|
22 |
import javax.xml.bind.annotation.XmlElementWrapper; |
|
23 |
import javax.xml.bind.annotation.XmlTransient; |
|
21 | 24 |
|
22 | 25 |
/** |
23 | 26 |
* metadata for an external file such as images, phylogenetic trees, or audio |
... | ... | |
29 | 32 |
@Entity |
30 | 33 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
31 | 34 |
public class MediaRepresentation extends VersionableEntity { |
35 |
|
|
32 | 36 |
private static final Logger logger = Logger.getLogger(MediaRepresentation.class); |
37 |
|
|
33 | 38 |
//http://www.iana.org/assignments/media-types |
39 |
@XmlElement(name = "MimeType") |
|
34 | 40 |
private String mimeType; |
41 |
|
|
35 | 42 |
//the file suffix (e.g. jpg, tif, mov) |
43 |
@XmlElement(name = "Suffix") |
|
36 | 44 |
private String suffix; |
45 |
|
|
46 |
@XmlTransient |
|
37 | 47 |
private Media media; |
48 |
|
|
49 |
@XmlElementWrapper(name = "MediaRepresentationParts") |
|
50 |
@XmlElement(name = "MediaRepresentationPart") |
|
38 | 51 |
private List<MediaRepresentationPart> mediaRepresentationParts = new ArrayList<MediaRepresentationPart>(); |
39 | 52 |
|
40 | 53 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaRepresentationPart.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.model.media; |
11 | 11 |
import javax.persistence.Entity; |
12 | 12 |
import javax.persistence.ManyToOne; |
13 |
import javax.xml.bind.annotation.XmlElement; |
|
14 |
import javax.xml.bind.annotation.XmlTransient; |
|
15 |
|
|
13 | 16 |
import org.apache.log4j.Logger; |
14 | 17 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
15 | 18 |
|
... | ... | |
23 | 26 |
private static final Logger logger = Logger.getLogger(MediaRepresentationPart.class); |
24 | 27 |
|
25 | 28 |
//sorting index |
29 |
@XmlElement(name = "SortIndex") |
|
26 | 30 |
private int sortIndex; |
31 |
|
|
27 | 32 |
//where the media file is stored |
33 |
@XmlElement(name = "URI") |
|
28 | 34 |
private String uri; |
35 |
|
|
29 | 36 |
//in bytes |
37 |
@XmlElement(name = "Size") |
|
30 | 38 |
private Integer size; |
39 |
|
|
31 | 40 |
//the MEdiaRepresentation this MediaRepresentation |
41 |
@XmlTransient |
|
32 | 42 |
private MediaRepresentation mediaRepresentation; |
33 | 43 |
|
34 | 44 |
/** |
Also available in: Unified diff
Using external marshaller listener to set id=0 in case of DefinedTermBase derived classes.
Using read-only transaction.