Search in sources :

Example 76 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class CatalogTest method createRepository.

private RepositoryEntry createRepository(String displayName, final Long resourceableId) {
    OLATResourceable resourceable = new OLATResourceable() {

        public String getResourceableTypeName() {
            return CourseModule.ORES_TYPE_COURSE;
        }

        public Long getResourceableId() {
            return resourceableId;
        }
    };
    OLATResourceManager rm = OLATResourceManager.getInstance();
    // create course and persist as OLATResourceImpl
    OLATResource r = rm.findResourceable(resourceable);
    if (r == null) {
        r = rm.createOLATResourceInstance(resourceable);
    }
    DBFactory.getInstance().saveObject(r);
    DBFactory.getInstance().intermediateCommit();
    RepositoryEntry d = RepositoryManager.getInstance().lookupRepositoryEntry(resourceable, false);
    if (d == null) {
        d = repositoryService.create("Rei Ayanami", "-", displayName, "Repo entry", r);
        DBFactory.getInstance().saveObject(d);
    }
    DBFactory.getInstance().intermediateCommit();
    return d;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 77 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class RepositoryEntryStatisticsDAOTest method incrementLaunchCounter.

@Test
public void incrementLaunchCounter() {
    RepositoryEntry repositoryEntry = repositoryService.create("Rei Ayanami", "-", "T1_perf1", "T1_perf1", null);
    final Long keyRepo = repositoryEntry.getKey();
    final OLATResourceable resourceable = repositoryEntry.getOlatResource();
    Assert.assertNotNull(resourceable);
    dbInstance.closeSession();
    assertEquals("Launch counter was not 0", 0, repositoryEntry.getStatistics().getLaunchCounter());
    final int mainLoop = 10;
    // 10 * 50 = 500
    final int loop = 50;
    for (int m = 0; m < mainLoop; m++) {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < loop; i++) {
            // 1. load RepositoryEntry
            RepositoryEntry repositoryEntryT1 = repositoryManager.lookupRepositoryEntry(keyRepo);
            repositoryService.incrementLaunchCounter(repositoryEntryT1);
            dbInstance.closeSession();
        }
        long endTime = System.currentTimeMillis();
        log.info("testIncrementLaunchCounter time=" + (endTime - startTime) + " for " + loop + " incrementLaunchCounter calls");
    }
    RepositoryEntry repositoryEntry2 = repositoryManager.lookupRepositoryEntry(keyRepo);
    assertEquals("Wrong value of incrementLaunch counter", mainLoop * loop, repositoryEntry2.getStatistics().getLaunchCounter());
    log.info("testIncrementLaunchCounter finished");
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 78 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class RepositoryEntryStatisticsDAOTest method incrementDownloadCounter.

@Test
public void incrementDownloadCounter() {
    RepositoryEntry repositoryEntry = repositoryService.create("Rei Ayanami", "-", "T1_perf2", "T1_perf2", null);
    final Long keyRepo = repositoryEntry.getKey();
    final OLATResourceable resourceable = repositoryEntry.getOlatResource();
    assertNotNull(resourceable);
    dbInstance.closeSession();
    assertEquals("Download counter was not 0", 0, repositoryEntry.getStatistics().getDownloadCounter());
    final int mainLoop = 10;
    // 10 * 50 = 500
    final int loop = 50;
    for (int m = 0; m < mainLoop; m++) {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < loop; i++) {
            // 1. load RepositoryEntry
            RepositoryEntry repositoryEntryT1 = repositoryManager.lookupRepositoryEntry(keyRepo);
            repositoryService.incrementDownloadCounter(repositoryEntryT1);
            dbInstance.closeSession();
        }
        long endTime = System.currentTimeMillis();
        log.info("testIncrementDownloadCounter time=" + (endTime - startTime) + " for " + loop + " incrementDownloadCounter calls");
    }
    RepositoryEntry repositoryEntry2 = repositoryManager.lookupRepositoryEntry(keyRepo);
    assertEquals("Wrong value of incrementLaunch counter", mainLoop * loop, repositoryEntry2.getStatistics().getDownloadCounter());
    log.info("testIncrementDownloadCounter finished");
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 79 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class ACMethodManagerTest method createResource.

private OLATResource createResource() {
    // create a repository entry
    OLATResourceable resourceable = new TypedResourceable(UUID.randomUUID().toString().replace("-", ""));
    OLATResource r = resourceManager.createOLATResourceInstance(resourceable);
    dbInstance.saveObject(r);
    return r;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResource(org.olat.resource.OLATResource)

Example 80 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class PortfolioTextForm method loadMapOrBinder.

protected void loadMapOrBinder() {
    RepositoryEntry mapEntry = courseNode.getReferencedRepositoryEntry();
    if (mapEntry != null) {
        if (BinderTemplateResource.TYPE_NAME.equals(mapEntry.getOlatResource().getResourceableTypeName())) {
            Binder binder = portfolioService.getBinderByResource(mapEntry.getOlatResource());
            if (binder != null) {
                inUse = portfolioService.isTemplateInUse(binder, courseEntry, courseNode.getIdent());
            }
            withDeadline = false;
        } else {
            PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
            Long courseResId = courseEntry.getOlatResource().getResourceableId();
            OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
            if (template != null) {
                inUse = ePFMgr.isTemplateInUse(template, courseOres, courseNode.getIdent(), null);
            }
            withDeadline = true;
        }
    } else {
        withDeadline = true;
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22