Package org.ryu22e.nico2cal.rome.module

Examples of org.ryu22e.nico2cal.rome.module.NicoliveModule


     * @return テスト用のRSSフィード
     */
    @SuppressWarnings("unchecked")
    private SyndFeed createFeed() {
        SyndFeed feed = new SyndFeedImpl();
        feed.setModules(Arrays.asList(new NicoliveModule()));

        feed.setTitle("テストRSS");

        DateTime datetime = new DateTime(2011, 1, 1, 0, 0, 0, 0);
        DateTimeFormatter df = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        List<SyndEntry> entries = new LinkedList<SyndEntry>();
        for (int i = 0; i < 9; i++) {
            SyndEntry entry = new SyndEntryImpl();
            entry.setTitle("テスト" + i);
            SyndContent description = new SyndContentImpl();
            description.setValue("テスト説明" + i);
            entry.setDescription(description);
            entry.setLink("http://ryu22e.org/" + i);

            NicoliveModule module = new NicoliveModule();
            module.setOpenTime(datetime.minusDays(i).toString(df));
            module.setStartTime(datetime
                .minusDays(i)
                .plusMinutes(10)
                .toString(df));
            module.setType("official");
            entry.getModules().add(module);

            entries.add(entry);
        }
        // NicoliveModuleなしのデータも含める。
View Full Code Here


    /*
     * (non-Javadoc) {@inheritDoc}
     */
    public Module parse(Element element) {
        NicoliveModule module = new NicoliveModule();
        Element openTime = element.getChild("open_time", NS);
        module.setOpenTime(openTime.getText());
        Element startTime = element.getChild("start_time", NS);
        module.setStartTime(startTime.getText());
        Element type = element.getChild("type", NS);
        module.setType(type.getText());
        return module;
    }
View Full Code Here

            assertThat(entry.getModules(), is(notNullValue()));
            assertThat(entry.getModules().size(), is(not(0)));
            assertThat(
                entry.getModules().get(0),
                is(instanceOf(NicoliveModule.class)));
            NicoliveModule module = (NicoliveModule) entry.getModules().get(0);
            assertThat(module.getOpenTime(), is(notNullValue()));
            assertThat(module.getStartTime(), is(notNullValue()));
            assertThat(module.getType(), is(notNullValue()));
        }
    }
View Full Code Here

        List<Nicolive> nicolives = new LinkedList<Nicolive>();
        @SuppressWarnings("unchecked")
        List<SyndEntry> entries = (List<SyndEntry>) feed.getEntries();
        for (SyndEntry entry : entries) {
            // RSSフィードの「nicolive:***」部分を取得する。
            NicoliveModule module = null;
            @SuppressWarnings("unchecked")
            List<Object> modules = entry.getModules();
            for (Object o : modules) {
                if (o instanceof NicoliveModule) {
                    module = (NicoliveModule) o;
                    break;
                }
            }

            // 「nicolive:***」が取得できないエントリーは登録しない。
            if (module != null) {
                // 重複するリンクを持つエンティティがある場合は更新対象から外す。
                Nicolive nicolive =
                        Datastore
                            .query(n)
                            .filter(n.link.equal(new Link(entry.getLink())))
                            .asSingle();
                if (nicolive == null) {
                    nicolive = new Nicolive();
                    nicolive.setTitle(entry.getTitle());
                    nicolive.setDescription(new Text(entry
                        .getDescription()
                        .getValue()));
                    try {
                        Date openTime =
                                DateUtil.toDate(df.parse(module.getOpenTime()));
                        nicolive.setOpenTime(openTime);
                        Date startTime =
                                DateUtil
                                    .toDate(df.parse(module.getStartTime()));
                        nicolive.setStartTime(startTime);
                    } catch (ParseException e) {
                        LOGGER.log(Level.WARNING, e.getMessage());
                        continue;
                    }

                    nicolive.setType(module.getType());
                    nicolive.setLink(new Link(entry.getLink()));

                    nicolives.add(nicolive);
                }
            }
View Full Code Here

TOP

Related Classes of org.ryu22e.nico2cal.rome.module.NicoliveModule

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.