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.ProjectManager;
11  import com.pnpconsult.zeiterfassung.model.Customer;
12  import com.pnpconsult.zeiterfassung.model.Project;
13  
14  /***
15   * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
16   * @version $Id: DeleteProjectForm.java,v 1.5 2004/06/24 20:54:18 powerpete Exp $
17   * 
18   * @struts.form name="deleteProjectForm"
19   */
20  public class DeleteProjectForm extends DeleteForm
21  {
22  	private static final Log LOG = LogFactory.getLog(DeleteProjectForm.class);
23  	private long id;
24  	private Customer customer;
25  
26  	public void delete()
27  	{
28  		try
29  		{
30  			new ProjectManager().delete(id);
31  		}
32  		catch (Exception e)
33  		{
34  			LOG.fatal("Error deleting project with id " + id, e);
35  		}
36  	}
37  
38  	public void writeToDataObject(Object obj)
39  	{
40  		throw new UnsupportedOperationException();
41  	}
42  
43  	public void readFromDataObject(Object obj)
44  	{
45  		throw new UnsupportedOperationException();
46  	}
47  
48  	public long getId()
49  	{
50  		return id;
51  	}
52  
53  	public void setId(long id)
54  	{
55  		this.id = id;
56  		try
57  		{
58  			Project project = new ProjectManager().load(id);
59  			setName(project.toString());
60  //			setInformation("Alle mit diesem Projekt verkn&uuml;pften "
61  //				+ "Rechnungen und Eintr&auml;ge werden gel&ouml;scht.");
62  		}
63  		catch (Exception e)
64  		{
65  			LOG.fatal("Error loading project with id " + id, e);
66  		}
67  	}
68  
69  	/***
70  	 * @return Returns the customerId.
71  	 */
72  	public long getCustomerId()
73  	{
74  		return customer == null ? -1 : customer.getId();
75  	}
76  
77  	/***
78  	 * @param customerId The customerId to set.
79  	 */
80  	public void setCustomerId(long customerId)
81  	{
82  		if (customer == null)
83  		{
84  			customer = new Customer();
85  		}
86  		customer.setId(customerId);
87  	}
88  
89  	/***
90  	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#newDataObject()
91  	 */
92  	protected Object newDataObject()
93  	{
94  		return new Project();
95  	}
96  
97  	/***
98  	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#dataObjectType()
99  	 */
100 	protected Class dataObjectType()
101 	{
102 		return Project.class;
103 	}
104 
105 	/***
106 	 * @see com.pnpconsult.zeiterfassung.actions.EditForm#dataObjectKey()
107 	 */
108 	protected Serializable dataObjectKey()
109 	{
110 		return new Long(id);
111 	}
112 }