2019-02-25 17:46:16 +01:00
|
|
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
|
|
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
|
2020-01-16 16:46:24 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2019-02-25 17:46:16 +01:00
|
|
|
|
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
|
import javax.xml.bind.JAXBException;
|
|
|
|
import javax.xml.bind.Unmarshaller;
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
public class ImportXmlBuilderDatasetProfile {
|
2020-01-16 16:46:24 +01:00
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDatasetProfile.class);
|
2019-02-25 17:46:16 +01:00
|
|
|
|
|
|
|
public DatasetProfile build(File xmlFile) throws IOException {
|
|
|
|
DatasetProfile datasetProfile = new DatasetProfile();
|
|
|
|
JAXBContext jaxbContext = null;
|
|
|
|
try {
|
|
|
|
jaxbContext = JAXBContext.newInstance(DatasetProfile.class);
|
|
|
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
|
|
|
datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile);
|
|
|
|
} catch (JAXBException e) {
|
2020-01-16 16:46:24 +01:00
|
|
|
logger.error(e.getMessage(), e);
|
2019-02-25 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return datasetProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|