hg merge release-5.1 (merge release5.1 into default)

This commit is contained in:
Carlos Ruiz 2018-01-23 12:01:20 +01:00
commit 16167a62cb
15 changed files with 435 additions and 68 deletions

View File

@ -0,0 +1,43 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3580 Advanced Zoom Across
-- Jan 19, 2018 6:08:19 PM CET
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200113,0,0,TO_DATE('2018-01-19 18:08:19','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-01-19 18:08:19','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZOOM_ACROSS_QUERY_TIMEOUT','5','Timeout in seconds for the count queries ran when pushing the button Zoom Across','D','C','a1f85478-e2d8-4c78-98ab-283f74e090ec')
;
-- Jan 19, 2018 6:10:52 PM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203157,0,0,'Y',TO_DATE('2018-01-19 18:09:06','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 18:09:06','YYYY-MM-DD HH24:MI:SS'),100,'IsDetailedZoomAcross','Detailed Zoom Across',NULL,'The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.','Detailed Zoom Across','D','58745104-ed8b-459c-aed8-6a9d9c4e33a1')
;
-- Jan 19, 2018 6:11:25 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213339,0,'Detailed Zoom Across','The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.',200174,'IsDetailedZoomAcross','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_DATE('2018-01-19 18:11:24','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 18:11:24','YYYY-MM-DD HH24:MI:SS'),100,203157,'Y','N','D','N','N','N','Y','c2e13243-17fa-45f4-9135-4fb4d1572664','Y',0,'N','N')
;
-- Jan 19, 2018 6:11:30 PM CET
ALTER TABLE AD_UserPreference ADD IsDetailedZoomAcross CHAR(1) DEFAULT 'N' CHECK (IsDetailedZoomAcross IN ('Y','N'))
;
-- Jan 19, 2018 6:11:39 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205303,'Detailed Zoom Across','The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.',200189,213339,'Y',1,90,'N','N','N','N',0,0,'Y',TO_DATE('2018-01-19 18:11:39','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 18:11:39','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','6c0b384b-f05e-4843-8b0e-eb15e2ee81d2','Y',90,2,2)
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203797
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205303
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203800
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=2, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203798
;
SELECT register_migration_script('201801191815_IDEMPIERE-3580.sql') FROM dual
;

View File

@ -0,0 +1,35 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-1906 Use postgresql SIMILAR TO instead of LIKE
-- Jan 19, 2018 10:55:51 PM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203158,0,0,'Y',TO_DATE('2018-01-19 22:54:41','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 22:54:41','YYYY-MM-DD HH24:MI:SS'),100,'IsUseSimilarTo','Use Similar To',NULL,'In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.','Use Similar To','D','6917772a-f465-411c-95ed-8a834249a578')
;
-- Jan 19, 2018 10:56:06 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213340,0,'Use Similar To','In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.',200174,'IsUseSimilarTo','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_DATE('2018-01-19 22:56:06','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 22:56:06','YYYY-MM-DD HH24:MI:SS'),100,203158,'Y','N','D','N','N','N','Y','81564050-9da4-492f-b298-cf8aac897583','Y',0,'N','N')
;
-- Jan 19, 2018 10:56:07 PM CET
ALTER TABLE AD_UserPreference ADD IsUseSimilarTo CHAR(1) DEFAULT 'N' CHECK (IsUseSimilarTo IN ('Y','N'))
;
-- Jan 19, 2018 10:56:20 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205304,'Use Similar To','In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.',200189,213340,'Y',1,100,'N','N','N','N',0,0,'Y',TO_DATE('2018-01-19 22:56:20','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2018-01-19 22:56:20','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','92dd69a0-5640-41d9-b26f-2546a71eb75b','Y',100,2,2)
;
-- Jan 19, 2018 10:56:41 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 22:56:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205304
;
-- Jan 19, 2018 10:56:41 PM CET
UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 22:56:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203798
;
-- Jan 19, 2018 10:59:21 PM CET
UPDATE AD_Field SET DisplayLogic='@#DBType@=PostgreSQL', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2018-01-19 22:59:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205304
;
SELECT register_migration_script('201801192257_IDEMPIERE-1906.sql') FROM dual
;

View File

@ -0,0 +1,40 @@
-- IDEMPIERE-3580 Advanced Zoom Across
-- Jan 19, 2018 6:08:19 PM CET
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200113,0,0,TO_TIMESTAMP('2018-01-19 18:08:19','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-01-19 18:08:19','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZOOM_ACROSS_QUERY_TIMEOUT','5','Timeout in seconds for the count queries ran when pushing the button Zoom Across','D','C','a1f85478-e2d8-4c78-98ab-283f74e090ec')
;
-- Jan 19, 2018 6:10:52 PM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203157,0,0,'Y',TO_TIMESTAMP('2018-01-19 18:09:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 18:09:06','YYYY-MM-DD HH24:MI:SS'),100,'IsDetailedZoomAcross','Detailed Zoom Across',NULL,'The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.','Detailed Zoom Across','D','58745104-ed8b-459c-aed8-6a9d9c4e33a1')
;
-- Jan 19, 2018 6:11:25 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213339,0,'Detailed Zoom Across','The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.',200174,'IsDetailedZoomAcross','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2018-01-19 18:11:24','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 18:11:24','YYYY-MM-DD HH24:MI:SS'),100,203157,'Y','N','D','N','N','N','Y','c2e13243-17fa-45f4-9135-4fb4d1572664','Y',0,'N','N')
;
-- Jan 19, 2018 6:11:30 PM CET
ALTER TABLE AD_UserPreference ADD COLUMN IsDetailedZoomAcross CHAR(1) DEFAULT 'N' CHECK (IsDetailedZoomAcross IN ('Y','N'))
;
-- Jan 19, 2018 6:11:39 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205303,'Detailed Zoom Across','The toolbar button zoom across discover where the record on screen is used on first tabs of windows. With detailed zoom across it goes deeper in the discovery of relationships within detailed tabs.',200189,213339,'Y',1,90,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-01-19 18:11:39','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 18:11:39','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','6c0b384b-f05e-4843-8b0e-eb15e2ee81d2','Y',90,2,2)
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203797
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205303
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203800
;
-- Jan 19, 2018 6:13:19 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=2, ColumnSpan=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 18:13:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203798
;
SELECT register_migration_script('201801191815_IDEMPIERE-3580.sql') FROM dual
;

View File

@ -0,0 +1,32 @@
-- IDEMPIERE-1906 Use postgresql SIMILAR TO instead of LIKE
-- Jan 19, 2018 10:55:51 PM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203158,0,0,'Y',TO_TIMESTAMP('2018-01-19 22:54:41','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 22:54:41','YYYY-MM-DD HH24:MI:SS'),100,'IsUseSimilarTo','Use Similar To',NULL,'In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.','Use Similar To','D','6917772a-f465-411c-95ed-8a834249a578')
;
-- Jan 19, 2018 10:56:06 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213340,0,'Use Similar To','In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.',200174,'IsUseSimilarTo','N',1,'N','N','N','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2018-01-19 22:56:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 22:56:06','YYYY-MM-DD HH24:MI:SS'),100,203158,'Y','N','D','N','N','N','Y','81564050-9da4-492f-b298-cf8aac897583','Y',0,'N','N')
;
-- Jan 19, 2018 10:56:07 PM CET
ALTER TABLE AD_UserPreference ADD COLUMN IsUseSimilarTo CHAR(1) DEFAULT 'N' CHECK (IsUseSimilarTo IN ('Y','N'))
;
-- Jan 19, 2018 10:56:20 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205304,'Use Similar To','In PostgreSQL database enable using the more powerful SIMILAR TO instead of LIKE for matching queries.',200189,213340,'Y',1,100,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2018-01-19 22:56:20','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2018-01-19 22:56:20','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','92dd69a0-5640-41d9-b26f-2546a71eb75b','Y',100,2,2)
;
-- Jan 19, 2018 10:56:41 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=5, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 22:56:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205304
;
-- Jan 19, 2018 10:56:41 PM CET
UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 22:56:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203798
;
-- Jan 19, 2018 10:59:21 PM CET
UPDATE AD_Field SET DisplayLogic='@#DBType@=PostgreSQL', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2018-01-19 22:59:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=205304
;
SELECT register_migration_script('201801192257_IDEMPIERE-1906.sql') FROM dual
;

View File

@ -17,16 +17,23 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTab;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
/**
* Generic provider of zoom targets. Contains pieces of {@link org.compiere.apps.AZoomAcross}
@ -37,32 +44,69 @@ import org.compiere.util.Env;
*/
public class GenericZoomProvider implements IZoomProvider {
private static final CLogger logger = CLogger
.getCLogger(GenericZoomProvider.class);
private static final CLogger logger = CLogger.getCLogger(GenericZoomProvider.class);
private Map<String, Integer> queries;
public List<ZoomInfoFactory.ZoomInfo> retrieveZoomInfos(PO po) {
// User preference
boolean detailedZoom = "Y".equals(Env.getContext(Env.getCtx(), "P|IsDetailedZoomAcross"));
String sql = "SELECT DISTINCT ws.AD_Window_ID, ws.Name, wp.AD_Window_ID, wp.Name, t.TableName, tts.AD_Tab_ID, ttp.AD_Tab_ID "
+ "FROM AD_Table t ";
StringBuilder sqlb = new StringBuilder().append(
"SELECT w.AD_Window_ID, w.Name, tt.Name, f.Name, t.TableName, c.ColumnName, tt.AD_Tab_ID, ");
boolean baseLanguage = Env.isBaseLanguage(Env.getCtx(), "AD_Window");
if (baseLanguage)
sql += "JOIN AD_Window ws ON (t.AD_Window_ID=ws.AD_Window_ID AND ws.IsActive='Y')"
+ " LEFT OUTER JOIN AD_Window wp ON (t.PO_Window_ID=wp.AD_Window_ID AND wp.IsActive='Y') ";
else
sql += "JOIN AD_Window_Trl ws ON (t.AD_Window_ID=ws.AD_Window_ID AND ws.AD_Language=?)"
+ " LEFT OUTER JOIN AD_Window_Trl wp ON (t.PO_Window_ID=wp.AD_Window_ID AND wp.AD_Language=?) "
+ " JOIN AD_Window wso ON (t.AD_Window_ID=wso.AD_Window_ID AND wso.IsActive='Y')"
+ " LEFT OUTER JOIN AD_Window wpo ON (t.PO_Window_ID=wpo.AD_Window_ID AND wpo.IsActive='Y') ";
// WARNING - HardCoded: first tab must have SeqNo = 10
sql += "JOIN AD_Tab tts ON (tts.AD_Window_ID=ws.AD_Window_ID AND tts.AD_Table_ID=t.AD_Table_ID AND tts.SeqNo=10)" // first tab so
+" LEFT OUTER JOIN AD_Tab ttp ON (ttp.AD_Window_ID=wp.AD_Window_ID AND ttp.AD_Table_ID=t.AD_Table_ID AND ttp.SeqNo=10)" // first tab po
+" WHERE t.TableName NOT LIKE 'I%'" // No Import
+ " AND t.AD_Table_ID IN "
+ "(SELECT AD_Table_ID FROM AD_Column "
+ "WHERE ColumnName=? AND IsKey='N' AND IsParent='N' AND IsActive='Y' AND ColumnSQL IS NULL) " // #x
+ "ORDER BY 2";
String tabAlias;
if (baseLanguage) {
tabAlias = "tt";
} else {
tabAlias = "tt0";
}
String justFirstTab = "";
if (! detailedZoom) {
justFirstTab = " AND " + tabAlias + ".SeqNo=10 ";
}
if (baseLanguage) {
sqlb.append(
"tt.SeqNo "
+ "FROM AD_Table t "
+ "JOIN AD_Tab tt ON (tt.AD_Table_ID=t.AD_Table_ID AND tt.IsActive='Y' AND tt.Name NOT LIKE 'Used in%' AND tt.IsReadOnly='N' AND tt.IsSortTab='N'")
.append(justFirstTab)
.append(") "
+ "JOIN AD_Window w ON (tt.AD_Window_ID=w.AD_Window_ID AND w.IsActive='Y') "
+ "JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsActive='Y' AND c.IsKey='N' AND c.IsParent='N' AND c.ColumnSQL IS NULL) "
+ "JOIN AD_Field f ON (f.AD_Column_ID=c.AD_Column_ID AND f.AD_Tab_ID=tt.AD_Tab_ID AND f.IsActive='Y' AND f.IsDisplayed='Y') ");
} else {
sqlb.append(
"tt0.SeqNo "
+ "FROM AD_Table t "
+ "JOIN AD_Tab tt0 ON (tt0.AD_Table_ID=t.AD_Table_ID AND tt0.IsActive='Y' AND tt0.Name NOT LIKE 'Used in%' AND tt0.IsReadOnly='N' AND tt0.IsSortTab='N'")
.append(justFirstTab)
.append(") "
+ "JOIN AD_Tab_Trl tt ON (tt.AD_Tab_ID=tt0.AD_Tab_ID AND tt.AD_Language=?) "
+ "JOIN AD_Window w0 ON (tt0.AD_Window_ID=w0.AD_Window_ID AND w0.IsActive='Y') "
+ "JOIN AD_Window_Trl w ON (w.AD_Window_ID=w0.AD_Window_ID AND w.AD_Language=?) "
+ "JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsActive='Y' AND c.IsKey='N' AND c.IsParent='N' AND c.ColumnSQL IS NULL) "
+ "JOIN AD_Field f0 ON (f0.AD_Column_ID=c.AD_Column_ID AND f0.AD_Tab_ID=tt0.AD_Tab_ID AND f0.IsActive='Y' AND f0.IsDisplayed='Y') "
+ "JOIN AD_Field_Trl f ON (f.AD_Field_ID=f0.AD_Field_ID AND f.AD_Language=?) ");
}
sqlb.append(
"LEFT JOIN AD_Ref_Table r ON (c.AD_Reference_Value_ID=r.AD_Reference_ID) "
+ "LEFT JOIN AD_Table tr ON (r.AD_Table_ID=tr.AD_Table_ID) "
+ "WHERE t.IsActive='Y' "
+ " AND t.TableName NOT LIKE 'I|_%' ESCAPE '|' " // not import tables
+ " AND t.TableName NOT LIKE 'T|_%' ESCAPE '|' " // not temp tables
+ " AND t.IsView='N' "); // not views
if (detailedZoom) {
sqlb.append(
" AND ( ( c.ColumnName=? AND c.AD_Reference_ID=19) "
+ " OR ( c.ColumnName=? AND c.AD_Reference_ID=30 AND c.AD_Reference_Value_ID IS NULL ) "
+ " OR ( c.AD_Reference_ID IN (18, 30) AND c.AD_Reference_Value_ID=r.AD_Reference_ID AND tr.TableName=? ) ) ");
} else {
sqlb.append(" AND c.ColumnName=? ");
}
sqlb.append(" ORDER BY 2, 8");
final PreparedStatement pstmt = DB.prepareStatement(sql, null);
final PreparedStatement pstmt = DB.prepareStatement(sqlb.toString(), null);
ResultSet rs = null;
try {
@ -70,64 +114,149 @@ public class GenericZoomProvider implements IZoomProvider {
if (!baseLanguage) {
pstmt.setString(index++, Env.getAD_Language(Env.getCtx()));
pstmt.setString(index++, Env.getAD_Language(Env.getCtx()));
pstmt.setString(index++, Env.getAD_Language(Env.getCtx()));
}
pstmt.setString(index++, po.get_KeyColumns()[0]);
if (detailedZoom) {
pstmt.setString(index++, po.get_KeyColumns()[0]);
pstmt.setString(index++, po.get_TableName());
}
pstmt.setString(index++, po.get_TableName() + "_ID");
rs = pstmt.executeQuery();
final List<ZoomInfoFactory.ZoomInfo> result = new ArrayList<ZoomInfoFactory.ZoomInfo>();
queries = new HashMap<String, Integer>();
while (rs.next()) {
int AD_Window_ID = rs.getInt(1);
String Name = rs.getString(2);
int PO_Window_ID = rs.getInt(3);
int AD_Tab_ID = rs.getInt(6);
int PO_Tab_ID = rs.getInt(7);
String winName = rs.getString(2);
String tabName = rs.getString(3);
String fldName = rs.getString(4);
String targetTableName = rs.getString(5);
String targetColumnName = rs.getString(6);
int AD_Tab_ID = rs.getInt(7);
final MQuery query = evaluateQuery(targetTableName,
AD_Tab_ID, Name, po);
result.add(new ZoomInfoFactory.ZoomInfo(AD_Window_ID,
query, Name));
if (PO_Window_ID != 0 && PO_Tab_ID != 0) {
Name = rs.getString(4);
final MQuery querypo = evaluateQuery(targetTableName,
PO_Tab_ID, Name, po);
result.add(new ZoomInfoFactory.ZoomInfo(PO_Window_ID,
querypo, Name));
Boolean access = MRole.getDefault().getWindowAccess(AD_Window_ID);
if (access == null)
continue;
final MQuery query = evaluateQuery(targetTableName, targetColumnName, AD_Tab_ID, po);
if (query != null && query.getRecordCount() > 0) {
if (detailedZoom) {
result.add(new ZoomInfoFactory.ZoomInfo(AD_Window_ID, query, winName + " / " + tabName + " / " + fldName));
} else {
result.add(new ZoomInfoFactory.ZoomInfo(AD_Window_ID, query, winName));
}
}
}
queries = null;
return result;
} catch (SQLException e) {
logger.log(Level.SEVERE, sql, e);
logger.log(Level.SEVERE, sqlb.toString(), e);
throw new AdempiereException(e);
} finally {
DB.close(rs, pstmt);
}
}
private static MQuery evaluateQuery(String targetTableName,
int AD_Tab_ID, String Name, final PO po) {
private MQuery evaluateQuery(String targetTableName, String targetColumnName, int AD_Tab_ID, final PO po) {
Properties ctx = Env.getCtx();
int clientID = Env.getAD_Client_ID(ctx);
MTab tab = new MTab(Env.getCtx(), AD_Tab_ID, null);
final MQuery query = new MQuery();
MTable table = MTable.get(ctx, targetTableName);
if (table.getColumnIndex("AD_Client_ID") < 0) // table doesn't have AD_Client_ID
return null;
query.addRestriction(po.get_TableName() + "_ID=" + po.get_ID());
if (tab.getWhereClause() != null && tab.getWhereClause().length() > 0)
query.addRestriction("(" + tab.getWhereClause() + ")");
int tabIDLoop = AD_Tab_ID;
int levelUp = 0;
while (true) {
MTab tab = new MTab(ctx, tabIDLoop, null);
String whereCtx = tab.getWhereClause();
if (!Util.isEmpty(whereCtx, true)) {
if (whereCtx.indexOf("@") != -1)
whereCtx = Env.parseVariable(whereCtx, po, null, true);
if (whereCtx.indexOf("@") != -1) // could not parse - probably window context variable in where tab
return null;
if (levelUp == 0) {
query.addRestriction("(" + whereCtx + ")");
} else if (levelUp == 1) {
MTable parentTable = MTable.get(ctx, tab.getAD_Table_ID());
String parentTableName = parentTable.getTableName();
StringBuilder subquery = new StringBuilder()
.append(parentTableName)
.append("_ID IN (SELECT ")
.append(parentTableName)
.append("_ID FROM ")
.append(parentTableName)
.append(" WHERE ")
.append(whereCtx)
.append(")");
query.addRestriction("(" + subquery + ")");
} else {
// Cannot add where beyond the first parent - need to implement recursion
return null;
}
}
levelUp++;
tabIDLoop = tab.getParentTabID();
if (tabIDLoop < 0)
break;
}
query.addRestriction(targetColumnName + "=" + po.get_ID());
query.setZoomTableName(targetTableName);
query.setZoomColumnName(po.get_KeyColumns()[0]);
query.setZoomColumnName(targetColumnName);
query.setZoomValue(po.get_ID());
query.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
String sql = "SELECT COUNT(*) FROM " + targetTableName + " WHERE "
+ Env.parseVariable(query.getWhereClause(false), po, null, false);
int count = DB.getSQLValue(null, sql);
String accessLevel = table.getAccessLevel();
if ( clientID != 0
&& MTable.ACCESSLEVEL_SystemOnly.equals(accessLevel)) {
return null;
}
if ( clientID != 0
&& ( MTable.ACCESSLEVEL_All.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemPlusClient.equals(accessLevel))) {
query.addRestriction("AD_Client_ID IN (0, " + clientID + ")");
} else {
query.addRestriction("AD_Client_ID=" + clientID);
}
StringBuilder sqlb = new StringBuilder("SELECT COUNT(*) FROM ")
.append(targetTableName)
.append(" WHERE ")
.append(query.getWhereClause(true));
String sql = sqlb.toString();
int count = -1;
if (queries.containsKey(sql)) {
count = queries.get(sql);
} else {
int timeout = MSysConfig.getIntValue("ZOOM_ACROSS_QUERY_TIMEOUT", 5, Env.getAD_Client_ID(Env.getCtx())); // default 5 seconds
count = getSQLValueTimeout(null, sql, timeout);
queries.put(sql, count);
}
query.setRecordCount(count);
return query;
}
private int getSQLValueTimeout(Object object, String sql, int timeOut) {
int retValue = -1;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
if (timeOut > 0)
pstmt.setQueryTimeout(timeOut);
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
} catch (SQLException e) {
logger.warning(e.getMessage() + " -> " + sql);
} finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return retValue;
}
}

View File

@ -30,11 +30,11 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import org.adempiere.base.ILookupFactory;
@ -2561,7 +2561,7 @@ public class GridField
return m_lookupEditorSettingValue;
}
private final Map<String, SQLLogicResult> sqlLogicCache = new HashMap<>();
private static final Map<String, SQLLogicResult> sqlLogicCache = new ConcurrentHashMap<>();
private class SQLLogicResult {
long timestamp;

View File

@ -155,6 +155,15 @@ public interface I_AD_UserPreference
*/
public boolean isActive();
/** Column name IsDetailedZoomAcross */
public static final String COLUMNNAME_IsDetailedZoomAcross = "IsDetailedZoomAcross";
/** Set Detailed Zoom Across */
public void setIsDetailedZoomAcross (boolean IsDetailedZoomAcross);
/** Get Detailed Zoom Across */
public boolean isDetailedZoomAcross();
/** Column name ToggleOnDoubleClick */
public static final String COLUMNNAME_ToggleOnDoubleClick = "ToggleOnDoubleClick";

View File

@ -679,7 +679,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
whereClauseFinal += whereClause;
List<MInvoiceLine> list = new Query(getCtx(), I_C_InvoiceLine.Table_Name, whereClauseFinal, get_TrxName())
.setParameters(getC_Invoice_ID())
.setOrderBy(I_C_InvoiceLine.COLUMNNAME_Line)
.setOrderBy("Line, C_InvoiceLine_ID")
.list();
return list.toArray(new MInvoiceLine[list.size()]);
} // getLines
@ -1778,7 +1778,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
payment.setC_Invoice_ID(getC_Invoice_ID());
payment.setC_Currency_ID(getC_Currency_ID());
payment.setC_DocType_ID(doctype.getC_DocType_ID());
payment.setPayAmt(getGrandTotal());
if (isCreditMemo())
payment.setPayAmt(getGrandTotal().negate());
else
payment.setPayAmt(getGrandTotal());
payment.setIsPrepayment(false);
payment.setDateAcct(getDateAcct());
payment.setDateTrx(getDateInvoiced());
@ -2447,17 +2450,23 @@ public class MInvoice extends X_C_Invoice implements DocAction
reversal.setReversal(true);
// Reverse Line Qty
MInvoiceLine[] oLines = getLines(false);
MInvoiceLine[] rLines = reversal.getLines(true);
for (int i = 0; i < rLines.length; i++)
{
MInvoiceLine rLine = rLines[i];
rLine.setQtyEntered(rLine.getQtyEntered().negate());
rLine.setQtyInvoiced(rLine.getQtyInvoiced().negate());
rLine.setLineNetAmt(rLine.getLineNetAmt().negate());
if (rLine.getTaxAmt() != null && rLine.getTaxAmt().compareTo(Env.ZERO) != 0)
rLine.setTaxAmt(rLine.getTaxAmt().negate());
if (rLine.getLineTotalAmt() != null && rLine.getLineTotalAmt().compareTo(Env.ZERO) != 0)
rLine.setLineTotalAmt(rLine.getLineTotalAmt().negate());
rLine.getParent().setReversal(true);
MInvoiceLine oLine = oLines[i];
rLine.setQtyEntered(oLine.getQtyEntered().negate());
rLine.setQtyInvoiced(oLine.getQtyInvoiced().negate());
rLine.setLineNetAmt(oLine.getLineNetAmt().negate());
rLine.setTaxAmt(oLine.getTaxAmt().negate());
rLine.setLineTotalAmt(oLine.getLineTotalAmt().negate());
rLine.setPriceActual(oLine.getPriceActual());
rLine.setPriceList(oLine.getPriceList());
rLine.setPriceLimit(oLine.getPriceLimit());
rLine.setPriceEntered(oLine.getPriceEntered());
rLine.setC_UOM_ID(oLine.getC_UOM_ID());
if (!rLine.save(get_TrxName()))
{
m_processMsg = "Could not correct Invoice Reversal Line";

View File

@ -842,12 +842,16 @@ public class MInvoiceLine extends X_C_InvoiceLine
protected boolean beforeSave (boolean newRecord)
{
if (log.isLoggable(Level.FINE)) log.fine("New=" + newRecord);
if (newRecord && getParent().isComplete()) {
boolean parentComplete = getParent().isComplete();
boolean isReversal = getParent().isReversal();
if (newRecord && parentComplete) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_InvoiceLine"));
return false;
}
// Re-set invoice header (need to update m_IsSOTrx flag) - phib [ 1686773 ]
setInvoice(getParent());
if (!parentComplete && !isReversal) { // do not change things when parent is complete
// Charge
if (getC_Charge_ID() != 0)
{
@ -916,6 +920,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
return false;
}
}
}
return true;
} // beforeSave

View File

@ -38,11 +38,10 @@ import org.compiere.util.DB;
*/
public class MTab extends X_AD_Tab
{
/**
*
*/
private static final long serialVersionUID = 4946144044358216142L;
private static final long serialVersionUID = -2964171360368660043L;
/**
* Standard Constructor
@ -208,5 +207,24 @@ public class MTab extends X_AD_Tab
return retValue;
}
//end vpj-cd e-evolution
public int getParentTabID() {
int parentTabID = -1;
if (getTabLevel() == 0)
return parentTabID; // tab level 0 doesn't have parent
final String sql = ""
+ "SELECT AD_Tab_ID "
+ "FROM AD_Tab "
+ "WHERE AD_Window_ID = ? "
+ " AND SeqNo < ? "
+ " AND TabLevel = ? "
+ " AND IsActive = 'Y' "
+ "ORDER BY SeqNo DESC";
parentTabID = DB.getSQLValue(get_TrxName(), sql, getAD_Window_ID(), getSeqNo(), getTabLevel()-1);
return parentTabID;
}
} // M_Tab

View File

@ -189,7 +189,9 @@ public class MZoomCondition extends X_AD_ZoomCondition
{
window.initTab(gTab.getTabNo());
GridTab parentTab = gTab.getParentTab();
int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
int parentId = -1;
if (!Util.isEmpty(gTab.getLinkColumnName()))
parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
if (parentId <= 0) {
if (Util.isEmpty(parentTab.getKeyColumnName()))
parentTab.initTab(false);

View File

@ -29,7 +29,7 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
/**
*
*/
private static final long serialVersionUID = 20171031L;
private static final long serialVersionUID = 20180119L;
/** Standard Constructor */
public X_AD_UserPreference (Properties ctx, int AD_UserPreference_ID, String trxName)
@ -194,6 +194,27 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
return false;
}
/** Set Detailed Zoom Across.
@param IsDetailedZoomAcross Detailed Zoom Across */
public void setIsDetailedZoomAcross (boolean IsDetailedZoomAcross)
{
set_Value (COLUMNNAME_IsDetailedZoomAcross, Boolean.valueOf(IsDetailedZoomAcross));
}
/** Get Detailed Zoom Across.
@return Detailed Zoom Across */
public boolean isDetailedZoomAcross ()
{
Object oo = get_Value(COLUMNNAME_IsDetailedZoomAcross);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Toggle on Double Click.
@param ToggleOnDoubleClick
Defines if double click in a field on grid mode switch to form view

View File

@ -50,6 +50,7 @@ import org.compiere.model.MTable;
import org.compiere.model.MUser;
import org.compiere.model.MUserPreference;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.compiere.util.Msg;
@ -273,6 +274,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
BrowserToken.save(mSession, user);
Env.setContext(ctx, "#UIClient", "zk");
Env.setContext(ctx, "#DBType", DB.getDatabase().getName());
StringBuilder localHttpAddr = new StringBuilder(Executions.getCurrent().getScheme());
localHttpAddr.append("://").append(Executions.getCurrent().getLocalAddr());
int port = Executions.getCurrent().getLocalPort();

View File

@ -937,6 +937,7 @@ public class ADSortTab extends Panel implements IADTabpanel
}
public void refresh() {
createUI();
loadData();
}

View File

@ -24,6 +24,7 @@ import java.util.regex.Pattern;
import org.compiere.db.DB_PostgreSQL;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Util;
/**
@ -35,7 +36,7 @@ import org.compiere.util.Util;
*/
public class Convert_PostgreSQL extends Convert_SQL92 {
/**
* Cosntructor
* Constructor
*/
public Convert_PostgreSQL() {
m_map = ConvertMap_PostgreSQL.getConvertMap();
@ -79,6 +80,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
String statement = replaceQuotedStrings(sqlStatement, retVars);
statement = convertWithConvertMap(statement);
statement = convertSimilarTo(statement);
statement = statement.replace(DB_PostgreSQL.NATIVE_MARKER, "");
String cmpString = statement.toUpperCase();
@ -122,6 +124,25 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
return result;
} // convertStatement
private String convertSimilarTo(String statement) {
String retValue = statement;
boolean useSimilarTo = "Y".equals(Env.getContext(Env.getCtx(), "P|IsUseSimilarTo"));
if (useSimilarTo) {
String regex = "\\bLIKE\\b";
String replacement = "SIMILAR TO";
try {
Pattern p = Pattern.compile(regex, REGEX_FLAGS);
Matcher m = p.matcher(retValue);
retValue = m.replaceAll(replacement);
} catch (Exception e) {
String error = "Error expression: " + regex + " - " + e;
log.info(error);
m_conversionError = error;
}
}
return retValue;
}
@Override
protected String escapeQuotedString(String in)
{