Revision 337563aa
Added by Andreas Müller over 6 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/StreamPartitioner.java | ||
---|---|---|
38 | 38 |
private final StreamImportStateBase<StreamImportConfiguratorBase, StreamImportBase> state; |
39 | 39 |
private ConcatenatingReader<MappedCdmBase<? extends CdmBase>> outStream; |
40 | 40 |
|
41 |
public StreamPartitioner(INamespaceReader<ITEM> input, IPartitionableConverter converter, StreamImportStateBase state, Integer size){ |
|
42 |
this.inStream = new LookAheadStream<ITEM>(input); |
|
41 |
public StreamPartitioner(INamespaceReader<ITEM> input, IPartitionableConverter converter, |
|
42 |
StreamImportStateBase<StreamImportConfiguratorBase, StreamImportBase> state, Integer size){ |
|
43 |
this.inStream = new LookAheadStream<>(input); |
|
43 | 44 |
this.converter = converter; |
44 | 45 |
this.partitionSize = size; |
45 | 46 |
this.state = state; |
... | ... | |
73 | 74 |
} |
74 | 75 |
|
75 | 76 |
private void handleNextPartition(){ |
76 |
List<ITEM> lookaheadArray = new ArrayList<ITEM>();
|
|
77 |
List<ITEM> lookaheadArray = new ArrayList<>(); |
|
77 | 78 |
while (this.inStream.hasNextLookAhead(partitionSize)){ |
78 | 79 |
lookaheadArray.add(this.inStream.readLookAhead()); |
79 | 80 |
} |
80 | 81 |
|
81 |
IReader<ITEM> lookaheadStream = new ListReader<ITEM>(lookaheadArray);
|
|
82 |
IReader<ITEM> lookaheadStream = new ListReader<>(lookaheadArray); |
|
82 | 83 |
|
83 | 84 |
Map<String, Set<String>> foreignKeys = converter.getPartitionForeignKeys(lookaheadStream); |
84 | 85 |
IImportMapping mapping = state.getMapping(); |
... | ... | |
118 | 119 |
if (cdmBase.isInstanceOf(IdentifiableEntity.class)){ |
119 | 120 |
Set<String> requiredSourceNamespaces = converter.requiredSourceNamespaces(); |
120 | 121 |
if (requiredSourceNamespaces.contains(item.getNamespace())){ |
121 |
if (item.getCdmBase().isInstanceOf(IdentifiableEntity.class)) { |
|
122 |
IdentifiableEntity identEntity = CdmBase.deproxy(item.getCdmBase(), IdentifiableEntity.class); |
|
123 |
state.addRelatedObject(item.getNamespace(), item.getSourceId(), identEntity); |
|
124 |
}else{ |
|
125 |
|
|
126 |
} |
|
122 |
state.addRelatedObject(item.getNamespace(), item.getSourceId(), item.getCdmBase()); |
|
127 | 123 |
} |
128 | 124 |
} |
129 | 125 |
} |
Also available in: Unified diff
cleanup