Package org.zanata.model

Examples of org.zanata.model.HLocale


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

        HLocale hLocale = localeServiceImpl.getByLocaleId(localeId);
        if (hLocale == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        TextFlowResultTransformer resultTransformer =
                new TextFlowResultTransformer(hLocale);

        FilterConstraints filterConstraints = FilterConstraints.builder().build();

        List<HTextFlow> textFlows =
                textFlowDAO.getNavigationByDocumentId(
                        new DocumentId(document.getId(), document.getDocId()),
                        hLocale, resultTransformer, filterConstraints);

        List<TransUnitStatus> statusList =
                Lists.newArrayListWithExpectedSize(textFlows.size());

        for (HTextFlow textFlow : textFlows) {
            ContentState state = textFlow.getTargets().get(hLocale.getId()).getState();
            statusList.add(new TransUnitStatus(textFlow.getId(), textFlow
                    .getResId(), state));
        }

        Type genericType = new GenericType<List<Locale>>() {
View Full Code Here


        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

        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

    }

    @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();
View Full Code Here

            return Response.status(Response.Status.NOT_FOUND).build();
        }
        if (document.isObsolete()) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
        HLocale hLocale =
                validateTargetLocale(messageBody.getLang(), projectSlug,
                        iterationSlug);
        boolean changed =
                resourceUtils.transferFromResourceMetadata(messageBody,
                        document, extensions, hLocale,
View Full Code Here

        }
    }

    private HLocale validateTargetLocale(LocaleId locale, String projectSlug,
            String iterationSlug) {
        HLocale hLocale;
        try {
            hLocale =
                    localeServiceImpl.validateLocaleByProjectIteration(locale,
                            projectSlug, iterationSlug);
            return hLocale;
View Full Code Here

            throws ActionException {
        identity.checkLoggedIn();
        log.debug("get translation history for text flow id {}",
                action.getTransUnitId());

        HLocale hLocale;
        try {
            hLocale =
                    localeServiceImpl.validateLocaleByProjectIteration(action
                            .getWorkspaceId().getLocaleId(), action
                            .getWorkspaceId().getProjectIterationId()
                            .getProjectSlug(), action.getWorkspaceId()
                            .getProjectIterationId().getIterationSlug());
        } catch (ZanataServiceException e) {
            throw new ActionException(e);
        }

        HTextFlow hTextFlow =
                textFlowDAO.findById(action.getTransUnitId().getId(), false);

        HTextFlowTarget hTextFlowTarget =
                hTextFlow.getTargets().get(hLocale.getId());
        Map<Integer, HTextFlowTargetHistory> history = Maps.newHashMap();
        TransHistoryItem latest = null;
        if (hTextFlowTarget != null) {
            String lastModifiedBy =
                    nameOrEmptyString(hTextFlowTarget.getLastModifiedBy());
View Full Code Here

            to.getRoles().add(hAccountRole);
        }

        hPerson.getLanguageMemberships().clear();
        for (String tribe : from.getTribes()) {
            HLocale hTribe = localeDAO.findByLocaleId(new LocaleId(tribe));
            if (hTribe == null)
                // generate error for missing tribe
                throw new NoLogWebApplicationException(Response
                        .status(Status.BAD_REQUEST)
                        .entity("Invalid tribe '" + tribe + "'").build());
View Full Code Here

        return new ArrayList<HLocale>(Collections2.transform(filtered,
                new Function<LocaleId, HLocale>() {
                    @Override
                    public HLocale apply(@Nullable LocaleId from) {
                        return new HLocale(from);
                    }
                }));
    }
View Full Code Here

            }

            // Enable en-US by default
            LocaleId localeId = new LocaleId("en-US");
            if (localeDAO.findByLocaleId(localeId) == null) {
                HLocale en_US = new HLocale(localeId);
                en_US.setActive(true);
                en_US.setEnabledByDefault(false);
                if (localeDAO.makePersistent(en_US) == null) {
                    throw new RuntimeException("Couldn't create 'en-US' locale");
                }
            }
View Full Code Here

TOP

Related Classes of org.zanata.model.HLocale

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.