Package org.zanata.model

Examples of org.zanata.model.HDocument


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

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


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

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

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

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

            if (tft != null) {
                url =
                        urlUtil.editorDocumentListUrl(version.getProject()
                                .getSlug(), version.getSlug(), tft
View Full Code Here

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

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

        ResponseBuilder response = request.evaluatePreconditions(generatedEtag);
        if (response != null) {
            return response.build();
        }

        HDocument document =
                documentDAO.getByDocIdAndIteration(hProjectIteration, id);
        if (document == null || document.isObsolete()) {
            return Response.status(Status.NOT_FOUND).build();
        }

        TranslationsResource translationResource = new TranslationsResource();
        // TODO avoid queries for better cacheability
View Full Code Here

        ResponseBuilder response = request.evaluatePreconditions(etag);
        if (response != null) {
            return response.build();
        }

        HDocument document =
                documentDAO.getByDocIdAndIteration(hProjectIteration, id);
        if (document == null || document.isObsolete()) {
            return Response.status(Status.NOT_FOUND).build();
        }
        List<HTextFlowTarget> targets =
                textFlowTargetDAO.findAllTranslations(document, locale);

        for (HTextFlowTarget target : targets) {
            target.clear();
        }

        // we also need to delete the extensions here
        document.getPoTargetHeaders().remove(hLocale);
        textFlowTargetDAO.flush();

        return Response.ok().build();

    }
View Full Code Here

public class ContainingWorkspaceBridge implements FieldBridge {

    @Override
    public void set(String name, Object value, Document luceneDocument,
            LuceneOptions luceneOptions) {
        HDocument doc;
        if (value instanceof HTextFlow) {
            doc = ((HTextFlow) value).getDocument();
        } else if (value instanceof HDocument) {
            doc = (HDocument) value;
        } else {
            throw new IllegalArgumentException(
                    "ContainingWorkspaceBridge used on a non HDocument or HTextFlow type");
        }

        HProjectIteration iteration = doc.getProjectIteration();
        HProject project = iteration.getProject();

        addStringField(IndexFieldLabels.PROJECT_FIELD, project.getSlug(),
                luceneDocument, luceneOptions);
        addStringField(IndexFieldLabels.ITERATION_FIELD, iteration.getSlug(),
                luceneDocument, luceneOptions);
        addStringField(IndexFieldLabels.DOCUMENT_ID_FIELD, doc.getDocId(),
                luceneDocument, luceneOptions);
    }
View Full Code Here

                baseContentState);
        when(translationResult.getBaseVersionNum()).thenReturn(baseVersionNum);
        HTextFlow hTextFlow =
                TestFixture.makeHTextFlow(1, new HLocale(LocaleId.EN_US),
                        ContentState.Approved);
        HDocument spy = spy(new HDocument());
        when(spy.getId()).thenReturn(1L);
        hTextFlow.setDocument(spy);
        when(translationResult.getTranslatedTextFlowTarget()).thenReturn(
                new HTextFlowTarget(hTextFlow, new HLocale(LocaleId.DE)));

        return translationResult;
View Full Code Here

        List<HDocument> documents = documentDAO.findAllByVersionId(versionId,
                batchStart, batchLength);

        for (HDocument doc : documents) {
            HDocument newDocument =
                    copyVersionService.copyDocument(newVersion, doc);
            // Needs to persist before inserting raw document
            newDocument = documentDAO.makePersistent(newDocument);

            if (doc.getRawDocument() != null) {
                HRawDocument newRawDocument =
                        copyVersionService.copyRawDocument(newDocument,
                                doc.getRawDocument());

                filePersistService.copyAndPersistRawDocument(
                        doc.getRawDocument(), newRawDocument);

                documentDAO.addRawDocument(newDocument, newRawDocument);
            }
            newVersion.getDocuments()
                    .put(newDocument.getDocId(), newDocument);
            docMap.put(doc.getId(), newDocument.getId());
        }
        documentDAO.flush();
        return docMap;
    }
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.