use of bio.fkaiser.fit3d.web.model.Fit3DJob in project fit3d by fkaiserbio.
the class SubmitJobView method submit.
public String submit() {
// determine if too many jobs were submitted in current session
int jobCount = getJobCountOfCurrentSession();
if (jobCount > Fit3DWebConstants.JOB_LIMIT) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Too many jobs submitted. Please wait until until some jobs are finished.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
// determine if too many exchanges were defined
if (exchangeDefinitions != null) {
int exchangeCount = (int) exchangeDefinitions.stream().map(ExchangeDefinition::getExchangeAminoAcids).mapToLong(Collection::size).sum();
if (exchangeCount > Fit3DWebConstants.EXCHANGE_LIMIT) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Only " + Fit3DWebConstants.EXCHANGE_LIMIT + " PSEs are allowed. Please use the command line or API version for more complex calculations.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
}
// motif file upload is mandatory
if (!motifFileUploaded) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "A motif file is required.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
// use predefined target list if no one was provided
if (!targetListFileUploaded) {
if (predefinedList == PredefinedList.NONE) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Please select or upload a target list.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
} else {
targetListPath = predefinedList.getPath();
chainTargetList = true;
}
}
Fit3DJobParameters jobParameters = new Fit3DJobParameters();
jobParameters.setAtomFilterType(atomFilterType);
jobParameters.setChainTargetList(chainTargetList);
jobParameters.setPdbTargetList(pdbTargetList);
if (motifPath.endsWith("4cha_motif.pdb")) {
targetListPath = motifPath.getParent().resolve("targets.txt");
logger.info("example run detected, using short target list {}", targetListPath);
motifPath = motifPath.getParent().resolve("4cha_motif.pdb");
}
jobParameters.setMotifPath(motifPath);
jobParameters.setTargetListPath(targetListPath);
jobParameters.setRmsdLimit(rmsdLimit);
jobParameters.setExchangeDefinitions(exchangeDefinitions);
jobParameters.setStatisticalModelType(statisticalModelType);
Fit3DJob job = new Fit3DJob(jobIdentifier, sessionManager.getSessionIdentifier(), determineIpAddress(), description, email, jobPath, jobParameters);
FacesContext facesContext = FacesContext.getCurrentInstance();
Flash flash = facesContext.getExternalContext().getFlash();
flash.put("job", job);
return "success";
}
use of bio.fkaiser.fit3d.web.model.Fit3DJob in project fit3d by fkaiserbio.
the class JobManager method cancelJob.
public void cancelJob(Fit3DJob job) {
UUID jobIdentifier = job.getJobIdentifier();
Optional<Fit3DJob> optionalJob = managedJobs.values().stream().flatMap(Collection::stream).filter(managedJob -> managedJob.getJobIdentifier().equals(jobIdentifier)).findFirst();
optionalJob.ifPresent(Fit3DJob::cancel);
if (optionalJob.isPresent()) {
Fit3DJob managedJob = optionalJob.get();
managedJob.cancel();
logger.info("sent cancel signal to job {}", managedJob);
} else {
logger.info("job with identifier not found {}", job.getJobIdentifier());
}
}
use of bio.fkaiser.fit3d.web.model.Fit3DJob in project fit3d by fkaiserbio.
the class JobManager method addJob.
public void addJob(Fit3DJob job) {
Document jobObject = JobConverter.toDocument(job);
mongoCollection.insertOne(jobObject);
jobLoadManager.updateTotalJobs();
logger.info("new job {} added to database", job);
// add jobs to existing jobs of current session
UUID sessionIdentifier = job.getSessionIdentifier();
if (managedJobs.containsKey(sessionIdentifier)) {
managedJobs.get(sessionIdentifier).add(job);
} else {
List<Fit3DJob> jobs = new ArrayList<>();
jobs.add(job);
managedJobs.put(sessionIdentifier, jobs);
}
// enqueue new job for execution
Future<?> future = jobExecutor.enqueue(job);
job.setFuture(future);
}
use of bio.fkaiser.fit3d.web.model.Fit3DJob in project fit3d by fkaiserbio.
the class AdminView method init.
@PostConstruct
public void init() {
MongoClient mongoClient = new MongoClient(Fit3DWebConstants.Database.DB_HOST, Fit3DWebConstants.Database.DB_PORT);
MongoCollection<Document> mongoCollection = mongoClient.getDatabase(Fit3DWebConstants.Database.DB_NAME).getCollection(Fit3DWebConstants.Database.DB_COLLECTION_NAME);
FindIterable<Document> documents = mongoCollection.find();
jobs = new ArrayList<>();
for (Document document : documents) {
Fit3DJob job = JobConverter.toFit3DJob(document);
jobs.add(job);
}
}
use of bio.fkaiser.fit3d.web.model.Fit3DJob in project fit3d by fkaiserbio.
the class JobConverter method toFit3DJob.
@SuppressWarnings("unchecked")
public static Fit3DJob toFit3DJob(Document jobDocument) {
Document parametersObject = (Document) jobDocument.get("parameters");
List<ExchangeDefinition> exchangeDefinitions = ((List<String>) parametersObject.get("exchangeDefinitions")).stream().map(ExchangeDefinition::fromString).collect(Collectors.toList());
Fit3DJobParameters parameters = new Fit3DJobParameters();
parameters.setAtomFilterType(AtomFilterType.valueOf((String) parametersObject.get("atomFilterType")));
parameters.setPdbTargetList((boolean) parametersObject.get("pdbTargetList"));
parameters.setChainTargetList((boolean) parametersObject.get("chainTargetList"));
parameters.setTargetListPath(Paths.get((String) parametersObject.get("targetListPath")));
parameters.setMotifPath(Paths.get((String) parametersObject.get("motifPath")));
parameters.setStatisticalModelType(StatisticalModelType.valueOf((String) parametersObject.get("statisticalModel")));
parameters.setRmsdLimit((double) parametersObject.get("rmsdLimit"));
parameters.setExchangeDefinitions(exchangeDefinitions);
Fit3DJob fit3dJob = new Fit3DJob();
fit3dJob.setTimeStamp(LocalDateTime.parse((String) jobDocument.get("timeStamp")));
fit3dJob.setSessionIdentifier((UUID.fromString((String) jobDocument.get("sessionIdentifier"))));
fit3dJob.setIpAddress((String) jobDocument.get("ipAddress"));
fit3dJob.setJobIdentifier(UUID.fromString((String) jobDocument.get("jobIdentifier")));
fit3dJob.setJobPath(Paths.get((String) jobDocument.get("jobPath")));
fit3dJob.setDescription((String) jobDocument.get("description"));
fit3dJob.setEmail((String) jobDocument.get("email"));
fit3dJob.setEnqueued((boolean) jobDocument.get("enqueued"));
fit3dJob.setRunning((boolean) jobDocument.get("running"));
fit3dJob.setFinished((boolean) jobDocument.get("finished"));
fit3dJob.setFailed((boolean) jobDocument.get("failed"));
fit3dJob.setSendMail((boolean) jobDocument.get("sendMail"));
fit3dJob.setErrorMessage((String) jobDocument.get("errorMessage"));
fit3dJob.setParameters(parameters);
return fit3dJob;
}
Aggregations