What is the syntax to add an association? - Forum - Corticon - Progress Community

What is the syntax to add an association?

 Forum

What is the syntax to add an association?

  • I have an action-only ruleset to seed some data for later rulesets. I have a Product entity which has an N:1 association to a ProductGroup entity.

    To add Product records, I have lines similar to this:

    Product.new[productId='P1', name='Lettuce']
    Product.new[productId='P2', name='Filet Mignon']
    Product.new[productId='P3', name='Apple']

    To add ProductGroup records, I have:

    ProductGroup.new[productGroupId='PG1', 'Produce']
    ProductGroup.new[productGroupId='PG2', 'Meat']

    So what is the syntax to associate the "Lettuce" product to the "Produce" product group?

  • You use the += notation for one-to-many associations
    With a vocab like this
    And a rule sheet like this
    You will get this:
     
     
    From: Ken Champion [mailto:bounce-kenchampionmerialcom@community.progress.com]
    Sent: Tuesday, January 27, 2015 9:35 AM
    To: TU.Corticon@community.progress.com
    Subject: [Technical Users - Corticon] What is the syntax to add an association?
     
    Thread created by Ken Champion

    I have an action-only ruleset to seed some data for later rulesets. I have a Product entity which has an N:1 association to a ProductGroup entity.

    To add Product records, I have lines similar to this:

    Product.new[productId='P1', name='Lettuce']
    Product.new[productId='P2', name='Filet Mignon']
    Product.new[productId='P3', name='Apple']

    To add ProductGroup records, I have:

    ProductGroup.new[productGroupId='PG1', 'Produce']
    ProductGroup.new[productGroupId='PG2', 'Meat']

    So what is the syntax to associate the "Lettuce" product to the "Produce" product group?

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • If the product groups already exist then you might use something like this to add the products by using aliases to the product collections within the product groups:
    newUnique can be used to avoid creating duplicate items
     
     
    From: mparish [mailto:bounce-mparish@community.progress.com]
    Sent: Tuesday, January 27, 2015 9:58 AM
    To: TU.Corticon@community.progress.com
    Subject: RE: [Technical Users - Corticon] What is the syntax to add an association?
     
    Reply by mparish
    You use the += notation for one-to-many associations
    With a vocab like this
    And a rule sheet like this
    You will get this:
     
     
    From: Ken Champion [mailto:bounce-kenchampionmerialcom@community.progress.com]
    Sent: Tuesday, January 27, 2015 9:35 AM
    To: TU.Corticon@community.progress.com
    Subject: [Technical Users - Corticon] What is the syntax to add an association?
     
    Thread created by Ken Champion

    I have an action-only ruleset to seed some data for later rulesets. I have a Product entity which has an N:1 association to a ProductGroup entity.

    To add Product records, I have lines similar to this:

    Product.new[productId='P1', name='Lettuce']
    Product.new[productId='P2', name='Filet Mignon']
    Product.new[productId='P3', name='Apple']

    To add ProductGroup records, I have:

    ProductGroup.new[productGroupId='PG1', 'Produce']
    ProductGroup.new[productGroupId='PG2', 'Meat']

    So what is the syntax to associate the "Lettuce" product to the "Produce" product group?

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • If both the product group and the products already exist then you can use rules like this to match them up to create the association:
     
     
     
     
    From: mparish [mailto:bounce-mparish@community.progress.com]
    Sent: Tuesday, January 27, 2015 10:42 AM
    To: TU.Corticon@community.progress.com
    Subject: RE: [Technical Users - Corticon] What is the syntax to add an association?
     
    Reply by mparish
    If the product groups already exist then you might use something like this to add the products by using aliases to the product collections within the product groups:
    newUnique can be used to avoid creating duplicate items
     
     
    From: mparish [mailto:bounce-mparish@community.progress.com]
    Sent: Tuesday, January 27, 2015 9:58 AM
    To: TU.Corticon@community.progress.com
    Subject: RE: [Technical Users - Corticon] What is the syntax to add an association?
     
    Reply by mparish
    You use the += notation for one-to-many associations
    With a vocab like this
    And a rule sheet like this
    You will get this:
     
     
    From: Ken Champion [mailto:bounce-kenchampionmerialcom@community.progress.com]
    Sent: Tuesday, January 27, 2015 9:35 AM
    To: TU.Corticon@community.progress.com
    Subject: [Technical Users - Corticon] What is the syntax to add an association?
     
    Thread created by Ken Champion

    I have an action-only ruleset to seed some data for later rulesets. I have a Product entity which has an N:1 association to a ProductGroup entity.

    To add Product records, I have lines similar to this:

    Product.new[productId='P1', name='Lettuce']
    Product.new[productId='P2', name='Filet Mignon']
    Product.new[productId='P3', name='Apple']

    To add ProductGroup records, I have:

    ProductGroup.new[productGroupId='PG1', 'Produce']
    ProductGroup.new[productGroupId='PG2', 'Meat']

    So what is the syntax to associate the "Lettuce" product to the "Produce" product group?

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • Thanks. This helps very much.

  • You can also use the -= notation to remove an entity from an existing collection.

  • You can also use += and -= in combination to move items in and out of collections.

    See this example community.progress.com/.../1377.aspx