use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class PortfolioCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(searchResourceContext, courseNode, NODE_TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
PortfolioCourseNode portfolioNode = (PortfolioCourseNode) courseNode;
RepositoryEntry repoEntry = portfolioNode.getReferencedRepositoryEntry();
if (repoEntry != null) {
OLATResource ores = repoEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
if (element != null) {
Document pDocument = PortfolioMapDocument.createDocument(courseNodeResourceContext, element);
indexWriter.addDocument(pDocument);
}
}
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class FeedDAOTest method loadFeed_Long.
@Test
public void loadFeed_Long() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
Feed reloaded = feedDao.loadFeed(feed.getKey());
// check values
Assert.assertEquals(feed.getKey(), reloaded.getKey());
Assert.assertEquals(resource.getResourceableId(), reloaded.getResourceableId());
Assert.assertEquals(resource.getResourceableTypeName(), reloaded.getResourceableTypeName());
// It's ok when the date is about the same in the database.
Assert.assertTrue("Dates aren't close enough to each other!", (feed.getCreationDate().getTime() - reloaded.getCreationDate().getTime()) < 1000);
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class FeedDAOTest method createFeed_feed.
@Test
public void createFeed_feed() {
OLATResource resource = JunitTestHelper.createRandomResource();
Feed tempFeed = new FeedImpl(resource);
Feed feed = feedDao.createFeed(tempFeed);
Assert.assertNotNull(feed);
dbInstance.commitAndCloseSession();
// check values
Assert.assertNotNull(feed.getKey());
Assert.assertNotNull(feed.getCreationDate());
Assert.assertNotNull(feed.getLastModified());
Assert.assertEquals(resource.getResourceableId(), feed.getResourceableId());
Assert.assertEquals(resource.getResourceableTypeName(), feed.getResourceableTypeName());
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class FeedDAOTest method copyFeed.
@Test
public void copyFeed() {
OLATResource source = JunitTestHelper.createRandomResource();
OLATResource target = JunitTestHelper.createRandomResource();
Feed feed = feedDao.createFeedForResourcable(source);
dbInstance.commitAndCloseSession();
Feed copy = feedDao.copyFeed(feed, target);
dbInstance.commitAndCloseSession();
assertThat(copy.getKey()).isNotEqualTo(feed.getKey());
assertThat(copy.getResourceableId()).isNotEqualTo(feed.getResourceableId());
assertThat(copy.getCreationDate()).isCloseTo(feed.getCreationDate(), 1000);
assertThat(copy.getLastModified()).isCloseTo(feed.getLastModified(), 1000);
}
use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.
the class FeedDAOTest method updateFeed_null.
@Test
public void updateFeed_null() {
OLATResource resource = JunitTestHelper.createRandomResource();
// create and save a feed
feedDao.createFeedForResourcable(resource);
dbInstance.commitAndCloseSession();
// update null
Feed updated = feedDao.updateFeed(null);
// check values
Assert.assertNull(updated);
}
Aggregations