Package org.zanata.rest.dto.resource

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


                documentDAO.getByDocIdAndIteration(hProjectIteration, id);
        if (document == null || document.isObsolete()) {
            return Response.status(Status.NOT_FOUND).build();
        }

        TranslationsResource translationResource = new TranslationsResource();
        // TODO avoid queries for better cacheability
        List<HTextFlowTarget> hTargets =
                textFlowTargetDAO.findTranslations(document, hLocale);
        boolean foundData =
                resourceUtils.transferToTranslationsResource(
View Full Code Here


        client.callWithTimeout(workDir,
                "mvn -B org.zanata:zanata-maven-plugin:push -Dzanata.userConfig="
                        + translatorConfig);

        // only message1 has translation
        TranslationsResource translationsResource =
                buildTranslationResource(buildTextFlowTarget("hello",
                        "translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, "prop1",
                new LocaleId("pl"), translationsResource, "auto");
View Full Code Here

        Resource message4 =
                buildSourceResource("message4", generateTextFlows(
                        numOfTextFlows));
        resources = new Resource[] { message1/*, message2, message3, message4*/ };

        TranslationsResource translation1 =
                buildTranslationResource(generateTextFlowTargets(
                numOfTextFlows));
        TranslationsResource translation2 =
                buildTranslationResource(generateTextFlowTargets(
                numOfTextFlows));
        TranslationsResource translation3 =
                buildTranslationResource(generateTextFlowTargets(
                numOfTextFlows));
        TranslationsResource translation4 =
                buildTranslationResource(generateTextFlowTargets(
                numOfTextFlows));
        translations = new Pair[] { Pair.of(message1, translation1)/*,
                Pair.of(message2, translation2),
                Pair.of(message3, translation3),
View Full Code Here

        restCaller.createProjectAndVersion(projectSlug, iterationSlug,
                projectType);

        String docId = "messages";
        Resource sourceResource = buildSourceResource(docId);
        TranslationsResource transResource = buildTranslationResource();
        int numOfMessages = 520;
        for (int i = 0; i < numOfMessages; i++) {
            String resId = "res" + i;
            String content = "content" + i;
            sourceResource.getTextFlows().add(buildTextFlow(resId, content));
            transResource.getTextFlowTargets().add(
                    buildTextFlowTarget(resId, content));
        }
        restCaller.asyncPushSource(projectSlug, iterationSlug, sourceResource, false);
        restCaller.asyncPushTarget(projectSlug, iterationSlug, docId,
                new LocaleId("pl"), transResource, "import");
View Full Code Here

        restCaller.createProjectAndVersion(projectSlug, iterationSlug,
                projectType);

        String docId = "messages";
        Resource sourceResource = buildSourceResource(docId);
        TranslationsResource transResource = buildTranslationResource();
        int numOfMessages = 10;
        for (int i = 0; i < numOfMessages; i++) {
            String resId = "res" + i;
            String content = "content" + i;
            sourceResource.getTextFlows().add(buildTextFlow(resId, content));
            transResource.getTextFlowTargets().add(
                    buildTextFlowTarget(resId, content));
        }
        restCaller.asyncPushSource(projectSlug, iterationSlug, sourceResource,
                false);
        LocaleId localeId = new LocaleId("pl");
        restCaller.asyncPushTarget(projectSlug, iterationSlug, docId,
                localeId, transResource, "auto");
        restCaller.runCopyTrans(projectSlug, iterationSlug, docId);

        assertThat(true, Matchers.is(true));

        // create some obsolete text flows
        Resource updatedSource = buildSourceResource(docId);
        TranslationsResource updatedTransResource = buildTranslationResource();
        for (int i = 0; i < numOfMessages; i++) {
            String resId = "res" + i;
            String content = "content" + i + " changed";
            updatedSource.getTextFlows().add(buildTextFlow(resId, content));
            updatedTransResource.getTextFlowTargets().add(buildTextFlowTarget(resId, content));
        }

        // push updated source (same resId different content)
        restCaller.asyncPushSource(projectSlug, iterationSlug, updatedSource, false);
        restCaller.asyncPushTarget(projectSlug, iterationSlug, docId, localeId, updatedTransResource, "auto");
View Full Code Here

            String iterationSlug, String docId) throws ZanataServiceException {
        if (fileName.endsWith(".po")) {
            return parsePoFile(fileContents, projectSlug, iterationSlug, docId);
        } else if (hasAdapterFor(fileName)) {
            File tempFile = persistToTempFile(fileContents);
            TranslationsResource transRes =
                    parseAdapterTranslationFile(tempFile, projectSlug,
                            iterationSlug, docId, localeId, fileName);
            removeTempFile(tempFile);
            return transRes;
        } else {
View Full Code Here

    public TranslationsResource parseAdapterTranslationFile(File tempFile,
            String projectSlug, String iterationSlug, String docId,
            String localeId, String fileName) {
        Optional<String> params =
                documentDAO.getAdapterParams(projectSlug, iterationSlug, docId);
        TranslationsResource transRes;
        try {
            transRes =
                    getAdapterFor(fileName).parseTranslationFile(
                            tempFile.toURI(), localeId, params);
        } catch (FileFormatAdapterException e) {
View Full Code Here

    @Test
    public void testDeleteTranslation() {
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        TranslationsResource sr = transTestFactory.getTestObject();
        translationResource.putTranslations(res.getName(), DE, sr,
                new StringSet("gettext;comment"));
        ClientResponse<String> resourceGetResponse =
                translationResource.deleteTranslations(res.getName(), DE);
        assertThat(resourceGetResponse.getResponseStatus(), is(Status.OK));
View Full Code Here

        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr,
                new StringSet("gettext;comment"));
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE,
                        new StringSet("gettext;comment")).getEntity();
        log.debug("expect:" + sr.toString());
        log.debug("actual:" + get.toString());
        ResourceTestUtil.clearRevs(sr);
        ResourceTestUtil.clearRevs(get);
        ResourceTestUtil.clearPoTargetHeaders(sr, get);
        assertThat(sr.toString(), is(get.toString()));
    }
View Full Code Here

        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr, null);
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE, null)
                        .getEntity();
        TranslationsResource base = transTestFactory.getTestObject();
        ResourceTestUtil.clearRevs(base);
        ResourceTestUtil.clearRevs(get);
        log.debug("expect:" + base.toString());
        log.debug("actual:" + get.toString());
        ResourceTestUtil.clearPoTargetHeaders(base, get);
        assertThat(base.toString(), is(get.toString()));
    }
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.