1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public Stack GetMainSubstitutes(int iin){
Stack AnswerStack = new Stack();
//get main substitues
Session session = HibernateUtil.getSessionFactory().openSession();
List result = null;
session.beginTransaction();
result = session.createQuery("from ArtSub where iin= ?")
.setInteger(0,iin).list();
session.getTransaction().commit();
session.close();
if (result.size()>0) {
for(int i=0; i<result.size(); i++){
ArtSub as = (ArtSub)result.get(i);
AnswerStack.push(new Integer(as.getSub()));
}
}
return AnswerStack;
}
public GetSubstitutes(int p, Stack lp) {
Stack produits = GetMainSubstitutes(p);
if(produits.empty()){
lp.push(new Integer(p));
}else{
while(!produits.empty()){
Integer iin2 = (Integer) produits.pop();
lp.push(new Integer(GetSubstitutes(iin2,lp)));
}
} |