Assembla home | Assembla project page
 

Changeset 249

Show
Ignore:
Timestamp:
04/11/09 00:45:17 (1 year ago)
Author:
restamon
Message:

DAO refactoring

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • approval-web/trunk/.settings/org.eclipse.jdt.core.prefs

    r220 r249  
    1 #Wed Dec 03 18:34:02 PST 2008 
     1#Sat Apr 04 15:14:11 PDT 2009 
    22org.eclipse.jdt.core.compiler.debug.localVariable=generate 
    33org.eclipse.jdt.core.compiler.compliance=1.5 
    44org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 
    55org.eclipse.jdt.core.compiler.debug.sourceFile=generate 
    6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 
     6org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 
    77org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 
    88eclipse.preferences.version=1 
    99org.eclipse.jdt.core.compiler.debug.lineNumber=generate 
    1010org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 
    11 org.eclipse.jdt.core.compiler.source=1.3 
     11org.eclipse.jdt.core.compiler.source=1.5 
    1212org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 
  • approval-web/trunk/pom.xml

    r243 r249  
    117117      <groupId>org.restafarian</groupId> 
    118118      <artifactId>approval</artifactId> 
    119       <version>1.0</version> 
     119      <version>1.1</version> 
    120120    </dependency> 
    121121    <dependency> 
  • approval-web/trunk/src/main/java/org/restafarian/approval/servlets/impl/RequestForApprovalSelectorServlet.java

    • Property svn:mergeinfo set
    r82 r249  
    1 package org.restafarian.approval.servlets
     1package org.restafarian.approval.servlets.impl
    22 
    33import java.util.HashMap; 
     
    2727         * @return the static list of fields to include 
    2828         */ 
    29         private Map defineDataFields() { 
    30                 Map fields = new HashMap(); 
     29        private Map<String,String> defineDataFields() { 
     30                Map<String,String> fields = new HashMap<String,String>(); 
    3131 
    3232                fields.put("id", "id"); 
  • approval-web/trunk/src/main/java/org/restafarian/approval/servlets/impl/RequestForApprovalServlet.java

    • Property svn:mergeinfo set
    r82 r249  
    1 package org.restafarian.approval.servlets
     1package org.restafarian.approval.servlets.impl
    22 
    33import java.io.IOException; 
     
    1616import org.apache.commons.betwixt.io.read.BeanCreationList; 
    1717import org.apache.commons.betwixt.strategy.ConvertUtilsObjectStringConverter; 
     18import org.apache.commons.lang.StringUtils; 
    1819import org.restafarian.approval.beans.RequestForApproval; 
    1920import org.restafarian.approval.beans.RequestForApprovalAction; 
    2021import org.restafarian.approval.beans.RequestForApprovalApprover; 
    21 import org.restafarian.approval.data.RequestForApprovalManager; 
    22 import org.restafarian.approval.data.RestServiceManager; 
     22import org.restafarian.approval.manager.RequestForApprovalManager; 
     23import org.restafarian.approval.service.impl.RestServiceManager; 
    2324import org.restafarian.core.beans.Person; 
    2425import org.restafarian.core.security.AuthenticatedUserManager; 
    2526import org.restafarian.core.servlets.RestServletBase; 
    2627import org.restafarian.core.utils.BetwixtTool; 
     28import org.springframework.dao.DataAccessException; 
    2729 
    2830/** 
     
    3335        private static final String MISSING_FIELD_ERROR_1 = "Required parameter \""; 
    3436        private static final String MISSING_FIELD_ERROR_2 = "\" missing or invalid."; 
     37        private RequestForApprovalManager requestForApprovalManager = null; 
    3538 
    3639        /** 
     
    109112                RequestForApproval rfa = buildRequestForApprovalFromInput(req, res); 
    110113                if (rfa != null) { 
    111                         int id = RequestForApprovalManager.insertRequestForApproval(rfa); 
     114                        requestForApprovalManager.save(rfa); 
     115                        int id = rfa.getId(); 
    112116                        if (id > 0) { 
    113117                                sendRequestForApproval(id, req, res); 
     
    159163         */ 
    160164        private void sendRequestForApproval(int id, HttpServletRequest req, HttpServletResponse res) throws IOException { 
    161                 RequestForApproval rfa = RequestForApprovalManager.getRequestForApproval(id); 
    162  
    163                 if (rfa != null) { 
     165                RequestForApproval requestForApproval = null; 
     166 
     167                try { 
     168                        requestForApproval = requestForApprovalManager.findById(id); 
    164169                        PrintWriter pw = res.getWriter(); 
    165170                        if (pw != null && !pw.equals("")) { 
    166                                 pw.print(BetwixtTool.toXml(rfa, "/approval/xsl/rfa.xsl")); 
     171                                pw.print(BetwixtTool.toXml(requestForApproval, "/approval/xsl/rfa.xsl")); 
    167172                        } else { 
    168173                                sendError(req, res, 500, "There was a technical error while attempting to access this resource. Details of this error have been logged on the server."); 
    169174                        } 
    170                 } else
     175                } catch (DataAccessException dae)
    171176                        sendError(req, res, 404, "The requested resource was not found on this server. If you entered the URL manually please check your spelling and try again."); 
     177                } catch (Exception e) { 
     178                        sendError(req, res, 500, "There was a technical error while attempting to access this resource. Details of this error have been logged on the server.", e); 
    172179                } 
    173180        } 
     
    181188        private void sendQueryResults(HttpServletRequest req, HttpServletResponse res) throws IOException { 
    182189                Person user = AuthenticatedUserManager.getAuthenticatedUser(req); 
    183                 List list = RequestForApprovalManager.requestForApprovalQuery(req.getParameterMap(), user.getId()); 
     190                List<RequestForApproval> list = requestForApprovalQuery(req, user.getId()); 
    184191 
    185192                if (list != null && list.size() > 0) { 
     
    210217                        sendError(req, res, 406, MISSING_FIELD_ERROR_1 + "action" + MISSING_FIELD_ERROR_2); 
    211218                } else { 
    212                         RequestForApproval rfa = RequestForApprovalManager.getRequestForApproval(id); 
     219                        RequestForApproval rfa = requestForApprovalManager.findById(id); 
    213220                        if (rfa == null) { 
    214221                                // send error 
     
    242249                                                newState = "Returned"; 
    243250                                        } 
    244                                         if (RequestForApprovalManager.updateRequestForApproval(id, newState, action, notes, user)) { 
    245                                                 // notify host system 
    246                                                 Map parameters = new HashMap(); 
    247                                                 parameters.put("action", req.getParameter("action")); 
    248                                                 parameters.put("notes", notes); 
    249                                                 Map response = RestServiceManager.post(rfa.getPayloadURI(), parameters, req); 
    250                                                 int statusCode = ((Integer) response.get("statusCode")).intValue(); 
    251                                                 if (statusCode == 200) { 
    252                                                         sendRequestForApproval(id, req, res); 
    253                                                 } else { 
    254                                                         // log error, if enabled 
    255                                                         if (log.isErrorEnabled()) { 
    256                                                                 log.error("Error posting to URI: " + rfa.getPayloadURI() + "; Status code: " + statusCode, (Exception) response.get("exception")); 
    257                                                         } 
    258                                                         // send error 
    259                                                         sendError(req, res, 500, "There was a technical error while attempting to update this resource. Details of this error have been logged on the server."); 
     251                                        // update rfa 
     252                                        rfa.setState(newState); 
     253                                        RequestForApprovalAction rfaAction = new RequestForApprovalAction(); 
     254                                        rfaAction.setDateTime(new Date()); 
     255                                        rfaAction.setActivity(action); 
     256                                        rfaAction.setUser(user); 
     257                                        rfaAction.setComments(notes); 
     258                                        rfa.addAction(rfaAction); 
     259                                        requestForApprovalManager.save(rfa); 
     260                                        // notify host system 
     261                                        Map<String,String> parameters = new HashMap<String,String> (); 
     262                                        parameters.put("action", req.getParameter("action")); 
     263                                        parameters.put("notes", notes); 
     264                                        Map<String, Object> response = RestServiceManager.post(rfa.getPayloadURI(), parameters, req); 
     265                                        int statusCode = ((Integer) response.get("statusCode")).intValue(); 
     266                                        if (statusCode == 200) { 
     267                                                sendRequestForApproval(id, req, res); 
     268                                        } else { 
     269                                                // log error, if enabled 
     270                                                if (log.isErrorEnabled()) { 
     271                                                        log.error("Error posting to URI: " + rfa.getPayloadURI() + "; Status code: " + statusCode, (Exception) response.get("exception")); 
    260272                                                } 
    261                                         } else { 
    262273                                                // send error 
    263274                                                sendError(req, res, 500, "There was a technical error while attempting to update this resource. Details of this error have been logged on the server."); 
     
    325336 
    326337        /** 
     338         * <p>Handles an RFA query.</p> 
     339         * 
     340         * @param queryString the query string 
     341         * @return the list of RFAs 
     342         */ 
     343        public List<RequestForApproval> requestForApprovalQuery(HttpServletRequest req, String userId) { 
     344                String role = req.getParameter("role"); 
     345                String orderBy = req.getParameter("orderBy"); 
     346                if (StringUtils.isEmpty(orderBy)) { 
     347                        orderBy = "id desc"; 
     348                } 
     349                String hql = "from RequestForApproval order by " + orderBy; 
     350                if ("author".equalsIgnoreCase(role)) { 
     351                        hql = "from RequestForApproval where authorId = '" + userId + "' and state = 'Submitted' order by " + orderBy; 
     352                } else if ("approver".equalsIgnoreCase(role)) { 
     353                        hql = "from RequestForApproval rfa where exists (select 1 from RequestForApprovalApprover where rfaId=rfa.id and approverId = '" + userId + "') and rfa.state = 'Submitted' order by " + orderBy; 
     354                } 
     355 
     356                return requestForApprovalManager.executeQuery(hql); 
     357        } 
     358 
     359        /** 
    327360         * <p>Converts a list of RFAs to XML.</p> 
    328361         *  
     
    330363         * @return the list of RFAs in XML format 
    331364         */ 
    332         private static String rfaListToXml(List list) { 
     365        private static String rfaListToXml(List<RequestForApproval> list) { 
    333366                StringBuffer buffer = new StringBuffer(); 
    334367 
     
    336369                buffer.append("<approval:rfas xmlns:approval=\"http://www.restafarian.org/approval\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"); 
    337370                if (list != null && list.size() > 0) { 
    338                         Iterator i = list.iterator(); 
     371                        Iterator<RequestForApproval> i = list.iterator(); 
    339372                        while (i.hasNext()) { 
    340373                                RequestForApproval rfa = (RequestForApproval) i.next(); 
     
    350383                return buffer.toString(); 
    351384        } 
     385 
     386        /** 
     387         * @return the requestForApprovalManager 
     388         */ 
     389        public RequestForApprovalManager getRequestForApprovalManager() { 
     390                return requestForApprovalManager; 
     391        } 
     392 
     393        /** 
     394         * @param requestForApprovalManager the requestForApprovalManager to set 
     395         */ 
     396        public void setRequestForApprovalManager( 
     397                        RequestForApprovalManager requestForApprovalManager) { 
     398                this.requestForApprovalManager = requestForApprovalManager; 
     399        } 
    352400} 
  • approval-web/trunk/src/main/webapp/WEB-INF/web.xml

    r106 r249  
    33  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    44  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
    5   <display-name>ApprovalWeb</display-name> 
     5  <display-name>approval-web</display-name> 
     6  <welcome-file-list> 
     7    <welcome-file>index.html</welcome-file> 
     8  </welcome-file-list> 
     9  <context-param> 
     10    <param-name>contextConfigLocation</param-name> 
     11    <param-value>/WEB-INF/applicationContext*.xml</param-value> 
     12  </context-param> 
     13  <listener> 
     14    <listener-class> 
     15      org.springframework.web.context.ContextLoaderListener 
     16    </listener-class> 
     17  </listener> 
    618  <servlet> 
    7     <description></description> 
     19    <description>RequestForApprovalServlet</description> 
    820    <display-name>RequestForApprovalServlet</display-name> 
    9     <servlet-name>RequestForApprovalServlet</servlet-name> 
     21    <servlet-name>requestForApprovalServlet</servlet-name> 
    1022    <servlet-class> 
    11       org.restafarian.approval.servlets.RequestForApprovalServlet 
     23      org.restafarian.core.servlets.GenericSpringServlet 
    1224    </servlet-class> 
    1325  </servlet> 
     
    1729    <servlet-name>RequestForApprovalSelectorServlet</servlet-name> 
    1830    <servlet-class> 
    19       org.restafarian.approval.servlets.RequestForApprovalSelectorServlet 
     31      org.restafarian.approval.servlets.impl.RequestForApprovalSelectorServlet 
    2032    </servlet-class> 
    2133  </servlet> 
    2234  <servlet-mapping> 
    23     <servlet-name>RequestForApprovalServlet</servlet-name> 
     35    <servlet-name>requestForApprovalServlet</servlet-name> 
    2436    <url-pattern>/rfa/*</url-pattern> 
    2537  </servlet-mapping> 
     
    2840    <url-pattern>/rfa.xml</url-pattern> 
    2941  </servlet-mapping> 
    30   <welcome-file-list> 
    31     <welcome-file>index.html</welcome-file> 
    32   </welcome-file-list> 
    3342  <security-constraint> 
    3443    <display-name>Protected</display-name> 
  • approval/trunk/.settings/org.eclipse.jdt.core.prefs

    r220 r249  
    1 #Wed Dec 03 18:33:45 PST 2008 
     1#Sat Mar 28 16:44:37 PDT 2009 
    22org.eclipse.jdt.core.compiler.debug.localVariable=generate 
    33org.eclipse.jdt.core.compiler.compliance=1.5 
    44org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 
    55org.eclipse.jdt.core.compiler.debug.sourceFile=generate 
    6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 
     6org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 
    77org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 
    88eclipse.preferences.version=1 
    99org.eclipse.jdt.core.compiler.debug.lineNumber=generate 
    1010org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 
    11 org.eclipse.jdt.core.compiler.source=1.3 
     11org.eclipse.jdt.core.compiler.source=1.5 
    1212org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 
  • approval/trunk/pom.xml

    r243 r249  
    77        <artifactId>approval</artifactId> 
    88        <name>approval</name> 
    9         <version>1.0</version> 
     9        <version>1.1</version> 
    1010        <description> 
    1111                The approval.jar file contains all of the Java classes and resources 
    12                 needed 
    13                 by other applications that interface with the Approval System. 
    14   </description> 
     12                needed by other applications that interface with the Approval System. 
     13    </description> 
    1514 
    1615        <parent> 
     
    9998                </plugins> 
    10099        </reporting> 
     100 
    101101        <build> 
    102102                <defaultGoal>install</defaultGoal> 
     
    110110                        </plugin> 
    111111                </plugins> 
     112    <resources> 
     113      <resource> 
     114        <directory>src/main/resources</directory> 
     115      </resource> 
     116      <resource> 
     117        <directory>src/main/java</directory> 
     118        <includes> 
     119          <include>**/*.xml</include> 
     120        </includes> 
     121      </resource> 
     122    </resources> 
     123    <testResources> 
     124      <testResource> 
     125        <directory>src/test/resources</directory> 
     126      </testResource> 
     127      <testResource> 
     128        <directory>src/test/spring</directory> 
     129        <includes> 
     130          <include>**/*.xml</include> 
     131        </includes> 
     132      </testResource> 
     133    </testResources> 
    112134        </build> 
     135 
    113136        <dependencies> 
    114137                <dependency> 
     
    128151                        <version>3.2.6.ga</version> 
    129152                </dependency> 
     153        <dependency> 
     154          <groupId>org.springframework</groupId> 
     155          <artifactId>spring</artifactId> 
     156          <version>2.5.6</version> 
     157        </dependency> 
     158    <dependency> 
     159      <groupId>mysql</groupId> 
     160      <artifactId>mysql-connector-java</artifactId> 
     161      <version>5.1.6</version> 
     162      <scope>test</scope> 
     163    </dependency> 
    130164        </dependencies> 
    131165 
  • approval/trunk/src/main/java/org/restafarian/approval/beans/RequestForApproval.java

    r11 r249  
    66import java.util.Set; 
    77 
     8import org.restafarian.core.beans.PersistentBeanBase; 
    89import org.restafarian.core.beans.Person; 
    910 
     
    1112 * <p>This entity bean defines a single Request for Approval (RFA).</p> 
    1213 */ 
    13 public class RequestForApproval { 
     14public class RequestForApproval extends PersistentBeanBase { 
     15        private static final long serialVersionUID = 1; 
    1416        public static final String ACTION_APPROVE = "Approve"; 
    1517        public static final String ACTION_CANCEL = "Cancel"; 
     
    2224        public static final String STATE_RETURNED = "Returned"; 
    2325        public static final String STATE_SUBMITTED = "Submitted"; 
    24         public static final Set VALID_ACTIONS = getValidActions(); 
    25         public static final Set VALID_STATES = getValidStates(); 
     26        public static final Set<String> VALID_ACTIONS = getValidActions(); 
     27        public static final Set<String> VALID_STATES = getValidStates(); 
    2628        private int id = -1; 
    2729        private String type = null; 
     
    3234        private Person author = null; 
    3335        private Date dateTime = null; 
    34         private Set approvers = null; 
    35         private Set actions = null; 
     36        private Set<RequestForApprovalApprover> approvers = null; 
     37        private Set<RequestForApprovalAction> actions = null; 
    3638 
    3739        /** 
     
    4042         * @return the list of valid actions 
    4143         */ 
    42         private static Set getValidActions() { 
    43                 Set actions = new HashSet(); 
     44        private static Set<String> getValidActions() { 
     45                Set<String> actions = new HashSet<String>(); 
    4446                 
    4547                actions.add(RequestForApproval.ACTION_APPROVE); 
     
    5759         * @return the list of valid states 
    5860         */ 
    59         private static Set getValidStates() { 
    60                 Set states = new HashSet(); 
     61        private static Set<String> getValidStates() { 
     62                Set<String> states = new HashSet<String>(); 
    6163                 
    6264                states.add(RequestForApproval.STATE_APPROVED); 
     
    7476        public void addAction(RequestForApprovalAction action) { 
    7577                if (actions == null) { 
    76                         actions = new HashSet(); 
     78                        actions = new HashSet<RequestForApprovalAction>(); 
    7779                } 
    7880                action.setRfaId(id); 
     
    8587        public void addApprover(RequestForApprovalApprover approver) { 
    8688                if (approvers == null) { 
    87                         approvers = new HashSet(); 
     89                        approvers = new HashSet<RequestForApprovalApprover>(); 
    8890                } 
    8991                approver.setRfaId(id); 
     
    98100 
    99101                if (approvers != null && approverId != null) { 
    100                         Iterator i = approvers.iterator(); 
     102                        Iterator<RequestForApprovalApprover> i = approvers.iterator(); 
    101103                        while (i.hasNext()) { 
    102                                 RequestForApprovalApprover thisApprover = (RequestForApprovalApprover) i.next(); 
     104                                RequestForApprovalApprover thisApprover = i.next(); 
    103105                                if (approverId.equalsIgnoreCase(thisApprover.getApprover().getId())) { 
    104106                                        approver = thisApprover; 
     
    110112        } 
    111113 
    112         public Set getActions() { 
     114        public Set<RequestForApprovalAction> getActions() { 
    113115                return actions; 
    114116        } 
    115117 
    116         public void setActions(Set actions) { 
     118        public void setActions(Set<RequestForApprovalAction> actions) { 
    117119                this.actions = actions; 
    118120        } 
    119121 
    120         public Set getApprovers() { 
     122        public Set<RequestForApprovalApprover> getApprovers() { 
    121123                return approvers; 
    122124        } 
    123125 
    124         public void setApprovers(Set approvers) { 
     126        public void setApprovers(Set<RequestForApprovalApprover> approvers) { 
    125127                this.approvers = approvers; 
    126128        } 
  • approval/trunk/src/main/java/org/restafarian/approval/beans/RequestForApprovalAction.java

    r11 r249  
    33import java.util.Date; 
    44 
     5import org.restafarian.core.beans.PersistentBeanBase; 
    56import org.restafarian.core.beans.Person; 
    67 
     
    89 * <p>This entity bean defines a single Request for Approval Action.</p> 
    910 */ 
    10 public class RequestForApprovalAction { 
     11public class RequestForApprovalAction extends PersistentBeanBase { 
     12        private static final long serialVersionUID = 1; 
    1113        private int id = -1; 
    1214        private int rfaId = -1; 
  • approval/trunk/src/main/java/org/restafarian/approval/beans/RequestForApprovalApprover.java

    r11 r249  
    55import java.util.List; 
    66 
     7import org.restafarian.core.beans.PersistentBeanBase; 
    78import org.restafarian.core.beans.Person; 
    89 
     
    1011 * <p>This entity bean defines a single Request for Approval Approver.</p> 
    1112 */ 
    12 public class RequestForApprovalApprover { 
     13public class RequestForApprovalApprover extends PersistentBeanBase { 
     14        private static final long serialVersionUID = 1; 
    1315        private int id = -1; 
    1416        private int rfaId = -1; 
    1517        private Person approver = null; 
    16         private List actions = null; 
     18        private List<String> actions = null; 
    1719 
    1820        /** 
     
    3638                if (actions != null) { 
    3739                        String separator = ""; 
    38                         Iterator i = actions.iterator(); 
     40                        Iterator<String> i = actions.iterator(); 
    3941                        while (i.hasNext()) { 
    4042                                buffer.append(separator); 
     
    5355         */ 
    5456        public void setActionList(String actionList) { 
    55                 actions = new ArrayList(); 
     57                actions = new ArrayList<String>(); 
    5658                if (actionList != null) { 
    5759                        String[] actionArray = actionList.split(","); 
     
    6971        public void addAction(String action) { 
    7072                if (actions == null) { 
    71                         actions = new ArrayList(); 
     73                        actions = new ArrayList<String>(); 
    7274                } 
    7375                if (!actions.contains(action) && RequestForApproval.VALID_ACTIONS.contains(action)) { 
     
    7678        } 
    7779 
    78         public List getActions() { 
     80        public List<String> getActions() { 
    7981                return actions; 
    8082        } 
    8183 
    82         public void setActions(List actions) { 
     84        public void setActions(List<String> actions) { 
    8385                this.actions = actions; 
    8486        } 
  • approval/trunk/src/main/java/org/restafarian/approval/service/impl

    • Property svn:mergeinfo set
  • approval/trunk/src/main/java/org/restafarian/approval/service/impl/RestServiceManager.java

    r80 r249  
    1 package org.restafarian.approval.data
     1package org.restafarian.approval.service.impl
    22 
    33import java.util.HashMap; 
     
    2525         * @return a Map containing two elements: 1) the HTTP Response Code and 2) the response body 
    2626         */ 
    27         public static Map post(String url, Map parameters, HttpServletRequest req) { 
    28                 Map returnData = new HashMap(); 
     27        public static Map<String,Object> post(String url, Map<String,String> parameters, HttpServletRequest req) { 
     28                Map<String,Object> returnData = new HashMap<String,Object>(); 
    2929 
    3030                returnData.put("statusCode", new Integer(0)); 
     
    4747                if (size > 0) { 
    4848                        int index = 0; 
    49                         Iterator i = parameters.keySet().iterator(); 
     49                        Iterator<String> i = parameters.keySet().iterator(); 
    5050                        while (i.hasNext()) { 
    51                                 String name = (String) i.next(); 
    52                                 dataToPost[index] = new NameValuePair(name, (String) parameters.get(name)); 
     51                                String name = i.next(); 
     52                                dataToPost[index] = new NameValuePair(name, parameters.get(name)); 
    5353                                index++; 
    5454                        } 
  • core/trunk/src/test/java/org/restafarian/core/dao/LookupTableEntryDaoTest.java

    r228 r249  
    1515        } 
    1616 
    17         public void testInsertLookupTableEntry() { 
     17        public void testLookupTableEntry() { 
    1818                Date rightNow = new Date(); 
    1919                String userId = "LookupTableEntryDaoTest"; 
     
    3131 
    3232                assertTrue(dao.findAll().size() >= 1); 
    33         } 
    3433 
    35         public void testInsertLookupTableEntryWithProperties() { 
    36                 Date rightNow = new Date(); 
    37                 String userId = "LookupTableEntryDaoTest"; 
     34                rightNow = new Date(); 
     35                userId = "LookupTableEntryDaoTest"; 
    3836                lookupTableEntry = new LookupTableEntry(); 
    3937                lookupTableEntry.setContext("testonly"); 
     
    5149 
    5250                assertTrue(dao.findAll().size() >= 2); 
    53         } 
    5451 
    55         public void testFindByTableIdEntryId() { 
    5652                // find test 
    5753                assertTrue("Expected entry \"test/test\" not found in database.", dao.findByContextTableEntry("testonly", "test", "test") != null); 
     
    5955                // find test2 
    6056                assertTrue("Expected entry \"test/test2\" not found in database.", dao.findByContextTableEntry("testonly", "test", "test2") != null); 
    61         } 
    6257 
    63         public void testFindByExample() throws Exception { 
    6458                // find test 
    6559                lookupTableEntry = new LookupTableEntry(); 
     
    7771                entries = dao.findByExample(lookupTableEntry); 
    7872                assertTrue(entries != null && entries.size() > 0); 
    79         } 
    8073 
    81         public void testFindByProperty() throws Exception { 
    8274                // find test 
    83                 List<LookupTableEntry> entries = dao.findByProperty("entryId", "test"); 
     75                entries = dao.findByProperty("entryId", "test"); 
    8476                assertTrue(entries != null && entries.size() > 0); 
    8577 
     
    8779                entries = dao.findByProperty("entryId", "test2"); 
    8880                assertTrue(entries != null && entries.size() > 0); 
    89         } 
    9081 
    91         public void testRemoveLookupTableEntries() throws Exception { 
    9282                // remove testtable 
    9383                log.debug("removing lookupTableEntry test ..."); 
  • example-web/trunk/src/main/java/org/restafarian/example/servlets/LeaveRequestEntryServlet.java

    r30 r249  
    1818import org.restafarian.approval.beans.RequestForApprovalAction; 
    1919import org.restafarian.approval.beans.RequestForApprovalApprover; 
    20 import org.restafarian.approval.data.RequestForApprovalManager; 
     20import org.restafarian.approval.manager.RequestForApprovalManager; 
    2121import org.restafarian.core.beans.Person; 
    2222import org.restafarian.core.security.AuthenticatedUserManager; 
     
    3030        private static SessionFactory sessionFactory; 
    3131        private Log log = LogFactory.getLog(getClass()); 
     32        private RequestForApprovalManager requestForApprovalManager = null; 
    3233 
    3334        static { 
     
    111112                approver.addAction(RequestForApproval.ACTION_CANCEL); 
    112113                rfa.addApprover(approver); 
    113                 RequestForApprovalManager.insertRequestForApproval(rfa); 
     114                requestForApprovalManager.save(rfa); 
    114115 
    115116                req.getRequestDispatcher("leave_request_posted.html").forward(req, res); 
     
    133134                return lr; 
    134135        } 
     136 
     137        /** 
     138         * @return the requestForApprovalManager 
     139         */ 
     140        public RequestForApprovalManager getRequestForApprovalManager() { 
     141                return requestForApprovalManager; 
     142        } 
     143 
     144        /** 
     145         * @param requestForApprovalManager the requestForApprovalManager to set 
     146         */ 
     147        public void setRequestForApprovalManager( 
     148                        RequestForApprovalManager requestForApprovalManager) { 
     149                this.requestForApprovalManager = requestForApprovalManager; 
     150        } 
    135151} 
  • notify/trunk/src/test/spring/context/applicationContext-hibernate.xml

    r214 r249  
    2020        <property name="mappingResources"> 
    2121            <list> 
    22                 <value>org/restafarian/notify/beans/NoticeAudit.hbm.xml</value> 
    23                 <value>org/restafarian/notify/beans/NoticeTemplate.hbm.xml</value> 
     22                <value>org/restafarian/approval/beans/RequestForApproval.hbm.xml</value> 
     23                <value>org/restafarian/approval/beans/RequestForApprovalAction.hbm.xml</value> 
     24                <value>org/restafarian/approval/beans/RequestForApprovalApprover.hbm.xml</value> 
    2425            </list> 
    2526        </property> 
     
    3637    </bean> 
    3738 
    38     <bean id="noticeTemplateDao" class="org.restafarian.notify.dao.hibernate.NoticeTemplateDaoHibernate"> 
    39         <constructor-arg><ref bean="sessionFactory"/></constructor-arg> 
    40     </bean> 
    41  
    42     <bean id="noticeAuditDao" class="org.restafarian.notify.dao.hibernate.NoticeAuditDaoHibernate"> 
     39    <bean id="requestForApprovalDao" class="org.restafarian.approval.dao.hibernate.RequestForApprovalDaoHibernate"> 
    4340        <constructor-arg><ref bean="sessionFactory"/></constructor-arg> 
    4441    </bean> 
  • notify/trunk/src/test/spring/context/applicationContext.xml

    r223 r249  
    2929    </tx:advice> 
    3030 
    31     <bean id="noticeTemplateManager" class="org.restafarian.notify.manager.impl.NoticeTemplateManagerImpl"> 
    32         <property name="noticeTemplateDao" ref="noticeTemplateDao"/> 
    33     </bean> 
    34  
    35     <bean id="noticeAuditManager" class="org.restafarian.notify.manager.impl.NoticeAuditManagerImpl"> 
    36         <property name="noticeAuditDao" ref="noticeAuditDao"/> 
    37     </bean> 
    38  
    39     <bean id="emailCourier" class="org.restafarian.notify.service.impl.EmailCourier"> 
    40         <property name="smtpHostName" value="localhost"/> 
    41         <property name="smtpPort" value="25"/> 
    42         <property name="defaultFromAddress" value="no-reply@restafarian.org"/> 
    43     </bean> 
    44  
    45     <bean id="messageCourierFactory" class="org.restafarian.notify.service.impl.MessageCourierFactoryImpl"> 
    46         <property name="messageCourierMap"> 
    47             <map> 
    48                 <entry> 
    49                     <key> 
    50                         <value>email</value> 
    51                     </key> 
    52                     <ref bean="emailCourier" /> 
    53                 </entry> 
    54             </map> 
    55         </property> 
    56     </bean> 
    57  
    58     <bean id="deliveryService" class="org.restafarian.notify.service.impl.DeliveryServiceImpl"> 
    59         <property name="messageCourierFactory" ref="messageCourierFactory"/> 
    60     </bean> 
    61  
    62     <bean id="notifier" class="org.restafarian.notify.service.impl.NotifierImpl"> 
    63         <property name="noticeTemplateManager" ref="noticeTemplateManager"/> 
    64         <property name="noticeAuditManager" ref="noticeAuditManager"/> 
    65         <property name="deliveryService" ref="deliveryService"/> 
    66         <property name="auditNotifications" value="true"/> 
    67         <property name="defaultTemplateContext" value="global"/> 
    68     </bean> 
     31    <!-- bean id="requestForApprovalManager" class="org.restafarian.approval.manager.impl.NoticeTemplateManagerImpl" --> 
     32        <!-- property name="requestForApprovalDao" ref="requestForApprovalDao"/ --> 
     33    <!-- /bean --> 
    6934 
    7035</beans>