Skip to content

Commit

Permalink
metasfresh/metasfresh#1090 FIX NewRecordDescriptorsProvider.getNewRec…
Browse files Browse the repository at this point in the history
…ordDescriptor
  • Loading branch information
teosarca committed Mar 7, 2017
1 parent 79b01aa commit 07a0869
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ public NewRecordDescriptor getNewRecordDescriptorOrNull(final String tableName)
return newRecordDescriptorsByTableName.get(tableName);
}

/**
* @param entityDescriptor the entity descriptor of the quick input window (e.g. for BPartner that is C_BPartner_QuickInput)
* @return new record descriptor
*/
public NewRecordDescriptor getNewRecordDescriptor(final DocumentEntityDescriptor entityDescriptor)
{
final String tableName = entityDescriptor.getTableName();
final NewRecordDescriptor newRecordDescriptor = getNewRecordDescriptorOrNull(tableName);
if (newRecordDescriptor == null)
{
throw new AdempiereException("No new record quick input defined for " + tableName);
}
return newRecordDescriptor;
final int newRecordWindowId = entityDescriptor.getAD_Window_ID();

return newRecordDescriptorsByTableName.values()
.stream()
.filter(descriptor -> newRecordWindowId == descriptor.getNewRecordWindowId())
.findFirst()
.orElseThrow(() -> new AdempiereException("No new record quick input defined windowId=" + newRecordWindowId));
}

public DocumentEntityDescriptor getNewRecordEntityDescriptorIfAvailable(final String tableName)
Expand Down

0 comments on commit 07a0869

Please sign in to comment.