modules/org.openbravo.client.application/src-db/database/model/functions/OBUIAPP_LANGUAGE_CREATE.xml
author Inigo Sanchez <inigo.sanchez@openbravo.com>
Fri, 23 Oct 2015 10:45:30 +0200
changeset 27808 04c472ffcb50
parent 10780 bcc1e52f9ea9
permissions -rw-r--r--
Related to issue 30986:Code review improvements.

The problem was when creating new language code has been included in AD_LANGUAGE_CREATE
which is in core, being insertions for a table in client.application module, the code
managing them should be within that module (OBUIAPP_LANGUAGE_CREATE) where parameters
are also handled.

Now it has been resolved the problem by moving the code to the correct function
(OBUIAPP_LANGUAGE_CREATE).
<?xml version="1.0"?>
  <database name="FUNCTION OBUIAPP_LANGUAGE_CREATE">
    <function name="OBUIAPP_LANGUAGE_CREATE" type="NULL">
      <parameter name="ep_instance_id" type="VARCHAR" mode="in">
        <default/>
      </parameter>
      <body><![CDATA[/*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* 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 Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2010-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************/

  v_rowcount NUMBER;

  BEGIN
    INSERT INTO OBUIAPP_Parameter_Trl  
           (OBUIAPP_PARAMETER_TRL_ID, AD_CLIENT_ID, AD_ORG_ID               ,                                             
            ISACTIVE                , CREATED     , CREATEDBY               ,                                             
            UPDATED                 , UPDATEDBY   , OBUIAPP_PARAMETER_ID    ,                                             
            NAME                    , DESCRIPTION , HELP                    ,                                             
            ISTRANSLATED            , AD_LANGUAGE)
     SELECT get_uuid()              , p.AD_CLIENT_ID, p.AD_ORG_ID           ,                                             
            p.ISACTIVE              , now()     , '0'                       ,                                             
            now()                   , '0'       , p.OBUIAPP_PARAMETER_ID    ,                                             
            p.NAME                  , p.DESCRIPTION , p.HELP                ,                                             
            'N'                     , l.AD_LANGUAGE
       FROM OBUIAPP_Parameter p, AD_Language l, AD_Module m
      WHERE l.isActive = 'Y'
        AND l.IsSystemLanguage='Y'
        AND m.AD_Module_ID = p.AD_Module_ID
        AND M.AD_Language != l.AD_Language
        AND NOT EXISTS (SELECT 1
                          FROM OBUIAPP_Parameter_Trl t
                         WHERE t.OBUIAPP_Parameter_ID = p.OBUIAPP_Parameter_ID
                           AND t.AD_Language = l.AD_Language);

    v_rowcount:=SQL%ROWCOUNT;
    DBMS_OUTPUT.PUT_LINE('- OBUIAPP_LANGUAGE_CREATE: OBUIAPP_Parameter_Trl ' || v_rowcount);
    -- Process Definition
    INSERT
    INTO OBUIAPP_Process_Trl
      (
        OBUIAPP_Process_Trl_ID, OBUIAPP_Process_ID, AD_Language, Name, Description,
        Help, IsTranslated, Createdby, UpdatedBy,
        AD_Client_ID, AD_Org_ID
      )
    SELECT get_uuid(), OBUIAPP_Process_ID, AD_Language.AD_Language, OBUIAPP_Process.Name, OBUIAPP_Process.Description, OBUIAPP_Process.Help, 'N', '0', '0', '0', '0'
    FROM OBUIAPP_Process, AD_Language, AD_Module M
    WHERE AD_Language.IsActive='Y'  
    AND AD_Language.IsSystemLanguage='Y'  
    AND M.AD_MODULE_ID = OBUIAPP_Process.AD_MODULE_ID
    AND M.AD_LANGUAGE != AD_Language.AD_Language
    AND NOT EXISTS (SELECT 1 FROM OBUIAPP_Process_trl
                 WHERE OBUIAPP_Process_ID = OBUIAPP_Process.OBUIAPP_Process_ID
                   AND AD_LANGUAGE = AD_Language.AD_Language);

    v_rowcount:=SQL%ROWCOUNT;
    DBMS_OUTPUT.PUT_LINE('- OBUIAPP_Process ' || v_rowcount) ;
END OBUIAPP_LANGUAGE_CREATE
]]></body>
    </function>
  </database>