modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_ELEMENT_TRG.xml
changeset 9076 c4f1a5c7d7c2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_ELEMENT_TRG.xml	Fri Dec 10 19:47:45 2010 +0100
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER OBUISEL_ELEMENT_TRG">
+    <trigger name="OBUISEL_ELEMENT_TRG" table="AD_ELEMENT" fires="before" insert="false" update="true" delete="false" foreach="row">
+      <body><![CDATA[
+    /*************************************************************************
+    * The contents of this file are subject to the Compiere Public
+    * License 1.1 ("License"); You may not use this file except in
+    * compliance with the License. You may obtain a copy of the License in
+    * the legal folder of your Openbravo installation.
+    * Software distributed under the License is distributed on an
+    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+    * implied. See the License for the specific language governing rights
+    * and limitations under the License.
+    * The Original Code is  Compiere  ERP &  Business Solution
+    * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
+    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
+    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
+    * All Rights Reserved.
+    * Contributor(s): Openbravo SLU
+    * Contributions are Copyright (C) 2010 Openbravo, S.L.U.
+    *
+    * Specifically, this derivative work is based upon the following Compiere
+    * file and version.
+    *************************************************************************
+    * Synchronize OBUISEL_Selector_Field with AD_Element
+    ************************************************************************/
+        
+BEGIN
+    
+    IF AD_isTriggerEnabled()='N' THEN RETURN;
+    END IF;
+
+    --  synchronize Selector Field
+    IF UPDATING THEN
+        UPDATE OBUISEL_Selector_Field
+            SET Name= :new.Name,
+	            Description=:new.Description,
+                Help=:new.Help
+            WHERE IsCentrallyMaintained = 'Y' and 
+                exists (select 1
+                    from ad_column c
+                    where c.ad_column_id = OBUISEL_Selector_Field.ad_column_id
+                    and c.AD_Element_ID=:new.AD_Element_ID)
+                AND exists (select 1
+                    from ad_module m, ad_module m1
+                    where m.ad_module_id = OBUISEL_Selector_Field.ad_module_id
+                    and m1.ad_module_id = :New.AD_Module_id
+                    and m.ad_language = m1.ad_language);
+                   
+        --Translations for columns in other languages must be managed in ad_element_trl trg
+    END IF;
+
+-- UPDATING
+END OBUISEL_ELEMENT_TRG
+]]></body>
+    </trigger>
+  </database>