Package org.zanata.rest.editor.dto

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


    @In
    private TransUnitUtils transUnitUtils;

    @Override
    public Response get(@QueryParam("ids") String ids) {
        TransUnits transUnits = new TransUnits();
        if (StringUtils.isEmpty(ids)) {
            return Response.ok(transUnits).build();
        }
        List<Long> idList = TransUnitUtils.filterAndConvertIdsToList(ids);
        if (idList.size() > TransUnitUtils.MAX_SIZE) {
            return Response.status(Response.Status.FORBIDDEN).build();
        }

        List<HTextFlow> hTextFlows = textFlowDAO.findByIdList(idList);

        for (HTextFlow htf : hTextFlows) {
            LocaleId localeId = htf.getDocument().getLocale().getLocaleId();
            EditorTextFlow tf = new EditorTextFlow(htf.getResId(), localeId);
            transUnitUtils.transferToTextFlow(htf, tf);
            transUnits.put(htf.getId().toString(), new TransUnit(tf));
        }
        return Response.ok(transUnits).build();
    }
View Full Code Here


    @In
    private TransUnitUtils transUnitUtils;

    @Override
    public Response get(String localeId, String ids) {
        TransUnits transUnits = new TransUnits();
        if (StringUtils.isEmpty(ids)) {
            return Response.ok(transUnits).build();
        }
        List<Long> idList = TransUnitUtils.filterAndConvertIdsToList(ids);
        if (idList.size() > TransUnitUtils.MAX_SIZE) {
            return Response.status(Response.Status.FORBIDDEN).build();
        }

        HLocale locale = localeServiceImpl.getByLocaleId(localeId);

        List<Object[]> results =
                textFlowDAO.getTextFlowAndTarget(idList, locale.getId());

        for (Object[] result : results) {
            HTextFlow textFlow = (HTextFlow) result[0];
            TransUnit tu;

            if (result.length < 2 || result[1] == null) {
                tu = transUnitUtils.buildTransUnitFull(textFlow, null,
                        locale.getLocaleId());
            }
            else {
                HTextFlowTarget textFlowTarget = (HTextFlowTarget) result[1];
                tu = transUnitUtils.buildTransUnitFull(textFlow,
                        textFlowTarget, locale.getLocaleId());
            }
            transUnits.put(textFlow.getId().toString(), tu);
        }

        return Response.ok(transUnits).build();
    }
View Full Code Here

    @In
    private LocaleService localeServiceImpl;

    @Override
    public Response get(String localeId, String ids) {
        TransUnits transUnits = new TransUnits();
        if (StringUtils.isEmpty(ids)) {
            return Response.ok(transUnits).build();
        }
        List<Long> idList = TransUnitUtils.filterAndConvertIdsToList(ids);
        if (idList.size() > TransUnitUtils.MAX_SIZE) {
            return Response.status(Response.Status.FORBIDDEN).build();
        }

        HLocale locale = localeServiceImpl.getByLocaleId(localeId);

        List<Object[]> results =
                textFlowDAO.getTextFlowAndTarget(idList, locale.getId());

        for (Object[] result : results) {
            HTextFlow hTextFlow = (HTextFlow) result[0];
            TransUnit tu;
            if (result.length < 2 || result[1] == null) {
                tu = transUnitUtils.buildTargetTransUnit(
                        hTextFlow, null, locale.getLocaleId());
            } else {
                HTextFlowTarget hTarget = (HTextFlowTarget) result[1];
                tu = transUnitUtils.buildTargetTransUnit(hTextFlow, hTarget,
                        locale.getLocaleId());
            }
            transUnits.put(hTextFlow.getId().toString(), tu);
        }

        return Response.ok(transUnits).build();
    }
View Full Code Here

TOP

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

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.