Package org.zanata.model

Examples of org.zanata.model.HTextFlow


        // an action with threshold 80% and trans unit id
        final long transUnitId = 1L;
        TransMemoryMerge action = prepareAction(80, transUnitId);

        // A Text Flow to be translated
        HTextFlow hTextFlow =
                TestFixture.makeHTextFlow(transUnitId, sourceLocale,
                        targetLocale, ContentState.New, docId, versionSlug,
                        projectSlug);

        // A matching imported Translation Unit
        TransMemoryUnit tuResultSource =
                TestFixture.makeTransMemoryUnit(10L, targetLocale);

        // and an associated result item
        TransMemoryResultItem mostSimilarTM =
                importedTmResult(tuResultSource.getId(), 100);

        Optional<TransMemoryResultItem> match = Optional.of(mostSimilarTM);

        // A Translation memory query
        TransMemoryQuery tmQuery =
                prepareTMQuery(hTextFlow.getContents(), FUZZY_PLURAL, null,
                        hTextFlow.getResId());

        // Expectations:
        when(localeService.getByLocaleId(action.getWorkspaceId().getLocaleId()))
                .thenReturn(targetLocale);
View Full Code Here


        UpdateTransUnitHandler transUnitHandler =
                seamAutowire.autowire(UpdateTransUnitHandler.class);

        // Translation unit id to update
        HTextFlow hTextFlow =
                (HTextFlow) getSession()
                        .createQuery(
                                "select tf from HTextFlow tf where tf.contentHash = ? and "
                                        + "tf.document.docId = ? and "
                                        + "tf.document.projectIteration.slug = ? and "
                                        + "tf.document.projectIteration.project.slug = ?")
                        .setString(0, HashUtil.generateHash(textFlowContent))
                        .setString(1, docId).setString(2, iterationSlug)
                        .setString(3, projectSlug).uniqueResult();
        Long textFlowId = hTextFlow.getId();
        int versionNum = 0; // no previous translation

        // Translate using webtrans
        UpdateType updateType = UpdateType.WebEditorSave;
        UpdateTransUnit action =
View Full Code Here

        String iterSlug = "iterslug";
        boolean requireReview = true;
        HProjectIteration iter = createIter(iterSlug, proj, requireReview);

        List<HTextFlow> textFlows = Arrays.asList(new HTextFlow());
        HDocument doc = createDoc(iter, textFlows);

        when(documentDAO.findById(doc.getId())).thenReturn(doc);

        HLocale de = new HLocale(LocaleId.DE);
View Full Code Here

    public void mergeChangedTextFlow() {
        // set up HDocument with a text flow
        HDocument to = new HDocument();
        int originalTFRevision = 1;
        to.setRevision(originalTFRevision);
        HTextFlow originalTF = new HTextFlow(to, "id", "original text");
        originalTF.setRevision(originalTFRevision);

        // target locales that will have new, fuzzy and approved targets
        HLocale newLoc, fuzzyLoc, apprLoc;
        newLoc = new HLocale(LocaleId.DE);
        fuzzyLoc = new HLocale(LocaleId.FR);
        apprLoc = new HLocale(LocaleId.ES);
        // Target Locale ids
        Long newLocId = 1L, fuzzyLocId = 2L, apprLocId = 3L;

        HTextFlowTarget newTarg, fuzzyTarg, apprTarg;
        newTarg = new HTextFlowTarget(originalTF, newLoc);
        fuzzyTarg = new HTextFlowTarget(originalTF, fuzzyLoc);
        apprTarg = new HTextFlowTarget(originalTF, apprLoc);

        int newTargVersionBefore = 1;
        int fuzzyTargVersionBefore = 1;
        int apprTargVersionBefore = 1;

        newTarg.setVersionNum(newTargVersionBefore);
        fuzzyTarg.setVersionNum(fuzzyTargVersionBefore);
        apprTarg.setVersionNum(apprTargVersionBefore);

        newTarg.setState(ContentState.New);
        fuzzyTarg.setState(ContentState.NeedReview);
        apprTarg.setState(ContentState.Approved);

        originalTF.getTargets().put(newLocId, newTarg);
        originalTF.getTargets().put(fuzzyLocId, fuzzyTarg);
        originalTF.getTargets().put(apprLocId, apprTarg);

        to.getAllTextFlows().put("id", originalTF);

        // set up a textflow with the same id and different content
        TextFlow changedTF =
                new TextFlow(originalTF.getResId(), LocaleId.EN, "changed text");
        List<TextFlow> from = new ArrayList<TextFlow>();
        from.add(changedTF);

        int newTFRevision = 2;
View Full Code Here

    private void verifyIdAndContentStateMatches(List<HTextFlow> one,
            List<HTextFlow> two) {
        assertThat(one.size(), Matchers.equalTo(two.size()));
        for (int i = 0; i < one.size(); i++) {
            HTextFlow textFlow1 = one.get(i);
            HTextFlow textFlow2 = two.get(i);
            assertThat(textFlow1.getId(), Matchers.equalTo(textFlow2.getId()));
            assertThat(getContentState(textFlow1, hLocale),
                    Matchers.equalTo(getContentState(textFlow2, hLocale)));
        }
    }
View Full Code Here

                        workspaceId.getLocaleId(),
                        projectIterationId.getProjectSlug(),
                        projectIterationId.getIterationSlug())).thenReturn(
                hLocale);
        // text flow 1
        HTextFlow hTextFlow1 = TestFixture.makeApprovedHTextFlow(1L, hLocale);
        setProjectAndIterationSlug(hTextFlow1, "project", "master");
        addHTextFlowTarget(hLocale, hTextFlow1, null);
        // text flow 2
        HTextFlow hTextFlow2 = TestFixture.makeApprovedHTextFlow(2L, hLocale);
        setProjectAndIterationSlug(hTextFlow2, "project 2", "beta");
        addHTextFlowTarget(hLocale, hTextFlow2, null);
        when(textFlowDAO.findByIdList(Lists.newArrayList(1L, 2L))).thenReturn(
                Lists.newArrayList(hTextFlow1, hTextFlow2));
View Full Code Here

        HProjectIteration projectIteration = new HProjectIteration();
        HProject project = new HProject();
        project.setName(projectName);
        projectIteration.setProject(project);
        document.setProjectIteration(projectIteration);
        textFlow = new HTextFlow(document, resId, "this is a string.");

        tmDetail = tmDetail(projectName, docId, resId, msgContext);

    }
View Full Code Here

    private final int batchStart;
    private final int batchLength;

    @Override
    protected Integer work() throws Exception {
        HTextFlow newTextFlow = textFlowDAO.findById(newTfId);

        List<HTextFlowTarget> copyTargets =
                textFlowTargetDAO
                        .getByTextFlowId(tfId, batchStart, batchLength);

        for (HTextFlowTarget tft : copyTargets) {
            HTextFlowTarget newTextFlowTarget =
                    copyVersionService.copyTextFlowTarget(newTextFlow, tft);

            newTextFlow.getTargets()
                    .put(newTextFlowTarget.getLocale().getId(),
                            newTextFlowTarget);
        }
        textFlowDAO.makePersistent(newTextFlow);
        textFlowDAO.flush();
View Full Code Here

                        event.getLocaleId());

        WordStatistic stats = documentStatisticCache.get(key);

        if (stats != null) {
            HTextFlow textFlow = getTextFlowDAO().findById(
                    event.getTextFlowId());

            stats.decrement(event.getPreviousState(),
                    textFlow.getWordCount().intValue());
            stats.increment(event.getNewState(),
                    textFlow.getWordCount().intValue());
            documentStatisticCache.put(key, stats);
        }

        // update document status information
        updateDocStatusCache(key, event.getTextFlowTargetId());
View Full Code Here

            statusToSet =
                    TransMemoryMergeStatusResolver.newInstance().decideStatus(
                            action, tmResult, oldTarget);
            comment = buildTargetComment(tu);
        } else {
            HTextFlow tmSource = textFlowDAO.findById(tmSourceId, false);
            TransMemoryDetails tmDetail =
                    translationMemoryServiceImpl.getTransMemoryDetail(hLocale,
                            tmSource);
            statusToSet =
                    TransMemoryMergeStatusResolver.newInstance().decideStatus(
View Full Code Here

TOP

Related Classes of org.zanata.model.HTextFlow

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.