FR: [ 2214883 ] Remove SQL code and Replace for Query
-- JUnit test included (no failures) Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
dd7b9b1341
commit
8df91cee04
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -204,33 +205,12 @@ public class MProject extends X_C_Project
|
||||||
*/
|
*/
|
||||||
public MProjectLine[] getLines()
|
public MProjectLine[] getLines()
|
||||||
{
|
{
|
||||||
ArrayList<MProjectLine> list = new ArrayList<MProjectLine>();
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String sql = "SELECT * FROM C_ProjectLine WHERE C_Project_ID=? ORDER BY Line";
|
String whereClause = "C_Project_ID=?";
|
||||||
PreparedStatement pstmt = null;
|
List <MProjectLine> list = new Query(getCtx(), I_C_ProjectLine.Table_Name, whereClause, get_TrxName())
|
||||||
try
|
.setParameters(getC_Project_ID())
|
||||||
{
|
.setOrderBy("Line")
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
.list();
|
||||||
pstmt.setInt(1, getC_Project_ID());
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
list.add(new MProjectLine (getCtx(), rs, get_TrxName()));
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (SQLException ex)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql, ex);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (pstmt != null)
|
|
||||||
pstmt.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
pstmt = null;
|
|
||||||
//
|
//
|
||||||
MProjectLine[] retValue = new MProjectLine[list.size()];
|
MProjectLine[] retValue = new MProjectLine[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
|
@ -243,33 +223,12 @@ public class MProject extends X_C_Project
|
||||||
*/
|
*/
|
||||||
public MProjectIssue[] getIssues()
|
public MProjectIssue[] getIssues()
|
||||||
{
|
{
|
||||||
ArrayList<MProjectIssue> list = new ArrayList<MProjectIssue>();
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String sql = "SELECT * FROM C_ProjectIssue WHERE C_Project_ID=? ORDER BY Line";
|
String whereClause = "C_Project_ID=?";
|
||||||
PreparedStatement pstmt = null;
|
List <MProjectIssue> list = new Query(getCtx(), I_C_ProjectIssue.Table_Name, whereClause, get_TrxName())
|
||||||
try
|
.setParameters(getC_Project_ID())
|
||||||
{
|
.setOrderBy("Line")
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
.list();
|
||||||
pstmt.setInt(1, getC_Project_ID());
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
list.add(new MProjectIssue (getCtx(), rs, get_TrxName()));
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (SQLException ex)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql, ex);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (pstmt != null)
|
|
||||||
pstmt.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
pstmt = null;
|
|
||||||
//
|
//
|
||||||
MProjectIssue[] retValue = new MProjectIssue[list.size()];
|
MProjectIssue[] retValue = new MProjectIssue[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
|
@ -282,33 +241,12 @@ public class MProject extends X_C_Project
|
||||||
*/
|
*/
|
||||||
public MProjectPhase[] getPhases()
|
public MProjectPhase[] getPhases()
|
||||||
{
|
{
|
||||||
ArrayList<MProjectPhase> list = new ArrayList<MProjectPhase>();
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String sql = "SELECT * FROM C_ProjectPhase WHERE C_Project_ID=? ORDER BY SeqNo";
|
String whereClause = "C_Project_ID=?";
|
||||||
PreparedStatement pstmt = null;
|
List <MProjectPhase> list = new Query(getCtx(), I_C_ProjectPhase.Table_Name, whereClause, get_TrxName())
|
||||||
try
|
.setParameters(getC_Project_ID())
|
||||||
{
|
.setOrderBy("SeqNo")
|
||||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
.list();
|
||||||
pstmt.setInt(1, getC_Project_ID());
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
list.add(new MProjectPhase (getCtx(), rs, get_TrxName()));
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (SQLException ex)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql, ex);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (pstmt != null)
|
|
||||||
pstmt.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
pstmt = null;
|
|
||||||
//
|
//
|
||||||
MProjectPhase[] retValue = new MProjectPhase[list.size()];
|
MProjectPhase[] retValue = new MProjectPhase[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. 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. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package test.functional;
|
||||||
|
|
||||||
|
import org.compiere.model.MProject;
|
||||||
|
import org.compiere.model.MProjectIssue;
|
||||||
|
import org.compiere.model.MProjectLine;
|
||||||
|
import org.compiere.model.MProjectPhase;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
|
import test.AdempiereTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Teo Sarca, www.arhipac.ro // used by red1
|
||||||
|
*/
|
||||||
|
public class MProjectTest extends AdempiereTestCase
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
assertEquals("Client is not GardenWorld", 11, Env.getAD_Client_ID(getCtx()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testQuery() throws Exception
|
||||||
|
{
|
||||||
|
MProject proj = new MProject(getCtx(),101,null);
|
||||||
|
{
|
||||||
|
//test ProjectLines
|
||||||
|
MProjectLine[] lines = proj.getLines();
|
||||||
|
assertTrue("There should be lines in this project", lines.length > 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//test ProjectIssue
|
||||||
|
MProjectIssue[] issues = proj.getIssues();
|
||||||
|
assertTrue("There are no issues in this project", issues.length == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//test ProjectPhase
|
||||||
|
MProjectPhase[] lines = proj.getPhases();
|
||||||
|
assertTrue("There are no phases in this project", lines.length == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue