Revision ab4cc1fb
Added by Andreas Müller about 14 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/erms/ErmsDrImport.java | ||
---|---|---|
20 | 20 |
import org.springframework.stereotype.Component; |
21 | 21 |
|
22 | 22 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
23 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
|
24 | 23 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportAnnotationMapper; |
25 | 24 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportDistributionCreationMapper; |
26 | 25 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
... | ... | |
43 | 42 |
*/ |
44 | 43 |
@Component |
45 | 44 |
public class ErmsDrImport extends ErmsImportBase<Distribution> { |
45 |
@SuppressWarnings("unused") |
|
46 | 46 |
private static final Logger logger = Logger.getLogger(ErmsDrImport.class); |
47 | 47 |
|
48 | 48 |
private DbImportMapping mapping; |
49 | 49 |
|
50 | 50 |
private int modCount = 10000; |
51 | 51 |
private static final String pluralString = "distributions"; |
52 |
private static String dbTableName = "dr"; |
|
53 |
private Class cdmTargetClass = Distribution.class; |
|
52 |
private static final String dbTableName = "dr";
|
|
53 |
private static final Class cdmTargetClass = Distribution.class;
|
|
54 | 54 |
|
55 | 55 |
public ErmsDrImport(){ |
56 |
super(pluralString, dbTableName); |
|
56 |
super(pluralString, dbTableName, cdmTargetClass);
|
|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
|
... | ... | |
69 | 69 |
return strRecordQuery; |
70 | 70 |
} |
71 | 71 |
|
72 |
/**
|
|
73 |
* @return
|
|
72 |
/* (non-Javadoc)
|
|
73 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping()
|
|
74 | 74 |
*/ |
75 |
private DbImportMapping getMapping() {
|
|
75 |
protected DbImportMapping getMapping() {
|
|
76 | 76 |
if (mapping == null){ |
77 | 77 |
mapping = new DbImportMapping(); |
78 | 78 |
PresenceTerm status = PresenceTerm.PRESENT(); |
... | ... | |
87 | 87 |
return mapping; |
88 | 88 |
} |
89 | 89 |
|
90 |
|
|
91 |
public boolean doPartition(ResultSetPartitioner partitioner, ErmsImportState state) { |
|
92 |
boolean success = true ; |
|
93 |
ErmsImportConfigurator config = state.getConfig(); |
|
94 |
Set referencesToSave = new HashSet<TaxonBase>(); |
|
95 |
|
|
96 |
DbImportMapping<?, ?> mapping = getMapping(); |
|
97 |
mapping.initialize(state, cdmTargetClass); |
|
98 |
|
|
99 |
ResultSet rs = partitioner.getResultSet(); |
|
100 |
try{ |
|
101 |
while (rs.next()){ |
|
102 |
success &= mapping.invoke(rs,referencesToSave); |
|
103 |
} |
|
104 |
} catch (SQLException e) { |
|
105 |
logger.error("SQLException:" + e); |
|
106 |
return false; |
|
107 |
} |
|
108 |
|
|
109 |
partitioner.startDoSave(); |
|
110 |
getReferenceService().save(referencesToSave); |
|
111 |
return success; |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
|
|
116 | 90 |
/* (non-Javadoc) |
117 | 91 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
118 | 92 |
*/ |
Also available in: Unified diff
some refactoring in the IO classes