/*******************************************************************************
 *  Copyright 2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package cdac.medinfo.sdk.dcm30_04.services.mwrite;


import java.util.Locale;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.services.dicomdir.DICOMDIRSinkImpl;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ResourceBundleWrapper;

/**
 * This class contains methods to create DICOMDIR file .
 * MWrite works as a processor for MWrite Service.
 */

public class MWrite 
{
	/**
	 * This function performs the MWrite operation and generate Dicomdir File-Set.
	 * @param strStoragePath,objIDataSet
	 */
	public void process (String strStoragePath,IDataSet objIDataSet )
	{
		DICOMDIRSinkImpl objDICOMDIRSinkImpl = new DICOMDIRSinkImpl();
		objDICOMDIRSinkImpl.store(objIDataSet, strStoragePath);
		DicomLogger objDicomLogger = DicomLogger.getLogger();
		objDicomLogger.log(ResourceBundleWrapper.getValue("status","StoragePath",new Locale(DicomConfig.createInstance().getLocale()))+ strStoragePath);
		String ReferencedFileID = (String)objIDataSet.getValue(0x0008,0x0018);
		objDicomLogger.log(ResourceBundleWrapper.getValue("status", "SOPInstanceUID", new Locale(DicomConfig.createInstance().getLocale())) + ReferencedFileID);
	}

}
