[OFBiz] Dev - How to filter a field in a <view-entity>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[OFBiz] Dev - How to filter a field in a <view-entity>

Bugzilla from elliot.li@gmail.com
Hello,

I'm trying to create a view that contains only one member entity, and
apply a filter onto one field. It is very simple, and the SQL should
be like this:

SELECT * FROM Employee WHERE isDeleted = 'N'

But I don't know how to apply this into a <view-entity> defined in
entitymodel.xml. I have searched through all the elements and
attributes of <view-entity> but found nothing helpful.

Thanks in advance.

--
Best regards,
Yan
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Si Chen-2
Li Yan,

You define your view-entity in the entitymodel.xml but you filter it
using the delegator.find_ methods in your java code, such as:

delegator.findByAnd("Employee", UtilMisc.toMap("isDeleted", "N"));

Si Chen

Yan Li wrote:

>Hello,
>
>I'm trying to create a view that contains only one member entity, and
>apply a filter onto one field. It is very simple, and the SQL should
>be like this:
>
>SELECT * FROM Employee WHERE isDeleted = 'N'
>
>But I don't know how to apply this into a <view-entity> defined in
>entitymodel.xml. I have searched through all the elements and
>attributes of <view-entity> but found nothing helpful.
>
>Thanks in advance.
>
>  
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Adam Heath-2
On Mon, 8 Aug 2005, Si Chen wrote:

> Li Yan,
>
> You define your view-entity in the entitymodel.xml but you filter it
> using the delegator.find_ methods in your java code, such as:
>
> delegator.findByAnd("Employee", UtilMisc.toMap("isDeleted", "N"));

Until such time as I forward port the change that let's you do it in
entitymodel.

The feature let you:
* create related entities, that were restricted based on a condition
* create a view-link that was restricted by a condition.
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

cjhowe
Why would you want to do it from the entity-model?  What advantage would that have over a the generic java classes from the delegator?
--- Adam Heath wrote:
On Mon, 8 Aug 2005, Si Chen wrote:

> Li Yan,
>
> You define your view-entity in the entitymodel.xml
but you filter it
> using the delegator.find_ methods in your java
code, such as:
>
> delegator.findByAnd("Employee",
UtilMisc.toMap("isDeleted", "N"));

Until such time as I forward port the change that
let's you do it in
entitymodel.

The feature let you:
* create related entities, that were restricted
based on a condition
* create a view-link that was restricted by a
condition.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Adam Heath-2
On Mon, 8 Aug 2005, Chris Howe wrote:

> Why would you want to do it from the entity-model?  What advantagewould that have over a the generic java classes from the delegator?

So if you change the model, you don't have to find all the code and change it
as well.

Consider the case when you are joining thru a fromDate/thruDate; if the model
system supported model conditions, then you would have a central location for
maintaining these queries, instead of scattered thruout the code.

Also, here's a few more ideas we've kicked around here:

==

GenericValue value = delegator.findByPrimaryKeyCache(name, keys);
value.run("procedure", data);

==

List values = delegator.runQueryCache("MyLookupQuery");

==

These ideas stem from separating code into multiple tiers; placing the
queries/conditions into separate files lets you separate the model even more.
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Si Chen-2
Generally, great ideas.

What is this value.run(...)? A stored procedure?

Also, I was surprised to find that there were no "updateByAnd" or
"updateByCondition" methods on the delegator. Do you think these would
be helpful to implement? On the other hand, never having had it for all
these years, maybe we don't really need it?

Si

Adam Heath wrote:

>On Mon, 8 Aug 2005, Chris Howe wrote:
>
>  
>
>>Why would you want to do it from the entity-model?  What advantagewould that have over a the generic java classes from the delegator?
>>    
>>
>
>So if you change the model, you don't have to find all the code and change it
>as well.
>
>Consider the case when you are joining thru a fromDate/thruDate; if the model
>system supported model conditions, then you would have a central location for
>maintaining these queries, instead of scattered thruout the code.
>
>Also, here's a few more ideas we've kicked around here:
>
>==
>
>GenericValue value = delegator.findByPrimaryKeyCache(name, keys);
>value.run("procedure", data);
>
>==
>
>List values = delegator.runQueryCache("MyLookupQuery");
>
>==
>
>These ideas stem from separating code into multiple tiers; placing the
>queries/conditions into separate files lets you separate the model even more.
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
>  
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Adam Heath-2
On Mon, 8 Aug 2005, Si Chen wrote:

> Generally, great ideas.
>
> What is this value.run(...)? A stored procedure?

Yes.  Now, what it would actually do, is another story.

> Also, I was surprised to find that there were no "updateByAnd" or
> "updateByCondition" methods on the delegator. Do you think these would
> be helpful to implement? On the other hand, never having had it for all
> these years, maybe we don't really need it?

I thought Andy did something like this, bulk updates or something.  Or am I
getting senile in my old age?
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

David E. Jones

Yep: GenericDelegator.storeByCondition



On Aug 8, 2005, at 5:32 PM, Adam Heath wrote:

> On Mon, 8 Aug 2005, Si Chen wrote:
>
>
>> Generally, great ideas.
>>
>> What is this value.run(...)? A stored procedure?
>>
>
> Yes.  Now, what it would actually do, is another story.
>
>
>> Also, I was surprised to find that there were no "updateByAnd" or
>> "updateByCondition" methods on the delegator. Do you think these  
>> would
>> be helpful to implement? On the other hand, never having had it  
>> for all
>> these years, maybe we don't really need it?
>>
>
> I thought Andy did something like this, bulk updates or something.  
> Or am I
> getting senile in my old age?
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Adam Heath-2
On Mon, 8 Aug 2005, David E. Jones wrote:

>
> Yep: GenericDelegator.storeByCondition

I need to stop putting my foot in my mouth, and letting people answer 'or'
questions.
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Bugzilla from elliot.li@gmail.com
In reply to this post by Si Chen-2
Chen,

Thanks, I'll try it.

But it would be much more handy if you can specify constraint directly
in the definition of <view-entity>, just like the widely used WHERE
clause in the creation of a view by SQL, isn't it?

On 8/9/05, Si Chen <[hidden email]> wrote:

> Li Yan,
>
> You define your view-entity in the entitymodel.xml but you filter it
> using the delegator.find_ methods in your java code, such as:
>
> delegator.findByAnd("Employee", UtilMisc.toMap("isDeleted", "N"));
>
> Si Chen
>
> Yan Li wrote:
>
> >Hello,
> >
> >I'm trying to create a view that contains only one member entity, and
> >apply a filter onto one field. It is very simple, and the SQL should
> >be like this:
> >
> >SELECT * FROM Employee WHERE isDeleted = 'N'
> >
> >But I don't know how to apply this into a <view-entity> defined in
> >entitymodel.xml. I have searched through all the elements and
> >attributes of <view-entity> but found nothing helpful.
> >
> >Thanks in advance.
> >
> >
> >
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>


--
Best regards,
Yan
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - How to filter a field in a <view-entity>

Bugzilla from elliot.li@gmail.com
In reply to this post by Adam Heath-2
Adam,

Yeah, I can't agree with you more. I need to create many views that
needing constraints on fields.

On 8/9/05, Adam Heath <[hidden email]> wrote:

> On Mon, 8 Aug 2005, Chris Howe wrote:
>
> > Why would you want to do it from the entity-model?  What advantagewould that have over a the generic java classes from the delegator?
>
> So if you change the model, you don't have to find all the code and change it
> as well.
>
> Consider the case when you are joining thru a fromDate/thruDate; if the model
> system supported model conditions, then you would have a central location for
> maintaining these queries, instead of scattered thruout the code.
>
> Also, here's a few more ideas we've kicked around here:
>
> ==
>
> GenericValue value = delegator.findByPrimaryKeyCache(name, keys);
> value.run("procedure", data);
>
> ==
>
> List values = delegator.runQueryCache("MyLookupQuery");
>
> ==
>
> These ideas stem from separating code into multiple tiers; placing the
> queries/conditions into separate files lets you separate the model even more.
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>


--
Best regards,
Yan
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev