Package org.zanata.model

Examples of org.zanata.model.HDocument


        return rawDoc;
    }

    public Optional<String> getAdapterParams(String projectSlug,
            String iterationSlug, String docId) {
        HDocument doc =
                getByProjectIterationAndDocId(projectSlug, iterationSlug, docId);
        if (doc != null) {
            HRawDocument rawDoc = doc.getRawDocument();
            if (rawDoc != null) {
                return Optional.fromNullable(rawDoc.getAdapterParameters());
            }
        }
        return Optional.<String> absent();
View Full Code Here


        HProjectIteration hProjectIteration =
                retrieveAndCheckIteration(projectSlug, iterationSlug, true);

        resourceUtils.validateExtensions(extensions); // gettext, comment

        HDocument document =
                documentDAO.getByDocIdAndIteration(hProjectIteration,
                        resource.getName());

        // already existing non-obsolete document.
        if (document != null) {
            if (!document.isObsolete()) {
                // updates must happen through PUT on the actual resource
                ProcessStatus status = new ProcessStatus();
                status.setStatusCode(ProcessStatusCode.Failed);
                status.getMessages().add(
                        "A document with name " + resource.getName()
View Full Code Here

                            .getDocId(), tft.getTextFlow().getId());
        } else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                return urlUtil.editorTransUnitUrl(version.getProject()
                        .getSlug(), version.getSlug(), tft.getLocaleId(),
                        document.getSourceLocaleId(), tft.getTextFlow()
                                .getDocument().getDocId(), tft.getTextFlow()
                                .getId());
            }
        }
        return "";
View Full Code Here

            HProjectIteration version = (HProjectIteration) context;
            return urlUtil.sourceFilesViewUrl(version.getProject().getSlug(),
                    version.getSlug());
        } else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                return urlUtil.editorDocumentUrl(
                        version.getProject().getSlug(), version.getSlug(),
                        tft.getLocaleId(), document.getSourceLocaleId(), tft
                                .getTextFlow().getDocument().getDocId());
            }
        }
        return "";
    }
View Full Code Here

                    tft.getLocaleId(), tft.getTextFlow().getLocale());
        } else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
            HProjectIteration version = (HProjectIteration) context;
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                return urlUtil.editorDocumentListUrl(version.getProject()
                        .getSlug(), version.getSlug(), tft.getLocaleId(), tft
                        .getTextFlow().getLocale());
View Full Code Here

        if (isTranslationUpdateActivity(activity.getActivityType())) {
            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
            return tft.getTextFlow().getDocument().getName();
        } else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT
                || activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
            HDocument document = (HDocument) lastTarget;
            return document.getName();
        }
        return "";
    }
View Full Code Here

            HTextFlowTarget tft = (HTextFlowTarget) lastTarget;
            return tft.getLocaleId().getId();
        } else if (activity.getActivityType() == ActivityType.UPLOAD_SOURCE_DOCUMENT) {
            // not supported for upload source action
        } else if (activity.getActivityType() == ActivityType.UPLOAD_TRANSLATION_DOCUMENT) {
            HDocument document = (HDocument) lastTarget;
            HTextFlowTarget tft =
                    documentDAO.getLastTranslatedTargetOrNull(document.getId());

            if (tft != null) {
                return tft.getLocaleId().getId();
            }
        }
View Full Code Here

        return EntityTag.valueOf(hash);
    }

    public EntityTag generateETagForDocument(HProjectIteration iteration,
            String id, Set<String> extensions) {
        HDocument doc = documentDAO.getByDocIdAndIteration(iteration, id);
        if (doc == null)
            throw new NoSuchEntityException("Document '" + id + "' not found.");

        Integer hashcode = 1;
        hashcode = hashcode * 31 + doc.getRevision();

        int extHash = 0;
        if (extensions.contains(PoHeader.ID)) {
            HPoHeader header = doc.getPoHeader();
            if (header != null) {
                extHash = header.getVersionNum();
            }
        }
        hashcode = hashcode * 31 + extHash;
View Full Code Here

    private DocumentDAO documentDAO;

    @Override
    public CopyTransStatus startCopyTrans(String projectSlug,
            String iterationSlug, String docId) {
        HDocument document =
                documentDAO.getByProjectIterationAndDocId(projectSlug,
                        iterationSlug, docId);
        if (document == null) {
            throw new NoSuchEntityException("Could not find document: "
                    + projectSlug + "/" + iterationSlug + "/" + docId);
View Full Code Here

    @Override
    public CopyTransStatus getCopyTransStatus(String projectSlug,
            String iterationSlug, String docId) {

        HDocument document =
                documentDAO.getByProjectIterationAndDocId(projectSlug,
                        iterationSlug, docId);
        if (document == null) {
            throw new NoSuchEntityException("Could not find document: "
                    + projectSlug + "/" + iterationSlug + "/" + docId);
        }

        identity.checkPermission("copy-trans", document.getProjectIteration());

        CopyTransTaskHandle processHandle =
                copyTransManager.getCopyTransProcessHandle(document);

        if (processHandle == null) {
View Full Code Here

TOP

Related Classes of org.zanata.model.HDocument

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.