001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle.
005 *
006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019
020/**
021 *
022 */
023package pt.ua.dicoogle.server.queryretrieve;
024
025import java.io.IOException;
026
027import org.dcm4che2.data.DicomObject;
028import org.dcm4che2.data.Tag;
029import org.dcm4che2.data.VR;
030import org.dcm4che2.net.Association;
031import org.dcm4che2.net.DimseRSP;
032import org.dcm4che2.net.Status;
033
034
035import pt.ua.dicoogle.server.SearchDicomResult;
036
037/**
038 *
039 * @author Luís A. Bastião Silva <bastiao@ua.pt>
040 */
041public class MoveRSP  implements DimseRSP 
042{
043    DicomObject rsp = null ;
044    DicomObject keys = null ;
045
046    DicomObject current = null ;
047    SearchDicomResult search = null ; 
048
049
050    public MoveRSP(DicomObject keys, DicomObject rsp)
051    {
052        /* Save args */
053        this.rsp = rsp ;
054        this.keys = keys ;
055        this.current = rsp ; 
056        
057
058       // DebugManager.getInstance().debug("--> Creating MoveRSP");
059        
060
061
062        /** Debug - show keys, rsp, index */
063        if (keys!=null)
064        {
065            //DebugManager.getInstance().debug("keys object: ");
066            //DebugManager.getInstance().debug(keys.toString());
067        }
068        if (rsp!=null)
069        {
070            //DebugManager.getInstance().debug("Rsp object");
071            //DebugManager.getInstance().debug(rsp.toString());
072        }
073
074          this.rsp.putInt(Tag.Status, VR.US, Status.Success);
075            
076    }
077
078    @Override
079    public boolean next() throws IOException, InterruptedException
080    {
081  
082            /** Sucess */
083            this.rsp.putInt(Tag.Status, VR.US, Status.Success);
084            /** Clean pointers */
085            this.current = null;
086            return true ;
087
088    }
089
090    @Override
091    public DicomObject getCommand()
092    {
093        return this.rsp ; 
094    }
095
096    @Override
097    public DicomObject getDataset()
098    {
099         return  this.current != null ? this.current.subSet(this.keys) : null;
100    }
101
102    @Override
103    public void cancel(Association arg0) throws IOException
104    {
105        // TODO
106    }
107
108}