Return-Path: X-Original-To: apmail-ofbiz-user-archive@www.apache.org Delivered-To: apmail-ofbiz-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CDA50EF87 for ; Sat, 16 Feb 2013 17:27:21 +0000 (UTC) Received: (qmail 97867 invoked by uid 500); 16 Feb 2013 17:27:21 -0000 Delivered-To: apmail-ofbiz-user-archive@ofbiz.apache.org Received: (qmail 97832 invoked by uid 500); 16 Feb 2013 17:27:20 -0000 Mailing-List: contact user-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ofbiz.apache.org Delivered-To: mailing list user@ofbiz.apache.org Received: (qmail 97820 invoked by uid 99); 16 Feb 2013 17:27:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Feb 2013 17:27:20 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of piechota@gmail.com designates 209.85.223.174 as permitted sender) Received: from [209.85.223.174] (HELO mail-ie0-f174.google.com) (209.85.223.174) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Feb 2013 17:27:14 +0000 Received: by mail-ie0-f174.google.com with SMTP id k10so5892563iea.5 for ; Sat, 16 Feb 2013 09:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=u3QTrGRQNGIqhHazNP0FcHYoQViCwR8Kx7h85tkx304=; b=dcNYRF/kCE4gT3PC5IUM4+CliHTcH3LyhJop/3LjpLL5xpiCeCbYrc3AUcjuR0iS0H 3TmWmTjfs63pQpGnjGdCykDOsBPVQMFOYWgudGFfFOOcqKOq0g754+xJMySBNiVL9cYl WFIfgGKUBPkv8XjeAzsex1kne6udfhEkUW2zLcJxtFxuUAQOxHrX7F04pCsN5WgEJ83N rLL6az4Eu3Zgy9+7QVQIfzbmysmpG05Qqu3XzuxVTmkLKZAeyLXc0s1rPNQsMpBjM9Nr tdNMIFtqqpzBVEAkDKzD40XjYydlAIltmYJGsKa2eQnQjl/qs++dArdTj7sqdbT6uhGd /dCg== MIME-Version: 1.0 X-Received: by 10.50.83.162 with SMTP id r2mr4865934igy.106.1361035613169; Sat, 16 Feb 2013 09:26:53 -0800 (PST) Received: by 10.50.15.168 with HTTP; Sat, 16 Feb 2013 09:26:52 -0800 (PST) In-Reply-To: <511F33C6.9080303@sandglass-software.com> References: <511CB0EF.3000505@librenberry.net> <511CBA63.4070905@sandglass-software.com> <511E627F.7060604@sandglass-software.com> <511F33C6.9080303@sandglass-software.com> Date: Sat, 16 Feb 2013 09:26:52 -0800 Message-ID: Subject: Re: List of all people and the company they work for From: James Piechota To: "user@ofbiz.apache.org" Content-Type: multipart/alternative; boundary=e89a8f2347cf3fe85e04d5dacca2 X-Virus-Checked: Checked by ClamAV on apache.org --e89a8f2347cf3fe85e04d5dacca2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Adrian. Yep, totally agree - in my first attempt, after using the PartyRelationshipAndPartyDetail view-entity as a starting point, I needed to add an OR clause in the join to get what I needed (i.e., a table with only a single Person and PartyGroup column, not a toPerson, fromPerson, toPartyGroup, fromPartyGroup), but that required hacking. Now I'll try the complex-alias approach mentioned above. Thanks for your help, James On Fri, Feb 15, 2013 at 11:22 PM, Adrian Crum < adrian.crum@sandglass-software.com> wrote: > Exactly. So, copy the view entity and add what you need. > > -Adrian > > > On 2/15/2013 7:24 PM, James Piechota wrote: > >> Thanks, Adrian! >> >> Yeah, I'd looked at PartyRelationshipAndDetail view entity (actually >> started my journey through the source there), but it seems like it only >> considers the PartyRelationship.partyIdTo side of the connection, not th= e >> partyIdFrom. >> >> I'd like to build a list of Persons and their associated PartyGroups. At >> its most basic the list would contain just: >> >> PersonFirstName PersonLastName CompanyName >> ... >> >> For all Persons. >> >> I'm not sure PartyRelationshipAndDetail will do that for me since the >> relationships could be Person -> PartyGroup as well as PartyGroup -> >> Person >> and it only looks at the end of the relationship. i.e. It grabbs all >> Persons and PartyGroups that sit on the terminal end of a relationship, >> but >> I believe ignores the start end of the relationship. >> >> James >> >> >> On Fri, Feb 15, 2013 at 8:29 AM, Adrian Crum < >> adrian.crum@sandglass-**software.com > >> wrote: >> >> Relationships go from Party to Party. Person and PartyGroup are Party >>> subtypes. So, if you want your code to work with all Party subtypes, yo= u >>> need a view entity that includes both Person and PartyGroup. The >>> PartyRelationshipAndDetail view entity is a good example. >>> >>> -Adrian >>> >>> >>> >>> On 2/15/2013 3:47 PM, James Piechota wrote: >>> >>> Update: >>>> >>>> I may be able to so what I need using complex aliases (basically map a >>>> fromPerson and toPerson column to a single person column - assuming th= at >>>> only one of the two will be non-null for a given row). >>>> >>>> I'll give it a go. >>>> >>>> James >>>> >>>> On Thursday, February 14, 2013, James Piechota wrote: >>>> >>>> Thank you both for the replies! >>>> >>>>> I completely agree: I'd love to avoid hacking as much as possible! >>>>> Maybe >>>>> my searching skills need some help because these are the issues I hit >>>>> after >>>>> combing through the source: >>>>> >>>>> 1. >>>>> I believe the relationships can go either Person -> PartyGroup or >>>>> PartyGroup -> Person - is that right? To simplify use of the >>>>> view-entity, >>>>> I'd like to just have single "person" and "partyGroup" fields (as >>>>> opposed >>>>> to the toPerson, fromPerson, toPartyGroup, fromPartyGroup fields used >>>>> in >>>>> the scrum PartyRelationshipAndPartyDetai****l entitymodel example) >>>>> >>>>> >>>>> 2. >>>>> We'll be tracking this employment relationship for customers and othe= r >>>>> external contacts and so I don't think I can rely on the human resour= ce >>>>> tables. >>>>> >>>>> I guess what it boils down to is: >>>>> >>>>> A. Are my search skills crappy, and there does in fact exist an examp= le >>>>> of >>>>> how to query the employment relationship without needing both to and >>>>> from >>>>> fields for both parties? (if so, I'll keep looking!) >>>>> >>>>> B. Have I misunderstood something fundamental, and there's another wa= y >>>>> to >>>>> get at what I need. >>>>> >>>>> Thanks again for the replies! >>>>> >>>>> >>>>> On Thu, Feb 14, 2013 at 2:20 AM, Adrian Crum < >>>>> adrian.crum@sandglass-**softwa**re.com < >>>>> adrian.crum@sandglass-**software.com >>>>> >>>>> 'adrian.crum@sandglass-**softw**are.com < >>>>> adrian.crum@sandglass-**software.com >>>>> >');>> >>>>> wrote: >>>>> >>>>> James, >>>>> >>>>>> One thing to always remember: Whatever you are trying to do, there i= s >>>>>> a >>>>>> good chance someone else has already done it. Looking up a party >>>>>> relationship is a very common requirement, so there is no need to ha= ck >>>>>> up >>>>>> the source code to do it. Just spend some time looking at the curren= t >>>>>> implementations - chances are it already exists. >>>>>> >>>>>> -Adrian >>>>>> >>>>>> >>>>>> On 2/14/2013 9:39 AM, Malin Nicolas wrote: >>>>>> >>>>>> Hi >>>>>> >>>>>>> You can create a view-entity between Person - PartyRelationship - >>>>>>> PartyGroup with non optional relation and a entity-condition on >>>>>>> partyRelationshipTypeId =3D EMPLOYMENT >>>>>>> See applications/humanres/******entitydef/entitymodel.xml for >>>>>>> example. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Nicolas >>>>>>> >>>>>>> Le 14/02/2013 00:09, James Piechota a =E9crit : >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>>> What's the recommended approach to getting a list of Persons and t= he >>>>>>>> Party >>>>>>>> Group that they are in an EMPLOYMENT relationship with? >>>>>>>> >>>>>>>> Some context: >>>>>>>> >>>>>>>> Since a Person can be on either end of a PartyRelationship the SQL >>>>>>>> query >>>>>>>> I've cooked up involves Left Joins with OR conditions. >>>>>>>> >>>>>>>> I've been unable to do this with a view-entity since the view-link= s >>>>>>>> seem to >>>>>>>> require at least one AND in any boolean condition (i.e., they >>>>>>>> require >>>>>>>> at >>>>>>>> least one key-map which gets AND'ed with any provided >>>>>>>> entity-conditions). >>>>>>>> >>>>>>>> I've edited my local install to relax the view-link requirements s= o >>>>>>>> that >>>>>>>> they just require *some* condition whether from a key-map, >>>>>>>> entity-condition >>>>>>>> or both. If there isn't a recommended approach to the above, I can >>>>>>>> look >>>>>>>> into opening a JIRA issue and attaching a patch. >>>>>>>> >>>>>>>> For reference, this is the sort of SQL query I've been trying to >>>>>>>> build: >>>>>>>> >>>>>>>> select PERSON.FIRST_NAME, PARTY_GROUP.GROUP_NAME >>>>>>>> from PERSON >>>>>>>> left outer join PARTY_RELATIONSHIP >>>>>>>> on (PERSON.PARTY_ID =3D PARTY_RELATIONSHIP.PARTY_ID_******F= ROM >>>>>>>> or >>>>>>>> PERSON.PARTY_ID =3D PARTY_RELATIONSHIP.PARTY_ID_******TO) and >>>>>>>> PARTY_RELATIONSHIP.PARTY_******RELATIONSHIP_TYPE_ID =3D 'EMPLOYMEN= T' >>>>>>>> left outer join PARTY_GROUP >>>>>>>> on (PARTY_GROUP.PARTY_ID =3D PARTY_RELATIONSHIP.PARTY_ID_**= ** >>>>>>>> **FROM >>>>>>>> or >>>>>>>> PARTY_GROUP.PARTY_ID =3D PARTY_RELATIONSHIP.PARTY_ID_******TO) and >>>>>>>> PARTY_RELATIONSHIP.PARTY_******RELATIONSHIP_TYPE_ID =3D 'EMPLOYMEN= T' >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> > --e89a8f2347cf3fe85e04d5dacca2--