1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.io.csv.redlist.out;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
/**
|
19
|
* @author a.mueller
|
20
|
* @date 20.04.2011
|
21
|
*
|
22
|
*/
|
23
|
public class CsvMetaDataRecordRedlist {
|
24
|
@SuppressWarnings("unused")
|
25
|
private static final Logger logger = Logger.getLogger(CsvMetaDataRecordRedlist.class);
|
26
|
|
27
|
private String fileLocation;
|
28
|
private String rowType;
|
29
|
|
30
|
private boolean isCore;
|
31
|
private int currentIndex = 0;
|
32
|
private boolean isMetaData = false; //is this record about meta data (should be true for MetaData and EML)
|
33
|
|
34
|
private int count = 0;
|
35
|
|
36
|
private List<FieldEntry> fieldEntryList = new ArrayList<CsvMetaDataRecordRedlist.FieldEntry>();
|
37
|
protected List<String> fieldList = new ArrayList<String>();
|
38
|
|
39
|
|
40
|
public CsvMetaDataRecordRedlist(boolean isCore, String fileLocation, String rowType){
|
41
|
FieldEntry idEntry = new FieldEntry();
|
42
|
idEntry.index = currentIndex++;
|
43
|
idEntry.elementName = isCore ? "id" : "coreid";
|
44
|
fieldEntryList.add(idEntry);
|
45
|
this.isCore = isCore;
|
46
|
this.fileLocation = fileLocation;
|
47
|
this.setRowType(rowType);
|
48
|
}
|
49
|
|
50
|
|
51
|
protected class FieldEntry{
|
52
|
int index;
|
53
|
URI term = null;
|
54
|
String defaultValue = null;
|
55
|
String elementName = "field";
|
56
|
}
|
57
|
|
58
|
public void addFieldEntry(URI term, String defaultValue){
|
59
|
FieldEntry fieldEntry = new FieldEntry();
|
60
|
fieldEntry.index = currentIndex++;
|
61
|
fieldEntry.term = term;
|
62
|
fieldEntry.defaultValue = defaultValue;
|
63
|
this.fieldEntryList.add(fieldEntry);
|
64
|
}
|
65
|
|
66
|
//TODO needed?
|
67
|
// public abstract List<String> getHeaderList();
|
68
|
|
69
|
// public List<URI> getTermList(){
|
70
|
// List<URI> result = new ArrayList<URI>();
|
71
|
// for (String key : fieldList){
|
72
|
// URI uri = knownFields.get(key);
|
73
|
// if (uri != null){
|
74
|
// result.add(uri);
|
75
|
// }else{
|
76
|
// String message = "Unknown 'known field key' " + key;
|
77
|
// logger.warn(message);
|
78
|
// }
|
79
|
// }
|
80
|
// return result;
|
81
|
// }
|
82
|
|
83
|
public boolean hasEntries(){
|
84
|
return fieldEntryList.size() > 1;
|
85
|
}
|
86
|
|
87
|
public List<FieldEntry> getEntries(){
|
88
|
return fieldEntryList;
|
89
|
}
|
90
|
|
91
|
|
92
|
public String getFileLocation() {
|
93
|
return fileLocation;
|
94
|
}
|
95
|
|
96
|
public void setFileLocation(String fileLocation) {
|
97
|
this.fileLocation = fileLocation;
|
98
|
}
|
99
|
|
100
|
public boolean isCore() {
|
101
|
return isCore;
|
102
|
}
|
103
|
|
104
|
public void setCore(boolean isCore) {
|
105
|
this.isCore = isCore;
|
106
|
}
|
107
|
|
108
|
public void setRowType(String rowType) {
|
109
|
this.rowType = rowType;
|
110
|
}
|
111
|
|
112
|
public String getRowType() {
|
113
|
return rowType;
|
114
|
}
|
115
|
|
116
|
public int inc(){
|
117
|
return ++count;
|
118
|
}
|
119
|
|
120
|
public void setMetaData(boolean isMetaData) {
|
121
|
this.isMetaData = isMetaData;
|
122
|
}
|
123
|
|
124
|
public boolean isMetaData() {
|
125
|
return isMetaData;
|
126
|
}
|
127
|
|
128
|
|
129
|
/* (non-Javadoc)
|
130
|
* @see java.lang.Object#toString()
|
131
|
*/
|
132
|
@Override
|
133
|
public String toString() {
|
134
|
return this.fileLocation;
|
135
|
}
|
136
|
|
137
|
|
138
|
|
139
|
}
|