modules/org.openbravo.userinterface.selector/src-db/database/model/functions/OBUISEL_SYNCHRONIZE.xml
author Harpreet Singh <harpreet@openbravo.com>
Fri, 10 Dec 2010 19:47:45 +0100
changeset 9076 c4f1a5c7d7c2
child 15457 42ab557adad4
permissions -rw-r--r--
Added 3.0 modules to modules dir and changed the VERSION number
harpreet@9076
     1
<?xml version="1.0"?>
harpreet@9076
     2
  <database name="FUNCTION OBUISEL_SYNCHRONIZE">
harpreet@9076
     3
    <function name="OBUISEL_SYNCHRONIZE" type="NULL">
harpreet@9076
     4
      <parameter name="ep_instance_id" type="VARCHAR" mode="in">
harpreet@9076
     5
        <default/>
harpreet@9076
     6
      </parameter>
harpreet@9076
     7
      <body><![CDATA[/************************************************************************* 
harpreet@9076
     8
  * The contents of this file are subject to the Compiere Public 
harpreet@9076
     9
  * License 1.1 ("License"); You may not use this file except in 
harpreet@9076
    10
  * compliance with the License. You may obtain a copy of the License in 
harpreet@9076
    11
  * the legal folder of your Openbravo installation. 
harpreet@9076
    12
  * Software distributed under the License is distributed on an 
harpreet@9076
    13
  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 
harpreet@9076
    14
  * implied See the License for the specific language governing rights 
harpreet@9076
    15
  * and limitations under the License. 
harpreet@9076
    16
  * The Original Code is  Compiere  ERP &  Business Solution 
harpreet@9076
    17
  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc. 
harpreet@9076
    18
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, 
harpreet@9076
    19
  * parts created by ComPiere are Copyright (C) ComPiere, Inc.; 
harpreet@9076
    20
  * All Rights Reserved. 
harpreet@9076
    21
  * Contributor(s): Openbravo SLU 
harpreet@9076
    22
  * Contributions are Copyright (C) 2010 Openbravo, S.L.U. 
harpreet@9076
    23
  * 
harpreet@9076
    24
  * Specifically, this derivative work is based upon the following Compiere 
harpreet@9076
    25
  * file and version. 
harpreet@9076
    26
  ************************************************************************* 
harpreet@9076
    27
  * $Id: AD_Syncronize.sql,v 1.12 2003/07/26 04:29:44 jjanke Exp $ 
harpreet@9076
    28
  *** 
harpreet@9076
    29
  * Title: Syncronize Application Dictionary for Selector Field 
harpreet@9076
    30
  ************************************************************************/
harpreet@9076
    31
  v_TemplateInDev CHAR(1); 
harpreet@9076
    32
  v_rowcount NUMBER; 
harpreet@9076
    33
  
harpreet@9076
    34
  BEGIN 
harpreet@9076
    35
  
harpreet@9076
    36
    SELECT count(*) 
harpreet@9076
    37
      INTO v_rowcount 
harpreet@9076
    38
      FROM AD_MODULE 
harpreet@9076
    39
    WHERE TYPE = 'T'
harpreet@9076
    40
       AND ISINDEVELOPMENT = 'Y'; 
harpreet@9076
    41
       
harpreet@9076
    42
    IF v_rowcount = '0' THEN 
harpreet@9076
    43
      v_TemplateInDev:='N'; 
harpreet@9076
    44
    ELSE 
harpreet@9076
    45
      v_TemplateInDev:='Y'; 
harpreet@9076
    46
    END IF; 
harpreet@9076
    47
    
harpreet@9076
    48
    -- synchronize field 
harpreet@9076
    49
    UPDATE OBUISEL_SELECTOR_FIELD 
harpreet@9076
    50
      SET NAME= COALESCE((SELECT COALESCE(T.NAME, e.NAME) 
harpreet@9076
    51
        FROM AD_COLUMN c, 
harpreet@9076
    52
             AD_MODULE M, 
harpreet@9076
    53
             AD_ELEMENT e, AD_ELEMENT_TRL T 
harpreet@9076
    54
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
    55
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
    56
          AND E.AD_ELEMENT_ID = T.AD_ELEMENT_ID  
harpreet@9076
    57
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
    58
          AND T.AD_LANGUAGE = M.AD_LANGUAGE),
harpreet@9076
    59
      (SELECT e.NAME 
harpreet@9076
    60
        FROM AD_COLUMN c, 
harpreet@9076
    61
             AD_MODULE M, AD_MODULE M2, 
harpreet@9076
    62
             AD_ELEMENT e 
harpreet@9076
    63
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
    64
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
    65
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
    66
          AND E.AD_MODULE_ID = M2.AD_MODULE_ID 
harpreet@9076
    67
          AND M2.AD_LANGUAGE = M.AD_LANGUAGE)), 
harpreet@9076
    68
      Description=
harpreet@9076
    69
        COALESCE((SELECT COALESCE(T.Description, e.Description) 
harpreet@9076
    70
        FROM AD_COLUMN c, 
harpreet@9076
    71
             AD_MODULE M, 
harpreet@9076
    72
             AD_ELEMENT e, AD_ELEMENT_TRL T 
harpreet@9076
    73
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
    74
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
    75
          AND E.AD_ELEMENT_ID = T.AD_ELEMENT_ID  
harpreet@9076
    76
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
    77
          AND T.AD_LANGUAGE = M.AD_LANGUAGE) 
harpreet@9076
    78
          ,
harpreet@9076
    79
      (SELECT e.Description 
harpreet@9076
    80
        FROM AD_COLUMN c, 
harpreet@9076
    81
             AD_MODULE M, AD_MODULE M2, 
harpreet@9076
    82
             AD_ELEMENT e 
harpreet@9076
    83
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
    84
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
    85
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
    86
          AND E.AD_MODULE_ID = M2.AD_MODULE_ID 
harpreet@9076
    87
          AND M2.AD_LANGUAGE = M.AD_LANGUAGE)), 
harpreet@9076
    88
      Help=
harpreet@9076
    89
        COALESCE((SELECT COALESCE(T.HELP, e.HELP) 
harpreet@9076
    90
        FROM AD_COLUMN c, 
harpreet@9076
    91
             AD_MODULE M, 
harpreet@9076
    92
             AD_ELEMENT e, AD_ELEMENT_TRL T 
harpreet@9076
    93
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
    94
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
    95
          AND E.AD_ELEMENT_ID = T.AD_ELEMENT_ID  
harpreet@9076
    96
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
    97
          AND T.AD_LANGUAGE = M.AD_LANGUAGE), 
harpreet@9076
    98
      (SELECT e.HELP 
harpreet@9076
    99
        FROM AD_COLUMN c, 
harpreet@9076
   100
             AD_MODULE M, AD_MODULE M2, 
harpreet@9076
   101
             AD_ELEMENT e 
harpreet@9076
   102
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
   103
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
   104
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
   105
          AND E.AD_MODULE_ID = M2.AD_MODULE_ID 
harpreet@9076
   106
          AND M2.AD_LANGUAGE = M.AD_LANGUAGE)), 
harpreet@9076
   107
      Updated=now() 
harpreet@9076
   108
    WHERE OBUISEL_SELECTOR_FIELD.IsCentrallyMaintained='Y' 
harpreet@9076
   109
      AND OBUISEL_SELECTOR_FIELD.IsActive='Y'  
harpreet@9076
   110
      AND EXISTS 
harpreet@9076
   111
        (SELECT 1 
harpreet@9076
   112
        FROM AD_COLUMN c, 
harpreet@9076
   113
             AD_MODULE M, 
harpreet@9076
   114
             AD_ELEMENT e, AD_ELEMENT_TRL T 
harpreet@9076
   115
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
   116
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID 
harpreet@9076
   117
          AND E.AD_ELEMENT_ID = T.AD_ELEMENT_ID  
harpreet@9076
   118
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID 
harpreet@9076
   119
          AND (M.ISINDEVELOPMENT='Y' OR v_TemplateInDev ='Y') 
harpreet@9076
   120
          AND T.AD_LANGUAGE = M.AD_LANGUAGE 
harpreet@9076
   121
          AND (OBUISEL_SELECTOR_FIELD.NAME != COALESCE(T.NAME, e.NAME) 
harpreet@9076
   122
             OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD.Description), ' ')<>COALESCE(TO_CHAR(T.Description), TO_CHAR(e.Description), ' ')
harpreet@9076
   123
             OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD.Help), ' ')<>COALESCE(TO_CHAR(T.Help), TO_CHAR(e.Help), ' '))
harpreet@9076
   124
          union
harpreet@9076
   125
      SELECT 1
harpreet@9076
   126
        FROM AD_COLUMN c,
harpreet@9076
   127
             AD_MODULE M, AD_MODULE M2,
harpreet@9076
   128
             AD_ELEMENT e
harpreet@9076
   129
        WHERE e.AD_Element_ID=c.AD_Element_ID 
harpreet@9076
   130
          AND c.AD_Column_ID=OBUISEL_SELECTOR_FIELD.AD_Column_ID
harpreet@9076
   131
          AND OBUISEL_SELECTOR_FIELD.AD_MODULE_ID = M.AD_MODULE_ID
harpreet@9076
   132
          AND (M.ISINDEVELOPMENT='Y' OR v_TemplateInDev ='Y')
harpreet@9076
   133
          AND E.AD_MODULE_ID = M2.AD_MODULE_ID
harpreet@9076
   134
          AND M2.AD_LANGUAGE = M.AD_LANGUAGE
harpreet@9076
   135
          AND (OBUISEL_SELECTOR_FIELD.NAME != e.NAME
harpreet@9076
   136
             OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
harpreet@9076
   137
             OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' ')));
harpreet@9076
   138
 
harpreet@9076
   139
    DBMS_OUTPUT.PUT_LINE('Synchronize Field Translations') ;
harpreet@9076
   140
    UPDATE OBUISEL_SELECTOR_FIELD_TRL
harpreet@9076
   141
      SET NAME=
harpreet@9076
   142
      (SELECT e.NAME
harpreet@9076
   143
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f, AD_LANGUAGE L
harpreet@9076
   144
      WHERE L.AD_LANGUAGE = e.AD_LANGUAGE AND L.AD_LANGUAGE_ID=OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID AND e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   145
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   146
      )
harpreet@9076
   147
      , Description=
harpreet@9076
   148
      (SELECT e.Description
harpreet@9076
   149
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f, AD_LANGUAGE L
harpreet@9076
   150
      WHERE L.AD_LANGUAGE = e.AD_LANGUAGE AND L.AD_LANGUAGE_ID=OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID AND e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   151
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   152
      )
harpreet@9076
   153
      , Help=
harpreet@9076
   154
      (SELECT e.Help
harpreet@9076
   155
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f, AD_LANGUAGE L
harpreet@9076
   156
      WHERE L.AD_LANGUAGE = e.AD_LANGUAGE AND L.AD_LANGUAGE_ID=OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID AND e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   157
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   158
      )
harpreet@9076
   159
      , IsTranslated=
harpreet@9076
   160
      (SELECT e.IsTranslated
harpreet@9076
   161
      FROM AD_ELEMENT_TRL e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f, AD_LANGUAGE L
harpreet@9076
   162
      WHERE L.AD_LANGUAGE = e.AD_LANGUAGE AND L.AD_LANGUAGE_ID=OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID AND e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   163
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   164
      )
harpreet@9076
   165
      , Updated=now()
harpreet@9076
   166
    WHERE EXISTS
harpreet@9076
   167
      (SELECT 1
harpreet@9076
   168
      FROM OBUISEL_SELECTOR_FIELD f, AD_ELEMENT_TRL e, AD_COLUMN c, AD_MODULE M, AD_LANGUAGE L
harpreet@9076
   169
      WHERE OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID=f.OBUISEL_SELECTOR_FIELD_ID  
harpreet@9076
   170
      AND f.AD_Column_ID=c.AD_Column_ID
harpreet@9076
   171
      AND c.AD_Element_ID=e.AD_Element_ID 
harpreet@9076
   172
      AND c.AD_Process_ID IS NULL
harpreet@9076
   173
      AND L.AD_LANGUAGE = e.AD_LANGUAGE
harpreet@9076
   174
      AND OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID=L.AD_LANGUAGE_ID
harpreet@9076
   175
      AND f.IsCentrallyMaintained='Y' 
harpreet@9076
   176
      AND f.IsActive='Y'
harpreet@9076
   177
      AND M.AD_MODULE_ID = F.AD_MODULE_ID
harpreet@9076
   178
      AND (M.ISINDEVELOPMENT='Y' OR v_TemplateInDev ='Y')
harpreet@9076
   179
      AND M.AD_LANGUAGE != E.AD_LANGUAGE
harpreet@9076
   180
      AND(OBUISEL_SELECTOR_FIELD_TRL.NAME<>e.NAME OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD_TRL.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
harpreet@9076
   181
      OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD_TRL.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' ')));
harpreet@9076
   182
    
harpreet@9076
   183
     -- Field Translations
harpreet@9076
   184
    -- Translations taken from the non trl table
harpreet@9076
   185
    UPDATE OBUISEL_SELECTOR_FIELD_TRL
harpreet@9076
   186
      SET NAME=
harpreet@9076
   187
      (SELECT e.NAME
harpreet@9076
   188
      FROM AD_ELEMENT e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f
harpreet@9076
   189
      WHERE e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   190
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   191
      )
harpreet@9076
   192
      , Description=
harpreet@9076
   193
      (SELECT e.Description
harpreet@9076
   194
      FROM AD_ELEMENT e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f
harpreet@9076
   195
      WHERE e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   196
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   197
      )
harpreet@9076
   198
      , Help=
harpreet@9076
   199
      (SELECT e.Help
harpreet@9076
   200
      FROM AD_ELEMENT e, AD_COLUMN c, OBUISEL_SELECTOR_FIELD f
harpreet@9076
   201
      WHERE  e.AD_Element_ID=c.AD_Element_ID
harpreet@9076
   202
      AND c.AD_Column_ID=f.AD_Column_ID AND f.OBUISEL_SELECTOR_FIELD_ID=OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID
harpreet@9076
   203
      )
harpreet@9076
   204
      , IsTranslated='Y'
harpreet@9076
   205
      , Updated=now()
harpreet@9076
   206
    WHERE EXISTS
harpreet@9076
   207
      (SELECT 1
harpreet@9076
   208
      FROM OBUISEL_SELECTOR_FIELD f, AD_ELEMENT e, AD_COLUMN c, AD_MODULE M, AD_MODULE M1, AD_LANGUAGE L
harpreet@9076
   209
      WHERE OBUISEL_SELECTOR_FIELD_TRL.OBUISEL_SELECTOR_FIELD_ID=f.OBUISEL_SELECTOR_FIELD_ID  
harpreet@9076
   210
      AND f.AD_Column_ID=c.AD_Column_ID
harpreet@9076
   211
      AND c.AD_Element_ID=e.AD_Element_ID 
harpreet@9076
   212
      AND c.AD_Process_ID IS NULL
harpreet@9076
   213
      AND L.AD_LANGUAGE = M1.AD_LANGUAGE
harpreet@9076
   214
      AND OBUISEL_SELECTOR_FIELD_TRL.AD_LANGUAGE_ID=L.AD_LANGUAGE_ID  
harpreet@9076
   215
      AND f.IsCentrallyMaintained='Y' 
harpreet@9076
   216
      AND f.IsActive='Y'
harpreet@9076
   217
      AND M.AD_MODULE_ID = F.AD_MODULE_ID
harpreet@9076
   218
      AND (M.ISINDEVELOPMENT='Y' OR v_TemplateInDev ='Y')
harpreet@9076
   219
      AND M1.AD_MODULE_ID = E.AD_MODULE_ID
harpreet@9076
   220
      AND M.AD_LANGUAGE != M1.AD_LANGUAGE
harpreet@9076
   221
      AND(OBUISEL_SELECTOR_FIELD_TRL.NAME<>e.NAME OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD_TRL.Description), ' ')<>COALESCE(TO_CHAR(e.Description), ' ')
harpreet@9076
   222
      OR COALESCE(TO_CHAR(OBUISEL_SELECTOR_FIELD_TRL.Help), ' ')<>COALESCE(TO_CHAR(e.Help), ' ')));    
harpreet@9076
   223
END OBUISEL_SYNCHRONIZE
harpreet@9076
   224
]]></body>
harpreet@9076
   225
    </function>
harpreet@9076
   226
  </database>