List of usage examples for javax.xml.datatype XMLGregorianCalendar getYear
public abstract int getYear();
From source file:no.uis.fsws.proxy.StudinfoProxyImpl.java
@Override public List<Studieprogram> getStudieprogram(final XMLGregorianCalendar arstall, final Terminkode terminkode, final Sprakkode sprak, final boolean medUPinfo, final String studieprogramkode) { final StudInfoImport svc = getServiceForPrincipal(); try {/* w ww .ja va 2s. c o m*/ Future<List<Studieprogram>> future = executor.submit(new Callable<List<Studieprogram>>() { @Override public List<Studieprogram> call() throws Exception { final FsStudieinfo sinfo = svc.fetchStudyProgram(studieprogramkode, arstall.getYear(), terminkode.toString(), medUPinfo, sprak.toString()); return sinfo.getStudieprogram(); } }); return future.get(timeoutMinutes, TimeUnit.MINUTES); } catch (ExecutionException | InterruptedException | TimeoutException e) { throw new RuntimeException(e); } }
From source file:no.uis.fsws.proxy.StudinfoProxyImpl.java
@Override @SneakyThrows//from ww w. j a v a2 s .c o m public List<Emne> getEmnerForOrgenhet(final XMLGregorianCalendar arstall, final Terminkode terminkode, final Sprakkode sprak, final int institusjonsnr, final Integer fakultetsnr, final Integer instituttnr, final Integer gruppenr) { final StudInfoImport svc = getServiceForPrincipal(); Future<List<Emne>> future = executor.submit(new Callable<List<Emne>>() { @Override public List<Emne> call() throws Exception { final FsStudieinfo sinfo = svc.fetchSubjects(institusjonsnr, fakultetsnr == null ? -1 : fakultetsnr.intValue(), arstall.getYear(), terminkode.toString(), sprak.toString()); return sinfo.getEmne(); } }); return future.get(timeoutMinutes, TimeUnit.MINUTES); }
From source file:no.uis.fsws.proxy.StudinfoProxyImpl.java
@Override public List<Studieprogram> getStudieprogrammerForOrgenhet(final XMLGregorianCalendar arstall, final Terminkode terminkode, final Sprakkode sprak, final int institusjonsnr, final Integer fakultetsnr, final Integer instituttnr, final Integer gruppenr, final boolean medUPinfo) { final StudInfoImport svc = getServiceForPrincipal(); try {//from w w w. j a v a 2 s . c om Future<List<Studieprogram>> future = executor.submit(new Callable<List<Studieprogram>>() { @Override public List<Studieprogram> call() throws Exception { final FsStudieinfo sinfo = svc.fetchStudyPrograms(institusjonsnr, fakultetsnr != null ? fakultetsnr : -1, arstall.getYear(), terminkode.toString(), medUPinfo, sprak.toString()); return sinfo.getStudieprogram(); } }); return future.get(timeoutMinutes, TimeUnit.MINUTES); } catch (ExecutionException | InterruptedException | TimeoutException e) { throw new RuntimeException(e); } }
From source file:eu.openminted.registry.service.generate.WorkflowOutputMetadataGenerate.java
protected ResourceCreationInfo generateResourceCreationInfo(String userId) throws JsonParseException, JsonMappingException, IOException { ResourceCreationInfo resourceCreationInfo = new ResourceCreationInfo(); // resourceCreators.resourceCreator.relatedPerson List<ActorInfo> resourceCreators = new ArrayList<>(); ActorInfo actorInfo = new ActorInfo(); actorInfo.setActorType(ActorTypeEnum.PERSON); actorInfo.setRelatedPerson(generatePersonInfo(userId, false)); resourceCreators.add(actorInfo);/*from w ww .j ava2 s. c o m*/ resourceCreationInfo.setResourceCreators(resourceCreators); // resourceCreationDate DateCombination creationDate = new DateCombination(); XMLGregorianCalendar calendar = null; try { calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregory); } catch (DatatypeConfigurationException e) { e.printStackTrace(); } Date date = new Date(); date.setYear(calendar.getYear()); date.setMonth(calendar.getMonth()); date.setDay(calendar.getDay()); creationDate.setDate(date); resourceCreationInfo.setCreationDate(creationDate); return resourceCreationInfo; }
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
private Participant copyParticipant(SessionFactory factory, ParticipantType pt, LocalDate sessionDate) { final Participant retVal = factory.createParticipant(); retVal.setId(pt.getId());// w w w. jav a2 s . c om retVal.setName(pt.getName()); final XMLGregorianCalendar bday = pt.getBirthday(); if (bday != null) { final LocalDate bdt = LocalDate.of(bday.getYear(), bday.getMonth(), bday.getDay()); retVal.setBirthDate(bdt); // calculate age up to the session date final Period period = Period.between(bdt, sessionDate); retVal.setAgeTo(period); } final Duration ageDuration = pt.getAge(); if (ageDuration != null) { // convert to period final Period age = Period.of(ageDuration.getYears(), ageDuration.getMonths(), ageDuration.getDays()); retVal.setAge(age); } retVal.setEducation(pt.getEducation()); retVal.setGroup(pt.getGroup()); String langs = ""; for (String lang : pt.getLanguage()) langs += (langs.length() > 0 ? ", " : "") + lang; retVal.setLanguage(langs); if (pt.getSex() == SexType.MALE) retVal.setSex(Sex.MALE); else if (pt.getSex() == SexType.FEMALE) retVal.setSex(Sex.FEMALE); else retVal.setSex(Sex.UNSPECIFIED); ParticipantRole prole = ParticipantRole.fromString(pt.getRole()); if (prole == null) prole = ParticipantRole.TARGET_CHILD; retVal.setRole(prole); retVal.setSES(pt.getSES()); return retVal; }
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
/** * Read session in from given xml {@link SessionType} object. * /*from w ww . j a va 2 s .c om*/ * @param sessionType * * @return session */ private Session readSessionType(SessionType sessionType) { final SessionFactory factory = SessionFactory.newFactory(); final Session retVal = factory.createSession(); // copy header info retVal.setName(sessionType.getId()); retVal.setCorpus(sessionType.getCorpus()); final HeaderType headerData = sessionType.getHeader(); if (headerData != null) { if (headerData.getMedia() != null && headerData.getMedia().length() > 0) { retVal.setMediaLocation(headerData.getMedia()); } if (headerData.getDate() != null) { final XMLGregorianCalendar xmlDate = headerData.getDate(); final LocalDate dateTime = LocalDate.of(xmlDate.getYear(), xmlDate.getMonth(), xmlDate.getDay()); retVal.setDate(dateTime); } if (headerData.getLanguage().size() > 0) { String langs = ""; for (String lang : headerData.getLanguage()) { langs += (langs.length() > 0 ? " " : "") + lang; } retVal.setLanguage(langs); } } // copy participant information final ParticipantsType participants = sessionType.getParticipants(); if (participants != null) { for (ParticipantType pt : participants.getParticipant()) { final Participant p = copyParticipant(factory, pt, retVal.getDate()); retVal.addParticipant(p); } } // copy transcriber information final TranscribersType transcribers = sessionType.getTranscribers(); if (transcribers != null) { for (TranscriberType tt : transcribers.getTranscriber()) { final Transcriber t = copyTranscriber(factory, tt); retVal.addTranscriber(t); } } // copy tier information final UserTiersType userTiers = sessionType.getUserTiers(); if (userTiers != null) { for (UserTierType utt : userTiers.getUserTier()) { final TierDescription td = copyTierDescription(factory, utt); retVal.addUserTier(td); } } final List<TierViewItem> tierOrder = new ArrayList<TierViewItem>(); for (TvType tot : sessionType.getTierOrder().getTier()) { final TierViewItem toi = copyTierViewItem(factory, tot); tierOrder.add(toi); } retVal.setTierView(tierOrder); // copy transcript data final List<Comment> recordComments = new ArrayList<Comment>(); boolean foundFirstRecord = false; if (sessionType.getTranscript() != null) { for (Object uOrComment : sessionType.getTranscript().getUOrComment()) { if (uOrComment instanceof CommentType) { final CommentType ct = (CommentType) uOrComment; final Comment comment = copyComment(factory, ct); recordComments.add(comment); } else { if (!foundFirstRecord && recordComments.size() > 0) { // add record comments to session metadata for (Comment c : recordComments) { retVal.getMetadata().addComment(c); } recordComments.clear(); } final RecordType rt = (RecordType) uOrComment; Record record = null; try { record = new LazyRecord(factory, retVal, rt); } catch (Exception e) { LOGGER.info(rt.getId()); LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } retVal.addRecord(record); for (Comment comment : recordComments) { record.addComment(comment); } recordComments.clear(); foundFirstRecord = true; } } } return retVal; }
From source file:org.apache.cxf.cwiki.SiteExporter.java
public String breadcrumbs(BlogEntrySummary page) { StringBuffer buffer = new StringBuffer(); if (breadCrumbRoot != null) { buffer.append("<a href=\""); buffer.append("../../../index.html"); buffer.append("\">"); buffer.append(breadCrumbRoot);//w w w . ja va2 s. co m buffer.append("</a>"); buffer.append(SEPARATOR); } else { buffer.append("<a href=\"../../../index.html\">Index</a>"); buffer.append(SEPARATOR); } XMLGregorianCalendar published = page.getPublished(); buffer.append(String.valueOf(published.getYear())); buffer.append(SEPARATOR); if (published.getMonth() < 10) { buffer.append("0"); } buffer.append(String.valueOf(published.getMonth())); buffer.append(SEPARATOR); if (published.getDay() < 10) { buffer.append("0"); } buffer.append(String.valueOf(published.getDay())); buffer.append(SEPARATOR); buffer.append("<a href=\""); buffer.append(page.createFileName()); buffer.append("\">"); buffer.append(page.getTitle()); buffer.append("</a>"); return buffer.toString(); }
From source file:com.microsoft.exchange.integration.TimeZoneIntegrationTest.java
@Test public void createGetDeleteCalendarItem() throws DatatypeConfigurationException { TimeZone utcTimeZone = TimeZone.getTimeZone(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID); TimeZone.setDefault(utcTimeZone); ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:test-contexts/exchangeContext.xml"); RequestServerTimeZoneInterceptor timeZoneInterceptor = context .getBean(RequestServerTimeZoneInterceptor.class); ExchangeWebServices ews = context.getBean(ExchangeWebServices.class); BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class); exchangeCalendarDao.setWebServices(ews); assertEquals(TimeZone.getDefault(), utcTimeZone); //XMLGregorianCalendar is sortof backed by a gregorian calendar, date/times should reflect default jvm timezone XMLGregorianCalendar xmlStart = DateHelp.getXMLGregorianCalendarNow(); CalendarItemType calendarItem = new CalendarItemType(); calendarItem.setStart(xmlStart);/*from ww w. j ava2 s . c om*/ ItemIdType itemId = exchangeCalendarDao.createCalendarItem(upn, calendarItem); assertNotNull(itemId); Set<ItemIdType> itemIds = Collections.singleton(itemId); Set<CalendarItemType> calendarItems = exchangeCalendarDao.getCalendarItems(upn, itemIds); assertNotNull(calendarItems); CalendarItemType createdCalendarItem = DataAccessUtils.singleResult(calendarItems); assertNotNull(createdCalendarItem); XMLGregorianCalendar createdCalendarItemStart = createdCalendarItem.getStart(); assertNotNull(createdCalendarItemStart); assertEquals(xmlStart.getTimezone(), createdCalendarItemStart.getTimezone()); //nope! tzDisplayName = createdCalendarItem.getTimeZone() //assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, createdCalendarItem.getTimeZone()); assertEquals(xmlStart.getEon(), createdCalendarItemStart.getEon()); assertEquals(xmlStart.getEonAndYear(), createdCalendarItemStart.getEonAndYear()); assertEquals(xmlStart.getYear(), createdCalendarItemStart.getYear()); assertEquals(xmlStart.getMonth(), createdCalendarItemStart.getMonth()); assertEquals(xmlStart.getDay(), createdCalendarItemStart.getDay()); assertEquals(xmlStart.getHour(), createdCalendarItemStart.getHour()); assertEquals(xmlStart.getMinute(), createdCalendarItemStart.getMinute()); assertEquals(xmlStart.getSecond(), createdCalendarItemStart.getSecond()); //nope! always seems to be a slight variation //assertEquals(xmlStart.toGregorianCalendar().getTimeInMillis(), createdCalendarItemStart.toGregorianCalendar().getTimeInMillis()); //assertEquals(xmlStart.getMillisecond(), createdCalendarItemStart.getMillisecond()); //assertEquals(xmlStart.getFractionalSecond(), createdCalendarItemStart.getFractionalSecond()); assertTrue(DateHelp.withinOneSecond(xmlStart, createdCalendarItemStart)); assertTrue(exchangeCalendarDao.deleteCalendarItems(upn, itemIds)); }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public String loadPreviousQueries(boolean getAllInGroup) { System.out.println("Loading previous queries for: " + System.getProperty("user")); String xmlStr = writeContentQueryXML(getAllInGroup); lastRequestMessage = xmlStr;//from w w w. j a va 2 s . co m //System.out.println(xmlStr); String responseStr = QueryListNamesClient.sendQueryRequestREST(xmlStr); if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return "CellDown"; } lastResponseMessage = responseStr; try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass( bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class); previousQueries = new ArrayList<QueryMasterData>(); for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) { QueryMasterData tmpData; tmpData = new QueryMasterData(); XMLGregorianCalendar cldr = queryMasterType.getCreateDate(); tmpData.name( queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]"); tmpData.tooltip("A query run by " + queryMasterType.getUserId());//System.getProperty("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(new Integer(queryMasterType.getQueryMasterId()).toString()); tmpData.userId(queryMasterType.getUserId()); //System.getProperty("user")); previousQueries.add(tmpData); } return ""; } catch (Exception e) { e.printStackTrace(); return "error"; } }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData data = (QueryMasterData) node.getUserObject(); try {//from w ww. j ava2 s . c o m String xmlRequest = data.writeContentQueryXML(); lastRequestMessage = xmlRequest; //System.out.println(xmlRequest); String xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } lastResponseMessage = xmlResponse; try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { //change later for working with new xml schema //RunQuery runQuery = queryInstanceType.getResult().get(i).getRunQuery().get(0); QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); runData.tooltip("The results of the query run"); runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString()); //runData.patientRefId(new Integer(queryInstanceType.getRefId()).toString()); //runData.patientCount(new Long(queryInstanceType.getCount()).toString()); XMLGregorianCalendar cldr = queryInstanceType.getStartDate(); runData.name("Results of " + "[" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + addZero(cldr.getHour()) + ":" + addZero(cldr.getMinute()) + ":" + addZero(cldr.getSecond()) + "]"); data.runs.add(runData); addNode(runData, node); } } catch (Exception e) { e.printStackTrace(); } jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData data = (QueryInstanceData) node.getUserObject(); try { String xmlRequest = data.writeContentQueryXML(); lastRequestMessage = xmlRequest; //System.out.println(xmlRequest); String xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } lastResponseMessage = xmlResponse; JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType .getQueryResultInstance()) { String status = queryResultInstanceType.getQueryStatusType().getName(); QueryResultData resultData = new QueryResultData(); resultData.visualAttribute("LAO"); resultData.tooltip("A patient set of the query run"); //resultData.queryId(data.queryId()); resultData.patientRefId(new Integer(queryResultInstanceType.getResultInstanceId()).toString());//data.patientRefId()); resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());//data.patientCount()); if (status.equalsIgnoreCase("FINISHED")) { resultData.name("Patient Set - " + resultData.patientCount() + " Patients"); } else { resultData.name("Patient Set - " + status); } resultData.xmlContent(xmlResponse); addNode(resultData, node); } jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } //implement for other type of nodes later!!! }