Menu

#112 Delete hard code to set a Column, Tab , Window

z_don't_use_3.2.0
closed
3
2008-06-14
2007-05-03
No

Hi everybody

I need add 3 mthos in MColumn , MTab , MWindow to delete hard code in libero, I set here the patch.

What do you think, can vote to add into trunk?

MColumn

//begin vpj-cd e-evolution
/**
* get Column ID
* @param String columnName
* @return int retValue
*/
public static int getColumn_ID(String columnName) {
int retValue = 0;
String SQL = "SELECT AD_Column_ID FROM AD_Column WHERE columnname = ?";
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, columnName);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
retValue = -1;
}
return retValue;
}
//end vpj-cd e-evolution

MTab:

// begin e-evolution vpj-cd
/**
* get Tab ID
* @param String AD_Window_ID
* @param String TabName
* @return int retValue
*/
public static int getTab_ID(int AD_Window_ID , String TabName) {
int retValue = 0;
String SQL = "SELECT AD_Tab_ID FROM AD_Tab WHERE AD_Window_ID= ? AND Name = ?";
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, AD_Window_ID);
pstmt.setString(2, TabName);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
retValue = -1;
}
return retValue;
}
//end vpj-cd e-evolution

MWindow:

//vpj-cd begin e-evolution
/**
* get Window ID
* @param String windowName
* @return int retValue
*/
public static int getWindow_ID(String windowName) {
int retValue = 0;
String SQL = "SELECT AD_Window_ID FROM AD_Window WHERE Name = ?";
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, windowName);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
retValue = -1;
}
return retValue;
}
//end vpj-cd e-evolution

kind regards
Victor Perez

Discussion

  • Victor Perez Juarez

    Logged In: YES
    user_id=332830
    Originator: YES

    File Added: MColumn.patch

     
  • Victor Perez Juarez

     
  • Victor Perez Juarez

    Logged In: YES
    user_id=332830
    Originator: YES

    File Added: MTab.patch

     
  • Victor Perez Juarez

    MTab

     
  • Victor Perez Juarez

    MWindow

     
  • Victor Perez Juarez

    Logged In: YES
    user_id=332830
    Originator: YES

    File Added: MWindow.patch

     
  • Fernando Lucktemberg

    Logged In: YES
    user_id=993007
    Originator: NO

    Victor, at least I see no problems with it..
    Those methods are just reading data from the database, not setting anything..
    No problems in reading..
    If you need it I'll cast a vote. +1
    Tested it here, on pg..

     
  • Carlos Ruiz

    Carlos Ruiz - 2007-05-03

    Logged In: YES
    user_id=1180760
    Originator: NO

    Victor, the getColumn_ID looks incomplete, I suppose it must have the table_id as parameter.

    Also, I'm not sure, but please verify if the tables have the corresponding unique keys needed:
    column = table_id + name
    tab = window_id + name
    window = name

    Regards,

    Carlos Ruiz

     
  • Carlos Ruiz

    Carlos Ruiz - 2007-05-03
    • priority: 8 --> 3
     
  • Trifon (An ADempiere founder)

    Logged In: YES
    user_id=195397
    Originator: NO

    Hi Victor,

    Carlos is right.
    getColumn_ID MUST have AD_Table_ID as parameter. In Db we have columns with the swme name but in different tables.

    Kind regards,
    Trifon

     
  • Victor Perez Juarez

    Logged In: YES
    user_id=332830
    Originator: YES

    Committed revision 2414.

     
  • Victor Perez Juarez

    • labels: --> Application Dictionary
    • status: open --> closed
     
  • Carlos Ruiz

    Carlos Ruiz - 2008-01-01

    Logged In: YES
    user_id=1180760
    Originator: NO

    Victor, with revision 4077 I enhanced the logging of these changes.

    I also reverted the changes to MPrintFormat. The getPrintFormat_ID is being called just with PrintFormat name and there is a big possibility of having duplicate records with the same name (key is client+table+name) - I think this must be enhanced adding enough parameters as needed (I still don't know how is being used this method).

    Regards,

    Carlos Ruiz

     
  • Carlos Ruiz

    Carlos Ruiz - 2008-01-01
    • status: closed --> open
     
  • Carlos Ruiz

    Carlos Ruiz - 2008-04-10

    Logged In: YES
    user_id=1180760
    Originator: NO

    Brought from
    https://sourceforge.net/forum/forum.php?thread_id=2002559&forum_id=610548

    The issue is you created a method to access dictionary by AD_PrintFormat.Name - but there can be lots of print formats with the same name because of the unique index.

    You must define an accessor method that has all keys on the index.

    Regards,

    Carlos Ruiz

     
  • Carlos Ruiz

    Carlos Ruiz - 2008-05-29
    • status: open --> pending
     
  • Carlos Ruiz

    Carlos Ruiz - 2008-05-29

    Logged In: YES
    user_id=1180760
    Originator: NO

    Hi, the method MPrintFormat.getPrintFormat_ID now take account of AD_Table_ID & AD_Client_ID.

    Regards,

    Carlos Ruiz

     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 15 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending --> closed
     

Log in to post a comment.