Examples of HTextFlowTarget


Examples of org.zanata.model.HTextFlowTarget

    public GetTargetForLocaleResult execute(GetTargetForLocale action,
    ExecutionContext context) throws ActionException {
        try {
            identity.checkLoggedIn();

            HTextFlowTarget hTextFlowTarget = textFlowTargetDAO
                    .getTextFlowTarget(
                    action.getSourceTransUnitId().getId(),
                    action.getLocale().getId().getLocaleId());

            if (hTextFlowTarget == null) {
                return new GetTargetForLocaleResult(null);
            } else {
                String displayName = retrieveDisplayName(hTextFlowTarget.getLocale());
                TextFlowTarget textFlowTarget = new TextFlowTarget(
                        new TextFlowTargetId(hTextFlowTarget.getId()),
                        action.getLocale(), hTextFlowTarget.getContents().get(0),
                        displayName);

                return new GetTargetForLocaleResult(textFlowTarget);
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

        Object lastTarget =
                getEntity(activity.getLastTargetType(),
                        activity.getLastTargetId());

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
            content = tft.getTextFlow().getContents().get(0);
        }

        return ShortString.shorten(content);
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                getEntity(activity.getLastTargetType(),
                        activity.getLastTargetId());

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HProjectIteration version = (HProjectIteration) context;
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

            url =
                    urlUtil.editorTransUnitUrl(version.getProject().getSlug(),
                            version.getSlug(), tft.getLocaleId(), tft
                                    .getTextFlow().getLocale(), tft
                                    .getTextFlow().getDocument().getDocId(),
                            tft.getTextFlow().getId());
        } else if (activity.getActivityType() == UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                url =
                        urlUtil.editorTransUnitUrl(version.getProject()
                                .getSlug(), version.getSlug(), tft
                                .getLocaleId(), document.getSourceLocaleId(),
                                tft.getTextFlow().getDocument().getDocId(), tft
                                        .getTextFlow().getId());
            }
        }
        return url;
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                getEntity(activity.getLastTargetType(),
                        activity.getLastTargetId());

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HProjectIteration version = (HProjectIteration) context;
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

            url =
                    urlUtil.editorDocumentUrl(version.getProject().getSlug(),
                            version.getSlug(), tft.getLocaleId(), tft
                                    .getTextFlow().getLocale(), tft
                                    .getTextFlow().getDocument().getDocId());
        } else if (activity.getActivityType() == UPLOAD_SOURCE_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            url =
                    urlUtil.sourceFilesViewUrl(version.getProject().getSlug(),
                            version.getSlug());
        } else if (activity.getActivityType() == UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                url =
                        urlUtil.editorDocumentUrl(version.getProject()
                                .getSlug(), version.getSlug(), tft
                                .getLocaleId(), document.getSourceLocaleId(),
                                tft.getTextFlow().getDocument().getDocId());
            }
        }
        return url;
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                getEntity(activity.getLastTargetType(),
                        activity.getLastTargetId());
        String docName = "";

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
            docName = tft.getTextFlow().getDocument().getName();
        } else if (activity.getActivityType() == UPLOAD_SOURCE_DOCUMENT
                || activity.getActivityType() == UPLOAD_TRANSLATION_DOCUMENT) {
            HDocument document = (HDocument) lastTarget;
            docName = document.getName();
        }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                        activity.getLastTargetId());
        String url = "";

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HProjectIteration version = (HProjectIteration) context;
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;

            url =
                    urlUtil.editorDocumentListUrl(version.getProject()
                            .getSlug(), version.getSlug(), tft.getLocaleId(),
                            tft.getTextFlow().getLocale());
        } else if (activity.getActivityType() == UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                url =
                        urlUtil.editorDocumentListUrl(version.getProject()
                                .getSlug(), version.getSlug(), tft
                                .getLocaleId(), tft.getTextFlow().getLocale());
            }
        }
        return url;
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                getEntity(activity.getLastTargetType(),
                        activity.getLastTargetId());
        String name = "";

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
            name = tft.getLocaleId().getId();
        } else if (activity.getActivityType() == UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == UPLOAD_TRANSLATION_DOCUMENT) {
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                name = tft.getLocaleId().getId();
            }
        }

        return name;
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

        if (entity instanceof HTextFlow) {
            HTextFlow tf = (HTextFlow) entity;
            localeId = tf.getDocument().getLocale().getLocaleId();
        } else if (entity instanceof HTextFlowTarget) {
            HTextFlowTarget tft = (HTextFlowTarget) entity;
            localeId = tft.getLocale().getLocaleId();
        } else if (entity instanceof TransMemoryUnitVariant) {
            TransMemoryUnitVariant tuv = (TransMemoryUnitVariant) entity;
            localeId = new LocaleId(tuv.getLanguage());
        } else {
            throw new IllegalArgumentException("Illegal text container type: "
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

                        Maps.<Integer, HTextFlowTargetHistory> newHashMap())));
        history.put(
                1,
                createHistory(createTarget(new Date(), "john", 1,
                        Maps.<Integer, HTextFlowTargetHistory> newHashMap())));
        HTextFlowTarget currentTranslation =
                createTarget(new Date(), "admin", 2, history);
        hTextFlow.getTargets().put(hLocale.getId(), currentTranslation);

        when(resourceUtils.getNumPlurals(hTextFlow.getDocument(), hLocale))
                .thenReturn(2);
        when(textFlowDAO.findById(transUnitId.getId(), false)).thenReturn(
                hTextFlow);

        // When:
        GetTranslationHistoryResult result =
                handler.execute(action, executionContext);

        // Then:
        assertThat(result.getHistoryItems(), Matchers.hasSize(2));
        assertThat(result.getLatest().getVersionNum(),
                Matchers.equalTo(currentTranslation.getVersionNum().toString()));
        assertThat(result.getLatest().getContents(),
                Matchers.equalTo(currentTranslation.getContents()));
        assertThat(result.getLatest().getModifiedBy(),
                Matchers.equalTo("admin"));
    }
View Full Code Here

Examples of org.zanata.model.HTextFlowTarget

        when(
                localeService.validateLocaleByProjectIteration(localeId,
                        "rhel", "7.0")).thenReturn(hLocale);
        when(hLocale.getId()).thenReturn(2L);
        HTextFlow hTextFlow = createHTextFlow();
        HTextFlowTarget currentTranslation =
                createTarget(new Date(), null, 0,
                        new HashMap<Integer, HTextFlowTargetHistory>());
        currentTranslation.setLastModifiedBy(null);
        hTextFlow.getTargets().put(hLocale.getId(), currentTranslation);

        when(resourceUtils.getNumPlurals(hTextFlow.getDocument(), hLocale))
                .thenReturn(2);
        when(textFlowDAO.findById(transUnitId.getId(), false)).thenReturn(
                hTextFlow);

        // When:
        GetTranslationHistoryResult result =
                handler.execute(action, executionContext);

        // Then:
        assertThat(result.getHistoryItems(),
                Matchers.<TransHistoryItem> emptyIterable());
        assertThat(result.getLatest().getVersionNum(),
                Matchers.equalTo(currentTranslation.getVersionNum().toString()));
        assertThat(result.getLatest().getContents(),
                Matchers.equalTo(currentTranslation.getContents()));
        assertThat(result.getLatest().getModifiedBy(), Matchers.equalTo(""));
    }
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.