0

I'm using ofbiz framework and researching data modeling. But I'm confusing with getting data from an entity when just had partyID.

When I know a partyID, I can query at party table to get Party_type_id. Then, I use this Party_type_id to query at party_type to get type of party, example PERSON or PARTY_GROUP. But then how can I exactly go to PERSON or PARTY_GROUP to get individual information of them ? Because I don't show any relationship between party_type and name of table (PERSON or PARTY_GROUP).

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ThangNguyen
  • 197
  • 1
  • 12
  • You may try this link. It helped me a lot. https://cwiki.apache.org/confluence/display/OFBIZ/Data+Model+Diagrams – Sattam Jun 22 '16 at 09:26

3 Answers3

1

I think viewEntity Can solve your problem.

Add the following view-entity in endityengine.xml.

    <view-entity entity-name="PartyInfo"
                 package-name="org.ofbiz.party"
                 title="View that combines Person, Paryt and PartyGroup">
  <member-entity entity-alias="P" entity-name="Party"/>
  <member-entity entity-alias="PG" entity-name="PartyGroup"/>
  <member-entity entity-alias="PER" entity-name="Person"/>
  <alias entity-alias="P" name="partyId"/>
  <alias entity-alias="PG" name="groupName"/>
  <alias entity-alias="PER" name="firstName"/>
  <alias entity-alias="PER" name="lastName"/>
  <alias entity-alias="P" name="partyTypeId"/>
  <view-link entity-alias="P" rel-entity-alias="PG" rel-optional="true">
    <key-map field-name="partyId"/>
  </view-link>
  <view-link entity-alias="P" rel-entity-alias="PER" rel-optional="true">
    <key-map field-name="partyId"/>
  </view-link>
</view-entity>

which will have the party information including firstName,lastName Or GroupName (if PartyType = 'PARTY_GROUP') and PartyTypeId.

    EntityCondition partyCondition = EntityCondition.makeCondition(UtilMisc.toList(
                    EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, prtyId)), EntityOperator.AND);


    List<GenericValue> partyDetails = delegator.findByCondition("PartyInfo", partyCondition, null, null);

Note : You cannot query databse using this table 'PartyInfo' ( Incase you are not aware of View entity)

Senthilmurugan
  • 383
  • 1
  • 14
0

Use the same party_id to query the table 'person' to get the info of the party of the party_type_id=PERSON

SELECT * FROM PERSON pers, PARTY p WHERE p.PARTY_ID=pers.PARTY_ID AND p.party_type_id='PERSON' AND pers.PARTY_ID='your-party-id'

Use the same party_id to query the table 'person' to get the info of the party of the party_type_id=PARTY_GROUP

SELECT * FROM PARTY_GROUP pg, PARTY p WHERE p.PARTY_ID=pg.PARTY_ID AND p.party_type_id='PARTY_GROUP' AND pg.PARTY_ID='your-party-id'

Visa
  • 111
  • 4
0

You may also try to navigate to Application>Framework>EntityEngine and check for the reln for any entity that you want. It gives quite a comprehensive info. Much like the foreign key connects.

Sattam
  • 28
  • 4