import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import net.ihe.gazelle.ihexds.validator.cmpdresperror.CMPDRESPERRORPackValidator; import net.ihe.gazelle.ihexds.validator.rimihe.RIMIHEPackValidator; import net.ihe.gazelle.query.AdhocQueryRequestType; import net.ihe.gazelle.query.AdhocQueryResponseType; import net.ihe.gazelle.validation.Notification; import net.ihe.gazelle.xds.ProvideAndRegisterDocumentSetRequestType; public class TestValidation { private TestValidation(){} // public static void main(String[] args) throws FileNotFoundException, JAXBException { // ProvideAndRegisterDocumentSetRequestType pr = TestValidation.load(new FileInputStream( // "/home/aboufahj/DICOM/samples/Sans titre1.xml")); // List diag = new ArrayList(); // ProvideAndRegisterDocumentSetRequestType.validateByModule(pr, "/ProvideRoot", new XDSIValidator(), diag); // for (Notification notification : diag) { // System.out.println(notification.getClass() + "::" + notification.getLocation() + "::" + notification.getDescription()); // } // } public static void main2(String[] args) throws FileNotFoundException, JAXBException { AdhocQueryResponseType pr = TestValidation.loadAdhocQueryResponseType(new FileInputStream( "/home/aboufahj/Documents/workspace/2/xds-ihe-model/samples/cmpd-resp.xml")); List diag = new ArrayList(); AdhocQueryResponseType.validateByModule(pr, "/AdhocQueryResponse", new CMPDRESPERRORPackValidator(), diag); AdhocQueryResponseType.validateByModule(pr, "/AdhocQueryResponse", new RIMIHEPackValidator(), diag); for (Notification notification : diag) { System.out.println(notification.getClass() + "::" + notification.getLocation() + "::" + notification.getDescription()); } } public static ProvideAndRegisterDocumentSetRequestType load(InputStream is) throws JAXBException { JAXBContext jc = JAXBContext.newInstance("net.ihe.gazelle.query"); Unmarshaller u = jc.createUnmarshaller(); ProvideAndRegisterDocumentSetRequestType mimi = (ProvideAndRegisterDocumentSetRequestType) u.unmarshal(is); System.out.println("mimi::" + mimi); return mimi; } public static AdhocQueryResponseType loadAdhocQueryResponseType(InputStream is) throws JAXBException { JAXBContext jc = JAXBContext.newInstance("net.ihe.gazelle.query"); Unmarshaller u = jc.createUnmarshaller(); AdhocQueryResponseType mimi = (AdhocQueryResponseType) u.unmarshal(is); System.out.println("mimi::" + mimi); return mimi; } public static AdhocQueryRequestType loadAdhocQueryRequestType(InputStream is) throws JAXBException { JAXBContext jc = JAXBContext.newInstance("net.ihe.gazelle.query"); Unmarshaller u = jc.createUnmarshaller(); AdhocQueryRequestType mimi = (AdhocQueryRequestType) u.unmarshal(is); System.out.println("mimi::" + mimi); return mimi; } }