package lu.tudor.santec.gecamed.esante.gui.data;
///* To change this template, choose Tools | Templates
// * and open the template in the editor. */
//package lu.tudor.santec.gecamed.esante.utils.data;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.Observable;
//
//import lu.tudor.santec.gecamed.esante.utils.webservice.ESantePatient;
//
//import org.jboss.remoting.marshal.Marshaller;
//
//
///**
// * @author jens.ferring(at)tudor.lu
// * 
// * Based on infomed client sources.
// */
////@XmlRootElement(name = "DataHolder")
//public class DataHolder extends Observable
//{
//	private static DataHolder			dataHolderSingleton	= null;
//	private ArrayList<ESantePatient>	patients;
////	private ArrayList<SOAPLog>			soapLogs;
////	private Configuration				configuration;
//	
//	
//	protected DataHolder ()
//	{
////		configuration = new Configuration();
//		patients = new ArrayList<ESantePatient>();
////		soapLogs = new ArrayList<SOAPLog>();
//	}
//	
//	
//	public static DataHolder getInstance ()
//	{
//		if (dataHolderSingleton == null)
//		{
//			try
//			{
//				dataHolderSingleton = DataHolder.loadFromDisk();
//			}
//			catch (Exception e)
//			{
//				e.printStackTrace();
//			}
//			
////			if (dataHolderSingleton == null)
////			{
////				dataHolderSingleton = new DataHolder();
////				dataHolderSingleton.loadTempData();
////			}
//		}
//		
//		return dataHolderSingleton;
//	}
//	
//	
//	/**
//	 * @return the patients
//	 */
////	@XmlElement(name = "patient")
//	public ArrayList<ESantePatient> getPatients ()
//	{
//		return patients;
//	}
//	
//	
//	public void setPatients (ArrayList<ESantePatient> patients)
//	{
//		this.patients = patients;
//	}
//	
//	
////	public ArrayList<SOAPLog> getSoapLogs ()
////	{
////		return soapLogs;
////	}
////	
////	
////	public void setSoapLogs (ArrayList<SOAPLog> soapLogs)
////	{
////		this.soapLogs = soapLogs;
////	}
////	
////	
////	public void addSoapLog (SOAPLog log)
////	{
////		this.soapLogs.add(log);
////		this.setChanged();
////		this.notifyObservers(soapLogs);
////	}
//	
//	
//	public void addPatient (ESantePatient p)
//	{
//		this.patients.add(p);
//		this.setChanged();
//		this.notifyObservers(patients);
//	}
//	
//	
//	public void patientWasUpdated (ESantePatient p)
//	{
//		this.setChanged();
//		this.notifyObservers(patients);
//	}
//	
//	
////	private void loadTempData ()
////	{
////		patients.add(new ESantePatient("test_infomed", "jean", "19700511", "123"));
////		patients.add(new ESantePatient("test_infomed", "marc", "", "102836133"));
////		patients.add(new ESantePatient("Levert", "Albert", "19600101", "123"));
////		patients.add(new ESantePatient("TUDOR", "patient", "19700507", "485216467^^^&1.3.6.1.4.1.5729.10020.2.6.10.1&ISO"));
////	}
//	
//	
////	@XmlElement(type = Configuration.class)
////	public Configuration getConfiguration ()
////	{
////		return configuration;
////	}
////	
////	
////	public void setConfiguration (Configuration configuration)
////	{
////		this.configuration = configuration;
////	}
//	
//	
//	public void saveToDisk () throws JAXBException
//	{
//		String path = System.getProperty("user.home") + File.separator + "infomed_client.xml";
//		System.out.println("Saved to: " + path);
//		File file = new File(path);
//		
//		JAXBContext jc = JAXBContext.newInstance(DataHolder.class);
//		Marshaller marshaller = jc.createMarshaller();
//		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//		marshaller.marshal(this, file);
//	}
//	
//	
//	private static DataHolder loadFromDisk () throws JAXBException
//	{
//		String path = System.getProperty("user.home") + File.separator + "infomed_client.xml";
//		System.out.println("Try to load from: " + path);
//		File file = new File(path);
//		
//		if (!file.exists())
//		{
//			System.out.println("File not found.");
//			return null;
//		}
//		System.out.println("File found.");
//		
//		JAXBContext jc = JAXBContext.newInstance(DataHolder.class);
//		Unmarshaller unmarshaller = jc.createUnmarshaller();
//		return (DataHolder) unmarshaller.unmarshal(file);
//	}
//}
