* especificado.
*/
private AnimalComplaint accessAnimal(Long codigo) throws RepositoryException,
ObjectNotFoundException {
AnimalComplaint complaint;
String sql = null;
try {
complaint = new AnimalComplaint();
// Query sql que recupera todos os dados de uma complaint animal
// para isso realiza um join para acessar as duas tabelas
// A primeira tabela cont�m os dados gen�ricos a todas as
// queixas, a segunda tabela cont�m os dados espec�ficos
// a complaint animal
sql = "select * from scbs_queixa q,scbs_queixaanimal qa where q.codigo=qa.codigo and q."
+ "codigo = '" + codigo + "'";
Statement stmt = (Statement) this.mp.getCommunicationChannel();
resultSet = stmt.executeQuery(sql);
if (resultSet.next()) {
accessComplaint(resultSet, complaint);
complaint.setAnimalQuantity(resultSet.getShort("qtdeAnimais"));
String date = resultSet.getString("dataIncomodo");
java.util.Date d = null;
if (!date.equals("NULL")) {
StringTokenizer token = new StringTokenizer(date, "/");
int day = (new Integer(token.nextToken())).intValue();
int month = (new Integer(token.nextToken())).intValue();
int year = (new Integer(token.nextToken())).intValue();
d = new java.util.Date(year, month, day);
}
if (d != null) {
try {
complaint.setInconvenienceDate(new Date(d.getDate(), d.getMonth() + 1, d
.getYear() + 1900));
} catch (InvalidDateException ex) {
}
} else {
complaint.setInconvenienceDate(null);
}
complaint.setAnimal(resultSet.getString("animal"));
String endAnimal = resultSet.getString("enderecolocalocorrencia");
// System.out.println("endereco animal = "+ endAnimal);
Address endLO = addressRep.search((new Long(endAnimal)).longValue());
complaint.setOccurenceLocalAddress(endLO);
} else {
throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
}
resultSet.close();