use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleDAO method deleteLifecycle.
public void deleteLifecycle(RepositoryEntryLifecycle lifecycle) {
RepositoryEntryLifecycle reloadedLifecycle = dbInstance.getCurrentEntityManager().getReference(RepositoryEntryLifecycle.class, lifecycle.getKey());
dbInstance.getCurrentEntityManager().remove(reloadedLifecycle);
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleDAO method create.
public RepositoryEntryLifecycle create(String label, String softKey, boolean privateCycle, Date from, Date to) {
RepositoryEntryLifecycle reLifeCycle = new RepositoryEntryLifecycle();
reLifeCycle.setCreationDate(new Date());
reLifeCycle.setLastModified(new Date());
reLifeCycle.setLabel(label);
reLifeCycle.setSoftKey(softKey);
reLifeCycle.setPrivateCycle(privateCycle);
reLifeCycle.setValidFrom(from);
reLifeCycle.setValidTo(to);
dbInstance.getCurrentEntityManager().persist(reLifeCycle);
return reLifeCycle;
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class LifecycleAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == createLifeCycle) {
doEdit(ureq, null);
} else if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete-lifecycle".equals(se.getCommand())) {
RepositoryEntryLifecycle row = model.getObject(se.getIndex());
doConfirmDelete(ureq, row);
} else if ("edit-lifecycle".equals(se.getCommand())) {
RepositoryEntryLifecycle row = model.getObject(se.getIndex());
doEdit(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryServiceImpl method isParticipantAllowedToLeave.
@Override
public boolean isParticipantAllowedToLeave(RepositoryEntry re) {
boolean allowed = false;
RepositoryEntryAllowToLeaveOptions setting = re.getAllowToLeaveOption();
if (setting == RepositoryEntryAllowToLeaveOptions.atAnyTime) {
allowed = true;
} else if (setting == RepositoryEntryAllowToLeaveOptions.afterEndDate) {
RepositoryEntryLifecycle lifecycle = re.getLifecycle();
if (lifecycle == null || lifecycle.getValidTo() == null) {
allowed = false;
} else {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date now = cal.getTime();
if (now.compareTo(lifecycle.getValidTo()) >= 0) {
allowed = true;
} else {
allowed = false;
}
}
} else {
allowed = false;
}
return allowed;
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleWebService method getPublicLifeCycles.
/**
* List all public lifecycles
* @response.representation.200.qname {http://www.example.com}repositoryEntryVO
* @response.representation.200.mediaType text/plain, text/html, application/xml, application/json
* @response.representation.200.doc List all entries in the repository
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_REPOENTRYVOes}
* @param uriInfo The URI information
* @param httpRequest The HTTP request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getPublicLifeCycles(@Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isInstitutionalResourceManager() && !roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
RepositoryEntryLifecycleDAO lifeCycleDao = CoreSpringFactory.getImpl(RepositoryEntryLifecycleDAO.class);
List<RepositoryEntryLifecycle> publicLifeCycles = lifeCycleDao.loadPublicLifecycle();
List<RepositoryEntryLifecycleVO> voList = new ArrayList<RepositoryEntryLifecycleVO>(publicLifeCycles.size());
for (RepositoryEntryLifecycle lifeCycle : publicLifeCycles) {
voList.add(new RepositoryEntryLifecycleVO(lifeCycle));
}
RepositoryEntryLifecycleVO[] voes = voList.toArray(new RepositoryEntryLifecycleVO[voList.size()]);
return Response.ok(voes).build();
}
Aggregations