Examples of TextFlow


Examples of org.zanata.apicompat.rest.dto.resource.TextFlow

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        new ResourceRequest(
                getRestEndpointUrl("/projects/p/sample-project/iterations/i/1.0/r/"
                        + res.getName()), "PUT", getAuthorizedEnvironment()) {
            @Override
            protected void prepareRequest(ClientRequest request) {
                request.queryParameter("ext", SimpleComment.ID).queryParameter(
                        "ext", PoHeader.ID);
                request.body(MediaType.APPLICATION_JSON, jsonMarshal(res));
            }

            @Override
            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(),
                        is(Status.CREATED.getStatusCode())); // 201
            }
        }.run();

        ISourceDocResource translationsClient =
                super.createProxy(
                        createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                translationsClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents(), is(tf1.getContents()));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

Examples of org.zanata.apicompat.rest.dto.resource.TextFlow

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        ISourceDocResource sourceDocClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<String> response =
                sourceDocClient.post(res, new StringSet(PoHeader.ID + ";"
                        + SimpleComment.ID), true);

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode())); // 201
        response.releaseConnection();

        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                sourceDocClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents().get(0), is(tf1.getContents().get(0)));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

Examples of org.zanata.apicompat.rest.dto.resource.TextFlow

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        ISourceDocResource sourceDocClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<String> response =
                sourceDocClient.putResource(res.getName(), res, new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode())); // 201
        response.releaseConnection();

        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                sourceDocClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents().get(0), is(tf1.getContents().get(0)));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

Examples of org.zanata.apicompat.rest.dto.resource.TextFlow

        // Make sure all Text Flows are present
        assertThat(resource.getTextFlows().size(), greaterThanOrEqualTo(3));

        // Evaluate individual text flows
        TextFlow txtFlow = resource.getTextFlows().get(0);
        assertThat(txtFlow.getId(), is("tf2"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId1"));

        txtFlow = resource.getTextFlows().get(1);
        assertThat(txtFlow.getId(), is("tf3"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId2"));

        txtFlow = resource.getTextFlows().get(2);
        assertThat(txtFlow.getId(), is("tf4"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId3"));
    }
View Full Code Here

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

      resource.setLang(LocaleId.EN_US);
      resource.setName("test");
      resource.setRevision(1);
      resource.setType(ResourceType.FILE);

      final TextFlow textFlow = new TextFlow();
      textFlow.setId("id");
      textFlow.setContent("Some text to be translated");
      textFlow.setLang(LocaleId.EN_US);
      textFlow.setRevision(1);

      resource.getTextFlows().add(textFlow);

      /* create a http client to supply the credentials */
      final HttpClient httpClient = new HttpClient();
View Full Code Here

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

        Resource entity = new Resource(doc.getDocId());
        log.debug("get resource details {}", entity.toString());
        resourceUtils.transferToResource(doc, entity);

        for (HTextFlow htf : doc.getTextFlows()) {
            TextFlow tf =
                    new TextFlow(htf.getResId(), doc.getLocale().getLocaleId());
            resourceUtils.transferToTextFlow(htf, tf);
            resourceUtils.transferToTextFlowExtensions(htf,
                    tf.getExtensions(true), extensions);
            entity.getTextFlows().add(tf);
        }

        // handle extensions
        resourceUtils.transferToResourceExtensions(doc,
View Full Code Here

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

                } else if (event.getEventType() == EventType.TEXT_UNIT) {
                    TextUnit tu = (TextUnit) event.getResource();
                    if (!tu.getSource().isEmpty() && tu.isTranslatable()) {
                        String content = getTranslatableText(tu);
                        if (!content.isEmpty()) {
                            TextFlow tf =
                                    new TextFlow(getIdFor(tu, content,
                                            subDocName), sourceLocale);
                            tf.setPlural(false);
                            tf.setContents(content);
                            if (shouldAdd(tf.getId(), tf, addedResources)) {
                                addedResources.put(tf.getId(), tf);
                                resources.add(tf);
                            }
                        }
                    }
                }
View Full Code Here

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

        // handle extensions
        this.transferToResourceExtensions(document, entity.getExtensions(true),
                extensions);

        for (HTextFlow htf : document.getTextFlows()) {
            TextFlow tf =
                    new TextFlow(htf.getResId(), document.getLocale()
                            .getLocaleId());
            this.transferToTextFlowExtensions(htf, tf.getExtensions(true),
                    extensions);
            this.transferToTextFlow(htf, tf);
            entity.getTextFlows().add(tf);
        }
View Full Code Here

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

        return resource;
    }

    public static TextFlow buildTextFlow(String resId, String... contents) {

        TextFlow textFlow = new TextFlow();
        textFlow.setId(resId);
        textFlow.setLang(LocaleId.EN_US);
        textFlow.setRevision(0);
        textFlow.setContents(contents);
        return textFlow;
    }
View Full Code Here

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

    @Test
    public void createResourceWithContentUsingPost() {
        Resource sr = createSourceResource("my.txt");

        TextFlow stf = new TextFlow("tf1", LocaleId.EN, "tf1");
        sr.getTextFlows().add(stf);

        ClientResponse<String> postResponse =
                sourceDocResource.post(sr, null, true);
        assertThat(postResponse.getResponseStatus(), is(Status.CREATED));
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.