View Javadoc

1   // Created on 24.11.2003
2   package com.pnpconsult.zeiterfassung.actions.admin;
3   
4   import java.io.Serializable;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   
9   import com.pnpconsult.zeiterfassung.actions.DeleteForm;
10  import com.pnpconsult.zeiterfassung.helper.CustomerManager;
11  import com.pnpconsult.zeiterfassung.model.Customer;
12  
13  /***
14   * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
15   * @version $Id: DeleteCustomerForm.java,v 1.5 2004/06/24 20:54:18 powerpete Exp $
16   * 
17   * @struts.form 
18   *      name="deleteCustomerForm"
19   */
20  public class DeleteCustomerForm extends DeleteForm
21  {
22  	private static final Log LOG = LogFactory.getLog(DeleteCustomerForm.class);
23  	private long id;
24  
25  	public void delete()
26  	{
27  		try
28  		{
29  			new CustomerManager().delete(id);
30  		}
31  		catch (Exception e)
32  		{
33  			LOG.fatal("Error deleting customer with id " + id, e);
34  		}
35  	}
36  
37  	public void writeToDataObject(Object obj)
38  	{
39  		throw new UnsupportedOperationException();
40  	}
41  
42  	public void readFromDataObject(Object obj)
43  	{
44  		throw new UnsupportedOperationException();
45  	}
46  
47  	/***
48  	 * @return Returns the id.
49  	 */
50  	public long getCustomerId()
51  	{
52  		return id;
53  	}
54  
55  	/***
56  	 * @param id The id to set.
57  	 */
58  	public void setCustomerId(long id)
59  	{
60  		this.id = id;
61  		try
62  		{
63  			Customer customer = new CustomerManager().load(id);
64  			setName(customer.toString());
65  //			setInformation("Es werden alle mit diesem Kunden verkn&uuml;pften "
66  //				+ "Projekte, Eintr&auml;ge und Rechnungen gel&ouml;scht.");
67  		}
68  		catch (Exception e)
69  		{
70  			LOG.fatal("Error loading customer with id " + id, e);
71  		}
72  	}
73  
74  	/***
75  	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#newDataObject()
76  	 */
77  	protected Object newDataObject()
78  	{
79  		throw new UnsupportedOperationException();
80  	}
81  
82  	/***
83  	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#dataObjectType()
84  	 */
85  	protected Class dataObjectType()
86  	{
87  		return Customer.class;
88  	}
89  
90  	/***
91  	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#dataObjectKey()
92  	 */
93  	protected Serializable dataObjectKey()
94  	{
95  		return new Long(id);
96  	}
97  }