I would model this as what I would call “Requirements and Exclusions”. If you only have a single “Product” entity, great - otherwise I would have the different entities inherit from a top level Product entity.
Then, I would have a way to edit (the relationship editor with drop zones comes to mind) both the requirement and exclusion relationships of each product. For example, for product X it might be required to have product A or product B. And with product y, we need to exclude the possibility of product h. When listing multiple related items in requirements, you might want specific logic based on your types of products to say “We only require 1 of product type ‘Mouse’”, so you might want to build 2 sets - “Required Products” and “Required Types of Products”. Then at validation, you iterate and make sure that everything in the cart has all its requirements met, and doesn’t hit any exclusions. Ken > On Oct 6, 2014, at 3:51 PM, Chuck Hill <[email protected]> wrote: > > I think Flavio’s question was more of how to model this so that the > configurations were not hard-coded in Java. I don’t have an immediate > answer, but it is an interesting modelling problem. > > Chuck > > > On 2014-10-06, 11:49 AM, "Ramsey Gurley" wrote: > > > On Oct 6, 2014, at 11:16 AM, Flavio Donadio <[email protected] > <mailto:[email protected]>> wrote: > > Hello, people! > This is a not a WO or WOnder question per se, but I think you guys can help > me. Since English is not my native language, I couldn't find anything on the > web... > I have this feature I want to implement in a website, which I call > "configurator". > In a database of products, each product has options, for example: memory > capacity (integer), display type (enum: color, monochrome), audio (boolean), > WLAN regulatory domain (enum: FCC, EU, Japan), and so on. > My problem is that some options require other specific option(s) to have a > specific value, for example: audio is only available in configurations with a > color display. > And, to confuse it a little more, different products have different options > with their own rules. > How can I create a model in a way I can input these rules for "valid" > configurations? Also, when the user browses the website, he/she can configure > the products the way they want and be assured that they won't select an > invalid configuration. > I am trying to figure this out, but it doesn't look easy. > Cheers, > Flavio > > Specifically in WO/Wonder, you can do this using NSValidation. Using your > example, you have a Product EO > > Product > -capacity > -display > -audio > -domain > > On your Product’s EO class, you would then implement validation methods for > these attributes like > > public Boolean validateAudio(Boolean audio) throws > NSValidation.ValidationException { > //TODO validate boolean here > boolean notValid = …; > if(notValid) { > ERXValidationFactory factory = ERXValidationFactory.defaultFactory(); > ERXValidationException ex = factory.createException(this, Product.AUDIO_KEY, > audio, ERXValidationException.InvalidValueException); > throw ex; > } > return audio; > } > > where the method signature is validate<KEY> where <KEY> is the name of your > attribute being validated. If you need validation that depends on values set > on multiple attributes, you would probably do that in the EO’s validateFor* > methods... validateForInsert, validateForUpdate, validateForSave, > validateForDelete. > > public void validateForSave() throws NSValidation.ValidationException { > if(display() != DisplayType.COLOR && audio() == true) { > ERXValidationFactory factory = ERXValidationFactory.defaultFactory(); > ERXValidationException ex = factory.createCustomException(this, > “AudioNotAvailableWithMonoChrome”); > throw ex; > } > } > > Then in your Resources/English.lproj/ValidationTemplate.strings file, you > would have something like > > { > “Product.AudioNotAvailableWithMonoChrome” = “Sorry, monochrome products are > not available with audio.”; > } > > If you’re using D2W, that’s it. You’re done. If you aren’t, then you need to > wire up some way to display validation errors in your page component. That > means overriding > > public void validationFailedWithException(Throwable t, Object value, String > keyPath) { > //TODO catch validation errors here to display to the user. > } > > along with some other internal array structure to handle multiple validation > exceptions, possibly nested ones down in the EO’s relationships, etc. > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected] > <mailto:[email protected]>) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net > > <https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net> > > This email sent to [email protected] > <mailto:[email protected]>_______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
