Package org.zanata.ui.model.statistic

Examples of org.zanata.ui.model.statistic.WordStatistic


                o2 = temp;
            }

            // Need to get statistic for comparison
            if (!selectedSortOption.equals(SortingType.SortOption.ALPHABETICAL)) {
                WordStatistic wordStatistic1;
                WordStatistic wordStatistic2;

                if (selectedVersionId == null) {
                    wordStatistic1 = getStatisticsForLocale(o1.getLocaleId());
                    wordStatistic2 = getStatisticsForLocale(o2.getLocaleId());
                } else {
                    wordStatistic1 =
                            statisticMap.get(new VersionLocaleKey(
                                    selectedVersionId, o1.getLocaleId()));
                    wordStatistic2 =
                            statisticMap.get(new VersionLocaleKey(
                                    selectedVersionId, o2.getLocaleId()));
                }
                switch (selectedSortOption) {
                case PERCENTAGE:
                    return Double.compare(
                            wordStatistic1.getPercentTranslated(),
                            wordStatistic2.getPercentTranslated());
                case HOURS:
                    return Double.compare(wordStatistic1.getRemainingHours(),
                            wordStatistic2.getRemainingHours());
                case WORDS:
                    return Double.compare(wordStatistic1.getUntranslated(),
                            wordStatistic2.getUntranslated());
                }
            } else {
                return o1.retrieveDisplayName().compareTo(
                        o2.retrieveDisplayName());
            }
View Full Code Here


                o2 = temp;
            }

            // Need to get statistic for comparison
            if (!selectedSortOption.equals(SortingType.SortOption.ALPHABETICAL)) {
                WordStatistic wordStatistic1;
                WordStatistic wordStatistic2;
                if (selectedLocaleId != null) {
                    wordStatistic1 =
                            statisticMap.get(new VersionLocaleKey(o1.getId(),
                                    selectedLocaleId));
                    wordStatistic2 =
                            statisticMap.get(new VersionLocaleKey(o2.getId(),
                                    selectedLocaleId));
                } else {
                    wordStatistic1 = getStatisticForProject(o1.getId());
                    wordStatistic2 = getStatisticForProject(o2.getId());
                }

                switch (selectedSortOption) {
                case PERCENTAGE:
                    return Double.compare(
                            wordStatistic1.getPercentTranslated(),
                            wordStatistic2.getPercentTranslated());
                case HOURS:
                    return Double.compare(wordStatistic1.getRemainingHours(),
                            wordStatistic2.getRemainingHours());
                case WORDS:
                    return Double.compare(wordStatistic1.getUntranslated(),
                            wordStatistic2.getUntranslated());
                }
            } else {
                return o1.getProject().getName().toLowerCase()
                        .compareTo(o2.getProject().getName().toLowerCase());
            }
View Full Code Here

    public WordStatistic getWordStatistics(Long iterationId, LocaleId localeId) {

        List<StatusCount> stats = getWordStatusCount(iterationId, localeId);

        WordStatistic wordStatistic = new WordStatistic();

        for (StatusCount count : stats) {
            wordStatistic.set(count.status, count.count.intValue());
        }

        Long totalCount = getTotalWordCountForIteration(iterationId);

        wordStatistic.set(
                ContentState.New,
                totalCount.intValue()
                        - (wordStatistic.getApproved()
                                + wordStatistic.getTranslated()
                                + wordStatistic.getNeedReview() + wordStatistic
                                    .getRejected()));
        return wordStatistic;
    }
View Full Code Here

    @Override
    public void textFlowStateUpdated(TextFlowTargetStateEvent event) {
        VersionLocaleKey key =
                new VersionLocaleKey(event.getProjectIterationId(),
                        event.getLocaleId());
        WordStatistic stats = versionStatisticCache.get(key);
        if (stats != null) {
            TextFlowDAO textFlowDAO = serviceLocator.getInstance(TextFlowDAO.class);
            HTextFlow textFlow = textFlowDAO.findById(event.getTextFlowId());

            stats.decrement(event.getPreviousState(),
                    textFlow.getWordCount().intValue());
            stats.increment(event.getNewState(),
                    textFlow.getWordCount().intValue());
            versionStatisticCache.put(key, stats);
        }
    }
View Full Code Here

        }

        @Override
        public WordStatistic load(VersionLocaleKey key) throws Exception {

            WordStatistic wordStatistic =
                    getProjectIterationDAO().getWordStatistics(
                        key.getProjectIterationId(), key.getLocaleId());

            return wordStatistic;
        }
View Full Code Here

    }

    // Fire asynchronous event
    public void publishAsyncEvent(TextFlowTargetStateEvent event) {
        if (Events.exists()) {
            WordStatistic stats =
                    translationStateCacheImpl.getDocumentStatistics(
                            event.getDocumentId(), event.getLocaleId());

            int wordCount = textFlowDAO.getWordCount(event.getTextFlowId());

            WordStatistic oldStats = StatisticsUtil.copyWordStatistic(stats);
            oldStats.decrement(event.getNewState(), wordCount);
            oldStats.increment(event.getPreviousState(), wordCount);

            Events.instance().raiseAsynchronousEvent(
                    DocumentStatisticUpdatedEvent.EVENT_NAME,
                    new DocumentStatisticUpdatedEvent(oldStats, stats,
                            event.getProjectIterationId(),
View Full Code Here

            String groupSlug, LocaleId localeId) {

        Map<VersionLocaleKey, WordStatistic> statisticMap = Maps.newHashMap();
        for (HProjectIteration version : getNonObsoleteProjectIterationsBySlug(groupSlug)) {
            if (version.getStatus() != EntityStatus.OBSOLETE) {
                WordStatistic statistic =
                        versionStateCacheImpl.getVersionStatistics(
                                version.getId(), localeId);
                statistic.setRemainingHours(StatisticsUtil
                        .getRemainingHours(statistic));

                statisticMap.put(
                        new VersionLocaleKey(version.getId(), localeId),
                        statistic);
View Full Code Here

    @Test
    public void documentMilestoneEventTranslatedTest() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);

        WordStatistic stats = new WordStatistic(0, 0, 0, 10, 0);
        runDocumentStatisticUpdatedTest(spyService, ContentState.New,
                ContentState.Translated, stats);

        DocumentMilestoneEvent milestoneEvent =
                new DocumentMilestoneEvent(projectSlug, versionSlug,
View Full Code Here

    @Test
    public void documentMilestoneEventTranslatedNot100Test() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);

        WordStatistic stats = new WordStatistic(0, 1, 0, 9, 0);
        runDocumentStatisticUpdatedTest(spyService, ContentState.New,
                ContentState.Translated, stats);

        DocumentMilestoneEvent milestoneEvent =
                new DocumentMilestoneEvent(projectSlug, versionSlug,
View Full Code Here

    @Test
    public void documentMilestoneEventApprovedTest() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);

        WordStatistic stats = new WordStatistic(10, 0, 0, 0, 0);
        runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
                ContentState.Approved, stats);

        DocumentMilestoneEvent milestoneEvent =
                new DocumentMilestoneEvent(projectSlug,
View Full Code Here

TOP

Related Classes of org.zanata.ui.model.statistic.WordStatistic

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.