0

What I'm trying to achieve here is to load some fields from sub-entities.

For instance, let's suppose i want to load some features for the product list. In xml it's pretty clear:

<row-actions>
  <entity-find-one entity-name="mantle.product.feature.ProductFeature" value-field="brandList">
      <field-map field-name="productFeatureId" from="featureList.productFeatureId"/>
      <field-map field-name="productFeatureTypeEnumId" from="featureList.productFeatureId" value="PftBrand"/>
  </entity-find-one>
</row-actions>

Is there a way to do something similar in groovy, without iterating through the whole product list and add the desired fields manually?

Also, can somebody give me a short example with the concrete use of sqlFind(http://www.moqui.org/javadoc/org/moqui/entity/EntityFacade.html) ?

I tried to solve the issue i'm asking about using a join query but I couldn't figure out how the SQL query is supposed to look like.

1 Answers1

0

a. The element 'entity-find-one' queries on primary key and returns a single map. You need to use the 'entity-find' element .

b. Yes, you can always drop down to groovy using the script tag. e.g. Just use ec.entity.find("mantle.product.feature.ProductFeature") or whatever you need in your groovy script.

c. In moqui, joined tables are handled by the 'view-entity' element and you can predefine your own (place in your 'entities' folder) or use the many existing ones that are provided in the framework. You don't need SQL.

EDIT - Sorry, you can also do it on the fly by using the EntityFind.makeEntityDynamicView() method.

Hope that helps.

Ronan Keane
  • 189
  • 8