Re: Validation messages to auto-attributes of a service

2016-10-13 Thread Rishi Solanki
Devanshu,

You can simply try to use override to override the default behavior of
auto-attribute. For example; if you are working on PartyContanctMech and
you want partyId and contactMechId should return custom error message if
empty. Then use the following practice to do that;




 




Override tag intended to override the default behavior set in the
auto-attributes. Simply using it suggested and implemented at service
defintion level.


HTH!



Rishi Solanki
Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com

On Thu, Oct 13, 2016 at 11:14 AM, Devanshu Vyas 
wrote:

> Hello Guys,
>
> I came across a situation where I tried to throw a custom
> (more user-friendly) validation message when a required field in a service
> is missing. And the service definition was written with auto-attributes,
> something like this:
>
> 
>
> And I found myself stuck as I wanted to throw a custom message on a
> specific field among the PKs of the entity.
>
> I want you to suggest me a way to set validate message in such situation
> like we set on a single attribute like:
>
>  optional="false">
> 
>  property="checkhelper.select_shipping_destination"/>
> 
> 
>
> IMO, we can think of doing something like the exclude field inside the
> auto-attributes to define the validate messages on the fields.
>
> 
> 
> 
>
> Something like this:
>
> 
>  resource="OrderUiLabels"
> property="checkhelper.select_shipping_destination"/>
> 
>
> Please share your thoughts. :)
>
> --
> Thanks and Regards,
> Devanshu Vyas
>


Re: Validation messages to auto-attributes of a service

2016-10-13 Thread Rishi Solanki
Applying same to your example;




 






Rishi Solanki
Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com

On Thu, Oct 13, 2016 at 1:46 PM, Rishi Solanki 
wrote:

> Devanshu,
>
> You can simply try to use override to override the default behavior of
> auto-attribute. For example; if you are working on PartyContanctMech and
> you want partyId and contactMechId should return custom error message if
> empty. Then use the following practice to do that;
>
> 
> 
> 
>  
> 
> 
>
>
> Override tag intended to override the default behavior set in the
> auto-attributes. Simply using it suggested and implemented at service
> defintion level.
>
>
> HTH!
>
>
>
> Rishi Solanki
> Manager, Enterprise Software Development
> HotWax Systems Pvt. Ltd.
> Direct: +91-9893287847
> http://www.hotwaxsystems.com
>
> On Thu, Oct 13, 2016 at 11:14 AM, Devanshu Vyas  > wrote:
>
>> Hello Guys,
>>
>> I came across a situation where I tried to throw a custom
>> (more user-friendly) validation message when a required field in a service
>> is missing. And the service definition was written with auto-attributes,
>> something like this:
>>
>> 
>>
>> And I found myself stuck as I wanted to throw a custom message on a
>> specific field among the PKs of the entity.
>>
>> I want you to suggest me a way to set validate message in such situation
>> like we set on a single attribute like:
>>
>> > optional="false">
>> 
>> > property="checkhelper.select_shipping_destination"/>
>> 
>> 
>>
>> IMO, we can think of doing something like the exclude field inside the
>> auto-attributes to define the validate messages on the fields.
>>
>> 
>> 
>> 
>>
>> Something like this:
>>
>> 
>> > resource="OrderUiLabels"
>> property="checkhelper.select_shipping_destination"/>
>> 
>>
>> Please share your thoughts. :)
>>
>> --
>> Thanks and Regards,
>> Devanshu Vyas
>>
>
>


Re: svn commit: r1759147 - in /ofbiz/trunk/applications/order/groovyScripts: entry/ entry/cart/ entry/catalog/ order/ quote/

2016-10-13 Thread Paul Foxworthy
Hi all,

Can I turn the proposition around? If I was looking for example code to
find products with a feature, I would be looking in the wiki and other
documentation. In other words, I would look in places where examples are to
be found. I would not look in the source code. So putting an example in the
code would make it obscure and hard to find.

Cheers

Paul Foxworthy


On 2 October 2016 at 21:55, Jacques Le Roux 
wrote:

> Despite the possible decay, I still think the best place is in the
> context. But it's up to the community.
>
> Jacques
>
>
>
> Le 02/10/2016 à 12:25, Taher Alkhateeb a écrit :
>
>> Put it somewhere in documentation if you want to. Live code is not a place
>> for commented out code snippets, it's bad coding practice and it adds to
>> the entropy and chaos. Commented out code with time decays and eventually
>> becomes broken and does not even work (changing dependencies, API
>> signatures, etc ...). Also, usually when committers see commented out code
>> they think someone put it there because they're working on it and it is
>> important somehow. No code should be important and everything should be
>> subject to refactoring and improvement.
>>
>> I think places where example code is suitable are: documentation and
>> tests.
>> Beyond that, it is just dead weight
>>
>> On Sun, Oct 2, 2016 at 1:17 PM, Jacques Le Roux <
>> jacques.le.r...@les7arts.com> wrote:
>>
>> Then how to keep this interesting code example?
>>>
>>> Jacques
>>>
>>>
>>>
>>> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>>>
>>> Commented out code should always be removed as a general programming
 guideline

 On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
 jacques.le.r...@les7arts.com> wrote:

 Hi Ashish,

> I think we should keep this example
>
> Thanks
>
> Jacques
>
>
> Le 04/09/2016 à 08:41, ash...@apache.org a écrit :
>
> Author: ashish
>
>> Date: Sun Sep  4 06:41:20 2016
>> New Revision: 1759147
>>
>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>> Log:
>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out
>> code
>> in Groovy for Order. Thanks Aman for the contribution.
>>
>> -/*
>> -  The following code is commented out because it is just an
>> example
>> of the business logic to retrieve products with a similar feature.
>> -
>> -// get other cross-sell information: product with a common
>> feature
>> -commonProductFeatureId = "SYMPTOM";
>> -// does this product have that feature?
>> -commonProductFeatureAndAppls = delegator.findByAnd("ProductFe
>> atureAndAppl",
>> [productId : productId, productFeatureTypeId :
>> commonProductFeatureId],
>> ["sequenceNum", "defaultSequenceNum"], false);
>> -if (commonProductFeatureAndAppls) {
>> -commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>> -
>> -// now search for other products that have this feature
>> -visitId = VisitHandler.getVisitId(session);
>> -
>> -productSearchConstraintList = [];
>> -productSearchConstraintList.add(new
>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>> -// make sure the view allow category is included
>> -productSearchConstraintList = ProductSearchSession.ensureVie
>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>> delegator);
>> -
>> -// don't care about the sort on this one
>> -resultSortOrder = null;
>> -
>> -commonFeatureResultIdsOrig = ProductSearch.searchProducts(p
>> roductSearchConstraintList,
>> resultSortOrder, delegator, visitId);
>> -commonFeatureResultIds = [];
>> -commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>> rator();
>> -while (commonFeatureResultIdIter.hasNext()) {
>> -commonFeatureResultId = commonFeatureResultIdIter.next
>> ();
>> -// filter out the current product
>> -if (commonFeatureResultId.equals(productId)) {
>> -continue;
>> -}
>> -// filter out all variants
>> -commonProduct = delegator.findOne("Product", [productId :
>> commonFeatureResultId], true);
>> -if ("Y".equals(commonProduct?.isVariant)) {
>> -continue;
>> -}
>> -commonFeatureResultIds.add(commonFeatureResultId);
>> -}
>> -if (commonFeatureResultIds) {
>> -context.commonFeatureResultIds = commonFeatureResultIds;
>> -}
>> -}
>> -*/
>> -
>> // get the DIGITAL_DOWNLOAD related Content records to show
>> the
>> contentName/description