Search in sources :

Example 1 with QuestionDAO

use of org.mamute.dao.QuestionDAO in project mamute by caelum.

the class AttachmentRepositoryTest method setup.

@Before
public void setup() {
    attachments = new AttachmentDao(session);
    fileStorage = new AttachmentsFileStorage(attachmentRootFolder.getRoot().getAbsolutePath());
    questions = new QuestionDAO(session, Mockito.mock(InvisibleForUsersRule.class));
    answers = new AnswerDAO(session, Mockito.mock(InvisibleForUsersRule.class));
    this.attachmentRepository = new AttachmentRepository(attachments, fileStorage, questions, answers);
}
Also used : AttachmentDao(org.mamute.dao.AttachmentDao) AnswerDAO(org.mamute.dao.AnswerDAO) QuestionDAO(org.mamute.dao.QuestionDAO) Before(org.junit.Before)

Example 2 with QuestionDAO

use of org.mamute.dao.QuestionDAO in project mamute by caelum.

the class IndexSyncJob method execute.

public void execute() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            Session session = factory.getInstance().openSession();
            try {
                QuestionDAO questions = new QuestionDAO(session, generateUser());
                long pages = questions.numberOfPages();
                long total = 0;
                LOGGER.info("Syncing questions!");
                for (int i = 0; i < pages; i++) {
                    List<Question> q = questions.allVisible(i);
                    index.indexQuestionBatch(q);
                    total += q.size();
                }
                LOGGER.info("Synced " + total + " questions");
            } finally {
                session.close();
            }
        }
    }).start();
}
Also used : Question(org.mamute.model.Question) Session(org.hibernate.Session) QuestionDAO(org.mamute.dao.QuestionDAO)

Aggregations

QuestionDAO (org.mamute.dao.QuestionDAO)2 Session (org.hibernate.Session)1 Before (org.junit.Before)1 AnswerDAO (org.mamute.dao.AnswerDAO)1 AttachmentDao (org.mamute.dao.AttachmentDao)1 Question (org.mamute.model.Question)1