|
From: <cli...@gr...> - 2007-01-29 18:45:50
|
Author: cliberty
Date: 2007-01-29 10:45:39 -0800 (Mon, 29 Jan 2007)
New Revision: 54
Modified:
versions/0.9/trunk/servicedef/services.xml
versions/0.9/trunk/src/org/opentaps/dataimport/ProductImportServices.java
Log:
Making goodIdentificationTypeId1 and 2 optional parameters in the importProducts service.
Modified: versions/0.9/trunk/servicedef/services.xml
===================================================================
--- versions/0.9/trunk/servicedef/services.xml 2007-01-24 17:30:04 UTC (rev 53)
+++ versions/0.9/trunk/servicedef/services.xml 2007-01-29 18:45:39 UTC (rev 54)
@@ -46,8 +46,8 @@
own transaction, so it can store as many good records as possible.
The goodIdentificationTypeIdN parameters correspond to the type of the customIdN fields in DataImportProduct.
</description>
- <attribute type="String" mode="IN" name="goodIdentificationTypeId1" optional="false"/>
- <attribute type="String" mode="IN" name="goodIdentificationTypeId2" optional="false"/>
+ <attribute type="String" mode="IN" name="goodIdentificationTypeId1" optional="true"/>
+ <attribute type="String" mode="IN" name="goodIdentificationTypeId2" optional="true"/>
<attribute type="Integer" mode="OUT" name="productsImported" optional="true"/>
</service>
Modified: versions/0.9/trunk/src/org/opentaps/dataimport/ProductImportServices.java
===================================================================
--- versions/0.9/trunk/src/org/opentaps/dataimport/ProductImportServices.java 2007-01-24 17:30:04 UTC (rev 53)
+++ versions/0.9/trunk/src/org/opentaps/dataimport/ProductImportServices.java 2007-01-29 18:45:39 UTC (rev 54)
@@ -53,6 +53,23 @@
// main try/catch block that traps errors related to obtaining data from delegator
try {
+
+ // make sure the supplied goodIdentificationTypes exist
+ GenericValue goodIdentificationType1 = null;
+ if (! UtilValidate.isEmpty(goodIdentificationTypeId1)) {
+ goodIdentificationType1 = delegator.findByPrimaryKey("GoodIdentificationType", UtilMisc.toMap("goodIdentificationTypeId", goodIdentificationTypeId1));
+ if (goodIdentificationType1 == null) {
+ return ServiceUtil.returnError("Cannot import products: goodIdentificationType ["+goodIdentificationTypeId1+"] does not exist.");
+ }
+ }
+ GenericValue goodIdentificationType2 = null;
+ if (! UtilValidate.isEmpty(goodIdentificationTypeId2)) {
+ goodIdentificationType2 = delegator.findByPrimaryKey("GoodIdentificationType", UtilMisc.toMap("goodIdentificationTypeId", goodIdentificationTypeId1));
+ if (goodIdentificationType2 == null) {
+ return ServiceUtil.returnError("Cannot import products: goodIdentificationType ["+goodIdentificationTypeId2+"] does not exist.");
+ }
+ }
+
// need to get an ELI because of possibly large number of records. productId <> null will get all records
EntityConditionList conditions = new EntityConditionList( UtilMisc.toList(
new EntityExpr("productId", EntityOperator.NOT_EQUAL, null),
@@ -151,7 +168,7 @@
toStore.add(productPrice);
// good identification (this is per customIdN)
- if (!UtilValidate.isEmpty(data.getString("customId1"))) {
+ if (!UtilValidate.isEmpty(data.getString("customId1")) && !UtilValidate.isEmpty(goodIdentificationTypeId1)) {
input = FastMap.newInstance();
input.put("goodIdentificationTypeId", goodIdentificationTypeId1);
input.put("productId", product.get("productId"));
@@ -159,7 +176,7 @@
GenericValue goodIdentification = delegator.makeValue("GoodIdentification", input);
toStore.add(goodIdentification);
}
- if (!UtilValidate.isEmpty(data.getString("customId2"))) {
+ if (!UtilValidate.isEmpty(data.getString("customId1")) && !UtilValidate.isEmpty(goodIdentificationTypeId2)) {
input = FastMap.newInstance();
input.put("goodIdentificationTypeId", goodIdentificationTypeId2);
input.put("productId", product.get("productId"));
|