IDEMPIERE-5567 - refactor of some array related methods (#1889)
This commit is contained in:
parent
7e1bfa1334
commit
066cd52b8e
|
@ -16,15 +16,14 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,37 +62,10 @@ public class MChangeLog extends X_AD_ChangeLog
|
||||||
*/
|
*/
|
||||||
private static void fillChangeLog()
|
private static void fillChangeLog()
|
||||||
{
|
{
|
||||||
ArrayList<Integer> list = new ArrayList<Integer>(40);
|
final String where = "IsChangeLog='Y' OR EXISTS (SELECT * FROM AD_Column c WHERE AD_Table.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='EntityType')";
|
||||||
String sql = "SELECT t.AD_Table_ID FROM AD_Table t "
|
s_changeLog = new Query(Env.getCtx(), MTable.Table_Name, where, null)
|
||||||
+ "WHERE t.IsChangeLog='Y'" // also inactive
|
.setOrderBy(MTable.COLUMNNAME_AD_Table_ID)
|
||||||
+ " OR EXISTS (SELECT * FROM AD_Column c "
|
.getIDs();
|
||||||
+ "WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='EntityType') "
|
|
||||||
+ "ORDER BY t.AD_Table_ID";
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
list.add(Integer.valueOf(rs.getInt(1)));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null; pstmt = null;
|
|
||||||
}
|
|
||||||
// Convert to Array
|
|
||||||
s_changeLog = new int [list.size()];
|
|
||||||
for (int i = 0; i < s_changeLog.length; i++)
|
|
||||||
{
|
|
||||||
Integer id = (Integer)list.get(i);
|
|
||||||
s_changeLog[i] = id.intValue();
|
|
||||||
}
|
|
||||||
if (s_log.isLoggable(Level.INFO)) s_log.info("#" + s_changeLog.length);
|
if (s_log.isLoggable(Level.INFO)) s_log.info("#" + s_changeLog.length);
|
||||||
} // fillChangeLog
|
} // fillChangeLog
|
||||||
|
|
||||||
|
|
|
@ -1043,11 +1043,7 @@ public class Query
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
// Convert to array
|
// Convert to array
|
||||||
int[] retValue = new int[list.size()];
|
int[] retValue = list.stream().mapToInt(Integer::intValue).toArray();
|
||||||
for (int i = 0; i < retValue.length; i++)
|
|
||||||
{
|
|
||||||
retValue[i] = list.get(i);
|
|
||||||
}
|
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get_IDs
|
} // get_IDs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue