diff --git a/migration/i6.1/oracle/201808021530_IDEMPIERE-3770.sql b/migration/i6.1/oracle/201808021530_IDEMPIERE-3770.sql new file mode 100644 index 0000000000..64e28e1857 --- /dev/null +++ b/migration/i6.1/oracle/201808021530_IDEMPIERE-3770.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3770: Translation : export only centralized data +-- Aug 2, 2018 3:36:33 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Only centralized data',0,0,'Y',TO_DATE('2018-08-02 15:36:32','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-08-02 15:36:32','YYYY-MM-DD HH24:MI:SS'),0,200481,'OnlyCentralizedData','D','f43c0cce-0462-4247-baf6-e7da842152ab') +; + +SELECT register_migration_script('201808021530_IDEMPIERE-3770.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i6.1/postgresql/201808021530_IDEMPIERE-3770.sql b/migration/i6.1/postgresql/201808021530_IDEMPIERE-3770.sql new file mode 100644 index 0000000000..9ab00fe7c6 --- /dev/null +++ b/migration/i6.1/postgresql/201808021530_IDEMPIERE-3770.sql @@ -0,0 +1,7 @@ +-- IDEMPIERE-3770: Translation : export only centralized data +-- Aug 2, 2018 3:36:33 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Only centralized data',0,0,'Y',TO_TIMESTAMP('2018-08-02 15:36:32','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-08-02 15:36:32','YYYY-MM-DD HH24:MI:SS'),0,200481,'OnlyCentralizedData','D','f43c0cce-0462-4247-baf6-e7da842152ab') +; + +SELECT register_migration_script('201808021530_IDEMPIERE-3770.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/install/Translation.java b/org.adempiere.base/src/org/compiere/install/Translation.java index 3bd02e9bdd..b0a0a6f410 100644 --- a/org.adempiere.base/src/org/compiere/install/Translation.java +++ b/org.adempiere.base/src/org/compiere/install/Translation.java @@ -173,7 +173,7 @@ public class Translation implements IApplication * @param Trl_Table translation table _Trl * @return status message */ - public String exportTrl (String directory, int AD_Client_ID, String AD_Language, String Trl_Table) + public String exportTrl (String directory, int AD_Client_ID, String AD_Language, String Trl_Table, boolean onlyCentralized) { String fileName = directory + File.separator + Trl_Table + "_" + AD_Language + ".xml"; log.info(fileName); @@ -185,6 +185,12 @@ public class Translation implements IApplication String Base_Table = Trl_Table.substring(0, pos); if (isBaseLanguage) tableName = Base_Table; + + if (onlyCentralized) { + if (MTable.get(m_ctx, tableName).getAD_Table_ID() > MTable.MAX_OFFICIAL_ID) + return ""; + } + String keyColumn = Base_Table + "_ID"; String uuidColumn = MTable.getUUIDColumnName(Base_Table); String[] trlColumns = getTrlColumns (Base_Table); @@ -237,6 +243,10 @@ public class Translation implements IApplication } if (AD_Client_ID >= 0) sql.append(haveWhere ? " AND " : " WHERE ").append("o.AD_Client_ID=").append(AD_Client_ID); + + if (onlyCentralized) + sql.append(haveWhere ? " AND " : " WHERE ").append(" o.").append(keyColumn).append("<=").append(MTable.MAX_OFFICIAL_ID).append(" AND o.IsActive = 'Y'"); + sql.append(" ORDER BY t.").append(keyColumn); // pstmt = DB.prepareStatement(sql.toString(), null); @@ -500,7 +510,7 @@ public class Translation implements IApplication System.out.println("Cannot create directory " + directory + " to export the language to it."); System.exit(1); } - exportTrl(directory, -1, AD_Language, table); + exportTrl(directory, -1, AD_Language, table, true); } else System.out.println("Just import and export are supported as modes."); } diff --git a/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java b/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java index 5539688d1f..7ea92cd2a5 100644 --- a/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java @@ -36,6 +36,7 @@ import org.compiere.apps.ADialog; import org.compiere.apps.StatusBar; import org.compiere.apps.form.FormFrame; import org.compiere.apps.form.FormPanel; +import org.compiere.grid.ed.VCheckBox; import org.compiere.swing.CPanel; import org.compiere.util.CLogger; import org.compiere.util.Env; @@ -80,6 +81,7 @@ public class VTranslationDialog extends TranslationController private StatusBar statusBar = new StatusBar(); private JLabel lClient = new JLabel(); private JComboBox cbClient = new JComboBox(); + private VCheckBox isOnlyCentralized = new VCheckBox(); /** @@ -93,6 +95,7 @@ public class VTranslationDialog extends TranslationController lLanguage.setText(Msg.translate(Env.getCtx(), "AD_Language")); lLanguage.setToolTipText(Msg.translate(Env.getCtx(), "IsSystemLanguage")); lTable.setText(Msg.translate(Env.getCtx(), "AD_Table_ID")); + isOnlyCentralized.setText(Msg.getMsg(Env.getCtx(), "OnlyCentralizedData")); // bExport.setText(Msg.getMsg(Env.getCtx(), "Export")); bExport.addActionListener(this); @@ -107,9 +110,11 @@ public class VTranslationDialog extends TranslationController ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); panel.add(cbTable, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(bExport, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 + panel.add(isOnlyCentralized, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 + ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); + panel.add(bExport, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(bImport, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 + panel.add(bImport, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); panel.add(lClient, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); @@ -224,7 +229,7 @@ public class VTranslationDialog extends TranslationController AD_Table = (ValueNamePair)cbTable.getItemAt(i); msg = imp ? t.importTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()) - : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()); + : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue(), isOnlyCentralized.isSelected()); } if(msg == null || msg.length() == 0) @@ -237,7 +242,7 @@ public class VTranslationDialog extends TranslationController msg = null; msg = imp ? t.importTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()) - : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()); + : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue(), isOnlyCentralized.isSelected()); if(msg == null || msg.length() == 0) msg = (imp ? "Import" : "Export") + " Successful. [" + directory + "]"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/install/WTranslationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/install/WTranslationDialog.java index c90009f84f..0c35c9c78f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/install/WTranslationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/install/WTranslationDialog.java @@ -29,6 +29,7 @@ import org.adempiere.exceptions.AdempiereException; import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Checkbox; import org.adempiere.webui.component.FolderBrowser; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.GridFactory; @@ -119,6 +120,7 @@ public class WTranslationDialog extends TranslationController implements IFormCo private int m_AD_Client_ID; private boolean m_imp; private ValueNamePair m_AD_Language; + private Checkbox isOnlyCentralized = new Checkbox(); private void zkInit() throws Exception { @@ -139,6 +141,8 @@ public class WTranslationDialog extends TranslationController implements IFormCo bImportZIP.setLabel(Msg.getMsg(Env.getCtx(), "ImportZIP")); bImportZIP.setUpload(AdempiereWebUI.getUploadSetting()); bImportZIP.addEventListener(Events.ON_UPLOAD, this); + isOnlyCentralized.setLabel(Msg.getMsg(Env.getCtx(), "OnlyCentralizedData")); + isOnlyCentralized.setChecked(true); Rows rows = centerLayout.newRows(); Row row = rows.newRow(); @@ -152,7 +156,11 @@ public class WTranslationDialog extends TranslationController implements IFormCo row = rows.newRow(); row.appendChild(lTable.rightAlign()); row.appendChild(cbTable); - + + row = rows.newRow(); + row.appendChild(new Label("")); + row.appendChild(isOnlyCentralized); + row = rows.newRow(); Div div = new Div(); div.setStyle("text-align: right;"); @@ -298,7 +306,7 @@ public class WTranslationDialog extends TranslationController implements IFormCo // Carlos Ruiz - globalqss - improve output message from translation import process msg.append(m_AD_Table.getValue()).append(" ").append((m_imp ? t.importTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue()) - : t.exportTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue()))).append(" "); + : t.exportTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue(), isOnlyCentralized.isChecked()))).append(" "); } if(msg == null || msg.length() == 0) @@ -311,7 +319,7 @@ public class WTranslationDialog extends TranslationController implements IFormCo msg = null; msg = new StringBuilder(m_imp ? t.importTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue()) - : t.exportTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue())); + : t.exportTrl (directory, m_AD_Client_ID, m_AD_Language.getValue(), m_AD_Table.getValue(), isOnlyCentralized.isChecked())); if(msg == null || msg.length() == 0) msg = new StringBuilder(m_imp ? "Import" : "Export").append(" Successful. [").append(directory).append("]");