use of org.crosswire.common.progress.Progress in project step by STEPBible.
the class JSwordModuleServiceImpl method getProgressOnInstallation.
@Override
public double getProgressOnInstallation(final String version) {
notBlank(version, "The book name provided was blank", SERVICE_VALIDATION_ERROR);
if (isInstalled(version)) {
return 1;
}
// not yet installed (or at least wasn't on the lines above, so check job list
String longVersionName = this.versionResolver.getLongName(version);
final Iterator<Progress> iterator = JobManager.iterator();
while (iterator.hasNext()) {
final Progress p = iterator.next();
final String expectedJobName = format(Progress.INSTALL_BOOK, longVersionName);
if (expectedJobName.equals(p.getJobID())) {
if (p.isFinished()) {
return 1;
}
return (double) p.getWorkDone() / p.getTotalWork();
}
}
// the job may have completed by now, while we did the search, so do a final check
if (isInstalled(version)) {
return 1;
}
throw new StepInternalException("An unknown error has occurred: the job has disappeared of the job list, " + "but the module is not installed");
}
use of org.crosswire.common.progress.Progress in project step by STEPBible.
the class JSwordModuleServiceImpl method getProgressOnIndexing.
@Override
public double getProgressOnIndexing(final String bookName) {
notBlank(bookName, "The book name to be indexed was blank", SERVICE_VALIDATION_ERROR);
if (isIndexed(bookName)) {
return 1;
}
// not yet installed (or at least wasn't on the lines above, so check job list
String longVersionName = this.versionResolver.getLongName(bookName);
final Iterator<Progress> iterator = JobManager.iterator();
while (iterator.hasNext()) {
final Progress p = iterator.next();
final String expectedJobName = format(CURRENT_BIBLE_INDEX_JOB, longVersionName);
if (expectedJobName.equals(p.getJobName())) {
if (p.isFinished()) {
return 1;
}
return (double) p.getWork() / p.getTotalWork();
}
}
// the job may have completed by now, while we did the search, so do a final check
if (isIndexed(bookName)) {
return 1;
}
throw new StepInternalException("An unknown error has occurred: the job has disappeared of the job list, " + "but the module is not installed");
}
use of org.crosswire.common.progress.Progress in project step by STEPBible.
the class DirectoryListingInstaller method reloadBookList.
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#reloadBookList()
*/
public void reloadBookList() throws InstallException {
// TRANSLATOR: Progress label for downloading one or more files.
String jobName = JSMsg.gettext("Downloading files");
Progress job = JobManager.createJob(Progress.RELOAD_BOOK_LIST, jobName, Thread.currentThread());
job.beginJob(jobName);
try {
loaded = false;
loadCachedIndex();
} catch (InstallException ex) {
job.cancel();
throw ex;
} finally {
job.done();
}
}
Aggregations