What is the syntax to add an association?

Posted by Ken Champion on 27-Jan-2015 11:34

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?

All Replies

Posted by mparish on 27-Jan-2015 11:57

You use the += notation for one-to-many associations
With a vocab like this
And a rule sheet like this
You will get this:
 
 
[collapse]
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.

[/collapse]

Posted by mparish on 27-Jan-2015 12:41

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
 
 
[collapse]
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:
 
 
[collapse]
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.

[/collapse][/collapse]

Posted by mparish on 27-Jan-2015 12:45

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:
 
 
 
 
[collapse]
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
 
 
[collapse]
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:
 
 
[collapse]
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.

[/collapse][/collapse][/collapse]

Posted by Ken Champion on 27-Jan-2015 12:52

Thanks. This helps very much.

Posted by Chris S. Hogan on 27-Jan-2015 13:04

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

Posted by mparish on 27-Jan-2015 13:08

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

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

This thread is closed