1
2
3
4
5
6
7
8
9
10 package com.sri.emo.dbobj;
11
12 import com.jcorporate.expresso.core.controller.ControllerRequest;
13 import com.jcorporate.expresso.core.controller.Input;
14 import com.jcorporate.expresso.core.controller.Output;
15 import com.jcorporate.expresso.core.controller.Transition;
16 import com.jcorporate.expresso.core.db.DBException;
17 import com.jcorporate.expresso.core.dbobj.DBObject;
18 import com.sri.emo.commandline.defaults.AbstractNodeExportSupport;
19 import org.dom4j.Element;
20 import java.util.HashMap;
21 import java.util.Map;
22
23
24 /***
25 * Interface for custom handling of parts, when display and storage of a part
26 * is out of the ordinary. possible to generalize to a customization for
27 * relations, but right now is focused on custom owned attributes
28 *
29 * @author Larry Hamel
30 */
31 public interface IPartHandler extends Cloneable {
32
33
34 /***
35 * <tt>Special Case</tt> for functions that take no parameters as
36 * an alternative for passing in null.
37 */
38 Map NO_PARAMETERS = new HashMap(0);
39
40 /***
41 * constant for indicating that default XML should be generated for
42 * all custom parts if they have no saved settings
43 */
44 String FULL_XML = "FULL_XML";
45
46 /***
47 * Get the View Transition.
48 *
49 * @param params map of ControllerRequest params.
50 * @return the transition for viewing this part
51 * @throws DBException upon error.
52 */
53 public Transition getViewTransition(Map params) throws DBException;
54
55 /***
56 * Get the part 'edit' transition.
57 *
58 * @param params map of ControllerRequest params.
59 * @return the transition for editing this part
60 * @throws DBException upon error.
61 */
62 public Transition getEditTransition(Map params) throws DBException;
63
64 /***
65 * Retrieve the view comment as an output.
66 *
67 * @param params map of ControllerRequest params.
68 * @return Output the resulting comment.
69 * @throws DBException upon Output construction error.
70 */
71 public Output getViewComment(Map params) throws DBException;
72
73 /***
74 * Add any necessary xml attributes and elements to root for this attribute.
75 *
76 * @param request ControllerRequest the ControllerRequest object.
77 * @param attrib The attribute value for the part.
78 * @param root The XML Element to add for the part.
79 * @throws DBException upon database error.
80 */
81 public void addXML(Attribute attrib, Element root, ControllerRequest request) throws DBException;
82
83 /***
84 * Parse xml into this attribute format.
85 *
86 * @param request ControllerRequest the ControllerRequest object.
87 * @param allNodeMap ?
88 * @param attrib the specifying format.
89 * @param elem The XML Element we're parsing.
90 * @throws DBException upon database error.
91 */
92 public void parseXML(Element elem, Attribute attrib, Map allNodeMap,
93 ControllerRequest request) throws DBException;
94
95 /***
96 * Clone data from existing to clone.
97 *
98 * @param existing The source attribute.
99 * @param clone The target Attribute.
100 * @throws DBException upon database error.
101 */
102 public void clone(Attribute existing, Attribute clone) throws DBException;
103
104 /***
105 * Delete a part.
106 *
107 * @param attribute Attribute the attribute to delete.
108 * @throws DBException upon database error.
109 */
110 public void delete(Attribute attribute) throws DBException;
111
112 /***
113 * Public implementation of the <tt>Clone</tt> object.
114 *
115 * @return Object
116 * @throws CloneNotSupportedException
117 * @see java.lang.Object#clone
118 */
119 public Object clone() throws CloneNotSupportedException;
120
121 /***
122 * @return true if this value is correct with respect to menu (category) limitations
123 */
124 public boolean validate(String key, String value);
125
126 /***
127 * given an input, save the value in the custom manner.
128 */
129 public void saveInput(Input key) throws DBException;
130
131 /***
132 * @return an array of SQL Insert statements that are equivalent to the contents of this attribute; can be empty but never null
133 */
134 public String[] getInsertStatements(AbstractNodeExportSupport support, DBObject attribute) throws DBException;
135
136 /***
137 * flag as to whether this attribute is required to make sense of XML.
138 * If true,
139 * the handler should output a default matrix or whatever even if there has been
140 * no saved values from user.
141 */
142 public boolean isNeededInFullXML();
143 }