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
.common
;
12 import java
.util
.ArrayList
;
13 import java
.util
.HashSet
;
14 import java
.util
.List
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.io
.berlinModel
.out
.mapper
.IDbExportMapper
;
27 public class CdmIoMapping
{
28 private static final Logger logger
= Logger
.getLogger(CdmIoMapping
.class);
30 //protected List<CdmAttributeMapperBase> mapperList = new ArrayList<CdmAttributeMapperBase>();
31 protected List
<CdmAttributeMapperBase
> mapperList
= new ArrayList
<CdmAttributeMapperBase
>();
32 Set
<String
> sourceAttributes
= new HashSet
<String
>();
33 Set
<String
> destinationAttributes
= new HashSet
<String
>();
34 List
<String
> sourceAttributeList
= new ArrayList
<String
>();
35 List
<String
> destinationAttributeList
= new ArrayList
<String
>();
38 public void addMapper(CdmAttributeMapperBase mapper
){
42 mapperList
.add(mapper
);
43 if (mapper
instanceof CdmSingleAttributeMapperBase
){
44 CdmSingleAttributeMapperBase singleMapper
= (CdmSingleAttributeMapperBase
)mapper
;
45 sourceAttributes
.addAll(singleMapper
.getSourceAttributes());
46 sourceAttributeList
.addAll(singleMapper
.getSourceAttributeList());
47 destinationAttributes
.addAll(singleMapper
.getDestinationAttributes());
48 destinationAttributeList
.addAll(singleMapper
.getDestinationAttributeList());
49 }else if (mapper
instanceof MultipleAttributeMapperBase
){
50 MultipleAttributeMapperBase
<?
> multipleMapper
= (MultipleAttributeMapperBase
<?
>)mapper
;
51 sourceAttributes
.addAll(multipleMapper
.getSourceAttributes());
52 sourceAttributeList
.addAll(multipleMapper
.getSourceAttributes());
53 destinationAttributes
.addAll(multipleMapper
.getDestinationAttributes());
54 destinationAttributeList
.addAll(multipleMapper
.getDestinationAttributeList());
56 logger
.error("Unknown mapper type: " + mapper
.getClass().getSimpleName());
57 throw new IllegalArgumentException("Unknown mapper type: " + mapper
.getClass().getSimpleName());
61 public Set
<String
> getSourceAttributes(){
62 Set
<String
> result
= new HashSet
<String
>();
63 result
.addAll(sourceAttributes
);
67 public Set
<String
> getSourceAttributesLowerCase(){
68 Set
<String
> result
= new HashSet
<String
>();
69 for(String attr
: sourceAttributes
){
71 result
.add(attr
.toLowerCase());
79 public Set
<String
> getDestinationAttributes(){
80 Set
<String
> result
= new HashSet
<String
>();
81 result
.addAll(destinationAttributes
);
85 public List
<String
> getDestinationAttributeList(){
86 List
<String
> result
= new ArrayList
<String
>();
87 result
.addAll(destinationAttributeList
);