001/* ***** BEGIN LICENSE BLOCK ***** 002 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 003 * 004 * The contents of this file are subject to the Mozilla Public License Version 005 * 1.1 (the "License"); you may not use this file except in compliance with 006 * the License. You may obtain a copy of the License at 007 * http://www.mozilla.org/MPL/ 008 * 009 * Software distributed under the License is distributed on an "AS IS" basis, 010 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 011 * for the specific language governing rights and limitations under the 012 * License. 013 * 014 * The Original Code is part of dcm4che, an implementation of DICOM(TM) in 015 * Java(TM), hosted at https://github.com/gunterze/dcm4che. 016 * 017 * The Initial Developer of the Original Code is 018 * Agfa Healthcare. 019 * Portions created by the Initial Developer are Copyright (C) 2011 020 * the Initial Developer. All Rights Reserved. 021 * 022 * Contributor(s): 023 * See @authors listed below 024 * 025 * Alternatively, the contents of this file may be used under the terms of 026 * either the GNU General Public License Version 2 or later (the "GPL"), or 027 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 028 * in which case the provisions of the GPL or the LGPL are applicable instead 029 * of those above. If you wish to allow use of your version of this file only 030 * under the terms of either the GPL or the LGPL, and not to allow others to 031 * use your version of this file under the terms of the MPL, indicate your 032 * decision by deleting the provisions above and replace them with the notice 033 * and other provisions required by the GPL or the LGPL. If you do not delete 034 * the provisions above, a recipient may use your version of this file under 035 * the terms of any one of the MPL, the GPL or the LGPL. 036 * 037 * ***** END LICENSE BLOCK ***** */ 038package org.dcm4che3.tool.wadouri.test; 039 040import java.io.File; 041 042import org.dcm4che3.tool.common.test.TestResult; 043import org.dcm4che3.tool.common.test.TestTool; 044import org.dcm4che3.tool.wadouri.WadoURI; 045 046/** 047 * @author Hesham Elbadawi <bsdreko@gmail.com> 048 */ 049 050public class WadoURITool implements TestTool { 051 052 private String url; 053 private String studyUID; 054 private String seriesUID; 055 private String objectUID; 056 private String contentType; 057 private String charset; 058 private boolean anonymize; 059 private String annotation; 060 private int rows; 061 private int columns; 062 private String regionCoordinates; 063 //windowParams; 064 private String windowCenter; 065 private String windowWidth; 066 private int[] frameNumbers; 067 private int imageQuality; 068 //presentationUID; 069 private String presentationSeriesUID; 070 private String presentationUID; 071 private String transferSyntax; 072 private boolean overlays; 073 private File retrieveDir; 074 private TestResult result; 075 076 public WadoURITool() { 077 078 } 079 080 public WadoURITool( 081 String url, 082 String studyUID, 083 String seriesUID, 084 String objectUID, 085 String contentType, 086 String charset, 087 boolean anonymize, 088 String annotation, 089 int rows, 090 int columns, 091 String regionCoordinates, 092 String windowCenter, 093 String windowWidth, 094 int[] frameNumbers, 095 int imageQuality, 096 String presentationSeriesUID, 097 String presentationUID, 098 String transferSyntax, 099 File retrieveDir) { 100 super(); 101 this.url = url; 102 this.studyUID = studyUID; 103 this.seriesUID = seriesUID; 104 this.objectUID = objectUID; 105 this.contentType = contentType; 106 this.charset = charset; 107 this.anonymize = anonymize; 108 this.annotation = annotation; 109 this.rows = rows; 110 this.columns = columns; 111 this.regionCoordinates = regionCoordinates; 112 this.windowCenter = windowCenter; 113 this.windowWidth = windowWidth; 114 this.frameNumbers = frameNumbers; 115 this.imageQuality = imageQuality; 116 this.presentationSeriesUID = presentationSeriesUID; 117 this.presentationUID = presentationUID; 118 this.transferSyntax = transferSyntax; 119 this.retrieveDir = retrieveDir; 120 } 121 122 public void wadoURI(String testDescription) throws Exception { 123 wado(testDescription, false); 124 } 125 126 public void wadoURI(String testDescription, boolean enableOverlays) throws Exception { 127 wado(testDescription, enableOverlays); 128 } 129 130 private void wado(String testDescription, boolean enableOverlays) throws Exception { 131 long t1, t2; 132 133 t1 = System.currentTimeMillis(); 134 WadoURIResponse response = null; 135 136 137 if (frameNumbers == null || frameNumbers.length == 0) { 138 // no frames 139 response = makeWadoURI(enableOverlays, -1).getResponse(); 140 } else { 141 // multi-frame - iterate through frames 142 for (int frameNumber : frameNumbers) { 143 WadoURI wadouri = makeWadoURI(enableOverlays, frameNumber); 144 145 WadoURIResponse thisFrameResponse = wadouri.getResponse(); 146 if (response == null) 147 response = thisFrameResponse; 148 else 149 response.addRetrievedInstance(thisFrameResponse.getRetrievedInstance()); 150 } 151 } 152 t2 = System.currentTimeMillis(); 153 init(new WadoURIResult(testDescription, t2 - t1, response)); 154 } 155 156 private WadoURI makeWadoURI(boolean enableOverlays, int frameNumber) throws Exception { 157 WadoURI wadouri = new WadoURI(this.url, this.studyUID, this.seriesUID, this.objectUID, 158 this.contentType, this.charset, this.anonymize, this.annotation 159 , this.rows, this.columns, this.regionCoordinates, this.windowCenter, 160 this.windowWidth, frameNumber, this.imageQuality, this.presentationSeriesUID, 161 this.presentationUID, this.transferSyntax); 162 163 wadouri.setOverlays(enableOverlays); 164 wadouri.setOutDir(this.retrieveDir); 165 wadouri.setOutFileName(this.objectUID + (frameNumber == -1 ? "" : "_frame_" + frameNumber)); 166 wadouri.wado(wadouri); 167 return wadouri; 168 } 169 170 @Override 171 public void init(TestResult result) { 172 this.result = result; 173 } 174 175 @Override 176 public TestResult getResult() { 177 return this.result; 178 } 179 180 public File getRetrieveDir() { 181 return retrieveDir; 182 } 183}