📄 mlookupinfo.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.util.*;
import java.sql.*;
import java.io.Serializable;
import org.compiere.util.*;
/**
* Info Class for Lookup SQL (ValueObject)
*
* @author Jorg Janke
* @version $Id: MLookupInfo.java,v 1.2 2003/02/23 19:44:05 jjanke Exp $
*/
public final class MLookupInfo implements Serializable
{
/**
* Cosntructor
* @param sqlQuery SQL query
* @param keyColumn key column
* @param zoomWindow zoom window
* @param zoomQuery zoom query
*/
public MLookupInfo (String sqlQuery, String keyColumn, int zoomWindow, MQuery zoomQuery)
{
Query = sqlQuery;
if (keyColumn == null)
throw new IllegalArgumentException("MLookupInfo - sqlQuery is null");
KeyColumn = keyColumn;
if (keyColumn == null)
throw new IllegalArgumentException("MLookupInfo - keyColumn is null");
ZoomWindow = zoomWindow;
ZoomQuery = zoomQuery;
} // MLookupInfo
/** Query */
public String Query = null;
/** Key Column */
public String KeyColumn = "";
/** Zoom Window */
public int ZoomWindow;
/** Zoom Query */
public MQuery ZoomQuery = null;
/** Direct Access Query */
public String QueryDirect = "";
/** Parent Flag */
public boolean IsParent = false;
/** Validation code */
public String Validation = "";
/** Validation flag */
public boolean IsValidated = true;
public Properties ctx = null;
public int WindowNo;
public int AD_Column_ID;
public boolean IsProcess;
public int DisplayType;
/**
* String representation
* @return info
*/
public String toString()
{
StringBuffer sb = new StringBuffer ("MLookupInfo[")
.append(KeyColumn).append(" - Direct=").append(QueryDirect)
.append("]");
return sb.toString();
} // toString
/*************************************************************************/
/**
* Get first AD_Reference_ID of a matching Reference Name.
* Can have SQL LIKE placeholders.
* (This is more a development tool than used for production)
* @param referenceName reference name
* @return AD_Reference_ID
*/
public static int getAD_Reference_ID (String referenceName)
{
int retValue = 0;
String sql = "SELECT AD_Reference_ID,Name,ValidationType,IsActive FROM AD_Reference WHERE Name LIKE ?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql);
pstmt.setString(1, referenceName);
ResultSet rs = pstmt.executeQuery();
//
int i = 0;
int id = 0;
String refName = "";
String validationType = "";
boolean isActive = false;
while (rs.next())
{
id = rs.getInt(1);
if (i == 0)
retValue = id;
refName = rs.getString(2);
validationType = rs.getString(3);
isActive = rs.getString(4).equals("Y");
Log.trace(Log.l3_Util, "AD_Reference Name=" + refName + ", ID=" + id + ", Type=" + validationType + ", Active=" + isActive);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
Log.error("MLookupInfo.getAD_Reference_ID", e);
}
return retValue;
} // getAD_Reference_ID
/**
* Get first AD_Column_ID of matching ColumnName.
* Can have SQL LIKE placeholders.
* (This is more a development tool than used for production)
* @param columnName column name
* @return AD_Column_ID
*/
public static int getAD_Column_ID (String columnName)
{
int retValue = 0;
String sql = "SELECT c.AD_Column_ID,c.ColumnName,t.TableName FROM AD_Column c, AD_Table t WHERE c.ColumnName LIKE ? AND c.AD_Table_ID=t.AD_Table_ID";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql);
pstmt.setString(1, columnName);
ResultSet rs = pstmt.executeQuery();
//
int i = 0;
int id = 0;
String colName = "";
String tabName = "";
while (rs.next())
{
id = rs.getInt(1);
if (i == 0)
retValue = id;
colName = rs.getString(2);
tabName = rs.getString(3);
Log.trace(Log.l3_Util, "AD_Column Name=" + colName + ", ID=" + id + ", Table=" + tabName);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
Log.error("MLookupInfo.getAD_Column_ID", e);
}
return retValue;
} // getAD_Reference_ID
} // MLookupInfo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -