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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
public class ModifierTermeAction extends DispatchAction {
public ActionForward ajouter(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
Terme terme = new Terme();
TermeDAO ter = new TermeDAO();
ThesaurusDAO dao = new ThesaurusDAO();
terme.setIdTerme(modifierTermeForm.getIdTerme());
terme.setIdLangue(modifierTermeForm.getIdLangue());
terme.setIdThesaurus(modifierTermeForm.getIdThesaurus());
terme.setDescripteur(modifierTermeForm.getDescripteur());
terme.setNoteApplication(modifierTermeForm.getNoteApplication());
terme.setNoteHistorique(modifierTermeForm.getNoteHistorique());
terme.setType(modifierTermeForm.getType());
terme.setIdMt(modifierTermeForm.getIdMt());
terme.setTest(modifierTermeForm.getTest());
Transaction tx = ter.getSession().beginTransaction();
ter.save(terme);
tx.commit();
List theso = dao.findAll();
List termeList = ter.findAll();
request.setAttribute("afficherTheso", theso);
request.setAttribute("afficherTerme", termeList);
ter.getSession().close();
return mapping.findForward("success");
}
public ActionForward effacer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ModifierTermeForm modifierTermeForm = (ModifierTermeForm) form;
TermeDAO ter = new TermeDAO();
ThesaurusDAO dao = new ThesaurusDAO();
List terme = ter.findByDescripteur(modifierTermeForm.getDescripteur());
Transaction tx = ter.getSession().beginTransaction();
if (terme.size() > 0) {
for(Iterator iter = terme.iterator(); iter.hasNext();)
{
Terme result = (Terme) iter.next();
if((modifierTermeForm.getDescripteur()).equalsIgnoreCase(result.getDescripteur())){
System.out.println(result.getDescripteur());
ter.delete(result);
tx.commit();
}
}
}
List theso = dao.findAll();
List termeList = ter.findAll();
request.setAttribute("afficherTheso", theso);
request.setAttribute("afficherTerme", termeList);
ter.getSession().close();
return mapping.findForward("success");
}
@SuppressWarnings("unchecked")
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("ajouter", "add");
map.put("effacer", "delete");
return map;
} |
Partager