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