1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.app.images;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.io.FileNotFoundException;
|
14
|
import eu.etaxonomy.cdm.common.URI;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
20
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
21
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
|
25
|
/**
|
26
|
* @author n.hoffmann
|
27
|
* @since 11.11.2008
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class ImageImportConfigurator extends ImportConfiguratorBase<ImageImportState, URI> implements IImportConfigurator {
|
31
|
private static final Logger logger = Logger.getLogger(ImageImportConfigurator.class);
|
32
|
|
33
|
|
34
|
public static ImageImportConfigurator NewInstance(URI source, ICdmDataSource destination, String mediaUrlString, Class<? extends AbstractImageImporter> importerClass){
|
35
|
return new ImageImportConfigurator(source, destination, mediaUrlString, importerClass);
|
36
|
}
|
37
|
|
38
|
|
39
|
//TODO
|
40
|
private static IInputTransformer defaultTransformer = null;
|
41
|
|
42
|
|
43
|
/**
|
44
|
* @param source
|
45
|
* @param destination
|
46
|
* @param importerClass
|
47
|
* @return
|
48
|
*/
|
49
|
|
50
|
public static ImageImportConfigurator NewInstance(URI source, ICdmDataSource destination, Class<? extends AbstractImageImporter> importerClass){
|
51
|
return new ImageImportConfigurator(source, destination, null, importerClass);
|
52
|
}
|
53
|
|
54
|
private ImageImportConfigurator(URI source, ICdmDataSource destination, String mediaUrlString, Class<? extends AbstractImageImporter> importerClass){
|
55
|
super(defaultTransformer);
|
56
|
FileNotFoundException e;
|
57
|
setSource(source);
|
58
|
setDestination(destination);
|
59
|
setMediaUrlString(mediaUrlString);
|
60
|
ioClassList = new Class[] {importerClass};
|
61
|
}
|
62
|
|
63
|
private String mediaUrlString = null;
|
64
|
|
65
|
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
69
|
*/
|
70
|
// @Override
|
71
|
public Reference getSourceReference() {
|
72
|
//TODO
|
73
|
if (this.sourceReference == null){
|
74
|
logger.warn("getSource Reference not yet fully implemented");
|
75
|
sourceReference = ReferenceFactory.newDatabase();
|
76
|
sourceReference.setTitleCache("XXX", true);
|
77
|
}
|
78
|
return sourceReference;
|
79
|
}
|
80
|
|
81
|
/* (non-Javadoc)
|
82
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
|
83
|
*/
|
84
|
@Override
|
85
|
//NOT used, component class is injected via constructor
|
86
|
protected void makeIoClassList() {
|
87
|
ioClassList = new Class[] {
|
88
|
AbstractImageImporter.class
|
89
|
};
|
90
|
}
|
91
|
|
92
|
|
93
|
/**
|
94
|
* @return the mediaUrlString
|
95
|
*/
|
96
|
public String getMediaUrlString() {
|
97
|
if(mediaUrlString == null){
|
98
|
throw new NullPointerException("mediaUrlString has not been set");
|
99
|
}
|
100
|
return mediaUrlString;
|
101
|
}
|
102
|
|
103
|
/**
|
104
|
* @param mediaUrlString the mediaUrlString to set
|
105
|
*/
|
106
|
public void setMediaUrlString(String mediaUrlString) {
|
107
|
this.mediaUrlString = mediaUrlString;
|
108
|
}
|
109
|
|
110
|
|
111
|
/* (non-Javadoc)
|
112
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
113
|
*/
|
114
|
public String getSourceNameString() {
|
115
|
return "Image file " + getSource();
|
116
|
}
|
117
|
|
118
|
/* (non-Javadoc)
|
119
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
120
|
*/
|
121
|
public ImageImportState getNewState() {
|
122
|
return new ImageImportState(this);
|
123
|
}
|
124
|
}
|