[Warehouse]Add module script to initialize on hand warehouses.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Tue, 23 Oct 2012 18:10:37 +0200
changeset 18659 719f9dba5048
parent 18658 20d2f53423cc
child 18660 64b27bbfdd72
[Warehouse]Add module script to initialize on hand warehouses.
src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeOnHandWarehouse.class
src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeOnHandWarehouseData.class
src-util/modulescript/src/org/openbravo/modulescript/InitializeOnHandWarehouse.java
src-util/modulescript/src/org/openbravo/modulescript/InitializeOnHandWarehouse_data.xsql
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeOnHandWarehouse.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeOnHandWarehouseData.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/InitializeOnHandWarehouse.java	Tue Oct 23 18:10:37 2012 +0200
@@ -0,0 +1,40 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.modulescript;
+
+import java.sql.Connection;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class InitializeOnHandWarehouse extends ModuleScript {
+  @Override
+  // Updates new column values with deprecated ones
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      if (!InitializeOnHandWarehouseData.hasOnHandWarehouse(cp.getConnection(), cp)) {
+        InitializeOnHandWarehouseData.initializeOnHandWarehouse(cp.getConnection(), cp);
+      }
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/InitializeOnHandWarehouse_data.xsql	Tue Oct 23 18:10:37 2012 +0200
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="InitializeOnHandWarehouseData" package="org.openbravo.modulescript">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="select" type="preparedStatement" connection="true" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        select '' as name
+        from dual
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="hasOnHandWarehouse" type="preparedStatement" connection="true" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        select count(*) as name from dual
+        where exists (select 1 from ad_org_warehouse)
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="initializeOnHandWarehouse" type="preparedStatement" connection="true" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        INSERT INTO ad_org_warehouse (
+          ad_org_warehouse_id, ad_client_id, ad_org_id, isactive,
+          created, createdby, updated, updatedby,
+          m_warehouse_id, priority
+        ) 
+          SELECT get_uuid(), wh.ad_client_id, o.ad_org_id, 'Y',
+                now(), '0', now(), '0',
+                wh.m_warehouse_id, 10
+          FROM m_warehouse wh
+              JOIN ad_org o ON ad_org_isinnaturaltree(wh.ad_org_id, o.ad_org_id, wh.ad_client_id) = 'Y'
+              JOIN aD_orgtype ot ON o.ad_orgtype_id = ot.ad_orgtype_id
+          WHERE ot.istransactionsallowed = 'Y'
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>