@Test public void testDeletedRecordRemainsAvailableinDBForUndelete() throws TabDeletionException { TabGroup fordsTabGroup = jpaTabGroupMapper.findById(fordsStartPageId); Tab fordTab1 = jpaTabMapper.findById(fordsFirstTabId); long pageId = fordsTabGroup.getId(); long tabId = fordTab1.getId(); int tabIndex = fordTab1.getTabIndex(); jpaTabGroupMapper.deleteTab(fordTab1); jpaTabGroupMapper.flush(); Boolean deletedFlag = (Boolean) getEntityManager().createQuery( "select deleted from Tab where id = :tabId and " + "tabGroupId = :tabGroupId and deleted = true and tabIndex = :tabIndex").setParameter( "tabGroupId", pageId).setParameter("tabId", tabId).setParameter("tabIndex", tabIndex).getSingleResult(); assertEquals("Expected that after deleting a tab, it's still tied to the " + "tabGroup, the tabIndex is null, and the tab is marked as deleted", true, deletedFlag.booleanValue()); }
public void deleteTab(final Tab tab) throws TabDeletionException { logger.debug("Attempting to delete the tab with id=" + tab.getId()); TabGroup tabGroup = null; try { tabGroup = getTabGroupByTabId(tab.getId(), false); } catch (Exception ex) { throw new TabDeletionException("Could not find either the specified Tab or TabGroup", ex, tab); } if (tabGroup.getTabs().size() > 1) { tabGroup.getTabs().remove(tab); } markTabAsDeleted(tabGroup, tab); cleanUpDeletedTabs(); }
TabGroupMapper extends DomainEntityMapper<TabGroup> { public void deleteTab(final Tab tab) throws TabDeletionException { logger.debug("Attempting to delete the tab with id=" + tab.getId()); TabGroup tabGroup = null; try { tabGroup = getTabGroupByTabId(tab.getId(), false); } catch (Exception ex) { throw new TabDeletionException("Could not find either the specified Tab or TabGroup", ex, tab); } if (tabGroup.getTabs().size() > 1) { tabGroup.getTabs().remove(tab); } markTabAsDeleted(tabGroup, tab); cleanUpDeletedTabs(); } }
TabGroupMapper extends DomainEntityMapper<TabGroup> { public void deleteTab(final Tab tab) throws TabDeletionException { logger.debug("Attempting to delete the tab with id=" + tab.getId()); TabGroup tabGroup = null; try { tabGroup = getTabGroupByTabId(tab.getId(), false); } catch (Exception ex) { throw new TabDeletionException("Could not find either the specified Tab or TabGroup", ex, tab); } if (tabGroup.getTabs().size() > 1) { tabGroup.getTabs().remove(tab); } markTabAsDeleted(tabGroup, tab); cleanUpDeletedTabs(); } TabGroupMapper(final QueryOptimizer inQueryOptimizer); }
TabGroupMapper extends DomainEntityMapper<TabGroup> { public void deleteTab(final Tab tab) throws TabDeletionException { logger.debug("Attempting to delete the tab with id=" + tab.getId()); TabGroup tabGroup = null; try { tabGroup = getTabGroupByTabId(tab.getId(), false); } catch (Exception ex) { throw new TabDeletionException("Could not find either the specified Tab or TabGroup", ex, tab); } if (tabGroup.getTabs().size() > 1) { tabGroup.getTabs().remove(tab); } markTabAsDeleted(tabGroup, tab); cleanUpDeletedTabs(); } TabGroupMapper(final QueryOptimizer inQueryOptimizer); void setUndeleteTabWindowInMinutes(final int undeleteWindowInMinutes); void deleteTab(final Tab tab); Tab undeleteTab(final long tabId); TabGroup getTabGroupByTabId(final long tabId, final boolean isDeleted); long getTabCountForTemplate(final TabTemplate template); }
TabGroupMapper extends DomainEntityMapper<TabGroup> { public void deleteTab(final Tab tab) throws TabDeletionException { logger.debug("Attempting to delete the tab with id=" + tab.getId()); TabGroup tabGroup = null; try { tabGroup = getTabGroupByTabId(tab.getId(), false); } catch (Exception ex) { throw new TabDeletionException("Could not find either the specified Tab or TabGroup", ex, tab); } if (tabGroup.getTabs().size() > 1) { tabGroup.getTabs().remove(tab); } markTabAsDeleted(tabGroup, tab); cleanUpDeletedTabs(); } TabGroupMapper(final QueryOptimizer inQueryOptimizer); void setUndeleteTabWindowInMinutes(final int undeleteWindowInMinutes); void deleteTab(final Tab tab); Tab undeleteTab(final long tabId); TabGroup getTabGroupByTabId(final long tabId, final boolean isDeleted); long getTabCountForTemplate(final TabTemplate template);  }