1
|
/**
|
2
|
* Copyright (C) 2017 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.reference.ris.in;
|
10
|
|
11
|
import java.io.IOException;
|
12
|
import java.io.InputStream;
|
13
|
import java.io.InputStreamReader;
|
14
|
import java.net.MalformedURLException;
|
15
|
import java.net.URI;
|
16
|
import java.net.URL;
|
17
|
|
18
|
import org.apache.commons.io.IOUtils;
|
19
|
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
\* @since 11.05.2017
|
28
|
*
|
29
|
*/
|
30
|
public class RisReferenceImportConfigurator
|
31
|
extends ExcelImportConfiguratorBase{
|
32
|
|
33
|
private static final long serialVersionUID = -5982826645441621962L;
|
34
|
// private static IInputTransformer defaultTransformer = null;
|
35
|
|
36
|
/**
|
37
|
* @param uri
|
38
|
* @param object
|
39
|
* @return
|
40
|
* @throws IOException
|
41
|
* @throws MalformedURLException
|
42
|
*/
|
43
|
public static RisReferenceImportConfigurator NewInstance(URI uri, ICdmDataSource cdm) throws MalformedURLException, IOException {
|
44
|
RisReferenceImportConfigurator result = new RisReferenceImportConfigurator(uri, cdm);
|
45
|
return result;
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* @param uri
|
50
|
* @param object
|
51
|
* @return
|
52
|
* @throws IOException
|
53
|
* @throws MalformedURLException
|
54
|
*/
|
55
|
|
56
|
public static RisReferenceImportConfigurator NewInstance(URL url, ICdmDataSource cdm) throws IOException {
|
57
|
InputStream stream = url.openStream();
|
58
|
InputStreamReader reader = new InputStreamReader(stream, "UTF8");
|
59
|
|
60
|
RisReferenceImportConfigurator result = new RisReferenceImportConfigurator();
|
61
|
result.setStream(IOUtils.toByteArray(reader));
|
62
|
return result;
|
63
|
}
|
64
|
|
65
|
public static RisReferenceImportConfigurator NewInstance() {
|
66
|
RisReferenceImportConfigurator result = new RisReferenceImportConfigurator(null, null);
|
67
|
|
68
|
return result;
|
69
|
}
|
70
|
|
71
|
|
72
|
|
73
|
/**
|
74
|
* @param transformer
|
75
|
*/
|
76
|
protected RisReferenceImportConfigurator() {
|
77
|
super(null,null);
|
78
|
}
|
79
|
|
80
|
protected RisReferenceImportConfigurator(URI uri, ICdmDataSource cdm) {
|
81
|
super(uri, cdm, null);
|
82
|
}
|
83
|
|
84
|
|
85
|
/**
|
86
|
* {@inheritDoc}
|
87
|
*/
|
88
|
@Override
|
89
|
public RisReferenceImportState getNewState() {
|
90
|
return new RisReferenceImportState(this);
|
91
|
}
|
92
|
|
93
|
|
94
|
/**
|
95
|
* {@inheritDoc}
|
96
|
*/
|
97
|
@Override
|
98
|
protected void makeIoClassList() {
|
99
|
ioClassList = new Class[]{
|
100
|
RisReferenceImport.class
|
101
|
};
|
102
|
}
|
103
|
|
104
|
|
105
|
/**
|
106
|
* {@inheritDoc}
|
107
|
*/
|
108
|
@Override
|
109
|
public Reference getSourceReference() {
|
110
|
if (this.sourceReference == null){
|
111
|
sourceReference = ReferenceFactory.newGeneric();
|
112
|
if (this.getSource() == null){
|
113
|
sourceReference.setTitleCache("RIS Reference Import " + getDateString(), true);
|
114
|
}else{
|
115
|
sourceReference.setTitleCache(getSource().toString(), true);
|
116
|
}
|
117
|
}
|
118
|
return sourceReference;
|
119
|
}
|
120
|
|
121
|
@Override
|
122
|
public boolean isValid(){
|
123
|
return true;
|
124
|
}
|
125
|
|
126
|
|
127
|
}
|