List of usage examples for javax.xml.datatype DatatypeFactory newInstance
public static DatatypeFactory newInstance() throws DatatypeConfigurationException
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testTemporalNullMetadata() throws Exception { String methodName = "testTemporalNullMetadata"; LOGGER.debug("*************** START: " + methodName + " *****************"); MockQuery query = new MockQuery(); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar start = df.newXMLGregorianCalendarDate(2011, 10, 25, 0); XMLGregorianCalendar end = df.newXMLGregorianCalendarDate(2011, 10, 27, 0); query.addTemporalFilter(start, end, Metacard.EFFECTIVE); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); LOGGER.debug("resulting predicate: " + pred); Filter filter = query.getFilter(); FilterTransformer transform = new FilterTransformer(); transform.setIndentation(2);/*from www . ja v a2s. c om*/ String filterXml = transform.transform(filter); LOGGER.debug(filterXml); // input that passes temporal LOGGER.debug("\npass temporal.\n"); MetacardImpl metacard = new MetacardImpl(); metacard.setCreatedDate(new Date()); metacard.setExpirationDate(new Date()); metacard.setModifiedDate(new Date()); XMLGregorianCalendar cal = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); Date effectiveDate = cal.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); // no contextual map containing indexed contextual data properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); Event testEvent = new Event("topic", properties); boolean b = pred.matches(testEvent); assertTrue(b); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:gov.va.ds4p.ds4pmobileportal.pep.XACMLPolicyEnforcement.java
private XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date dt) { XMLGregorianCalendar xcal = null; try {/*from ww w.ja va 2 s . co m*/ GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dt); xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc); } catch (Exception ex) { ex.printStackTrace(); } return xcal; }
From source file:edu.harvard.hms.dbmi.i2b2.api.crc.CRCCell.java
/** * Returns observation facts as described by the primary key * //from w w w .j ava 2s.c o m * @param client * HTTPClient * @param eventId * Event id * @param patientId * Patient id * @param conceptCd * Concept * @param observerId * Observer * @param startDate * Start Date * @param modifierCd * Modifier * @param instanceNum * instance number * @param onlyKeys * Only keys * @param blob * Blobs * @param techdata * Techdata * @param select * Output option * @return The observation facts * @throws JAXBException * An Exception Occurred * @throws ClientProtocolException * An Exception Occurred * @throws I2B2InterfaceException * An Exception Occurred * @throws IOException * An Exception Occurred * @throws DatatypeConfigurationException * An Exception Occurred */ public PatientDataResponseType getObservationFactByPrimaryKey(HttpClient client, String eventId, String patientId, String conceptCd, String observerId, GregorianCalendar startDate, String modifierCd, String instanceNum, boolean onlyKeys, boolean blob, boolean techdata, OutputOptionSelectType select) throws JAXBException, ClientProtocolException, I2B2InterfaceException, IOException, DatatypeConfigurationException { RequestMessageType rmt = createMinimumPDOBaseMessage(PdoRequestTypeType.GET_OBSERVATIONFACT_BY_PRIMARY_KEY, "/pdorequest"); GetObservationFactByPrimaryKeyRequestType irct = pdoOF.createGetObservationFactByPrimaryKeyRequestType(); FactPrimaryKeyType fpkt = pdoOF.createFactPrimaryKeyType(); fpkt.setEventId(eventId); fpkt.setPatientId(patientId); fpkt.setConceptCd(conceptCd); fpkt.setObserverId(observerId); fpkt.setStartDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(startDate)); fpkt.setModifierCd(modifierCd); fpkt.setInstanceNum(instanceNum); irct.setFactPrimaryKey(fpkt); OutputOptionType oot = pdoOF.createOutputOptionType(); oot.setOnlykeys(onlyKeys); oot.setBlob(blob); oot.setTechdata(techdata); oot.setSelect(select); irct.setFactOutputOption(oot); rmt.getMessageBody().getAny().add(pdoOF.createRequest(irct)); StringWriter sw = new StringWriter(); pdoMarshaller.marshal(pdoOF.createHiveRequest(rmt), sw); return (PatientDataResponseType) this.getPDOResponseType(runRequest(client, sw.toString(), "/pdorequest")); }
From source file:com.headstrong.npi.raas.Utils.java
public static CmAttributeDateMonthDay getCmAttrDateMonthDay(String monthDayStr) { if (null != monthDayStr && !monthDayStr.trim().isEmpty()) { Date date = DateConversion.getDateFromMmDString(monthDayStr); if (null != date) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date);/*w w w .j a v a2 s . co m*/ XMLGregorianCalendar xmlGregorianCalendar; try { xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(); xmlGregorianCalendar.setMonth(cal.get(Calendar.MONTH) + 1); xmlGregorianCalendar.setDay(cal.get(Calendar.DAY_OF_MONTH)); } catch (DatatypeConfigurationException e) { e.printStackTrace(); return null; } CmAttributeDateMonthDay cmAttributeDateMonthDay = new CmAttributeDateMonthDay(); cmAttributeDateMonthDay.setValue(xmlGregorianCalendar); return cmAttributeDateMonthDay; } } return null; }
From source file:cz.cas.lib.proarc.common.export.mets.MetsUtils.java
/** * * Generates and saves info.xml// www . j av a 2s .com * * @param path * @param mets */ public static void saveInfoFile(String path, MetsContext metsContext, String md5, String fileMd5Name, File metsFile) throws MetsExportException { File infoFile = new File(path + File.separator + metsContext.getPackageID() + File.separator + "info_" + metsContext.getPackageID() + ".xml"); GregorianCalendar c = new GregorianCalendar(); c.setTime(new Date()); XMLGregorianCalendar date2; try { date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); } catch (DatatypeConfigurationException e1) { throw new MetsExportException("Error while generating info.xml file", false, e1); } Info infoJaxb = new Info(); infoJaxb.setCreated(date2); infoJaxb.setMainmets("./" + metsFile.getName()); Checksum checkSum = new Checksum(); checkSum.setChecksum(md5); checkSum.setType("MD5"); addModsIdentifiersRecursive(metsContext.getRootElement(), infoJaxb); checkSum.setValue(fileMd5Name); infoJaxb.setChecksum(checkSum); Validation validation = new Validation(); validation.setValue("W3C-XML"); validation.setVersion(Float.valueOf("0.0")); infoJaxb.setValidation(validation); infoJaxb.setCreator(metsContext.getCreatorOrganization()); infoJaxb.setPackageid(metsContext.getPackageID()); if (Const.PERIODICAL_TITLE.equalsIgnoreCase(metsContext.getRootElement().getElementType())) { infoJaxb.setMetadataversion((float) 1.5); } else { infoJaxb.setMetadataversion((float) 1.1); } Itemlist itemList = new Itemlist(); infoJaxb.setItemlist(itemList); itemList.setItemtotal(BigInteger.valueOf(metsContext.getFileList().size())); List<FileMD5Info> fileList = metsContext.getFileList(); long size = 0; for (FileMD5Info fileName : fileList) { itemList.getItem() .add(fileName.getFileName().replaceAll(Matcher.quoteReplacement(File.separator), "/")); size += fileName.getSize(); } int infoTotalSize = (int) (size / 1024); infoJaxb.setSize(infoTotalSize); try { JAXBContext jaxbContext = JAXBContext.newInstance(Info.class); Marshaller marshaller = jaxbContext.createMarshaller(); // SchemaFactory factory = // SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // factory.setResourceResolver(MetsLSResolver.getInstance()); // Schema schema = factory.newSchema(new // StreamSource(Info.class.getResourceAsStream("info.xsd"))); // marshaller.setSchema(schema); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_ENCODING, "utf-8"); marshaller.marshal(infoJaxb, infoFile); } catch (Exception ex) { throw new MetsExportException("Error while generating info.xml", false, ex); } List<String> validationErrors; try { validationErrors = MetsUtils.validateAgainstXSD(infoFile, Info.class.getResourceAsStream("info.xsd")); } catch (Exception e) { throw new MetsExportException("Error while validating info.xml", false, e); } if (validationErrors.size() > 0) { MetsExportException metsException = new MetsExportException( "Invalid info file:" + infoFile.getAbsolutePath(), false, null); metsException.getExceptions().get(0).setValidationErrors(validationErrors); for (String error : validationErrors) { LOG.fine(error); } throw metsException; } }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testTemporalNullOperation() throws Exception { String methodName = "testTemporalNullOperation"; LOGGER.debug("*************** START: " + methodName + " *****************"); MockQuery query = new MockQuery(); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar start = df.newXMLGregorianCalendarDate(2011, 10, 25, 0); XMLGregorianCalendar end = df.newXMLGregorianCalendarDate(2011, 10, 27, 0); query.addTemporalFilter(start, end, Metacard.EFFECTIVE); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); LOGGER.debug("resulting predicate: " + pred); Filter filter = query.getFilter(); FilterTransformer transform = new FilterTransformer(); transform.setIndentation(2);/*from w ww. j a v a 2s.co m*/ String filterXml = transform.transform(filter); LOGGER.debug(filterXml); // input that passes temporal LOGGER.debug("\npass temporal.\n"); MetacardImpl metacard = new MetacardImpl(); metacard.setCreatedDate(new Date()); metacard.setExpirationDate(new Date()); metacard.setModifiedDate(new Date()); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); XMLGregorianCalendar cal = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); Date effectiveDate = cal.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, null); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); Event testEvent = new Event("topic", properties); boolean b = pred.matches(testEvent); assertTrue(b); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:at.gv.egovernment.moa.id.protocols.stork2.MandateRetrievalRequest.java
private MandateContentType getMandateContent(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException { MandateContentType mandateContent = new MandateContentType(); try {// w w w . j a va 2 s.com XMLGregorianCalendar validFrom = DatatypeFactory.newInstance() .newXMLGregorianCalendar(mandateContainer.getMandateValidFrom()); XMLGregorianCalendar validTo = DatatypeFactory.newInstance() .newXMLGregorianCalendar(mandateContainer.getMandateValidTo()); TimeRestrictionType timeRestriction = new TimeRestrictionType(); timeRestriction.setValidFrom(validFrom); timeRestriction.setValidTo(validTo); mandateContent.setTimeRestriction(timeRestriction); } catch (DatatypeConfigurationException dte) { Logger.error("Error converting date from mandate: " + mandateContainer.getMandateValidFrom() + ", " + mandateContainer.getMandateValidTo()); throw new MOAIDException("stork.20", new Object[] {}); } mandateContent.setAQAA(this.QAALevel); mandateContent.setOriginalMandate(originalContent); mandateContent.setOriginalMandateType("application/xml"); TransactionLimitRestrictionType transactionLimit = new TransactionLimitRestrictionType(); mandateContent.setTransactionLimit(transactionLimit); mandateContent.setIsJoint(""); mandateContent.setIsChained(false); mandateContent.setTypeOfPower(mapPowersType(mandateContainer)); // TODO check Logger.debug("Complex attribute extracted: " + sourceAttribute.getName()); return mandateContent; }
From source file:hu.unideb.inf.rdfizers.rpm.ModelBuilder.java
/** * Converts a POSIX time value to a W3C XML Schema <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a> value. * * @param seconds/*from w ww . j av a 2 s . c om*/ * @return */ private static XMLGregorianCalendar toDateTime(int seconds) { GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(seconds * 1000L); try { return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); } catch (DatatypeConfigurationException e) { return null; } }
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testMultipleCriteriaWithContentTypes() throws Exception { String methodName = "testMultipleCriteriaWithContentTypes"; LOGGER.debug("*************** START: " + methodName + " *****************"); MockQuery query = new MockQuery(); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar start = df.newXMLGregorianCalendarDate(2011, 10, 25, 0); XMLGregorianCalendar end = df.newXMLGregorianCalendarDate(2011, 10, 27, 0); query.addTemporalFilter(start, end, Metacard.EFFECTIVE); // create content type criteria String version1 = "version1"; String type1 = "type1"; List<MockTypeVersionsExtension> extensions = new ArrayList<>(); MockTypeVersionsExtension ext1 = new MockTypeVersionsExtension(); List<String> ext1Versions = ext1.getVersions(); ext1Versions.add(version1);//from www . j a va 2s. c o m ext1.setExtensionTypeName(type1); extensions.add(ext1); query.addTypeFilter(extensions); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate pred = (Predicate) query.getFilter().accept(visitor, null); LOGGER.debug("resulting predicate: " + pred); Filter filter = query.getFilter(); FilterTransformer transform = new FilterTransformer(); transform.setIndentation(2); String filterXml = transform.transform(filter); LOGGER.debug(filterXml); // input that passes both temporal and content type LOGGER.debug("\npass temporal and pass content type.\n"); MetacardImpl metacard = new MetacardImpl(); metacard.setCreatedDate(new Date()); metacard.setExpirationDate(new Date()); metacard.setModifiedDate(new Date()); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); XMLGregorianCalendar cal = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); Date effectiveDate = cal.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); Event testEvent = new Event("topic", properties); boolean b = pred.matches(testEvent); assertTrue(b); // input that fails both temporal and content type LOGGER.debug("\nfail temporal. fail content type.\n"); XMLGregorianCalendar cal1 = df.newXMLGregorianCalendarDate(2012, 10, 30, 0); // time out of // range Date effectiveDate1 = cal1.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate1); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "invalid_type" + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); // input that passes temporal and fails content type LOGGER.debug("\npass temporal. fail content type\n"); XMLGregorianCalendar cal2 = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); // time in // range Date effectiveDate2 = cal2.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate2); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, "invalid_type" + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); // input that fails temporal and passes content type LOGGER.debug("\nfail temporal. pass content type\n"); XMLGregorianCalendar cal3 = df.newXMLGregorianCalendarDate(2012, 10, 26, 0); // time out of // range Date effectiveDate3 = cal3.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate3); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertFalse(pred.matches(testEvent)); // multiple content types LOGGER.debug("\nTesting multiple content types.\n"); String type2 = "type2"; String version2 = "version2"; MockTypeVersionsExtension ext2 = new MockTypeVersionsExtension(); List<String> ext2Versions = ext2.getVersions(); ext2Versions.add(version2); ext2.setExtensionTypeName(type2); extensions.add(ext2); // No version String type3 = "type3"; MockTypeVersionsExtension ext3 = new MockTypeVersionsExtension(); ext3.setExtensionTypeName(type3); extensions.add(ext3); MockQuery query2 = new MockQuery(); query2.addTemporalFilter(start, end, Metacard.EFFECTIVE); query2.addTypeFilter(extensions); SubscriptionFilterVisitor visitor1 = new SubscriptionFilterVisitor(); Predicate pred1 = (Predicate) query2.getFilter().accept(visitor1, null); LOGGER.debug("resulting predicate: " + pred1); // Create metacard for input // time and contentType match XMLGregorianCalendar cal4 = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); // time in // range Date effectiveDate4 = cal4.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate4); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type1 + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertTrue(pred1.matches(testEvent)); // time and contentType match against content type 3 with any version XMLGregorianCalendar cal5 = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); // time in // range Date effectiveDate5 = cal5.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate5); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type3 + "," + "random_version"); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertTrue(pred1.matches(testEvent)); // time matches and contentType matches type2 XMLGregorianCalendar cal6 = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); // time in // range Date effectiveDate6 = cal6.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate6); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version2); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertTrue(pred1.matches(testEvent)); // time matches and content type doesn't match XMLGregorianCalendar cal7 = df.newXMLGregorianCalendarDate(2011, 10, 26, 0); // time in // range Date effectiveDate7 = cal7.toGregorianCalendar().getTime(); metacard.setEffectiveDate(effectiveDate7); LOGGER.debug("metacard date: " + metacard.getEffectiveDate()); properties.clear(); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_CONTENT_TYPE_KEY, type2 + "," + version1); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); testEvent = new Event("topic", properties); assertFalse(pred1.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.RulesMessageServiceBean.java
private List<ValidationResultDocument> getValidationResultDocument(ValidationResultDto faReportValidationResult) throws DatatypeConfigurationException { ValidationResultDocument validationResultDocument = new ValidationResultDocument(); GregorianCalendar date = DateTime.now(DateTimeZone.UTC).toGregorianCalendar(); XMLGregorianCalendar calender = DatatypeFactory.newInstance().newXMLGregorianCalendar(date); DateTimeType dateTime = new DateTimeType(); dateTime.setDateTime(calender);/* w w w . j a va 2s . co m*/ validationResultDocument.setCreationDateTime(dateTime); IDType idType = new IDType(); String fluxNationCode = ruleModuleCache.getSingleConfig("flux_local_nation_code"); idType.setValue(StringUtils.isNotEmpty(fluxNationCode) ? fluxNationCode : "XEU"); idType.setSchemeID("FLUX_GP_PARTY"); validationResultDocument.setValidatorID(idType); List<ValidationQualityAnalysis> validationQuality = new ArrayList<>(); for (ValidationMessageType validationMessage : faReportValidationResult.getValidationMessages()) { ValidationQualityAnalysis analysis = new ValidationQualityAnalysis(); IDType identification = new IDType(); identification.setValue(validationMessage.getBrId()); analysis.setID(identification); CodeType level = new CodeType(); level.setValue(validationMessage.getLevel()); analysis.setLevelCode(level); eu.europa.ec.fisheries.uvms.rules.service.constants.ErrorType errorType = codeTypeMapper .mapErrorType(validationMessage.getErrorType()); if (errorType != null) { CodeType type = new CodeType(); type.setValue(errorType.name()); analysis.setTypeCode(type); } else { throw new DatatypeConfigurationException("UNABLE TO MAP ERROR CODES"); } TextType text = new TextType(); text.setValue(validationMessage.getMessage()); analysis.getResults().add(text); List<String> xpaths = validationMessage.getXpaths(); if (CollectionUtils.isNotEmpty(xpaths)) { for (String xpath : xpaths) { TextType referenceItem = new TextType(); referenceItem.setValue(xpath); analysis.getReferencedItems().add(referenceItem); } } validationQuality.add(analysis); } validationResultDocument.setRelatedValidationQualityAnalysises(validationQuality); return singletonList(validationResultDocument); }