Examples of ProjectIterationDAO


Examples of org.zanata.dao.ProjectIterationDAO

    @Test(dataProvider = "CopyTrans")
    @SlowTest
    public void testCopyTrans(CopyTransExecution execution) {
        // Prepare Execution
        ProjectIterationDAO iterationDAO =
                seam.autowire(ProjectIterationDAO.class);
        LocaleDAO localeDAO = seam.autowire(LocaleDAO.class);

        // Get the project iteration
        HProjectIteration projectIteration;
        if (execution.projectMatches) {
            projectIteration =
                    iterationDAO.getBySlug("same-project", "different-version");
        } else {
            projectIteration =
                    iterationDAO.getBySlug("different-project",
                            "different-version");
        }
        assert projectIteration != null;

        // Set require translation review
        projectIteration
                .setRequireTranslationReview(execution.requireTranslationReview);

        // Change all targets to have the execution's match state
        for (HDocument doc : projectIteration.getDocuments().values()) {
            for (HTextFlow tf : doc.getAllTextFlows().values()) {
                for (HTextFlowTarget tft : tf.getTargets().values()) {
                    tft.setState(execution.matchState);
                }
            }
        }

        // Create the document
        HDocument doc = new HDocument();
        doc.setContentType(ContentType.TextPlain);
        doc.setLocale(localeDAO.findByLocaleId(LocaleId.EN_US));
        doc.setProjectIteration(projectIteration);
        if (execution.documentMatches) {
            doc.setFullPath("/same/document");
        } else {
            doc.setFullPath("/different/document");
        }
        projectIteration.getDocuments().put(doc.getDocId(), doc);

        // Create the text Flow
        HTextFlow textFlow = new HTextFlow();
        textFlow.setContents("Source Content"); // Source content matches
        textFlow.setPlural(false);
        textFlow.setObsolete(false);
        textFlow.setDocument(doc);
        if (execution.contextMatches) {
            textFlow.setResId("same-context");
        } else {
            textFlow.setResId("different-context");
        }
        doc.getTextFlows().add(textFlow);

        projectIteration = iterationDAO.makePersistent(projectIteration);
        getEm().flush(); // So the rest of the test sees the results

        HCopyTransOptions options =
                new HCopyTransOptions(execution.getContextMismatchAction(),
                        execution.getDocumentMismatchAction(),
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

    }

    @Test
    public void ignoreTranslationsFromObsoleteProjectAndVersion()
            throws Exception {
        ProjectIterationDAO projectIterationDAO =
                seam.autowire(ProjectIterationDAO.class);
        ProjectDAO projectDAO = seam.autowire(ProjectDAO.class);

        // Make versions and projects obsolete
        HProjectIteration version =
                projectIterationDAO.getBySlug("same-project", "same-version");
        assert version != null;
        version.setStatus(EntityStatus.OBSOLETE);
        projectIterationDAO.makePersistent(version);

        HProject project = projectDAO.getBySlug("different-project");
        assert project != null;
        project.setStatus(EntityStatus.OBSOLETE);
        projectDAO.makePersistent(project);
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

        testCopyTrans(execution);
    }

    @Test
    public void reuseTranslationsFromObsoleteDocuments() throws Exception {
        ProjectIterationDAO projectIterationDAO =
                seam.autowire(ProjectIterationDAO.class);
        DocumentDAO documentDAO = seam.autowire(DocumentDAO.class);

        // Make all documents obsolete
        HProjectIteration version =
                projectIterationDAO.getBySlug("same-project", "same-version");
        assert version != null;
        for (HDocument doc : version.getDocuments().values()) {
            doc.setObsolete(true);
            documentDAO.makePersistent(doc);
        }
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

        MockitoAnnotations.initMocks(this);

        when(identity.getCredentials()).thenReturn(credentials);
        when(credentials.getUsername()).thenReturn("mock user");

        projectIterationDAO = new ProjectIterationDAO(getSession());
        documentDAO = new DocumentDAO(getSession());
        textFlowTargetDAO = new TextFlowTargetDAO(getSession());
        textFlowDAO = new TextFlowDAO(getSession());
        rawDocumentDAO = new RawDocumentDAO((getSession()));
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

    /**
     * Makes sure that given two equal results, it will reuse the most recent
     * translation.
     */
    private void testMostRecentMatch(TranslationFinder service) {
        ProjectIterationDAO projectIterationDAO =
                seam.autowire(ProjectIterationDAO.class);

        HProjectIteration version =
                projectIterationDAO.getBySlug("same-project", "same-version");
        assert version != null;

        HDocument hDoc = version.getDocuments().get("/same/document0");

        HTextFlow textFlow = hDoc.getTextFlows().get(0);
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO


    private void testExecution(Class<? extends TranslationFinder> impl, Execution execution) {
        TranslationFinder service = seam.autowire(impl);
        // Prepare Execution
        ProjectIterationDAO iterationDAO =
                seam.autowire(ProjectIterationDAO.class);

        // Get the project iteration
        HProjectIteration queryProjIter =
                iterationDAO.getBySlug(execution.getProject(), execution.getVersion());

        assert queryProjIter != null;

        // Create the document
        HDocument queryDoc = new HDocument();
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

        String id = DOC2_NAME;
        expectTarget(true, id, FR, target2);
    }

    private void verifyObsoleteDocument(final String docID) throws Exception {
        ProjectIterationDAO projectIterationDAO =
                getSeamAutowire().autowire(ProjectIterationDAO.class);
        HProjectIteration iteration =
                projectIterationDAO.getBySlug(projectSlug, iter);
        Map<String, HDocument> allDocuments = iteration.getAllDocuments();
        HDocument hDocument = allDocuments.get(docID);
        // FIXME hDocument is coming back null
        // Assert.assertNotNull(hDocument);
        // Assert.assertTrue(hDocument.isObsolete());
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

        // Assert.assertTrue(hDocument.isObsolete());
    }

    private void verifyObsoleteResource(final String docID,
            final String resourceID) throws Exception {
        ProjectIterationDAO projectIterationDAO =
                getSeamAutowire().autowire(ProjectIterationDAO.class);
        HProjectIteration iteration =
                projectIterationDAO.getBySlug(projectSlug, iter);
        Map<String, HDocument> allDocuments = iteration.getAllDocuments();
        HDocument hDocument = allDocuments.get(docID);
        // FIXME hDocument is coming back null
        // HTextFlow hResource = hDocument.getAllTextFlows().get(resourceID);
        // Assert.assertNotNull(hResource);
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

        MockitoAnnotations.initMocks(this);
        // @formatter:off
        seam.reset()
            .use("localeServiceImpl", localeService)
            .use("documentDAO", new DocumentDAO(getSession()))
            .use("projectIterationDAO", new ProjectIterationDAO(getSession()))
            .use("entityManager", new FullTextEntityManagerImpl(getEm()))
            .use("session", new FullTextSessionImpl(getSession()));
        // @formatter:on
        jaHLocale = getEm().find(HLocale.class, 3L);
        when(
View Full Code Here

Examples of org.zanata.dao.ProjectIterationDAO

    @BeforeMethod
    public void initializeSeam() {
        seam.reset()
                .use("versionGroupDAO", new VersionGroupDAO(getSession()))
                .use("projectIterationDAO",
                        new ProjectIterationDAO(getSession()))
                .use("session", getSession())
                .useImpl(VersionStateCacheImpl.class).useImpl(LocaleServiceImpl.class).ignoreNonResolvable();

        versionGroupServiceImpl = seam.autowire(VersionGroupServiceImpl.class);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.