diff --git a/ispyb-ejb/pom.xml b/ispyb-ejb/pom.xml index f98d59713..391982922 100644 --- a/ispyb-ejb/pom.xml +++ b/ispyb-ejb/pom.xml @@ -493,7 +493,7 @@ /data/ispyb/pyarch /data/ispyb/pyarch/pdb/ - /mxn/groups/ispybstorage/pdf/ + /data/staff/ispybstorage/pdf/ w-v-ispyb-0.maxiv.lu.se ispyb.maxiv.lu.se diff --git a/ispyb-ejb/src/main/java/ispyb/common/util/PathUtils.java b/ispyb-ejb/src/main/java/ispyb/common/util/PathUtils.java index 1dacf7242..b79a0a3ee 100644 --- a/ispyb-ejb/src/main/java/ispyb/common/util/PathUtils.java +++ b/ispyb-ejb/src/main/java/ispyb/common/util/PathUtils.java @@ -67,7 +67,7 @@ public static String getFullDNAPath(DataCollection3VO dataCollectionVO) throws E String imageDir = getImageDirPath(dataCollectionVO); if (Constants.SITE_IS_MAXIV()) { - imageDir = imageDir.replace("/data/visitors/","/mxn/groups/ispybstorage/visitors/"); + imageDir = imageDir.replace("/data/visitors/","/data/staff/ispybstorage/visitors/"); } String fullDNAPath = imageDir + Constants.IMG_DNA_URL_SUFIX; if (isWindows) { diff --git a/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiCsvExporter.java b/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiCsvExporter.java new file mode 100644 index 000000000..9df764886 --- /dev/null +++ b/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiCsvExporter.java @@ -0,0 +1,317 @@ +/******************************************************************************* + * This file is part of ISPyB. + * + * ISPyB is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ISPyB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with ISPyB. If not, see . + * + * Contributors : S. Delageniere, R. Leal, L. Launer, K. Levik, S. Veyrier, P. Brenchereau, M. Bodin, A. De Maria Antolinos + ******************************************************************************/ + +package ispyb.common.util.export; + +import ispyb.common.util.Constants; +import ispyb.server.common.services.sessions.Session3Service; +import ispyb.server.common.util.ejb.Ejb3ServiceLocator; +import ispyb.server.mx.services.autoproc.SpaceGroup3Service; +import ispyb.server.mx.services.collections.DataCollection3Service; +import ispyb.server.mx.services.sample.BLSample3Service; +import ispyb.server.mx.vos.autoproc.SpaceGroup3VO; +import ispyb.server.mx.vos.collections.DataCollection3VO; +import ispyb.server.mx.vos.collections.DataCollectionGroup3VO; +import ispyb.server.mx.vos.collections.Session3VO; +import org.apache.log4j.Logger; + +import java.io.ByteArrayOutputStream; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.*; + +/** + * allows creation of CSV report - general report for EXI, available in the + * + * @author Solange Delageniere + * + */ +public class ExiCsvExporter { + + private final static Logger LOG = Logger.getLogger(ExiCsvExporter.class); + + //proposalId + int proposalId; + + // proposal code + String proposalCode; + + // session info + Integer sessionId; + + private Session3VO slv; + + List dataCollections = new ArrayList<>(); + + DecimalFormat df1; + + DecimalFormat df2; + + DecimalFormat df3; + + DecimalFormat df4; + + private final Ejb3ServiceLocator ejb3ServiceLocator = Ejb3ServiceLocator.getInstance(); + + private Session3Service sessionService; + + private DataCollection3Service dataCollectionService; + + private BLSample3Service sampleService; + + private DataCollection3Service dcService; + + private SpaceGroup3Service spacegroupService; + + + public ExiCsvExporter(int proposalId, String proposalCode, Integer sessionId, + List dataCollections) throws Exception { + this.proposalCode = proposalCode; + this.sessionId = sessionId; + this.dataCollections = dataCollections; + init(); + } + + private void init() throws Exception { + df1 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df1.applyPattern("#####0.0"); + df2 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df2.applyPattern("#####0.00"); + df3 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df3.applyPattern("#####0.000"); + df4 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df4.applyPattern("#####0.0000"); + + sessionService = (Session3Service) ejb3ServiceLocator + .getLocalService(Session3Service.class); + dcService = (DataCollection3Service) ejb3ServiceLocator + .getLocalService(DataCollection3Service.class); + spacegroupService = (SpaceGroup3Service) ejb3ServiceLocator + .getLocalService(SpaceGroup3Service.class); + + dataCollectionService = (DataCollection3Service) ejb3ServiceLocator.getLocalService(DataCollection3Service.class); + sampleService = (BLSample3Service) ejb3ServiceLocator.getLocalService(BLSample3Service.class); + + slv = sessionService.findByPk(sessionId, false/*withDataCollectionGroup*/, false/*withEnergyScan*/, false/*withXFESpectrum*/); + } + + /** + * export datacollection report + * + * @return + * @throws Exception + */ + public ByteArrayOutputStream exportDataCollectionReport() throws Exception { + + this.init(); + String doc = ""; + // create simple doc and write to a ByteArrayOutputStream + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final String CSV_DELIMITER = ","; + + if (this.dataCollections.isEmpty()) { + doc += "There is no data collection in this report"; + baos.write(doc.getBytes()); + return baos; + } + + + // Header + doc += "Image prefix,"; + doc += "Beamline,"; + doc += "Run no,"; + doc += "Start Time,"; + doc += "Sample Name,"; + doc += "Protein Acronym,"; + doc += "# images,"; + doc += "Wavelength (angstrom),"; + doc += "Distance (mm),"; + doc += "Exp. Time (sec),"; + doc += "Phi start (deg),"; + doc += "Phi range (deg),"; + doc += "Xbeam (mm),"; + doc += "Ybeam (mm),"; + doc += "Detector resol. (angstrom),"; + if (this.proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) + doc += "Crystal class,"; + doc += "Comments"; + doc += "\n"; + + // Data + DecimalFormat df2 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df2.applyPattern("#####0.00"); + DecimalFormat df3 = (DecimalFormat) NumberFormat.getInstance(Locale.US); + df3.applyPattern("#####0.000"); + + + Iterator it = this.dataCollections.iterator(); + int i = 1; + while (it.hasNext()) { + + DataCollection3VO col = (DataCollection3VO) it.next(); + DataCollectionGroup3VO dcGroup = col.getDataCollectionGroupVO(); + Session3VO slv = sessionService.findByPk(dcGroup.getSessionVOId(), false, false, false); + col = dataCollectionService.loadEager(col); + if(dcGroup.getBlSampleVO() != null){ + dcGroup.setBlSampleVO(sampleService.loadEager(dcGroup.getBlSampleVO())); + } + + // ImagePrefix + if (col.getImagePrefix() != null) + doc += col.getImagePrefix() + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Beamline + if (slv.getBeamlineName() != null) + doc += slv.getBeamlineName() + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Run number + if (col.getDataCollectionNumber() != null) + doc += col.getDataCollectionNumber().toString() + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Start Time + if (col.getStartTime() != null) { + SimpleDateFormat simple1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + String date = simple1.format(col.getStartTime()); + doc += date + CSV_DELIMITER; + } else + doc += CSV_DELIMITER; + + // Sample name + String sampleName = null; + if (dcGroup.getBlSampleVO() != null) + //sampleName = samples.findByPrimaryKey(col.getBlSampleVO()).getName(); + sampleName = dcGroup.getBlSampleVO().getName(); + if (sampleName != null) + doc += sampleName + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Protein acronym + String proteinAcronym = null; + if (dcGroup.getBlSampleVO() != null && dcGroup.getBlSampleVO().getCrystalVO() != null && dcGroup.getBlSampleVO().getCrystalVO().getProteinVO() != null) + //proteinAcronym = samples.findByPrimaryKey(col.getBlSampleId()).getAcronym(); + proteinAcronym = dcGroup.getBlSampleVO().getCrystalVO().getProteinVO().getAcronym(); + if (proteinAcronym != null) + doc += proteinAcronym + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Number of images + if (col.getNumberOfImages() != null) + doc += col.getNumberOfImages().toString() + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Wavelength + if (col.getWavelength() != null) + doc += df3.format(col.getWavelength()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Detector distance + if (col.getDetectorDistance() != null) + doc += df2.format(col.getDetectorDistance()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Exposure time + if (col.getExposureTime() != null) + doc += df3.format(col.getExposureTime()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Axis start + if (col.getAxisStart() != null) + doc += df2.format(col.getAxisStart()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Axis range + if (col.getAxisRange() != null) + doc += df2.format(col.getAxisRange()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Xbeam + if (col.getXbeam() != null) + doc += df2.format(col.getXbeam()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Ybeam + if (col.getYbeam() != null) + doc += df2.format(col.getYbeam()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // Resolution + if (col.getResolution() != null) + doc += df2.format(col.getResolution()) + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + + // SrystalClass (only for IFX proposal in case of MXPress experiment) + if (this.proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { + if (dcGroup.getCrystalClass() != null && dcGroup.getCrystalClass() != "") + doc += dcGroup.getCrystalClass() + CSV_DELIMITER; + else + doc += CSV_DELIMITER; + } + + // Comments + if (col.getComments() != null && col.getComments() != "") { + doc += "\"" + col.getComments().replaceAll("\"", "\"\"") + "\""; + } else + doc += ""; + + i++; + + doc += "\n"; + } + + baos.write(doc.getBytes()); + + return baos; + + } + + + + private String getDecimalFormat(String value, DecimalFormat df) { + String ret = ""; + if (value == null || value.isEmpty()) + return ret; + try { + Double paramValue = new Double(value); + ret = df.format(paramValue); + } catch (NumberFormatException e) { + return ""; + } + + return ret; + } +} diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3Service.java b/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3Service.java index 5ee7e04a2..32d08ad5f 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3Service.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3Service.java @@ -85,4 +85,10 @@ public List findAll() */ public List findNoanomCorrect(final Integer autoProcProgramId) throws Exception; + /** + * find aimless files attachments + * @return + * @throws Exception + */ + public List findAimless(final Integer autoProcProgramId) throws Exception; } diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3ServiceBean.java b/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3ServiceBean.java index 58a80c5be..b25cd454c 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3ServiceBean.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/services/autoproc/AutoProcProgramAttachment3ServiceBean.java @@ -70,6 +70,11 @@ private static final String FIND_ALL() { "WHERE autoProcProgramId = :autoProcProgramId AND " + "fileName like '%_noanom_aimless%' "; + private static final String FIND_AUTOPROC_AIMLESS = "SELECT * " + + "FROM AutoProcProgramAttachment " + + "WHERE autoProcProgramId = :autoProcProgramId AND " + + "fileName like '%_aimless%' "; + @PersistenceContext(unitName = "ispyb_db") private EntityManager entityManager; @@ -208,6 +213,25 @@ public List findNoanomCorrect(final Integer autoPr } } + /** + * find anom correct files attachments + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public List findAimless(final Integer autoProcProgramId) throws Exception { + + String query = FIND_AUTOPROC_AIMLESS ; + try{ + + List listVOs = this.entityManager.createNativeQuery(query, "autoProcProgramAttachmentNativeQuery") + .setParameter("autoProcProgramId", autoProcProgramId).getResultList(); + return listVOs; + }catch(Exception e){ + return null; + } + } + /* Private methods ------------------------------------------------------ */ /** diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/services/utils/reader/AutoProcProgramaAttachmentFileReader.java b/ispyb-ejb/src/main/java/ispyb/server/mx/services/utils/reader/AutoProcProgramaAttachmentFileReader.java index 6d09c2b1f..bfbe420d9 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/services/utils/reader/AutoProcProgramaAttachmentFileReader.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/services/utils/reader/AutoProcProgramaAttachmentFileReader.java @@ -22,7 +22,7 @@ public static List getAutoProcessingDataFromAttachemt(AutoPr public static HashMap readAttachment(AutoProcProgramAttachment3VO attachment) throws Exception { boolean xscaleFile = false; boolean truncateLog = false; - boolean noanomAimlessLog = false; + boolean aimlessLog = false; ArrayList fastdp_cc2 = new ArrayList(); ArrayList fastdp_completeness = new ArrayList(); ArrayList fastdp_rfactor = new ArrayList(); @@ -35,11 +35,11 @@ public static HashMap readAttachment(AutoProcProgramAttachment3V String fileName = attachment.getFileName(); xscaleFile = (fileName != null && fileName.toLowerCase().endsWith("xscale.lp")); truncateLog = (fileName != null && fileName.toLowerCase().endsWith(".log") && fileName.toLowerCase().contains("truncate")); - noanomAimlessLog = (fileName != null && fileName.toLowerCase().endsWith(".log") && fileName.toLowerCase().contains("aimless")); + aimlessLog = (fileName != null && fileName.toLowerCase().endsWith(".log") && fileName.toLowerCase().contains("aimless")); // System.out.println(xscaleFile); // System.out.println(truncateLog); - if (xscaleFile || truncateLog || noanomAimlessLog) { + if (xscaleFile || truncateLog || aimlessLog) { // parse the file String sourceFileName = PathUtils.FitPathToOS(attachment.getFilePath() + "/" + fileName); BufferedReader inFile = null; @@ -154,7 +154,7 @@ public static HashMap readAttachment(AutoProcProgramAttachment3V startToRead = false; } - } else if (noanomAimlessLog) { + } else if (aimlessLog) { if (line.contains("Analysis against resolution, XDSdataset")){ startToReadFastDPRfactor = true; startToReadFastDPCompleteness = false; @@ -179,9 +179,8 @@ public static HashMap readAttachment(AutoProcProgramAttachment3V if (!line.contains("$$") && !line.isEmpty() && !line.contains("I/sigma") && !line.contains("I/sigma") && !line.contains("Filtered") && !line.contains("Mean") && !line.contains("Rmerge") && !line.contains("Average") && !line.contains("Fractional") - && !line.contains("$GRAPHS:Completeness v Resolution") + && !line.contains("$GRAPHS") && !line.contains(":Multiplicity v Resolution") - && !line.contains("$GRAPHS: CC(1/2) v resolution") && !line.contains("RMS anomalous correlation ratio") && !line.contains("Analysis against resolution, XDSdataset") && !line.contains("Completeness & multiplicity v. resolution, XDSdataset") @@ -235,7 +234,7 @@ public static HashMap readAttachment(AutoProcProgramAttachment3V } inFile.close(); - if (noanomAimlessLog) { + if (aimlessLog) { try { int imax = 21; for (int i = 0; i < imax; i++) { @@ -280,7 +279,7 @@ public static HashMap readAttachment(AutoProcProgramAttachment3V o.put("xscaleFile", xscaleFile); o.put("truncateLog", truncateLog); o.put("autoProcessingData", listAutoProcessingData); - o.put("noanomAimlessLog", noanomAimlessLog); + o.put("noanomAimlessLog", aimlessLog); return o; } } diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/DataCollectionRestWebService.java b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/DataCollectionRestWebService.java index 0e6e77e99..9896718fd 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/DataCollectionRestWebService.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/DataCollectionRestWebService.java @@ -6,6 +6,7 @@ import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -20,6 +21,11 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import ispyb.common.util.export.ExiCsvExporter; +import ispyb.server.common.services.proposals.Proposal3Service; +import ispyb.server.common.services.sessions.Session3Service; +import ispyb.server.common.util.ejb.Ejb3ServiceLocator; +import ispyb.server.mx.services.collections.DataCollection3Service; import org.apache.log4j.Logger; import org.jboss.resteasy.annotations.GZIP; @@ -237,7 +243,7 @@ public Response getDataCollectionsReportBySessionIdPDF(@PathParam("token") Strin try { byte[] byteToExport = this.getPdfRtf(sessionId, proposal, nbRows, false, false).toByteArray(); this.logFinish(methodName, start, logger); - Session3VO ses = this.getSession3Service().findByPk(new Integer(sessionId), false, false, false); + Session3VO ses = this.getSession3Service().findByPk(Integer.valueOf(sessionId), false, false, false); if (ses != null) return this.downloadFile(byteToExport, "Report_" + proposal + "_"+ ses.getBeamlineName()+ "_" + ses.getStartDate() + ".pdf"); else @@ -271,7 +277,31 @@ public Response getDataCollectionsReportByfilterParamPDF(@PathParam("token") Str return this.logError(methodName, e, start, logger); } } - + + @RolesAllowed({"User", "Manager", "Industrial", "Localcontact"}) + @GET + @Path("{token}/proposal/{proposal}/mx/datacollection/filterParam/{filterParam}/report/csv") + @Produces({ "application/csv" }) + public Response getDataCollectionsReportByfilterParamCsv(@PathParam("token") String token, + @PathParam("proposal") String proposal, + @PathParam("filterParam") String filterParam) throws NamingException { + + String methodName = "getDataCollectionReportyByfilterParamCsv"; + long start = this.logInit(methodName, logger, token, proposal, filterParam); + try { + byte[] byteToExport = this.getCsv(filterParam, proposal).toByteArray(); + this.logFinish(methodName, start, logger); + + if (filterParam != null) + return this.downloadFile(byteToExport, "Report_" + proposal + "_"+ filterParam + ".csv"); + else + return this.downloadFile(byteToExport, "No_data.csv"); + + } catch (Exception e) { + return this.logError(methodName, e, start, logger); + } + } + @RolesAllowed({"User", "Manager", "Industrial", "Localcontact"}) @GET @Path("{token}/proposal/{proposal}/mx/datacollection/filterParam/{filterParam}/report/rtf") @@ -309,7 +339,7 @@ public Response getDataCollectionsReportBySessionIdRTF(@PathParam("token") Strin try { byte[] byteToExport = this.getPdfRtf(sessionId, proposal, nbRows, true, false).toByteArray(); this.logFinish(methodName, start, logger); - Session3VO ses = this.getSession3Service().findByPk(new Integer(sessionId), false, false, false); + Session3VO ses = this.getSession3Service().findByPk(Integer.valueOf(sessionId), false, false, false); if (ses != null) return this.downloadFile(byteToExport, "Report_" + proposal + "_"+ ses.getBeamlineName()+ "_" + ses.getStartDate() + ".rtf"); else @@ -333,7 +363,7 @@ public Response getDataCollectionsAnalysisReportBySessionIdPDF(@PathParam("token try { byte[] byteToExport = this.getPdfRtf(sessionId, proposal, nbRows, false, true).toByteArray(); this.logFinish(methodName, start, logger); - Session3VO ses = this.getSession3Service().findByPk(new Integer(sessionId), false, false, false); + Session3VO ses = this.getSession3Service().findByPk(Integer.valueOf(sessionId), false, false, false); if (ses !=null) return this.downloadFile(byteToExport, "AnalysisReport_" + proposal + "_"+ ses.getBeamlineName()+ "_" + ses.getStartDate() + ".pdf"); else @@ -403,7 +433,7 @@ public Response getDataCollectionsAnalysisReportBySessionIdRTF(@PathParam("token try { byte[] byteToExport = this.getPdfRtf(sessionId, proposal, nbRows, true, true).toByteArray(); this.logFinish(methodName, start, logger); - Session3VO ses = this.getSession3Service().findByPk(new Integer(sessionId), false, false, false); + Session3VO ses = this.getSession3Service().findByPk(Integer.valueOf(sessionId), false, false, false); if (ses !=null) return this.downloadFile(byteToExport, "AnalysisReport_" + proposal + "_"+ ses.getBeamlineName()+ "_" + ses.getStartDate() + ".rtf"); else @@ -447,7 +477,7 @@ public Response getViewDataCollectionByWorkflowStepId(@PathParam("token") String public Response getViewDataCollectionByDataCollectionId(@PathParam("token") String token, @PathParam("proposal") String proposal, @PathParam("datacollectiongroupids") String datacollectiongroupids) { - String methodName = "getViewDataCollectionByWorkflowStepId"; + String methodName = "getViewDataCollectionByDataCollectionId"; long start = this.logInit(methodName, logger, token, proposal, datacollectiongroupids); try { List ids = this.parseToInteger(datacollectiongroupids); @@ -553,7 +583,7 @@ public void exportReportAndSendAsPdf(@PathParam("token") String token, if (sessionId != null) { - Session3VO ses = this.getSession3Service().findByPk(new Integer(sessionId), false, false, false); + Session3VO ses = this.getSession3Service().findByPk(Integer.valueOf(sessionId), false, false, false); Proposal3VO pv = ses.getProposalVO(); // String mpEmail = personService.findByPk(pv.getPersonVOId(), false).getEmailAddress(); @@ -600,7 +630,7 @@ public void exportReportAndSendAsPdf(@PathParam("token") String token, private ByteArrayOutputStream getPdfRtf(String sessionId, String proposal, String nbRows, boolean isRtf, boolean isAnalysis) throws NamingException, Exception { - Integer id = new Integer(sessionId); + Integer id = Integer.valueOf(sessionId); List> dataCollections = this.getWebServiceDataCollectionGroup3Service().getViewDataCollectionBySessionIdHavingImages(this.getProposalId(proposal), id); @@ -612,7 +642,7 @@ private ByteArrayOutputStream getPdfRtf(String sessionId, String proposal, Strin Integer nbRowsMax = dataCollections.size(); if (nbRows != null && !nbRows.isEmpty()) { - nbRowsMax = new Integer(nbRows); + nbRowsMax = Integer.valueOf(nbRows); } ExiPdfRtfExporter pdf = new ExiPdfRtfExporter(this.getProposalId(proposal), proposal, id , dataCollections, energyScans, xrfSpectrums, nbRowsMax); @@ -626,6 +656,28 @@ private ByteArrayOutputStream getPdfRtf(String sessionId, String proposal, Strin return baosToExport; } + + private ByteArrayOutputStream getCsv(String sessionId, String proposal) throws NamingException, Exception { + + Integer id = Integer.valueOf(sessionId); + Session3VO slv = new Session3VO(); + Ejb3ServiceLocator ejb3ServiceLocator = Ejb3ServiceLocator.getInstance(); + Session3Service sessionService = (Session3Service) ejb3ServiceLocator.getLocalService(Session3Service.class); + Proposal3Service proposalService = (Proposal3Service) ejb3ServiceLocator.getLocalService(Proposal3Service.class); + DataCollection3Service dataCollectionService = (DataCollection3Service) ejb3ServiceLocator + .getLocalService(DataCollection3Service.class); + + + Proposal3VO pv = proposalService.findByPk(this.getProposalId(proposal)); + + slv = sessionService.findByPk(id, false, false, false); + List dataCollectionList = dataCollectionService.findFiltered(null, null, null, id, null, null); + ExiCsvExporter csv = new ExiCsvExporter(pv.getProposalId(), pv.getCode(), slv.getSessionId(), dataCollectionList); + + ByteArrayOutputStream baosToExport = csv.exportDataCollectionReport(); + + return baosToExport; + } private byte [] getPdfRtf(String filterParam, String proposal, boolean isRtf, boolean isAnalysis) throws NamingException, Exception { diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXRestWebService.java b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXRestWebService.java index 7420d6fb1..b5f3569e3 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXRestWebService.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXRestWebService.java @@ -61,8 +61,8 @@ protected AutoProcessingDataParser getFastDPParserByAutoProcIntegrationListId(Li List> lists = new ArrayList>(); for (Integer id : ids) { AutoProcIntegration3VO autoProcIntegration3VO = this.getAutoProcIntegration3Service().findByPk(id); - List noanomCorrectAttachmentList = this.getAutoProcProgramAttachment3Service().findNoanomCorrect(autoProcIntegration3VO.getAutoProcProgramVOId()); - for (AutoProcProgramAttachment3VO autoProcProgramAttachment3VO : noanomCorrectAttachmentList) { + List aimlessAttachmentList = this.getAutoProcProgramAttachment3Service().findAimless(autoProcIntegration3VO.getAutoProcProgramVOId()); + for (AutoProcProgramAttachment3VO autoProcProgramAttachment3VO : aimlessAttachmentList) { List data = AutoProcProgramaAttachmentFileReader.getAutoProcessingDataFromAttachemt(autoProcProgramAttachment3VO); lists.add(data); } diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/security/login/MAXIVLoginModule.java b/ispyb-ws/src/main/java/ispyb/ws/rest/security/login/MAXIVLoginModule.java index 63608356d..f2c16a898 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/security/login/MAXIVLoginModule.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/security/login/MAXIVLoginModule.java @@ -38,9 +38,12 @@ protected static Properties getConnectionProperties(String username, String pass env.put("java.naming.security.authentication", "simple"); //env.put("java.naming.provider.url", "url"); String userDN = principalDNPrefix + username; - env.setProperty("java.naming.security.principal", userDN); + String userDomain = username +"@maxlab.lu.se"; + //env.setProperty("java.naming.security.principal", userDN); + env.put("java.naming.security.principal", userDomain); env.put("java.naming.security.credentials", password); + return env; }