Analysis of multi-language conversion development in oaf

Source: Internet
Author: User

This article describes how to develop oaf multi-language conversion.

However, the following questions are also raised:

  1. How does the program know that multi-language conversion is not required?
  2. There are no view objects related to tl tables on the page. How can I import multi-language data?
  3. In oaf development, data needs to be inserted into the database through EO operations. However, according to the development manual, we create EO Based on the VL view, and the compound view cannot insert data, what's going on?
  4. The base table for multi-language conversion does not define EO at all. When does it insert data?

 

With the above questions, let's take a look at the implementation class of the object.OaentityimplHow to Implement the multi-language Conversion Function

 

I. First, let's take a look at the create method of EO.

public void create(AttributeList paramAttributeList)  {    super.create(paramAttributeList);    createRowWho();    createObjectVersionNumber();    if (isTranslatable())      createTranslated(paramAttributeList);  }

 

WhereIstranslatable() To determine whether multi-language conversion is required.Createtranslated() Method. Otherwise, the create method of the parent class is called according to the default creation method.

The istrnaslattable () method isGetbasetablename() Method to determine whether multi-language conversion is required:

 

private String getBaseTableName(){  return ((String)getEntityDef().getProperty("OA_BASE_TABLE"));} 

Getbasetablename () method to get the custom object attributes of an objectOa_base_tableThis attribute is defined on the object of the VL view during development. Therefore, if this attribute is set, it is considered to require multi-language conversion.

 

The above answers my first question:How does the program know how to convert multiple languages?

 

2. Look at the createtranslated () method specially designed for multilingual conversion.

private RowIterator createTranslated(AttributeList paramAttributeList){  RowIterator localRowIterator = getTLEOIterator();  String str = getOADBTransaction().getCurrentLanguage();  String[] arrayOfString2 = getInstalledLanguages();  int j = getTLLanguageAttributeIndex();  int k = getTLSourceLangAttributeIndex();  for (int l = 0; l < arrayOfString2.length; ++l)  {    RowImpl localRowImpl = (RowImpl)localRowIterator.createRow();    localRowImpl.setAttribute(j, arrayOfString2[l]);    localRowImpl.setAttribute(k, str);    localRowIterator.insertRow(localRowImpl);  }  return localRowIterator;}

 

Gettleoiterator() The method returns the EO row set instance corresponding to tl. You can see a for loop in the Code. The loop is based on the currently Installed Language, therefore, when data is inserted into an VL object, records are inserted into the TL table according to the Installed Language.

The answer is as follows:How to insert TL table data and understand why all language environment information can be inserted into TL table at a time.

 

In addition, for how to find the TL object corresponding to the VL object, leave a reader to complete it (in the oatranslatedentitystaticinfo class)

 

But there is no program to insert data into the multi-language base table. Let's continue to browse the code.

 

3. view the builddmlstatement method for generating DML statements

 

protected StringBuffer buildDMLStatement(int paramInt, AttributeDefImpl[] paramArrayOfAttributeDefImpl1, AttributeDefImpl[] paramArrayOfAttributeDefImpl2, AttributeDefImpl[] paramArrayOfAttributeDefImpl3, boolean paramBoolean){  if (!(isTranslatable()))    return super.buildDMLStatement(paramInt, paramArrayOfAttributeDefImpl1, paramArrayOfAttributeDefImpl2, paramArrayOfAttributeDefImpl3, paramBoolean);  StringBuffer localStringBuffer = super.buildDMLStatement(paramInt, trimXlatAttributes(paramArrayOfAttributeDefImpl1), trimXlatAttributes(paramArrayOfAttributeDefImpl2), trimXlatAttributes(paramArrayOfAttributeDefImpl3), paramBoolean);  if (localStringBuffer == null)    return null;  String str = localStringBuffer.toString();  str = OACommonUtils.replace(str, getEntityDef().getSource(), getBaseTableName());  return new StringBuffer(str);} 

 

The most critical sentence is:Oacommonutils. Replace (STR, getentitydef (). getsource (), getbasetablename ());This statement replaces the name getentitydef (). getsource () of the VL view with the name getbasetablename () of the multilingual base table (),

In this way, it seems that the data is inserted into the VL object, but it has been stolen. It does not perform DML operations on the VL view object at all.

In this way, the first question (3) and question (3) have been answered:Why is the data in the view and TL multi-language base table inserted?

 

But careful people will find new problems. In the builddmlstatement method above, can we simply replace the table object in the DML statement?

The answer is no, because the VL database columns and multi-language base tables are different. Based on the column attribute in the VL object, there are more fields in multiple languages than the base table.

 

Iv. How to view multilingual attribute removal trimxlatattributes

 

I noticed from the code that the builddmlstatement method calls the trimxlatattributes () method to process the passed parameters. Let's take a look.Trimxlatattributes() Implementation of methods

private AttributeDefImpl[] trimXlatAttributes(AttributeDefImpl[] paramArrayOfAttributeDefImpl){  if (paramArrayOfAttributeDefImpl == null)    return null;  int i = 0;  for (int j = 0; j < paramArrayOfAttributeDefImpl.length; ++j)    if (!(isTranslatableAttribute(j)))      ++i;  AttributeDefImpl[] arrayOfAttributeDefImpl = new AttributeDefImpl[i];  int k = 0;  for (int l = 0; l < paramArrayOfAttributeDefImpl.length; ++l)    if (!(isTranslatableAttribute(l)))    {      arrayOfAttributeDefImpl[k] = paramArrayOfAttributeDefImpl[l];      ++k;    }  return arrayOfAttributeDefImpl;} 

 

The Code containsIstranslatableattribute() Method to determine whether the corresponding column is a multi-language conversion column. If not, add it to the arrayofattributedefimpl [] array; otherwise, discard it.

In this way, the returned data only includes columns excluding the multilingual attribute. This is the attribute column in the multilingual base table, so the builddmlstatement () above () replace the data table with a multi-language base table.

 

At this point, the main logic of multi-language processing has been explained. In addition, there are a lot of details about the above processing, so I will leave someone interested to study it.

Source: http://oracleseeker.com/tag/oa-framework/page/3/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.