List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.impl.CswRecordConverter.java
private void writeValue(HierarchicalStreamWriter writer, MarshallingContext context, AttributeDescriptor attributeDescriptor, QName field, Serializable value) { String xmlValue = null;//from www .j ava 2 s . co m AttributeFormat attrFormat = null; if (attributeDescriptor != null && attributeDescriptor.getType() != null) { attrFormat = attributeDescriptor.getType().getAttributeFormat(); } if (attrFormat == null) { attrFormat = AttributeFormat.STRING; } String name = null; if (!StringUtils.isBlank(field.getNamespaceURI())) { if (!StringUtils.isBlank(field.getPrefix())) { name = field.getPrefix() + CswConstants.NAMESPACE_DELIMITER + field.getLocalPart(); } else { name = field.getLocalPart(); } } else { name = field.getLocalPart(); } switch (attrFormat) { case BINARY: xmlValue = Base64.encodeBase64String((byte[]) value); break; case DATE: GregorianCalendar cal = new GregorianCalendar(); cal.setTime((Date) value); xmlValue = XSD_FACTORY.newXMLGregorianCalendar(cal).toXMLFormat(); break; case OBJECT: break; case GEOMETRY: case XML: default: xmlValue = value.toString(); break; } // Write the node if we were able to convert it. if (xmlValue != null) { writer.startNode(name); if (!StringUtils.isBlank(field.getNamespaceURI())) { if (!StringUtils.isBlank(field.getPrefix())) { writeNamespace(writer, field); } else { writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE, field.getNamespaceURI()); } } writer.setValue(xmlValue); writer.endNode(); } }
From source file:org.tolven.analysis.bean.SnapshotBean.java
/** * Based on the age and gender of the patient, this function validated the patients who satisfies * the two cohort properties - Age Ranges and gender.Return either true or false. *///from ww w. j a v a2 s. com @Override public Boolean validateCohortProperties(String type, MenuData patient, AppEvalAdaptor app) { Boolean genderCondition = false; Boolean ageCondition = false; String lowRangeType = ""; String highRangeType = ""; String calcType = ""; int lowRange = 0; int highRange = 0; int ageY = 0; int ageM = 0; int ageD = 0; int ageW = 0; int calcAge = 0; //gender Condition if (app.getAccount().getProperty().get("org.tolven.cohort." + type + ".gender") == null) { genderCondition = true; } else if (app.getAccount().getProperty().get("org.tolven.cohort." + type + ".gender").equals("")) { genderCondition = true; } else if ((app.getAccount().getProperty().get("org.tolven.cohort." + type + ".gender") .equals(patient.getString04().trim())) || (app.getAccount().getProperty().get("org.tolven.cohort." + type + ".gender").equals("Both"))) { genderCondition = true; } //age Condition if (app.getAccount().getProperty().get("org.tolven.cohort." + type + ".ageRangeCodes") == null) { ageCondition = true; } else if (app.getAccount().getProperty().get("org.tolven.cohort." + type + ".ageRangeCodes").equals("")) { ageCondition = true; } else { for (int i = 1; i < app.getAccount().getProperty().get("org.tolven.cohort." + type + ".ageRangeCodes") .split(",").length; i++) { ageCondition = false; lowRange = Integer.parseInt(app.getAccount().getProperty() .get("org.tolven.cohort." + type + ".ageRangeCodes").split(",")[i].split("~")[0]); lowRangeType = app.getAccount().getProperty().get("org.tolven.cohort." + type + ".ageRangeCodes") .split(",")[i].split("~")[1]; highRange = Integer.parseInt(app.getAccount().getProperty() .get("org.tolven.cohort." + type + ".ageRangeCodes").split(",")[i].split("~")[2]); highRangeType = app.getAccount().getProperty().get("org.tolven.cohort." + type + ".ageRangeCodes") .split(",")[i].split("~")[3]; GregorianCalendar n = new GregorianCalendar(); n.setTime(new Date()); GregorianCalendar b = new GregorianCalendar(); b.setTime(patient.getDate01()); int years = n.get(Calendar.YEAR) - b.get(Calendar.YEAR); int days = n.get(Calendar.DAY_OF_YEAR) - b.get(Calendar.DAY_OF_YEAR); if (days < 0) { years--; days = days + 365; } if (years > 1) { calcAge = years; calcType = "year"; } else if (years == 0 && days < 30) { calcAge = days; calcType = "days"; } else { calcAge = years * 12 + (days / 30); calcType = "months"; } if (calcType.equals("year")) { ageD = calcAge * 365; ageM = calcAge * 12; ageY = calcAge; ageW = calcAge * 52; } if (calcType.equals("months")) { ageD = calcAge * 30; ageM = calcAge; ageY = 0; ageW = calcAge / 7; } if (calcType.equals("days")) { ageD = calcAge; ageM = 0; ageY = 0; ageW = calcAge / 7; } if ((lowRangeType.equals("year")) && (highRangeType.equals("year"))) { if ((ageY >= lowRange) && (ageY <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("year")) && (highRangeType.equals("month"))) { if ((ageY >= lowRange) && (ageM <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("year")) && (highRangeType.equals("week"))) { if ((ageY >= lowRange) && (ageW <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("year")) && (highRangeType.equals("day"))) { if ((ageY >= lowRange) && (ageD <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("month")) && (highRangeType.equals("year"))) { if ((ageM >= lowRange) && (ageY <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("month")) && (highRangeType.equals("month"))) { if ((ageM >= lowRange) && (ageM <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("month")) && (highRangeType.equals("week"))) { if ((ageM >= lowRange) && (ageW <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("month")) && (highRangeType.equals("day"))) { if ((ageM >= lowRange) && (ageD <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("week")) && (highRangeType.equals("year"))) { if ((ageW >= lowRange) && (ageY <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("week")) && (highRangeType.equals("month"))) { if ((ageW >= lowRange) && (ageM <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("week")) && (highRangeType.equals("week"))) { if ((ageW >= lowRange) && (ageW <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("week")) && (highRangeType.equals("day"))) { if ((ageW >= lowRange) && (ageD <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("day")) && (highRangeType.equals("year"))) { if ((ageD >= lowRange) && (ageY <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("day")) && (highRangeType.equals("month"))) { if ((ageD >= lowRange) && (ageM <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("day")) && (highRangeType.equals("week"))) { if ((ageD >= lowRange) && (ageW <= highRange)) { ageCondition = true; } } if ((lowRangeType.equals("day")) && (highRangeType.equals("day"))) { if ((ageD >= lowRange) && (ageD <= highRange)) { ageCondition = true; } } if (ageCondition == true) break; } } if (genderCondition == true && ageCondition == true) { return true; } else { return false; } }
From source file:migration.RepositoryUpgrader.java
protected Time dateToTime(Date in) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(in); return TimeService.newTime(gc); }
From source file:edu.umm.radonc.ca_dash.controllers.PieChartController.java
public PieChartController() { endDate = new Date(); this.interval = ""; GregorianCalendar gc = new GregorianCalendar(); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map<String, Object> sessionMap = externalContext.getSessionMap(); if (sessionMap.containsKey("endDate")) { endDate = (Date) sessionMap.get("endDate"); } else {//from w w w .j ava2 s. c o m endDate = new Date(); sessionMap.put("endDate", endDate); } if (sessionMap.containsKey("startDate")) { startDate = (Date) sessionMap.get("startDate"); } else { gc.setTime(endDate); gc.add(Calendar.MONTH, -1); startDate = gc.getTime(); sessionMap.put("startDate", startDate); this.interval = "1m"; } this.df = new SimpleDateFormat("MM/dd/YYYY"); this.decf = new DecimalFormat("###.###"); this.decf.setRoundingMode(RoundingMode.HALF_UP); this.selectedFacility = new Long(-1); this.dstats = new SynchronizedDescriptiveStatistics(); this.dstatsPerDoc = new TreeMap<>(); this.dstatsPerRTM = new TreeMap<>(); this.pieChart = new PieChartModel(); selectedFilters = "all-tx"; }
From source file:org.webical.test.web.component.MonthViewPanelTest.java
/** * Test rendering with events.//from w w w. j a v a 2 s. c o m * @throws WebicalException */ public void testRenderingWithEvents() throws WebicalException { log.debug("testRenderingWithEvents"); String path = null; MockCalendarManager mockCalendarManager = (MockCalendarManager) annotApplicationContextMock .getBean("calendarManager"); Calendar calendar1 = mockCalendarManager.getCalendarById("1"); MockEventManager mockEventManager = new MockEventManager(); annotApplicationContextMock.putBean("eventManager", mockEventManager); GregorianCalendar cal = CalendarUtils.newTodayCalendar(getFirstDayOfWeek()); cal.set(GregorianCalendar.DAY_OF_MONTH, 15); final GregorianCalendar currentDate = CalendarUtils.duplicateCalendar(cal); // FIXME mattijs: test fails when run at 23:30 (probably also between 22:00 and 00:00) // all events List<Event> allEvents = new ArrayList<Event>(); // Add a normal event Event event = new Event(); event.setUid("e1"); event.setCalendar(calendar1); event.setSummary("Normal Event Description"); event.setLocation("Normal Event Location"); event.setDescription("Event e1"); cal.set(GregorianCalendar.DAY_OF_MONTH, 15); cal.set(GregorianCalendar.HOUR_OF_DAY, 13); cal.set(GregorianCalendar.MINUTE, 30); event.setDtStart(cal.getTime()); cal.add(GregorianCalendar.HOUR_OF_DAY, 2); event.setDtEnd(cal.getTime()); log.debug( "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd()); allEvents.add(event); mockEventManager.storeEvent(event); // Add a short recurring event, starting yesterday, ending tomorrow event = new Event(); event.setUid("e2"); event.setCalendar(calendar1); event.setSummary("Recurring Event Yesterday"); event.setLocation("Recurring Event Location"); event.setDescription("Event e2"); cal.set(GregorianCalendar.DAY_OF_MONTH, 14); cal.set(GregorianCalendar.HOUR_OF_DAY, 10); cal.set(GregorianCalendar.MINUTE, 0); event.setDtStart(cal.getTime()); cal.add(GregorianCalendar.HOUR_OF_DAY, 2); cal.set(GregorianCalendar.DAY_OF_MONTH, 17); event.setDtEnd(cal.getTime()); RecurrenceUtil.setRecurrenceRule(event, new Recurrence(Recurrence.DAILY, 1, CalendarUtils.getEndOfDay(cal.getTime()))); log.debug( "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd()); allEvents.add(event); mockEventManager.storeEvent(event); // Add a long recurring event, starting last month, ending next month event = new Event(); event.setUid("e3"); event.setCalendar(calendar1); event.setSummary("Recurring Event Last Month"); event.setLocation("Recurring Event Location"); event.setDescription("Event e3"); cal.set(GregorianCalendar.DAY_OF_MONTH, 15); cal.set(GregorianCalendar.HOUR_OF_DAY, 16); cal.set(GregorianCalendar.MINUTE, 0); cal.add(GregorianCalendar.MONTH, -1); event.setDtStart(cal.getTime()); cal.add(GregorianCalendar.HOUR_OF_DAY, 1); cal.set(GregorianCalendar.MINUTE, 30); cal.add(GregorianCalendar.MONTH, 2); event.setDtEnd(cal.getTime()); RecurrenceUtil.setRecurrenceRule(event, new Recurrence(Recurrence.DAILY, 1, CalendarUtils.getEndOfDay(cal.getTime()))); log.debug( "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd()); allEvents.add(event); mockEventManager.storeEvent(event); // Add a (pseudo) all day event, starting 21 00:00 hours, ending 22 00:00 hours event = new Event(); event.setUid("e4"); event.setCalendar(calendar1); event.setSummary("Pseudo All Day Event"); event.setLocation("All Day Event Location"); event.setDescription("Starting 21 00:00 hours, ending 22 00:00 hours"); cal = CalendarUtils.duplicateCalendar(currentDate); cal.set(GregorianCalendar.DAY_OF_MONTH, 21); cal.set(GregorianCalendar.HOUR_OF_DAY, 0); cal.set(GregorianCalendar.MINUTE, 0); cal.set(GregorianCalendar.SECOND, 0); cal.set(GregorianCalendar.MILLISECOND, 0); event.setDtStart(cal.getTime()); cal.add(GregorianCalendar.DAY_OF_MONTH, 1); event.setDtEnd(cal.getTime()); log.debug( "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd()); allEvents.add(event); mockEventManager.storeEvent(event); // Add a long event this week starting 23 14.00 hours and ending 25 16.00 hours event = new Event(); event.setUid("e5"); event.setCalendar(calendar1); event.setSummary("Long Event Description"); event.setLocation("Long Event Location"); event.setDescription("Event e5"); cal.set(GregorianCalendar.DAY_OF_MONTH, 23); cal.set(GregorianCalendar.HOUR_OF_DAY, 14); cal.set(GregorianCalendar.MINUTE, 0); event.setDtStart(cal.getTime()); cal.add(GregorianCalendar.DAY_OF_MONTH, 2); cal.add(GregorianCalendar.HOUR_OF_DAY, 2); event.setDtEnd(cal.getTime()); log.debug( "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd()); allEvents.add(event); mockEventManager.storeEvent(event); // Render test page with a MonthViewPanel wicketTester.startPage(new ITestPageSource() { private static final long serialVersionUID = 1L; public Page getTestPage() { MonthViewPanel monthViewPanel = new MonthViewPanel(PanelTestPage.PANEL_MARKUP_ID, 1, currentDate) { private static final long serialVersionUID = 1L; @Override public void onAction(IAction action) { /* NOTHING TO DO */ } }; return new PanelTestPage(monthViewPanel); } }); // Basic Assertions wicketTester.assertRenderedPage(PanelTestPage.class); wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID, MonthViewPanel.class); // Assert number of days rendered // Set the correct dates to find the first and last day of the month GregorianCalendar monthFirstDayDate = CalendarUtils.duplicateCalendar(currentDate); monthFirstDayDate .setTime(CalendarUtils.getFirstDayOfWeekOfMonth(currentDate.getTime(), getFirstDayOfWeek())); // Assert the first day in the view path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthFirstDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthFirstDayDate.get(GregorianCalendar.DAY_OF_YEAR); wicketTester.assertComponent(path, MonthDayPanel.class); GregorianCalendar monthLastDayDate = CalendarUtils.duplicateCalendar(currentDate); monthLastDayDate.setTime(CalendarUtils.getLastWeekDayOfMonth(currentDate.getTime(), getFirstDayOfWeek())); // Assert the last day in the view path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthLastDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthLastDayDate.get(GregorianCalendar.DAY_OF_YEAR); wicketTester.assertComponent(path, MonthDayPanel.class); // Check events List<Event> dayEvents = new ArrayList<Event>(); cal = CalendarUtils.duplicateCalendar(currentDate); // Assert events day 13 cal.set(GregorianCalendar.DAY_OF_MONTH, 13); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); MonthDayPanel monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Assert events day 14 cal.set(GregorianCalendar.DAY_OF_MONTH, 14); dayEvents.clear(); path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); dayEvents.add(allEvents.get(1)); // e2 dayEvents.add(allEvents.get(2)); // e3 wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Assert events day 15 cal.set(GregorianCalendar.DAY_OF_MONTH, 15); dayEvents.clear(); dayEvents.add(allEvents.get(0)); // e1 dayEvents.add(allEvents.get(1)); // e2 dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); cal.set(GregorianCalendar.DAY_OF_MONTH, 16); dayEvents.clear(); dayEvents.add(allEvents.get(1)); // e2 dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); cal.set(GregorianCalendar.DAY_OF_MONTH, 17); dayEvents.clear(); dayEvents.add(allEvents.get(1)); // e2 dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Only long recurring event cal.set(GregorianCalendar.DAY_OF_MONTH, 18); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Assert long recurring event first and last view day dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthFirstDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthFirstDayDate.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage() .get(PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + monthLastDayDate.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + monthLastDayDate.get(GregorianCalendar.DAY_OF_YEAR)); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Assert events day 21 cal.set(GregorianCalendar.DAY_OF_MONTH, 21); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 dayEvents.add(allEvents.get(3)); // e4 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); path = monthDayEventsListView.getPageRelativePath() + ":eventItem"; wicketTester.assertListView(path, dayEvents); ListView listView = (ListView) wicketTester.getComponentFromLastRenderedPage(path); Iterator<?> lvIt = listView.iterator(); while (lvIt.hasNext()) { ListItem item = (ListItem) lvIt.next(); Event evt = (Event) item.getModelObject(); List<?> bhvs = item.getBehaviors(); if (evt.getUid().equals("e4")) assertEquals(1, bhvs.size()); // e4 is an all day event on day 21 else assertEquals(0, bhvs.size()); } // Assert events day 22 cal.set(GregorianCalendar.DAY_OF_MONTH, 22); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); // Assert events day 23 cal.set(GregorianCalendar.DAY_OF_MONTH, 23); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 dayEvents.add(allEvents.get(4)); // e5 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); path = monthDayEventsListView.getPageRelativePath() + ":eventItem"; wicketTester.assertListView(path, dayEvents); listView = (ListView) wicketTester.getComponentFromLastRenderedPage(path); lvIt = listView.iterator(); while (lvIt.hasNext()) { ListItem item = (ListItem) lvIt.next(); List<?> bhvs = item.getBehaviors(); assertEquals(0, bhvs.size()); // no all day events } // Assert events day 24 cal.set(GregorianCalendar.DAY_OF_MONTH, 24); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 dayEvents.add(allEvents.get(4)); // e5 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); path = monthDayEventsListView.getPageRelativePath() + ":eventItem"; wicketTester.assertListView(path, dayEvents); listView = (ListView) wicketTester.getComponentFromLastRenderedPage(path); lvIt = listView.iterator(); while (lvIt.hasNext()) { ListItem item = (ListItem) lvIt.next(); Event evt = (Event) item.getModelObject(); List<?> bhvs = item.getBehaviors(); if (evt.getUid().equals("e5")) assertEquals(1, bhvs.size()); // e5 is an all day event on day 24 else assertEquals(0, bhvs.size()); } // Assert events day 25 cal.set(GregorianCalendar.DAY_OF_MONTH, 25); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 dayEvents.add(allEvents.get(4)); // e5 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); path = monthDayEventsListView.getPageRelativePath() + ":eventItem"; wicketTester.assertListView(path, dayEvents); listView = (ListView) wicketTester.getComponentFromLastRenderedPage(path); lvIt = listView.iterator(); while (lvIt.hasNext()) { ListItem item = (ListItem) lvIt.next(); List<?> bhvs = item.getBehaviors(); assertEquals(0, bhvs.size()); // no all day events } // Assert events day 26 cal.set(GregorianCalendar.DAY_OF_MONTH, 26); dayEvents.clear(); dayEvents.add(allEvents.get(2)); // e3 path = PanelTestPage.PANEL_MARKUP_ID + ":monthRowRepeater:week" + cal.get(GregorianCalendar.WEEK_OF_YEAR) + ":monthDayRepeater:day" + cal.get(GregorianCalendar.DAY_OF_YEAR); monthDayEventsListView = (MonthDayPanel) wicketTester.getLastRenderedPage().get(path); wicketTester.assertListView(monthDayEventsListView.getPageRelativePath() + ":eventItem", dayEvents); }
From source file:org.exoplatform.wiki.service.impl.WikiRestServiceImpl.java
public org.exoplatform.wiki.service.rest.model.Page createPage(ObjectFactory objectFactory, URI baseUri, URI self, PageImpl doc) throws Exception { org.exoplatform.wiki.service.rest.model.Page page = objectFactory.createPage(); fillPageSummary(page, objectFactory, baseUri, doc); page.setVersion("current"); page.setMajorVersion(1);//from w w w . jav a 2 s. com page.setMinorVersion(0); page.setLanguage(doc.getSyntax()); page.setCreator(doc.getOwner()); GregorianCalendar calendar = new GregorianCalendar(); page.setCreated(calendar); page.setModifier(doc.getAuthor()); calendar = new GregorianCalendar(); calendar.setTime(doc.getUpdatedDate()); page.setModified(calendar); page.setContent(doc.getContent().getText()); if (self != null) { Link pageLink = objectFactory.createLink(); pageLink.setHref(self.toString()); pageLink.setRel(Relations.SELF); page.getLinks().add(pageLink); } return page; }
From source file:ca.uhn.fhir.model.primitive.BaseDateTimeDt.java
/** * Returns the value of this object as a {@link GregorianCalendar} *///from w w w . j av a 2 s . co m public GregorianCalendar getValueAsCalendar() { if (getValue() == null) { return null; } GregorianCalendar cal; if (getTimeZone() != null) { cal = new GregorianCalendar(getTimeZone()); } else { cal = new GregorianCalendar(); } cal.setTime(getValue()); return cal; }
From source file:edu.umm.radonc.ca_dash.controllers.HistogramController.java
public HistogramController() { histogram = new BarChartModel(); percentile = 50.0;/*from ww w .jav a2 s . co m*/ dstats = new SynchronizedDescriptiveStatistics(); endDate = new Date(); interval = ""; binInterval = -1; includeWeekends = false; GregorianCalendar gc = new GregorianCalendar(); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map<String, Object> sessionMap = externalContext.getSessionMap(); if (sessionMap.containsKey("endDate")) { endDate = (Date) sessionMap.get("endDate"); } else { endDate = new Date(); sessionMap.put("endDate", endDate); } if (sessionMap.containsKey("startDate")) { startDate = (Date) sessionMap.get("startDate"); } else { gc.setTime(endDate); gc.add(Calendar.MONTH, -1); startDate = gc.getTime(); sessionMap.put("startDate", startDate); this.interval = "1m"; } selectedFilters = "all-tx"; selectedFacility = new Long(-1); patientsFlag = true; scheduledFlag = false; relativeModeFlag = false; }
From source file:org.extensiblecatalog.ncip.v2.millennium.MillenniumCheckOutItemService.java
/** * Handles a NCIP CheckOutItem service by returning hard-coded data. * * @param initData the CheckOutItemInitiationData * @param serviceManager provides access to remote services * @return CheckOutItemResponseData//from w w w .ja v a 2 s. c o m */ @Override public CheckOutItemResponseData performService(CheckOutItemInitiationData initData, ServiceContext serviceContext, RemoteServiceManager serviceManager) { final CheckOutItemResponseData responseData = new CheckOutItemResponseData(); MillenniumRemoteServiceManager millenniumSvcMgr = (MillenniumRemoteServiceManager) serviceManager; MillenniumConfiguration MillenniumConfig = millenniumSvcMgr.buildConfiguration(); String IIIClassicBaseUrl = MillenniumConfig.getURL(); String SNo = MillenniumConfig.getSearchScope(); String baseUrl = "https://" + IIIClassicBaseUrl + "/patroninfo"; //.html~S0"; //LOG.debug("CheckOut - baseURL: " + baseUrl); boolean foundUserId = false; boolean foundUserPass = false; List<Problem> problems = null; String userIdentifierType = null; final String getLDAPUserVarString = MillenniumConfig.getLdapUserVariable(); String[] getLDAPUserVarList = getLDAPUserVarString.split(","); final String getLDAPPasswordVarString = MillenniumConfig.getLdapPasswordVariable(); String[] getLDAPPasswordVarList = getLDAPPasswordVarString.split(","); final String getPatronUserVarString = MillenniumConfig.getPatronUserVariable(); String[] getPatronUserVarList = getPatronUserVarString.split(","); final String getPatronPasswordVarString = MillenniumConfig.getPatronPasswordVariable(); String[] getPatronPasswordVarList = getPatronPasswordVarString.split(","); boolean foundLDAPUser = false; boolean foundPatronUser = false; //boolean foundService = false; boolean foundCheckOut = false; //for (int x = 0; x < millenniumServicesList.length; x++) { // if (millenniumServicesList[x].trim().equals("CheckOut")) { // foundService = true; // } //} //if (foundService) { //for (int x = 0; x < millenniumFunctionsList.length; x++) { // if (millenniumFunctionsList[x].trim().equals("CheckOut")) { // foundCheckOut = true; // } //} //if (foundCheckOut) { authenticatedUserName = new ArrayList<String>(); authenticatedUserPassword = new ArrayList<String>(); for (AuthenticationInput authenticationInput : initData.getAuthenticationInputs()) { //LOG.debug("authenticationInput: " + authenticationInput.getAuthenticationInputData()); //LOG.debug("Type: " + authenticationInput.getAuthenticationInputType().getValue()); if ((authenticationInput.getAuthenticationInputType().getValue().toUpperCase().equals("LDAPUSERNAME")) || (authenticationInput.getAuthenticationInputType().getValue().toUpperCase() .equals("USERNAME"))) { userIdentifierType = authenticationInput.getAuthenticationInputType().getValue(); LOG.debug("RequestItem - userIdentifierType: " + userIdentifierType); if (authenticationInput.getAuthenticationInputData().trim().length() > 0) { authenticatedUserName.add(authenticationInput.getAuthenticationInputData()); foundUserId = true; } } if ((authenticationInput.getAuthenticationInputType().getValue().toUpperCase().equals("LDAPPASSWORD")) || (authenticationInput.getAuthenticationInputType().getValue().toUpperCase() .equals("PASSWORD")) || (authenticationInput.getAuthenticationInputType().getValue().toUpperCase().equals("PIN"))) { if (authenticationInput.getAuthenticationInputData().trim().length() > 0) { authenticatedUserPassword.add(authenticationInput.getAuthenticationInputData()); foundUserPass = true; } } } //LOG.debug("foundUser and foundPass: " + foundUserId + ", " + foundUserPass); if (foundUserId && foundUserPass) { //LOG.debug("1 - User: " + authenticatedUserName.size() + "=" + getLDAPUserVarList.length + "Pass: " + authenticatedUserPassword.size() + "=" + getLDAPPasswordVarList.length); testAuthUser = new ArrayList<PairGroup>(); testAuthPass = new ArrayList<PairGroup>(); authUserName = new ArrayList<PairGroup>(); authPassword = new ArrayList<PairGroup>(); htmlProperty authenticateStatus = null; if ((authenticatedUserName.size() == getLDAPUserVarList.length) && (authenticatedUserPassword.size() == getLDAPPasswordVarList.length)) { for (int x = 0; x < authenticatedUserName.size(); x++) { //LOG.debug("User pair: " + getLDAPUserVarList[x] + ", " + authenticatedUserName.get(x)); PairGroup userPair = millenniumSvcMgr.setPairGroup(getLDAPUserVarList[x], authenticatedUserName.get(x)); testAuthUser.add(userPair); } for (int y = 0; y < authenticatedUserPassword.size(); y++) { //LOG.debug("pass pair: " + getLDAPPasswordVarList[y] + ", " + authenticatedUserPassword.get(y)); PairGroup passPair = millenniumSvcMgr.setPairGroup(getLDAPPasswordVarList[y], authenticatedUserPassword.get(y)); testAuthPass.add(passPair); } authenticateStatus = millenniumSvcMgr.Authenticate(testAuthUser, testAuthPass, baseUrl); if (authenticateStatus.recordStatus.returnStatus) { authUserName = testAuthUser; authPassword = testAuthPass; foundLDAPUser = true; LOG.debug("LDAP authUserName.size() =" + authUserName.size()); } } //LOG.debug("2 - FoundLDAPUser: " + foundLDAPUser); if ((foundLDAPUser == false) && ((authenticatedUserName.size() == getPatronUserVarList.length) && (authenticatedUserPassword.size() == getPatronPasswordVarList.length))) { testAuthUser = new ArrayList<PairGroup>(); testAuthPass = new ArrayList<PairGroup>(); for (int x = 0; x < authenticatedUserName.size(); x++) { PairGroup userPair = millenniumSvcMgr.setPairGroup(getPatronUserVarList[x], authenticatedUserName.get(x)); testAuthUser.add(userPair); } for (int y = 0; y < authenticatedUserPassword.size(); y++) { PairGroup passPair = millenniumSvcMgr.setPairGroup(getPatronPasswordVarList[y], authenticatedUserPassword.get(y)); testAuthPass.add(passPair); } authenticateStatus = millenniumSvcMgr.Authenticate(testAuthUser, testAuthPass, baseUrl); if (authenticateStatus.recordStatus.returnStatus) { authUserName = testAuthUser; authPassword = testAuthPass; foundPatronUser = true; LOG.debug("Patron authUserName.size() =" + authUserName.size()); } } String itemBarCode = initData.getItemId().getItemIdentifierValue(); LOG.debug("CheckOut - itemBarCode: " + itemBarCode); int barCodeIndex = 0; //htmlProperty authenticateStatus = millenniumSvcMgr.Authenticate(authenticatedUserName, authenticatedUserPassword, baseUrl); if (foundLDAPUser || foundPatronUser) { LOG.debug("CheckOut - Login Success!"); boolean getItems = false; String strSessionId = authenticateStatus.sessionId; String redirectedUrl = authenticateStatus.url; LOG.debug("CheckOut - redirectedUrl: " + redirectedUrl); authenticatedUserId = authenticateStatus.userid; LOG.debug("CheckOut - authenticatedUserId: " + authenticatedUserId); String html = authenticateStatus.html; String pageItem = authenticateStatus.pageItem.toLowerCase().trim(); //LOG.debug("CheckOut - itempage: " + authenticateStatus.pageItem); //LOG.debug("CheckOut - SNo: " + SNo); if (pageItem.equals("items") || html.contains("<a href=\"/patroninfo~" + SNo + "/" + authenticatedUserId + "/items")) { getItems = true; } LOG.debug("CheckOut - Found - Items: " + getItems); if (getItems) { LOG.debug("CheckOut - Found Items Currently Checked out"); StatusString getItemsStatus = millenniumSvcMgr.getAuthenticationItemsPage(authenticatedUserId, strSessionId, "items"); if (getItemsStatus.recordStatus.returnStatus) { LOG.debug("CheckOut - Success received items page. HTML char: " + getItemsStatus.statusValue.length()); ArrayList<AuthenticationItemsInfo> itemsCheckedOutList = null;//millenniumSvcMgr.getItemsCheckedOut(authenticatedUserId, strSessionId, "items"); UserItemInfo itemsCheckOutStatus = millenniumSvcMgr .getItemsCheckedOut(getItemsStatus.statusValue, foundCheckOut); if (itemsCheckOutStatus.recordStatus.returnStatus) { LOG.debug("CheckOut - Success received items page array information"); itemsCheckedOutList = itemsCheckOutStatus.itemsList; boolean foundBarCode = false; for (int x = 0; x < itemsCheckedOutList.size(); x++) { if (itemsCheckedOutList.get(x).iBarcode.contains(itemBarCode)) { foundBarCode = true; barCodeIndex = x; } } if (foundBarCode) { LOG.debug("CheckOut - Found item barcode in items page at index: " + barCodeIndex); //LOG.debug("CheckOut - Mark id: " + itemsCheckedOutList.get(barCodeIndex).iMark); //LOG.debug("CheckOut - Mark Value: " + itemsCheckedOutList.get(barCodeIndex).iMarkValue); String url = null; if (strFunction.Rightstr(redirectedUrl, "/").equals("items")) { url = redirectedUrl; } else { url = redirectedUrl.replace(pageItem, "items"); } LOG.debug("CheckOut - url: " + url); PostMethod postMethod = new PostMethod(url); postMethod.addParameter(itemsCheckedOutList.get(barCodeIndex).iMark, itemsCheckedOutList.get(barCodeIndex).iMarkValue); postMethod.addParameter("renewsome", "YES"); StatusString renewStatus = millenniumSvcMgr.LogInWebActionForm(postMethod, strSessionId); if (renewStatus.recordStatus.returnStatus) { //LOG.debug("html lenght: " + renewStatus.statusValue.length()); UserItemInfo itemRenewStatus = millenniumSvcMgr .getItemsCheckedOut(renewStatus.statusValue, foundCheckOut); if (itemRenewStatus.recordStatus.returnStatus) { ArrayList<AuthenticationItemsInfo> renewItemList = itemRenewStatus.itemsList; if (itemsCheckedOutList.size() == renewItemList.size()) { LOG.debug("Checkout Status is: " + itemsCheckedOutList.get(barCodeIndex).iStatus); LOG.debug("Checkout Status is: " + renewItemList.get(barCodeIndex).iStatus); if (itemsCheckedOutList.get(barCodeIndex).iStatus .equals(renewItemList.get(barCodeIndex).iStatus) == false) { StatusString newDueDateString = millenniumSvcMgr .setRenewSimpleDateFormat( renewItemList.get(barCodeIndex).iStatus); if (newDueDateString.recordStatus.returnStatus) { //Date dueDate = null; // set to null SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); try { Date dueDate = dateFormat.parse(newDueDateString.statusValue .trim().replace("-", "/")); LOG.debug("CheckOut - NewDueDate: " + dueDate); //Date newDueDate = millenniumSvcMgr.setRenewSimpleDateFormat(renewItemList.get(barCodeIndex).iStatus); GregorianCalendar DueDateCalendar = new GregorianCalendar( TimeZone.getTimeZone("UTC")); DueDateCalendar.setTime(dueDate); responseData.setDateDue(DueDateCalendar); ItemId itemId = new ItemId(); itemId.setItemIdentifierValue(itemBarCode); responseData.setItemId(itemId); } catch (ParseException pe) { LOG.error("setRenewSimpleDateFormat ERROR: Cannot parse \"" + newDueDateString.statusValue + "\""); problems = ServiceHelper.generateProblems( Version1LookupItemProcessingError.UNKNOWN_ITEM, "CheckOut Error", null, "Date format error for: " + itemBarCode); } } else { LOG.error("CheckOut - " + newDueDateString.statusValue.trim() + " for Item Barcode: " + itemBarCode + "."); String errorMsg = newDueDateString.statusValue.trim() + " for Item Barcode '" + itemBarCode + "'."; problems = ServiceHelper.generateProblems( Version1LookupItemProcessingError.UNKNOWN_ITEM, "CheckOut Error", null, errorMsg); } } else { LOG.error("CheckOut - Couldn't Renew Item for Item Barcode: " + itemBarCode); problems = ServiceHelper.generateProblems( Version1LookupItemProcessingError.UNKNOWN_ITEM, "CheckOut Error", null, "Couldn't Renew Item for Item Barcode: " + itemBarCode); } } else { LOG.error("CheckOut - Renew Item array list not match"); problems = ServiceHelper.generateProblems( Version1LookupItemProcessingError.UNKNOWN_ITEM, "Item Array not match", null, "Renew Item array list not match"); } // if (itemsCheckedOutList.size() == renewItemList.size()) } else { LOG.error("CheckOut - False received renew items page array information"); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "Failed to get Items Array", null, itemRenewStatus.recordStatus.returnMsg); } // if (itemRenewStatus.recordStatus.returnStatus) } else { LOG.error("CheckOut - Couldn't receive Renewitem page!"); //LOG.debug ("Error: " + renewStatus.recordStatus.returnMsg); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "Failed to get Renew Confirmation", null, renewStatus.recordStatus.returnMsg); } // if (renewStatus.recordStatus.returnStatus) } else { LOG.error("CheckOut - Couldn't find the Barcode: " + itemBarCode + " in Items Page of user: " + authenticatedUserName); problems = ServiceHelper.generateProblems( Version1LookupItemProcessingError.UNKNOWN_ITEM, "BarCode not Found", null, "Couldn't find the Barcode: " + itemBarCode + " in Items Page of user: " + authenticatedUserName); } } else { LOG.error("CheckOut - False received checkout items page array information"); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "Failed to get Items Array", null, itemsCheckOutStatus.recordStatus.returnMsg); } // if (foundLDAPUser || foundPatronUser) } else { LOG.error("CheckOut - False received items page"); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "False received items page", null, getItemsStatus.recordStatus.returnMsg); } // if (getItemsStatus.recordStatus.returnStatus) } else { // if (getItems) LOG.error("CheckOut - Couldn't found Item page"); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "Items page not found", null, "Couldn't found Item page!"); } } else { LOG.error("CheckOut - Incorrect User Id or Password!"); problems = ServiceHelper.generateProblems( Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "User Authentication Failed", null, "False to login - Incorrect User Id or Password!"); } } else { LOG.error("User Id or Password is missing!"); problems = ServiceHelper.generateProblems(Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, "Missing User Id or Password", null, "User Id or Password is missing!"); } // } else { // LOG.error("CheckOut - Function Renew is not support!"); // problems = ServiceHelper.generateProblems(Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, // "Function is not support", null, "Function is not support!"); // } // if (foundRenew) // } else { // LOG.error("CheckOut - Services is not support!"); // problems = ServiceHelper.generateProblems(Version1LookupUserProcessingError.USER_AUTHENTICATION_FAILED, // "Services is not support", null, "Services is not support!"); // } // if (foundService) if (problems != null) { //LOG.debug("main 3 - " + problems.size()); responseData.setProblems(problems); if (foundLDAPUser || foundPatronUser) { baseUrl = "https://" + IIIClassicBaseUrl + "/logout"; millenniumSvcMgr.LogOut(baseUrl); } return responseData; } else { LOG.debug("CheckOut - Success received all information"); user.setUserIdentifierValue(authUserName.get(0).secondValue); try { user.setUserIdentifierType(UserIdentifierType.find(null, userIdentifierType)); } catch (ServiceException e) { e.printStackTrace(); } responseData.setUserId(user); baseUrl = "https://" + IIIClassicBaseUrl + "/logout"; millenniumSvcMgr.LogOut(baseUrl); return responseData; } }
From source file:org.squale.squalecommon.daolayer.component.AuditDAOImpl.java
/** * Dcale l'audit de rotation des partitions la prochaine date prvue Le dlai prvu entre 2 rotations est de 12 * semaines//from w w w . ja v a2s . c o m * * @param pSession la session * @throws JrafDaoException en cas d'chec */ public void reportRotationAudit(ISession pSession) throws JrafDaoException { // Rcupre l'audit de rotation Collection result = findRotationAudit(pSession); if (result != null && result.size() != 0) { // il ne doit y avoir qu'un seul lment Iterator it = result.iterator(); AuditBO rotationAudit = (AuditBO) it.next(); Date currentDate = rotationAudit.getDate(); // ajout le dlai prvu GregorianCalendar currentCal = new GregorianCalendar(); currentCal.setTime(currentDate); currentCal.add(Calendar.WEEK_OF_YEAR, ROTATION_DELAY_IN_WEEKS); rotationAudit.setDate(currentCal.getTime()); // et mise jour en base save(pSession, rotationAudit); } }