use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class BinderTemplateHandler method importResource.
@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
try {
// create resource
OLATResource resource = portfolioService.createBinderTemplateResource();
OlatRootFolderImpl fResourceRootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
File fResourceFileroot = fResourceRootContainer.getBasefile();
File zipRoot = new File(fResourceFileroot, FileResourceManager.ZIPDIR);
FileResource.copyResource(file, filename, zipRoot);
// create repository entry
RepositoryEntry re = repositoryService.create(initialAuthor, initialAuthorAlt, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
// import binder
File binderFile = new File(zipRoot, BinderTemplateResource.BINDER_XML);
Binder transientBinder = BinderXStream.fromPath(binderFile.toPath());
File posterImage = null;
if (StringHelper.containsNonWhitespace(transientBinder.getImagePath())) {
posterImage = new File(zipRoot, transientBinder.getImagePath());
}
portfolioService.importBinder(transientBinder, re, posterImage);
RepositoryEntryImportExport rei = new RepositoryEntryImportExport(re, zipRoot);
if (rei.anyExportedPropertiesAvailable()) {
re = rei.importContent(re, fResourceRootContainer.createChildContainer("media"));
}
// delete the imported files
FileUtils.deleteDirsAndFiles(zipRoot, true, true);
return re;
} catch (IOException e) {
log.error("", e);
return null;
}
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class SearchUserToolExtension method createUserTool.
@Override
public UserTool createUserTool(UserRequest ureq, WindowControl wControl, Locale locale) {
boolean canSearch = isEnabled();
if (canSearch && isSearchOnlyHasInternalSiteMember()) {
String softKey = getInternalSiteSoftKey();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(softKey, false);
if (repoEntry != null) {
RepositoryService contextManager = CoreSpringFactory.getImpl(RepositoryService.class);
canSearch = contextManager.isMember(ureq.getUserSession().getIdentity(), repoEntry);
}
}
return canSearch ? new SearchUserTool(wControl) : null;
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method getCurrentAssessmentMode.
@Test
public void getCurrentAssessmentMode() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getCurrentAssessmentMode(entry, now);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method getCurrentAssessmentMode_manualNowLeadingTime.
/**
* Manual with lead time -> in the current list
*/
@Test
public void getCurrentAssessmentMode_manualNowLeadingTime() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
// manual now
AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
mode.setName("Assessment to load");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.HOUR_OF_DAY, 1);
mode.setBegin(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 2);
mode.setEnd(cal.getTime());
mode.setTargetAudience(Target.course);
mode.setManualBeginEnd(true);
mode.setLeadTime(120);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getCurrentAssessmentMode(entry, now);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method loadAssessmentModes.
@Test
public void loadAssessmentModes() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
mode.setName("Assessment to load");
mode.setBegin(new Date());
mode.setEnd(new Date());
mode.setTargetAudience(Target.course);
AssessmentMode savedMode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedMode);
List<AssessmentMode> assessmentModes = assessmentModeMgr.getAssessmentModeFor(entry);
Assert.assertNotNull(assessmentModes);
Assert.assertEquals(1, assessmentModes.size());
Assert.assertEquals(savedMode, assessmentModes.get(0));
}
Aggregations