Package org.zanata.rest.dto.resource

Examples of org.zanata.rest.dto.resource.TranslationsResource


      final IFixedTranslationResources client = ProxyFactory.create(IFixedTranslationResources.class, URI);
      final ClientResponse<TranslationsResource> response = client.getTranslations(id, locale);

      if (Response.Status.fromStatusCode(response.getStatus()) == Response.Status.OK)
      {
        final TranslationsResource retValue = response.getEntity();
        return retValue;
      }
    }
    catch (final Exception ex)
    {
View Full Code Here


    final ClientResponse<TranslationsResource> response = client.getTranslations("test", LocaleId.DE);

    if (response.getStatus() == 200)
    {

      final TranslationsResource entity = response.getEntity();

      final List<TextFlowTarget> targets = entity.getTextFlowTargets();

      for (final TextFlowTarget target : targets)
        System.out.println(target.getContent());
    }
    else
View Full Code Here

                String projectSlug = params.get("projectSlug").getString();
                String versionSlug = params.get("versionSlug").getString();
                String docId = params.get("docId").getString();
                // process the file
                TranslationsResource transRes =
                        translationFileServiceImpl.parseTranslationFile(params
                                .get("uploadFileElement").getInputStream(),
                                params.get("fileName").getString(),
                                params.get("targetLocale").getString(),
                                projectSlug, versionSlug, docId);
View Full Code Here

        return parseTranslationFile(rawDoc, filterParams);
    }

    private TranslationsResource parseTranslationFile(RawDocument rawDoc,
            Optional<String> params) {
        TranslationsResource transRes = new TranslationsResource();
        List<TextFlowTarget> translations = transRes.getTextFlowTargets();

        Map<String, HasContents> addedResources =
                new HashMap<String, HasContents>();
        updateParams(params);
        try {
View Full Code Here

    public void uploadTranslationFile(HLocale hLocale) {
        identity.checkPermission("modify-translation", hLocale, getVersion()
                .getProject());
        try {
            // process the file
            TranslationsResource transRes =
                    translationFileServiceImpl.parseTranslationFile(
                            translationFileUpload.getFileContents(),
                            translationFileUpload.getFileName(), hLocale
                                    .getLocaleId().getId(), projectSlug,
                            versionSlug, translationFileUpload.docId);
View Full Code Here

                        Collections.<String>emptySet(), mergeType);
        checkStatusAndReleaseConnection(response);
    }

    public static TranslationsResource buildTranslationResource(TextFlowTarget... targets) {
        TranslationsResource resource = new TranslationsResource();
        resource.setRevision(0);
        resource.getTextFlowTargets().addAll(Lists.newArrayList(targets));
        return resource;
    }
View Full Code Here

            final Set<String> extensions = new HashSet<String>();
            extensions.add("gettext");
            extensions.add("comment");

            // Perform translation of Hibernate DTOs to JAXB DTOs
            TranslationsResource transRes =
                    (TranslationsResource) this.translatedDocResourceService
                            .getTranslations(docId, new LocaleId(locale),
                                    extensions, true, null).getEntity();
            Resource res = this.resourceUtils.buildResource(document);

            StreamingOutput output =
                    new POStreamingOutput(res, transRes,
                            FILE_TYPE_OFFLINE_PO.equals(fileType));
            response =
                    Response.ok()
                            .header("Content-Disposition",
                                    "attachment; filename=\""
                                            + document.getName() + ".po\"")
                            .type(MediaType.TEXT_PLAIN).entity(output).build();
        } else if (FILETYPE_TRANSLATED_APPROVED.equals(fileType)
                || FILETYPE_TRANSLATED_APPROVED_AND_FUZZY.equals(fileType)) {
            if (!filePersistService.hasPersistedDocument(id)) {
                return Response.status(Status.NOT_FOUND).build();
            }
            final Set<String> extensions = Collections.<String> emptySet();
            TranslationsResource transRes =
                    (TranslationsResource) this.translatedDocResourceService
                            .getTranslations(docId, new LocaleId(locale),
                                    extensions, true, null).getEntity();
            // Filter to only provide translated targets. "Preview" downloads
            // include fuzzy.
            // New list is used as transRes list appears not to be a modifiable
            // implementation.
            Map<String, TextFlowTarget> translations =
                    new HashMap<String, TextFlowTarget>();
            boolean useFuzzy =
                    FILETYPE_TRANSLATED_APPROVED_AND_FUZZY.equals(fileType);
            for (TextFlowTarget target : transRes.getTextFlowTargets()) {
                // TODO rhbz953734 - translatedDocResourceService will map
                // review content state to old state. For now this is
                // acceptable. Once we have new REST options, we should review
                // this
                if (target.getState() == ContentState.Approved
View Full Code Here

                                            previousParts,
                                            uploadForm));
                }
            }

            TranslationsResource transRes;
            if (uploadForm.getFileType().equals(".po")) {
                InputStream poStream = getInputStream(tempFile, uploadForm);
                transRes =
                        translationFileServiceImpl.parsePoFile(poStream,
                                id.getProjectSlug(), id.getVersionSlug(),
View Full Code Here

        String translation = editorPage.getMessageTargetAtRowIndex(0);
        // for some reason getText() will return one space in it
        assertThat(translation.trim()).isEmpty();

        // push target
        TranslationsResource translationsResource =
                buildTranslationResource(
                        buildTextFlowTarget("res1", "hello world translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, docId,
                new LocaleId("pl"), translationsResource, "auto");
View Full Code Here

                        buildTextFlow("res1", "hello world"),
                        buildTextFlow("res2", "greetings"));
        restCaller.postSourceDocResource(projectSlug, iterationSlug,
                sourceResource, false);

        TranslationsResource translationsResource =
                buildTranslationResource(
                        buildTextFlowTarget("res1", "hello world translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, docId,
                new LocaleId("pl"), translationsResource, "auto");
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.resource.TranslationsResource

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.