Subversion Repositories WebE

Rev

Rev 33 | Rev 35 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 34
Line 38... Line 38...
38
  /**
38
  /**
39
   * Session object
39
   * Session object
40
   */
40
   */
41
  Map<String, Object> session = ActionContext.getContext().getSession();
41
  Map<String, Object> session = ActionContext.getContext().getSession();
42
42
-
 
43
  private final HttpServletRequest request = (HttpServletRequest) ActionContext
-
 
44
      .getContext().get(StrutsStatics.HTTP_REQUEST);
-
 
45
43
  /*
46
  /*
44
   * (non-Javadoc)
47
   * (non-Javadoc)
45
   *
48
   *
46
   * @see com.opensymphony.xwork2.ModelDriven#getModel()
49
   * @see com.opensymphony.xwork2.ModelDriven#getModel()
47
   */
50
   */
Line 53... Line 56...
53
  /**
56
  /**
54
   * Executes the DB query to save the user
57
   * Executes the DB query to save the user
55
   *
58
   *
56
   * @return {@link Action#SUCCESS}
59
   * @return {@link Action#SUCCESS}
57
   */
60
   */
58
  public String add()
61
  public String save()
59
  {
62
  {
-
 
63
    if (!"1".equals(this.request.getParameter("edit")))
-
 
64
    {
60
    User user = this.userDAO.searchUsername((String) this.session
65
      User user = this.userDAO.searchUsername((String) this.session
61
        .get("username"));
66
          .get("username"));
62
    ObjectEntity obj = new ObjectEntity(user, new ObjectType(ObjectType.TERM),
67
      ObjectEntity obj = new ObjectEntity(user,
-
 
68
          new ObjectType(ObjectType.TERM), user, null, new Date(), false,
63
        user, null, new Date(), false, this.term, null, null);
69
          this.term, null, null);
64
    this.term.setObject(obj);
70
      this.term.setObject(obj);
-
 
71
    }
-
 
72
65
    if (this.termDAO.saveOrUpdate(this.term))
73
    if (this.termDAO.saveOrUpdate(this.term))
66
    {
74
    {
67
      return Action.SUCCESS;
75
      return Action.SUCCESS;
68
    }
76
    }
69
77
Line 75... Line 83...
75
   *
83
   *
76
   * @return SUCCESS
84
   * @return SUCCESS
77
   */
85
   */
78
  public String list()
86
  public String list()
79
  {
87
  {
80
    this.termList = this.termDAO.listTerm();
88
    this.termList = this.termDAO.getTerms();
81
    return Action.SUCCESS;
89
    return Action.SUCCESS;
82
  }
90
  }
83
91
84
  /**
92
  /**
85
   * @return {@link Action#SUCCESS} if <var>id</var> > 0, {@link Action#ERROR}
93
   * @return {@link Action#SUCCESS} if <var>id</var> > 0, {@link Action#ERROR}
Line 92... Line 100...
92
    if (id > 0)
100
    if (id > 0)
93
    {
101
    {
94
      this.term = this.termDAO.getTermById(id);
102
      this.term = this.termDAO.getTermById(id);
95
      if (this.term != null)
103
      if (this.term != null)
96
      {
104
      {
-
 
105
        this.term.edit = true;
97
        return Action.SUCCESS;
106
        return Action.SUCCESS;
98
      }
107
      }
99
    }
108
    }
100
109
101
    return Action.ERROR;
110
    return Action.ERROR;
Line 106... Line 115...
106
   *
115
   *
107
   * @return int from the ID request. If not set or wrong, it gives back -1
116
   * @return int from the ID request. If not set or wrong, it gives back -1
108
   */
117
   */
109
  private int getIdParameter()
118
  private int getIdParameter()
110
  {
119
  {
111
    HttpServletRequest request = (HttpServletRequest) ActionContext
-
 
112
        .getContext().get(StrutsStatics.HTTP_REQUEST);
-
 
113
-
 
114
    int id = -1;
120
    int id = -1;
115
    try
121
    try
116
    {
122
    {
117
      id = Integer.parseInt(request.getParameter("id")); //$NON-NLS-1$
123
      id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
118
    }
124
    }
119
    catch (Exception e)
125
    catch (Exception e)
120
    {
126
    {
121
      /* TODO: Logging - wrong parameter set */
127
      /* TODO: Logging - wrong parameter set */
122
    }
128
    }