Author: lektran
Date: Sun Apr 18 10:41:32 2010 New Revision: 935329 URL: http://svn.apache.org/viewvc?rev=935329&view=rev Log: A couple of examples of using EntityConditionBuilder Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/ListInvoiceItemTypesGlAccount.groovy ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/ListInvoiceItemTypesGlAccount.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/ListInvoiceItemTypesGlAccount.groovy?rev=935329&r1=935328&r2=935329&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/ListInvoiceItemTypesGlAccount.groovy (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/ListInvoiceItemTypesGlAccount.groovy Sun Apr 18 10:41:32 2010 @@ -29,8 +29,8 @@ invItemTypePrefix = context.invItemTypeP invItemTypePrefix += "_%"; organizationPartyId = parameters.organizationPartyId; - -invoiceItemTypes = delegator.findList("InvoiceItemType", EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.LIKE, invItemTypePrefix), null, null, null, false); +exprBldr = new EntityExpressionBuilder(); +invoiceItemTypes = delegator.findList("InvoiceItemType", exprBldr.LIKE(invoiceItemTypeId: invItemTypePrefix), null, null, null, false); allTypes = []; invoiceItemTypes.each { invoiceItemType -> activeGlDescription = ""; Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy?rev=935329&r1=935328&r2=935329&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy Sun Apr 18 10:41:32 2010 @@ -26,49 +26,50 @@ import org.ofbiz.entity.condition.Entity import javolution.util.FastList; +exprBldr = new EntityConditionBuilder(); invoice = context.invoice; if (!invoice) return; glAccountOrganizationAndClassList = null; if ("SALES_INVOICE".equals(invoice.invoiceTypeId)) { - List itemTypes = FastList.newInstance(); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "INVOICE_ADJ")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "INVOICE_ADJ")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "INVOICE_ITM_ADJ")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "INVOICE_ITM_ADJ")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "INV_PROD_ITEM")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "INV_PROD_ITEM")); - itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR); + itemTypesCond = exprBldr.OR() { + EQUALS(invoiceItemTypeId: "INVOICE_ADJ") + EQUALS(parentTypeId: "INVOICE_ADJ") + EQUALS(invoiceItemTypeId: "INVOICE_ITM_ADJ") + EQUALS(parentTypeId: "INVOICE_ITM_ADJ") + EQUALS(invoiceItemTypeId: "INV_PROD_ITEM") + EQUALS(parentTypeId: "INV_PROD_ITEM") + } invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false); glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyIdFrom]); } else if ("PURCHASE_INVOICE".equals(invoice.invoiceTypeId)) { - List itemTypes = FastList.newInstance(); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PINVOICE_ADJ")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PINVOICE_ADJ")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PINVOICE_ITM_ADJ")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PINVOICE_ITM_ADJ")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PINV_PROD_ITEM")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PINV_PROD_ITEM")); - itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR); + itemTypesCond = exprBldr.OR() { + EQUALS(invoiceItemTypeId: "PINVOICE_ADJ") + EQUALS(parentTypeId: "PINVOICE_ADJ") + EQUALS(invoiceItemTypeId: "PINVOICE_ITM_ADJ") + EQUALS(parentTypeId: "PINVOICE_ITM_ADJ") + EQUALS(invoiceItemTypeId: "PINV_PROD_ITEM") + EQUALS(parentTypeId: "PINV_PROD_ITEM") + } invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false); glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyId]); } else if ("PAYROL_INVOICE".equals(invoice.invoiceTypeId)) { - List itemTypes = FastList.newInstance(); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_EARN_HOURS")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_EARN_HOURS")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_DD_FROM_GROSS")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_DD_FROM_GROSS")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_TAXES")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_TAXES")); - itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR); + itemTypesCond = exprBldr.OR() { + EQUALS(invoiceItemTypeId: "PAYROL_EARN_HOURS") + EQUALS(parentTypeId: "PAYROL_EARN_HOURS") + EQUALS(invoiceItemTypeId: "PAYROL_DD_FROM_GROSS") + EQUALS(parentTypeId: "PAYROL_DD_FROM_GROSS") + EQUALS(invoiceItemTypeId: "PAYROL_TAXES") + EQUALS(parentTypeId: "PAYROL_TAXES") + } invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false); glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyId]); } else if ("COMMISSION_INVOICE".equals(invoice.invoiceTypeId)) { - List itemTypes = FastList.newInstance(); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "COMM_INV_ITEM")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "COMM_INV_ITEM")); - itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "COMM_INV_ADJ")); - itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "COMM_INV_ADJ")); - itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR); + itemTypesCond = exprBldr.OR() { + EQUALS(invoiceItemTypeId: "COMM_INV_ITEM") + EQUALS(parentTypeId: "COMM_INV_ITEM") + EQUALS(invoiceItemTypeId: "COMM_INV_ADJ") + EQUALS(parentTypeId: "COMM_INV_ADJ") + } invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false); glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyId]); } else { |
Free forum by Nabble | Edit this page |