<make-value entity-name="FinAccountTrans" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
|
// this is the easy way
GenericValue newEntity = makeValue("FinAccountTrans", parameters)
// this is also possible
GenericValue newEntity = makeValue("FinAccountTrans")
newEntity.setPKFields(parameters)
newEntity.setNonPKFields(parameters)
|
<entity-and entity-name="BudgetStatus" list="budgetStatuses">
<field-map field-name="budgetId" from-field="parameters.budgetId"/>
<order-by field-name="-statusDate"/>
</entity-and>
|
// this can also be done in one line, but it can easily become unreadable
def budgetStatuses = from("BudgetStatus")
.where("budgetId", paramters.budgetId)
.orderBy("-statusDate")
.queryList()
|
<entity-one entity-name="StatusValidChange" value-field="statusValidChange">
<field-map field-name="statusId" from-field="budgetStatus.statusId"/>
<field-map field-name="statusIdTo" from-field="parameters.statusId"/>
</entity-one>
<!-- entity-one can be called without child elements, too -->
<entity-one entity-name="Product" value-field="product" auto-field-map="true"/>
|
// MiniLang has false set for useCache as the default value
statusValidChange = findOne("StatusValidChange", [statusId: budgetStatus.statusId, statusIdTo: parameters.statusId], false)
// this is also possible
statusValidChange = from("StatusValidChange")
.where("statusId", budgetStatus.statusId, "statusIdTo", parameters.statusId)
.queryOne()
// if there are no child elements, this can be used
GenericValue product = from("Product").where(parameters).queryOne()
|
<find-by-primary-key entity-name="ProductCategoryMember" map="lookupPKMap" value-field="lookedUpValue"/>
|
GenericValue lookedUpValue = findOne("ProductCategoryMember", lookupPKMap, false)
// this is also possible
lookedUpValue = from("ProductCategoryRole")
.where(lookupPKMap)
.queryOne()
|
<entity-condition entity-name="ProductCategoryContentAndInfo" list="productCategoryContentAndInfoList" filter-by-date="true" use-cache="true">
<condition-list combine="and">
<condition-expr field-name="productCategoryId" from-field="productCategoryList.productCategoryId"/>
<condition-expr field-name="prodCatContentTypeId" value="ALTERNATIVE_URL"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<!-- entity-condition can also be used with the "or" operator -->
<entity-condition entity-name="ProdCatalogCategory" list="prodCatalogCategoryList" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productCategoryId" from-field="parameters.productCategoryId"/>
<condition-list combine="or">
<condition-expr field-name="prodCatalogCategoryTypeId" value="PCCT_VIEW_ALLW"/>
<condition-expr field-name="prodCatalogCategoryTypeId" value="PCCT_PURCH_ALLW"/>
</condition-list>
</condition-list>
</entity-condition>
|
// the Groovy methods use the "and" and "equals" operator as default values
List productCategoryContentAndInfoList = from("ProductCategoryContentAndInfo")
.where("productCategoryId", productCategoryList.productCategoryId, "prodCatContentTypeId", "ALTERNATIVE_URL")
.cache().orderBy("-fromDate")
.filterByDate()
.queryList()
// with the use of the "or" operator you have to build your condition like this
EntityCondition condition = EntityCondition.makeCondition([
EntityCondition.makeCondition([
EntityCondition.makeCondition("prodCatalogCategoryTypeId", "PCCT_VIEW_ALLW"),
EntityCondition.makeCondition("prodCatalogCategoryTypeId", "PCCT_PURCH_ALLW")
], EntityOperator.OR),
EntityCondition.makeCondition("productCategoryId", parameters.productCategoryId)
])
List prodCatalogCategoryList = from("ProdCatalogCategory").where(condition).filterByDate().queryList()
|
<make-value entity-name="FinAccountTrans" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<!-- In this case multiple fields of the GenericValue are set -->
<make-value entity-name="ProductCategoryRollup" value-field="newLimitRollup"/>
<set field="newLimitRollup.productCategoryId" from-field="newEntity.productCategoryId"/>
<set field="newLimitRollup.parentProductCategoryId" from-field="productCategoryRole.productCategoryId"/>
<set field="newLimitRollup.fromDate" from-field="nowTimestamp"/>
|
def newEntity = makeValue("FinAccountTrans", parameters)
// you can set multiple fields of a GenericValue like this
def newLimitRollup = makeValue("ProductCategoryRollup", [
productCategoryId: newEntity.productCategoryId,
parentProductCategoryId: productCategoryRole.productCategoryId,
fromDate: nowTimestamp
])
|
<set field="statusValidChange.prop" value="value"/>
|
statusValidChange.prop = "value"
|
<create-value value-field="newEntity"/>
|
|
<store-value value-field="newEntity"/>
<store-list list="listToStore"/>
|
newEntity.store()
delegator.storeAll(listToStore)
|
<clone-value value-field="productCategoryMember" new-value-field="newProductCategoryMember"/>
|
def newProductCategoryMember = productCategoryMember.clone()
|
<remove-value value-field="lookedUpValue"/>
|
|
<sequenced-id sequence-name="ProductCategory" field="newEntity.productCategoryId"/>
|
newEntity.productCategoryId = delegator.getNextSeqId("ProductCategory")
|
<check-id field="newEntity.productCategoryId"/>
|
UtilValidate.checkValidDatabaseId(newEntity.productCategoryId)
|
<make-next-seq-id value-field="newEntity" seq-field-name="linkSeqId"/>
|
delegator.setNextSubSeqId(newEntity, "linkSeqId", 5, 1)
// the numbers 5 and 1 are used in the Java implementation of the MiniLang method
// and can also be found as the default values in the MiniLang documentation
|