modules/org.openbravo.client.application/src-db/database/model/triggers/OBUIAPP_NAVBAR_COMPONENT_TRG.xml
changeset 9076 c4f1a5c7d7c2
child 10772 802557f42def
equal deleted inserted replaced
9075:b3ea04de2722 9076:c4f1a5c7d7c2
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER OBUIAPP_NAVBAR_COMPONENT_TRG">
       
     3     <trigger name="OBUIAPP_NAVBAR_COMPONENT_TRG" table="OBUIAPP_NAVBAR_COMPONENT" fires="before" insert="true" update="true" delete="true" foreach="row">
       
     4       <body><![CDATA[
       
     5 
       
     6 /*************************************************************************
       
     7 * The contents of this file are subject to the Openbravo  Public  License
       
     8 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
       
     9 * Version 1.1  with a permitted attribution clause; you may not  use this
       
    10 * file except in compliance with the License. You  may  obtain  a copy of
       
    11 * the License at http://www.openbravo.com/legal/license.html
       
    12 * Software distributed under the License  is  distributed  on  an "AS IS"
       
    13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
       
    14 * License for the specific  language  governing  rights  and  limitations
       
    15 * under the License.
       
    16 * The Original Code is Openbravo ERP.
       
    17 * The Initial Developer of the Original Code is Openbravo SL
       
    18 * All portions are Copyright (C) 2010 Openbravo SL
       
    19 * All Rights Reserved.
       
    20 * Contributor(s):  ______________________________________.
       
    21 ************************************************************************/
       
    22   devTemplate NUMBER;
       
    23   devModule   CHAR(1);
       
    24   currentModuleID  VARCHAR2(32);
       
    25   vAux NUMBER;
       
    26 
       
    27 BEGIN
       
    28     
       
    29     IF AD_isTriggerEnabled()='N' THEN RETURN;
       
    30     END IF;
       
    31 
       
    32   IF (UPDATING) THEN
       
    33     IF (COALESCE(:NEW.AD_Module_ID , '.') != COALESCE(:OLD.AD_Module_ID , '.')) THEN
       
    34       SELECT COUNT(*) 
       
    35         INTO vAux
       
    36         FROM AD_MODULE
       
    37        WHERE AD_MODULE_ID = :old.AD_Module_ID
       
    38         AND isindevelopment = 'N';
       
    39       IF (vAux!=0) THEN
       
    40         RAISE_APPLICATION_ERROR(-20000, '@ChangeNotInDevModule@');
       
    41       END IF;
       
    42     END IF;
       
    43   END IF;
       
    44 
       
    45   SELECT COUNT(*)
       
    46     INTO devTemplate
       
    47     FROM AD_MODULE
       
    48    WHERE IsInDevelopment = 'Y'
       
    49      AND Type = 'T';
       
    50      
       
    51   IF (UPDATING OR INSERTING) THEN
       
    52     currentModuleID := :new.AD_Module_ID;
       
    53   ELSE
       
    54     currentModuleID := :old.AD_Module_ID;
       
    55   END IF;
       
    56 
       
    57   SELECT M.IsInDevelopment
       
    58     INTO devModule
       
    59     FROM AD_MODULE M
       
    60    WHERE M.AD_MODULE_ID = currentModuleID;
       
    61 
       
    62     IF (UPDATING AND devTemplate=0 AND devModule='N') THEN
       
    63     -- Cannot update an object in a module not in developement and without an active template
       
    64       RAISE_APPLICATION_ERROR(-20000, '@20532@');
       
    65     END IF;
       
    66 
       
    67   IF ((DELETING OR INSERTING) AND devModule='N') THEN
       
    68   -- Cannot insert/delete objects in a module not in development.
       
    69     RAISE_APPLICATION_ERROR(-20000, '@20533@');
       
    70   END IF;
       
    71 
       
    72 END OBUIAPP_NAVBAR_COMPONENT_TRG
       
    73 ]]></body>
       
    74     </trigger>
       
    75   </database>