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