Project

General

Profile

Download (3.11 KB) Statistics
| Branch: | Tag: | Revision:
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.util.ArrayList;
12
import java.util.List;
13

    
14
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.common.URI;
17

    
18
/**
19
 * @author a.mueller
20
 * @since 20.04.2011
21
 */
22
public class CsvDemoMetaDataRecord  {
23
	@SuppressWarnings("unused")
24
	private static final Logger logger = LogManager.getLogger(CsvDemoMetaDataRecord.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<CsvDemoMetaDataRecord.FieldEntry>();
36
	protected List<String> fieldList = new ArrayList<String>();
37

    
38

    
39
	public CsvDemoMetaDataRecord(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
	protected class FieldEntry{
50
		int index;
51
		URI term = null;
52
		String defaultValue = null;
53
		String elementName = "field";
54
	}
55

    
56
	public void addFieldEntry(URI term, String defaultValue){
57
		FieldEntry fieldEntry = new FieldEntry();
58
		fieldEntry.index = currentIndex++;
59
		fieldEntry.term = term;
60
		fieldEntry.defaultValue = defaultValue;
61
		this.fieldEntryList.add(fieldEntry);
62
	}
63

    
64
	//TODO needed?
65
//	public abstract List<String> getHeaderList();
66

    
67
//	public List<URI> getTermList(){
68
//		List<URI> result = new ArrayList<URI>();
69
//		for (String key : fieldList){
70
//			URI uri = knownFields.get(key);
71
//			if (uri != null){
72
//				result.add(uri);
73
//			}else{
74
//				String message = "Unknown 'known field key' " + key;
75
//				logger.warn(message);
76
//			}
77
//		}
78
//		return result;
79
//	}
80

    
81
	public boolean hasEntries(){
82
		return fieldEntryList.size() > 1;
83
	}
84

    
85
	public List<FieldEntry> getEntries(){
86
		return fieldEntryList;
87
	}
88

    
89

    
90
	public String getFileLocation() {
91
		return fileLocation;
92
	}
93

    
94
	public void setFileLocation(String fileLocation) {
95
		this.fileLocation = fileLocation;
96
	}
97

    
98
	public boolean isCore() {
99
		return isCore;
100
	}
101

    
102
	public void setCore(boolean isCore) {
103
		this.isCore = isCore;
104
	}
105

    
106
	public void setRowType(String rowType) {
107
		this.rowType = rowType;
108
	}
109

    
110
	public String getRowType() {
111
		return rowType;
112
	}
113

    
114
	public int inc(){
115
		return ++count;
116
	}
117

    
118
	public void setMetaData(boolean isMetaData) {
119
		this.isMetaData = isMetaData;
120
	}
121

    
122
	public boolean isMetaData() {
123
		return isMetaData;
124
	}
125

    
126
//*********************** toString() *******************************/
127
	@Override
128
	public String toString() {
129
		return this.fileLocation;
130
	}
131
}
(7-7/10)