database/model/triggers/AD_WINDOW_TRG.xml
author Antonio Moreno <antonio.moreno@openbravo.com>
Tue, 22 Apr 2008 13:47:26 +0000
changeset 737 935386ff0f30
parent 735 daced7e311c9
permissions -rw-r--r--
Structure without blank spaces (sqlplus step)
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER AD_WINDOW_TRG">
adrian@94
     3
    <trigger name="AD_WINDOW_TRG" table="AD_WINDOW" fires="after" insert="true" update="true" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
gorka@367
     9
adrian@94
    10
    /*************************************************************************
adrian@94
    11
    * The contents of this file are subject to the Compiere License
adrian@94
    12
    * Version 2.5.0 ("License"); You may not use this file except in
adrian@94
    13
    * compliance with the License. You may obtain a copy of the License at
adrian@94
    14
    * http://www.compiere.org/license.html
adrian@94
    15
    * Software distributed under the License is distributed on an
adrian@94
    16
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    17
    * implied. See the License for the specific language governing rights
adrian@94
    18
    * and limitations under the License.
gorkaion@239
    19
    * The Original Code is  Compiere  ERP &  Business Solution
adrian@94
    20
    * The Initial Developer of the Original Code is Jorg Janke  and ComPiere,
adrian@94
    21
    Inc.
adrian@94
    22
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    23
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    24
    * All Rights Reserved.
adrian@94
    25
    * Contributor(s): Openbravo SL
adrian@94
    26
    * Contributions are Copyright (C) 1999-2005 Openbravo, S.L
adrian@94
    27
    *************************************************************************
adrian@94
    28
    * $Id: AD_Window_Trg.sql,v 1.2 2002/08/26 05:23:32 jjanke Exp $
adrian@94
    29
    ***
adrian@94
    30
    * Title: Window Changes
adrian@94
    31
    * Description:
adrian@94
    32
    *   - Transaltion
adrian@94
    33
    *   - Sync Name (Workflow, Menu)
adrian@94
    34
    *   - Active State (Menu)
adrian@94
    35
    ************************************************************************/
adrian@94
    36
    BEGIN
adrian@94
    37
    -- Insert AD_Window Trigger
adrian@94
    38
    --  for Translation
adrian@94
    39
    --  Access
adrian@94
    40
    IF INSERTING
adrian@94
    41
    THEN
adrian@94
    42
    --  Create Translation Row
adrian@94
    43
  INSERT
adrian@94
    44
  INTO AD_Window_Trl
adrian@94
    45
    (
adrian@94
    46
      AD_Window_ID, AD_Language, AD_Client_ID,
adrian@94
    47
      AD_Org_ID, IsActive, Created,
adrian@94
    48
      CreatedBy, Updated, UpdatedBy,
adrian@94
    49
      Name, Description, Help,
adrian@94
    50
      IsTranslated
adrian@94
    51
    )
adrian@94
    52
  SELECT :new.AD_Window_ID,
adrian@94
    53
    AD_Language, :new.AD_Client_ID, :new.AD_Org_ID,
adrian@94
    54
    :new.IsActive, :new.Created, :new.CreatedBy,
adrian@94
    55
    :new.Updated, :new.UpdatedBy, :new.Name,
adrian@94
    56
    :new.Description, :new.Help, 'N'
adrian@94
    57
  FROM AD_Language
adrian@94
    58
  WHERE IsActive='Y'
adrian@94
    59
    AND IsSystemLanguage='Y';
adrian@94
    60
  -- Access for all
adrian@94
    61
  INSERT
adrian@94
    62
  INTO AD_Window_Access
adrian@94
    63
    (
adrian@94
    64
      AD_Window_ID, AD_Role_ID, AD_Client_ID,
adrian@94
    65
      AD_Org_ID, IsActive, Created,
adrian@94
    66
      CreatedBy, Updated, UpdatedBy,
adrian@94
    67
      IsReadWrite
adrian@94
    68
    )
adrian@94
    69
  SELECT DISTINCT :new.AD_Window_ID,
adrian@94
    70
    r.AD_Role_ID, r.AD_CLIENT_ID, r.AD_ORG_ID,
antonio@735
    71
     'Y', now(), 0,
antonio@735
    72
    now(), 0,  'Y'
adrian@94
    73
  FROM AD_Role r
adrian@94
    74
   WHERE isManual='N';
adrian@94
    75
 END IF;
adrian@94
    76
 -- Inserting
adrian@94
    77
 -- AD_Window update trigger
adrian@94
    78
 --  synchronize name,...
adrian@94
    79
 IF UPDATING THEN
gorkaion@239
    80
  IF(COALESCE(:old.Name, '.') <> COALESCE(:NEW.Name, '.')
gorkaion@239
    81
  OR COALESCE(:old.Description, '.') <> COALESCE(:NEW.Description, '.')
gorka@367
    82
  OR COALESCE(:old.Help, '.') <> COALESCE(:NEW.Help, '.'))
adrian@94
    83
 THEN
gorka@367
    84
    IF (COALESCE(:old.IsActive, '.') <> COALESCE(:NEW.IsActive, '.')) THEN
gorka@367
    85
        -- Update Menu
gorka@367
    86
        UPDATE AD_Menu
gorka@367
    87
          SET IsActive=:new.IsActive,
gorka@367
    88
          Name=:new.Name,
gorka@367
    89
          Description=:new.Description
gorka@367
    90
        WHERE AD_Window_ID=:new.AD_Window_ID;
gorka@367
    91
        -- Update Workflow
gorka@367
    92
        UPDATE AD_WF_Node
gorka@367
    93
          SET IsActive=:new.IsActive
gorka@367
    94
        WHERE AD_Window_ID=:new.AD_Window_ID;
gorka@367
    95
        UPDATE AD_WF_Node
gorka@367
    96
          SET Name=:new.Name,
gorka@367
    97
          Description=:new.Description,
gorka@367
    98
          Help=:new.Help
gorka@367
    99
        WHERE AD_Window_ID=:new.AD_Window_ID
gorka@367
   100
          AND IsCentrallyMaintained='Y';
gorka@367
   101
    END IF;
antonio@737
   102
adrian@94
   103
    -- Translation
adrian@94
   104
    UPDATE AD_Window_Trl
adrian@94
   105
      SET IsTranslated='N',
antonio@735
   106
      Updated=now()
adrian@94
   107
    WHERE AD_Window_ID=:new.AD_Window_ID;
adrian@94
   108
  END IF;
adrian@94
   109
 END IF;
adrian@94
   110
-- Updating
antonio@735
   111
END AD_WINDOW_TRG
gorkaion@239
   112
]]></body>
adrian@94
   113
    </trigger>
adrian@94
   114
  </database>