IDEMPIERE-2144 Pack in of Attachment: Update entry is using wrong index.
This commit is contained in:
parent
1b75bb4e78
commit
6758daac61
|
@ -303,6 +303,7 @@ public class MAttachment extends X_AD_Attachment
|
|||
}
|
||||
if (!replaced) {
|
||||
retValue = m_items.add(item);
|
||||
item.setIndex(m_items.size());
|
||||
}
|
||||
if (log.isLoggable(Level.FINE)) log.fine(item.toStringX());
|
||||
setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
|
||||
|
|
|
@ -296,4 +296,8 @@ public class MAttachmentEntry
|
|||
return new ByteArrayInputStream(m_data);
|
||||
} // getInputStream
|
||||
|
||||
public void setIndex(int index) {
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
} // MAttachmentItem
|
||||
|
|
|
@ -304,15 +304,20 @@ public class PoFiller{
|
|||
MAttachment attach = ((MAttachment)po);
|
||||
for (File file : files) {
|
||||
boolean found = false;
|
||||
int index = -1;
|
||||
for (MAttachmentEntry entry : attach.getEntries()) {
|
||||
index++;
|
||||
if (entry.getName().equals(file.getName())) {
|
||||
found = true;
|
||||
attach.updateEntry(entry.getIndex(), file);
|
||||
attach.updateEntry(index, file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found)
|
||||
attach.addEntry(file);
|
||||
}
|
||||
if (!attach.is_Changed())
|
||||
attach.set_ValueNoCheck("Updated", new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
} else {
|
||||
Object data = null;
|
||||
|
|
Loading…
Reference in New Issue