public void create(EventBean newEvent) throws DAOException { try { Transaction.begin(); EventBean dbEvent = factory.create(); factory.copyInto(newEvent, dbEvent); Transaction.commit(); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }
public EventBean lookup(int id) throws DAOException { try { return factory.lookup(id); } catch (RollbackException e) { throw new DAOException(e); } }
public void create(UserBean user) throws DAOException { String origID = user.getUserID(); try { Transaction.begin(); user.setUserID(user.getUserID().toLowerCase()); UserBean dBUser = factory.create(user.getUserID()); factory.copyInto(user, dBUser); Transaction.commit(); } catch (DuplicateKeyException e) { throw new DAOException("UserID: " + user.getUserID() + "already exists."); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }
public synchronized Course lookup(String courseName) throws MyDAOException { try { return factory.lookup(courseName); } catch (RollbackException e) { throw new MyDAOException(e); } }
public void create(Community community) throws DAOException { try { Transaction.begin(); Community dbcommunity = factory.create(community.getName()); factory.copyInto(community, dbcommunity); Transaction.commit(); } catch (DuplicateKeyException e) { throw new DAOException("Community named " + community.getName() + " already exists."); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }
public UserBean lookup(String userID) throws DAOException { try { return factory.lookup(userID); } catch (RollbackException e) { throw new DAOException(e); } }
public EventBean[] getEventsByLocation(int id) { try { EventBean[] list = factory.match(MatchArg.equals("locationid", id)); return list; } catch (RollbackException e) { throw new DAOException(e); } }
public Community lookup(String name) throws DAOException { try { Community comm = factory.lookup(name); return comm; } catch (RollbackException e) { throw new DAOException(e); } }
public synchronized List<Note> getSelectedCourseNotesList(String courseSelected) throws MyDAOException { BeanFactory<Note> factory; ArrayList<Note> al = new ArrayList<Note>(); try { BeanTable<Note> table = BeanTable.getSQLInstance(Note.class, "fanc_note", jdbcDriver, jdbcURL); factory = table.getFactory(); al = new ArrayList( Arrays.asList(factory.match(MatchArg.equals("courseName", courseSelected)))); } catch (RollbackException e) { throw new MyDAOException(e); } return al; }
public EventBean[] getAllEvents() throws DAOException { try { EventBean[] list = factory.match(); Arrays.sort(list); return list; } catch (RollbackException e) { throw new DAOException(e); } }
public Community[] getCommunityByMovie(String rM) throws DAOException { try { Community[] result = factory.match(MatchArg.contains("relatedMovie", rM)); return result; } catch (RollbackException e) { // TODO Auto-generated catch block throw new DAOException(e); } }
public EventBean[] getMyEvents(String userid) throws DAOException { try { EventBean[] list = factory.match(MatchArg.equals("userid", userid)); Arrays.sort(list); return list; } catch (RollbackException e) { throw new DAOException(e); } }
public void delete(int id, String owner) throws DAOException { try { Transaction.begin(); EventBean p = factory.lookup(id); if (p == null) { throw new DAOException("Event does not exist: id=" + id); } if (!owner.equals(p.getUserId())) { throw new DAOException("Event not owned by " + owner); } factory.delete(id); Transaction.commit(); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }
public Community[] search(String key) throws DAOException { try { Community[] oResults = factory.match(MatchArg.containsIgnoreCase("name", key)); List<Community> list = Arrays.asList(oResults); Collections.sort(list, Community.REVERSE_TIMEORDER); Community[] results = (Community[]) list.toArray(); return results; } catch (RollbackException e) { throw new DAOException(e); } }
public Community[] getAllCommunities() throws DAOException { try { Community[] oResults = factory.match(); List<Community> list = Arrays.asList(oResults); Collections.sort(list, Community.REVERSE_TIMEORDER); Community[] results = (Community[]) list.toArray(); return results; } catch (RollbackException e) { throw new DAOException(e); } }
public void updateUserCount(int x, String name) throws DAOException { try { Transaction.begin(); Community comm = factory.lookup(name); comm.setUserCount(comm.getUserCount() + x); Transaction.commit(); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }
@Override public synchronized List<String> getAllCourses() throws MyDAOException { try { Course[] courseArrList = factory.match(); ArrayList<String> al = new ArrayList<String>(); for (Course course : courseArrList) { al.add(course.getCourseName()); } return al; } catch (RollbackException e) { throw new MyDAOException(e); } }
@Override public synchronized Course createCourse(String courseName, String createdBy) throws MyDAOException { try { Transaction.begin(); Course newCourse = factory.create(courseName); newCourse.setCreatedBy(createdBy); Transaction.commit(); return newCourse; } catch (DuplicateKeyException e) { throw new MyDAOException("A course with this name already exists."); } catch (RollbackException e) { throw new MyDAOException(e); } }
public void setEvent(int eventid, String userid) throws DAOException { try { Transaction.begin(); UserBean dbUser = factory.lookup(userid); if (dbUser == null) { throw new DAOException("User " + userid + " no longer exists"); } dbUser.seteventAttendingID(eventid); Transaction.commit(); } catch (RollbackException e) { throw new DAOException(e); } finally { if (Transaction.isActive()) Transaction.rollback(); } }