Search in sources :

Example 26 with OLATResource

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);
        }
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

Example 27 with OLATResource

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);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 28 with OLATResource

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());
}
Also used : OLATResource(org.olat.resource.OLATResource) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 29 with OLATResource

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);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 30 with OLATResource

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);
}
Also used : OLATResource(org.olat.resource.OLATResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

OLATResource (org.olat.resource.OLATResource)706 Test (org.junit.Test)304 RepositoryEntry (org.olat.repository.RepositoryEntry)198 Identity (org.olat.core.id.Identity)170 File (java.io.File)80 Date (java.util.Date)72 Feed (org.olat.modules.webFeed.Feed)72 ArrayList (java.util.ArrayList)64 ICourse (org.olat.course.ICourse)64 RepositoryService (org.olat.repository.RepositoryService)62 OLATResourceable (org.olat.core.id.OLATResourceable)60 BusinessGroup (org.olat.group.BusinessGroup)58 Item (org.olat.modules.webFeed.Item)44 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)38 OLATResourceManager (org.olat.resource.OLATResourceManager)34 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)34 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)30 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)30 FreeAccessMethod (org.olat.resource.accesscontrol.model.FreeAccessMethod)28 Group (org.olat.basesecurity.Group)26