diff --git a/Dockerfile b/Dockerfile index 399c31217..3d5dc25f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN mvn install:install-file -Dfile=dependencies/securityfilter.jar -DgroupId=se mvn install:install-file -Dfile=dependencies/jhdf5.jar -DgroupId=jhdf5 -DartifactId=jhdf5 -Dversion=1.0 -Dpackaging=jar && \ mvn install:install-file -Dfile=dependencies/jhdf5obj.jar -DgroupId=jhdf5obj -DartifactId=jhdf5obj -Dversion=1.0 -Dpackaging=jar && \ mvn install:install-file -Dfile=dependencies/jhdfobj.jar -DgroupId=jhdfobj -DartifactId=jhdfobj -Dversion=1.0 -Dpackaging=jar && \ - mvn install:install-file -Dfile=dependencies/ispyb-userportal-gen-1.5.jar -DgroupId=ispyb -DartifactId=ispyb-userportal-gen -Dversion=1.5 -Dpackaging=jar && \ + mvn install:install-file -Dfile=dependencies/ispyb-userportal-gen-1.7.jar -DgroupId=ispyb -DartifactId=ispyb-userportal-gen -Dversion=1.7 -Dpackaging=jar && \ mvn install:install-file -Dfile=dependencies/Struts-Layout-1.2.jar -DgroupId=struts-layout -DartifactId=struts-layout -Dversion=1.2 -Dpackaging=jar && \ mvn install -Dispyb.site=MAXIV -Dispyb.env=production && \ cp ispyb-ear/target/ispyb.ear /var/ispyb.ear diff --git a/ispyb-ejb/db/scripts/ahead/2020_05_08_EnergyScan_add_remoteEnergy.sql b/ispyb-ejb/db/scripts/ahead/2020_05_08_EnergyScan_add_remoteEnergy.sql new file mode 100644 index 000000000..070397cca --- /dev/null +++ b/ispyb-ejb/db/scripts/ahead/2020_05_08_EnergyScan_add_remoteEnergy.sql @@ -0,0 +1,61 @@ +INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2020_05_08_EnergyScan_add_remoteEnergy.sql', 'ONGOING'); + +ALTER TABLE `pydb`.`EnergyScan` +ADD COLUMN `remoteEnergy` FLOAT NULL DEFAULT NULL AFTER `blSubSampleId`, +ADD COLUMN `remoteFPrime` FLOAT NULL DEFAULT NULL AFTER `remoteEnergy`, +ADD COLUMN `remoteFDoublePrime` FLOAT NULL DEFAULT NULL AFTER `remoteFPrime`; + +USE `pydb`; +CREATE + OR REPLACE ALGORITHM = MERGE + DEFINER = `pxadmin`@`%` + SQL SECURITY DEFINER +VIEW `v_energyScan` AS + SELECT + `EnergyScan`.`energyScanId` AS `energyScanId`, + `EnergyScan`.`sessionId` AS `sessionId`, + `EnergyScan`.`blSampleId` AS `blSampleId`, + `EnergyScan`.`fluorescenceDetector` AS `fluorescenceDetector`, + `EnergyScan`.`scanFileFullPath` AS `scanFileFullPath`, + `EnergyScan`.`choochFileFullPath` AS `choochFileFullPath`, + `EnergyScan`.`jpegChoochFileFullPath` AS `jpegChoochFileFullPath`, + `EnergyScan`.`element` AS `element`, + `EnergyScan`.`startEnergy` AS `startEnergy`, + `EnergyScan`.`endEnergy` AS `endEnergy`, + `EnergyScan`.`transmissionFactor` AS `transmissionFactor`, + `EnergyScan`.`exposureTime` AS `exposureTime`, + `EnergyScan`.`synchrotronCurrent` AS `synchrotronCurrent`, + `EnergyScan`.`temperature` AS `temperature`, + `EnergyScan`.`peakEnergy` AS `peakEnergy`, + `EnergyScan`.`peakFPrime` AS `peakFPrime`, + `EnergyScan`.`peakFDoublePrime` AS `peakFDoublePrime`, + `EnergyScan`.`inflectionEnergy` AS `inflectionEnergy`, + `EnergyScan`.`inflectionFPrime` AS `inflectionFPrime`, + `EnergyScan`.`inflectionFDoublePrime` AS `inflectionFDoublePrime`, + `EnergyScan`.`xrayDose` AS `xrayDose`, + `EnergyScan`.`startTime` AS `startTime`, + `EnergyScan`.`endTime` AS `endTime`, + `EnergyScan`.`edgeEnergy` AS `edgeEnergy`, + `EnergyScan`.`filename` AS `filename`, + `EnergyScan`.`beamSizeVertical` AS `beamSizeVertical`, + `EnergyScan`.`beamSizeHorizontal` AS `beamSizeHorizontal`, + `EnergyScan`.`crystalClass` AS `crystalClass`, + `EnergyScan`.`comments` AS `comments`, + `EnergyScan`.`flux` AS `flux`, + `EnergyScan`.`flux_end` AS `flux_end`, + `EnergyScan`.`remoteEnergy` AS `remoteEnergy`, + `EnergyScan`.`remoteFPrime` AS `remoteFPrime`, + `EnergyScan`.`remoteFDoublePrime` AS `remoteFDoublePrime`, + `BLSample`.`blSampleId` AS `BLSample_sampleId`, + `BLSample`.`name` AS `name`, + `BLSample`.`code` AS `code`, + `Protein`.`acronym` AS `acronym`, + `BLSession`.`proposalId` AS `BLSession_proposalId` + FROM + ((((`EnergyScan` + LEFT JOIN `BLSample` ON ((`BLSample`.`blSampleId` = `EnergyScan`.`blSampleId`))) + LEFT JOIN `Crystal` ON ((`Crystal`.`crystalId` = `BLSample`.`crystalId`))) + LEFT JOIN `Protein` ON ((`Protein`.`proteinId` = `Crystal`.`proteinId`))) + LEFT JOIN `BLSession` ON ((`BLSession`.`sessionId` = `EnergyScan`.`sessionId`))); + +UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2020_05_08_EnergyScan_add_remoteEnergy.sql'; \ No newline at end of file diff --git a/ispyb-ejb/db/scripts/ahead/2020_10_08_experiment_statistics_view.sql b/ispyb-ejb/db/scripts/ahead/2020_10_08_experiment_statistics_view.sql new file mode 100644 index 000000000..ba71584f6 --- /dev/null +++ b/ispyb-ejb/db/scripts/ahead/2020_10_08_experiment_statistics_view.sql @@ -0,0 +1,37 @@ +INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2020_10_08_experiment_statistics_view.sql', 'ONGOING'); + +CREATE + ALGORITHM = UNDEFINED + DEFINER = `pxadmin`@`%` + SQL SECURITY DEFINER +VIEW `v_mx_experiment_stats` AS + SELECT + `DC`.`startTime` AS `startTime`, + `DC`.`numberOfImages` AS `Images`, + `DC`.`transmission` AS `Transmission`, + `DC`.`resolution` AS `Res. (corner)`, + `DC`.`wavelength` AS `En. (Wave.)`, + `DC`.`omegaStart` AS `Omega start (total)`, + `DC`.`exposureTime` AS `Exposure Time`, + `DC`.`flux` AS `Flux`, + `DC`.`flux_end` AS `Flux End`, + `DC`.`detectorDistance` AS `Detector Distance`, + `DC`.`xBeam` AS `X Beam`, + `DC`.`yBeam` AS `Y Beam`, + `DC`.`kappaStart` AS `Kappa`, + `DC`.`phiStart` AS `Phi`, + `DC`.`axisStart` AS `Axis Start`, + `DC`.`axisEnd` AS `Axis End`, + `DC`.`axisRange` AS `Axis Range`, + `DC`.`beamSizeAtSampleX` AS `Beam Size X`, + `DC`.`beamSizeAtSampleY` AS `Beam Size Y`, + `BLS`.`beamLineName` AS `beamLineName`, + `DCG`.`comments` AS `comments`, + `P`.`proposalNumber` AS `proposalNumber` + FROM + (((`DataCollection` `DC` + JOIN `DataCollectionGroup` `DCG` ON ((`DCG`.`dataCollectionGroupId` = `DC`.`dataCollectionGroupId`))) + JOIN `BLSession` `BLS` ON ((`BLS`.`sessionId` = `DCG`.`sessionId`))) + JOIN `Proposal` `P` ON ((`P`.`proposalId` = `BLS`.`proposalId`))) + +UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2020_10_08_experiment_statistics_view.sql'; \ No newline at end of file diff --git a/ispyb-ejb/pom.xml b/ispyb-ejb/pom.xml index ac08cda2b..031e1be72 100644 --- a/ispyb-ejb/pom.xml +++ b/ispyb-ejb/pom.xml @@ -479,7 +479,7 @@ LDAP database - ldaps://srv-ad-2.maxiv.lu.se/ + ldaps://adauth.maxiv.lu.se/ dc=maxlab,dc=lu,dc=se dc=maxlab,dc=lu,dc=se samaccountname diff --git a/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiPdfRtfExporter.java b/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiPdfRtfExporter.java index bff3980f6..854b0fe80 100644 --- a/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiPdfRtfExporter.java +++ b/ispyb-ejb/src/main/java/ispyb/common/util/export/ExiPdfRtfExporter.java @@ -810,7 +810,10 @@ private void setEnergyScanMapData(Document document, Map energyS + "Pk f'': \n" + "Inflection Energy: \n" + "Ip f': \n" - + "Ip f'': \n" ; + + "Ip f'': \n" + + "Remote Energy: \n" + + "Remote f': \n" + + "Remote f'': \n" ; table.addCell(new Paragraph(parag, FONT_DOC)); @@ -819,9 +822,12 @@ private void setEnergyScanMapData(Document document, Map energyS parag = getCellParam(energyScanMapItem, "peakEnergy", df3) + "keV \n" + getCellParam(energyScanMapItem, "peakFPrime", df2) + " e- \n" + getCellParam(energyScanMapItem, "peakFDoublePrime", df2) + " e- \n" - + "("+ getCellParam(energyScanMapItem, "inflectionEnergy", df2) + "keV \n" + + getCellParam(energyScanMapItem, "inflectionEnergy", df2) + "keV \n" + getCellParam(energyScanMapItem, "inflectionFPrime", df2) + " e- \n" - + getCellParam(energyScanMapItem, "inflectionFDoublePrime", df2) + " e- \n" ; + + getCellParam(energyScanMapItem, "inflectionFDoublePrime", df2) + " e- \n" + + getCellParam(energyScanMapItem, "remoteEnergy", df2) + "keV \n" + + getCellParam(energyScanMapItem, "remoteFPrime", df2) + " e- \n" + + getCellParam(energyScanMapItem, "remoteFDoublePrime", df2) + " e- \n" ;; table.addCell(new Paragraph(parag, FONT_DOC_BOLD)); @@ -1173,7 +1179,7 @@ private void setEnergyScanMapData2(Document document, Map energy String parag = getCellParam(energyScanMapItem, "scanFileFullPath", null) + "\n" ; document.add(new Paragraph(parag, FONT_DOC_SMALL)); - Table table = new Table(9); + Table table = new Table(11); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorderWidth(0); table.setBorder(0); @@ -1250,7 +1256,18 @@ private void setEnergyScanMapData2(Document document, Map energy parag = getCellParam(energyScanMapItem, "inflectionEnergy", df2) + "keV \n" + getCellParam(energyScanMapItem, "inflectionFPrime", df2) + " e- \n" + getCellParam(energyScanMapItem, "inflectionFDoublePrime", df2) + " e- \n" ; - + + // Cell 10 + parag = "Remote Energy: \n" + + "Remote f': \n" + + "Remote f'': \n" ; + + table.addCell(new Paragraph(parag, FONT_DOC_SMALL)); + + // Cell 11 + parag = getCellParam(energyScanMapItem, "remoteEnergy", df2) + "keV \n" + + getCellParam(energyScanMapItem, "remoteFPrime", df2) + " e- \n" + + getCellParam(energyScanMapItem, "remoteFDoublePrime", df2) + " e- \n" ; table.addCell(new Paragraph(parag, FONT_DOC_SMALL_BOLD)); document.add(table); diff --git a/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3Service.java b/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3Service.java index 1afad5e52..6c4a7ef9c 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3Service.java +++ b/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3Service.java @@ -45,6 +45,8 @@ public interface Stats3Service { List> getDatacollectionStatsByDate(String datacollectionStatisticsType, Date startDate, Date endDate, String[] datacollectionTestProposals, String beamline); + List> getExperimentStatsByDate(Date startDate, Date endDate, String[] datacollectionTestProposals); + List> getExperimentStatsByDate(Date startDate, Date endDate, String[] datacollectionTestProposals, String beamline); } \ No newline at end of file diff --git a/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3ServiceBean.java b/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3ServiceBean.java index 355702438..020edeabd 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3ServiceBean.java +++ b/ispyb-ejb/src/main/java/ispyb/server/biosaxs/services/stats/Stats3ServiceBean.java @@ -62,6 +62,8 @@ public class Stats3ServiceBean extends WsServiceBean implements Stats3Service, +"and DCG.comments not in (' Data collection failed!\n') " +"and P.proposalNumber not in (:TESTPROPOSALS) "; + private String EXPERIMENTSTATS_QUERY ="select * from v_mx_experiment_stats where startTime >= :START and startTime <= :END and comments not in (' Data collection failed!\\n') and proposalNumber not in (:TESTPROPOSALS) "; + @PersistenceContext(unitName = "ispyb_db") private EntityManager entityManager; @@ -153,4 +155,29 @@ public List> getDatacollectionStatsByDate( query.setParameter("BEAMLINENAME",beamline); return executeSQLQuery(query); } + + @Override + public List> getExperimentStatsByDate( + Date startDate, Date endDate, String[] datacollectionTestProposals) { + Session session = (Session) this.entityManager.getDelegate(); + SQLQuery query = session.createSQLQuery(EXPERIMENTSTATS_QUERY); + SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); + query.setParameter("START", dt1.format(startDate)); + query.setParameter("END", dt1.format(endDate)); + query.setParameterList("TESTPROPOSALS", datacollectionTestProposals); + return executeSQLQuery(query); + } + + @Override + public List> getExperimentStatsByDate( + Date startDate, Date endDate, String[] datacollectionTestProposals, String beamline) { + Session session = (Session) this.entityManager.getDelegate(); + SQLQuery query = session.createSQLQuery(EXPERIMENTSTATS_QUERY + " and beamLineName = :BEAMLINENAME "); + SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); + query.setParameter("START", dt1.format(startDate)); + query.setParameter("END", dt1.format(endDate)); + query.setParameterList("TESTPROPOSALS", datacollectionTestProposals); + query.setParameter("BEAMLINENAME",beamline); + return executeSQLQuery(query); + } } 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 5d5115b02..6d09c2b1f 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 @@ -35,7 +35,7 @@ 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("noanom_aimless")); + noanomAimlessLog = (fileName != null && fileName.toLowerCase().endsWith(".log") && fileName.toLowerCase().contains("aimless")); // System.out.println(xscaleFile); // System.out.println(truncateLog); diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsService.java b/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsService.java index 2b9120671..0616ca173 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsService.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsService.java @@ -34,6 +34,8 @@ public interface DataCollectionGroupRestWsService { public List> getViewDataCollectionBySessionIdHavingImages(int proposalId, int sessionId); public List> getViewDataCollectionByProteinAcronym(int proposalId, String proteinAcronym); + + public List> getViewDataCollectionBySampleId(int proposalId, int sampleId); public List> getViewDataCollectionBySampleName(int proposalId, String name); diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsServiceBean.java b/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsServiceBean.java index 1a5deeedc..f46c5f84d 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsServiceBean.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/services/ws/rest/datacollectiongroup/DataCollectionGroupRestWsServiceBean.java @@ -80,6 +80,18 @@ public List> getViewDataCollectionByProteinAcronym(int propo return executeSQLQuery(query); } + @Override + public List> getViewDataCollectionBySampleId(int proposalId, int sampleId) { + String mySQLQuery = getViewTableQuery() + " where BLSession_proposalId = :proposalId and DataCollectionGroup_blSampleId = :sampleId"; + mySQLQuery = mySQLQuery + " group by v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId, v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId"; + Session session = (Session) this.entityManager.getDelegate(); + SQLQuery query = session.createSQLQuery(mySQLQuery); + query.setParameter("proposalId", proposalId); + query.setParameter("sampleId", sampleId); + query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE); + return executeSQLQuery(query); + } + @Override public List> getViewDataCollectionBySampleName(int proposalId, String name) { String mySQLQuery = getViewTableQuery() + " where BLSession_proposalId = :proposalId and BLSample_name = :name"; diff --git a/ispyb-ejb/src/main/java/ispyb/server/mx/vos/collections/EnergyScan3VO.java b/ispyb-ejb/src/main/java/ispyb/server/mx/vos/collections/EnergyScan3VO.java index 433e1dab1..8cecbf1e9 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/mx/vos/collections/EnergyScan3VO.java +++ b/ispyb-ejb/src/main/java/ispyb/server/mx/vos/collections/EnergyScan3VO.java @@ -149,6 +149,15 @@ public class EnergyScan3VO extends ISPyBValueObject implements Cloneable { @Column(name = "workingDirectory") protected String workingDirectory; + + @Column(name = "remoteEnergy") + protected Double remoteEnergy; + + @Column(name = "remoteFPrime") + protected Double remoteFPrime; + + @Column(name = "remoteFDoublePrime") + protected Double remoteFDoublePrime; @ManyToOne @JoinColumn(name = "blSubSampleId") @@ -169,7 +178,8 @@ public EnergyScan3VO(Integer energyScanId, Session3VO sessionVO, BLSample3VO sam Double inflectionFDoublePrime, Double xrayDose, Date startTime, Date endTime, String edgeEnergy, String filename, Float beamSizeVertical, Float beamSizeHorizontal, - String crystalClass, String comments, Double flux, Double flux_end) { + String crystalClass, String comments, Double flux, Double flux_end, + Double remoteEnergy, Double remoteFPrime, Double remoteFDoublePrime) { super(); this.energyScanId = energyScanId; this.sessionVO = sessionVO; @@ -202,6 +212,9 @@ public EnergyScan3VO(Integer energyScanId, Session3VO sessionVO, BLSample3VO sam this.comments = comments; this.flux = flux; this.flux_end = flux_end; + this.remoteEnergy = remoteEnergy; + this.remoteFPrime = remoteFPrime; + this.remoteFDoublePrime = remoteFDoublePrime; } @@ -238,6 +251,9 @@ public EnergyScan3VO(EnergyScan3VO vo) { this.comments = vo.getComments(); this.flux = vo.getFlux(); this.flux_end = vo.getFlux_end(); + this.remoteEnergy = vo.getRemoteEnergy(); + this.remoteFPrime = vo.getRemoteFPrime(); + this.remoteFDoublePrime = vo.getRemoteFDoublePrime(); } @@ -274,6 +290,9 @@ public void fillVOFromLight(EnergyScanWS3VO vo) { this.comments = vo.getComments(); this.flux = vo.getFlux(); this.flux_end = vo.getFlux_end(); + this.remoteEnergy = vo.getRemoteEnergy(); + this.remoteFPrime = vo.getRemoteFPrime(); + this.remoteFDoublePrime = vo.getRemoteFDoublePrime(); } @@ -555,6 +574,24 @@ public void setFlux_end(Double flux_end) { this.flux_end = flux_end; } + public Double getRemoteEnergy() { return remoteEnergy; } + public void setRemoteEnergy(Double remoteEnergy) { + this.remoteEnergy = remoteEnergy; + } + + public Double getRemoteFPrime() { + return remoteFPrime; + } + public void setRemoteFPrime(Double remoteFPrime) { + this.remoteFPrime = remoteFPrime; + } + + public Double getRemoteFDoublePrime() { + return remoteFDoublePrime; + } + public void setRemoteFDoublePrime(Double remoteFDoublePrime) { + this.remoteFDoublePrime = remoteFDoublePrime; + } /** @@ -637,7 +674,10 @@ public String toWSString(){ "crystalClass="+this.crystalClass+", "+ "comments="+this.comments+", "+ "flux="+this.flux+", "+ - "flux_end="+this.flux_end; + "flux_end="+this.flux_end+", "+ + "remoteEnergy="+this.remoteEnergy+", "+ + "remoteFPrime="+this.remoteFPrime+", "+ + "remoteFDoublePrime="+this.remoteFDoublePrime; return s; } diff --git a/ispyb-ejb/src/main/java/ispyb/server/security/LdapLoginModule.java b/ispyb-ejb/src/main/java/ispyb/server/security/LdapLoginModule.java index 5df896a43..4880c3663 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/security/LdapLoginModule.java +++ b/ispyb-ejb/src/main/java/ispyb/server/security/LdapLoginModule.java @@ -283,6 +283,7 @@ private void createLdapInitContext(String username, Object credential) throws Na env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put("jboss.security.security_domain", "ispyb"); env.put("allowEmptyPasswords", "false"); + //LOG.info("Env:" + env); } @@ -293,8 +294,8 @@ private void createLdapInitContext(String username, Object credential) throws Na try { ctx = new InitialLdapContext(env, null); }catch (Exception ex){ - if (username.equals("ispyb")) { - LOG.debug("Env:" + env); + if (Constants.SITE_IS_MAXIV() && username.equals("ispyb")) { + LOG.info("Env:" + env); } throw ex; } @@ -366,12 +367,12 @@ private void createLdapInitContext(String username, Object credential) throws Na Attribute roles = attrs.get(groupAttrName); for (int r = 0; r < roles.size(); r++) { - Object value = roles.get(r); String roleName = null; roleName = value.toString(); // fill roles array if (roleName != null) { + LOG.info("Role found for " +username +":" +roleName); if (roleName.equals("ispyb-manager") || roleName.equals("ispyb-biomax-contacts") || roleName.equals("Information Management") || roleName.equals("biomax")) { userRoles.addMember(new SimplePrincipal(Constants.ROLE_MANAGER)); diff --git a/ispyb-ejb/src/main/java/ispyb/server/smis/UpdateFromSMIS.java b/ispyb-ejb/src/main/java/ispyb/server/smis/UpdateFromSMIS.java index 5e6a53d28..a3438bcd6 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/smis/UpdateFromSMIS.java +++ b/ispyb-ejb/src/main/java/ispyb/server/smis/UpdateFromSMIS.java @@ -1066,6 +1066,9 @@ private static void retrieveSession(Proposal3VO proplv, ExpSessionInfoLightVO se // number because we // always start // with 0 + if (Constants.SITE_IS_MAXIV()){ + visit_number = Integer.valueOf(sessionVO.getName()); + } Integer nbShifts = sessionVO.getShifts(); Integer startShift = sessionVO.getStartShift(); // startShift equals 1, // 2 or 3 and stands for @@ -1122,7 +1125,7 @@ private static void retrieveSession(Proposal3VO proplv, ExpSessionInfoLightVO se sesv.setExpSessionPk(sessionVO.getPk()); sesv.setOperatorSiteNumber(siteNumber); - if (Constants.SITE_IS_SOLEIL()) { + if (Constants.SITE_IS_SOLEIL() || Constants.SITE_IS_MAXIV()) { sesv.setVisit_number(visit_number); } diff --git a/ispyb-ejb/src/main/java/ispyb/server/webservice/smis/util/MAXIVWebService.java b/ispyb-ejb/src/main/java/ispyb/server/webservice/smis/util/MAXIVWebService.java index 65c7b6a5a..467e9fc55 100644 --- a/ispyb-ejb/src/main/java/ispyb/server/webservice/smis/util/MAXIVWebService.java +++ b/ispyb-ejb/src/main/java/ispyb/server/webservice/smis/util/MAXIVWebService.java @@ -2,7 +2,6 @@ import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Date; @@ -37,7 +36,6 @@ import org.json.JSONArray; import org.json.JSONObject; -import generated.ws.smis.FinderException; import generated.ws.smis.Exception_Exception; import generated.ws.smis.ExpSessionInfoLightVO; import generated.ws.smis.FinderException_Exception; @@ -54,8 +52,10 @@ public class MAXIVWebService implements SMISWebService { private String serverUrl = ""; - public MAXIVWebService() { - this.serverUrl = Constants.getProperty("userportal.url"); + public void init() { + if ("".equals(this.serverUrl)) { + this.serverUrl = Constants.getProperty("userportal.url"); + } } public List findNewMXProposalPKs_OLD (String startDateStr, String endDateStr) { @@ -91,6 +91,7 @@ public List findNewMXProposalPKs_OLD (String startDateStr, String endDateS public List findNewMXProposalPKs (String startDateStr, String endDateStr) { List pks = new ArrayList(); + init(); try { StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Sessions/?access_token=") .append(this.getToken()) @@ -261,20 +262,37 @@ public List findParticipantsForProposal(Long pro public List findRecentSessionsInfoLightForProposalPkAndDays(Long propId, Integer days){ List sessions = new ArrayList(); - + init(); JSONObject jsonProposal = getProposalForId(propId); ArrayList jsonSessions = new ArrayList(); + ArrayList jsonLocalContacts = new ArrayList(); + InnerScientistVO localContact = new InnerScientistVO(); + try { jsonSessions = getSessionsForProposal(propId); } catch (Exception ex) { ex.printStackTrace(); } + try { + jsonLocalContacts = getProposalLocalContactForPropid(propId); + localContact.setName((String) jsonLocalContacts.get(0).get("lastname")); + localContact.setFirstName((String) jsonLocalContacts.get(0).get("firstname")); + localContact.setPhone((String) jsonLocalContacts.get(0).get("phone")); + localContact.setEmail((String) jsonLocalContacts.get(0).get("email")); + //localContact.setTitle((String) jsonLocalContacts.get(0).get("title")); + } catch (Exception ex) { + ex.printStackTrace(); + localContact.setFirstName("Manager"); + localContact.setName("BioMAX"); + } for(JSONObject jsonSession : jsonSessions){ ExpSessionInfoLightVO session = new ExpSessionInfoLightVO(); - + + try{ - ArrayList jsonShifts = getShiftsForSession((Integer)jsonSession.get("sessionid")); + Integer sessionId = (Integer)jsonSession.get("sessionid"); + ArrayList jsonShifts = getShiftsForSession(sessionId); if(jsonShifts.size() != 0){ session.setBeamlineName((String)jsonSession.get("beamline")); session.setBeamlinePk(Long.valueOf(12345));//TODO Verify. We dont have a Long id @@ -285,14 +303,12 @@ public List findRecentSessionsInfoLightForProposalPkAndDa session.setExperimentPk(propId); session.setComment("Created by DUO"); session.setPk(new Long((int)jsonSession.get("sessionid"))); - InnerScientistVO localContact = new InnerScientistVO(); - localContact.setName("Muller"); - localContact.setFirstName("Uwe"); + session.setName(((Integer)jsonSession.get("sessionnum")).toString()); session.setFirstLocalContact(localContact); String title = (String)jsonProposal.get("title"); if(title.length() >= 200){ title = title.substring(0,195).concat("..."); - System.out.println("Truncated Tilte :" + title); + System.out.println("Truncated Title :" + title); } session.setProposalTitle(title); session.setCategCode("MX"); @@ -327,6 +343,8 @@ public List findRecentSessionsInfoLightForProposalPkAndDa session.setCancelled(false);//TODO: Check what this means sessions.add(session); + } else { + LOG.info("Empty session found for DUO sessionid" + sessionId.toString()); } } catch(Exception ex){ //TODO: Handle exception @@ -407,6 +425,7 @@ public void addDoiToSessionByProposalBeamlineAndDate(String arg0, Integer arg1, private JSONObject getProposalForId(Long propId){ JSONObject proposal = null; + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Proposals/") .append(propId).append("?access_token=").append(this.getToken()); @@ -416,8 +435,27 @@ private JSONObject getProposalForId(Long propId){ return proposal; } + private ArrayList getProposalLocalContactForPropid(Long propId)throws Exception { + ArrayList localContacts = new ArrayList(); + init(); + + StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Proposals/") + .append(propId).append("/localcontacts").append("?access_token=").append(this.getToken()); + + JSONArray jsonLocalContacts = readJsonArrayFromUrl(url.toString()); + + int len = jsonLocalContacts.length(); + for (int i = 0; i < len; i++) { + JSONObject jsonLocalContact = (JSONObject) jsonLocalContacts.get(i); + localContacts.add(jsonLocalContact); + } + + return localContacts; + } + private ArrayList getProposalAuthorsForPropid(Long propId)throws Exception { ArrayList authors = new ArrayList(); + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Proposals/") .append(propId).append("/authors").append("?access_token=").append(this.getToken()); @@ -435,6 +473,7 @@ private ArrayList getProposalAuthorsForPropid(Long propId)throws Exc private ArrayList getBeamlinesForProposal(Long propId){ ArrayList beamlines = new ArrayList(); + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Proposals/") .append(propId).append("/beamlines").append("?access_token=").append(this.getToken()); @@ -452,6 +491,7 @@ private ArrayList getBeamlinesForProposal(Long propId){ private ArrayList getSessionsForProposal(Long propId) throws Exception { ArrayList sessions = new ArrayList(); + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Proposals/") .append(propId).append("/sessions/").append("?access_token=").append(this.getToken()); @@ -470,6 +510,7 @@ private ArrayList getSessionsForProposal(Long propId) throws Excepti private ArrayList getShiftsForSession(Integer sessionId){ ArrayList shifts = new ArrayList(); + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Sessions/") .append(sessionId).append("/shifts").append("?access_token=").append(this.getToken()); @@ -487,6 +528,7 @@ private ArrayList getShiftsForSession(Integer sessionId){ private ArrayList getParticipantsForSession(Integer sessionId){ ArrayList participants = new ArrayList(); + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Sessions/") .append(sessionId).append("/participants").append("?access_token=").append(this.getToken()); @@ -504,6 +546,7 @@ private ArrayList getParticipantsForSession(Integer sessionId){ private JSONObject getUserForId(Integer userId){ JSONObject user = null; + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Clients/") .append(userId).append("?access_token=").append(this.getToken()); @@ -515,6 +558,7 @@ private JSONObject getUserForId(Integer userId){ private JSONObject getLabForId(Integer labId){ JSONObject lab = null; + init(); StringBuilder url = new StringBuilder("https://").append(this.serverUrl).append("/api/Institutes/") .append(labId).append("?access_token=").append(this.getToken()); diff --git a/ispyb-ui/src/main/java/ispyb/client/mx/collection/PdfRtfExporter.java b/ispyb-ui/src/main/java/ispyb/client/mx/collection/PdfRtfExporter.java index cc2e0200e..ef124477c 100644 --- a/ispyb-ui/src/main/java/ispyb/client/mx/collection/PdfRtfExporter.java +++ b/ispyb-ui/src/main/java/ispyb/client/mx/collection/PdfRtfExporter.java @@ -871,6 +871,9 @@ private void setEnergyScansTable(Document document) throws Exception { tableES.addCell(new Paragraph("Beam size Hor.\n(" + Constants.MICRO + "m)", FONT_DOC_BOLD)); tableES.addCell(new Paragraph("Beam size Ver.\n(" + Constants.MICRO + "m)", FONT_DOC_BOLD)); tableES.addCell(new Paragraph("Transm. Factor\n(%)", FONT_DOC_BOLD)); + tableES.addCell(new Paragraph("Remote Energy\n(keV)", FONT_DOC_BOLD)); + tableES.addCell(new Paragraph("Remote f'\n(e)", FONT_DOC_BOLD)); + tableES.addCell(new Paragraph("Remote f''\n(e)", FONT_DOC_BOLD)); // Column crystalClass only for IFX proposal in case of MXPress // experiment if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) @@ -940,6 +943,22 @@ private void setEnergyScansTable(Document document) throws Exception { else tableES.addCell(""); + if (col.getRemoteEnergy() != null) + tableES.addCell(new Paragraph(col.getRemoteEnergy().toString(), FONT_DOC)); + else + tableES.addCell(""); + + if (col.getRemoteFPrime() != null) + tableES.addCell(new Paragraph(col.getRemoteFPrime().toString(), FONT_DOC)); + else + tableES.addCell(""); + + if (col.getRemoteFDoublePrime() != null) + tableES.addCell(new Paragraph(col.getRemoteFDoublePrime().toString(), FONT_DOC)); + else + tableES.addCell(""); + + if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // if (col.getCrystalClass()!= null) tableES.addCell(new // Paragraph(col.getCrystalClass().toString(), diff --git a/ispyb-ui/src/main/java/ispyb/client/mx/collection/ViewSessionSummaryAction.java b/ispyb-ui/src/main/java/ispyb/client/mx/collection/ViewSessionSummaryAction.java index b6a0d2c86..7d4264930 100644 --- a/ispyb-ui/src/main/java/ispyb/client/mx/collection/ViewSessionSummaryAction.java +++ b/ispyb-ui/src/main/java/ispyb/client/mx/collection/ViewSessionSummaryAction.java @@ -171,6 +171,12 @@ public class ViewSessionSummaryAction extends DispatchAction { public final static String KEY_PEAK_ENERGY_DOUBLE_PRIME = "peakEnergyDoublePrime"; + public final static String KEY_REMOTE_ENERGY = "remoteEnergy"; + + public final static String KEY_REMOTE_ENERGY_PRIME = "remoteEnergyPrime"; + + public final static String KEY_REMOTE_ENERGY_DOUBLE_PRIME = "remoteEnergyDoublePrime"; + public final static String KEY_UNIT_CELL = "unitCell"; public final static String KEY_UNIT_CELL_TITLE = "unitCellTitle"; @@ -865,7 +871,12 @@ private static SessionDataObjectInformation getSessionDataObjectForEnergyScan(Se EnergyScan3VO energyScan = sessionDataObject.getEnergyScan(); // experimentType info.setExperimentType("Energy Scan"); - info.setImagePrefix(""); + if (Constants.SITE_IS_MAXIV()){ + info.setImagePrefix(energyScan.getFilename()); + } else { + info.setImagePrefix(""); + } + info.setImageThumbnailPath(""); info.setCrystalSnapshotPath(""); // parameters @@ -876,12 +887,14 @@ private static SessionDataObjectInformation getSessionDataObjectForEnergyScan(Se listParameters.add(new Param(KEY_TRANSMISSION, "Transmission factor", (energyScan.getTransmissionFactor() == null ? "" : ("" + energyScan.getTransmissionFactor() + " %")), false)); - listParameters.add(new Param(KEY_BEAMSIZE_HOR, "Beam size Hor", - (energyScan.getBeamSizeHorizontal() == null ? "" : ("" + energyScan.getBeamSizeHorizontal() + " μm")), - false)); - listParameters.add(new Param(KEY_BEAMSIZE_VERT, "Beam size Vert", - (energyScan.getBeamSizeVertical() == null ? "" : ("" + energyScan.getBeamSizeVertical() + " μm")), - false)); + if (!Constants.SITE_IS_MAXIV()) { + listParameters.add(new Param(KEY_BEAMSIZE_HOR, "Beam size Hor", + (energyScan.getBeamSizeHorizontal() == null ? "" : ("" + energyScan.getBeamSizeHorizontal() + " μm")), + false)); + listParameters.add(new Param(KEY_BEAMSIZE_VERT, "Beam size Vert", + (energyScan.getBeamSizeVertical() == null ? "" : ("" + energyScan.getBeamSizeVertical() + " μm")), + false)); + } info.setListParameters(listParameters); // comments info.setComments(energyScan.getComments()); @@ -892,7 +905,7 @@ private static SessionDataObjectInformation getSessionDataObjectForEnergyScan(Se info.setProteinAcronym(""); info.setSampleName(""); info.setSampleNameProtein(""); - if (energyScan.getBlSampleVO() != null) { + if (energyScan.getBlSampleVO() != null && !Constants.SITE_IS_MAXIV()) { setSampleAndProteinNames(info, energyScan.getBlSampleVO()); } @@ -918,6 +931,12 @@ private static SessionDataObjectInformation getSessionDataObjectForEnergyScan(Se + (energyScan.getPeakFPrime() == null ? "" : energyScan.getPeakFPrime() + ""), false)); listResults.add(new Param(KEY_PEAK_ENERGY_DOUBLE_PRIME, "Peak f''", "" + (energyScan.getPeakFDoublePrime() == null ? "" : energyScan.getPeakFDoublePrime() + ""), false)); + listResults.add(new Param(KEY_REMOTE_ENERGY, "Remote Energy", "" + + (energyScan.getRemoteEnergy() == null ? "" : energyScan.getRemoteEnergy() + " keV"), false)); + listResults.add(new Param(KEY_REMOTE_ENERGY_PRIME, "Remote f'", "" + + (energyScan.getRemoteFPrime() == null ? "" : energyScan.getRemoteFPrime() + ""), false)); + listResults.add(new Param(KEY_REMOTE_ENERGY_DOUBLE_PRIME, "Remote f''", "" + + (energyScan.getRemoteFDoublePrime() == null ? "" : energyScan.getRemoteFDoublePrime() + ""), false)); info.setListResults(listResults); return info; @@ -928,21 +947,34 @@ private static SessionDataObjectInformation getSessionDataObjectForXRFSpectra(Se XFEFluorescenceSpectrum3VO xrfSpectrum = sessionDataObject.getXrfSpectra(); // experimentType info.setExperimentType("XRFSpectrum"); + if (Constants.SITE_IS_MAXIV()){ + info.setImagePrefix(xrfSpectrum.getFilename()); + } else { + info.setImagePrefix(""); + } info.setImagePrefix(""); info.setImageThumbnailPath(""); info.setCrystalSnapshotPath(""); + Float energy = xrfSpectrum.getEnergy(); + String energyValue = Float.toString(energy) +" keV"; + if (Constants.SITE_IS_MAXIV()){ + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + energyValue = decimalFormat.format(energy) +" keV"; + } + // parameters List listParameters = new ArrayList(); - listParameters.add(new Param(KEY_ENERGY, "Energy", xrfSpectrum.getEnergy() == null ? "" : Float - .toString(xrfSpectrum.getEnergy()), false)); + listParameters.add(new Param(KEY_ENERGY, "Energy", xrfSpectrum.getEnergy() == null ? "" : energyValue, false)); listParameters.add(new Param(KEY_EXPOSURE_TIME, "Exposure time", (xrfSpectrum.getExposureTime() == null ? "" : ("" + xrfSpectrum.getExposureTime() + " s")), false)); - listParameters - .add(new Param(KEY_BEAMSIZE_HOR, "Beam size Hor", (xrfSpectrum.getBeamSizeHorizontal() == null ? "" - : ("" + xrfSpectrum.getBeamSizeHorizontal() + " μm")), false)); - listParameters.add(new Param(KEY_BEAMSIZE_VERT, "Beam size Vert", - (xrfSpectrum.getBeamSizeVertical() == null ? "" : ("" + xrfSpectrum.getBeamSizeVertical() + " μm")), - false)); + if (!Constants.SITE_IS_MAXIV()) { + listParameters + .add(new Param(KEY_BEAMSIZE_HOR, "Beam size Hor", (xrfSpectrum.getBeamSizeHorizontal() == null ? "" + : ("" + xrfSpectrum.getBeamSizeHorizontal() + " μm")), false)); + listParameters.add(new Param(KEY_BEAMSIZE_VERT, "Beam size Vert", + (xrfSpectrum.getBeamSizeVertical() == null ? "" : ("" + xrfSpectrum.getBeamSizeVertical() + " μm")), + false)); + } info.setListParameters(listParameters); // comments info.setComments(xrfSpectrum.getComments()); @@ -953,7 +985,7 @@ private static SessionDataObjectInformation getSessionDataObjectForXRFSpectra(Se info.setProteinAcronym(""); info.setSampleName(""); info.setSampleNameProtein(""); - if (xrfSpectrum.getBlSampleVO() != null) { + if (xrfSpectrum.getBlSampleVO() != null && !Constants.SITE_IS_MAXIV()) { setSampleAndProteinNames(info, xrfSpectrum.getBlSampleVO()); } @@ -967,7 +999,7 @@ private static SessionDataObjectInformation getSessionDataObjectForXRFSpectra(Se int annotatedPymcaXfeSpectrumExists = PathUtils.fileExists(xrfSpectrum.getAnnotatedPymcaXfeSpectrum()); String shortFileNameAnnotatedPymcaXfeSpectrum = StringUtils.getShortFilename(xrfSpectrum .getAnnotatedPymcaXfeSpectrum()); - if (annotatedPymcaXfeSpectrumExists == 0) { + if (annotatedPymcaXfeSpectrumExists == 0 && !Constants.SITE_IS_MAXIV()) { result = "Html report not found: " + shortFileNameAnnotatedPymcaXfeSpectrum; } else if (annotatedPymcaXfeSpectrumExists == 1) { result = shortFileNameAnnotatedPymcaXfeSpectrum; diff --git a/ispyb-ui/src/main/webapp/js/ispyb/mx/collection/energyScanGrid.js b/ispyb-ui/src/main/webapp/js/ispyb/mx/collection/energyScanGrid.js index 88cb5fb2d..41d9fb3d1 100644 --- a/ispyb-ui/src/main/webapp/js/ispyb/mx/collection/energyScanGrid.js +++ b/ispyb-ui/src/main/webapp/js/ispyb/mx/collection/energyScanGrid.js @@ -135,6 +135,15 @@ function EnergyScanGrid(args) { name : 'inflectionFDoublePrime', mapping : 'inflectionFDoublePrime' }, { + name : 'remoteEnergy', + mapping : 'remoteEnergy' + }, { + name : 'remoteFPrime', + mapping : 'remoteFPrime' + }, { + name : 'remoteFDoublePrime', + mapping : 'remoteFDoublePrime' + }, { name : 'xrayDose', mapping : 'xrayDose' }, { @@ -466,6 +475,24 @@ EnergyScanGrid.prototype._getColumns = function () { renderer : renderNumberFormat1, id : 'peakFDoublePrime' }, { + text : 'Remote
Energy
(keV)', + dataIndex : 'remoteEnergy', + flex : 0.05, + renderer : renderNumberFormat3, + id : 'remoteEnergy' + }, { + text : 'Remote
f\'
(e)', + dataIndex : 'remoteFPrime', + flex : 0.05, + renderer : renderNumberFormat1, + id : 'remoteFPrime' + }, { + text : 'Remote
f\'\'
(e)', + dataIndex : 'remoteFDoublePrime', + flex : 0.05, + renderer : renderNumberFormat1, + id : 'remoteFDoublePrime' + }, { text : 'Start Time', dataIndex : 'startTime', renderer : Ext.util.Format.dateRenderer('d-m-Y H:i:s'), 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 b84d3a385..0e6e77e99 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 @@ -513,6 +513,28 @@ public Response getViewDataCollectionByProteinAcronym(@PathParam("token") String return this.logError(methodName, e, start, logger); } } + + @RolesAllowed({ "User", "Manager", "Industrial", "Localcontact" }) + @GET + @GZIP + @Path("{token}/proposal/{proposal}/mx/datacollection/sample/{sampleId}/list") + @Produces({ "application/json" }) + public Response getViewDataCollectionBySampleId(@PathParam("token") String token, @PathParam("proposal") String proposal, + @PathParam("sampleId") Integer sampleId) { + + String methodName = "getViewDataCollectionBySampleId"; + long start = this.logInit(methodName, logger, token, proposal, sampleId); + try { + List> dataCollections = new ArrayList>(); + + dataCollections.addAll(this.getWebServiceDataCollectionGroup3Service().getViewDataCollectionBySampleId( + this.getProposalId(proposal), sampleId)); + this.logFinish(methodName, start, logger); + return this.sendResponse(dataCollections, false); + } catch (Exception e) { + return this.logError(methodName, e, start, logger); + } + } @RolesAllowed({"User", "Manager", "Industrial", "Localcontact"}) @GET diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXStatsRestWebService.java b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXStatsRestWebService.java index 9702f71aa..73429448c 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXStatsRestWebService.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/mx/MXStatsRestWebService.java @@ -182,10 +182,86 @@ public Response getCSVDatacollectionStatisticsByDate(@PathParam("imageslimit") S } return null; } - - - + @RolesAllowed({ "Manager", "LocalContact" }) + @GET + @Path("{token}/stats/experimentstatistics/{start}/{end}/{beamlinenames}/json") + @Produces({ "application/json" }) + public Response getExperimentStatisticsByDate(@PathParam("start") Date startDate, + @PathParam("end") Date endDate, + @PathParam("beamlinenames") String beamlinesName, + @QueryParam("testproposals")String datacollectionTestProposals + ) { + + String methodName = "getExperimentStatisticsByDate"; + long id = this.logInit(methodName, logger, startDate, endDate, beamlinesName, datacollectionTestProposals); + try { + String[] testProposals = null; + if (datacollectionTestProposals != null && datacollectionTestProposals != ""){ + testProposals = datacollectionTestProposals.split(","); + } + + List> list = new ArrayList>(); + + if (beamlinesName != null && !beamlinesName.equals("0")){ + List beamlines = this.parseToString(beamlinesName); + if (beamlines.size() > 0){ + for (String beamline : beamlines) { + list.addAll(this.getStatsWSService().getExperimentStatsByDate(startDate, endDate, testProposals, beamline)); + } + } + } + else{ + list.addAll(this.getStatsWSService().getExperimentStatsByDate(startDate, endDate, testProposals)); + } + + return this.sendResponse(list); + + } catch (Exception e) { + this.logError(methodName, e, id, logger); + } + return null; + } + + @RolesAllowed({ "Manager", "LocalContact" }) + @GET + @Path("{token}/stats/experimentstatistics/{start}/{end}/{beamlinenames}/csv") + @Produces({ "application/csv" }) + public Response getCSVDatacollectionStatisticsByDate(@PathParam("start") Date startDate, + @PathParam("end") Date endDate, + @PathParam("beamlinenames") String beamlinesName, + @QueryParam("testproposals") String datacollectionTestProposals + ) { + + String methodName = "getCSVExperimentStatisticsByDate"; + long id = this.logInit(methodName, logger, startDate, endDate, beamlinesName, datacollectionTestProposals); + try { + String[] testProposals = null; + if (datacollectionTestProposals != null && datacollectionTestProposals != ""){ + testProposals = datacollectionTestProposals.split(","); + } + List> list = new ArrayList>(); + + if (beamlinesName != null && !beamlinesName.equals("0")){ + List beamlines = this.parseToString(beamlinesName); + if (beamlines.size() > 0){ + for (String beamline : beamlines) { + list.addAll(this.getStatsWSService().getExperimentStatsByDate(startDate, endDate, testProposals, beamline)); + } + } + } + else{ + list.addAll(this.getStatsWSService().getExperimentStatsByDate( startDate, endDate, testProposals)); + } + + return this.sendResponse(this.parseListToCSV(list)); + + } catch (Exception e) { + this.logError(methodName, e, id, logger); + } + return null; + } + public String parseListToCSV(List> list) { StringWriter output = new StringWriter(); diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/DewarRestWebService.java b/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/DewarRestWebService.java index d8e602529..a5bcbc055 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/DewarRestWebService.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/DewarRestWebService.java @@ -16,6 +16,7 @@ import ispyb.server.mx.services.ws.rest.dewar.DewarRestWsService; import ispyb.server.mx.vos.collections.Session3VO; import ispyb.ws.rest.RestWebService; +import ispyb.server.common.vos.proposals.ProposalWS3VO; import java.io.ByteArrayOutputStream; import java.sql.Timestamp; @@ -271,6 +272,18 @@ public Response saveDewar( } } + if (Constants.SITE_IS_MAXIV()) { + ArrayList p = StringUtils.GetProposalNumberAndCode(proposal); + String proposalCode = p.get(0); + String proposalNumber = p.get(2); + ProposalWS3VO proposalws3vo = getProposal3Service().findForWSByCodeAndNumber(proposalCode, proposalNumber); + Integer proposalId = proposalws3vo.getProposalId(); + List dewar3vos = getDewar3Service().findFiltered(proposalId, shippingId, null, + code, null, null, null, null, null, null, false, false); + if (dewar3vos != null && dewar3vos.size() > 0){ + return this.sendError("You cannot have 2 dewars with the same name in the same shipment at MAXIV"); + } + } dewar3vo = getDewar3Service().create(dewar3vo); } else { dewar3vo = getDewar3Service().findByPk(dewarId, false, false); @@ -346,7 +359,7 @@ public Response updateStatus( return this.sendResponse(Status.OK); } catch (Exception e) { this.logError("updateStatus", e, start, logger); - return this.sendResponse(Status.NOT_FOUND); + return this.sendResponse(Response.Status.NOT_FOUND); } } diff --git a/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/ShippingRestWebService.java b/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/ShippingRestWebService.java index ae67225b4..15fe0b4f9 100644 --- a/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/ShippingRestWebService.java +++ b/ispyb-ws/src/main/java/ispyb/ws/rest/proposal/ShippingRestWebService.java @@ -15,10 +15,7 @@ import ispyb.ws.rest.mx.MXRestWebService; import java.lang.reflect.Type; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import javax.annotation.security.RolesAllowed; import javax.ws.rs.FormParam; @@ -174,6 +171,24 @@ public Response getShipping(@PathParam("token") String token, @PathParam("propos } + /*@RolesAllowed({"User", "Manager", "Industrial", "Localcontact"}) + @GET + @Path("{token}/proposal/{proposal}/shipping/find/") + @Produces({ "application/json" }) + public Response getShippingByProposalAndName(@PathParam("token") String token, @PathParam("proposal") String proposal, + @FormParam("name") String name, ) throws Exception { + + long id = this.logInit("getShippingByProposalAndName", logger, token, proposal, name); + try { + List result = this.getShipping3Service().findFiltered(null, name, proposal, null, null, null, null, null, false); + this.logFinish("getShippingByProposalAndName", id, logger); + return sendResponse(result); + } catch (Exception e) { + return this.logError("getShipping", e, id, logger); + } + + }*/ + @RolesAllowed({"User", "Manager", "Industrial", "Localcontact"}) @GET @@ -462,15 +477,39 @@ public Response saveShipping(@PathParam("token") String token, @PathParam("propo Shipping3VO shipping3VO = new Shipping3VO(); - if ((shippingId != null) && (shippingId != "")) { + if ((shippingId != null) && (!"".equals(shippingId))) { try{ - shipping3VO = this.getShipping3Service().findByPk(Integer.parseInt(shippingId), true); + shipping3VO = this.getShipping3Service().findByPk(Integer.parseInt(shippingId), true); } catch(Exception e){ System.out.println("shipping Id is not a number"); } } + if (Constants.SITE_IS_MAXIV()) { + try { + String proposalCode = proposal.substring(0, 2); + String proposalNumber = proposal.substring(proposal.length() - 8); + List results = this.getShipping3Service().findFiltered(null, name, proposalCode, proposalNumber, null, null, null, null, false); + if (results != null && !results.isEmpty()) { + if ((shippingId != null) && (!"".equals(shippingId))) { + for (int i=0;i