use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class RemoteAPITokenServiceImpl method getOldTokenId.
/**
* Remove any old token for this user from the database
*
* @param apiToken
* the api token to remove.
* @return the token that was found.
*/
protected RemoteAPIToken getOldTokenId(RemoteAPIToken apiToken) {
RemoteAPIToken oldToken = null;
try {
oldToken = getToken(apiToken.getRemoteApi());
logger.trace("Old token found for service " + apiToken.getRemoteApi());
apiToken.setId(oldToken.getId());
} catch (EntityNotFoundException ex) {
logger.trace("No token found for service " + apiToken.getRemoteApi());
}
return apiToken;
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class RemoteAPITokenServiceImpl method getToken.
/**
* {@inheritDoc}
*/
@Override
public RemoteAPIToken getToken(RemoteAPI remoteAPI) throws EntityNotFoundException {
User user = userRepository.loadUserByUsername(getUserName());
RemoteAPIToken readTokenForApiAndUser = tokenRepository.readTokenForApiAndUser(remoteAPI, user);
if (readTokenForApiAndUser == null) {
throw new EntityNotFoundException("Couldn't find an OAuth2 token for this API and User");
}
return readTokenForApiAndUser;
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class SequencingObjectServiceImpl method getUniqueSamplesForSequencingObjects.
/**
* {@inheritDoc}
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN') or hasPermission(#sequenceFiles, 'canReadSequencingObject')")
@Override
public <T extends SequencingObject> Map<Sample, T> getUniqueSamplesForSequencingObjects(Set<T> sequenceFiles) throws DuplicateSampleException {
Map<Sample, T> sequenceFilesSampleMap = new HashMap<>();
for (T seqObj : sequenceFiles) {
SequenceFile file = seqObj.getFiles().iterator().next();
SampleSequencingObjectJoin join = ssoRepository.getSampleForSequencingObject(seqObj);
if (join == null) {
throw new EntityNotFoundException("No sample associated with sequence file " + seqObj.getClass() + "[id=" + seqObj.getId() + "]");
} else {
Sample sample = join.getSubject();
if (sequenceFilesSampleMap.containsKey(sample)) {
SequencingObject previousFile = sequenceFilesSampleMap.get(sample);
throw new DuplicateSampleException("Sequence files " + file + ", " + previousFile + " have the same sample " + sample);
} else {
sequenceFilesSampleMap.put(sample, seqObj);
}
}
}
return sequenceFilesSampleMap;
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class SampleServiceImpl method getSampleForProject.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = true)
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_SEQUENCER') or (hasPermission(#project, 'canReadProject') and hasPermission(#sampleId, 'canReadSample'))")
public ProjectSampleJoin getSampleForProject(Project project, Long sampleId) {
Sample sample = read(sampleId);
ProjectSampleJoin join = psjRepository.readSampleForProject(project, sample);
if (join == null) {
throw new EntityNotFoundException("Join between the project and this identifier doesn't exist");
}
return join;
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class AnalysisExecutionServiceGalaxyAsync method transferAnalysisResults.
/**
* Downloads and saves the results of an {@link AnalysisSubmission} that was
* previously submitted from an execution manager.
*
* @param submittedAnalysis
* An {@link AnalysisSubmission} that was previously submitted.
* @return A {@link Future} with an {@link AnalysisSubmission} object
* containing information about the particular analysis.
* @throws ExecutionManagerException
* If there was an issue with the execution manager.
* @throws IridaWorkflowNotFoundException
* If the workflow for this submission could not be found in
* IRIDA.
* @throws IOException
* If there was an error loading the analysis results from an
* execution manager.
* @throws IridaWorkflowAnalysisTypeException
* If there was an issue building an {@link Analysis} object.
*/
@Transactional
public Future<AnalysisSubmission> transferAnalysisResults(AnalysisSubmission submittedAnalysis) throws ExecutionManagerException, IOException, IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException {
checkNotNull(submittedAnalysis, "submittedAnalysis is null");
checkNotNull(submittedAnalysis.getRemoteAnalysisId(), "remoteAnalysisId is null");
if (!analysisSubmissionService.exists(submittedAnalysis.getId())) {
throw new EntityNotFoundException("Could not find analysis submission for " + submittedAnalysis);
}
logger.debug("Getting results for " + submittedAnalysis);
Analysis analysisResults = workspaceService.getAnalysisResults(submittedAnalysis);
logger.trace("Saving results for " + submittedAnalysis);
Analysis savedAnalysis = analysisService.create(analysisResults);
// if samples should be updated, set to TRANSFERRED. Otherwise just complete.
if (submittedAnalysis.getUpdateSamples()) {
submittedAnalysis.setAnalysisState(AnalysisState.TRANSFERRED);
} else {
submittedAnalysis.setAnalysisState(AnalysisState.COMPLETED);
}
try {
submittedAnalysis.setAnalysis(savedAnalysis);
} catch (AnalysisAlreadySetException e) {
throw new ExecutionManagerException("Analysis already set", e);
}
AnalysisSubmission completedSubmission = analysisSubmissionService.update(submittedAnalysis);
return new AsyncResult<>(completedSubmission);
}
Aggregations