*/
public Complaint search(Long code) throws RepositoryException, ObjectNotFoundException {
PersistenceManager pm = (PersistenceManager) mp.getCommunicationChannel();
//pm.setDetachAllOnCommit(true);
Complaint obj = null;
Long id = null;
String email = null;
String descricao = null;
Address enderecoSolicitante = null;
String solicitante = null;
String observation = null;
Employee attendant = null;
int situacao = 1;
long timestamp = 0;
try{
String queryFood = ("select from "+FoodComplaint.class.getName()+" where id == "+code+"");
List<FoodComplaint> food = (List<FoodComplaint>) pm.newQuery(queryFood).execute();
String queryAnimal = ("select from "+AnimalComplaint.class.getName()+" where id == "+code+"");
List<AnimalComplaint> animal = (List<AnimalComplaint>) pm.newQuery(queryAnimal).execute();
String querySpecial = ("select from "+SpecialComplaint.class.getName()+" where id == "+code+"");
List<SpecialComplaint> special = (List<SpecialComplaint>) pm.newQuery(querySpecial).execute();
if (!animal.isEmpty()){
id = animal.get(0).getId();
email = animal.get(0).obterEmail();
descricao = animal.get(0).obterDescricao();
enderecoSolicitante = animal.get(0).obterEnderecoSolicitante();
solicitante = animal.get(0).obterSolicitante();
observation = animal.get(0).obterObservation();
//attendant = animal.get(0).obterAttendant();
timestamp = animal.get(0).obterTimestamp();
situacao = animal.get(0).getSituacao();
obj = animal.get(0);
} else if(!food.isEmpty()){
id = food.get(0).getId();
solicitante = food.get(0).obterSolicitante();
email = food.get(0).obterEmail();
descricao = food.get(0).obterDescricao();
observation = food.get(0).obterObservation();
enderecoSolicitante = food.get(0).obterEnderecoSolicitante();
//attendant = food.get(0).obterAttendant();
situacao = food.get(0).getSituacao();
obj = food.get(0);
} else if (!special.isEmpty()){
id = special.get(0).getId();
solicitante = special.get(0).obterSolicitante();
email = special.get(0).obterEmail();
descricao = special.get(0).obterDescricao();
observation = special.get(0).obterObservation();
enderecoSolicitante = special.get(0).obterEnderecoSolicitante();
//attendant = special.get(0).obterAttendant();
situacao = special.get(0).getSituacao();
obj = special.get(0);
}
} catch(Exception e) {
e.printStackTrace();
}
obj.setCodigo(id);
obj.setEmail(email);
obj.setDescricao(descricao);
obj.setEnderecoSolicitante(enderecoSolicitante);
obj.setSolicitante(solicitante);
obj.setObservacao(observation);
obj.setAtendente(attendant);
obj.setTimestamp(timestamp);
obj.setSituacao(situacao);
return obj;
}