@Test public void whenAFormIsSoftDeleted_isNotOnDevice() throws Exception { formsRepository.save(new Form.Builder() .id(1L) .jrFormId("form-1") .jrVersion("server") .md5Hash("form-1-hash") .deleted(true) .build()); List<ServerFormDetails> serverFormDetails = fetcher.fetchFormDetails(); assertThat(serverFormDetails.get(0).isNotOnDevice(), is(true)); assertThat(serverFormDetails.get(1).isNotOnDevice(), is(true)); }
public List<ServerFormDetails> fetchFormDetails() throws FormApiException { diskFormsSynchronizer.synchronize(); List<FormListItem> formListItems = formListAPI.fetchFormList(); List<ServerFormDetails> serverFormDetailsList = new ArrayList<>(); for (FormListItem listItem : formListItems) { boolean isNewerFormVersionAvailable = false; boolean areNewerMediaFilesAvailable = false; ManifestFile manifestFile = null; boolean thisFormAlreadyDownloaded = isThisFormAlreadyDownloaded(listItem.getFormID()); if (thisFormAlreadyDownloaded) { isNewerFormVersionAvailable = isNewerFormVersionAvailable(MultiFormDownloader.getMd5Hash(listItem.getHashWithPrefix())); if (!isNewerFormVersionAvailable && listItem.getManifestURL() != null) { manifestFile = getManifestFile(formListAPI, listItem.getManifestURL()); if (manifestFile != null) { List<MediaFile> newMediaFiles = manifestFile.getMediaFiles(); if (newMediaFiles != null && !newMediaFiles.isEmpty()) { areNewerMediaFilesAvailable = areNewerMediaFilesAvailable(listItem.getFormID(), listItem.getVersion(), newMediaFiles); } } } } String manifestFileHash = manifestFile != null ? manifestFile.getHash() : null; ServerFormDetails serverFormDetails = new ServerFormDetails( listItem.getName(), listItem.getDownloadURL(), listItem.getManifestURL(), listItem.getFormID(), listItem.getVersion(), listItem.getHashWithPrefix(), manifestFileHash, !thisFormAlreadyDownloaded, isNewerFormVersionAvailable || areNewerMediaFilesAvailable); serverFormDetailsList.add(serverFormDetails); } return serverFormDetailsList; }
ServerFormsDetailsFetcher { public List<ServerFormDetails> fetchFormDetails() throws FormApiException { diskFormsSynchronizer.synchronize(); List<FormListItem> formListItems = formListAPI.fetchFormList(); List<ServerFormDetails> serverFormDetailsList = new ArrayList<>(); for (FormListItem listItem : formListItems) { boolean isNewerFormVersionAvailable = false; boolean areNewerMediaFilesAvailable = false; ManifestFile manifestFile = null; boolean thisFormAlreadyDownloaded = isThisFormAlreadyDownloaded(listItem.getFormID()); if (thisFormAlreadyDownloaded) { isNewerFormVersionAvailable = isNewerFormVersionAvailable(MultiFormDownloader.getMd5Hash(listItem.getHashWithPrefix())); if (!isNewerFormVersionAvailable && listItem.getManifestURL() != null) { manifestFile = getManifestFile(formListAPI, listItem.getManifestURL()); if (manifestFile != null) { List<MediaFile> newMediaFiles = manifestFile.getMediaFiles(); if (newMediaFiles != null && !newMediaFiles.isEmpty()) { areNewerMediaFilesAvailable = areNewerMediaFilesAvailable(listItem.getFormID(), listItem.getVersion(), newMediaFiles); } } } } String manifestFileHash = manifestFile != null ? manifestFile.getHash() : null; ServerFormDetails serverFormDetails = new ServerFormDetails( listItem.getName(), listItem.getDownloadURL(), listItem.getManifestURL(), listItem.getFormID(), listItem.getVersion(), listItem.getHashWithPrefix(), manifestFileHash, !thisFormAlreadyDownloaded, isNewerFormVersionAvailable || areNewerMediaFilesAvailable); serverFormDetailsList.add(serverFormDetails); } return serverFormDetailsList; } }
ServerFormsDetailsFetcher { public List<ServerFormDetails> fetchFormDetails() throws FormApiException { diskFormsSynchronizer.synchronize(); List<FormListItem> formListItems = formListAPI.fetchFormList(); List<ServerFormDetails> serverFormDetailsList = new ArrayList<>(); for (FormListItem listItem : formListItems) { boolean isNewerFormVersionAvailable = false; boolean areNewerMediaFilesAvailable = false; ManifestFile manifestFile = null; boolean thisFormAlreadyDownloaded = isThisFormAlreadyDownloaded(listItem.getFormID()); if (thisFormAlreadyDownloaded) { isNewerFormVersionAvailable = isNewerFormVersionAvailable(MultiFormDownloader.getMd5Hash(listItem.getHashWithPrefix())); if (!isNewerFormVersionAvailable && listItem.getManifestURL() != null) { manifestFile = getManifestFile(formListAPI, listItem.getManifestURL()); if (manifestFile != null) { List<MediaFile> newMediaFiles = manifestFile.getMediaFiles(); if (newMediaFiles != null && !newMediaFiles.isEmpty()) { areNewerMediaFilesAvailable = areNewerMediaFilesAvailable(listItem.getFormID(), listItem.getVersion(), newMediaFiles); } } } } String manifestFileHash = manifestFile != null ? manifestFile.getHash() : null; ServerFormDetails serverFormDetails = new ServerFormDetails( listItem.getName(), listItem.getDownloadURL(), listItem.getManifestURL(), listItem.getFormID(), listItem.getVersion(), listItem.getHashWithPrefix(), manifestFileHash, !thisFormAlreadyDownloaded, isNewerFormVersionAvailable || areNewerMediaFilesAvailable); serverFormDetailsList.add(serverFormDetails); } return serverFormDetailsList; } ServerFormsDetailsFetcher(FormsRepository formsRepository,
                                     MediaFileRepository mediaFileRepository,
                                     FormListApi formListAPI,
                                     DiskFormsSynchronizer diskFormsSynchronizer); }
ServerFormsDetailsFetcher { public List<ServerFormDetails> fetchFormDetails() throws FormApiException { diskFormsSynchronizer.synchronize(); List<FormListItem> formListItems = formListAPI.fetchFormList(); List<ServerFormDetails> serverFormDetailsList = new ArrayList<>(); for (FormListItem listItem : formListItems) { boolean isNewerFormVersionAvailable = false; boolean areNewerMediaFilesAvailable = false; ManifestFile manifestFile = null; boolean thisFormAlreadyDownloaded = isThisFormAlreadyDownloaded(listItem.getFormID()); if (thisFormAlreadyDownloaded) { isNewerFormVersionAvailable = isNewerFormVersionAvailable(MultiFormDownloader.getMd5Hash(listItem.getHashWithPrefix())); if (!isNewerFormVersionAvailable && listItem.getManifestURL() != null) { manifestFile = getManifestFile(formListAPI, listItem.getManifestURL()); if (manifestFile != null) { List<MediaFile> newMediaFiles = manifestFile.getMediaFiles(); if (newMediaFiles != null && !newMediaFiles.isEmpty()) { areNewerMediaFilesAvailable = areNewerMediaFilesAvailable(listItem.getFormID(), listItem.getVersion(), newMediaFiles); } } } } String manifestFileHash = manifestFile != null ? manifestFile.getHash() : null; ServerFormDetails serverFormDetails = new ServerFormDetails( listItem.getName(), listItem.getDownloadURL(), listItem.getManifestURL(), listItem.getFormID(), listItem.getVersion(), listItem.getHashWithPrefix(), manifestFileHash, !thisFormAlreadyDownloaded, isNewerFormVersionAvailable || areNewerMediaFilesAvailable); serverFormDetailsList.add(serverFormDetails); } return serverFormDetailsList; } ServerFormsDetailsFetcher(FormsRepository formsRepository,
                                     MediaFileRepository mediaFileRepository,
                                     FormListApi formListAPI,
                                     DiskFormsSynchronizer diskFormsSynchronizer); List<ServerFormDetails> fetchFormDetails(); void updateFormListApi(String url, WebCredentialsUtils webCredentialsUtils); }
ServerFormsDetailsFetcher { public List<ServerFormDetails> fetchFormDetails() throws FormApiException { diskFormsSynchronizer.synchronize(); List<FormListItem> formListItems = formListAPI.fetchFormList(); List<ServerFormDetails> serverFormDetailsList = new ArrayList<>(); for (FormListItem listItem : formListItems) { boolean isNewerFormVersionAvailable = false; boolean areNewerMediaFilesAvailable = false; ManifestFile manifestFile = null; boolean thisFormAlreadyDownloaded = isThisFormAlreadyDownloaded(listItem.getFormID()); if (thisFormAlreadyDownloaded) { isNewerFormVersionAvailable = isNewerFormVersionAvailable(MultiFormDownloader.getMd5Hash(listItem.getHashWithPrefix())); if (!isNewerFormVersionAvailable && listItem.getManifestURL() != null) { manifestFile = getManifestFile(formListAPI, listItem.getManifestURL()); if (manifestFile != null) { List<MediaFile> newMediaFiles = manifestFile.getMediaFiles(); if (newMediaFiles != null && !newMediaFiles.isEmpty()) { areNewerMediaFilesAvailable = areNewerMediaFilesAvailable(listItem.getFormID(), listItem.getVersion(), newMediaFiles); } } } } String manifestFileHash = manifestFile != null ? manifestFile.getHash() : null; ServerFormDetails serverFormDetails = new ServerFormDetails( listItem.getName(), listItem.getDownloadURL(), listItem.getManifestURL(), listItem.getFormID(), listItem.getVersion(), listItem.getHashWithPrefix(), manifestFileHash, !thisFormAlreadyDownloaded, isNewerFormVersionAvailable || areNewerMediaFilesAvailable); serverFormDetailsList.add(serverFormDetails); } return serverFormDetailsList; } ServerFormsDetailsFetcher(FormsRepository formsRepository,
                                     MediaFileRepository mediaFileRepository,
                                     FormListApi formListAPI,
                                     DiskFormsSynchronizer diskFormsSynchronizer); List<ServerFormDetails> fetchFormDetails(); void updateFormListApi(String url, WebCredentialsUtils webCredentialsUtils);  }