Added: ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml?rev=1642027&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml (added) +++ ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml Thu Nov 27 06:14:06 2014 @@ -0,0 +1,751 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd"> + + <simple-method method-name="loadSalesInvoiceFact" short-description=""> + <entity-one entity-name="Invoice" value-field="invoice"/> + <if-empty field="invoice"> + <add-error> + <fail-property resource="AccountingUiLabels" property="AccountingInvoiceDoesNotExists"/> + </add-error> + </if-empty> + <check-errors/> + <if-compare field="invoice.invoiceTypeId" operator="equals" value="SALES_INVOICE"> + <set field="andConditions.invoiceItemTypeId" value="INV_FPROD_ITEM"/> + <get-related relation-name="InvoiceItem" value-field="invoice" list="invoiceItems" map="andConditions"/> + <iterate list="invoiceItems" entry="invoiceItem"> + <clear-field field="inMap"/> + <set field="inMap.invoice" from-field="invoice"/> + <set field="inMap.invoiceItem" from-field="invoiceItem"/> + <call-service service-name="loadSalesInvoiceItemFact" in-map-name="inMap"/> + </iterate> + </if-compare> + </simple-method> + <simple-method method-name="loadSalesInvoiceItemFact" short-description=""> + <set field="invoice" from-field="parameters.invoice"/> + <set field="invoiceItem" from-field="parameters.invoiceItem"/> + <if-empty field="invoice"> + <entity-one entity-name="Invoice" value-field="invoice"/> + </if-empty> + <if-empty field="invoiceItem"> + <entity-one entity-name="InvoiceItem" value-field="invoiceItem"/> + </if-empty> + <if-empty field="invoice"> + <add-error> + <fail-property resource="AccountingUiLabels" property="AccountingInvoiceDoesNotExists"/> + </add-error> + </if-empty> + <if-empty field="invoiceItem"> + <add-error> + <fail-property resource="AccountingUiLabels" property="AccountingInvoiceItemDoesNotExists"/> + </add-error> + </if-empty> + <check-errors/> + + <if-compare field="invoice.invoiceTypeId" operator="equals" value="SALES_INVOICE"> + <entity-one entity-name="SalesInvoiceItemFact" value-field="fact" auto-field-map="false"> + <field-map field-name="invoiceId" from-field="invoiceItem.invoiceId"/> + <field-map field-name="invoiceItemSeqId" from-field="invoiceItem.invoiceItemSeqId"/> + </entity-one> + <!-- key handling --> + <if-empty field="fact"> + <make-value entity-name="SalesInvoiceItemFact" value-field="fact"/> + <set field="fact.invoiceId" from-field="invoice.invoiceId"/> + <set field="fact.invoiceItemSeqId" from-field="invoiceItem.invoiceItemSeqId"/> + <!-- conversion of the invoice date --> + <if-not-empty field="invoice.invoiceDate"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="DateDimension"/> + <set field="inMap.naturalKeyFields.dateValue" from-field="invoice.invoiceDate" type="Date"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.invoiceDateDimId"/> + </call-service> + <if-empty field="fact.invoiceDateDimId"> + <set field="fact.invoiceDateDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.invoiceDateDimId" value="_NA_"/> + </else> + </if-not-empty> + <!-- conversion of the product id --> + <if-not-empty field="invoiceItem.productId"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="ProductDimension"/> + <set field="inMap.naturalKeyFields.productId" from-field="invoiceItem.productId"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.productDimId"/> + </call-service> + <if-empty field="fact.productDimId"> + <set field="fact.productDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.productDimId" value="_NA_"/> + </else> + </if-not-empty> + <!-- conversion of the invoice currency --> + <if-not-empty field="invoice.currencyUomId"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="CurrencyDimension"/> + <set field="inMap.naturalKeyFields.currencyId" from-field="invoice.currencyUomId"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.origCurrencyDimId"/> + </call-service> + <if-empty field="fact.origCurrencyDimId"> + <set field="fact.origCurrencyDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.origCurrencyDimId" value="_NA_"/> + </else> + </if-not-empty> + <!-- TODO --> + <set field="fact.orderId" value="_NA_"/> + <set field="fact.billToCustomerDimId" value="_NA_"/> + <create-value value-field="fact"/> + </if-empty> + <!-- =============== --> + <!-- facts handling --> + <!-- =============== --> + <set field="fact.quantity" from-field="invoiceItem.quantity" type="BigDecimal"/> + <set field="fact.extGrossAmount" value="0.0" type="BigDecimal"/> + <set field="fact.extDiscountAmount" value="0.0" type="BigDecimal"/> + <set field="fact.extTaxAmount" value="0.0" type="BigDecimal"/> + <set field="fact.extNetAmount" value="0.0" type="BigDecimal"/> + <calculate field="fact.extGrossAmount"> + <calcop field="invoiceItem.quantity" operator="multiply"> + <calcop field="invoiceItem.amount" operator="get"/> + </calcop> + </calculate> + <!-- taxes --> + <clear-field field="andConditions"/> + <set field="andConditions.invoiceItemTypeId" value="ITM_SALES_TAX"/> + <get-related relation-name="ChildrenInvoiceItem" value-field="invoiceItem" list="taxes" map="andConditions"/> + <iterate list="taxes" entry="tax"> + <calculate field="fact.extTaxAmount"> + <calcop field="fact.extTaxAmount" operator="add"> + <calcop field="tax.amount" operator="get"/> + </calcop> + </calculate> + </iterate> + <!-- discounts --> + <clear-field field="andConditions"/> + <set field="andConditions.invoiceItemTypeId" value="ITM_PROMOTION_ADJ"/> + <get-related relation-name="ChildrenInvoiceItem" value-field="invoiceItem" list="discounts" map="andConditions"/> + <iterate list="discounts" entry="discount"> + <calculate field="fact.extDiscountAmount" type="BigDecimal"> + <calcop field="fact.extDiscountAmount" operator="add"> + <calcop field="discount.amount" operator="negative"/> + </calcop> + </calculate> + </iterate> + + <calculate field="fact.extNetAmount"> + <calcop field="fact.extGrossAmount" operator="subtract"> + <calcop field="fact.extDiscountAmount" operator="get"/> + </calcop> + </calculate> + <!-- TODO: prorate invoice header discounts and shipping charges --> + <!-- TODO: costs --> + <set field="fact.extManFixedCost" value="0.0" type="BigDecimal"/> + <set field="fact.extManVarCost" value="0.0" type="BigDecimal"/> + <set field="fact.extStorageCost" value="0.0" type="BigDecimal"/> + <set field="fact.extDistributionCost" value="0.0" type="BigDecimal"/> + + <calculate field="fact.contributionAmount"> + <calcop field="fact.extNetAmount" operator="subtract"> + <calcop field="fact.extManFixedCost" operator="get"/> + <calcop field="fact.extManVarCost" operator="get"/> + <calcop field="fact.extStorageCost" operator="get"/> + <calcop field="fact.extDistributionCost" operator="get"/> + </calcop> + </calculate> + + <store-value value-field="fact"/> + </if-compare> + </simple-method> + + <simple-method method-name="loadSalesOrderFact" short-description=""> + <entity-one entity-name="OrderHeader" value-field="orderHeader"/> + <if-empty field="orderHeader"> + <add-error> + <fail-property resource="OrderErrorUiLabels" property="OrderOrderIdDoesNotExists"/> + </add-error> + </if-empty> + <check-errors/> + <if-compare field="orderHeader.orderTypeId" operator="equals" value="SALES_ORDER"> + <if-compare field="orderHeader.statusId" operator="equals" value="ORDER_APPROVED"> + <entity-condition entity-name="OrderItem" list="orderItems"> + <condition-list combine="and"> + <condition-expr field-name="orderId" operator="equals" from-field="orderHeader.orderId"/> + <!--<condition-expr field-name="productId" operator="not-like" value="M00%"/>--> + <condition-expr field-name="orderItemTypeId" operator="equals" value="PRODUCT_ORDER_ITEM"/> + <!--<condition-expr field-name="statusId" operator="equals" value="ITEM_APPROVED"/>--> + </condition-list> + </entity-condition> + + <!--<set field="andConditions.orderItemTypeId" value="PRODUCT_ORDER_ITEM"/> + <get-related relation-name="OrderItem" value-field="orderHeader" list="orderItems" map="andConditions"/>--> + + <iterate list="orderItems" entry="orderItem"> + <clear-field field="inMap"/> + <set field="inMap.orderHeader" from-field="orderHeader"/> + <set field="inMap.orderItem" from-field="orderItem"/> + <set field="inMap.orderAdjustment" from-field="orderAdjustment"/> + <call-service service-name="loadSalesOrderItemFact" in-map-name="inMap"/> + </iterate> + </if-compare> + </if-compare> + </simple-method> + + <simple-method method-name="loadSalesOrderItemFact" short-description=""> + <set field="orderHeader" from-field="parameters.orderHeader"/> + <set field="orderItem" from-field="parameters.orderItem"/> + <set field="orderAdjustment" from-field="parameters.orderAdjustment"/> + <if-empty field="orderHeader"> + <entity-one entity-name="OrderHeader" value-field="orderHeader"/> + </if-empty> + <if-empty field="orderItem"> + <entity-one entity-name="OrderItem" value-field="orderItem"/> + </if-empty> + <if-empty field="orderAdjustment"> + <entity-and entity-name="OrderAdjustment" list="orderAdjustments"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + </entity-and> + </if-empty> + <if-empty field="orderHeader"> + <add-error> + <fail-property resource="OrderErrorUiLabels" property="OrderOrderIdDoesNotExists"/> + </add-error> + </if-empty> + <if-empty field="orderItem"> + <add-error> + <fail-property resource="OrderErrorUiLabels" property="OrderOrderItemIdDoesNotExists"/> + </add-error> + </if-empty> + <check-errors/> + + <if-compare field="orderHeader.statusId" operator="equals" value="ORDER_APPROVED"> + <entity-one entity-name="SalesOrderItemFact" value-field="fact" auto-field-map="false"> + <field-map field-name="orderId" from-field="orderItem.orderId"/> + <field-map field-name="orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + </entity-one> + <!-- key handling --> + <if-empty field="fact"> + <make-value entity-name="SalesOrderItemFact" value-field="fact"/> + <set field="fact.orderId" from-field="orderHeader.orderId"/> + <set field="fact.orderItemSeqId" from-field="orderItem.orderItemSeqId"/> + <set field="fact.productStoreId" from-field="orderHeader.productStoreId"/> + <set field="fact.salesChannelEnumId" from-field="orderHeader.salesChannelEnumId"/> + <set field="fact.statusId" from-field="orderItem.statusId"/> + + <!-- account --> + <if-not-empty field="orderHeader.productStoreId"> + <entity-one entity-name="ProductStore" value-field="account"> + <field-map field-name="productStoreId" from-field="orderHeader.productStoreId"/> + </entity-one> + <set field="fact.account" from-field="account.storeName"/> + </if-not-empty> + + <!-- pod --> + <if-compare field="orderHeader.currencyUom" operator="equals" value="EUR"> + <set field="fact.pod" value="Latin"/> + <else> + <set field="fact.pod" value="English"/> + </else> + </if-compare> + + <!-- brand --> + <if-not-empty field="orderHeader.salesChannelEnumId"> + <entity-one entity-name="Enumeration" value-field="brand"> + <field-map field-name="enumId" from-field="orderHeader.salesChannelEnumId"/> + </entity-one> + <set field="fact.brand" from-field="brand.description"/> + </if-not-empty> + + <!-- conversion of the order date --> + <entity-condition entity-name="OrderStatus" list="orderStatusList"> + <condition-list combine="and"> + <condition-expr field-name="orderId" from-field="orderHeader.orderId"/> + <condition-expr field-name="statusId" value="ORDER_APPROVED"/> + </condition-list> + <order-by field-name="-statusDatetime"/> + </entity-condition> + <first-from-list entry="orderStatus" list="orderStatusList"/> + <if-not-empty field="orderStatus.statusDatetime"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="DateDimension"/> + <set field="inMap.naturalKeyFields.dateValue" from-field="orderStatus.statusDatetime" type="Date"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.orderDateDimId"/> + </call-service> + <if-empty field="fact.orderDateDimId"> + <set field="fact.orderDateDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.orderDateDimId" value="_NA_"/> + </else> + </if-not-empty> + + <!-- conversion of the product id --> + <if-not-empty field="orderItem.productId"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="ProductDimension"/> + <set field="inMap.naturalKeyFields.productId" from-field="orderItem.productId"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.productDimId"/> + </call-service> + <if-empty field="fact.productDimId"> + <set field="fact.productDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.productDimId" value="_NA_"/> + </else> + </if-not-empty> + + <!-- conversion of the order currency --> + <if-not-empty field="orderHeader.currencyUom"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="CurrencyDimension"/> + <set field="inMap.naturalKeyFields.currencyId" from-field="orderHeader.currencyUom"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.origCurrencyDimId"/> + </call-service> + <if-empty field="fact.origCurrencyDimId"> + <set field="fact.origCurrencyDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.origCurrencyDimId" value="_NA_"/> + </else> + </if-not-empty> + + <!-- productCategoryId --> + <entity-and entity-name="ProductCategoryMember" list="productCategoryMembers"> + <field-map field-name="productId" from-field="orderItem.productId"/> + <field-map field-name="thruDate" from-field="nullField"/> + </entity-and> + <if-not-empty field="productCategoryMembers"> + <first-from-list list="productCategoryMembers" entry="productCategoryMember"/> + <set field="fact.productCategoryId" from-field="productCategoryMember.productCategoryId"/> + </if-not-empty> + + <!-- TODO --> + <set field="fact.billToCustomerDimId" value="_NA_"/> + + <create-value value-field="fact"/> + </if-empty> + <!-- =============== --> + <!-- facts handling --> + <!-- =============== --> + <set field="fact.quantity" from-field="orderItem.quantity" type="BigDecimal"/> + <set field="fact.extGrossAmount" value="0" type="BigDecimal"/> + <set field="fact.extGrossCost" value="0" type="BigDecimal"/> + <set field="fact.extDiscountAmount" value="0" type="BigDecimal"/> + <set field="fact.extNetAmount" value="0" type="BigDecimal"/> + <set field="fact.extShippingAmount" value="0" type="BigDecimal"/> + <set field="fact.extTaxAmount" value="0" type="BigDecimal"/> + + <set field="fact.GS" value="0" type="BigDecimal"/> + <set field="fact.GMS" value="0" type="BigDecimal"/> + <set field="fact.GMP" value="0" type="BigDecimal"/> + <set field="fact.GSS" value="0" type="BigDecimal"/> + <set field="fact.GSC" value="0" type="BigDecimal"/> + <set field="fact.GSP" value="0" type="BigDecimal"/> + <set field="fact.GP" value="0" type="BigDecimal"/> + + <set field="fact.countOrder" value="0" type="BigDecimal"/> + + <!-- extGrossAmount --> + <set field="convertUomCurrencyMap.uomId" from-field="orderHeader.currencyUom"/> + <set field="convertUomCurrencyMap.uomIdTo" value="USD"/> + <set field="convertUomCurrencyMap.nowDate" from-field="orderStatus.statusDatetime"/> + <call-service service-name="convertUomCurrency" in-map-name="convertUomCurrencyMap"> + <result-to-field result-name="conversionFactor" field="exchangeRate"/> + </call-service> + + <if-not-empty field="exchangeRate"> + <calculate field="unitPrice"> + <calcop field="orderItem.unitPrice" operator="multiply"> + <calcop field="exchangeRate" operator="get"/> + </calcop> + </calculate> + + <calculate field="fact.extGrossAmount"> + <calcop field="fact.quantity" operator="multiply"> + <calcop field="unitPrice" operator="get"/> + </calcop> + </calculate> + </if-not-empty> + + <!-- extGrossCost --> + <entity-condition entity-name="SupplierProduct" list="costs"> + <condition-list combine="and"> + <condition-expr field-name="productId" operator="equals" from-field="orderItem.productId"/> + <condition-expr field-name="availableThruDate" operator="equals" from-field="nullField"/> + <condition-expr field-name="minimumOrderQuantity" operator="equals" value="0"/> + </condition-list> + </entity-condition> + <if-not-empty field="costs"> + <first-from-list entry="cost" list="costs"/> + + <set field="convertUomCurrencyMap.uomId" from-field="cost.currencyUomId"/> + <set field="convertUomCurrencyMap.uomIdTo" value="USD"/> + <set field="convertUomCurrencyMap.nowDate" from-field="orderStatus.statusDatetime"/> + <call-service service-name="convertUomCurrency" in-map-name="convertUomCurrencyMap"> + <result-to-field result-name="conversionFactor" field="exchangeRate"/> + </call-service> + + <if-not-empty field="exchangeRate"> + <calculate field="costPrice"> + <calcop field="cost.lastPrice" operator="multiply"> + <calcop field="exchangeRate" operator="get"/> + </calcop> + </calculate> + + <calculate field="fact.extGrossCost"> + <calcop field="fact.quantity" operator="multiply"> + <calcop field="costPrice" operator="get"/> + </calcop> + </calculate> + </if-not-empty> + </if-not-empty> + + <!-- extShippingAmount --> + <iterate list="orderAdjustments" entry="shipping"> + <if-compare field="shipping.orderAdjustmentTypeId" operator="equals" value="SHIPPING_CHARGES"> + <calculate field="fact.extShippingAmount"> + <calcop field="fact.extShippingAmount" operator="add"> + <calcop field="shipping.amount" operator="get"/> + </calcop> + </calculate> + </if-compare> + </iterate> + + <!-- extTaxAmount --> + <iterate list="orderAdjustments" entry="tax"> + <if-compare field="tax.orderAdjustmentTypeId" operator="equals" value="SALES_TAX"> + <calculate field="fact.extTaxAmount"> + <calcop field="fact.extTaxAmount" operator="add"> + <calcop field="tax.amount" operator="get"/> + </calcop> + </calculate> + </if-compare> + </iterate> + + <!-- extDiscountAmount --> + <iterate list="orderAdjustments" entry="discount"> + <if-compare field="discount.orderAdjustmentTypeId" operator="equals" value="PROMOTION_ADJUSTMENT"> + <calculate field="fact.extDiscountAmount"> + <calcop field="fact.extDiscountAmount" operator="add"> + <calcop field="discount.amount" operator="get"/> + </calcop> + </calculate> + <!-- product promo code --> + <entity-and entity-name="ProductPromoCode" list="productPromo"> + <field-map field-name="productPromoId" from-field="discount.productPromoId"/> + </entity-and> + <first-from-list entry="productPromoCode" list="productPromo"/> + <if-not-empty field="productPromoCode"> + <set field="fact.productPromoCode" from-field="productPromoCode.productPromoCodeId"/> + <else> + <set field="fact.productPromoCode" value="Not require code"/> + </else> + </if-not-empty> + </if-compare> + </iterate> + + <!-- extNetAmount --> + <calculate field="fact.extNetAmount"> + <calcop field="fact.extGrossAmount" operator="subtract"> + <calcop field="fact.extDiscountAmount" operator="get"/> + </calcop> + </calculate> + + <!-- GS --> + <set field="countGS" value="0"/> + <entity-and entity-name="SalesOrderItemFact" list="checkGSList"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <iterate entry="checkGS" list="checkGSList"> + <if-not-empty field="checkGS.GS"> + <if-compare field="checkGS.GS" operator="not-equals" value="0"> + <set field="countGS" value="1"/> + </if-compare> + </if-not-empty> + </iterate> + <if-compare field="countGS" operator="equals" value="0"> + <set field="convertUomCurrencyMap.uomId" from-field="orderHeader.currencyUom"/> + <set field="convertUomCurrencyMap.uomIdTo" value="USD"/> + <set field="convertUomCurrencyMap.nowDate" from-field="orderStatus.statusDatetime"/> + <call-service service-name="convertUomCurrency" in-map-name="convertUomCurrencyMap"> + <result-to-field result-name="conversionFactor" field="exchangeRate"/> + </call-service> + + <if-not-empty field="exchangeRate"> + <calculate field="fact.GS"> + <calcop field="orderHeader.grandTotal" operator="multiply"> + <calcop field="exchangeRate" operator="get"/> + </calcop> + </calculate> + </if-not-empty> + </if-compare> + + <!-- GMS --> + <calculate field="fact.GMS"> + <calcop field="fact.GMS" operator="add"> + <calcop field="fact.extGrossAmount" operator="get"/> + </calcop> + </calculate> + + <!-- GMP --> + <calculate field="fact.GMP"> + <calcop field="fact.GMS" operator="subtract"> + <calcop field="fact.extGrossCost" operator="get"/> + </calcop> + </calculate> + + <!-- GSP --> + <set field="countGSP" value="0"/> + <entity-and entity-name="SalesOrderItemFact" list="checkGSPList"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <iterate entry="checkGSP" list="checkGSPList"> + <if-not-empty field="checkGSP.GSP"> + <if-compare field="checkGSP.GSP" operator="not-equals" value="0"> + <set field="countGSP" value="1"/> + </if-compare> + </if-not-empty> + </iterate> + <if-compare field="countGSP" operator="equals" value="0"> + <entity-and list="orderItemList" entity-name="OrderItem"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + + <set field="warrantyPrice" value="0" type="BigDecimal"/> + <iterate list="orderAdjustments" entry="warranty"> + <if-compare field="warranty.orderAdjustmentTypeId" operator="equals" value="WARRANTY_ADJUSTMENT"> + <calculate field="warrantyPrice"> + <calcop field="warrantyPrice" operator="add"> + <calcop field="warranty.amount" operator="get"/> + </calcop> + </calculate> + </if-compare> + </iterate> + <calculate field="GSS"> + <calcop field="fact.extShippingAmount" operator="add"> + <calcop field="warrantyPrice" operator="get"/> + </calcop> + </calculate> + + <set field="convertUomCurrencyMap.uomId" from-field="orderHeader.currencyUom"/> + <set field="convertUomCurrencyMap.uomIdTo" value="USD"/> + <set field="convertUomCurrencyMap.nowDate" from-field="orderStatus.statusDatetime"/> + <call-service service-name="convertUomCurrency" in-map-name="convertUomCurrencyMap"> + <result-to-field result-name="conversionFactor" field="exchangeRate"/> + </call-service> + + <if-not-empty field="exchangeRate"> + <calculate field="GSS"> + <calcop field="GSS" operator="multiply"> + <calcop field="exchangeRate" operator="get"/> + </calcop> + </calculate> + </if-not-empty> + <set field="fact.GSS" from-field="GSS"/> + + <set field="fact.GSP" from-field="GSS" type="BigDecimal"/> + </if-compare> + + <!-- GP --> + <calculate field="fact.GP"> + <calcop field="fact.GMP" operator="add"> + <calcop field="fact.GSP" operator="get"/> + </calcop> + </calculate> + + <!-- countOrder --> + <set field="countOrder" value="0"/> + <entity-and entity-name="SalesOrderItemFact" list="checkCountOrderList"> + <field-map field-name="orderId" from-field="orderHeader.orderId"/> + </entity-and> + <iterate entry="checkCountOrder" list="checkCountOrderList"> + <if-not-empty field="checkCountOrder.countOrder"> + <if-compare field="checkCountOrder.countOrder" operator="not-equals" value="0"> + <set field="countOrder" value="1"/> + </if-compare> + </if-not-empty> + </iterate> + <if-compare field="countOrder" operator="equals" value="0"> + <set field="fact.countOrder" value="1" type="BigDecimal"/> + </if-compare> + + <store-value value-field="fact"/> + </if-compare> + </simple-method> + + <simple-method method-name="loadSalesOrderDataDaily" short-description="Load Sales Order Data Daily"> + <now-date-to-env field="nowDate"/> + <set field="yesterday" value="${groovy: + import java.text.SimpleDateFormat; + def sdf = new SimpleDateFormat("yyyy-MM-dd 07:00:00.000"); + def yesterday = sdf.format(nowDate-1); + return yesterday; + }" type="Timestamp"/> + <set field="today" value="${groovy: + import java.text.SimpleDateFormat; + def sdf = new SimpleDateFormat("yyyy-MM-dd 07:00:00.000"); + def today = sdf.format(nowDate); + return today; + }" type="Timestamp"/> + + <set field="inMap.fromDate" from-field="yesterday"/> + <set field="inMap.thruDate" from-field="today"/> + <call-service service-name="importSalesOrderData" in-map-name="inMap"></call-service> + </simple-method> + + <simple-method method-name="importSalesOrderData" short-description="Import Sales Order Data"> + <set-service-fields service-name="loadDateDimension" map="parameters" to-map="inMap"/> + <set field="inMap.fromDate" from-field="parameters.fromDate"/> + <set field="inMap.thruDate" from-field="parameters.thruDate"/> + <call-service service-name="loadDateDimension" in-map-name="inMap"/> + <check-errors/> + + <entity-condition list="orderStatusList" entity-name="OrderStatus"> + <condition-list combine="and"> + <condition-expr field-name="statusId" value="ORDER_APPROVED"/> + <condition-expr field-name="statusDatetime" operator="greater-equals" from-field="parameters.fromDate"/> + <condition-expr field-name="statusDatetime" operator="less" from-field="parameters.thruDate"/> + </condition-list> + </entity-condition> + <iterate list="orderStatusList" entry="orderHeader"> + <clear-field field="inMap"/> + <set field="inMap.orderId" from-field="orderHeader.orderId"/> + <call-service service-name="loadSalesOrderFact" in-map-name="inMap"></call-service> + <check-errors/> + </iterate> + </simple-method> + + <simple-method method-name="convertUomCurrency" short-description="Convert Uom Currency from UomConversionDated entity"> + <if-empty field="parameters.nowDate"> + <now field="now"/> + <set field="parameters.nowDate" from-field="now"/> + </if-empty> + <entity-condition entity-name="UomConversionDated" list="UomConversionDatedList"> + <condition-list combine="and"> + <condition-expr field-name="uomId" operator="equals" from-field="parameters.uomId"/> + <condition-expr field-name="uomIdTo" operator="equals" from-field="parameters.uomIdTo"/> + <condition-expr field-name="fromDate" operator="less-equals" from-field="parameters.nowDate"/> + <condition-expr field-name="thruDate" operator="greater" from-field="parameters.nowDate"/> + </condition-list> + <order-by field-name="-fromDate"/> + </entity-condition> + <if-not-empty field="UomConversionDatedList"> + <first-from-list entry="UomConversion" list="UomConversionDatedList"/> + <field-to-result field="UomConversion.conversionFactor" result-name="conversionFactor"/> + <else> + <entity-condition entity-name="UomConversionDated" list="UomConversionDatedLastestList"> + <condition-list combine="and"> + <condition-expr field-name="uomId" operator="equals" from-field="parameters.uomId"/> + <condition-expr field-name="uomIdTo" operator="equals" from-field="parameters.uomIdTo"/> + <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/> + </condition-list> + </entity-condition> + <if-not-empty field="UomConversionDatedLastestList"> + <first-from-list entry="UomConversionLastest" list="UomConversionDatedLastestList"/> + <field-to-result field="UomConversionLastest.conversionFactor" result-name="conversionFactor"/> + </if-not-empty> + </else> + </if-not-empty> + </simple-method> + + <simple-method method-name="loadInventoryFact" short-description=""> + <entity-one entity-name="InventoryItem" value-field="inventory"> + <field-map field-name="inventoryItemId" from-field="parameters.inventoryItemId"/> + </entity-one> + <entity-one entity-name="InventoryItemFact" value-field="fact"> + <field-map field-name="inventoryItemId" from-field="parameters.inventoryItemId"/> + </entity-one> + <if-empty field="fact"> + <make-value value-field="fact" entity-name="InventoryItemFact"/> + <set field="fact.inventoryItemId" from-field="inventory.inventoryItemId"/> + <!-- conversion of the inventory date --> + <if-not-empty field="inventory.createdStamp"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="DateDimension"/> + <set field="inMap.naturalKeyFields.dateValue" from-field="inventory.createdStamp" type="Date"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.inventoryDateDimId"/> + </call-service> + <if-empty field="fact.inventoryDateDimId"> + <set field="fact.inventoryDateDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.inventoryDateDimId" value="_NA_"/> + </else> + </if-not-empty> + <!-- conversion of the product id --> + <if-not-empty field="inventory.productId"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="ProductDimension"/> + <set field="inMap.naturalKeyFields.productId" from-field="inventory.productId"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.productDimId"/> + </call-service> + <if-empty field="fact.productDimId"> + <set field="fact.productDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.productDimId" value="_NA_"/> + </else> + </if-not-empty> + <!-- conversion of the order currency --> + <if-not-empty field="inventory.currencyUomId"> + <clear-field field="inMap"/> + <set field="inMap.dimensionEntityName" value="CurrencyDimension"/> + <set field="inMap.naturalKeyFields.currencyId" from-field="inventory.currencyUomId"/> + <call-service service-name="getDimensionIdFromNaturalKey" in-map-name="inMap"> + <result-to-field result-name="dimensionId" field="fact.origCurrencyDimId"/> + </call-service> + <if-empty field="fact.origCurrencyDimId"> + <set field="fact.origCurrencyDimId" value="_NF_"/> + </if-empty> + <else> + <set field="fact.origCurrencyDimId" value="_NA_"/> + </else> + </if-not-empty> + <create-value value-field="fact"/> + </if-empty> + + <set field="fact.facilityId" from-field="inventory.facilityId"/> + <set field="fact.inventoryItemId" from-field="inventory.inventoryItemId"/> + <set field="fact.quantityOnHandTotal" from-field="inventory.quantityOnHandTotal"/> + <set field="fact.availableToPromiseTotal" from-field="inventory.availableToPromiseTotal"/> + <set field="fact.unitCost" from-field="inventory.unitCost"/> + + <!-- calculate sold out amount --> + <calculate field="fact.soldoutAmount"> + <calcop operator="get" field="inventory.quantityOnHandTotal"> + <calcop operator="negative" field="inventory.availableToPromiseTotal"/> + </calcop> + </calculate> + <store-value value-field="fact"/> + </simple-method> + +</simple-methods> Propchange: ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/bi/script/org/ofbiz/bi/FactServices.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml?rev=1642027&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml (added) +++ ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml Thu Nov 27 06:14:06 2014 @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd"> + + <!-- dimension entities --> + <eca service="createProduct" event="global-commit-post-run"> + <action service="loadType1ProductInProductDimension" mode="async"/> + </eca> + <eca service="updateProduct" event="global-commit-post-run"> + <action service="loadType2ProductInProductDimension" mode="async"/> + </eca> + + <!-- fact entities --> + <!-- Load data into the SalesInvoiceItemFact olap entity when a sales invoice is set to ready --> + <eca service="setInvoiceStatus" event="global-commit-post-run"> + <condition field-name="statusId" operator="equals" value="INVOICE_READY"/> + <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> + <action service="loadSalesInvoiceFact" mode="async" run-as-user="system"/> + </eca> + <!-- Load data into the SalesOrderItemFact olap entity when a sales order is set to ready --> + <!-- TODO: there are two eca for the same order status change: one of the two should be removed --> + <eca service="setOrderStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="ITEM_APPROVED"/> + <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> + <action service="loadSalesOrderFact" mode="async" run-as-user="system"/> + </eca> + <eca service="changeOrderItemStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="ITEM_APPROVED"/> + <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> + <action service="loadSalesOrderFact" mode="sync" run-as-user="system"/> + </eca> +</service-eca> Propchange: ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/bi/servicedef/secas.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/specialpurpose/bi/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/bi/servicedef/services.xml?rev=1642027&r1=1641394&r2=1642027&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/bi/servicedef/services.xml (original) +++ ofbiz/trunk/specialpurpose/bi/servicedef/services.xml Thu Nov 27 06:14:06 2014 @@ -28,7 +28,6 @@ under the License. <attribute name="naturalKeyFields" type="List" mode="IN" optional="false"/> <!-- the names of the fields that compose the natural key of the dimension --> <attribute name="updateMode" type="String" mode="IN" optional="false"/> <!-- TYPE1, TYPE2, TYPE3 --> </service> - <service name="getDimensionIdFromNaturalKey" engine="java" location="org.ofbiz.bi.util.DimensionServices" invoke="getDimensionIdFromNaturalKey" auth="true"> <description>Generic service to get the dimensionId for a natural key.</description> @@ -36,8 +35,6 @@ under the License. <attribute name="naturalKeyFields" type="Map" mode="IN" optional="false"/> <!-- the names/values pairs of the fields that compose the natural key of the dimension --> <attribute name="dimensionId" type="String" mode="OUT" optional="true"/> </service> - - <!-- TODO: this should be moved outside of the bi component --> <service name="quickInitDataWarehouse" auth="true" engine="simple" location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="quickInitDataWarehouse"> <description>Quickly initialize the dimensions (Currency, Date, Product) and facts (SalesInvoiceItem): useful to quickly initialize the datawarehouse.</description> @@ -45,4 +42,108 @@ under the License. <attribute name="thruDate" type="Timestamp" mode="IN" optional="false"/> </service> + <!-- Common Dimensions --> + <service name="loadDateDimension" engine="java" transaction-timeout="300" + location="org.ofbiz.bi.util.DimensionServices" invoke="loadDateDimension" auth="true"> + <description>Loads data in the DateDimension entity (olap entity) using the update strategy of 'type 1': overwrite the values of the attributes</description> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + <attribute name="thruDate" type="Timestamp" mode="IN" optional="false"/> + </service> + <service name="loadCurrencyDimension" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="loadCurrencyDimension"> + <description>Loads data in the CurrencyDimension entity (olap entity) using the update strategy of 'type 1': overwrite the values of the attributes</description> + </service> + <!-- Product Dimension --> + <service name="prepareProductDimensionData" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="prepareProductDimensionData"> + <description>Pulls information from the Product* entities (oltp entities) and prepares data for the ProductDimension entity (olap entity)</description> + <attribute name="productId" type="String" mode="IN" optional="false"/> + <attribute name="productDimension" type="GenericEntity" mode="OUT" optional="false"/> + </service> + <service name="loadProductInProductDimension" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension"> + <description>Pulls information from the Product* entities and stores them in the ProductDimension entity (olap entity)</description> + <attribute name="productId" type="String" mode="IN" optional="false"/> + <attribute name="updateMode" type="String" mode="IN" optional="false"/> <!-- TYPE1, TYPE2, TYPE3 --> + </service> + <service name="loadType1ProductInProductDimension" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension"> + <description>Same as loadProductInProductDimension; the update strategy is 'type 1': overwrite the values of the attributes</description> + <attribute name="productId" type="String" mode="IN" optional="false"/> + <attribute name="updateMode" type="String" mode="IN" optional="true" default-value="TYPE1"/> + </service> + <service name="loadType2ProductInProductDimension" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension"> + <description>Same as loadProductInProductDimension; the update strategy is 'type 2': add a dimension row</description> + <attribute name="productId" type="String" mode="IN" optional="false"/> + <attribute name="updateMode" type="String" mode="IN" optional="true" default-value="TYPE2"/> + </service> + <service name="loadAllProductsInProductDimension" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/DimensionServices.xml" invoke="loadAllProductsInProductDimension"> + <description>Calls the loadProductInProductDimension service for all the products.</description> + <attribute name="updateMode" type="String" mode="IN" optional="true" default-value="TYPE1"/> + </service> + + <!-- Accounting Facts --> + <service name="loadSalesInvoiceItemFact" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadSalesInvoiceItemFact"> + <description> + Pulls information from the Invoice* entities and stores them in the SalesInvoiceItem entity (olap entity). + One of invoiceId/invoiceItemSeqId or invoice/invoiceItem must be passed or an error is returned. + </description> + <attribute name="invoiceId" type="String" mode="IN" optional="true"/> + <attribute name="invoiceItemSeqId" type="String" mode="IN" optional="true"/> + <attribute name="invoice" type="org.ofbiz.entity.GenericValue" mode="IN" optional="true"/> + <attribute name="invoiceItem" type="org.ofbiz.entity.GenericValue" mode="IN" optional="true"/> + </service> + <service name="loadSalesInvoiceFact" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadSalesInvoiceFact"> + <description>Calls the loadSalesInvoiceItemFact service for all the invoice items.</description> + <attribute name="invoiceId" type="String" mode="IN" optional="false"/> + </service> + + <!-- Order Facts --> + <service name="loadSalesOrderItemFact" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadSalesOrderItemFact"> + <description> + Pulls information from the OrderItem* entities and stores them in the SalesOrderItem entity (olap entity). + One of orderId/orderItemSeqId or order/orderItem must be passed or an error is returned. + </description> + <attribute name="orderId" type="String" mode="IN" optional="true"/> + <attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/> + <attribute name="orderHeader" type="org.ofbiz.entity.GenericValue" mode="IN" optional="true"/> + <attribute name="orderItem" type="org.ofbiz.entity.GenericValue" mode="IN" optional="true"/> + <attribute name="orderAdjustment " type="org.ofbiz.entity.GenericValue" mode="IN" optional="true"/> + </service> + <service name="loadSalesOrderFact" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadSalesOrderFact"> + <description>Calls the loadSalesOrderItemFact service for all the order items.</description> + <attribute name="orderId" type="String" mode="IN" optional="false"/> + </service> + <service name="loadSalesOrderDataDaily" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadSalesOrderDataDaily" transaction-timeout="10000000"> + <description>Load Sales Order Data Daily.</description> + </service> + <service name="importSalesOrderData" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="importSalesOrderData" transaction-timeout="10000000"> + <description>Import Sales Order Data.</description> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + <attribute name="thruDate" type="Timestamp" mode="IN" optional="false"/> + </service> + <service name="convertUomCurrency" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="convertUomCurrency"> + <description>Import Sales Order Data.</description> + <attribute name="uomId" type="String" mode="IN"/> + <attribute name="uomIdTo" type="String" mode="IN"/> + <attribute name="nowDate" type="Timestamp" mode="IN" optional="true"/> + <attribute name="conversionFactor" type="Double" mode="OUT" optional="true"/> + </service> + + <!-- Inventory Facts --> + <service name="loadInventoryFact" auth="true" engine="simple" + location="component://bi/script/org/ofbiz/bi/FactServices.xml" invoke="loadInventoryFact"> + <attribute name="inventoryItemId" type="String" mode="IN" optional="true"/> + </service> + + </services> Modified: ofbiz/trunk/specialpurpose/bi/src/org/ofbiz/bi/util/DimensionServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/bi/src/org/ofbiz/bi/util/DimensionServices.java?rev=1642027&r1=1641394&r2=1642027&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/bi/src/org/ofbiz/bi/util/DimensionServices.java (original) +++ ofbiz/trunk/specialpurpose/bi/src/org/ofbiz/bi/util/DimensionServices.java Thu Nov 27 06:14:06 2014 @@ -18,12 +18,16 @@ under the License. */ package org.ofbiz.bi.util; +import java.lang.Object; +import java.lang.String; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import javolution.util.FastMap; - import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -66,7 +70,7 @@ public class DimensionServices { Locale locale = (Locale) context.get("locale"); try { - Map<String, Object> andCondition = FastMap.newInstance(); + Map<String, Object> andCondition = new HashMap<String, Object>(); for (String naturalKeyField: naturalKeyFields) { andCondition.put(naturalKeyField, dimensionValue.get(naturalKeyField)); } @@ -104,4 +108,72 @@ public class DimensionServices { return ServiceUtil.returnSuccess(); } + /* + * OLAP Dimension + * Service used to initialize the Date dimension (DateDimension). + * The DateDimension entity is a nearly constant dimension ("Slowly Changing Dimension" or SCD): + * the default strategy to handle data change is "Type 1" (i.e. overwrite the values). + */ + public static Map<String, Object> loadDateDimension(DispatchContext ctx, Map<String, ? extends Object> context) { + Delegator delegator = ctx.getDelegator(); + + Date fromDate = (Date) context.get("fromDate"); + Date thruDate = (Date) context.get("thruDate"); + + SimpleDateFormat monthNameFormat = new SimpleDateFormat("MMMM"); + SimpleDateFormat dayNameFormat = new SimpleDateFormat("EEEE"); + SimpleDateFormat dayDescriptionFormat = new SimpleDateFormat("MMMM d, yyyy"); + SimpleDateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM"); + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(fromDate); + calendar.set(Calendar.HOUR, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + java.sql.Date currentDate = new java.sql.Date(calendar.getTimeInMillis()); + while (currentDate.compareTo(thruDate) <= 0) { + GenericValue dateValue = null; + try { + dateValue = EntityUtil.getFirst(delegator.findByAnd("DateDimension", UtilMisc.toMap("dateValue", currentDate), null, false)); + } catch (GenericEntityException gee) { + return ServiceUtil.returnError(gee.getMessage()); + } + boolean newValue = (dateValue == null); + if (newValue) { + dateValue = delegator.makeValue("DateDimension"); + dateValue.set("dimensionId", delegator.getNextSeqId("DateDimension")); + dateValue.set("dateValue", new java.sql.Date(currentDate.getTime())); + } + dateValue.set("description", dayDescriptionFormat.format(currentDate)); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + dateValue.set("dayName", dayNameFormat.format(currentDate)); + dateValue.set("dayOfMonth", new Long(calendar.get(Calendar.DAY_OF_MONTH))); + dateValue.set("dayOfYear", new Long(calendar.get(Calendar.DAY_OF_YEAR))); + dateValue.set("monthName", monthNameFormat.format(currentDate)); + + dateValue.set("monthOfYear", new Long(calendar.get(Calendar.MONTH) + 1)); + dateValue.set("yearName", new Long(calendar.get(Calendar.YEAR))); + dateValue.set("weekOfMonth", new Long(calendar.get(Calendar.WEEK_OF_MONTH))); + dateValue.set("weekOfYear", new Long(calendar.get(Calendar.WEEK_OF_YEAR))); + dateValue.set("weekdayType", (dayOfWeek == 1 || dayOfWeek == 7? "Weekend": "Weekday")); + dateValue.set("yearMonthDay", yearMonthDayFormat.format(currentDate)); + dateValue.set("yearAndMonth", yearMonthFormat.format(currentDate)); + + try { + if (newValue) { + dateValue.create(); + } else { + dateValue.store(); + } + } catch (GenericEntityException gee) { + return ServiceUtil.returnError(gee.getMessage()); + } + calendar.add(Calendar.DATE, 1); + currentDate = new java.sql.Date(calendar.getTimeInMillis()); + } + return ServiceUtil.returnSuccess(); + } + } Modified: ofbiz/trunk/specialpurpose/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/build.xml?rev=1642027&r1=1642026&r2=1642027&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/build.xml (original) +++ ofbiz/trunk/specialpurpose/build.xml Thu Nov 27 06:14:06 2014 @@ -38,6 +38,7 @@ pos/build.xml, projectmgr/build.xml, scrum/build.xml, + bi/build.xml, webpos/build.xml "/> </project> Modified: ofbiz/trunk/specialpurpose/component-load.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/component-load.xml?rev=1642027&r1=1642026&r2=1642027&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/component-load.xml (original) +++ ofbiz/trunk/specialpurpose/component-load.xml Thu Nov 27 06:14:06 2014 @@ -38,6 +38,7 @@ under the License. <load-component component-location="ldap"/> <load-component component-location="webpos"/> <load-component component-location="birt"/> + <load-component component-location="bi"/> <load-component component-location="example"/> <load-component component-location="exampleext"/> <!-- <load-component component-location="jetty"/> --> |
Free forum by Nabble | Edit this page |