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);
}
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();
}
Aggregations