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