@Test public void testIsVaultForReview() { System.out.println("Test if vault due for review"); assertTrue(isVaultForReview(0, -9)); assertFalse(isVaultForReview(-1, 0)); assertTrue(isVaultForReview(+1, -9)); assertFalse(isVaultForReview(+12, -9)); }
public boolean isVaultForReview(Vault vault) { Date today = new Date(); Calendar c = Calendar.getInstance(); c.setTime(vault.getReviewDate()); c.add(Calendar.MONTH, x); Date reviewDateMinusx = c.getTime(); if (today.after(reviewDateMinusx)) { boolean currentReviewExists = false; for (VaultReview vr : vault.getVaultReviews()) { if ((vr.getActionedDate() != null) && ((vr.getActionedDate().after(reviewDateMinusx)))) { currentReviewExists = true; } } if (!currentReviewExists) { return true; } } return false; }
VaultsReviewService { public boolean isVaultForReview(Vault vault) { Date today = new Date(); Calendar c = Calendar.getInstance(); c.setTime(vault.getReviewDate()); c.add(Calendar.MONTH, x); Date reviewDateMinusx = c.getTime(); if (today.after(reviewDateMinusx)) { boolean currentReviewExists = false; for (VaultReview vr : vault.getVaultReviews()) { if ((vr.getActionedDate() != null) && ((vr.getActionedDate().after(reviewDateMinusx)))) { currentReviewExists = true; } } if (!currentReviewExists) { return true; } } return false; } }
VaultsReviewService { public boolean isVaultForReview(Vault vault) { Date today = new Date(); Calendar c = Calendar.getInstance(); c.setTime(vault.getReviewDate()); c.add(Calendar.MONTH, x); Date reviewDateMinusx = c.getTime(); if (today.after(reviewDateMinusx)) { boolean currentReviewExists = false; for (VaultReview vr : vault.getVaultReviews()) { if ((vr.getActionedDate() != null) && ((vr.getActionedDate().after(reviewDateMinusx)))) { currentReviewExists = true; } } if (!currentReviewExists) { return true; } } return false; }  }
VaultsReviewService { public boolean isVaultForReview(Vault vault) { Date today = new Date(); Calendar c = Calendar.getInstance(); c.setTime(vault.getReviewDate()); c.add(Calendar.MONTH, x); Date reviewDateMinusx = c.getTime(); if (today.after(reviewDateMinusx)) { boolean currentReviewExists = false; for (VaultReview vr : vault.getVaultReviews()) { if ((vr.getActionedDate() != null) && ((vr.getActionedDate().after(reviewDateMinusx)))) { currentReviewExists = true; } } if (!currentReviewExists) { return true; } } return false; }  void setVaultReviewDAO(VaultReviewDAO vaultReviewDAO); VaultReview createVaultReview(Vault vault); void addVaultReview(VaultReview vaultReview); List<VaultReview> getVaultReviews(); VaultReview getVaultReview(String vaultReviewID); List<VaultReview> search(String query); void updateVaultReview(VaultReview vaultReview); List<Vault> getVaultsForReview(List<Vault> vaults); boolean isVaultForReview(Vault vault); boolean dueForReviewEmail(Vault vault); }
VaultsReviewService { public boolean isVaultForReview(Vault vault) { Date today = new Date(); Calendar c = Calendar.getInstance(); c.setTime(vault.getReviewDate()); c.add(Calendar.MONTH, x); Date reviewDateMinusx = c.getTime(); if (today.after(reviewDateMinusx)) { boolean currentReviewExists = false; for (VaultReview vr : vault.getVaultReviews()) { if ((vr.getActionedDate() != null) && ((vr.getActionedDate().after(reviewDateMinusx)))) { currentReviewExists = true; } } if (!currentReviewExists) { return true; } } return false; }  void setVaultReviewDAO(VaultReviewDAO vaultReviewDAO); VaultReview createVaultReview(Vault vault); void addVaultReview(VaultReview vaultReview); List<VaultReview> getVaultReviews(); VaultReview getVaultReview(String vaultReviewID); List<VaultReview> search(String query); void updateVaultReview(VaultReview vaultReview); List<Vault> getVaultsForReview(List<Vault> vaults); boolean isVaultForReview(Vault vault); boolean dueForReviewEmail(Vault vault);  }