Package org.zanata.rest.dto.stats

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


        if (doc == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        ContainerTranslationStatistics docStats =
                getDocStatistics(doc.getId(), new LocaleId(localeId));

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

        Type genericType = new GenericType<List<TranslationStatistics>>() {
        }.getGenericType();
        Object entity =
                new GenericEntity<List<TranslationStatistics>>(
View Full Code Here


    }

    //TODO: need to merge with StatisticsServiceImpl.getDocStatistics
    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

        }
        long newWordCount =
                StatisticsUtil.calculateUntranslated(totalWordCount, wordCount);
        wordCount.set(ContentState.New, (int) newWordCount);

        ContainerTranslationStatistics result =
                new ContainerTranslationStatistics();
        result.addStats(new TranslationStatistics(unitCount, localeId
                .toString()));
        result.addStats(new TranslationStatistics(wordCount, localeId
                .toString()));

        return result;
    }
View Full Code Here

                            new Long(stat.getTotal()), stat));
        }

        // Merge into a single Stats object
        for (String locale : transUnitCountMap.keySet()) {
            ContainerTranslationStatistics newStats =
                    new ContainerTranslationStatistics();
            newStats.addStats(new TranslationStatistics(transUnitCountMap
                    .get(locale), locale));
            newStats.addStats(new TranslationStatistics(transUnitWordsMap
                    .get(locale), locale));

            if (newStats.getStats(locale, StatUnit.MESSAGE) != null
                    && newStats.getStats(locale, StatUnit.WORD) != null) {
                returnStats.put(new LocaleId(locale), newStats);
            }
        }

        return returnStats;
View Full Code Here

        localeId =
                userWorkspaceContext.getWorkspaceContext().getWorkspaceId()
                        .getLocaleId();

        projectStats = new ContainerTranslationStatistics();
        resetProjectStats();

        display.setListener(this);
    }
View Full Code Here

    @Override
    public void onProjectStatsUpdated(RefreshProjectStatsEvent event) {
        resetProjectStats();

        for (DocumentNode documentNode : event.getDocumentNodes()) {
            ContainerTranslationStatistics statsContainer =
                    documentNode.getDocInfo().getStats();

            TranslationStatistics msgStats =
                    statsContainer.getStats(localeId.getId(), StatUnit.MESSAGE);

            if (msgStats != null) {
                projectStats.getStats(localeId.getId(), StatUnit.MESSAGE).add(
                        msgStats);
            }

            TranslationStatistics wordStats =
                    statsContainer.getStats(localeId.getId(), StatUnit.WORD);

            if (wordStats != null) {
                projectStats.getStats(localeId.getId(), StatUnit.WORD).add(
                        wordStats);
            }
View Full Code Here

    @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

                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

                        .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

        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

TOP

Related Classes of org.zanata.rest.dto.stats.ContainerTranslationStatistics

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.