src-util/modulescript/src/org/openbravo/modulescript/UpdatePersistOrgInfo_data.xsql
author Víctor Martínez Romanos <victor.martinez@openbravo.com>
Fri, 27 Apr 2018 10:55:13 +0200
changeset 33894 faca925fb578
parent 33887 793f3d0ba3f5
permissions -rw-r--r--
Related to issue 33650: code review improvements
Properly format modulescript
Removed info message in module script
Increased limits
Ensure we don't work with * org and any organization where the persist org is already available
atul@33887
     1
<?xml version="1.0" encoding="UTF-8" ?>
atul@33887
     2
<!--
atul@33887
     3
 *************************************************************************
atul@33887
     4
 * The contents of this file are subject to the Openbravo  Public  License
atul@33887
     5
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
atul@33887
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
atul@33887
     7
 * file except in compliance with the License. You  may  obtain  a copy of
atul@33887
     8
 * the License at http://www.openbravo.com/legal/license.html
atul@33887
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
atul@33887
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
atul@33887
    11
 * License for the specific  language  governing  rights  and  limitations
atul@33887
    12
 * under the License.
atul@33887
    13
 * The Original Code is Openbravo ERP.
atul@33887
    14
 * The Initial Developer of the Original Code is Openbravo SLU
atul@33887
    15
 * All portions are Copyright (C) 2018 Openbravo SLU
atul@33887
    16
 * All Rights Reserved.
atul@33887
    17
 * Contributor(s):  ______________________________________.
atul@33887
    18
 ************************************************************************
atul@33887
    19
-->
atul@33887
    20
<SqlClass name="UpdatePersistOrgInfoData" package="org.openbravo.modulescript">
atul@33887
    21
   <SqlClassComment></SqlClassComment>
atul@33887
    22
   <SqlMethod name="select" type="preparedStatement" return="multiple">
atul@33887
    23
    <SqlMethodComment></SqlMethodComment>
atul@33887
    24
    <Sql><![CDATA[
atul@33887
    25
      SELECT 1 as dummy, '' as AD_Org_ID, '' as C_CALENDAR_ID FROM DUAL
atul@33887
    26
      ]]>
atul@33887
    27
    </Sql>
atul@33887
    28
   </SqlMethod>
atul@33887
    29
  <SqlMethod name="selectOrgs" type="preparedStatement" return="multiple">
atul@33887
    30
    <SqlMethodComment></SqlMethodComment>
atul@33887
    31
    <Sql><![CDATA[
atul@33887
    32
        SELECT AD_Org_ID
atul@33887
    33
        FROM AD_Org
victor@33894
    34
        WHERE IsReady = 'Y'
victor@33894
    35
        AND AD_Org_ID <> '0'
victor@33894
    36
        AND AD_PeriodControlAllowed_Org_ID IS NULL
victor@33894
    37
        AND AD_CalendarOwner_Org_ID IS NULL 
victor@33894
    38
        AND AD_InheritedCalendar_ID IS NULL 
victor@33894
    39
        AND AD_LegalEntity_Org_ID IS NULL
victor@33894
    40
        AND AD_BusinessUnit_Org_ID IS NULL
atul@33887
    41
    ]]></Sql>
atul@33887
    42
    <Field name="dummy" value="void"/>
atul@33887
    43
  </SqlMethod>
atul@33887
    44
  <SqlMethod name="updatePersistOrgInfo" type="preparedStatement" return="rowcount">
atul@33887
    45
    <SqlMethodComment></SqlMethodComment>
atul@33887
    46
    <Sql><![CDATA[
atul@33887
    47
        UPDATE AD_Org
atul@33887
    48
        SET AD_PeriodControlAllowed_Org_ID = ?,
atul@33887
    49
            AD_CalendarOwner_Org_ID = ?,
atul@33887
    50
            AD_InheritedCalendar_ID = ?,
atul@33887
    51
            AD_LegalEntity_Org_ID = ?,
atul@33887
    52
            AD_BusinessUnit_Org_ID = ?
atul@33887
    53
        WHERE AD_Org_ID = ?
atul@33887
    54
    ]]></Sql>
atul@33887
    55
    <Parameter name="periodControlAllowedOrg"/>
atul@33887
    56
    <Parameter name="calendarOwnerOrg"/>
atul@33887
    57
    <Parameter name="inheritedCalendarOrg"/>
atul@33887
    58
    <Parameter name="legalEntityOrg"/>
atul@33887
    59
    <Parameter name="businessUnitOrg"/>
atul@33887
    60
    <Parameter name="orgId"/>
atul@33887
    61
  </SqlMethod>
atul@33887
    62
  <SqlMethod name="getPeriodControlAllowedOrg" type="preparedStatement" return="String">
atul@33887
    63
    <SqlMethodComment></SqlMethodComment>
atul@33887
    64
    <Sql><![CDATA[
atul@33887
    65
        SELECT ad_org_getperiodcontrolallowtn(?) AS AD_Org_ID
atul@33887
    66
        FROM DUAL
atul@33887
    67
    ]]></Sql>
atul@33887
    68
    <Parameter name="orgId"/>
atul@33887
    69
  </SqlMethod>
atul@33887
    70
  <SqlMethod name="getCalendarOwnerOrg" type="preparedStatement" return="String">
atul@33887
    71
    <SqlMethodComment></SqlMethodComment>
atul@33887
    72
    <Sql><![CDATA[
atul@33887
    73
        SELECT ad_org_getcalendarownertn(?) AS AD_Org_ID
atul@33887
    74
        FROM DUAL
atul@33887
    75
    ]]></Sql>
atul@33887
    76
    <Parameter name="orgId"/>
atul@33887
    77
  </SqlMethod>
atul@33887
    78
  <SqlMethod name="getCalendar" type="preparedStatement" return="String">
atul@33887
    79
    <SqlMethodComment></SqlMethodComment>
atul@33887
    80
    <Sql><![CDATA[
atul@33887
    81
        SELECT C_CALENDAR_ID
atul@33887
    82
        FROM AD_ORG
atul@33887
    83
        WHERE AD_ORG_ID = ?
atul@33887
    84
    ]]></Sql>
atul@33887
    85
    <Parameter name="orgId"/>
atul@33887
    86
  </SqlMethod>
atul@33887
    87
  <SqlMethod name="getLegalEntityBusinessUnitOrg" type="preparedStatement" return="String">
atul@33887
    88
    <SqlMethodComment></SqlMethodComment>
atul@33887
    89
    <Sql><![CDATA[
atul@33887
    90
        SELECT ad_get_org_le_bu_treenode(?, ?) AS AD_Org_ID
atul@33887
    91
        FROM DUAL
atul@33887
    92
    ]]></Sql>
atul@33887
    93
    <Parameter name="orgId"/>
atul@33887
    94
    <Parameter name="orgType"/>
atul@33887
    95
  </SqlMethod>
atul@33887
    96
  <SqlMethod name="isPersistOrgInfoUpdated" type="preparedStatement" return="boolean">
atul@33887
    97
    <SqlMethodComment></SqlMethodComment>
atul@33887
    98
    <Sql>
atul@33887
    99
      <![CDATA[
atul@33887
   100
        SELECT count(*) as exist
atul@33887
   101
        FROM DUAL
atul@33887
   102
        WHERE EXISTS (SELECT 1 FROM ad_preference
atul@33887
   103
                      WHERE attribute = 'PersistOrgInfoUpdated')
atul@33887
   104
      ]]>
atul@33887
   105
    </Sql>
atul@33887
   106
  </SqlMethod>
atul@33887
   107
  <SqlMethod name="createPreferencePersistOrgInfoUpdated" type="preparedStatement" return="rowcount">
atul@33887
   108
    <SqlMethodComment></SqlMethodComment>
atul@33887
   109
    <Sql>
atul@33887
   110
      <![CDATA[
atul@33887
   111
        INSERT INTO ad_preference (
atul@33887
   112
          ad_preference_id, ad_client_id, ad_org_id, isactive,
atul@33887
   113
          createdby, created, updatedby, updated,
atul@33887
   114
          attribute, value
atul@33887
   115
        ) VALUES (
atul@33887
   116
          get_uuid(), '0', '0', 'Y',
atul@33887
   117
          '0', NOW(), '0', NOW(),
atul@33887
   118
          'PersistOrgInfoUpdated', 'Y'
atul@33887
   119
        )
atul@33887
   120
      ]]>
atul@33887
   121
    </Sql>
atul@33887
   122
  </SqlMethod>
atul@33887
   123
 </SqlClass>