Skip to content

Commit

Permalink
Update de.metas.adempiere.adempiere/base/src/main/java-legacy/org/com…
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Oct 16, 2018
1 parent 19c1251 commit 48c7852
Showing 1 changed file with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;

Expand All @@ -22,9 +22,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.Callable;
Expand All @@ -47,13 +45,16 @@
import de.metas.i18n.po.POTrlInfo;
import de.metas.i18n.po.POTrlRepository;
import de.metas.logging.LogManager;
import lombok.NonNull;

/**
* Persistent Object Info. Provides structural information
*
* @author Jorg Janke
* @version $Id: POInfo.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $
* @author Victor Perez, e-Evolution SC <li>[ 2195894 ] Improve performance in PO engine <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
* @author Victor Perez, e-Evolution SC
* <li>[ 2195894 ] Improve performance in PO engine
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195894&group_id=176962&atid=879335
*/
public final class POInfo implements Serializable
{
Expand Down Expand Up @@ -207,13 +208,13 @@ private POInfo(final int AD_Table_ID, final String trxName)
/** Columns */
private POInfoColumn[] m_columns;

private Map<String, Integer> columnName2columnIndex;
private Map<Integer, Integer> adColumnId2columnIndex;
private ImmutableMap<String, Integer> columnName2columnIndex;
private ImmutableMap<Integer, Integer> adColumnId2columnIndex;

/**
* Key Column Names
*/
private List<String> m_keyColumnNames;
private ImmutableList<String> m_keyColumnNames;
/**
* Single Primary Key.
*
Expand Down Expand Up @@ -431,12 +432,12 @@ else if (!parentColumnNames.isEmpty())
// Fallback: there are no keys nor parents
else
{
m_keyColumnNames = Collections.emptyList();
m_keyColumnNames = ImmutableList.of();
m_keyColumnName = null;
}

// First valid ID
if(m_keyColumnName != null)
if (m_keyColumnName != null)
{
firstValidId = POWrapper.getFirstValidIdByColumnName(m_keyColumnName);
}
Expand All @@ -451,7 +452,7 @@ else if (!parentColumnNames.isEmpty())
sqlSelect = buildSqlSelect();
sqlWhereClauseByKeys = buildSqlWhereClauseByKeys();
sqlSelectByKeys = buildSqlSelectByKeys();

trlInfo = POTrlRepository.instance.createPOTrlInfo(m_TableName, m_keyColumnName, translatedColumnNames);
} // loadInfo

Expand Down Expand Up @@ -518,12 +519,12 @@ public String getKeyColumnName()
{
return m_keyColumnName;
}

public boolean isSingleKeyColumnName()
{
return m_keyColumnName != null;
}

public String getSingleKeyColumnName()
{
if (!isSingleKeyColumnName())
Expand Down Expand Up @@ -551,7 +552,7 @@ public String[] getKeyColumnNamesAsArray()
{
return m_keyColumnNames.toArray(new String[m_keyColumnNames.size()]);
}

public int getFirstValidId()
{
return firstValidId;
Expand Down Expand Up @@ -789,15 +790,15 @@ public boolean isVirtualColumn(final String columnName)
return isVirtualColumn(columnIndex);
}

/** @return true if column exist and it's physical (i.e. not a virtual column) */
/** @return true if column exist and it's physical (i.e. not a virtual column) */
public boolean isPhysicalColumn(final String columnName)
{
final int columnIndex = getColumnIndex(columnName);
if (columnIndex < 0)
{
return false;
}

return !isVirtualColumn(columnIndex);
}

Expand Down Expand Up @@ -839,7 +840,7 @@ public Class<?> getColumnClass(final int index)
return null;
return m_columns[index].ColumnClass;
} // getColumnClass

/**
* Get Column Class
*
Expand All @@ -856,7 +857,6 @@ public Class<?> getColumnClass(final String columnName)
return getColumnClass(columnIndex);
}


/**
* Get Column Display Type
*
Expand Down Expand Up @@ -933,7 +933,7 @@ public int getColumnReferenceValueId(final String columnName)
final int columnIndex = getColumnIndex(columnName);
return getColumnReferenceValueId(columnIndex);
}

public int getColumnValRuleId(final String columnName)
{
final int columnIndex = getColumnIndex(columnName);
Expand Down Expand Up @@ -990,7 +990,7 @@ public void setUpdateable(final boolean updateable)
m_columns[i].IsUpdateable = updateable;
}
} // setUpdateable

public String getReferencedTableNameOrNull(final String columnName)
{
final int columnIndex = getColumnIndex(columnName);
Expand All @@ -1015,6 +1015,12 @@ public Lookup getColumnLookup(final Properties ctx, final int windowNo, final in
return m_columns[columnIndex].getLookup(ctx, windowNo);
}

public Lookup getColumnLookup(@NonNull final String columnName)
{
final int columnIndex = getColumnIndex(columnName);
return getColumnLookup(Env.getCtx(), columnIndex);
}

/**
* Is Column Key
*
Expand Down Expand Up @@ -1055,7 +1061,7 @@ public boolean isColumnParent(final int index)
return false;
return m_columns[index].IsParent;
} // isColumnParent

public boolean isColumnParent(final String columnName)
{
final int columnIndex = getColumnIndex(columnName);
Expand Down Expand Up @@ -1418,7 +1424,7 @@ private final String buildSqlWhereClauseByKeys()
}
return sb.toString();
}

/**
* Checks if given column can be stale
*
Expand All @@ -1443,15 +1449,15 @@ private final String buildSqlWhereClauseByKeys()
{
return m_HasStaleableColumns;
}

/**
* @return list of column names which are translated
*/
public List<String> getTranslatedColumnNames()
{
return trlInfo.getTranslatedColumnNames();
}

public POTrlInfo getTrlInfo()
{
return trlInfo;
Expand All @@ -1463,8 +1469,8 @@ public boolean isPasswordColumn(final int index)
{
return false;
}

return m_columns[index].isPasswordColumn();

}
} // POInfo

0 comments on commit 48c7852

Please sign in to comment.