List of usage examples for javax.xml.datatype DatatypeFactory newInstance
public static DatatypeFactory newInstance() throws DatatypeConfigurationException
From source file:br.gov.frameworkdemoiselle.behave.integration.alm.objects.util.GenerateXMLString.java
public static String getExecutionresultString(String urlServer, String projectAreaAlias, String encoding, String executionWorkItemUrl, ScenarioState stateOf, Date _startDate, Date _endDate, String details) throws JAXBException, DatatypeConfigurationException { Date startDate = (Date) _startDate.clone(); Date endDate = (Date) _endDate.clone(); com.ibm.rqm.xml.bind.Executionresult.Executionworkitem workTest = new com.ibm.rqm.xml.bind.Executionresult.Executionworkitem(); workTest.setHref(executionWorkItemUrl); State state = new State(); Executionresult result = new Executionresult(); if (stateOf.equals(ScenarioState.FAILED)) { state.setContent("com.ibm.rqm.execution.common.state.failed"); } else {//from w w w . ja v a 2 s . c o m if (stateOf.equals(ScenarioState.PENDING)) { state.setContent("com.ibm.rqm.execution.common.state.blocked"); } else { state.setContent("com.ibm.rqm.execution.common.state.passed"); } } result.setState(state); result.setExecutionworkitem(workTest); // Datas de incio e fim do teste GregorianCalendar c = new GregorianCalendar(); c.setTime(startDate); XMLGregorianCalendar startDateXml = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); result.setStarttime(startDateXml); c.setTime(endDate); XMLGregorianCalendar endDateXml = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); result.setEndtime(endDateXml); // Details Details d = new Details(); d.getContent().add(details); result.setDetails(d); JAXBContext jaxb = JAXBContext.newInstance(Executionresult.class); Marshaller marshaller = jaxb.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); StringWriter resourceString = new StringWriter(); marshaller.marshal(result, resourceString); return resourceString.toString(); }
From source file:de.fischer.thotti.core.runner.NDRunner.java
private TestSuiteResult generatedTestResult(List<NDTestResult> resultList) throws RunnerException { if (null == resultList) { throw new NullPointerException(); }//w ww . j a v a 2 s . com DatatypeFactory datatypeFac = null; try { datatypeFac = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RunnerException("Failed to instanciate datatype factory.", e); } de.fischer.thotti.core.resources.ndtest.ObjectFactory factory = new de.fischer.thotti.core.resources.ndtest.ObjectFactory(); de.fischer.thotti.core.resources.ndresult.ObjectFactory factory2 = new de.fischer.thotti.core.resources.ndresult.ObjectFactory(); TestSuiteResult suiteResult = factory2.createTestSuiteResult(); for (NDTestResult result : resultList) { NonDistributedTestResultType ndResult = factory2.createNonDistributedTestResultType(); Duration execTime = datatypeFac.newDuration(result.getExecutionTime()); XMLGregorianCalendar startTime = datatypeFac.newXMLGregorianCalendar(result.getStartTime()); ndResult.setTestID(result.getTestId()); ndResult.setExitCode(BigInteger.valueOf(result.getExitCode())); ndResult.setJvmArgsID(result.getJVMArgsID()); ndResult.setJvmArgs(result.getJvmArgs()); ndResult.setExecutionTimeMS(execTime); ndResult.setStartedAt(startTime); ndResult.setParamGrpID(result.getParamGrpID()); try { ndResult.setMahoutVersion(org.apache.mahout.Version.versionFromResource()); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } suiteResult.getNonDistributedTestResults().add(ndResult); } suiteResult.setUuid(generateResultUUID()); return suiteResult; }
From source file:no.uis.service.ws.studinfosolr.impl.StudinfoSolrServiceImpl.java
@SneakyThrows private synchronized DatatypeFactory getDatatypeFactory() { if (dtFactory == null) { dtFactory = DatatypeFactory.newInstance(); }//w w w .j av a 2s .c o m return dtFactory; }
From source file:es.itecban.deployment.executionmanager.gui.swf.service.PlanLaunchManager.java
public ExecutionReportType getReportFromCodifiedPlanId(String planId) throws DatatypeConfigurationException { ExecutionReportType planReport = null; // the planId given is a concatenation of the name of the plan and the // startTime of the plan of the report String reportName = planId.substring(0, planId.lastIndexOf('|')); String calendarString = planId.substring(planId.lastIndexOf('|') + 1); long calendarMiliSecs = Long.decode(calendarString); GregorianCalendar gregCalendar = new GregorianCalendar(); gregCalendar.setTimeInMillis(calendarMiliSecs); XMLGregorianCalendar xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCalendar); planReport = reportManager.findExecutionReportByPlanId(reportName, xmlCalendar); return planReport; }
From source file:com.fusesource.example.camel.process.camel.ProcessorRouteBuilderTest.java
@Test @DirtiesContext/* w w w.j a v a 2 s . co m*/ public void testNonRecoverableExternalServiceException() throws Exception { configureProcessRecordFailure(1, false); context.start(); DatatypeFactory dtf = DatatypeFactory.newInstance(); output.setExpectedMessageCount(0); dlq.setExpectedMessageCount(1); RecordType recordType = new RecordType(); recordType.setId("1"); recordType.setDate(dtf.newXMLGregorianCalendar(new GregorianCalendar())); recordType.setDescription("Record number: 1"); trigger.sendBody(recordType); output.assertIsSatisfied(1000); dlq.assertIsSatisfied(); }
From source file:eu.dasish.annotation.backend.dao.impl.DBDispatcherTest.java
/** * Test of getAnnotation method, of class DBIntegrityServiceImlp. *//*from w w w. ja v a 2 s .co m*/ @Test public void testGetAnnotation() throws Exception { System.out.println("test getAnnotation"); final Annotation mockAnnotation = new Annotation();// corresponds to the annotation # 1 mockAnnotation.setHref("/api/annotations/00000000-0000-0000-0000-000000000021"); mockAnnotation.setId("00000000-0000-0000-0000-000000000021"); mockAnnotation.setHeadline("Sagrada Famiglia"); XMLGregorianCalendar mockTimeStamp = DatatypeFactory.newInstance() .newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"); mockAnnotation.setLastModified(mockTimeStamp); mockAnnotation.setOwnerHref("/api/principals/00000000-0000-0000-0000-000000000111"); AnnotationBody mockBody = new AnnotationBody(); TextBody textBody = new AnnotationBody.TextBody(); mockBody.setTextBody(textBody); textBody.setMimeType("text/plain"); textBody.setBody("<html><body>some html 1</body></html>"); mockAnnotation.setBody(mockBody); PermissionList permissions = new PermissionList(); permissions.setPublic(Access.WRITE); mockAnnotation.setPermissions(permissions); mockAnnotation.setTargets(null); final List<Number> mockTargetIDs = new ArrayList<Number>(); mockTargetIDs.add(1); mockTargetIDs.add(2); final Target mockTargetOne = new Target(); mockTargetOne.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"); mockTargetOne.setId("00000000-0000-0000-0000-000000000031"); mockTargetOne.setHref("/api/targets/00000000-0000-0000-0000-000000000031"); mockTargetOne.setVersion("version 1.0"); final Target mockTargetTwo = new Target(); mockTargetTwo.setLink("http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD"); mockTargetTwo.setId("00000000-0000-0000-0000-000000000032"); mockTargetTwo.setHref("/api/targets/00000000-0000-0000-0000-000000000032"); mockTargetTwo.setVersion("version 1.1"); final List<Map<Number, String>> listMap = new ArrayList<Map<Number, String>>(); Map<Number, String> map2 = new HashMap<Number, String>(); map2.put(2, "write"); listMap.add(map2); Map<Number, String> map3 = new HashMap<Number, String>(); map3.put(3, "read"); listMap.add(map3); Map<Number, String> map4 = new HashMap<Number, String>(); map4.put(11, "read"); listMap.add(map4); final String uri1 = "/api/principals/00000000-0000-0000-0000-000000000111"; final String uri2 = "/api/principals/00000000-0000-0000-0000-000000000112"; final String uri3 = "/api/principals/00000000-0000-0000-0000-000000000113"; final String uri4 = "/api/principals/00000000-0000-0000-0000-000000000221"; mockeryDao.checking(new Expectations() { { oneOf(annotationDao).getAnnotationWithoutTargetsAndPemissionList(1); will(returnValue(mockAnnotation)); oneOf(annotationDao).getOwner(1); will(returnValue(1)); oneOf(principalDao).getHrefFromInternalID(1); will(returnValue(uri1)); oneOf(targetDao).getTargetIDs(1); will(returnValue(mockTargetIDs)); oneOf(targetDao).getTarget(1); will(returnValue(mockTargetOne)); oneOf(targetDao).getTarget(2); will(returnValue(mockTargetTwo)); /// getPermissionsForAnnotation oneOf(annotationDao).getPermissions(1); will(returnValue(listMap)); oneOf(principalDao).getHrefFromInternalID(2); will(returnValue(uri2)); oneOf(principalDao).getHrefFromInternalID(3); will(returnValue(uri3)); oneOf(principalDao).getHrefFromInternalID(11); will(returnValue(uri4)); } }); Annotation result = dbDispatcher.getAnnotation(1); assertEquals("00000000-0000-0000-0000-000000000021", result.getId()); assertEquals("/api/annotations/00000000-0000-0000-0000-000000000021", result.getHref()); assertEquals("text/plain", result.getBody().getTextBody().getMimeType()); assertEquals("<html><body>some html 1</body></html>", result.getBody().getTextBody().getBody()); assertEquals("Sagrada Famiglia", result.getHeadline()); assertEquals("2013-08-12T09:25:00.383000Z", result.getLastModified().toString()); assertEquals("/api/principals/00000000-0000-0000-0000-000000000111", result.getOwnerHref()); assertEquals(mockTargetOne.getLink(), result.getTargets().getTargetInfo().get(0).getLink()); assertEquals(mockTargetOne.getHref(), result.getTargets().getTargetInfo().get(0).getHref()); assertEquals(mockTargetOne.getVersion(), result.getTargets().getTargetInfo().get(0).getVersion()); assertEquals(mockTargetTwo.getLink(), result.getTargets().getTargetInfo().get(1).getLink()); assertEquals(mockTargetTwo.getHref(), result.getTargets().getTargetInfo().get(1).getHref()); assertEquals(mockTargetTwo.getVersion(), result.getTargets().getTargetInfo().get(1).getVersion()); assertEquals(3, result.getPermissions().getPermission().size()); assertEquals(Access.WRITE, result.getPermissions().getPermission().get(0).getLevel()); assertEquals(uri2, result.getPermissions().getPermission().get(0).getPrincipalHref()); assertEquals(Access.READ, result.getPermissions().getPermission().get(1).getLevel()); assertEquals(uri3, result.getPermissions().getPermission().get(1).getPrincipalHref()); assertEquals(Access.READ, result.getPermissions().getPermission().get(2).getLevel()); assertEquals(uri4, result.getPermissions().getPermission().get(2).getPrincipalHref()); assertEquals(Access.WRITE, result.getPermissions().getPublic()); }
From source file:it.cnr.icar.eric.server.persistence.rdb.AuditableEventDAO.java
/** * Creates an unitialized binding object for the type supported by this DAO. *//*from www.j a va 2s . c o m*/ Object createObject() throws JAXBException { AuditableEventType ebAuditableEventType = null; try { ebAuditableEventType = bu.rimFac.createAuditableEventType(); XMLGregorianCalendar timeNow = DatatypeFactory.newInstance() .newXMLGregorianCalendar(new GregorianCalendar()); ebAuditableEventType.setTimestamp(timeNow); } catch (DatatypeConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ebAuditableEventType; }
From source file:com.fusesource.example.camel.ingest.SimpleFileIngestorRouteBuilderTest.java
@Test @DirtiesContext/*from w w w . ja v a 2s. co m*/ public void testRecoverableExternalServiceException() throws Exception { configureProcessRecordFailure(1, true); context.start(); DatatypeFactory dtf = DatatypeFactory.newInstance(); output.setExpectedMessageCount(1); RecordType recordType = new RecordType(); recordType.setId("1"); recordType.setDate(dtf.newXMLGregorianCalendar(new GregorianCalendar())); recordType.setDescription("Record number: 1"); try { trigger.sendBody(SimpleFileIngestorRouteBuilder.HANDLE_RECORD_ROUTE_ENDPOINT_URI, marshallToXml(recordType)); } catch (CamelExecutionException e) { // expected } output.assertIsSatisfied(); }
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java
private Notification convert(CCTSNotification notification) { try {/*from ww w.ja v a 2 s . c om*/ Notification jaxbNotification = new Notification(); jaxbNotification.setApplication(Application.C_3_PR); jaxbNotification.setEventType(EventType.fromValue(notification.getEventType())); if (notification.getTimestamp() != null) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(notification.getTimestamp()); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar xmlDate = df.newXMLGregorianCalendar(gc); jaxbNotification.setTimestamp(xmlDate); } BusinessObjectID businessObjectID = new BusinessObjectID(); businessObjectID.setValue(notification.getIdentifierValue()); businessObjectID.setType(notification.getIdentifierType()); jaxbNotification.setObjectId(businessObjectID); return jaxbNotification; } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } }
From source file:be.fedict.eid.tsl.TrustServiceList.java
protected TrustServiceList(TrustStatusListType trustStatusList, Document tslDocument, File tslFile) { this.trustStatusList = trustStatusList; this.tslDocument = tslDocument; this.tslFile = tslFile; this.changeListeners = new LinkedList<ChangeListener>(); this.objectFactory = new ObjectFactory(); this.xadesObjectFactory = new be.fedict.eid.tsl.jaxb.xades.ObjectFactory(); this.xmldsigObjectFactory = new be.fedict.eid.tsl.jaxb.xmldsig.ObjectFactory(); this.tslxObjectFactory = new be.fedict.eid.tsl.jaxb.tslx.ObjectFactory(); try {//from w ww .j a va2 s.co m this.datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException("datatype config error: " + e.getMessage(), e); } }