Compare Associations (XPath or Microflows)[HELP A STUDENT IN NEED]

0
Hi! I’m a student and this is my final project. All help would be appreciated. Essentially what I need to do is check if a Recipe object has all of the ingredients from an object of the class Pantry. However, the attributes are stored in the association Recipe_Ingredient and Pantry_Ingredient respectively. I am trying to build a Recipe App that will match recipe ingredients to those store in your “pantry”. I have the following domain model:   The recipe entity contains general information about the recipe. One thing to notice is that the Ingredients attribute is a String meaning its the paragraph of ingredients (E.g. 3 cups of rice, 2 tablespoons of salt), The ingredient entity acts as a “master” list of all ingredients (E.g. rice, salt, pepper). I have used the associations Recipe_Ingredient and Pantry_Ingredient to relate ingredients from the “master” list to object of Recipe and Pantry classes using reference selectors. Now what I have to do is implement a search function that will compare Recipe_Ingredients with Pantry_Ingredients to check if there are recipes that have the ingredients in the pantry. So, comparing two associations, I have tried a data view with the following Xpath code: [MyFirstModule.Recipe_Ingredient/MyFirstModule.Ingredient/Name = MyFirstModule.Recipe_Pantry/MyFirstModule.Pantry/MyFirstModule.Pantry_Ingredient/MyFirstModule.Ingredient/Name] It did not work probably because I have to use Recipe_Pantry to get to Pantry_Ingredient.
asked
1 answers
0

What about this:

[not(MyFirstModule.Recipe_Ingredient/MyFirstModule.Ingredient/MyFirstModule.Pantry_Ingredient/MyFirstModule.Pantry/id = empty)]

 

This xpath checks if all ingredients of your recipe are associated to a pantry. (It checks if there is none who is not associated with pantry)

This xpath will return all recipe objects that have ingredients that are all associated with pantry. Is this what you need?

 

Please note that using the not() operation on associations can cause performance issues.

answered