From 9e07d697635b8142cd5e492c44b433adb7c8e8df Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Fri, 4 Jan 2019 17:51:06 +0100 Subject: [PATCH 01/30] debug --- src/Orthanc_Standalone/Orthanc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orthanc_Standalone/Orthanc.json b/src/Orthanc_Standalone/Orthanc.json index 1d53a77a..d66916fe 100644 --- a/src/Orthanc_Standalone/Orthanc.json +++ b/src/Orthanc_Standalone/Orthanc.json @@ -40,7 +40,7 @@ // folders, in which case they will be scanned non-recursively to // find shared libraries. Backslashes must be either escaped by // doubling them, or replaced by forward slashes "/". - "Plugins" : [ + "Plugins" : ["./" ], // Maximum number of processing jobs that are simultaneously running From e6fcd3e5c57fb57b186325419a4420b4ac3a2e29 Mon Sep 17 00:00:00 2001 From: salim Date: Fri, 4 Jan 2019 23:47:57 +0100 Subject: [PATCH 02/30] debug --- src/org/petctviewer/orthanc/setup/Run_Orthanc.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/petctviewer/orthanc/setup/Run_Orthanc.java b/src/org/petctviewer/orthanc/setup/Run_Orthanc.java index 87a8c1fa..d06148e9 100644 --- a/src/org/petctviewer/orthanc/setup/Run_Orthanc.java +++ b/src/org/petctviewer/orthanc/setup/Run_Orthanc.java @@ -71,7 +71,6 @@ else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){ else if (System.getProperty("os.name").toLowerCase().startsWith("linux")){ resourceName="Orthanc_Standalone/Orthanc-1.5.1-ReleaseLinux"; fileExecName="Orthanc-1.5.1-ReleaseLinux"; - resourceLibPath="Orthanc_Standalone/libOrthancWebViewer.so"; resourceLibName.add("libOrthancWebViewer.so"); resourceLibName.add("libOrthancTransfers.so"); @@ -95,6 +94,7 @@ public String copyOrthanc(String installPath) throws Exception { File FileExe=new File(file.toString()+File.separator+fileExecName); System.out.println(FileExe); File FileJSON=new File(file.toString()+File.separator+orthancJsonName); + System.out.println(FileJSON); InputStream in = ClassLoader.getSystemResourceAsStream(resourceName); InputStream inJson = ClassLoader.getSystemResourceAsStream(resourceNameJSON); @@ -122,6 +122,8 @@ public String copyOrthanc(String installPath) throws Exception { orthancJson=FileJSON; startOrthanc(); + + return resourceName; @@ -175,7 +177,9 @@ public void run() { System.out.println(line); if (line.contains("Orthanc has started")) { isStarted=true; - System.out.println("confirmation"); ; + System.out.println("confirmation"); + //SK A REVOIR + connexionHttp.testConnexion(); } } From bef37b8002a14138f09d3b064f875ed2a791f21f Mon Sep 17 00:00:00 2001 From: salim Date: Sun, 13 Jan 2019 10:48:04 +0100 Subject: [PATCH 03/30] rest password check --- src/org/petctviewer/orthanc/CTP/CTP.java | 99 +++++++++++++------- src/org/petctviewer/orthanc/CTP/CTP_Gui.java | 13 ++- 2 files changed, 73 insertions(+), 39 deletions(-) diff --git a/src/org/petctviewer/orthanc/CTP/CTP.java b/src/org/petctviewer/orthanc/CTP/CTP.java index c695e60a..324f85a6 100644 --- a/src/org/petctviewer/orthanc/CTP/CTP.java +++ b/src/org/petctviewer/orthanc/CTP/CTP.java @@ -6,10 +6,13 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.ProtocolException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import javax.swing.JOptionPane; + import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -32,6 +35,26 @@ public CTP(String username, String password, String serverAdress) { } + public void checkLogin() throws Exception { + JSONObject jsonPost=new JSONObject(); + jsonPost.put("username", username); + jsonPost.put("password", password); + String answser=makePostConnection("/Rest_Api/check_login.php",jsonPost.toString()); + System.out.println(answser); + JSONObject response = null; + try { + response=(JSONObject) parser.parse(answser); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(!response.get("login").equals("Allowed")) { + JOptionPane.showMessageDialog(null, response.get("login").toString(), "Login Error", JOptionPane.ERROR_MESSAGE); + throw new Exception("No access"); + } + + } + @SuppressWarnings("unchecked") public String[] getAvailableStudies(){ JSONObject jsonPost=new JSONObject(); @@ -42,7 +65,7 @@ public String[] getAvailableStudies(){ String answser=makePostConnection("/Rest_Api/get-studies.php",jsonPost.toString()); System.out.println(answser); studies=(JSONArray) parser.parse(answser); - } catch (IOException | ParseException e) { + } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -66,7 +89,7 @@ public String[] getAvailableVisits(String studyName) { try { String answser=makePostConnection("/Rest_Api/get-visits.php",jsonPost.toString()); visits=(JSONArray) parser.parse(answser); - } catch (IOException | ParseException e) { + } catch ( ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -96,7 +119,7 @@ public JSONArray getAvailableImports(String studyName, String visitName) { try { String answser=makePostConnection("/Rest_Api/get-possible-import.php", jsonPost.toString()); visits=(JSONArray) parser.parse(answser); - } catch (IOException | ParseException e) { + } catch ( ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -120,13 +143,16 @@ public boolean validateUpload(JSONArray studiesArray) { System.out.println(jsonPost.toString()); JSONObject visits = null; + + String answser=makePostConnection("/Rest_Api/validate-upload.php", jsonPost.toString()); + System.out.println(answser); try { - String answser=makePostConnection("/Rest_Api/validate-upload.php", jsonPost.toString()); - System.out.println(answser); visits=(JSONObject) parser.parse(answser); - } catch (IOException | ParseException e) { + } catch (ParseException e) { + // TODO Auto-generated catch block e.printStackTrace(); } + return (boolean) visits.get("recivedConfirmation"); @@ -134,39 +160,42 @@ public boolean validateUpload(JSONArray studiesArray) { } - private String makePostConnection(String apiUrl, String post) throws IOException { + private String makePostConnection(String apiUrl, String post) { URL url = null; + StringBuilder sb=new StringBuilder(); try { - url = new URL(serverAdress+apiUrl); - } catch ( MalformedURLException ex) { } - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - if((serverAdress != null && serverAdress.contains("https")) ){ - try{ - HttpsTrustModifier.Trust(conn); - }catch (Exception e){ - throw new IOException("Cannot allow self-signed certificates"); + url = new URL(serverAdress+apiUrl); + + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + if((serverAdress != null && serverAdress.contains("https")) ){ + try{ + HttpsTrustModifier.Trust(conn); + }catch (Exception e){ + + } } - } - if(this.authentication != null){ - conn.setRequestProperty("Authorization", "Basic " + this.authentication); - } - OutputStream os = conn.getOutputStream(); - os.write(post.getBytes()); - os.flush(); - conn.getResponseMessage(); - - StringBuilder sb=new StringBuilder(); - if (conn !=null) { - BufferedReader br = new BufferedReader(new InputStreamReader( - (conn.getInputStream()))); - String output; - while ((output = br.readLine()) != null) { - sb.append(output); + if(this.authentication != null){ + conn.setRequestProperty("Authorization", "Basic " + this.authentication); } - conn.disconnect(); - } + OutputStream os = conn.getOutputStream(); + os.write(post.getBytes()); + os.flush(); + conn.getResponseMessage(); + + + if (conn !=null) { + BufferedReader br = new BufferedReader(new InputStreamReader( + (conn.getInputStream()))); + String output; + while ((output = br.readLine()) != null) { + sb.append(output); + } + conn.disconnect(); + } + } catch ( IOException ex) { }; + return sb.toString(); } diff --git a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java index 31e6a9ad..55d5e32e 100644 --- a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java +++ b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java @@ -195,10 +195,15 @@ public void actionPerformed(ActionEvent arg0) { comboBox_Visits.removeAllItems(); if (tablePatient.getModel().getRowCount()>0) modelTablePatient.setRowCount(0); ctp=new CTP(CTP_Username.getText(), new String(CTP_Password.getPassword()), CTPAddress ); - String[] studies=ctp.getAvailableStudies(); - comboBox_Studies.addItem("Choose"); - for (int i=0; i Date: Sun, 13 Jan 2019 15:02:29 +0100 Subject: [PATCH 04/30] debug ctp --- src/org/petctviewer/orthanc/CTP/CTP.java | 9 +++++---- src/org/petctviewer/orthanc/CTP/CTP_Gui.java | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/org/petctviewer/orthanc/CTP/CTP.java b/src/org/petctviewer/orthanc/CTP/CTP.java index 324f85a6..f4105a11 100644 --- a/src/org/petctviewer/orthanc/CTP/CTP.java +++ b/src/org/petctviewer/orthanc/CTP/CTP.java @@ -30,12 +30,11 @@ public CTP(String username, String password, String serverAdress) { this.username=username; this.password=password; this.serverAdress=serverAdress; - getAvailableStudies(); //String authentication = Base64.getEncoder().encodeToString(("httpLogin" + ":" + "httpPassword").getBytes()); } - public void checkLogin() throws Exception { + public boolean checkLogin() { JSONObject jsonPost=new JSONObject(); jsonPost.put("username", username); jsonPost.put("password", password); @@ -48,11 +47,13 @@ public void checkLogin() throws Exception { // TODO Auto-generated catch block e.printStackTrace(); } - if(!response.get("login").equals("Allowed")) { + if(!response.get("login").equals("Allowed") ) { JOptionPane.showMessageDialog(null, response.get("login").toString(), "Login Error", JOptionPane.ERROR_MESSAGE); - throw new Exception("No access"); + return false; } + return true; + } @SuppressWarnings("unchecked") diff --git a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java index 55d5e32e..826c341b 100644 --- a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java +++ b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java @@ -195,17 +195,19 @@ public void actionPerformed(ActionEvent arg0) { comboBox_Visits.removeAllItems(); if (tablePatient.getModel().getRowCount()>0) modelTablePatient.setRowCount(0); ctp=new CTP(CTP_Username.getText(), new String(CTP_Password.getPassword()), CTPAddress ); - try { - ctp.checkLogin(); + + boolean checklogin=ctp.checkLogin(); + if(checklogin) { String[] studies=ctp.getAvailableStudies(); comboBox_Studies.addItem("Choose"); for (int i=0; i Date: Wed, 23 Jan 2019 12:40:37 +0100 Subject: [PATCH 05/30] explore reading --- .../orthanc/ParametreConnexionHttp.java | 15 +++ .../orthanc/reader/Read_Orthanc.java | 123 ++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 src/org/petctviewer/orthanc/reader/Read_Orthanc.java diff --git a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java index b40aec2a..97a84370 100644 --- a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java +++ b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java @@ -18,7 +18,9 @@ package org.petctviewer.orthanc; import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; @@ -235,6 +237,19 @@ public StringBuilder makePostConnectionAndStringBuilder(String apiUrl, String po return sb; } + public InputStream OpenUrl(String apiUrl) { + HttpURLConnection conn = this.makeGetConnection(apiUrl); + InputStream is=null; + + try { + is = conn.getInputStream(); + } catch(FileNotFoundException fnfe) {return null;} + + catch (Exception e) { } + + return is; + } + public void makeDeleteConnection(String apiUrl) { URL url = null; diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java new file mode 100644 index 00000000..e49560d9 --- /dev/null +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -0,0 +1,123 @@ +package org.petctviewer.orthanc.reader; + +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.util.ArrayList; +import java.util.Collections; + +import javax.imageio.ImageIO; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.petctviewer.orthanc.ParametreConnexionHttp; + +import ij.ImagePlus; +import ij.ImageStack; +import ij.process.ColorProcessor; +import ij.process.ImageProcessor; +import ij.process.ShortProcessor; + +public class Read_Orthanc { + + ParametreConnexionHttp connexion=new ParametreConnexionHttp(); + + ImageProcessor readCompressed(String uuid) { + ImageProcessor slice=null; + try { + + String imgType = "/image-uint16"; + //int bufType = BufferedImage.TYPE_USHORT_GRAY; + /*if(SC) { + imgType = "/preview"; + bufType = BufferedImage.TYPE_3BYTE_BGR; + }*/ + String uri = "/instances/" + uuid + "/image-uint16"; + BufferedImage bi = ImageIO.read( connexion.OpenUrl(uri)); + + //if( SC) slice = new ColorProcessor(bi); + //else + slice = new ShortProcessor(bi); + /* + if( stack == null) { + ColorModel cm = slice.getColorModel(); + stack = new ImageStack(slice.getWidth(), slice.getHeight(), cm); + } + stack.addSlice(tmp1, slice); + */ + String tmp1 = "Compressed \n" + this.extractDicomInfo(uuid); + ImagePlus ip=new ImagePlus(tmp1,slice); + ip.show(); + } catch (Exception e) { } + return slice; + } + + private String extractDicomInfo(String uuid) { + JSONObject tags = (JSONObject) ReadJson("instances/" + uuid + "/tags"); + if (tags == null || tags.isEmpty()) return ""; + String info = new String(); + String type1; + + ArrayList tagsIndex = new ArrayList(); + for (Object tag : tags.keySet()) { + tagsIndex.add((String) tag); + } + + Collections.sort(tagsIndex); + for (String tag : tagsIndex) { + JSONObject value = (JSONObject) tags.get(tag); + type1 = (String) value.get("Type"); + if (type1.equals("String")) { + info += (tag + " " + (String) value.get("Name") + + ": " + (String) value.get("Value") + "\n"); + } else { + if( type1.equals("Sequence")) { + info = addSequence(info, value, tag); + } + } + } + return info; + } + + private int seqDepth = 0; + + private String addSequence(String info0, JSONObject value, Object tag) { + String type2, info = info0; + JSONArray seq0; + JSONObject seqVal, vals; + seq0 = (JSONArray)value.get("Value"); + if( seq0 == null || seq0.isEmpty()) { + return info; // ignore empty sequences + } + info += tag + getIndent() + (String) value.get("Name") +"\n"; + seqDepth++; + seqVal = (JSONObject) seq0.get(0); + + ArrayList tagsIndex = new ArrayList(); + for( Object tag0 : seqVal.keySet()) { + tagsIndex.add((String) tag0); + } + Collections.sort(tagsIndex); + + for( Object tag1 : tagsIndex) { + vals = (JSONObject) seqVal.get(tag1); + type2 = (String) vals.get("Type"); + if( type2.equals("String")) { + info += tag1 + getIndent() + (String) vals.get("Name") + + ": " + (String) vals.get("Value")+ "\n"; + } else { + if(type2.equals("Sequence")) { + info = addSequence(info, vals, tag1); + } + } + } + seqDepth--; + return info; + } + + private String getIndent() { + String indent = " "; + for( int i=0; i Date: Wed, 23 Jan 2019 17:04:55 +0100 Subject: [PATCH 06/30] progress on monitoring rate --- .../orthanc/monitoring/Burner_Settings.java | 18 ++++++++++++++++++ .../orthanc/monitoring/CD_Burner.java | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java index 05e2f98c..f59d76d0 100644 --- a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java +++ b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java @@ -39,6 +39,8 @@ import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.DefaultComboBoxModel; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; @SuppressWarnings("serial") public class Burner_Settings extends JDialog { @@ -60,6 +62,7 @@ public class Burner_Settings extends JDialog { private String fijiDirectory; private String burnerManifacturer; private String suportType; + private JSpinner spinnerTiming; private Boolean deleteStudies; private JComboBox comboBoxSupportType, comboBoxBurnerManufacturer; @@ -270,6 +273,20 @@ public void actionPerformed(ActionEvent arg0) { comboBoxBurnerManufacturer.setSelectedItem(burnerManifacturer); } } + { + JLabel lblMonitorEachsec = new JLabel("Monitor Each (sec)"); + lblMonitorEachsec.setHorizontalAlignment(SwingConstants.CENTER); + contentPanel.add(lblMonitorEachsec); + } + { + JPanel panel = new JPanel(); + contentPanel.add(panel); + + spinnerTiming = new JSpinner(); + spinnerTiming.setModel(new SpinnerNumberModel(new Integer(90), new Integer(10), null, new Integer(1))); + panel.add(spinnerTiming); + + } } @@ -282,6 +299,7 @@ public void setCDPreference() { dateFormatChoix=jPrefer.get("DateFormat", null); deleteStudies=jPrefer.getBoolean("deleteStudies", false); suportType=jPrefer.get("suportType", "Auto"); + monitoringTime=jPrefer.get("monitoringTime", 90); } diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index ff5db6db..5fc21dd4 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -57,6 +57,7 @@ public class CD_Burner { private String labelFile; private String epsonDirectory; private String fijiDirectory; + private int monitoringTime; private Boolean deleteStudies; private String suportType; private JTable table_burning_history; @@ -109,7 +110,7 @@ public void run() { //running timer task as daemon thread timer = new Timer(true); //Toutes les 90 seconds - timer.scheduleAtFixedRate(timerTask, 0, (90*1000)); + timer.scheduleAtFixedRate(timerTask, 0, (monitoringTime*1000)); } } @@ -473,6 +474,7 @@ public void setCDPreference() { dateFormatChoix=jPrefer.get("DateFormat", null); deleteStudies=jPrefer.getBoolean("deleteStudies", false); suportType=jPrefer.get("suportType", "Auto"); + monitoringTime=jPrefer.getInt("monitoringTime", 90); } From af495cec741742c1d0f243f7b1dbb3929628f136 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 09:22:08 +0100 Subject: [PATCH 07/30] frequence monitoring of cd burner option --- src/org/petctviewer/orthanc/monitoring/Burner_Settings.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java index f59d76d0..3261820c 100644 --- a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java +++ b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java @@ -64,6 +64,7 @@ public class Burner_Settings extends JDialog { private String suportType; private JSpinner spinnerTiming; private Boolean deleteStudies; + private int monitoringTime; private JComboBox comboBoxSupportType, comboBoxBurnerManufacturer; /** @@ -243,6 +244,7 @@ public void actionPerformed(ActionEvent e) { jPrefer.put("suportType", comboBoxSupportType.getSelectedItem().toString()); //On ajoute la string du format date jPrefer.put("DateFormat", buttonGroup.getSelection().getActionCommand()); + jPrefer.putInt("monitoringTime", (int) spinnerTiming.getValue()); //on dispose dispose(); } @@ -284,6 +286,7 @@ public void actionPerformed(ActionEvent arg0) { spinnerTiming = new JSpinner(); spinnerTiming.setModel(new SpinnerNumberModel(new Integer(90), new Integer(10), null, new Integer(1))); + spinnerTiming.setValue(monitoringTime); panel.add(spinnerTiming); } @@ -299,7 +302,7 @@ public void setCDPreference() { dateFormatChoix=jPrefer.get("DateFormat", null); deleteStudies=jPrefer.getBoolean("deleteStudies", false); suportType=jPrefer.get("suportType", "Auto"); - monitoringTime=jPrefer.get("monitoringTime", 90); + monitoringTime=jPrefer.getInt("monitoringTime", 90); } From 2332123cfb50f57f602c00d0f6f48fe4f66874fa Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 10:34:23 +0100 Subject: [PATCH 08/30] reading --- .../orthanc/ParametreConnexionHttp.java | 40 ++++++++++++++++--- .../orthanc/reader/Read_Orthanc.java | 25 +++++++++--- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java index 97a84370..3249c075 100644 --- a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java +++ b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java @@ -132,6 +132,34 @@ public HttpURLConnection makeGetConnection(String apiUrl) { return conn; } + +public HttpURLConnection makeGetConnectionImage(String apiUrl) { + + HttpURLConnection conn=null; + URL url = null; + try { + url = new URL(fullAddress+apiUrl); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("Accept", "image/png"); + conn.setDoOutput(true); + conn.setRequestMethod("GET"); + if((fullAddress != null && fullAddress.contains("https"))){ + HttpsTrustModifier.Trust(conn); + } + if(authentication != null){ + conn.setRequestProperty("Authorization", "Basic " + authentication); + } + conn.getResponseMessage(); + + } catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + return conn; + + } public StringBuilder makeGetConnectionAndStringBuilder(String apiUrl) { HttpURLConnection conn = null; @@ -237,16 +265,16 @@ public StringBuilder makePostConnectionAndStringBuilder(String apiUrl, String po return sb; } - public InputStream OpenUrl(String apiUrl) { - HttpURLConnection conn = this.makeGetConnection(apiUrl); + public InputStream openImage(String apiUrl) { + HttpURLConnection conn = this.makeGetConnectionImage(apiUrl); + InputStream is=null; try { - is = conn.getInputStream(); - } catch(FileNotFoundException fnfe) {return null;} - - catch (Exception e) { } + is = conn.getInputStream(); + } catch(IOException e) { e.printStackTrace();} + System.out.println(conn); return is; } diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index e49560d9..ae8f6647 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -1,7 +1,6 @@ package org.petctviewer.orthanc.reader; import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; import java.util.ArrayList; import java.util.Collections; @@ -9,17 +8,23 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import org.petctviewer.orthanc.ParametreConnexionHttp; import ij.ImagePlus; -import ij.ImageStack; -import ij.process.ColorProcessor; import ij.process.ImageProcessor; import ij.process.ShortProcessor; + public class Read_Orthanc { ParametreConnexionHttp connexion=new ParametreConnexionHttp(); + + public static void main(String[] args) { + Read_Orthanc orthancReader= new Read_Orthanc(); + orthancReader.readCompressed("87c4fd56-6d4e7573-c3c640ca-b33a09b9-5adfa7ee"); + } ImageProcessor readCompressed(String uuid) { ImageProcessor slice=null; @@ -32,7 +37,7 @@ ImageProcessor readCompressed(String uuid) { bufType = BufferedImage.TYPE_3BYTE_BGR; }*/ String uri = "/instances/" + uuid + "/image-uint16"; - BufferedImage bi = ImageIO.read( connexion.OpenUrl(uri)); + BufferedImage bi = ImageIO.read( connexion.openImage(uri)); //if( SC) slice = new ColorProcessor(bi); //else @@ -47,12 +52,20 @@ ImageProcessor readCompressed(String uuid) { String tmp1 = "Compressed \n" + this.extractDicomInfo(uuid); ImagePlus ip=new ImagePlus(tmp1,slice); ip.show(); - } catch (Exception e) { } + } catch (Exception e) { e.printStackTrace();} return slice; } private String extractDicomInfo(String uuid) { - JSONObject tags = (JSONObject) ReadJson("instances/" + uuid + "/tags"); + StringBuilder sb=connexion.makeGetConnectionAndStringBuilder("/instances/" + uuid + "/tags"); + JSONParser parser=new JSONParser(); + JSONObject tags=null; + try { + tags = (JSONObject) parser.parse(sb.toString()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (tags == null || tags.isEmpty()) return ""; String info = new String(); String type1; From 7ce63bf333165f090c1bcbdbc6102817b899edaa Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 11:32:48 +0100 Subject: [PATCH 09/30] Read In Progress --- .../orthanc/reader/Read_Orthanc.java | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index ae8f6647..4b0ec822 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -13,24 +13,56 @@ import org.petctviewer.orthanc.ParametreConnexionHttp; import ij.ImagePlus; +import ij.ImageStack; import ij.process.ImageProcessor; import ij.process.ShortProcessor; public class Read_Orthanc { + JSONParser parser=new JSONParser(); ParametreConnexionHttp connexion=new ParametreConnexionHttp(); public static void main(String[] args) { Read_Orthanc orthancReader= new Read_Orthanc(); - orthancReader.readCompressed("87c4fd56-6d4e7573-c3c640ca-b33a09b9-5adfa7ee"); + orthancReader.readSerie("c527df8d-4472b531-e22cdd98-5c5512a4-9287556d"); } + + public void readSerie(String uuid) { + StringBuilder sb=connexion.makeGetConnectionAndStringBuilder("/series/"+uuid); + JSONObject seriesDetails = null; + try { + seriesDetails=(JSONObject)parser.parse(sb.toString()); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + ImageStack stack = null; + + JSONArray instanceIDList=(JSONArray) seriesDetails.get("Instances"); + for(int i=0 ; i Date: Thu, 24 Jan 2019 12:50:56 +0100 Subject: [PATCH 10/30] reading progress --- .../orthanc/ParametreConnexionHttp.java | 3 +- .../orthanc/anonymize/VueAnon.java | 21 ++- .../orthanc/reader/Read_Orthanc.java | 130 ++++++++++++++---- 3 files changed, 126 insertions(+), 28 deletions(-) diff --git a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java index 3249c075..8e338141 100644 --- a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java +++ b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java @@ -273,8 +273,7 @@ public InputStream openImage(String apiUrl) { try { is = conn.getInputStream(); } catch(IOException e) { e.printStackTrace();} - - System.out.println(conn); + return is; } diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index c6bde988..8395a572 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -98,6 +98,7 @@ import org.petctviewer.orthanc.importdicom.ImportDCM; import org.petctviewer.orthanc.monitoring.Monitoring_GUI; import org.petctviewer.orthanc.query.*; +import org.petctviewer.orthanc.reader.Read_Orthanc; import org.petctviewer.orthanc.setup.ConnectionSetup; import org.petctviewer.orthanc.setup.Run_Orthanc; @@ -1361,11 +1362,29 @@ protected void done() { c.gridy = 0; tablesPanel.add(jscp2,c); + JPanel panelTableauSeries=new JPanel(new BorderLayout()); JScrollPane jscp3 = new JScrollPane(tableauSeries); jscp3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); c.gridx = 2; c.gridy = 0; - tablesPanel.add(jscp3,c); + panelTableauSeries.add(jscp3, BorderLayout.CENTER); + JButton btnReadSeries=new JButton("Open Images"); + btnReadSeries.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + int[] selectedListes=tableauSeries.getSelectedRows(); + for( int line : selectedListes) { + String id=(String) tableauSeries.getValueAt(line, 4); + new Read_Orthanc(id, connexionHttp); + } + + + } + + }); + panelTableauSeries.add(btnReadSeries, BorderLayout.SOUTH); + tablesPanel.add(panelTableauSeries,c); mainPanel.add(tablesPanel); mainPanel.add(toolbox); diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index 4b0ec822..b0f6e574 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -3,6 +3,8 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; +import java.util.Locale; +import java.util.Scanner; import javax.imageio.ImageIO; @@ -14,6 +16,8 @@ import ij.ImagePlus; import ij.ImageStack; +import ij.measure.Calibration; +import ij.process.ColorProcessor; import ij.process.ImageProcessor; import ij.process.ShortProcessor; @@ -21,11 +25,15 @@ public class Read_Orthanc { JSONParser parser=new JSONParser(); - ParametreConnexionHttp connexion=new ParametreConnexionHttp(); + ParametreConnexionHttp connexion; + + public Read_Orthanc(String serieUID, ParametreConnexionHttp connexion) { + this.connexion=connexion; + readSerie(serieUID); + } public static void main(String[] args) { - Read_Orthanc orthancReader= new Read_Orthanc(); - orthancReader.readSerie("c527df8d-4472b531-e22cdd98-5c5512a4-9287556d"); + new Read_Orthanc("b90e3e43-478efadb-ed824c50-46f2193f-b7dd8941", new ParametreConnexionHttp()); } public void readSerie(String uuid) { @@ -40,12 +48,20 @@ public void readSerie(String uuid) { ImageStack stack = null; JSONArray instanceIDList=(JSONArray) seriesDetails.get("Instances"); + boolean screenCapture=false; for(int i=0 ; i 0 || key2 == null) { + // here we have a problem that the key may appear more than once. + // for example a SeriesUID may appear in a sequence. Look for ">". + if( k0 > 0) { + tmp1 = meta.substring(k0+4, k0+16); + k1 = tmp1.indexOf(">"); + while(k1 > 0) { // do search last value + k1 = meta.indexOf(key2, k0+4); + if( k1 > 0) k0 = k1; + } + } + k1 = meta.indexOf("\n", k0); + if( k1 < 0) return null; + tmp1 = meta.substring(k0, k1); + k1 = tmp1.indexOf(": "); + if( k1 > 0) ret1 = tmp1.substring(k1+2); + else ret1 = tmp1; + ret1 = ret1.trim(); + if( ret1.isEmpty()) ret1 = null; + } + return ret1; + } + + private float[] parseMultFloat( String tmp1) { + float [] ret1 = null; + double[] val = new double[32]; // arbitrary limit of 32 + int i, n = 0; + if( tmp1 == null) return null; + String tmp2 = tmp1.replace("\\ ", "\\"); + Scanner sc = new Scanner(tmp2).useDelimiter("\\\\"); + sc.useLocale(Locale.US); + while(sc.hasNextDouble() && n < 32) { + val[n++] = sc.nextDouble(); + } + sc.close(); + if( n>0) { + ret1 = new float[n]; + for( i=0; i Date: Thu, 24 Jan 2019 12:51:37 +0100 Subject: [PATCH 11/30] fix --- src/org/petctviewer/orthanc/ParametreConnexionHttp.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java index 8e338141..38518473 100644 --- a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java +++ b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java @@ -18,7 +18,6 @@ package org.petctviewer.orthanc; import java.io.BufferedReader; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; From e65a257bd7e75769262698ad03454cbe4775e08c Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 14:05:14 +0100 Subject: [PATCH 12/30] reader progress --- .../orthanc/anonymize/VueAnon.java | 26 +++++++++++++++++-- .../orthanc/reader/Read_Orthanc.java | 9 ++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index 8395a572..37de955b 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -1374,11 +1374,33 @@ protected void done() { @Override public void actionPerformed(ActionEvent arg0) { int[] selectedListes=tableauSeries.getSelectedRows(); + List ids=new ArrayList(); for( int line : selectedListes) { - String id=(String) tableauSeries.getValueAt(line, 4); - new Read_Orthanc(id, connexionHttp); + ids.add((String) tableauSeries.getValueAt(line, 4)); + } + SwingWorker worker = new SwingWorker(){ + + @Override + protected Void doInBackground() { + btnReadSeries.setText("Reading Series"); + for(String id : ids) { + new Read_Orthanc(id, connexionHttp); + + } + + return null; + } + + @Override + public void done(){ + btnReadSeries.setText("Open Images"); + + } + }; + + worker.execute(); } diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index b0f6e574..a466f989 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -14,6 +14,7 @@ import org.json.simple.parser.ParseException; import org.petctviewer.orthanc.ParametreConnexionHttp; +import ij.IJ; import ij.ImagePlus; import ij.ImageStack; import ij.measure.Calibration; @@ -67,10 +68,13 @@ public void readSerie(String uuid) { stack.addSlice(metadata, ip); + + IJ.showProgress((double) i/instanceIDList.size()); } ImagePlus imp=new ImagePlus(); imp.setStack(stack); updateCalibration(imp); + imp.show(); } @@ -177,7 +181,7 @@ private String getIndent() { } private void updateCalibration( ImagePlus img) { - String meta=img.getInfoProperty(); + String meta=img.getStack().getSliceLabel(1); double[] coeff = new double[2]; float[] spacing; String tmp1; @@ -194,6 +198,8 @@ private void updateCalibration( ImagePlus img) { img.getCalibration().pixelWidth = spacing[0]; img.getCalibration().pixelHeight = spacing[1]; img.getCalibration().setUnit("mm"); + + img.setTitle(getDicomValue(meta, "0010,0010")+getDicomValue(meta, "0008,0022")+getDicomValue(meta, "0008,0103E")); } private String getDicomValue( String meta, String key1) { @@ -234,6 +240,7 @@ private float[] parseMultFloat( String tmp1) { int i, n = 0; if( tmp1 == null) return null; String tmp2 = tmp1.replace("\\ ", "\\"); + @SuppressWarnings("resource") Scanner sc = new Scanner(tmp2).useDelimiter("\\\\"); sc.useLocale(Locale.US); while(sc.hasNextDouble() && n < 32) { From d6de6386e4e05a41f16aa1749f39c514fc9da21f Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 14:06:38 +0100 Subject: [PATCH 13/30] read progress --- src/org/petctviewer/orthanc/reader/Read_Orthanc.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index a466f989..ae516d79 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -74,7 +74,6 @@ public void readSerie(String uuid) { ImagePlus imp=new ImagePlus(); imp.setStack(stack); updateCalibration(imp); - imp.show(); } @@ -199,7 +198,7 @@ private void updateCalibration( ImagePlus img) { img.getCalibration().pixelHeight = spacing[1]; img.getCalibration().setUnit("mm"); - img.setTitle(getDicomValue(meta, "0010,0010")+getDicomValue(meta, "0008,0022")+getDicomValue(meta, "0008,0103E")); + img.setTitle(getDicomValue(meta, "0010,0010")+"-"+getDicomValue(meta, "0008,0022")+"-"+getDicomValue(meta, "0008,0103E")); } private String getDicomValue( String meta, String key1) { From 3977ccc4a569b4d0524369ea0a2fcdb2b0d21f1d Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 14:06:39 +0100 Subject: [PATCH 14/30] read progress From bff935f382a3499c1ce7d6e6ab205ab66fd283f4 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 14:59:05 +0100 Subject: [PATCH 15/30] progress --- .../orthanc/anonymize/VueAnon.java | 15 +++++++ .../orthanc/reader/Read_Orthanc.java | 6 +-- .../orthanc/reader/Run_Pet_Ct.java | 40 +++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index 37de955b..efe76166 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -1375,8 +1375,13 @@ protected void done() { public void actionPerformed(ActionEvent arg0) { int[] selectedListes=tableauSeries.getSelectedRows(); List ids=new ArrayList(); + boolean pet = false; + boolean ct = false; + for( int line : selectedListes) { ids.add((String) tableauSeries.getValueAt(line, 4)); + if(tableauSeries.getValueAt(line, 1).equals("PT")) pet=true; + if(tableauSeries.getValueAt(line, 1).equals("CT")) ct=true; } @@ -1390,6 +1395,8 @@ protected Void doInBackground() { } + + return null; } @@ -1402,8 +1409,16 @@ public void done(){ worker.execute(); + if(pet && ct) { + System.out.println("start viewer"); + + } + + } + + }); panelTableauSeries.add(btnReadSeries, BorderLayout.SOUTH); tablesPanel.add(panelTableauSeries,c); diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index ae516d79..dc8c4f15 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -33,10 +33,6 @@ public Read_Orthanc(String serieUID, ParametreConnexionHttp connexion) { readSerie(serieUID); } - public static void main(String[] args) { - new Read_Orthanc("b90e3e43-478efadb-ed824c50-46f2193f-b7dd8941", new ParametreConnexionHttp()); - } - public void readSerie(String uuid) { StringBuilder sb=connexion.makeGetConnectionAndStringBuilder("/series/"+uuid); JSONObject seriesDetails = null; @@ -69,7 +65,7 @@ public void readSerie(String uuid) { stack.addSlice(metadata, ip); - IJ.showProgress((double) i/instanceIDList.size()); + IJ.showProgress((double) i+1/instanceIDList.size()); } ImagePlus imp=new ImagePlus(); imp.setStack(stack); diff --git a/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java b/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java new file mode 100644 index 00000000..f82a07ea --- /dev/null +++ b/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java @@ -0,0 +1,40 @@ +package org.petctviewer.orthanc.reader; + +import java.util.ArrayList; + +import ij.IJ; +import ij.ImageJ; +import ij.ImagePlus; + +public class Run_Pet_Ct { + + + private Run_Pet_Ct(ArrayList imagePlusList) { + String seriesUIDs = ChoosePetCt.buildSeriesUIDs(imagePlusList); + if( seriesUIDs == null) return; + if( seriesUIDs.startsWith("2CTs")) seriesUIDs = ""; + IJ.runPlugIn("Pet_Ct_Viewer", seriesUIDs); + wait4bkgd(); + } + + private void wait4bkgd() { + Integer i = 0, j; + while( ChoosePetCt.loadingData == 1 || ChoosePetCt.loadingData == 3) { + mySleep(200); + i++; + if( (i % 20) == 0 && ChoosePetCt.loadingData == 1) { + ImageJ ij = IJ.getInstance(); + if( ij != null) ij.toFront(); + j = i/5; + IJ.showStatus("Loading data, please wait " + j.toString()); + } + } + } + + private void mySleep(int msec) { + try { + Thread.sleep(msec); + } catch (Exception e) { e.printStackTrace();} + } + +} From 0cf94a8d9cbcab48fc66c44cc1f3aa48f95ee413 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 15:05:01 +0100 Subject: [PATCH 16/30] reader progress --- src/org/petctviewer/orthanc/anonymize/VueAnon.java | 9 +++++++-- src/org/petctviewer/orthanc/reader/Read_Orthanc.java | 7 ++++--- src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index efe76166..fc293a93 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -88,6 +88,7 @@ import com.michaelbaranov.microba.calendar.DatePicker; +import ij.ImagePlus; import ij.plugin.PlugIn; import org.petctviewer.orthanc.*; @@ -99,6 +100,7 @@ import org.petctviewer.orthanc.monitoring.Monitoring_GUI; import org.petctviewer.orthanc.query.*; import org.petctviewer.orthanc.reader.Read_Orthanc; +import org.petctviewer.orthanc.reader.Run_Pet_Ct; import org.petctviewer.orthanc.setup.ConnectionSetup; import org.petctviewer.orthanc.setup.Run_Orthanc; @@ -1375,6 +1377,7 @@ protected void done() { public void actionPerformed(ActionEvent arg0) { int[] selectedListes=tableauSeries.getSelectedRows(); List ids=new ArrayList(); + ArrayList imagestacks=new ArrayList(); boolean pet = false; boolean ct = false; @@ -1391,7 +1394,9 @@ public void actionPerformed(ActionEvent arg0) { protected Void doInBackground() { btnReadSeries.setText("Reading Series"); for(String id : ids) { - new Read_Orthanc(id, connexionHttp); + Read_Orthanc reader=new Read_Orthanc(connexionHttp); + ImagePlus ip=reader.readSerie(id); + imagestacks.add(ip); } @@ -1411,7 +1416,7 @@ public void done(){ if(pet && ct) { System.out.println("start viewer"); - + new Run_Pet_Ct(imagestacks); } diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java index dc8c4f15..0b284bf9 100644 --- a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java +++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java @@ -28,12 +28,12 @@ public class Read_Orthanc { JSONParser parser=new JSONParser(); ParametreConnexionHttp connexion; - public Read_Orthanc(String serieUID, ParametreConnexionHttp connexion) { + public Read_Orthanc(ParametreConnexionHttp connexion) { this.connexion=connexion; - readSerie(serieUID); + } - public void readSerie(String uuid) { + public ImagePlus readSerie(String uuid) { StringBuilder sb=connexion.makeGetConnectionAndStringBuilder("/series/"+uuid); JSONObject seriesDetails = null; try { @@ -71,6 +71,7 @@ public void readSerie(String uuid) { imp.setStack(stack); updateCalibration(imp); imp.show(); + return imp; } diff --git a/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java b/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java index f82a07ea..3f1eade1 100644 --- a/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java +++ b/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java @@ -9,7 +9,7 @@ public class Run_Pet_Ct { - private Run_Pet_Ct(ArrayList imagePlusList) { + public Run_Pet_Ct(ArrayList imagePlusList) { String seriesUIDs = ChoosePetCt.buildSeriesUIDs(imagePlusList); if( seriesUIDs == null) return; if( seriesUIDs.startsWith("2CTs")) seriesUIDs = ""; From 8228d466e56814b698d39b313d4f0a0e10fe15ef Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 15:07:23 +0100 Subject: [PATCH 17/30] debg --- src/org/petctviewer/orthanc/anonymize/VueAnon.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index fc293a93..95ad59af 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -235,6 +235,9 @@ public class VueAnon extends JFrame implements PlugIn, ActionListener{ //CustomListener AnonymizeListener anonymizeListener; + // + private boolean fijiEnvironement=false; + public VueAnon() { super("Orthanc Tools"); @@ -1414,7 +1417,7 @@ public void done(){ worker.execute(); - if(pet && ct) { + if(pet && ct && fijiEnvironement) { System.out.println("start viewer"); new Run_Pet_Ct(imagestacks); } @@ -3017,6 +3020,7 @@ public void run(String string) { VueAnon anon=new VueAnon(); anon.setLocationRelativeTo(null); anon.setVisible(true); + fijiEnvironement=true; } From 1e822099c1993fcfb9266a56470426c321eaa806 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 15:32:40 +0100 Subject: [PATCH 18/30] progress --- .../orthanc/reader => }/Run_Pet_Ct.java | 2 +- .../orthanc/anonymize/VueAnon.java | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) rename src/{org/petctviewer/orthanc/reader => }/Run_Pet_Ct.java (91%) diff --git a/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java b/src/Run_Pet_Ct.java similarity index 91% rename from src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java rename to src/Run_Pet_Ct.java index 3f1eade1..8cde8b4e 100644 --- a/src/org/petctviewer/orthanc/reader/Run_Pet_Ct.java +++ b/src/Run_Pet_Ct.java @@ -1,4 +1,4 @@ -package org.petctviewer.orthanc.reader; + import java.util.ArrayList; diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index 95ad59af..b7fbb714 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -39,6 +39,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.text.DateFormat; import java.text.ParseException; @@ -100,7 +102,6 @@ import org.petctviewer.orthanc.monitoring.Monitoring_GUI; import org.petctviewer.orthanc.query.*; import org.petctviewer.orthanc.reader.Read_Orthanc; -import org.petctviewer.orthanc.reader.Run_Pet_Ct; import org.petctviewer.orthanc.setup.ConnectionSetup; import org.petctviewer.orthanc.setup.Run_Orthanc; @@ -1376,6 +1377,7 @@ protected void done() { JButton btnReadSeries=new JButton("Open Images"); btnReadSeries.addActionListener(new ActionListener() { + @SuppressWarnings("unchecked") @Override public void actionPerformed(ActionEvent arg0) { int[] selectedListes=tableauSeries.getSelectedRows(); @@ -1419,7 +1421,21 @@ public void done(){ if(pet && ct && fijiEnvironement) { System.out.println("start viewer"); - new Run_Pet_Ct(imagestacks); + Class Run_Pet_Ct = null; + try { + Run_Pet_Ct = Class.forName("Run_Pet_Ct"); + } catch (ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + Constructor cs=Run_Pet_Ct.getDeclaredConstructor(ArrayList.class); + cs.newInstance(imagestacks); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } From 88b4311081531c3cc1116e0889ccc677417e0b06 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 15:38:32 +0100 Subject: [PATCH 19/30] test --- src/org/petctviewer/orthanc/anonymize/VueAnon.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index b7fbb714..f77ec5b1 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -3037,6 +3037,7 @@ public void run(String string) { anon.setLocationRelativeTo(null); anon.setVisible(true); fijiEnvironement=true; + System.out.println(fijiEnvironement); } From f52901af9ac1d692d3dfbcde6ca4b4e0a201f402 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 24 Jan 2019 16:30:08 +0100 Subject: [PATCH 20/30] reading ok --- .../orthanc/anonymize/VueAnon.java | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java index f77ec5b1..041863f5 100644 --- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java +++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java @@ -40,7 +40,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.text.DateFormat; import java.text.ParseException; @@ -1374,6 +1373,7 @@ protected void done() { c.gridx = 2; c.gridy = 0; panelTableauSeries.add(jscp3, BorderLayout.CENTER); + JPanel panelButton=new JPanel(); JButton btnReadSeries=new JButton("Open Images"); btnReadSeries.addActionListener(new ActionListener() { @@ -1381,10 +1381,15 @@ protected void done() { @Override public void actionPerformed(ActionEvent arg0) { int[] selectedListes=tableauSeries.getSelectedRows(); + + if(selectedListes.length==0) { + JOptionPane.showMessageDialog(gui, "Select Series to read", "No series", JOptionPane.ERROR_MESSAGE); + } List ids=new ArrayList(); ArrayList imagestacks=new ArrayList(); - boolean pet = false; + boolean ct = false; + boolean pet = false; for( int line : selectedListes) { ids.add((String) tableauSeries.getValueAt(line, 4)); @@ -1393,8 +1398,11 @@ public void actionPerformed(ActionEvent arg0) { } + boolean startViewer=(pet && ct && fijiEnvironement); + SwingWorker worker = new SwingWorker(){ + @SuppressWarnings("rawtypes") @Override protected Void doInBackground() { btnReadSeries.setText("Reading Series"); @@ -1405,6 +1413,25 @@ protected Void doInBackground() { } + if(startViewer) { + System.out.println("start viewer"); + Class Run_Pet_Ct = null; + try { + Run_Pet_Ct = Class.forName("Run_Pet_Ct"); + } catch (ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + Constructor cs=Run_Pet_Ct.getDeclaredConstructor(ArrayList.class); + cs.newInstance(imagestacks); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + return null; @@ -1419,24 +1446,7 @@ public void done(){ worker.execute(); - if(pet && ct && fijiEnvironement) { - System.out.println("start viewer"); - Class Run_Pet_Ct = null; - try { - Run_Pet_Ct = Class.forName("Run_Pet_Ct"); - } catch (ClassNotFoundException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - try { - Constructor cs=Run_Pet_Ct.getDeclaredConstructor(ArrayList.class); - cs.newInstance(imagestacks); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } + } @@ -1444,7 +1454,8 @@ public void done(){ }); - panelTableauSeries.add(btnReadSeries, BorderLayout.SOUTH); + panelButton.add(btnReadSeries); + panelTableauSeries.add(panelButton, BorderLayout.EAST); tablesPanel.add(panelTableauSeries,c); mainPanel.add(tablesPanel); @@ -3033,11 +3044,9 @@ public static void main(String... args){ @Override public void run(String string) { - VueAnon anon=new VueAnon(); - anon.setLocationRelativeTo(null); - anon.setVisible(true); + setLocationRelativeTo(null); + this.setVisible(true); fijiEnvironement=true; - System.out.println(fijiEnvironement); } From 2960612f511ba1bad2616243c1b3e1ce26ff7146 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Wed, 6 Feb 2019 16:53:51 +0100 Subject: [PATCH 21/30] comprehensive JOB_ID for burner --- .../orthanc/monitoring/CD_Burner.java | 91 ++++++++++++------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 5fc21dd4..38ad9e5b 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -35,6 +35,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.prefs.Preferences; +import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -212,7 +213,7 @@ public void makeCD(List newStableStudyID) { if (burnerManifacturer.equals("Epson")) { //Generation du Dat File dat = printDat(nom, id, formattedDateExamen, studyDescription, accessionNumber, formattedPatientDOB ); - robotRequestFile=createCdBurnerEpson(dat, discType); + robotRequestFile=createCdBurnerEpson(dat, discType, nom, formattedDateExamen); } @@ -294,35 +295,36 @@ private void unzip(File zipFile){ * @param studyDescription * @param dat */ - private File createCdBurnerEpson(File dat, String discType){ - + private File createCdBurnerEpson(File dat, String discType, String name, String formattedStudyDate){ //REalisation du texte pour le Robot - String txtRobot= "# Making data CD\n" - //Peut definir le Job ID et le mettre le compteur dans registery si besoin de tracer les operation avec fichier STF - + "#nombre de copies\n" - + "COPIES=1\n" - + "#CD ou DVD\n" - + "DISC_TYPE="+discType+"\n" - + "FORMAT=UDF102\n" - + "DATA="+fijiDirectory+"\n" - + "DATA="+folder+ File.separator+ "DICOM" +File.separator+"\n" - + "#Instruction d'impression\n" - + "LABEL="+labelFile+"\n" - + "REPLACE_FIELD="+dat.getAbsolutePath().toString(); - + String txtRobot= "# Making data CD\n"; + //Peut definir le Job ID et le mettre le compteur dans registery si besoin de tracer les operation avec fichier STF + if(createJobID(name, formattedStudyDate)!=null) txtRobot+="JOB_ID="+createJobID(name, formattedStudyDate)+"\n"; + System.out.println(createJobID(name, formattedStudyDate)); + txtRobot+="#nombre de copies\n" + + "COPIES=1\n" + + "#CD ou DVD\n" + + "DISC_TYPE="+discType+"\n" + + "FORMAT=UDF102\n" + + "DATA="+fijiDirectory+"\n" + + "DATA="+folder+ File.separator+ "DICOM" +File.separator+"\n" + + "#Instruction d'impression\n" + + "LABEL="+labelFile+"\n" + + "REPLACE_FIELD="+dat.getAbsolutePath().toString(); + // On ecrit le fichier JDF - File f = new File(epsonDirectory + File.separator + "CD_"+dateFormat.format(datenow)+".JDF"); - PrintWriter pw = null; - try { - pw = new PrintWriter(f); - pw.write(txtRobot); - } catch (IOException e) { - e.printStackTrace(); - } finally { - pw.close(); - } - - return f; + File f = new File(epsonDirectory + File.separator + "CD_"+dateFormat.format(datenow)+".JDF"); + PrintWriter pw = null; + try { + pw = new PrintWriter(f); + pw.write(txtRobot); + } catch (IOException e) { + e.printStackTrace(); + } finally { + pw.close(); + } + + return f; } @@ -336,7 +338,11 @@ private File createCdBurnerEpson(File dat, String discType){ */ private File createCdBurnerPrimera(String nom, String id, String date, String studyDescription, String accessionNumber, String patientDOB, String discType){ //Command Keys/Values for Primera Robot - String txtRobot= "Copies = 1\n" + String txtRobot=new String(); + + if(createJobID(nom, date) != null) txtRobot +="JobID="+createJobID(nom,date)+"\n"; + + txtRobot+="Copies = 1\n" + "DataImageType = UDF\n" + "Data="+fijiDirectory+"\n" + "Data="+folder+ File.separator+ "DICOM\n" @@ -380,9 +386,7 @@ private File createCdBurnerPrimera(String nom, String id, String date, String st //Creer le fichier DAT pour injecter NOM, Date, Modalite private File printDat(String nom, String id, String date, String studyDescription, String accessionNumber, String patientDOB) throws ParseException { - - - + //On parse le nom pour enlever les ^ et passer le prenom en minuscule int separationNomPrenom=nom.indexOf("^", 0); if (separationNomPrenom!=-1) { @@ -439,6 +443,29 @@ private void updateProgress() throws IOException { + } + + private String createJobID(String name, String formattedStudyDate) { + String lastName = null; + String firstName= ""; + //prepare JOB_ID string. + if(name.contains("^")) { + String[] names=name.split(Pattern.quote("^")); + //Get 10 first character of lastname and first name if input over 10 characters + if(names[0].length()>5) lastName=names[0].substring(0, 5); else lastName=names[0]; + if(names[1].length()>5) firstName=names[1].substring(0, 5); else firstName=names[1]; + + }else { + if(!StringUtils.isEmpty(name)) { + if(name.length()>10) lastName=name.substring(0, 10); else lastName=name; + //No name information return null + }else { + return null; + } + + } + + return ( lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000)) ); } /** From c73206be19eb2d59d7516aafed98c9143436de94 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Wed, 6 Feb 2019 17:20:13 +0100 Subject: [PATCH 22/30] ref --- src/org/petctviewer/orthanc/monitoring/CD_Burner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 38ad9e5b..31923218 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -300,7 +300,7 @@ private File createCdBurnerEpson(File dat, String discType, String name, String String txtRobot= "# Making data CD\n"; //Peut definir le Job ID et le mettre le compteur dans registery si besoin de tracer les operation avec fichier STF if(createJobID(name, formattedStudyDate)!=null) txtRobot+="JOB_ID="+createJobID(name, formattedStudyDate)+"\n"; - System.out.println(createJobID(name, formattedStudyDate)); + txtRobot+="#nombre de copies\n" + "COPIES=1\n" + "#CD ou DVD\n" From 09a59e5e7e9e578536b8353d47216e8a0e4fb0b1 Mon Sep 17 00:00:00 2001 From: salim Date: Wed, 6 Feb 2019 23:48:55 +0100 Subject: [PATCH 23/30] minor --- src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java b/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java index 2e5d9141..fa37be84 100644 --- a/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java +++ b/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java @@ -52,7 +52,7 @@ public CTP_Import_GUI() { listePeers.setVisible(false); listeAETExport.setVisible(false); - addressFieldCTP.setText("http://kanoun.fr/"); + addressFieldCTP.setText("https://kanoun.fr/"); importCTP.addActionListener(new ActionListener() { From 4380e9245bc1939af3275676b4192adb2495b6f0 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 7 Feb 2019 15:05:34 +0100 Subject: [PATCH 24/30] debug space in jobID --- src/org/petctviewer/orthanc/monitoring/CD_Burner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 31923218..9f0f3b54 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -465,7 +465,8 @@ private String createJobID(String name, String formattedStudyDate) { } - return ( lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000)) ); + String results=lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000)); + return ( results.replaceAll("\\s+","") ); } /** From 395d877b316117e3e6bec766ba038dee41134cee Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Fri, 8 Feb 2019 14:02:40 +0100 Subject: [PATCH 25/30] add paused status for burner --- src/org/petctviewer/orthanc/monitoring/CD_Burner.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 9f0f3b54..611fe2dd 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -435,6 +435,8 @@ private void updateProgress() throws IOException { }else if(extension.equals("DON")) { table_burning_history.setValueAt("Burning Done", rowNubmer, 5); FileUtils.deleteDirectory(tempFolder); + }else if(extension.equals("STP")) { + table_burning_history.setValueAt("Paused", rowNubmer, 5); } } } From fe02f7732b4ba0bf7a5844746128aed923a6c6d2 Mon Sep 17 00:00:00 2001 From: salim Date: Fri, 8 Feb 2019 15:46:36 +0100 Subject: [PATCH 26/30] strip accent from ID burner --- pom.xml | 5 +++++ src/org/petctviewer/orthanc/monitoring/CD_Burner.java | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70e15300..86c54d6c 100644 --- a/pom.xml +++ b/pom.xml @@ -358,6 +358,11 @@ 0.0.5 + + org.apache.commons + commons-lang3 + 3.8.1 + \ No newline at end of file diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 611fe2dd..00307710 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -41,7 +41,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.petctviewer.orthanc.ParametreConnexionHttp; @@ -468,6 +468,8 @@ private String createJobID(String name, String formattedStudyDate) { } String results=lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000)); + results=StringUtils.stripAccents(results); + return ( results.replaceAll("\\s+","") ); } From 5f20e1bace01a2e1623c8e980cea9f3a8b2d5c51 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Tue, 12 Feb 2019 15:50:29 +0100 Subject: [PATCH 27/30] debug --- src/org/petctviewer/orthanc/setup/Run_Orthanc.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/org/petctviewer/orthanc/setup/Run_Orthanc.java b/src/org/petctviewer/orthanc/setup/Run_Orthanc.java index d06148e9..ffe83d3f 100644 --- a/src/org/petctviewer/orthanc/setup/Run_Orthanc.java +++ b/src/org/petctviewer/orthanc/setup/Run_Orthanc.java @@ -37,7 +37,7 @@ public class Run_Orthanc { private String resourceName; private String fileExecName; public String orthancJsonName="Orthanc.json"; - private String resourceLibPath="Orthanc_Standalone"; + private String resourceLibPath="Orthanc_Standalone/"; private List resourceLibName=new ArrayList(); private boolean temp; private ParametreConnexionHttp connexionHttp; @@ -80,7 +80,7 @@ else if (System.getProperty("os.name").toLowerCase().startsWith("linux")){ } public String copyOrthanc(String installPath) throws Exception { - String resourceNameJSON=resourceLibPath+File.separator+orthancJsonName; + String resourceNameJSON=resourceLibPath+orthancJsonName; DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); //Si pas de destination on met dans le temp directory @@ -92,9 +92,7 @@ public String copyOrthanc(String installPath) throws Exception { else file=Paths.get(installPath); File FileExe=new File(file.toString()+File.separator+fileExecName); - System.out.println(FileExe); File FileJSON=new File(file.toString()+File.separator+orthancJsonName); - System.out.println(FileJSON); InputStream in = ClassLoader.getSystemResourceAsStream(resourceName); InputStream inJson = ClassLoader.getSystemResourceAsStream(resourceNameJSON); @@ -111,7 +109,7 @@ public String copyOrthanc(String installPath) throws Exception { //Add lib to get GDCM decoder for (int i=0; i Date: Mon, 18 Feb 2019 11:49:21 +0100 Subject: [PATCH 28/30] disociate connexion settings from BiDb --- .../orthanc/ParametreConnexionHttp.java | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java index 38518473..c83eb018 100644 --- a/src/org/petctviewer/orthanc/ParametreConnexionHttp.java +++ b/src/org/petctviewer/orthanc/ParametreConnexionHttp.java @@ -44,7 +44,7 @@ */ public class ParametreConnexionHttp { - private Preferences jprefer = Preferences.userRoot().node("/biplugins"); + //private Preferences jprefer = Preferences.userRoot().node("/biplugins"); private Preferences jpreferPerso = Preferences.userRoot().node("/queryplugin"); private String fullAddress; private String authentication; @@ -53,11 +53,12 @@ public class ParametreConnexionHttp { public ParametreConnexionHttp() { - int curDb = jprefer.getInt("current database", 0); - int typeDb = jprefer.getInt("db type" + curDb, 0); + //int curDb = jprefer.getInt("current database", 0); + //int typeDb = jprefer.getInt("db type" + curDb, 0); String ip=null; String port=null; + /* if(typeDb == 5){ if(!jprefer.get("db path" + curDb, "none").equals("none") && !jprefer.get("db path" + curDb, "none").equals("")){ @@ -84,18 +85,14 @@ public ParametreConnexionHttp() { authentication = Base64.getEncoder().encodeToString((jprefer.get("db user" + curDb, null) + ":" + jprefer.get("db pass" + curDb, null)).getBytes()); } + }*/ + + ip = jpreferPerso.get("ip", "http://localhost"); + port = jpreferPerso.get("port", "8042"); + this.fullAddress = ip + ":" + port; + if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){ + authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes()); } - else if (typeDb != 5 ){ - ip = jpreferPerso.get("ip", "http://localhost"); - port = jpreferPerso.get("port", "8042"); - this.fullAddress = ip + ":" + port; - if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){ - authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes()); - } - - - } - System.out.println(ip+port); } @@ -302,14 +299,6 @@ public void makeDeleteConnection(String apiUrl) { } - private int ordinalIndexOf(String str, String substr, int n) { - - int pos = str.indexOf(substr); - while (--n > 0 && pos != -1) - pos = str.indexOf(substr, pos + 1); - return pos; - } - // Display Error message if connexion failed public Boolean testConnexion() { Boolean test=true; @@ -336,6 +325,7 @@ public Boolean testConnexion() { */ private boolean isVersionAfter131() { int test=versionCompare(orthancVersion, "1.3.1"); + System.out.println("testVs1.3.1"+test); if (test>0) return true; else return false; } From 31da0ea2f81e66847de064b3df20571f40f84314 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Mon, 18 Feb 2019 13:56:07 +0100 Subject: [PATCH 29/30] update --- pom.xml | 252 ++++++------------ .../orthanc/monitoring/CD_Burner.java | 4 +- 2 files changed, 82 insertions(+), 174 deletions(-) diff --git a/pom.xml b/pom.xml index 86c54d6c..3dd59957 100644 --- a/pom.xml +++ b/pom.xml @@ -185,184 +185,90 @@ - - - -net.imagej - -ij - -1.51s - - - - - - -org.kie.modules - -org-apache-commons-lang3 - -6.5.0.Final - -pom - - - - - - -org.apache.commons - -commons-io - -1.3.2 - - - - - - -com.github.stephenc.java-iso-tools - -sabre - -2.0.1 - - - - - - -com.googlecode.json-simple - -json-simple - -1.1 - - - - - - -com.google.code.gson - -gson - -2.8.5 - - - - - - -com.github.stephenc.java-iso-tools - -iso9660-writer - -2.0.1 - - - - - - -com.github.lookfirst - -sardine - -5.7 - - - - - - -commons-vfs - -commons-vfs - -20050307052300 - - - - - - -commons-net - -commons-net - -3.6 - - - - - - -org.apache.commons - -commons-vfs2 - -2.2 - - - - - - -org.apache.commons - -commons-csv - -1.5 - - - - - - -com.michaelbaranov - -microba - -0.4.4.3 - - - - - - -mysql - -mysql-connector-java - -5.1.14 - - - - - - -net.sf.packtag - -packtag-core - -3.8 - - - - - com.vnetpublishing.java - super-user-application - 0.0.5 - - + + net.imagej + ij + 1.51s + + + + org.apache.commons + commons-io + 1.3.2 + + + + com.github.stephenc.java-iso-tools + sabre + 2.0.1 + + + + com.googlecode.json-simple + json-simple + 1.1 + + + + com.google.code.gson + gson + 2.8.5 + + + + com.github.stephenc.java-iso-tools + iso9660-writer + 2.0.1 + + + + com.github.lookfirst + sardine + 5.7 + + + + commons-net + commons-net + 3.6 + + + + org.apache.commons + commons-vfs2 + 2.2 + + + + org.apache.commons + commons-csv + 1.5 + + + + com.michaelbaranov + microba + 0.4.4.3 + + + + mysql + mysql-connector-java + 5.1.14 + + + + net.sf.packtag + packtag-core + 3.8 + + org.apache.commons commons-lang3 3.8.1 + \ No newline at end of file diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index 00307710..627c6c8c 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -468,9 +468,11 @@ private String createJobID(String name, String formattedStudyDate) { } String results=lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000)); + //Remove Accent and space to match requirement of burners results=StringUtils.stripAccents(results); + results=StringUtils.deleteWhitespace(results); - return ( results.replaceAll("\\s+","") ); + return results; } /** From 4481f448390befbc15cd902aacc1830f025d2b39 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Mon, 18 Feb 2019 14:00:27 +0100 Subject: [PATCH 30/30] 1.2 version --- src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java b/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java index 68fe5ba1..7351ee1d 100644 --- a/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java +++ b/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java @@ -39,7 +39,7 @@ public AboutBoxFrame(){ JPanel mainPanel = new JPanel(new BorderLayout()); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS)); - JLabel title = new JLabel("Dicom Tools v.1.1"); + JLabel title = new JLabel("Dicom Tools v.1.2"); title.setBorder(new EmptyBorder(3, 150, 3, 150)); labelPanel.add(title); JLabel orthancSite = new JLabel("Based on Orthanc http://www.orthanc-server.com");