use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class BinderTemplateHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
OLATResource resource = portfolioService.createBinderTemplateResource();
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
portfolioService.createAndPersistBinderTemplate(initialAuthor, re, locale);
DBFactory.getInstance().commit();
return re;
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method createHelpCourseLaunchController.
/**
* Create a user locale dependent help-course run controller
*
* @param ureq The user request
* @param wControl The current window controller
* @return The help-course run controller
*/
public static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl) {
// Find repository entry for this course
String helpCourseSoftKey = CoreSpringFactory.getImpl(CourseModule.class).getHelpCourseSoftKey();
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = null;
if (StringHelper.containsNonWhitespace(helpCourseSoftKey)) {
entry = rm.lookupRepositoryEntryBySoftkey(helpCourseSoftKey, false);
}
if (entry == null) {
Translator translator = Util.createPackageTranslator(CourseFactory.class, ureq.getLocale());
wControl.setError(translator.translate("error.helpcourse.not.configured"));
// create empty main controller
LayoutMain3ColsController emptyCtr = new LayoutMain3ColsController(ureq, wControl, null, null, null);
return emptyCtr;
} else {
// Increment launch counter
rs.incrementLaunchCounter(entry);
ICourse course = loadCourse(entry);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
RepositoryEntrySecurity reSecurity = new RepositoryEntrySecurity(false, false, false, false, false, false, false, true, false);
RunMainController launchC = new RunMainController(ureq, bwControl, null, course, entry, reSecurity, null);
return launchC;
}
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class ScoreAccountingHelper method loadUsers.
/**
* Load all users from all known learning groups into a list
*
* @param courseEnv
* @return The list of identities from this course
*/
public static List<Identity> loadUsers(CourseEnvironment courseEnv) {
CourseGroupManager gm = courseEnv.getCourseGroupManager();
List<BusinessGroup> groups = gm.getAllBusinessGroups();
BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
Set<Identity> userSet = new HashSet<>(businessGroupService.getMembers(groups, GroupRoles.participant.name()));
RepositoryEntry re = gm.getCourseEntry();
if (re != null) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
userSet.addAll(repositoryService.getMembers(re, GroupRoles.participant.name()));
}
List<Identity> assessedList = courseEnv.getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(userSet);
if (!assessedList.isEmpty()) {
userSet.addAll(assessedList);
}
return new ArrayList<>(userSet);
}
use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.
the class JunitTestHelper method createAndPersistRepositoryEntry.
public static final RepositoryEntry createAndPersistRepositoryEntry(String initialAuthor, OLATResource r, boolean membersOnly) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry re = repositoryService.create(initialAuthor, "Lernen mit OLAT", r.getResourceableTypeName(), null, r);
if (membersOnly) {
re.setAccess(RepositoryEntry.ACC_OWNERS);
re.setMembersOnly(true);
} else {
re.setAccess(RepositoryEntry.ACC_USERS);
}
repositoryService.update(re);
return re;
}
use of org.olat.repository.RepositoryService in project openolat by klemens.
the class CoursesWebService method createEmptyCourse.
/**
* Create an empty course with some settings
* @param initialAuthor
* @param shortTitle
* @param longTitle
* @param softKey
* @param externalId
* @param externalRef
* @param managedFlags
* @param courseConfigVO
* @return
*/
public static ICourse createEmptyCourse(Identity initialAuthor, String shortTitle, String longTitle, String reDisplayName, String description, String softKey, int access, boolean membersOnly, String authors, String location, String externalId, String externalRef, String managedFlags, CourseConfigVO courseConfigVO) {
if (!StringHelper.containsNonWhitespace(reDisplayName)) {
reDisplayName = shortTitle;
}
try {
// create a repository entry
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
OLATResource resource = OLATResourceManager.getInstance().createOLATResourceInstance(CourseModule.class);
RepositoryEntry addedEntry = repositoryService.create(initialAuthor, null, "-", reDisplayName, null, resource, 0);
if (StringHelper.containsNonWhitespace(softKey) && softKey.length() <= 30) {
addedEntry.setSoftkey(softKey);
}
addedEntry.setLocation(location);
addedEntry.setAuthors(authors);
addedEntry.setExternalId(externalId);
addedEntry.setExternalRef(externalRef);
addedEntry.setManagedFlagsString(managedFlags);
addedEntry.setDescription(description);
if (RepositoryEntryManagedFlag.isManaged(addedEntry, RepositoryEntryManagedFlag.membersmanagement)) {
addedEntry.setAllowToLeaveOption(RepositoryEntryAllowToLeaveOptions.never);
} else {
// default
addedEntry.setAllowToLeaveOption(RepositoryEntryAllowToLeaveOptions.atAnyTime);
}
if (membersOnly) {
addedEntry.setMembersOnly(true);
addedEntry.setAccess(RepositoryEntry.ACC_OWNERS);
} else {
addedEntry.setAccess(access);
}
addedEntry = repositoryService.update(addedEntry);
// create an empty course
CourseFactory.createCourse(addedEntry, shortTitle, longTitle, "");
return prepareCourse(addedEntry, shortTitle, longTitle, courseConfigVO);
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
Aggregations