Package org.zanata.rest.dto

Examples of org.zanata.rest.dto.GlossaryEntry


    }

    public void transferEntriesResource(List<HGlossaryEntry> hGlosssaryEntries,
            Glossary glossary) {
        for (HGlossaryEntry hGlossaryEntry : hGlosssaryEntries) {
            GlossaryEntry glossaryEntry = new GlossaryEntry();
            glossaryEntry.setSourcereference(hGlossaryEntry.getSourceRef());
            glossaryEntry.setSrcLang(hGlossaryEntry.getSrcLocale()
                    .getLocaleId());

            for (HGlossaryTerm hGlossaryTerm : hGlossaryEntry
                    .getGlossaryTerms().values()) {
                GlossaryTerm glossaryTerm = new GlossaryTerm();
                glossaryTerm.setContent(hGlossaryTerm.getContent());
                glossaryTerm.setLocale(hGlossaryTerm.getLocale().getLocaleId());

                for (HTermComment hTermComment : hGlossaryTerm.getComments()) {
                    glossaryTerm.getComments().add(hTermComment.getComment());
                }
                glossaryEntry.getGlossaryTerms().add(glossaryTerm);
            }
            glossary.getGlossaryEntries().add(glossaryEntry);
        }
    }
View Full Code Here


    public static void transferEntriesLocaleResource(
            List<HGlossaryEntry> hGlosssaryEntries, Glossary glossary,
            LocaleId locale) {
        for (HGlossaryEntry hGlossaryEntry : hGlosssaryEntries) {
            GlossaryEntry glossaryEntry = new GlossaryEntry();
            glossaryEntry.setSrcLang(hGlossaryEntry.getSrcLocale()
                    .getLocaleId());
            glossaryEntry.setSourcereference(hGlossaryEntry.getSourceRef());
            for (HGlossaryTerm hGlossaryTerm : hGlossaryEntry
                    .getGlossaryTerms().values()) {
                if (hGlossaryTerm.getLocale().getLocaleId().equals(locale)) {
                    GlossaryTerm glossaryTerm = new GlossaryTerm();
                    glossaryTerm.setContent(hGlossaryTerm.getContent());
                    glossaryTerm.setLocale(hGlossaryTerm.getLocale()
                            .getLocaleId());

                    for (HTermComment hTermComment : hGlossaryTerm
                            .getComments()) {
                        glossaryTerm.getComments().add(
                                hTermComment.getComment());
                    }
                    glossaryEntry.getGlossaryTerms().add(glossaryTerm);
                }
            }
            glossary.getGlossaryEntries().add(glossaryEntry);
        }
    }
View Full Code Here

    }

    @Test
    public void putGlossary() {
        Glossary glossary = new Glossary();
        GlossaryEntry glossaryEntry1 = new GlossaryEntry();
        glossaryEntry1.setSrcLang(LocaleId.EN_US);
        glossaryEntry1.setSourcereference("TEST SOURCE REF DATA");

        GlossaryTerm glossaryTerm1 = new GlossaryTerm();
        glossaryTerm1.setLocale(LocaleId.EN_US);
        glossaryTerm1.setContent("TEST DATA 1 EN_US");
        glossaryTerm1.getComments().add("COMMENT 1");

        GlossaryTerm glossaryTerm2 = new GlossaryTerm();
        glossaryTerm2.setLocale(LocaleId.DE);
        glossaryTerm2.setContent("TEST DATA 2 DE");
        glossaryTerm2.getComments().add("COMMENT 2");

        glossaryEntry1.getGlossaryTerms().add(glossaryTerm1);
        glossaryEntry1.getGlossaryTerms().add(glossaryTerm2);

        GlossaryEntry glossaryEntry2 = new GlossaryEntry();
        glossaryEntry2.setSrcLang(LocaleId.EN_US);
        glossaryEntry2.setSourcereference("TEST SOURCE REF DATA2");

        GlossaryTerm glossaryTerm3 = new GlossaryTerm();
        glossaryTerm3.setLocale(LocaleId.EN_US);
        glossaryTerm3.setContent("TEST DATA 3 EN_US");
        glossaryTerm3.getComments().add("COMMENT 3");

        GlossaryTerm glossaryTerm4 = new GlossaryTerm();
        glossaryTerm4.setLocale(LocaleId.DE);
        glossaryTerm4.setContent("TEST DATA 4 DE");
        glossaryTerm4.getComments().add("COMMENT 4");

        glossaryEntry2.getGlossaryTerms().add(glossaryTerm3);
        glossaryEntry2.getGlossaryTerms().add(glossaryTerm4);

        glossary.getGlossaryEntries().add(glossaryEntry1);
        glossary.getGlossaryEntries().add(glossaryEntry2);

        ClientResponse<String> response = glossaryService.put(glossary);
View Full Code Here

    }

    @Test
    public void testPutGlossaries() {
        Glossary glossary = new Glossary();
        GlossaryEntry glossaryEntry1 = new GlossaryEntry();
        glossaryEntry1.setSrcLang(LocaleId.EN_US);
        glossaryEntry1.setSourcereference("TEST SOURCE REF DATA");

        GlossaryTerm glossaryTerm1 = new GlossaryTerm();
        glossaryTerm1.setLocale(LocaleId.EN_US);
        glossaryTerm1.setContent("test data content 1 (source lang)");
        glossaryTerm1.getComments().add("COMMENT 1");

        glossaryEntry1.getGlossaryTerms().add(glossaryTerm1);

        glossary.getGlossaryEntries().add(glossaryEntry1);

        ClientResponse<String> response = glossaryService.put(glossary);
View Full Code Here

                Glossary glossary = jaxbUnmarshal(response, Glossary.class);
                assertThat(glossary.getGlossaryEntries().size(), is(1));

                // Glossary Entry
                GlossaryEntry entry = glossary.getGlossaryEntries().get(0);
                assertThat(entry.getSourcereference(), is("source reference"));
                assertThat(entry.getSrcLang(), is(LocaleId.EN_US));
                assertThat(entry.getGlossaryTerms().size(), is(3));

                // Expected / Actual glossary terms
                Set<GlossaryTerm> actualTerms =
                        new HashSet<GlossaryTerm>(entry.getGlossaryTerms());

                Set<GlossaryTerm> expectedTerms = new HashSet<GlossaryTerm>();
                GlossaryTerm expTerm = new GlossaryTerm();
                expTerm.setLocale(LocaleId.EN_US);
                expTerm.setContent("test data content 1 (source lang)");
View Full Code Here

                Glossary glossary = jsonUnmarshal(response, Glossary.class);
                assertThat(glossary.getGlossaryEntries().size(), is(1));

                // Glossary Entry
                GlossaryEntry entry = glossary.getGlossaryEntries().get(0);
                assertThat(entry.getSourcereference(), is("source reference"));
                assertThat(entry.getSrcLang(), is(LocaleId.EN_US));
                assertThat(entry.getGlossaryTerms().size(), is(3));

                // Expected / Actual glossary terms
                Set<GlossaryTerm> actualTerms =
                        new HashSet<GlossaryTerm>(entry.getGlossaryTerms());

                Set<GlossaryTerm> expectedTerms = new HashSet<GlossaryTerm>();
                GlossaryTerm expTerm = new GlossaryTerm();
                expTerm.setLocale(LocaleId.EN_US);
                expTerm.setContent("test data content 1 (source lang)");
View Full Code Here

        }.run();
    }

    private Glossary getSampleGlossary() {
        Glossary glossary = new Glossary();
        GlossaryEntry glossaryEntry1 = new GlossaryEntry();
        glossaryEntry1.setSrcLang(LocaleId.EN_US);
        glossaryEntry1.setSourcereference("TEST SOURCE REF DATA");

        GlossaryTerm glossaryTerm1 = new GlossaryTerm();
        glossaryTerm1.setLocale(LocaleId.EN_US);
        glossaryTerm1.setContent("TEST DATA 1 EN_US");
        glossaryTerm1.getComments().add("COMMENT 1");

        GlossaryTerm glossaryTerm2 = new GlossaryTerm();
        glossaryTerm2.setLocale(LocaleId.DE);
        glossaryTerm2.setContent("TEST DATA 2 DE");
        glossaryTerm2.getComments().add("COMMENT 2");

        glossaryEntry1.getGlossaryTerms().add(glossaryTerm1);
        glossaryEntry1.getGlossaryTerms().add(glossaryTerm2);

        GlossaryEntry glossaryEntry2 = new GlossaryEntry();
        glossaryEntry2.setSrcLang(LocaleId.EN_US);
        glossaryEntry2.setSourcereference("TEST SOURCE REF DATA2");

        GlossaryTerm glossaryTerm3 = new GlossaryTerm();
        glossaryTerm3.setLocale(LocaleId.EN_US);
        glossaryTerm3.setContent("TEST DATA 3 EN_US");
        glossaryTerm3.getComments().add("COMMENT 3");

        GlossaryTerm glossaryTerm4 = new GlossaryTerm();
        glossaryTerm4.setLocale(LocaleId.DE);
        glossaryTerm4.setContent("TEST DATA 4 DE");
        glossaryTerm4.getComments().add("COMMENT 4");

        glossaryEntry2.getGlossaryTerms().add(glossaryTerm3);
        glossaryEntry2.getGlossaryTerms().add(glossaryTerm4);

        glossary.getGlossaryEntries().add(glossaryEntry1);
        glossary.getGlossaryEntries().add(glossaryEntry2);

        return glossary;
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.GlossaryEntry

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.