Search in sources :

Example 26 with RepositoryEntryLifecycle

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);
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle)

Example 27 with RepositoryEntryLifecycle

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;
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Date(java.util.Date)

Example 28 with RepositoryEntryLifecycle

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);
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Example 29 with RepositoryEntryLifecycle

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;
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) Date(java.util.Date)

Example 30 with RepositoryEntryLifecycle

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();
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) ArrayList(java.util.ArrayList) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryEntryLifecycleVO(org.olat.restapi.support.vo.RepositoryEntryLifecycleVO) RepositoryEntryLifecycleDAO(org.olat.repository.manager.RepositoryEntryLifecycleDAO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RepositoryEntryLifecycle (org.olat.repository.model.RepositoryEntryLifecycle)54 Date (java.util.Date)34 Test (org.junit.Test)22 Calendar (java.util.Calendar)18 ArrayList (java.util.ArrayList)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 List (java.util.List)6 Identity (org.olat.core.id.Identity)6 RepositoryEntryLifecycleVO (org.olat.restapi.support.vo.RepositoryEntryLifecycleVO)6 Produces (javax.ws.rs.Produces)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 ICourse (org.olat.course.ICourse)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 RepositoryEntryLifecycleDAO (org.olat.repository.manager.RepositoryEntryLifecycleDAO)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)3 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)3 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2