src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml
author Gorka Gil <gorka.gil@openbravo.com>
Mon, 17 Nov 2008 17:19:51 +0000
changeset 1984 6072e1cf1838
child 2067 c73cf7263093
permissions -rw-r--r--
Added System Info window
Added Customization_Allowed to AD_System_info table
Added trigger to create an industry template when Customization_Allowed is checked
gorka@1984
     1
<?xml version="1.0"?>
gorka@1984
     2
  <database name="TRIGGER AD_SYSTEM_INFO_TRG2">
gorka@1984
     3
    <trigger name="AD_SYSTEM_INFO_TRG2" table="AD_SYSTEM_INFO" fires="after" insert="false" update="true" delete="false" foreach="row">
gorka@1984
     4
      <body><![CDATA[
gorka@1984
     5
gorka@1984
     6
/*************************************************************************
gorka@1984
     7
* The contents of this file are subject to the Openbravo  Public  License
gorka@1984
     8
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
gorka@1984
     9
* Version 1.1  with a permitted attribution clause; you may not  use this
gorka@1984
    10
* file except in compliance with the License. You  may  obtain  a copy of
gorka@1984
    11
* the License at http://www.openbravo.com/legal/license.html
gorka@1984
    12
* Software distributed under the License  is  distributed  on  an "AS IS"
gorka@1984
    13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
gorka@1984
    14
* License for the specific  language  governing  rights  and  limitations
gorka@1984
    15
* under the License.
gorka@1984
    16
* The Original Code is Openbravo ERP.
gorka@1984
    17
* The Initial Developer of the Original Code is Openbravo SL
gorka@1984
    18
* All portions are Copyright (C) 2001-2008 Openbravo SL
gorka@1984
    19
* All Rights Reserved.
gorka@1984
    20
* Contributor(s):  ______________________________________.
gorka@1984
    21
************************************************************************/
gorka@1984
    22
gorka@1984
    23
exist NUMBER := 0;
gorka@1984
    24
indTempName NVARCHAR2(50) := 'System Customization';
gorka@1984
    25
indTempPackage NVARCHAR2(50) := 'mySystem.CustomizationTemplate';
gorka@1984
    26
gorka@1984
    27
BEGIN
gorka@1984
    28
  If :old.customization_Allowed='N' and :new.customization_Allowed='Y' then
gorka@1984
    29
  
gorka@1984
    30
    select count(*) into exist
gorka@1984
    31
    from AD_MODULE
gorka@1984
    32
    where TYPE = 'T'
gorka@1984
    33
    and ISINDEVELOPMENT = 'Y';
gorka@1984
    34
    
gorka@1984
    35
    if (exist > 0) then
gorka@1984
    36
      RAISE_APPLICATION_ERROR(-20631,'There is already an active Industry Template.');
gorka@1984
    37
    else
gorka@1984
    38
      Insert into AD_MODULE (
gorka@1984
    39
        AD_MODULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
gorka@1984
    40
        NAME,VERSION,DESCRIPTION,
gorka@1984
    41
        HELP,
gorka@1984
    42
        URL,TYPE,LICENSE,
gorka@1984
    43
        ISINDEVELOPMENT,ISDEFAULT,SEQNO,JAVAPACKAGE,
gorka@1984
    44
        LICENSETYPE,AUTHOR,STATUS,UPDATE_AVAILABLE,ISTRANSLATIONREQUIRED,AD_LANGUAGE,HASCHARTOFACCOUNTS,
gorka@1984
    45
        ISTRANSLATIONMODULE,HASREFERENCEDATA,ISREGISTERED,UPDATEINFO,UPDATE_VER_ID) 
gorka@1984
    46
      values (
gorka@1984
    47
        get_uuid(),'0','0','Y',now(),'0',now(),'0',
gorka@1984
    48
        to_char(indTempName),'1.0.0', to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core.',
gorka@1984
    49
        to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core. Only one industry template can be active at the same time.',
gorka@1984
    50
        null,'T','The Openbravo Public License Version 1.1 ("OBPL") consists of the Mozilla Public License Version 1.1, modified to be specific to Openbravo, with the Additional Terms in Exhibit B. The original Mozilla Public License 1.1 can be found at: http://www.mozilla.org/MPL/MPL-1.1.html',
gorka@1984
    51
        'Y','N',null,to_char(indTempPackage),
gorka@1984
    52
        'OtherOS',null,null,null,'Y','en_US','N',
gorka@1984
    53
        'N','N',null,null,null);
gorka@1984
    54
    end if;
gorka@1984
    55
  end if;
gorka@1984
    56
  
gorka@1984
    57
  If (:old.customization_Allowed='Y' and :new.customization_Allowed='N') then
gorka@1984
    58
    delete from AD_MODULE
gorka@1984
    59
    where name = indTempName;
gorka@1984
    60
  end if;
gorka@1984
    61
gorka@1984
    62
END AD_SYSTEM_INFO_TRG2
gorka@1984
    63
]]></body>
gorka@1984
    64
    </trigger>
gorka@1984
    65
  </database>