src-db/database/model/triggers/AD_FORM_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 785 8dba91261590
child 1660 1919f6d69730
permissions -rw-r--r--
Merge r2.5x intro trunk
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER AD_FORM_TRG">
adrian@94
     3
    <trigger name="AD_FORM_TRG" table="AD_FORM" fires="after" insert="true" update="true" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
juanpablo@771
     5
    /*************************************************************************
juanpablo@771
     6
    * The contents of this file are subject to the Compiere Public
juanpablo@771
     7
    * License 1.1 ("License"); You may not use this file except in
juanpablo@771
     8
    * compliance with the License. You may obtain a copy of the License in
juanpablo@771
     9
    * the legal folder of your Openbravo installation.
adrian@94
    10
    * Software distributed under the License is distributed on an
adrian@94
    11
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    12
    * implied. See the License for the specific language governing rights
adrian@94
    13
    * and limitations under the License.
juanpablo@778
    14
    * The Original Code is  Compiere  ERP &  Business Solution
juanpablo@771
    15
    * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
adrian@94
    16
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    17
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    18
    * All Rights Reserved.
adrian@94
    19
    * Contributor(s): Openbravo SL
juanpablo@785
    20
    * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
juanpablo@771
    21
    *
juanpablo@771
    22
    * Specifically, this derivative work is based upon the following Compiere
juanpablo@771
    23
    * file and version.
adrian@94
    24
    *************************************************************************
adrian@94
    25
    * Insert AD_Form Trigger
adrian@94
    26
    *  for Translation
adrian@94
    27
    *  Access
adrian@94
    28
    */
adrian@94
    29
    BEGIN   IF INSERTING
adrian@94
    30
    THEN
adrian@94
    31
  INSERT
adrian@94
    32
  INTO AD_Form_Trl
adrian@94
    33
    (
juanpablo@1605
    34
      AD_Form_Trl_ID, AD_Form_ID, AD_Language, AD_Client_ID,
adrian@94
    35
      AD_Org_ID, IsActive, Created,
adrian@94
    36
      CreatedBy, Updated, UpdatedBy,
adrian@94
    37
      Name, Description, Help,
adrian@94
    38
      IsTranslated
adrian@94
    39
    )
juanpablo@1605
    40
  SELECT get_uuid(), :new.AD_Form_ID,
adrian@94
    41
    AD_Language, :new.AD_Client_ID, :new.AD_Org_ID,
adrian@94
    42
    :new.IsActive, :new.Created, :new.CreatedBy,
adrian@94
    43
    :new.Updated, :new.UpdatedBy, :new.Name,
adrian@94
    44
    :new.Description, :new.Help, 'N'
adrian@94
    45
  FROM AD_Language
adrian@94
    46
  WHERE IsActive='Y'
adrian@94
    47
    AND IsSystemLanguage='Y';
adrian@94
    48
  -- Access for all
adrian@94
    49
  INSERT
adrian@94
    50
  INTO AD_Form_Access
adrian@94
    51
    (
adrian@94
    52
      AD_Form_ID, AD_Role_ID, AD_Client_ID,
adrian@94
    53
      AD_Org_ID, IsActive, Created,
adrian@94
    54
      CreatedBy, Updated, UpdatedBy,
adrian@94
    55
      IsReadWrite
adrian@94
    56
    )
adrian@94
    57
  SELECT :new.AD_Form_ID,
adrian@94
    58
    r.AD_Role_ID,  r.AD_CLIENT_ID, r.AD_ORG_ID,
juanpablo@1605
    59
     'Y', now(), '0',
juanpablo@1605
    60
    now(), '0',  'Y'
adrian@94
    61
  FROM AD_Role r
adrian@94
    62
  where ismanual = 'N';
adrian@94
    63
 END IF;
adrian@94
    64
 -- Inserting
adrian@94
    65
 -- AD_Form update trigger
adrian@94
    66
 --  synchronize name,... with Field if not centrally maintained
adrian@94
    67
 IF(UPDATING) THEN
gorkaion@239
    68
  IF((COALESCE(:old.Name, '.') <> COALESCE(:NEW.Name, '.')
gorkaion@239
    69
  OR COALESCE(:old.Help, '.') <> COALESCE(:NEW.Help, '.')
gorkaion@239
    70
  OR COALESCE(:old.Description, '.') <> COALESCE(:NEW.Description, '.')))
adrian@94
    71
 THEN
adrian@94
    72
    UPDATE AD_Form_Trl
adrian@94
    73
      SET IsTranslated='N',
antonio@735
    74
      Updated=now()
adrian@94
    75
    WHERE AD_Form_ID=:new.AD_Form_ID;
adrian@94
    76
  END IF;
adrian@94
    77
 END IF;
adrian@94
    78
-- Updating
antonio@735
    79
END AD_FORM_TRG
gorkaion@239
    80
]]></body>
adrian@94
    81
    </trigger>
adrian@94
    82
  </database>