@Test public void removeAnnotation() throws Exception { AnnotationImpl a = new AnnotationImpl(); a.setInpoint(10); a.setOutpoint(100); a.setMediapackageId("mp123"); a.setSessionId("session123"); a.setType("ugc"); a.setValue("This is some user generated content"); annotationService.addAnnotation(a); Assert.assertTrue(annotationService.removeAnnotation(a)); Annotation a1FromDb = null; try { a1FromDb = annotationService.getAnnotation(a.getAnnotationId()); } catch (NotFoundException e) { } Assert.assertNull(a1FromDb); }
public boolean removeAnnotation(Annotation a) { EntityManager em = null; EntityTransaction tx = null; try { em = emf.createEntityManager(); tx = em.getTransaction(); tx.begin(); em.remove(em.merge(a)); tx.commit(); return true; } catch (Exception e) { return false; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }
AnnotationServiceJpaImpl implements AnnotationService { public boolean removeAnnotation(Annotation a) { EntityManager em = null; EntityTransaction tx = null; try { em = emf.createEntityManager(); tx = em.getTransaction(); tx.begin(); em.remove(em.merge(a)); tx.commit(); return true; } catch (Exception e) { return false; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } } }
AnnotationServiceJpaImpl implements AnnotationService { public boolean removeAnnotation(Annotation a) { EntityManager em = null; EntityTransaction tx = null; try { em = emf.createEntityManager(); tx = em.getTransaction(); tx.begin(); em.remove(em.merge(a)); tx.commit(); return true; } catch (Exception e) { return false; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }  }
AnnotationServiceJpaImpl implements AnnotationService { public boolean removeAnnotation(Annotation a) { EntityManager em = null; EntityTransaction tx = null; try { em = emf.createEntityManager(); tx = em.getTransaction(); tx.begin(); em.remove(em.merge(a)); tx.commit(); return true; } catch (Exception e) { return false; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }  void setSecurityService(SecurityService securityService); Annotation addAnnotation(Annotation a); boolean removeAnnotation(Annotation a); Annotation changeAnnotation(Annotation a); Annotation getAnnotation(long id); @SuppressWarnings("unchecked") AnnotationList getAnnotations(int offset, int limit); AnnotationList getAnnotationsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit); AnnotationList getAnnotationsByMediapackageId(String mediapackageId, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByTypeAndDay(String type, String day, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByDay(String day, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByType(String type, int offset, int limit); }
AnnotationServiceJpaImpl implements AnnotationService { public boolean removeAnnotation(Annotation a) { EntityManager em = null; EntityTransaction tx = null; try { em = emf.createEntityManager(); tx = em.getTransaction(); tx.begin(); em.remove(em.merge(a)); tx.commit(); return true; } catch (Exception e) { return false; } finally { if (tx.isActive()) { tx.rollback(); } em.close(); } }  void setSecurityService(SecurityService securityService); Annotation addAnnotation(Annotation a); boolean removeAnnotation(Annotation a); Annotation changeAnnotation(Annotation a); Annotation getAnnotation(long id); @SuppressWarnings("unchecked") AnnotationList getAnnotations(int offset, int limit); AnnotationList getAnnotationsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit); AnnotationList getAnnotationsByMediapackageId(String mediapackageId, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByTypeAndDay(String type, String day, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByDay(String day, int offset, int limit); @SuppressWarnings("unchecked") AnnotationList getAnnotationsByType(String type, int offset, int limit); static final String PERSISTENCE_UNIT; }