Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sapphire-dev] Validate a ValueProperty

Ah. Good point. Then you are down to what you are doing or factoring out
your validation logic so that you can call it separately as needed.

-----Original Message-----
From: sapphire-dev-bounces@xxxxxxxxxxx
[mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Ling Hao
Sent: Wednesday, August 10, 2011 4:22 PM
To: Sapphire project
Subject: Re: [sapphire-dev] Validate a ValueProperty

That was very similar to my first attempt. But the problem was that it 
validated my existing instance. I believe it is not possible to just 
validate my value string because of target() in 
ModelPropertyValidationService

return (T) element().read( property() );

Any other suggestions?

On 8/10/2011 3:43 PM, Konstantin Komissarchik wrote:
> There isn't a conceptual problem with instantiating and using a model
> element, except where it depends on being part of a bigger model which
isn't
> there (as is the case with this @DependsOn annotation).
>
> There isn't a way to suppress this particular error message.
>
> Do you have access to an existing instance of this model element? If you
do,
> you can pull the set of ValidationService instances for the property and
run
> validation yourself without modifying the existing model...
>
> final Status.CompositeStatusFactory factory =
Status.factoryForComposite();
>
> for( ValidationService svc : element.services( property,
> ValidationService.class ) )
> {
>      factory.merge( svc.validation() );
> }
>
> return factory.create();
>
>
> -----Original Message-----
> From: sapphire-dev-bounces@xxxxxxxxxxx
> [mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Ling Hao
> Sent: Wednesday, August 10, 2011 3:27 PM
> To: Sapphire project
> Subject: [sapphire-dev] Validate a ValueProperty
>
> I need to validate a value against its ValueProperty. I found the
> following way:
>
>                                   ICachingScheme newScheme =
> scheme.getModelElementType().instantiate();
>
> newScheme.resource().binding((ValueProperty)property).write(value);
>                                   newScheme.refresh(property);
>                                   Value<?>  newValue =
> newScheme.read((ValueProperty)property);
>                                   return newValue.validate();
>
> This seems to work, except there is a @DependsOn() annotation in another
> property which caused the following error:
>
> ERROR : Invalid model path "CachingSchemes/SchemeName" evaluated on
>
oracle.eclipse.tools.coherence.descriptors.cacheConfig.IPagedExternalScheme.
>
> First of all, I'm not sure if instantiating an in-memory ModelElement is
> the right approach. If it is, Is there a way a suppress the error
> message in the in-memory case?
>
> Thanks!
> _______________________________________________
> sapphire-dev mailing list
> sapphire-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/sapphire-dev
>
> _______________________________________________
> sapphire-dev mailing list
> sapphire-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/sapphire-dev
_______________________________________________
sapphire-dev mailing list
sapphire-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/sapphire-dev



Back to the top