IDEMPIERE-2675: Adding custom table support in Tree

This commit is contained in:
Deepak Pansheriya 2015-08-05 19:24:00 +05:30
parent b493a2567d
commit a1702112f1
5 changed files with 189 additions and 3 deletions

View File

@ -0,0 +1,58 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jun 18, 2015 10:47:07 AM IST
INSERT INTO AD_Column (SeqNoSelection,AD_Column_ID,IsAlwaysUpdateable,IsSyncDatabase,AD_Client_ID,AD_Org_ID,CreatedBy,Updated,UpdatedBy,EntityType,IsSecure,IsEncrypted,IsParent,IsMandatory,IsIdentifier,SeqNo,Help,Version,FieldLength,IsKey,IsTranslated,Created,IsUpdateable,IsAutocomplete,IsAllowLogging,IsAllowCopy,Description,ColumnName,Name,IsSelectionColumn,AD_Column_UU,IsActive,IsToolbarButton,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,212212,'N','N',0,0,100,TO_DATE('2015-06-18 10:47:06','YYYY-MM-DD HH24:MI:SS'),100,'D','N','N','N','N','N',0,'The Database Table provides the information of the table definition',0,10,'N','N',TO_DATE('2015-06-18 10:47:06','YYYY-MM-DD HH24:MI:SS'),'Y','N','Y','Y','Database Table information','AD_Table_ID','Table','N','cd639a6d-243f-4737-80b7-e953534cafa6','Y','N','N',126,19,288)
;
-- Jun 18, 2015 10:47:12 AM IST
UPDATE AD_Column SET FKConstraintType='N', FKConstraintName='ADTable_ADTree',Updated=TO_DATE('2015-06-18 10:47:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212212
;
-- Jun 18, 2015 10:47:12 AM IST
ALTER TABLE AD_Tree ADD AD_Table_ID NUMBER(10) DEFAULT NULL
;
-- Jun 18, 2015 10:47:12 AM IST
ALTER TABLE AD_Tree ADD CONSTRAINT ADTable_ADTree FOREIGN KEY (AD_Table_ID) REFERENCES ad_table(ad_table_id) DEFERRABLE INITIALLY DEFERRED
;
-- Jun 18, 2015 10:47:46 AM IST
INSERT INTO AD_Ref_List (AD_Ref_List_ID,CreatedBy,UpdatedBy,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,Description,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200310,100,100,TO_DATE('2015-06-18 10:47:45','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2015-06-18 10:47:45','YYYY-MM-DD HH24:MI:SS'),'D',0,0,'Custom Table','TL','Custom Table','Y','e3104c45-9a71-4ea1-bd24-9125d33f07db',120)
;
-- Jun 18, 2015 10:48:11 AM IST
INSERT INTO AD_Field (ColumnSpan,AD_Field_ID,AD_Client_ID,CreatedBy,AD_Org_ID,Updated,UpdatedBy,IsHeading,IsDisplayed,IsFieldOnly,IsSameLine,IsDisplayedGrid,SeqNo,IsReadOnly,IsCentrallyMaintained,Created,EntityType,Name,IsEncrypted,DisplayLength,AD_Field_UU,IsActive,AD_Column_ID,AD_Tab_ID) VALUES (2,203825,0,100,0,TO_DATE('2015-06-18 10:48:05','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N','N','N',100,'N','Y',TO_DATE('2015-06-18 10:48:05','YYYY-MM-DD HH24:MI:SS'),'D','AD_Tree_UU','N',36,'13075486-eba0-4882-8270-9205a2440b6f','Y',60514,243)
;
-- Jun 18, 2015 10:48:11 AM IST
INSERT INTO AD_Field (ColumnSpan,AD_Field_ID,AD_Client_ID,CreatedBy,AD_Org_ID,Updated,UpdatedBy,IsHeading,Help,IsDisplayed,IsFieldOnly,IsSameLine,SeqNo,IsReadOnly,IsCentrallyMaintained,Created,EntityType,Name,Description,IsEncrypted,DisplayLength,AD_Field_UU,IsActive,AD_Column_ID,AD_Tab_ID) VALUES (2,203826,0,100,0,TO_DATE('2015-06-18 10:48:11','YYYY-MM-DD HH24:MI:SS'),100,'N','The Database Table provides the information of the table definition','Y','N','N',110,'N','Y',TO_DATE('2015-06-18 10:48:11','YYYY-MM-DD HH24:MI:SS'),'D','Table','Database Table information','N',10,'f7ca6a1b-4a96-48fe-938e-6784af276493','Y',212212,243)
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=203825
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=203826
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=5228
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=12421
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=8371
;
-- Jun 18, 2015 10:49:23 AM IST
UPDATE AD_Field SET DisplayLogic='@TreeType@=''TL''',Updated=TO_DATE('2015-06-18 10:49:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203826
;
SELECT register_migration_script('201506241206_IDEMPIERE-2675.sql') FROM dual
;

View File

@ -0,0 +1,56 @@
-- Jun 18, 2015 10:47:07 AM IST
INSERT INTO AD_Column (SeqNoSelection,AD_Column_ID,IsAlwaysUpdateable,IsSyncDatabase,AD_Client_ID,AD_Org_ID,CreatedBy,Updated,UpdatedBy,EntityType,IsSecure,IsEncrypted,IsParent,IsMandatory,IsIdentifier,SeqNo,Help,Version,FieldLength,IsKey,IsTranslated,Created,IsUpdateable,IsAutocomplete,IsAllowLogging,IsAllowCopy,Description,ColumnName,Name,IsSelectionColumn,AD_Column_UU,IsActive,IsToolbarButton,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,212212,'N','N',0,0,100,TO_TIMESTAMP('2015-06-18 10:47:06','YYYY-MM-DD HH24:MI:SS'),100,'D','N','N','N','N','N',0,'The Database Table provides the information of the table definition',0,10,'N','N',TO_TIMESTAMP('2015-06-18 10:47:06','YYYY-MM-DD HH24:MI:SS'),'Y','N','Y','Y','Database Table information','AD_Table_ID','Table','N','cd639a6d-243f-4737-80b7-e953534cafa6','Y','N','N',126,19,288)
;
-- Jun 18, 2015 10:47:12 AM IST
UPDATE AD_Column SET FKConstraintType='N', FKConstraintName='ADTable_ADTree',Updated=TO_TIMESTAMP('2015-06-18 10:47:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212212
;
-- Jun 18, 2015 10:47:12 AM IST
ALTER TABLE AD_Tree ADD COLUMN AD_Table_ID NUMERIC(10) DEFAULT NULL
;
-- Jun 18, 2015 10:47:12 AM IST
ALTER TABLE AD_Tree ADD CONSTRAINT ADTable_ADTree FOREIGN KEY (AD_Table_ID) REFERENCES ad_table(ad_table_id) DEFERRABLE INITIALLY DEFERRED
;
-- Jun 18, 2015 10:47:46 AM IST
INSERT INTO AD_Ref_List (AD_Ref_List_ID,CreatedBy,UpdatedBy,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,Description,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200310,100,100,TO_TIMESTAMP('2015-06-18 10:47:45','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2015-06-18 10:47:45','YYYY-MM-DD HH24:MI:SS'),'D',0,0,'Custom Table','TL','Custom Table','Y','e3104c45-9a71-4ea1-bd24-9125d33f07db',120)
;
-- Jun 18, 2015 10:48:11 AM IST
INSERT INTO AD_Field (ColumnSpan,AD_Field_ID,AD_Client_ID,CreatedBy,AD_Org_ID,Updated,UpdatedBy,IsHeading,IsDisplayed,IsFieldOnly,IsSameLine,IsDisplayedGrid,SeqNo,IsReadOnly,IsCentrallyMaintained,Created,EntityType,Name,IsEncrypted,DisplayLength,AD_Field_UU,IsActive,AD_Column_ID,AD_Tab_ID) VALUES (2,203825,0,100,0,TO_TIMESTAMP('2015-06-18 10:48:05','YYYY-MM-DD HH24:MI:SS'),100,'N','N','N','N','N',100,'N','Y',TO_TIMESTAMP('2015-06-18 10:48:05','YYYY-MM-DD HH24:MI:SS'),'D','AD_Tree_UU','N',36,'13075486-eba0-4882-8270-9205a2440b6f','Y',60514,243)
;
-- Jun 18, 2015 10:48:11 AM IST
INSERT INTO AD_Field (ColumnSpan,AD_Field_ID,AD_Client_ID,CreatedBy,AD_Org_ID,Updated,UpdatedBy,IsHeading,Help,IsDisplayed,IsFieldOnly,IsSameLine,SeqNo,IsReadOnly,IsCentrallyMaintained,Created,EntityType,Name,Description,IsEncrypted,DisplayLength,AD_Field_UU,IsActive,AD_Column_ID,AD_Tab_ID) VALUES (2,203826,0,100,0,TO_TIMESTAMP('2015-06-18 10:48:11','YYYY-MM-DD HH24:MI:SS'),100,'N','The Database Table provides the information of the table definition','Y','N','N',110,'N','Y',TO_TIMESTAMP('2015-06-18 10:48:11','YYYY-MM-DD HH24:MI:SS'),'D','Table','Database Table information','N',10,'f7ca6a1b-4a96-48fe-938e-6784af276493','Y',212212,243)
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=203825
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=203826
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=5228
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=12421
;
-- Jun 18, 2015 10:48:40 AM IST
UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=8371
;
-- Jun 18, 2015 10:49:23 AM IST
UPDATE AD_Field SET DisplayLogic='@TreeType@=''TL''',Updated=TO_TIMESTAMP('2015-06-18 10:49:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203826
;
SELECT register_migration_script('201506241206_IDEMPIERE-2675.sql') FROM dual
;

View File

@ -62,6 +62,21 @@ public interface I_AD_Tree
*/ */
public int getAD_Org_ID(); public int getAD_Org_ID();
/** Column name AD_Table_ID */
public static final String COLUMNNAME_AD_Table_ID = "AD_Table_ID";
/** Set Table.
* Database Table information
*/
public void setAD_Table_ID (int AD_Table_ID);
/** Get Table.
* Database Table information
*/
public int getAD_Table_ID();
public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException;
/** Column name AD_Tree_ID */ /** Column name AD_Tree_ID */
public static final String COLUMNNAME_AD_Tree_ID = "AD_Tree_ID"; public static final String COLUMNNAME_AD_Tree_ID = "AD_Tree_ID";

View File

@ -159,6 +159,14 @@ public class MTree extends MTree_Base
TreeType = TREETYPE_CMTemplate; TreeType = TREETYPE_CMTemplate;
else else
{ {
String tableName = keyColumnName.substring(0, keyColumnName.length() - 3);
String query = "SELECT tr.AD_Tree_ID FROM AD_Tree tr inner join AD_Table t on (tr.AD_Table_ID=t.AD_Table_ID) WHERE tr.AD_Client_ID=? AND tr.TreeType='"
+ TREETYPE_Table
+ " ' AND tr.IsActive='Y' AND tr.IsAllNodes='Y' AND t.TableName = ?";
int treeID = DB.getSQLValue(null, query, Env.getAD_Client_ID(Env.getCtx()),tableName);
if (treeID != -1)
return treeID;
s_log.log(Level.SEVERE, "Could not map " + keyColumnName); s_log.log(Level.SEVERE, "Could not map " + keyColumnName);
return 0; return 0;
} }
@ -219,6 +227,11 @@ public class MTree extends MTree_Base
else // IDEMPIERE 329 - nmicoud else // IDEMPIERE 329 - nmicoud
{ {
String sourceTableName = getSourceTableName(getTreeType()); String sourceTableName = getSourceTableName(getTreeType());
if (sourceTableName == null)
{
if (getAD_Table_ID() > 0)
sourceTableName = MTable.getTableName(getCtx(), getAD_Table_ID());
}
sql = new StringBuffer("SELECT " sql = new StringBuffer("SELECT "
+ "tn.Node_ID,tn.Parent_ID,tn.SeqNo,st.IsActive " + "tn.Node_ID,tn.Parent_ID,tn.SeqNo,st.IsActive "
+ "FROM ").append(sourceTableName).append(" st " + "FROM ").append(sourceTableName).append(" st "
@ -449,13 +462,27 @@ public class MTree extends MTree_Base
sqlNode.append("f.JSPURL"); sqlNode.append("f.JSPURL");
sqlNode.append(" IS NOT NULL))"); sqlNode.append(" IS NOT NULL))");
} }
} else if (isTreeDrivenByValue()) { }else if(getAD_Table_ID() != 0) {
String tableName =MTable.getTableName(getCtx(), getAD_Table_ID());
sqlNode.append("SELECT t.").append(tableName)
.append("_ID,");
if (isTreeDrivenByValue())
sqlNode.append("t.Value || ' - ' || t.Name,");
else
sqlNode.append("t.Name,");
sqlNode.append("t.Description,t.IsSummary,").append(color)
.append(" FROM ").append(tableName).append(" t ");
if (!m_editable)
sqlNode.append(" WHERE t.IsActive='Y'");
} else if (isTreeDrivenByValue()) {
sqlNode.append("SELECT t.").append(columnNameX) sqlNode.append("SELECT t.").append(columnNameX)
.append("_ID, t.Value || ' - ' || t.Name, t.Description, t.IsSummary,").append(color) .append("_ID, t.Value || ' - ' || t.Name, t.Description, t.IsSummary,").append(color)
.append(" FROM ").append(fromClause); .append(" FROM ").append(fromClause);
if (!m_editable) if (!m_editable)
sqlNode.append(" WHERE t.IsActive='Y'"); sqlNode.append(" WHERE t.IsActive='Y'");
} else { }
else {
if (columnNameX == null) if (columnNameX == null)
throw new IllegalArgumentException("Unknown TreeType=" + getTreeType()); throw new IllegalArgumentException("Unknown TreeType=" + getTreeType());
sqlNode.append("SELECT t.").append(columnNameX) sqlNode.append("SELECT t.").append(columnNameX)

View File

@ -30,7 +30,7 @@ public class X_AD_Tree extends PO implements I_AD_Tree, I_Persistent
/** /**
* *
*/ */
private static final long serialVersionUID = 20150111L; private static final long serialVersionUID = 20150618L;
/** Standard Constructor */ /** Standard Constructor */
public X_AD_Tree (Properties ctx, int AD_Tree_ID, String trxName) public X_AD_Tree (Properties ctx, int AD_Tree_ID, String trxName)
@ -77,6 +77,34 @@ public class X_AD_Tree extends PO implements I_AD_Tree, I_Persistent
return sb.toString(); return sb.toString();
} }
public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException
{
return (org.compiere.model.I_AD_Table)MTable.get(getCtx(), org.compiere.model.I_AD_Table.Table_Name)
.getPO(getAD_Table_ID(), get_TrxName()); }
/** Set Table.
@param AD_Table_ID
Database Table information
*/
public void setAD_Table_ID (int AD_Table_ID)
{
if (AD_Table_ID < 1)
set_Value (COLUMNNAME_AD_Table_ID, null);
else
set_Value (COLUMNNAME_AD_Table_ID, Integer.valueOf(AD_Table_ID));
}
/** Get Table.
@return Database Table information
*/
public int getAD_Table_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Table_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Tree. /** Set Tree.
@param AD_Tree_ID @param AD_Tree_ID
Identifies a Tree Identifies a Tree
@ -286,6 +314,8 @@ public class X_AD_Tree extends PO implements I_AD_Tree, I_Persistent
public static final String TREETYPE_CMTemplate = "CT"; public static final String TREETYPE_CMTemplate = "CT";
/** CM Media = CM */ /** CM Media = CM */
public static final String TREETYPE_CMMedia = "CM"; public static final String TREETYPE_CMMedia = "CM";
/** Table = TL */
public static final String TREETYPE_Table = "TL";
/** Set Type | Area. /** Set Type | Area.
@param TreeType @param TreeType
Element this tree is built on (i.e Product, Business Partner) Element this tree is built on (i.e Product, Business Partner)