src-db/database/model/triggers/AD_CALLOUT_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 756 ae11e4610537
child 1605 8a0fe0193bef
permissions -rw-r--r--
Fix last update of copyright years in database files
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER AD_CALLOUT_TRG">
adrian@94
     3
    <trigger name="AD_CALLOUT_TRG" table="AD_CALLOUT" fires="after" insert="true" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
adrian@94
     9
/*************************************************************************
adrian@94
    10
* The contents of this file are subject to the Openbravo  Public  License
adrian@94
    11
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    12
* Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    13
* file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    14
* the License at http://www.openbravo.com/legal/license.html
adrian@94
    15
* Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    17
* License for the specific  language  governing  rights  and  limitations
adrian@94
    18
* under the License.
adrian@94
    19
* The Original Code is Openbravo ERP.
adrian@94
    20
* The Initial Developer of the Original Code is Openbravo SL
adrian@94
    21
* All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    22
* All Rights Reserved.
adrian@94
    23
* Contributor(s):  ______________________________________.
adrian@94
    24
************************************************************************/
adrian@94
    25
  v_ID NUMBER(10) ;
adrian@94
    26
  v_ID_MAP     NUMBER(10) ;
adrian@94
    27
  v_WindowName VARCHAR2(60) ;
adrian@94
    28
  v_ClassName  VARCHAR2(60) ;
adrian@94
    29
BEGIN
adrian@94
    30
  IF(UPDATING) THEN
gorkaion@239
    31
    IF(NOT(COALESCE(:old.Name, '.') <> COALESCE(:NEW.Name, '.')
gorkaion@239
    32
   OR COALESCE(:old.IsActive, '.') <> COALESCE(:NEW.IsActive, '.')))
adrian@94
    33
  THEN
adrian@94
    34
      RETURN;
adrian@94
    35
    END IF;
adrian@94
    36
  END IF;
adrian@94
    37
  v_WindowName:='ad_callouts';
adrian@94
    38
  IF(DELETING OR UPDATING) THEN
adrian@94
    39
    IF :OLD.ISACTIVE='Y' THEN
adrian@94
    40
      DELETE
adrian@94
    41
      FROM AD_MODEL_OBJECT_MAPPING
adrian@94
    42
      WHERE AD_MODEL_OBJECT_ID IN
adrian@94
    43
        (
adrian@94
    44
        SELECT AD_MODEL_OBJECT_ID
adrian@94
    45
        FROM AD_MODEL_OBJECT
adrian@94
    46
        WHERE AD_MODEL_OBJECT.AD_CALLOUT_ID=:old.AD_CALLOUT_ID
adrian@94
    47
          AND ACTION='C'
adrian@94
    48
        )
adrian@94
    49
        ;
adrian@94
    50
      DELETE
adrian@94
    51
      FROM AD_MODEL_OBJECT
adrian@94
    52
      WHERE ACTION='C'
adrian@94
    53
        AND AD_MODEL_OBJECT.AD_CALLOUT_ID=:OLD.AD_CALLOUT_ID;
adrian@94
    54
    END IF;
adrian@94
    55
  END IF;
adrian@94
    56
  IF(INSERTING OR UPDATING) THEN
adrian@94
    57
    IF :NEW.ISACTIVE='Y' THEN
adrian@94
    58
      v_ClassName:=AD_MAPPING_FORMAT(TO_CHAR(:new.NAME)) ;
adrian@94
    59
      Ad_Sequence_Next('AD_Model_Object', :new.AD_Client_ID, v_ID) ;
adrian@94
    60
      INSERT
adrian@94
    61
      INTO AD_MODEL_OBJECT
adrian@94
    62
        (
adrian@94
    63
          AD_MODEL_OBJECT_ID, AD_CLIENT_ID, AD_ORG_ID,
adrian@94
    64
          ISACTIVE, CREATED, CREATEDBY,
adrian@94
    65
          UPDATED, UPDATEDBY, ACTION,
adrian@94
    66
          AD_CALLOUT_ID, CLASSNAME, ISDEFAULT
adrian@94
    67
        )
adrian@94
    68
        VALUES
adrian@94
    69
        (
adrian@94
    70
          v_ID, :new.AD_CLIENT_ID, :new.AD_ORG_ID,  'Y',
antonio@735
    71
          now(), :new.CREATEDBY, now(),
adrian@94
    72
          :new.UPDATEDBY,  'C', :new.AD_CALLOUT_ID,
adrian@94
    73
           'org.openbravo.erpCommon.' || v_WindowName || '.' || v_ClassName, 'Y'
adrian@94
    74
        )
adrian@94
    75
        ;
adrian@94
    76
      Ad_Sequence_Next('AD_Model_Object_Mapping', :new.AD_Client_ID, v_ID_MAP) ;
adrian@94
    77
      INSERT
adrian@94
    78
      INTO AD_MODEL_OBJECT_MAPPING
adrian@94
    79
        (
adrian@94
    80
          AD_MODEL_OBJECT_MAPPING_ID, AD_CLIENT_ID, AD_ORG_ID,
adrian@94
    81
          ISACTIVE, CREATED, CREATEDBY,
adrian@94
    82
          UPDATED, UPDATEDBY, AD_MODEL_OBJECT_ID,
adrian@94
    83
          MAPPINGNAME, ISDEFAULT
adrian@94
    84
        )
adrian@94
    85
        VALUES
adrian@94
    86
        (
adrian@94
    87
          v_ID_MAP, :new.AD_CLIENT_ID, :new.AD_ORG_ID,
antonio@735
    88
           'Y', now(), :new.CREATEDBY,
antonio@735
    89
          now(), :new.UPDATEDBY, v_ID,
adrian@94
    90
          ('/' || v_WindowName || '/' || v_ClassName || '.html'), 'Y'
adrian@94
    91
        )
adrian@94
    92
        ;
adrian@94
    93
    END IF;
adrian@94
    94
  END IF;
antonio@735
    95
END AD_CALLOUT_TRG
gorkaion@239
    96
]]></body>
adrian@94
    97
    </trigger>
adrian@94
    98
  </database>