Examples of ContainerTranslationStatistics


Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

    @Override
    public void onTransUnitUpdated(TransUnitUpdatedEvent event) {
        TransUnitUpdateInfo updateInfo = event.getUpdateInfo();
        // update stats for containing document
        DocumentInfo updatedDoc = getDocumentInfo(updateInfo.getDocumentId());
        ContainerTranslationStatistics currentStats = updatedDoc.getStats();
        if (currentStats != null) {
            adjustStats(currentStats, updateInfo);
            updatedDoc.setStats(currentStats);

            updateLastTranslatedInfo(updatedDoc, event.getUpdateInfo()
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

                new HashMap<DocumentId, ContainerTranslationStatistics>();
        Map<DocumentId, AuditInfo> lastTranslatedMap =
                new HashMap<DocumentId, AuditInfo>();

        for (DocumentId documentId : action.getDocIds()) {
            ContainerTranslationStatistics stats =
                    statisticsServiceImpl.getDocStatistics(documentId.getId(),
                            action.getWorkspaceId().getLocaleId());
            statsMap.put(documentId, stats);

            DocumentStatus docStat =
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

                        .getId());
        Map<String, TransUnitWords> wordIterationStats =
                projectIterationDAO
                        .getAllWordStatsStatistics(iteration.getId());

        ContainerTranslationStatistics iterationStats =
                new ContainerTranslationStatistics();
        iterationStats.setId(iterationSlug);
        iterationStats.addRef(new Link(URI.create(zPathService
                .generatePathForProjectIteration(iteration)), "statSource",
                "PROJ_ITER"));
        long iterationTotalMssgs =
                projectIterationDAO
                        .getTotalMessageCountForIteration(iteration.getId());
        long iterationTotalWords =
                projectIterationDAO.getTotalWordCountForIteration(iteration
                        .getId());

        for (LocaleId locId : localeIds) {
            // trans unit level stats
            TransUnitCount count = transUnitIterationStats.get(locId.getId());
            // Stats might not return anything if nothing is translated
            if (count == null) {
                count = new TransUnitCount(0, 0, (int) iterationTotalMssgs);
            }

            HTextFlowTarget target =
                    localeServiceImpl.getLastTranslated(projectSlug,
                            iterationSlug, locId);

            String lastModifiedBy = "";
            Date lastModifiedDate = null;

            if (target != null) {
                lastModifiedDate = target.getLastChanged();
                if (target.getLastModifiedBy() != null) {
                    lastModifiedBy =
                            target.getLastModifiedBy().getAccount()
                                    .getUsername();
                }
            }

            TransUnitWords wordCount = wordIterationStats.get(locId.getId());
            if (wordCount == null) {
                wordCount = new TransUnitWords(0, 0, (int) iterationTotalWords);
            }

            TranslationStatistics transUnitStats =
                    getMessageStats(count, locId, lastModifiedDate,
                            lastModifiedBy);
            transUnitStats.setRemainingHours(StatisticsUtil
                    .getRemainingHours(wordCount));
            iterationStats.addStats(transUnitStats);

            // word level stats
            if (includeWordStats) {
                TranslationStatistics wordsStats =
                        getWordsStats(wordCount, locId, lastModifiedDate,
                                lastModifiedBy);
                wordsStats.setRemainingHours(StatisticsUtil
                        .getRemainingHours(wordCount));
                iterationStats.addStats(wordsStats);
            }
        }

        // TODO Do in a single query
        if (includeDetails) {
            for (String docId : iteration.getDocuments().keySet()) {
                iterationStats.addDetailedStats(this.getStatistics(projectSlug,
                        iterationSlug, docId, includeWordStats, locales));
            }
        }

        return iterationStats;
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

        if (document == null) {
            throw new NoSuchEntityException(projectSlug + "/" + iterationSlug
                    + "/" + docId);
        }

        ContainerTranslationStatistics docStatistics =
                new ContainerTranslationStatistics();
        docStatistics.setId(docId);
        docStatistics.addRef(new Link(URI.create(zPathService
                .generatePathForDocument(document)), "statSource", "DOC"));

        for (LocaleId localeId : localeIds) {
            ContainerTranslationStatistics docStats =
                    getDocStatistics(document.getId(), localeId);

            DocumentStatus docStatus =
                    translationStateCacheImpl.getDocumentStatus(
                            document.getId(), localeId);

            TranslationStatistics docWordStatistic =
                    docStats.getStats(localeId.getId(), StatUnit.WORD);
            TranslationStatistics docMsgStatistic =
                    docStats.getStats(localeId.getId(), StatUnit.MESSAGE);

            docMsgStatistic
                    .setLastTranslatedBy(docStatus.getLastTranslatedBy());
            docMsgStatistic.setLastTranslatedDate(docStatus
                    .getLastTranslatedDate());
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

        return result.toString();
    }

    public ContainerTranslationStatistics getDocStatistics(Long documentId,
            LocaleId localeId) {
        ContainerTranslationStatistics result =
                documentDAO.getStatistics(documentId, localeId);

        TranslationStatistics wordStatistics =
                result.getStats(localeId.getId(), StatUnit.WORD);
        wordStatistics.setRemainingHours(StatisticsUtil
                .getRemainingHours(wordStatistics));

        TranslationStatistics msgStatistics =
                result.getStats(localeId.getId(), StatUnit.MESSAGE);
        msgStatistics.setRemainingHours(StatisticsUtil
                .getRemainingHours(wordStatistics));

        return result;
    }
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

        }
    }

    @Test
    public void getWordIterationStatisticsForAllLocales() {
        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0", false,
                        true, new String[] {});

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("1.0");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No detailed stats
        assertThat(stats.getDetailedStats()).isNull();

        // Word level AND message level stats
        int wordLevel = 0;
        int mssgLevel = 0;
        for (TranslationStatistics transStat : stats.getStats()) {
            if (transStat.getUnit() == TranslationStatistics.StatUnit.MESSAGE) {
                mssgLevel++;
            } else if (transStat.getUnit() == TranslationStatistics.StatUnit.WORD) {
                wordLevel++;
            }
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

    @Test
    public void getDetailedIterationStatisticsForSpecificLocales() {
        String[] locales = new String[] { "en-US", "es", "as" };

        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0", true,
                        true, locales);

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("1.0");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // Detailed Stats
        assertThat(stats.getDetailedStats().size()).isGreaterThan(0);

        // Results returned only for specified locales
        for (TranslationStatistics transStat : stats.getStats()) {
            assertThat(Arrays.asList(locales)).contains(transStat.getLocale());
            // make sure counts are sane
            assertThat(
                    transStat.getDraft() + transStat.getApproved()
                            + transStat.getTranslatedOnly()
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

        }
    }

    @Test
    public void getSimpleDocumentStatisticsForAllLocales() {
        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0",
                        "my/path/document.txt", false, new String[] {});

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("my/path/document.txt");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No detailed stats
        assertThat(stats.getDetailedStats()).isNull();

        assertThat(stats.getStats().get(0).getUnit()).isEqualTo(
                TranslationStatistics.StatUnit.MESSAGE);

        for (TranslationStatistics transStat : stats.getStats()) {
            // Check that there are no word level stats
            assertThat(transStat.getUnit()).isNotEqualTo(
                    TranslationStatistics.StatUnit.WORD);

            // make sure counts are sane
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

    @Test
    public void getDetailedDocumentStatisticsForSpecificLocales() {
        String[] locales = new String[] { "en-US", "es", "as" };

        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0",
                        "my/path/document.txt", true, locales);

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("my/path/document.txt");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No Detailed Stats
        assertThat(stats.getDetailedStats()).isNull();

        // Results returned only for specified locales
        for (TranslationStatistics transStat : stats.getStats()) {
            assertThat(Arrays.asList(locales)).contains(transStat.getLocale());
            // make sure counts are sane
            assertThat(
                    transStat.getDraft() + transStat.getApproved()
                            + transStat.getTranslatedOnly()
View Full Code Here

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics

        TranslationStatistics msgStats =
                new TranslationStatistics(count, LocaleId.EN_US.toString());
        TranslationStatistics wordStats =
                new TranslationStatistics(words, LocaleId.EN_US.toString());

        ContainerTranslationStatistics result =
                new ContainerTranslationStatistics();
        result.addStats(msgStats);
        result.addStats(wordStats);
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.