Skip to content

Commit

Permalink
Merge pull request #436 from antolinos/issue_435
Browse files Browse the repository at this point in the history
It fixes issue #435
  • Loading branch information
antolinos authored Jul 23, 2019
2 parents 3b3b156 + c86aee2 commit e2af17a
Showing 1 changed file with 32 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,44 +208,42 @@ private DataCollectionGroup3VO createDataCollectionGroup(Session3VO session, BLS
return dataCollectionGroup3Service.update(group);
}


private DataCollectionGroup3VO getDataCollectionBySampleAndSession(String sampleAcronym, int proposalId, Session3VO session) throws Exception{
List<BLSample3VO> samples = sample3Service.findByAcronymAndProposalId(sampleAcronym, proposalId, null);
log.info("{} samples found for sample acronym = {} proposalId = {} sessionId = {} ", samples.size(), sampleAcronym, proposalId, session.getSessionId());

/** Get data collection groups for that sample acronym **/
List<DataCollectionGroup3VO> groups = new ArrayList<DataCollectionGroup3VO>();
for (BLSample3VO blSample3VO : samples) {
groups.addAll(dataCollectionGroup3Service.findBySampleId(blSample3VO.getBlSampleId(), false, false));
}
log.info("{} data collections found for sample acronym = {} proposalId = {} sessionId = {} ", groups.size(), sampleAcronym, proposalId, session.getSessionId());


/** Look for a DCGroup for that session **/
for (DataCollectionGroup3VO dataCollectionGroup3VO : groups) {
if (dataCollectionGroup3VO.getSessionVOId().equals(session.getSessionId())){
log.info("Data collection group found for sample acronym = {} proposalId = {} sessionId = {} ", sampleAcronym, proposalId, session.getSessionId());
return dataCollectionGroup3VO;
}
}

return null;

}


private DataCollectionGroup3VO getDataCollectionGroup(String sampleAcronym, String proposal, String beamlineName, Session3VO session, String proteinAcronym) throws Exception{
int proposalId = this.getProposalId(proposal, beamlineName);

List<BLSample3VO> samples = sample3Service.findByAcronymAndProposalId(sampleAcronym, proposalId, null);
log.info("{} samples found for sample acronym = {} proposalId = {} beamlineName = {}", samples.size(), sampleAcronym, proposalId, beamlineName);
DataCollectionGroup3VO group = new DataCollectionGroup3VO();
if (samples != null){
if (samples.size() > 1){
log.warn("Multiple acronyms found for sample acronym = {} and proposal = {} and only one was expected . technique=EM sampleAcronym={} proposal={}",sampleAcronym, proposal);
}
if (samples.size() > 0 ){
BLSample3VO sample = samples.get(0);
/** Grid should already exist **/
List<DataCollectionGroup3VO> groups = dataCollectionGroup3Service.findBySampleId(sample.getBlSampleId(), false, false);
log.info("{} dataCollectionGroup found for sample acronym = {}", groups.size(), sampleAcronym);
if (groups.size() == 0){
/** No group exists then we will create one **/
/** Creating datacollectionGroup. This is the GRID **/
return this.createDataCollectionGroup(session);
}
else{
group = this.getDataCollectionGroupBySessionId(groups, session);

if (group == null){
/** There are not grid with this sample Acronym for this session **/
log.info("No dataCollectionGroup found for sample acronym = {} and sessionId = {}", sampleAcronym, session.getSessionId());
return this.createDataCollectionGroup(session);

}
else{
log.info("DataCollectionGroup found for sample acronym = {} and sessionId = {}", sampleAcronym, session.getSessionId());
return group;
}
}
}



DataCollectionGroup3VO group = this.getDataCollectionBySampleAndSession(sampleAcronym, proposalId, session);
if (group != null){
return group;
}
log.info("No sample acronym found for sampleAcronym = {} and proposal = {} ", sampleAcronym, proposal);
log.info("No sample acronym found for sampleAcronym = {} and proposal = {} sessionId = {} ", sampleAcronym, proposal, session.getSessionId());
/** Samples are null or 0 **/

List<Protein3VO> proteins = protein3Service.findByAcronymAndProposalId(proposalId, proteinAcronym);
Expand Down

0 comments on commit e2af17a

Please sign in to comment.