Skip to content

Commit

Permalink
Use ERCPreference batch size value when available.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarthez committed Oct 12, 2015
1 parent c9eb740 commit 95e9f30
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public interface Keys extends ERD2WEditRelationshipPage.Keys {
private EODataSource _dataSource;
private EODataSource _selectDataSource;
private WODisplayGroup _relationshipDisplayGroup;
private Integer _batchSize = null;
public boolean isRelationshipToMany;
public WOComponent nextPage;
public NextPageDelegate nextPageDelegate;
Expand Down Expand Up @@ -437,6 +438,28 @@ protected boolean isValidSortKey(NSArray<String> displayPropertyKeys, String sor
public boolean userPreferencesCanSpecifySorting() {
return !"printerFriendly".equals(d2wContext().valueForKey(Keys.subTask));
}

// BATCH SIZE

/**
* @return the batch size as set via ERCPreference or the rules
*/
public int numberOfObjectsPerBatch() {
if (_batchSize == null) {
Integer batchSize = ERXValueUtilities.IntegerValueWithDefault(d2wContext()
.valueForKey("defaultBatchSize"), 5);
Object batchSizePref = userPreferencesValueForPageConfigurationKey("batchSize");
if (batchSizePref != null) {
if (log.isDebugEnabled()) {
log.debug("Found batch size in user prefs " + batchSizePref);
}
batchSize = ERXValueUtilities.IntegerValueWithDefault(batchSizePref,
batchSize);
}
_batchSize = batchSize;
}
return _batchSize.intValue();
}

// ACCESSORS

Expand Down Expand Up @@ -494,12 +517,7 @@ public void setObjectToAddToRelationship( EOEnterpriseObject objectToAddTorRelat
public WODisplayGroup relationshipDisplayGroup() {
if (_relationshipDisplayGroup == null) {
_relationshipDisplayGroup = new WODisplayGroup();
String count = (String)d2wContext().valueForKey("defaultBatchSize");
if (count != null) {
int intCount = Integer.parseInt(count);
_relationshipDisplayGroup.setNumberOfObjectsPerBatch(intCount);
}

_relationshipDisplayGroup.setNumberOfObjectsPerBatch(numberOfObjectsPerBatch());
}
return _relationshipDisplayGroup;
}
Expand Down

0 comments on commit 95e9f30

Please sign in to comment.