modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_ELEMENT_TRL_TRG.xml
changeset 9076 c4f1a5c7d7c2
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER OBUISEL_ELEMENT_TRL_TRG">
       
     3     <trigger name="OBUISEL_ELEMENT_TRL_TRG" table="AD_ELEMENT_TRL" fires="before" insert="false" update="true" delete="false" foreach="row">
       
     4       <body><![CDATA[
       
     5 /*************************************************************************
       
     6 * The contents of this file are subject to the Compiere Public
       
     7 * License 1.1 ("License"); You may not use this file except in
       
     8 * compliance with the License. You may obtain a copy of the License in
       
     9 * the legal folder of your Openbravo installation.
       
    10 * Software distributed under the License is distributed on an
       
    11 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
       
    12 * implied. See the License for the specific language governing rights
       
    13 * and limitations under the License.
       
    14 * The Original Code is  Compiere  ERP &  Business Solution
       
    15 * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
       
    16 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
       
    17 * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
       
    18 * All Rights Reserved.
       
    19 * Contributor(s): Openbravo SLU
       
    20 * Contributions are Copyright (C) 2010 Openbravo, S.L.U.
       
    21 *
       
    22 * Specifically, this derivative work is based upon the following Compiere
       
    23 * file and version.
       
    24 *************************************************************************
       
    25 * $Id: AD_Element_Trl_Trg.sql,v 1.4 2002/11/08 05:42:01 jjanke Exp $
       
    26 ***
       
    27 * Title: AD_Element_Trl update trigger
       
    28 * Description:
       
    29 *   Synchronize name,... with  Selector Field if centrally maintained
       
    30 ************************************************************************/
       
    31 BEGIN --BODY
       
    32     
       
    33     IF AD_isTriggerEnabled()='N' THEN RETURN;
       
    34     END IF;
       
    35 
       
    36 
       
    37     IF UPDATING THEN
       
    38     IF (   
       
    39         COALESCE (:OLD.NAME, '.') <> COALESCE (:NEW.NAME, '.')
       
    40         OR COALESCE (:OLD.Description, '.') <> COALESCE (:NEW.Description, '.')
       
    41         OR COALESCE (:OLD.HELP, '.') <> COALESCE (:NEW.HELP, '.')
       
    42         OR COALESCE (:OLD.PrintName, '.') <> COALESCE (:NEW.PrintName, '.')
       
    43         OR COALESCE (:OLD.IsTranslated, '.') <> COALESCE (:NEW.IsTranslated, '.')
       
    44        )
       
    45     THEN
       
    46         UPDATE OBUISEL_Selector_Field_Trl
       
    47         SET NAME = :NEW.NAME,
       
    48             Description = :NEW.Description,
       
    49             HELP = :NEW.HELP,
       
    50             IsTranslated = :NEW.IsTranslated
       
    51         WHERE  AD_Language_ID = :NEW.AD_Language
       
    52             AND OBUISEL_Selector_Field_ID IN (
       
    53                 SELECT F.OBUISEL_Selector_Field_ID
       
    54                 FROM OBUISEL_Selector_Field F, AD_Column C, AD_Module M
       
    55                 WHERE F.AD_Column_ID = C.AD_Column_ID
       
    56                     AND C.AD_Element_ID = :NEW.AD_Element_ID
       
    57                     AND F.IsCentrallyMaintained = 'Y'
       
    58                     AND M.aD_Module_id = f.ad_module_id
       
    59                     and m.AD_Language != :new.AD_Language);
       
    60                   
       
    61         UPDATE OBUISEL_Selector_Field
       
    62         SET NAME = :NEW.NAME,
       
    63             Description = :NEW.Description,
       
    64             HELP = :NEW.HELP
       
    65         WHERE  OBUISEL_Selector_Field_ID IN (
       
    66             SELECT F.OBUISEL_Selector_Field_ID
       
    67                 FROM OBUISEL_Selector_Field F, AD_Column C, AD_Module M
       
    68                 WHERE F.AD_Column_ID = C.AD_Column_ID
       
    69                 AND C.AD_Element_ID = :NEW.AD_Element_ID
       
    70                 AND F.IsCentrallyMaintained = 'Y'
       
    71                 AND M.aD_Module_id = f.ad_module_id
       
    72                 and m.AD_Language = :new.AD_Language)
       
    73             AND exists (SELECT 1 from ad_module m
       
    74                 where m.ad_module_id=OBUISEL_Selector_Field.ad_module_id
       
    75                 and m.isindevelopment='Y');
       
    76         END IF;
       
    77     END IF;
       
    78 END OBUISEL_ELEMENT_TRL_TRG
       
    79 ]]></body>
       
    80     </trigger>
       
    81   </database>