}
if(lblcol == -1) {
throw new AbortException("No external ID column found in primary source.");
}
for(int i = 0; i < first.dataLength(); i++) {
ExternalID data = (ExternalID) first.data(i, lblcol);
if(data == null) {
logger.debug("Object without ID encountered.");
continue;
}
Integer old = labelmap.put(data, i);
if(old != null) {
logger.debug("Duplicate id encountered: " + data + " in rows " + old + " and " + i);
}
}
}
// Process additional columns
for(int c = 1; c < sources.size(); c++) {
MultipleObjectsBundle cur = bundles.get(c);
final int lblcol;
{
int lblc = -1;
for(int i = 0; i < cur.metaLength(); i++) {
if(TypeUtil.EXTERNALID.isAssignableFromType(cur.meta(i))) {
lblc = i;
break;
}
}
lblcol = lblc; // make static
}
if(lblcol == -1) {
StringBuffer buf = new StringBuffer();
for(int i = 0; i < cur.metaLength(); i++) {
if(buf.length() > 0) {
buf.append(",");
}
buf.append(cur.meta(i));
}
throw new AbortException("No external ID column found in source " + (c + 1) + " to join with. Got: " + buf.toString());
}
// Destination columns
List<ArrayList<Object>> dcol = new ArrayList<ArrayList<Object>>(cur.metaLength());
for(int i = 0; i < cur.metaLength(); i++) {
// Skip the label columns
if(i == lblcol) {
dcol.add(null);
continue;
}
ArrayList<Object> newcol = new ArrayList<Object>(first.dataLength());
// Pre-fill with nulls.
for(int j = 0; j < first.dataLength(); j++) {
newcol.add(null);
}
first.appendColumn(cur.meta(i), newcol);
dcol.add(newcol);
}
for(int i = 0; i < cur.dataLength(); i++) {
ExternalID data = (ExternalID) cur.data(i, lblcol);
if(data == null) {
logger.warning("Object without label encountered.");
continue;
}
Integer row = labelmap.get(data);