Package net.fortuna.ical4j.model

Examples of net.fortuna.ical4j.model.Calendar


        DateTime startDate = new DateTime(2011, 1, 1, 0, 0, 0, 0);
        startDate = startDate.minusDays(7);
        condition.setStartDate(startDate.toDate());
        condition.setKeywords(Arrays.asList("テスト", "説明"));

        Calendar calendar = service.getCalendar(condition);
        assertThat(calendar, not(nullValue()));
        assertThat(calendar.getProperty("PRODID").getValue(), is("nico2ical"));
        assertThat(calendar.getProperty("VERSION").getValue(), is("2.0"));
        assertThat(
            calendar.getProperty("X-WR-CALNAME").getValue(),
            is("ニコニコ生放送"));
        ComponentList components = calendar.getComponents();
        assertThat(components, is(notNullValue()));
        assertThat(components.size(), is(8));
        // DTSTARTが古い順にイベントが並んでいる。
        int i = 7;
        for (Object object : components) {
View Full Code Here


        CalendarCondition condition = new CalendarCondition();
        DateTime startDate = new DateTime(2011, 1, 2, 0, 0, 0, 0);
        condition.setStartDate(startDate.toDate());

        Calendar calendar = service.getCalendar(condition);
        // データが存在しない場合でもnullにはならない。
        assertThat(calendar, not(nullValue()));
        // イベントなしのiCalendar形式データが取得される。
        assertThat(calendar.getProperty("PRODID").getValue(), is("nico2ical"));
        assertThat(calendar.getProperty("VERSION").getValue(), is("2.0"));
        assertThat(
            calendar.getProperty("X-WR-CALNAME").getValue(),
            is("ニコニコ生放送"));
        ComponentList components = calendar.getComponents();
        assertThat(components, is(notNullValue()));
        assertThat(components.size(), is(0));
    }
View Full Code Here

        assertThat(output, is(notNullValue()));
        Reader reader = null;
        try {
            reader = new StringReader(output);
            CalendarBuilder builder = new CalendarBuilder();
            Calendar calendar = builder.build(reader);
            assertThat(calendar, is(notNullValue()));
            assertThat(
                calendar.getProperty("PRODID").getValue(),
                is("nico2ical"));
            assertThat(calendar.getProperty("VERSION").getValue(), is("2.0"));
            assertThat(
                calendar.getProperty("X-WR-CALNAME").getValue(),
                is("ニコニコ生放送"));
            ComponentList components = calendar.getComponents();
            assertThat(components, is(notNullValue()));
            assertThat(components.size(), is(0));
        } catch (IOException e) {
            fail(e.getMessage());
        } catch (ParserException e) {
View Full Code Here

        assertThat(output, is(notNullValue()));
        Reader reader = null;
        try {
            reader = new StringReader(output);
            CalendarBuilder builder = new CalendarBuilder();
            Calendar calendar = builder.build(reader);
            assertThat(calendar, is(notNullValue()));
            assertThat(
                calendar.getProperty("PRODID").getValue(),
                is("nico2ical"));
            assertThat(calendar.getProperty("VERSION").getValue(), is("2.0"));
            assertThat(
                calendar.getProperty("X-WR-CALNAME").getValue(),
                is("ニコニコ生放送"));
            ComponentList components = calendar.getComponents();
            assertThat(components, is(notNullValue()));
            assertThat(components.size(), is(1));
            // DTSTARTが古い順にイベントが並んでいる。
            int i = 0;
            for (Object object : components) {
View Full Code Here

        assertThat(output, is(notNullValue()));
        Reader reader = null;
        try {
            reader = new StringReader(output);
            CalendarBuilder builder = new CalendarBuilder();
            Calendar calendar = builder.build(reader);
            assertThat(calendar, is(notNullValue()));
            assertThat(
                calendar.getProperty("PRODID").getValue(),
                is("nico2ical"));
            assertThat(calendar.getProperty("VERSION").getValue(), is("2.0"));
            assertThat(
                calendar.getProperty("X-WR-CALNAME").getValue(),
                is("ニコニコ生放送"));
            ComponentList components = calendar.getComponents();
            assertThat(components, is(notNullValue()));
            assertThat(components.size(), is(2));
            // DTSTARTが古い順にイベントが並んでいる。
            int i = 1;
            for (Object object : components) {
View Full Code Here

                    // 半角スペースで区切られているキーワードは分割して配列にする。
                    condition.setKeywords(Arrays.asList(keyword.split(" ")));
                }
                condition.setStartDate(startWeek.toDate());

                Calendar calendar = calendarService.getCalendar(condition);
                response.getWriter().write(calendar.toString());

                // MemcacheにiCalendarの内容をキャッシュする。
                Memcache.put(memcacheKey, calendar.toString());
            } else {
                // キャッシュがある場合はキャッシュの内容を返す。
                response.getWriter().write((String) cache);
            }
View Full Code Here

        }
        if (condition.getStartDate() == null) {
            throw new IllegalArgumentException("StartDate is null.");
        }

        Calendar calendar = new Calendar();
        calendar.getProperties().add(PROD_ID);
        calendar.getProperties().add(Version.VERSION_2_0);
        calendar.getProperties().add(new XProperty("X-WR-CALNAME", CALNAME));

        NicoliveMeta n = NicoliveMeta.get();
        NicoliveIndexMeta ni = NicoliveIndexMeta.get();

        ModelQuery<Nicolive> query =
                Datastore
                    .query(n)
                    .filter(
                        n.openTime.greaterThanOrEqual(condition.getStartDate()))
                    .sort(n.openTime.getName(), SortDirection.ASCENDING);

        if (condition.getKeywords() != null
                && 0 < condition.getKeywords().size()) {
            List<Key> keywordKeys = new LinkedList<Key>();
            for (String keyword : condition.getKeywords()) {
                List<NicoliveIndex> indexes =
                        Datastore
                            .query(ni)
                            .filter(ni.keyword.equal(keyword))
                            .asList();
                List<Key> keys = new LinkedList<Key>();
                for (NicoliveIndex nicoliveIndex : indexes) {
                    keys.add(nicoliveIndex.getNicoliveKey());
                }
                keywordKeys = merge(keys, keywordKeys);
            }
            if (0 < keywordKeys.size()) {
                query = query.filterInMemory(n.key.in(keywordKeys));
            } else {
                // キーワード検索で該当するエンティティがなければ、この後のクエリを発行する必要がないので、ここで検索を終了とする。
                return calendar;
            }
        }

        TimeZone timezone = TimeZoneLocator.get();
        List<Nicolive> nicolives = query.asList();
        for (Nicolive nicolive : nicolives) {
            PropertyList properties = new PropertyList();
            properties.add(new Summary(nicolive.getTitle()));
            String description;
            try {
                description =
                        HtmlRemoveUtil.removeHtml(nicolive
                            .getDescription()
                            .getValue());
            } catch (SAXException e1) {
                description = "";
            } catch (IOException e1) {
                description = "";
            }
            java.util.Calendar c = DateUtil.toCalendar(nicolive.getOpenTime());
            c.setTimeZone(timezone);
            properties.add(new Description(description));
            properties.add(new DtStart(new DateTime(c.getTime()), true));
            properties.add(new DtEnd(new DateTime(c.getTime()), true));
            try {
                URI uri = new URI(nicolive.getLink().getValue());
                properties.add(new Url(uri));
            } catch (URISyntaxException e) {
                LOGGER.warning(e.getMessage());
            }

            VEvent event = new VEvent(properties);
            calendar.getComponents().add(event);
        }

        return calendar;
    }
View Full Code Here

        endpoint.assertIsSatisfied();
    }

    @Test
    public void testMarshal() throws Exception {
        Calendar testCalendar = createTestCalendar();
        MockEndpoint endpoint = getMockEndpoint("mock:result");

        endpoint.expectedBodiesReceived(testCalendar.toString());

        template.sendBody("direct:marshal", testCalendar);

        endpoint.assertIsSatisfied();
    }
View Full Code Here

    }

    public static Calendar createCalendar(List<EventBean> events) {

        final String prodIdCompany = Unit.getInstitutionName().getContent();
        Calendar calendar = new Calendar();
        calendar.getProperties().add(new ProdId("-//" + prodIdCompany + "//" + PROD_ID_APPLICATION + "//PT"));
        calendar.getProperties().add(Version.VERSION_2_0);
        calendar.getProperties().add(CalScale.GREGORIAN);

        VTimeZone tz = TIMEZONE.getVTimeZone();
        calendar.getComponents().add(tz);

        for (EventBean eventBean : events) {
            calendar.getComponents().add(convertEventBean(eventBean));
        }
        return calendar;

    }
View Full Code Here

        ICalendarSyncPoint calendarSyncPoint = new ICalendarSyncPoint();

        List<EventBean> listEventBean = calendarSyncPoint.getExams(person.getUser());
        listEventBean.addAll(calendarSyncPoint.getTeachingExams(person.getUser()));

        Calendar createCalendar = CalendarFactory.createCalendar(listEventBean);

        return createCalendar.toString();
    }
View Full Code Here

TOP

Related Classes of net.fortuna.ical4j.model.Calendar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.