Moved the bi component from specialpurpose to the framework folder; moved artifacts from the bi component to the proper components.

Everything should be in place now, except for a convenience service (in the bi component) that quickly initializes the datawarehouse for demo purposes: this service calls two services from the applications (wrong dependency); I will fix this soon by moving it in some other places... however it is not a big deal for now because the service is really only useful to quickly test the prototype.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@677587 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2008-07-17 14:12:38 +00:00
parent 85e1dd9529
commit 795a920fe4
43 changed files with 263 additions and 161 deletions
+1 -1
View File
@@ -25,7 +25,6 @@ under the License.
<classpathentry kind="src" path="specialpurpose/assetmaint/src"/>
<classpathentry kind="src" path="specialpurpose/pos/src"/>
<classpathentry kind="src" path="specialpurpose/projectmgr/src"/>
<classpathentry kind="src" path="specialpurpose/bi/src"/>
<classpathentry kind="src" path="specialpurpose/ebay/src"/>
<classpathentry kind="src" path="specialpurpose/googlebase/src"/>
<classpathentry kind="src" path="framework/base/src/base"/>
@@ -41,6 +40,7 @@ under the License.
<classpathentry excluding="ShipmentScaleApplet.java" kind="src" path="applications/product/src"/>
<classpathentry excluding="org/ofbiz/securityext/thirdparty/truition/TruitionCoReg.java" kind="src" path="applications/securityext/src"/>
<classpathentry kind="src" path="applications/workeffort/src"/>
<classpathentry kind="src" path="framework/bi/src"/>
<classpathentry kind="src" path="framework/appserver/src"/>
<classpathentry kind="src" path="framework/catalina/src"/>
<classpathentry kind="src" path="framework/common/src"/>
+2 -1
View File
@@ -50,6 +50,7 @@ under the License.
<!-- <fileset dir="lib/worldpay" includes="*.jar"/> -->
<!-- <fileset dir="lib/cybersource" includes="*.jar"/> -->
<fileset dir="lib" includes="*.jar"/>
<fileset dir="../../hot-deploy/twpinc/lib" includes="*.jar"/>
</path>
<!-- ================================================================== -->
@@ -59,7 +60,7 @@ under the License.
<target name="classes" depends="prepare">
<javac15 classpathref="local.class.path">
<!-- exclude the payment processor packages; comment this out to not exclude if you have libs -->
<exclude name="org/ofbiz/accounting/thirdparty/verisign/**"/>
<!-- <exclude name="org/ofbiz/accounting/thirdparty/verisign/**"/> -->
<exclude name="org/ofbiz/accounting/thirdparty/cybersource/**"/>
<exclude name="org/ofbiz/accounting/thirdparty/worldpay/**"/>
</javac15>
@@ -33,6 +33,8 @@ under the License.
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_reports.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_old.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_olap.xml"/>
<entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/AccountingTypeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/UsTaxAccountGroups.xml"/>
@@ -54,6 +56,7 @@ under the License.
<service-resource type="model" loader="main" location="servicedef/services_paymentmethod.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_tax.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_cost.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_olap.xml"/>
<!-- Payment Processor/Gateway Service Definitions -->
<service-resource type="model" loader="main" location="servicedef/services_clearcommerce.xml"/>
@@ -68,6 +71,7 @@ under the License.
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_payment.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_ledger.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_olap.xml"/>
<test-suite loader="main" location="testdef/accountingtests.xml"/>
@@ -23,7 +23,7 @@ under the License.
<!-- Accounting Facts -->
<service name="loadSalesInvoiceItemFact" auth="true" engine="simple"
location="org/ofbiz/bi/FactServices.xml" invoke="loadSalesInvoiceItemFact">
location="org/ofbiz/accounting/olap/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.
@@ -34,7 +34,7 @@ under the License.
<attribute name="invoiceItem" type="GenericValue" mode="IN" optional="true"/>
</service>
<service name="loadSalesInvoiceFact" auth="true" engine="simple"
location="org/ofbiz/bi/FactServices.xml" invoke="loadSalesInvoiceFact">
location="org/ofbiz/accounting/olap/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>
+6 -1
View File
@@ -28,6 +28,8 @@ under the License.
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_shipment.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_olap.xml"/>
<entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/>
<entity-resource type="data" reader-name="seed-initial" loader="main" location="data/ProductScheduledServices.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/ProductTypeData.xml"/>
@@ -35,7 +37,8 @@ under the License.
<entity-resource type="data" reader-name="seed" loader="main" location="data/ProductSecurityData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/ProductUserDemoData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/ApiSchemaDhl.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/DimensionTypeData.xml"/>
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_facility.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_feature.xml"/>
@@ -53,8 +56,10 @@ under the License.
<service-resource type="model" loader="main" location="servicedef/services_view.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_cost.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_uom.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_olap.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_shipment.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_olap.xml"/>
<!-- test suite -->
<test-suite loader="main" location="testdef/FacilityTest.xml"/>
@@ -21,30 +21,6 @@ under the License.
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="loadCurrencyDimension" short-description="">
<entity-and entity-name="Uom" list-name="currencies">
<field-map field-name="uomTypeId" value="CURRENCY_MEASURE"/>
</entity-and>
<iterate list-name="currencies" entry-name="currency">
<entity-and entity-name="CurrencyDimension" list-name="currencyDims">
<field-map field-name="currencyId" env-name="currency.uomId"/>
</entity-and>
<if-not-empty field="currencyDims">
<iterate list-name="currencyDims" entry-name="currencyDim">
<set field="currencyDim.description" from-field="currency.description"/>
<store-value value-name="currencyDim"/>
</iterate>
<else>
<make-value value-name="currencyDim" entity-name="CurrencyDimension"/>
<sequenced-id-to-env sequence-name="CurrencyDimension" env-name="currencyDim.dimensionId"/>
<set field="currencyDim.currencyId" from-field="currency.uomId"/>
<set field="currencyDim.description" from-field="currency.description"/>
<create-value value-name="currencyDim"/>
</else>
</if-not-empty>
</iterate>
</simple-method>
<simple-method method-name="prepareProductDimensionData" short-description="">
<entity-one entity-name="Product" value-name="product"/>
<if-empty field="product">
@@ -80,33 +56,4 @@ under the License.
<clear-field field-name="inMap"/>
</iterate>
</simple-method>
<simple-method method-name="quickInitDataWarehouse" short-description="">
<set-service-fields service-name="loadDateDimension" map-name="parameters" to-map-name="inMap"/>
<call-service service-name="loadDateDimension" in-map-name="inMap"/>
<check-errors/>
<clear-field field-name="inMap"/>
<call-service service-name="loadCurrencyDimension" in-map-name="inMap"/>
<check-errors/>
<!-- loads all products in the ProductDimension -->
<clear-field field-name="inMap"/>
<call-service service-name="loadAllProductsInProductDimension" in-map-name="inMap"/>
<check-errors/>
<!-- loads the invoice items in the SalesInvoiceItemFact fact entity -->
<entity-condition entity-name="Invoice" list-name="invoices">
<condition-list>
<condition-expr field-name="invoiceTypeId" value="SALES_INVOICE"/>
<condition-expr field-name="invoiceDate" operator="greater-equals" env-name="parameters.fromDate"/>
<condition-expr field-name="invoiceDate" operator="less-equals" env-name="parameters.thruDate"/>
</condition-list>
</entity-condition>
<iterate list-name="invoices" entry-name="invoice">
<clear-field field-name="inMap"/>
<set field="inMap.invoiceId" from-field="invoice.invoiceId"/>
<call-service service-name="loadSalesInvoiceFact" in-map-name="inMap"/>
<check-errors/>
</iterate>
</simple-method>
</simple-methods>
@@ -23,32 +23,32 @@ under the License.
<!-- ProductDimension -->
<service name="prepareProductDimensionData" auth="true" engine="simple"
location="org/ofbiz/bi/DimensionServices.xml" invoke="prepareProductDimensionData">
location="org/ofbiz/product/olap/ProductDimensionServices.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="org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension">
location="org/ofbiz/product/olap/ProductDimensionServices.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="org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension">
location="org/ofbiz/product/olap/ProductDimensionServices.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="org/ofbiz/bi/DimensionServices.xml" invoke="loadProductInProductDimension">
location="org/ofbiz/product/olap/ProductDimensionServices.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="org/ofbiz/bi/DimensionServices.xml" invoke="loadAllProductsInProductDimension">
location="org/ofbiz/product/olap/ProductDimensionServices.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"/> <!-- TYPE1, TYPE2, TYPE3 -->
<attribute name="updateMode" type="String" mode="IN" optional="true" default-value="TYPE1"/>
</service>
</services>
@@ -39,12 +39,6 @@ under the License.
<fileset dir="../../framework/security/build/lib" includes="*.jar"/>
<fileset dir="../../framework/service/lib" includes="*.jar"/>
<fileset dir="../../framework/service/build/lib" includes="*.jar"/>
<fileset dir="../../framework/entityext/build/lib" includes="*.jar"/>
<fileset dir="../../framework/guiapp/lib" includes="*.jar"/>
<fileset dir="../../framework/guiapp/build/lib" includes="*.jar"/>
<fileset dir="../../framework/webapp/build/lib" includes="*.jar"/>
<fileset dir="../../applications/party/build/lib" includes="*.jar"/>
<fileset dir="../../applications/product/build/lib" includes="*.jar"/>
</path>
<!-- ================================================================== -->
@@ -25,23 +25,8 @@ under the License.
<classpath type="dir" location="script"/>
<classpath type="dir" location="config"/>
<classpath type="jar" location="build/lib/*"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_common_olap.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_product_olap.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_accounting_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_common_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_product_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_accounting_olap.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/DimensionTypeData_common.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/DimensionTypeData_product.xml"/>
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_common_olap.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_product_olap.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_accounting_olap.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_product_olap.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_accounting_olap.xml"/>
<webapp name="bi"
title="Business Intelligence"
@@ -0,0 +1,53 @@
<?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.xsd">
<simple-method method-name="quickInitDataWarehouse" short-description="">
<set-service-fields service-name="loadDateDimension" map-name="parameters" to-map-name="inMap"/>
<call-service service-name="loadDateDimension" in-map-name="inMap"/>
<check-errors/>
<clear-field field-name="inMap"/>
<call-service service-name="loadCurrencyDimension" in-map-name="inMap"/>
<check-errors/>
<!-- loads all products in the ProductDimension -->
<clear-field field-name="inMap"/>
<call-service service-name="loadAllProductsInProductDimension" in-map-name="inMap"/>
<check-errors/>
<!-- loads the invoice items in the SalesInvoiceItemFact fact entity -->
<entity-condition entity-name="Invoice" list-name="invoices">
<condition-list>
<condition-expr field-name="invoiceTypeId" value="SALES_INVOICE"/>
<condition-expr field-name="invoiceDate" operator="greater-equals" env-name="parameters.fromDate"/>
<condition-expr field-name="invoiceDate" operator="less-equals" env-name="parameters.thruDate"/>
</condition-list>
</entity-condition>
<iterate list-name="invoices" entry-name="invoice">
<clear-field field-name="inMap"/>
<set field="inMap.invoiceId" from-field="invoice.invoiceId"/>
<call-service service-name="loadSalesInvoiceFact" in-map-name="inMap"/>
<check-errors/>
</iterate>
</simple-method>
</simple-methods>
@@ -120,72 +120,4 @@ public class DimensionServices {
return ServiceUtil.returnSuccess();
}
/*
* 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 loadDateDimension(DispatchContext ctx, Map context) {
GenericDelegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
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);
Date currentDate = calendar.getTime();
while (currentDate.compareTo(thruDate) <= 0) {
GenericValue dateValue = null;
try {
dateValue = EntityUtil.getFirst(delegator.findByAnd("DateDimension", UtilMisc.toMap("dateValue", currentDate)));
} 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 = calendar.getTime();
}
return ServiceUtil.returnSuccess();
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ under the License.
entity/build.xml,geronimo/build.xml,
catalina/build.xml,jetty/build.xml,
security/build.xml,service/build.xml,entityext/build.xml,
datafile/build.xml,minilang/build.xml,
bi/build.xml,datafile/build.xml,minilang/build.xml,
common/build.xml,
webapp/build.xml,guiapp/build.xml,widget/build.xml,
testtools/build.xml,
+4
View File
@@ -26,6 +26,8 @@ under the License.
<classpath type="dir" location="config"/>
<classpath type="dir" location="script"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_olap.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CommonSecurityData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CommonTypeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CountryCodeData.xml"/>
@@ -49,9 +51,11 @@ under the License.
<entity-resource type="data" reader-name="seed" loader="main" location="data/LanguageData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/UnitData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/PeriodData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/DimensionTypeData.xml"/>
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_test.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_cdyne.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_olap.xml"/>
<service-resource type="group" loader="main" location="servicedef/groups_test.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_test.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas_cdyne.xml"/>
@@ -0,0 +1,48 @@
<?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.xsd">
<!-- OLAP Dimension -->
<simple-method method-name="loadCurrencyDimension" short-description="Initialize the CurrencyDimension using the update strategy of 'type 1'">
<entity-and entity-name="Uom" list-name="currencies">
<field-map field-name="uomTypeId" value="CURRENCY_MEASURE"/>
</entity-and>
<iterate list-name="currencies" entry-name="currency">
<entity-and entity-name="CurrencyDimension" list-name="currencyDims">
<field-map field-name="currencyId" env-name="currency.uomId"/>
</entity-and>
<if-not-empty field="currencyDims">
<iterate list-name="currencyDims" entry-name="currencyDim">
<set field="currencyDim.description" from-field="currency.description"/>
<store-value value-name="currencyDim"/>
</iterate>
<else>
<make-value value-name="currencyDim" entity-name="CurrencyDimension"/>
<sequenced-id-to-env sequence-name="CurrencyDimension" env-name="currencyDim.dimensionId"/>
<set field="currencyDim.currencyId" from-field="currency.uomId"/>
<set field="currencyDim.description" from-field="currency.description"/>
<create-value value-name="currencyDim"/>
</else>
</if-not-empty>
</iterate>
</simple-method>
</simple-methods>
@@ -23,13 +23,13 @@ under the License.
<!-- Common Dimension -->
<service name="loadDateDimension" engine="java" transaction-timeout="300"
location="org.ofbiz.bi.util.DimensionServices" invoke="loadDateDimension" auth="true">
location="org.ofbiz.common.olap.CommonDimensionServices" 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="Date" mode="IN" optional="false"/>
<attribute name="thruDate" type="Date" mode="IN" optional="false"/>
</service>
<service name="loadCurrencyDimension" auth="true" engine="simple"
location="org/ofbiz/bi/DimensionServices.xml" invoke="loadCurrencyDimension">
location="org/ofbiz/common/olap/CommonDimensionServices.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>
@@ -21,6 +21,7 @@ package org.ofbiz.common;
import java.io.*;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.mail.internet.MimeMessage;
@@ -40,6 +41,7 @@ import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -497,6 +499,5 @@ public class CommonServices {
return ServiceUtil.returnError("Invalid count returned from database");
}
}
}
@@ -0,0 +1,129 @@
/*******************************************************************************
* 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.
*******************************************************************************/
package org.ofbiz.common.olap;
import java.io.*;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.mail.internet.MimeMessage;
import javax.transaction.xa.XAException;
import javolution.util.FastMap;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import static org.ofbiz.base.util.UtilGenerics.checkList;
import static org.ofbiz.base.util.UtilGenerics.checkMap;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.service.ServiceXaWrapper;
import org.ofbiz.service.mail.MimeMessageWrapper;
/**
* Common Services
*/
public class CommonDimensionServices {
public final static String module = CommonDimensionServices.class.getName();
/*
* 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 loadDateDimension(DispatchContext ctx, Map context) {
GenericDelegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
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);
Date currentDate = calendar.getTime();
while (currentDate.compareTo(thruDate) <= 0) {
GenericValue dateValue = null;
try {
dateValue = EntityUtil.getFirst(delegator.findByAnd("DateDimension", UtilMisc.toMap("dateValue", currentDate)));
} 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 = calendar.getTime();
}
return ServiceUtil.returnSuccess();
}
}
+1
View File
@@ -30,6 +30,7 @@ under the License.
<load-component component-location="common"/>
<load-component component-location="service"/>
<load-component component-location="entityext"/>
<load-component component-location="bi"/>
<load-component component-location="webapp"/>
<load-component component-location="guiapp"/>
<load-component component-location="widget"/>
-1
View File
@@ -26,7 +26,6 @@
hhfacility/build.xml,
assetmaint/build.xml,
oagis/build.xml,
bi/build.xml,
googlebase/build.xml,
ebay/build.xml,
projectmgr/build.xml"/>
-1
View File
@@ -26,7 +26,6 @@ under the License.
<load-component component-location="cmssite"/>
<load-component component-location="projectmgr"/>
<load-component component-location="oagis"/>
<load-component component-location="bi"/>
<load-component component-location="googlebase"/>
<load-component component-location="ebay"/>
<load-component component-location="mypage"/>