Package org.zanata.rest.editor.dto

Examples of org.zanata.rest.editor.dto.TranslationData


        return Response.ok(transUnits).build();
    }

    @Override
    public Response put(String localeId, TranslationData data) {
        TranslationData requestData = data;
        HLocale locale = localeDAO.findByLocaleId(new LocaleId(localeId));
        HTextFlow textFlow =
                textFlowDAO.findById(requestData.getId().longValue());

        if (textFlow == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        identity.checkPermission("modify-translation",
                textFlow.getDocument().getProjectIteration().getProject(),
                locale);

        // //Only support 1 translation update for the moment
        TransUnitUpdateRequest request =
                new TransUnitUpdateRequest(new TransUnitId(requestData.getId()
                        .longValue()), requestData.getContents(),
                        requestData.getStatus(), requestData.getRevision());

        List<TranslationResult> translationResults =
                translationServiceImpl.translate(new LocaleId(localeId),
                        Lists.newArrayList(request));

        TranslationResult result = translationResults.get(0);

        if (result.isVersionNumConflict()) {
            return Response.status(Response.Status.CONFLICT).build();
        } else if (!result.isTranslationSuccessful()) {
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                    .build();
        } else {
            requestData.setStatus(result.getTranslatedTextFlowTarget()
                    .getState());
            requestData.setRevision(result.getTranslatedTextFlowTarget()
                    .getVersionNum());
            return Response.ok(requestData).build();
        }
    }
View Full Code Here

TOP

Related Classes of org.zanata.rest.editor.dto.TranslationData

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.