Package org.zanata.model

Examples of org.zanata.model.HTextFlowTarget


            HTextFlowTarget hTarget, Set<String> extensions) {
        Preconditions.checkArgument(hTarget == null,
                "This merge service only handles null HTextFlowTarget");

        boolean targetChanged = true;
        hTarget = new HTextFlowTarget(textFlow, hLocale);
        List<String> contents = Collections.nCopies(nPlurals, "");
        hTarget.setContents(contents);
        hTarget.setVersionNum(0); // incremented when content is set
        // textFlowTargetDAO.makePersistent(hTarget);
        textFlow.getTargets().put(hLocale.getId(), hTarget);
View Full Code Here


        return result.subList(startIndex, toIndex);
    }

    private boolean textFlowTargetHasWarningOrError(Long textFlowId,
            List<ValidationId> validationIds, LocaleId localeId) {
        HTextFlowTarget target =
                textFlowTargetDAO.getTextFlowTarget(textFlowId, localeId);
        if (target != null) {
            for (ValidationId validationId : validationIds) {
                Boolean value =
                        translationStateCacheImpl
                                .textFlowTargetHasWarningOrError(
                                        target.getId(), validationId);
                if (value != null && value.booleanValue()) {
                    return value.booleanValue();
                }
            }
        }
View Full Code Here

            // 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());
View Full Code Here

    @Test
    public void getMergeServiceWhenServerHasTargetAndMergeTypeIsAuto() {
        TranslationMergeServiceFactory.MergeContext mergeContext =
                new TranslationMergeServiceFactory.MergeContext(MergeType.AUTO,
                        null, null, new HTextFlowTarget(), 1);
        TranslationMergeService result = factory.getMergeService(mergeContext);

        assertThat(result, Matchers.instanceOf(TranslationMergeAuto.class));
    }
View Full Code Here

    @Test
    public void getMergeServiceWhenServerHasTargetAndMergeTypeIsImport() {
        TranslationMergeServiceFactory.MergeContext mergeContext =
                new TranslationMergeServiceFactory.MergeContext(
                        MergeType.IMPORT, null, null, new HTextFlowTarget(), 1);
        TranslationMergeService result = factory.getMergeService(mergeContext);

        assertThat(result, Matchers.instanceOf(TranslationMergeImport.class));
    }
View Full Code Here

                        .setParameter("projectIteration", projectIteration)
                        .setParameter("docId", doc.getDocId())
                        .setParameter("resId", textFlow.getResId())
                        .getSingleResult();
        // Id: 3L for Locale de
        HTextFlowTarget target = targetTextFlow.getTargets().get(3L);

        if (execution.isExpectUntranslated()) {
            if (target != null && target.getState() != ContentState.New) {
                throw new AssertionError(
                        "Expected untranslated text flow but got state "
                                + target.getState());
            }
        } else if (execution.getExpectedTranslationState() != New) {
            if (target == null) {
                throw new AssertionError("Expected state "
                        + execution.getExpectedTranslationState()
                        + ", but got untranslated.");
            } else if (execution.getExpectedTranslationState() != target
                    .getState()) {
                throw new AssertionError("Expected state "
                        + execution.getExpectedTranslationState()
                        + ", but got " + target.getState());
            }
        }

        // Contents
        if (execution.getExpectedContents() != null) {
            if (target == null) {
                throw new AssertionError("Expected contents "
                        + Arrays.toString(execution.getExpectedContents())
                        + ", but got untranslated.");
            } else if (!Arrays.equals(execution.getExpectedContents(), target
                    .getContents().toArray())) {
                throw new AssertionError("Expected contents "
                        + Arrays.toString(execution.getExpectedContents())
                        + ", but got "
                        + Arrays.toString(target.getContents().toArray()));
            }
        }
    }
View Full Code Here

        return new TransMemoryQuery.Condition(isCheck, value);
    }

    private static HTextFlowTarget addHTextFlowTarget(HLocale hLocale,
            HTextFlow hTextFlow, String username) {
        HTextFlowTarget hTextFlowTarget =
                new HTextFlowTarget(hTextFlow, hLocale);
        HPerson lastModifiedBy = new HPerson();
        HAccount account = new HAccount();
        account.setUsername(username);
        lastModifiedBy.setAccount(account);
        hTextFlowTarget.setLastModifiedBy(lastModifiedBy);
        hTextFlowTarget.setLastChanged(new Date());
        return hTextFlowTarget;
    }
View Full Code Here

                            "testResId:" + i)
                            .withSourceContent("source content").build();

            if (insertTargets) {
                for (int x = 0; x < localeList.size(); x++) {
                    HTextFlowTarget tft =
                            new HTextFlowTarget(tf, localeList.get(x));
                    tft.setContents(Lists.newArrayList("test data"));
                    tf.getTargets().put(localeList.get(x).getId(), tft);
                }
            }
            doc.getAllTextFlows().put(tf.getResId(), tf);
        }
View Full Code Here

                assertThat(newTf.getTargets().size()).isEqualTo(
                        existingTf.getTargets().size());
                for (Map.Entry<Long, HTextFlowTarget> targetSet : existingTf
                        .getTargets().entrySet()) {

                    HTextFlowTarget existingTarget = targetSet.getValue();
                    HTextFlowTarget newTarget = newTf
                            .getTargets().get(targetSet.getKey());

                    assertTextFlowTarget(existingTarget, newTarget, newTf);

                    for (int x = 0; x < existingTarget.getReviewComments()
                            .size(); x++) {
                        HTextFlowTargetReviewComment expectedComment =
                                existingTarget.getReviewComments().get(x);
                        HTextFlowTargetReviewComment newComment =
                                newTarget.getReviewComments().get(x);

                        assertTextFlowTargetHistoryAndReview(expectedComment,
                                newComment, existingTarget, newTarget);
                    }
                }
View Full Code Here

    }

    @Test
    public void testCopyTextFlowTarget() throws Exception {
        HTextFlow dummyTextFlow = getDummyTextFlow();
        HTextFlowTarget existingTarget = textFlowTargetDAO.findById(3L, false);

        HTextFlowTarget newTarget =
                service.copyTextFlowTarget(dummyTextFlow, existingTarget);

        assertTextFlowTarget(existingTarget, newTarget, dummyTextFlow);
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.HTextFlowTarget

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.