2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.berlinModel
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.CdmSingleAttributeMapperBase
;
18 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.MultipleAttributeMapperBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
26 public class CdmOneToManyMapper
<ONE
extends CdmBase
, MANY
extends CdmBase
, SINGLE_MAPPER
extends CdmSingleAttributeMapperBase
> extends MultipleAttributeMapperBase
<SINGLE_MAPPER
> {
27 @SuppressWarnings("unused")
28 private static Logger logger
= Logger
.getLogger(CdmOneToManyMapper
.class);
30 private Class
<MANY
> manyClass
;
31 private Class
<ONE
> oneClass
;
32 private String singleAttributeName
;
34 public CdmOneToManyMapper(Class
<ONE
> oneClass
, Class
<MANY
> manyClass
, String singleAttributeName
, SINGLE_MAPPER
[] singleAttributesMappers
) {
35 if (singleAttributesMappers
== null){
36 throw new NullPointerException("singleAttributesMapper and cdmAttributeStrings must not be null");
38 for (SINGLE_MAPPER singleMapper
: singleAttributesMappers
){
39 singleMappers
.add(singleMapper
);
41 this.manyClass
= manyClass
;
42 this.oneClass
= oneClass
;
43 this.singleAttributeName
= singleAttributeName
;
47 // public Set<String> getSourceAttributes(){
48 // Set<String> result = new HashSet<String>();
49 // result.addAll(getSourceAttributeList());
54 public List
<String
> getSourceAttributeList(){
55 List
<String
> result
= new ArrayList
<String
>();
56 for (SINGLE_MAPPER singleMapper
: singleMappers
){
57 result
.add(singleMapper
.getSourceAttribute());
63 // public Set<String> getDestinationAttributes(){
64 // Set<String> result = new HashSet<String>();
65 // result.addAll(getDestinationAttributeList());
70 public List
<String
> getDestinationAttributeList(){
71 List
<String
> result
= new ArrayList
<String
>();
72 for (SINGLE_MAPPER singleMapper
: singleMappers
){
73 result
.add(singleMapper
.getDestinationAttribute());
79 public Class
<MANY
> getManyClass(){
83 public Class
<ONE
> getOneClass(){
87 public String
getDestinationAttribute(String sourceAttribute
){
88 if (sourceAttribute
== null){
91 for (SINGLE_MAPPER singleMapper
: singleMappers
){
92 if (sourceAttribute
.equals(singleMapper
.getSourceAttribute())){
93 return singleMapper
.getDestinationAttribute();
99 public List
<SINGLE_MAPPER
> getSingleMappers(){
100 return singleMappers
;
104 * @return the singleAttributeName
106 public String
getSingleAttributeName() {
107 return singleAttributeName
;