CVDal cvdl = new CVDal(dataSource);
cvdl.setSql("project.getproject");
cvdl.setInt(1, projectId);
Collection col = cvdl.executeQuery();
Iterator ite = col.iterator();
ProjectVO pvo = new ProjectVO();
if (ite.hasNext())
{
HashMap project = (HashMap)ite.next();
pvo.setProjectID(((Long)project.get("ProjectID")).intValue());
pvo.setTitle((String)project.get("ProjectTitle"));
if (project.get("Description") != null)
pvo.setDescription((String)project.get("Description"));
if (project.get("StatusID") != null)
pvo.setStatusID(((Long)project.get("StatusID")).intValue());
if (project.get("Start") != null)
pvo.setStart((java.sql.Date)project.get("Start"));
if (project.get("End") != null)
pvo.setEnd((java.sql.Date)project.get("End"));
if (project.get("BudgetedHours") != null)
pvo.setBudgetedHours(((Long)project.get("BudgetedHours")).intValue());
if (project.get("HoursUsed") != null)
pvo.setUsedHours(((Long)project.get("HoursUsed")).intValue());
if (project.get("Owner") != null)
pvo.setOwner(((Long)project.get("Owner")).intValue());
if (project.get("Manager") != null)
pvo.setManagerID(((Long)project.get("Manager")).intValue());
if (project.get("Creator") != null)
pvo.setCreator(((Long)project.get("Creator")).intValue());
if (project.get("ModifiedBy") != null)
pvo.setModifiedBy(((Long)project.get("ModifiedBy")).intValue());
if (project.get("Modified") != null)
pvo.setModified((Timestamp)project.get("Modified"));
if (project.get("Created") != null)
pvo.setCreated((Timestamp)project.get("Created"));
}
cvdl.clearParameters();
cvdl.setSql("project.getindname");
cvdl.setInt(1, pvo.getCreator());
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setCreatorName((String)hm.get("CONCAT(firstname,' ',lastname)"));
}
cvdl.clearParameters();
cvdl.setSql("project.getindname");
cvdl.setInt(1, pvo.getModifiedBy());
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setModifierName((String)hm.get("CONCAT(firstname,' ',lastname)"));
}
cvdl.clearParameters();
cvdl.setSql("project.getprojectentitylink");
cvdl.setInt(1, projectId);
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setEntityID(((Long)hm.get("entityid")).intValue());
pvo.setEntityName((String)hm.get("name"));
}
cvdl.clearParameters();
cvdl.setSql("project.getprojectindividuallink");
cvdl.setInt(1, projectId);
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setContactID(((Long)hm.get("individualid")).intValue());
pvo.setContactName((String)hm.get("CONCAT(firstname , ' ' , lastname)"));
}
cvdl.clearParameters();
cvdl.setSql("project.getprojectgrouplink");
cvdl.setInt(1, projectId);
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setGroupID(((Long)hm.get("groupid")).intValue());
pvo.setGroupName((String)hm.get("name"));
}
cvdl.clearParameters();
cvdl.setSql("project.projecthoursused");
cvdl.setInt(1, projectId);
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
if (hm.get("sum(hours)") != null)
{
pvo.setUsedHours(((Double)hm.get("sum(hours)")).floatValue());
}
}
cvdl.clearParameters();
cvdl.setSql("project.getindname");
cvdl.setInt(1, pvo.getOwner());
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setOwnerName((String)hm.get("CONCAT(firstname,' ',lastname)"));
}
cvdl.clearParameters();
cvdl.setSql("project.getindname");
cvdl.setInt(1, pvo.getManagerID());
col = cvdl.executeQuery();
ite = col.iterator();
if (ite.hasNext())
{
HashMap hm = (HashMap)ite.next();
pvo.setManager((String)hm.get("CONCAT(firstname,' ',lastname)"));
}
cvdl.clearParameters();
return pvo;
}