Package org.zanata.model

Examples of org.zanata.model.HRawDocument


     * @param doc
     * @param rawDoc
     * @return
     */
    public HRawDocument addRawDocument(HDocument doc, HRawDocument rawDoc) {
        HRawDocument oldRawDoc = doc.getRawDocument();

        if (oldRawDoc != null && !oldRawDoc.equals(rawDoc)) {
            getSession().delete(oldRawDoc);
        }

        if (rawDoc != null) {
            getSession().saveOrUpdate(rawDoc);
View Full Code Here


    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

    @Override
    public boolean hasPersistedDocument(GlobalDocumentId id) {
        HDocument doc = documentDAO.getByGlobalId(id);
        if (doc != null) {
            HRawDocument rawDocument = doc.getRawDocument();
            return rawDocument != null
                    && getFileForRawDocument(rawDocument).exists();
        }
        return false;
    }
View Full Code Here

        }

        if (document == null) {
            // error message for failed parse already added.
        } else {
            HRawDocument rawDocument = new HRawDocument();
            rawDocument.setDocument(document);
            rawDocument.setContentHash(new String(Hex.encodeHex(md5hash)));
            rawDocument.setType(DocumentType.typeFor(translationFileServiceImpl
                    .extractExtension(fileName)));
            rawDocument.setUploadedBy(identity.getCredentials().getUsername());

            Optional<String> params = getOptionalParams();
            if (params.isPresent()) {
                rawDocument.setAdapterParameters(params.get());
            }

            try {
                String name = projectSlug + ":" + versionSlug + ":" + docId;
                virusScanner.scan(tempFile, name);
View Full Code Here

    }

    private void persistRawDocument(HDocument document, File rawFile,
            String contentHash, DocumentType documentType,
            Optional<String> params) {
        HRawDocument rawDocument = new HRawDocument();
        rawDocument.setDocument(document);
        rawDocument.setContentHash(contentHash);
        rawDocument.setType(documentType);
        rawDocument.setUploadedBy(identity.getCredentials().getUsername());
        filePersistService.persistRawDocumentContentFromFile(rawDocument,
                rawFile);
        if (params.isPresent()) {
            rawDocument.setAdapterParameters(params.get());
        }
        documentDAO.addRawDocument(document, rawDocument);
        documentDAO.flush();
    }
View Full Code Here

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

                    entry.getValue().getDocId());
            HDocument newDoc = entry.getValue();

            assertDocument(existingDoc, newDoc);

            HRawDocument newRawDoc =
                    rawDocumentDAO.getByDocumentId(newDoc.getId());
            HRawDocument oldRawDoc = existingDoc.getRawDocument();
            assertRawDocument(newRawDoc, oldRawDoc);

            assertThat(newDoc.getTextFlows().size()).isEqualTo(
                    existingDoc.getTextFlows().size());
View Full Code Here

    }

    @Test
    public void testCopyRawDocument() throws Exception {
        HDocument existingDoc = documentDAO.getById(1L);
        HRawDocument newRawDoc =
                service.copyRawDocument(getDummyDocument(),
                        existingDoc.getRawDocument());

        assertRawDocument(newRawDoc, existingDoc.getRawDocument());
    }
View Full Code Here

                        conf.versionSlug, conf.docId)).thenReturn(
                Optional.fromNullable(conf.storedParams));
        when(
                documentDAO.addRawDocument(Matchers.<HDocument> any(),
                        persistedRawDocument.capture())).thenReturn(
                new HRawDocument());
        when(
                documentDAO.getByProjectIterationAndDocId(conf.projectSlug,
                        conf.versionSlug, conf.docId)).thenReturn(
                conf.existingDocument);
        Resource document = new Resource();
View Full Code Here

    }

    @Override
    public HRawDocument copyRawDocument(HDocument newDocument,
            @Nonnull HRawDocument rawDocument) throws Exception {
        HRawDocument copy =
                JPACopier.<HRawDocument> copyBean(rawDocument, "document");
        copy.setDocument(newDocument);
        return copy;
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.HRawDocument

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.