Commit 58495fbf authored by Mark Orlando Molina's avatar Mark Orlando Molina Committed by Víctor Martínez Romanos
Browse files

Fixes ISSUE-45823: Created new "ManageVariantsLimit" preference limit

Currently was hard-coded a fixed limit of 1000 possible records that can be created when processing products variants.

To make more flexible this limit, a new "ManageVariantsLimit" preference is created as an attribute preference to handle this threshold in a more configurable way.
parent df2e6b3b
......@@ -20551,6 +20551,18 @@ You can upgrade the license of your instance by contacting Openbravo sales staff
<!--626F58F6C94843FE9EC377A1E9BB81B8--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--626F58F6C94843FE9EC377A1E9BB81B8--></AD_MESSAGE>
 
<!--62EFB05DD99D4CCB83E5DA567A379E65--><AD_MESSAGE>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <AD_MESSAGE_ID><![CDATA[62EFB05DD99D4CCB83E5DA567A379E65]]></AD_MESSAGE_ID>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <VALUE><![CDATA[ManageVariantsLimitReached]]></VALUE>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <MSGTEXT><![CDATA[The number of records is too high. Please, either try to review and reduce the number of product characteristics or alternatively set the ManageVariantsLimit preference to a higher value.]]></MSGTEXT>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--62EFB05DD99D4CCB83E5DA567A379E65--> <ISINCLUDEINI18N><![CDATA[Y]]></ISINCLUDEINI18N>
<!--62EFB05DD99D4CCB83E5DA567A379E65--></AD_MESSAGE>
<!--631B7EBFDD604B18B92CCF2F855602FE--><AD_MESSAGE>
<!--631B7EBFDD604B18B92CCF2F855602FE--> <AD_MESSAGE_ID><![CDATA[631B7EBFDD604B18B92CCF2F855602FE]]></AD_MESSAGE_ID>
<!--631B7EBFDD604B18B92CCF2F855602FE--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
......@@ -46,6 +46,17 @@
<!--D965E00387CB434DAD78493B417AFD37--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--D965E00387CB434DAD78493B417AFD37--></AD_PREFERENCE>
<!--E801D3AEAD134E7C8106B7A986DA00D3--><AD_PREFERENCE>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <AD_PREFERENCE_ID><![CDATA[E801D3AEAD134E7C8106B7A986DA00D3]]></AD_PREFERENCE_ID>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <ATTRIBUTE><![CDATA[ManageVariantsLimit]]></ATTRIBUTE>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <VALUE><![CDATA[1000]]></VALUE>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <ISPROPERTYLIST><![CDATA[N]]></ISPROPERTYLIST>
<!--E801D3AEAD134E7C8106B7A986DA00D3--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--E801D3AEAD134E7C8106B7A986DA00D3--></AD_PREFERENCE>
<!--F44893EDBDA84C6BAF99A1F8550E5044--><AD_PREFERENCE>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_PREFERENCE_ID><![CDATA[F44893EDBDA84C6BAF99A1F8550E5044]]></AD_PREFERENCE_ID>
<!--F44893EDBDA84C6BAF99A1F8550E5044--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
......
......@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2013-2020 Openbravo SLU
* All portions are Copyright (C) 2013-2021 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
*************************************************************************
......@@ -45,6 +45,7 @@ import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
import org.openbravo.dal.service.OBQuery;
import org.openbravo.erpCommon.businessUtility.Preferences;
import org.openbravo.model.ad.domain.Reference;
import org.openbravo.model.common.plm.Characteristic;
import org.openbravo.model.common.plm.CharacteristicValue;
......@@ -145,9 +146,8 @@ public class ManageVariantsDS extends ReadOnlyDataSourceService {
i++;
}
if (variantNumber > 1000) {
throw new OBException("HighRecords");
}
throwExceptionIfVariantNumberIsTooHigh(variantNumber);
totalMaxLength += Long.toString(variantNumber).length();
boolean useCodes = totalMaxLength <= SEARCH_KEY_LENGTH;
......@@ -296,6 +296,23 @@ public class ManageVariantsDS extends ReadOnlyDataSourceService {
return result;
}
private void throwExceptionIfVariantNumberIsTooHigh(long variantNumber) {
if (variantNumber > getManageVariantsLimitPrefValue()) {
throw new OBException("ManageVariantsLimitReached");
}
}
private int getManageVariantsLimitPrefValue() {
try {
OBContext context = OBContext.getOBContext();
return Integer.parseInt(
Preferences.getPreferenceValue("ManageVariantsLimit", false, context.getCurrentClient(),
context.getCurrentOrganization(), context.getUser(), context.getRole(), null));
} catch (Exception e) {
return 1000;
}
}
private ProductChSelectedFilters readCriteria(Map<String, String> parameters)
throws JSONException {
ProductChSelectedFilters selectedFilters = new ProductChSelectedFilters();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment