Revision 4f033523
Added by Andreas Müller over 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelReferenceImport.java | ||
---|---|---|
37 | 37 |
import java.util.Set; |
38 | 38 |
import java.util.UUID; |
39 | 39 |
|
40 |
import org.apache.commons.lang.StringUtils; |
|
41 | 40 |
import org.apache.log4j.Logger; |
42 | 41 |
import org.springframework.stereotype.Component; |
43 | 42 |
|
... | ... | |
103 | 102 |
protected void initializeMappers(BerlinModelImportState state){ |
104 | 103 |
for (CdmAttributeMapperBase mapper: classMappers){ |
105 | 104 |
if (mapper instanceof DbSingleAttributeImportMapperBase){ |
106 |
DbSingleAttributeImportMapperBase<BerlinModelImportState,Reference> singleMapper = |
|
105 |
@SuppressWarnings("unchecked") |
|
106 |
DbSingleAttributeImportMapperBase<BerlinModelImportState,Reference> singleMapper = |
|
107 | 107 |
(DbSingleAttributeImportMapperBase<BerlinModelImportState,Reference>)mapper; |
108 | 108 |
singleMapper.initialize(state, Reference.class); |
109 | 109 |
} |
... | ... | |
255 | 255 |
} |
256 | 256 |
|
257 | 257 |
@Override |
258 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState state) { |
|
259 |
if (state.isReferenceSecondPath()){ |
|
258 |
public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState state) { |
|
259 |
deduplicationHelper.restartSession(); |
|
260 |
|
|
261 |
if (state.isReferenceSecondPath()){ |
|
260 | 262 |
return doPartitionSecondPath(partitioner, state); |
261 | 263 |
} |
262 | 264 |
boolean success = true; |
... | ... | |
270 | 272 |
|
271 | 273 |
try { |
272 | 274 |
|
273 |
int i = 0; |
|
274 |
RefCounter refCounter = new RefCounter(); |
|
275 |
|
|
276 |
ResultSet rs = partitioner.getResultSet(); |
|
277 |
|
|
278 |
//for each resultset |
|
279 |
while (rs.next()){ |
|
280 |
if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("References handled: " + (i-1) + " in round -" );} |
|
275 |
int i = 0; |
|
276 |
RefCounter refCounter = new RefCounter(); |
|
277 |
ResultSet rs = partitioner.getResultSet(); |
|
281 | 278 |
|
282 |
success &= makeSingleReferenceRecord(rs, state, partitioner, refToSave, relatedReferences, refCounter); |
|
283 |
} // end resultSet |
|
279 |
//for each resultset |
|
280 |
while (rs.next()){ |
|
281 |
if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("References handled: " + (i-1) + " in round -" );} |
|
284 | 282 |
|
285 |
//for the concept reference a fixed uuid may be needed -> change uuid |
|
286 |
Integer sourceSecId = (Integer)config.getSourceSecId(); |
|
287 |
Reference sec = refToSave.get(sourceSecId); |
|
283 |
success &= makeSingleReferenceRecord(rs, state, partitioner, refToSave, relatedReferences, refCounter); |
|
284 |
} // end resultSet |
|
288 | 285 |
|
289 |
if (sec != null){ |
|
290 |
sec.setUuid(config.getSecUuid()); |
|
291 |
logger.info("SecUuid changed to: " + config.getSecUuid()); |
|
292 |
} |
|
286 |
//for the concept reference a fixed uuid may be needed -> change uuid |
|
287 |
Integer sourceSecId = (Integer)config.getSourceSecId(); |
|
288 |
Reference sec = refToSave.get(sourceSecId); |
|
293 | 289 |
|
294 |
//save and store in map |
|
295 |
logger.info("Save references (" + refCounter.refCount + ")"); |
|
296 |
getReferenceService().saveOrUpdate(refToSave.values()); |
|
290 |
if (sec != null){ |
|
291 |
sec.setUuid(config.getSecUuid()); |
|
292 |
logger.info("SecUuid changed to: " + config.getSecUuid()); |
|
293 |
} |
|
297 | 294 |
|
298 |
// }//end resultSetList |
|
295 |
//save and store in map |
|
296 |
logger.info("Save references (" + refCounter.refCount + ")"); |
|
297 |
getReferenceService().saveOrUpdate(refToSave.values()); |
|
299 | 298 |
|
300 | 299 |
// logger.info("end makeReferences ..." + getSuccessString(success));; |
301 | 300 |
return success; |
... | ... | |
313 | 312 |
* @param state |
314 | 313 |
* @return |
315 | 314 |
*/ |
316 |
private boolean doPartitionSecondPath(ResultSetPartitioner partitioner, BerlinModelImportState state) { |
|
315 |
private boolean doPartitionSecondPath(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState state) {
|
|
317 | 316 |
boolean success = true; |
318 | 317 |
|
319 |
Map<Integer, Reference> refToSave = new HashMap<Integer, Reference>();
|
|
318 |
Map<Integer, Reference> refToSave = new HashMap<>(); |
|
320 | 319 |
|
321 |
Map<String, Reference> relatedReferencesMap = partitioner.getObjectMap(REFERENCE_NAMESPACE); |
|
320 |
@SuppressWarnings("unchecked") |
|
321 |
Map<String, Reference> relatedReferencesMap = partitioner.getObjectMap(REFERENCE_NAMESPACE); |
|
322 | 322 |
|
323 | 323 |
try { |
324 | 324 |
int i = 0; |
... | ... | |
534 | 534 |
private boolean makeNomAndBiblioReference( |
535 | 535 |
ResultSet rs, |
536 | 536 |
BerlinModelImportState state, |
537 |
ResultSetPartitioner partitioner, |
|
537 |
@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner,
|
|
538 | 538 |
int refId, |
539 | 539 |
Reference ref, |
540 | 540 |
RefCounter refCounter, |
... | ... | |
589 | 589 |
ref.addMarker(Marker.NewInstance(MarkerType.COMMON_NAME_REFERENCE(), true)); |
590 | 590 |
} |
591 | 591 |
|
592 |
|
|
593 | 592 |
return true; |
594 | 593 |
} |
595 | 594 |
|
... | ... | |
962 | 961 |
return (state.getConfig().getDoReferences() == IImportConfigurator.DO_REFERENCES.NONE); |
963 | 962 |
} |
964 | 963 |
|
965 |
|
|
966 |
|
|
967 |
|
|
968 | 964 |
} |
Also available in: Unified diff
cleanup