Search in sources :

Example 56 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ACTransactionManagerTest method testSaveTransaction.

@Test
public void testSaveTransaction() {
    // pick up a method
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    assertNotNull(methods);
    assertEquals(1, methods.size());
    AccessMethod tokenMethod = methods.get(0);
    // create an offer to buy
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestSaveTransaction");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create and save an order
    Order order = acOrderManager.createOrder(ident1);
    OrderPart orderPart = acOrderManager.addOrderPart(order);
    OrderLine item = acOrderManager.addOrderLine(orderPart, offer);
    assertNotNull(order);
    assertNotNull(item);
    assertNotNull(order.getDelivery());
    assertEquals(ident1, order.getDelivery());
    acOrderManager.save(order);
    AccessTransaction accessTransaction = acTransactionManager.createTransaction(order, orderPart, tokenMethod);
    assertNotNull(accessTransaction);
    acTransactionManager.save(accessTransaction);
    dbInstance.commitAndCloseSession();
    {
        // test load by key
        AccessTransaction retrievedTransaction = acTransactionManager.loadTransactionByKey(accessTransaction.getKey());
        assertNotNull(retrievedTransaction);
        assertNotNull(retrievedTransaction.getOrder());
        assertEquals(order, retrievedTransaction.getOrder());
        assertNotNull(retrievedTransaction.getOrderPart());
        assertEquals(orderPart, retrievedTransaction.getOrderPart());
        assertNotNull(retrievedTransaction.getMethod());
        assertEquals(tokenMethod, retrievedTransaction.getMethod());
    }
    {
        // test load by order
        List<AccessTransaction> retrievedTransactions = acTransactionManager.loadTransactionsForOrder(order);
        assertNotNull(retrievedTransactions);
        assertEquals(1, retrievedTransactions.size());
        AccessTransaction retrievedTransaction = retrievedTransactions.get(0);
        assertNotNull(retrievedTransaction);
        assertNotNull(retrievedTransaction.getOrder());
        assertEquals(order, retrievedTransaction.getOrder());
        assertNotNull(retrievedTransaction.getOrderPart());
        assertEquals(orderPart, retrievedTransaction.getOrderPart());
        assertNotNull(retrievedTransaction.getMethod());
        assertEquals(tokenMethod, retrievedTransaction.getMethod());
    }
}
Also used : AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OLATResource(org.olat.resource.OLATResource) List(java.util.List) Test(org.junit.Test)

Example 57 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ACMethodManagerTest method testOfferAccess.

@Test
public void testOfferAccess() {
    // create a resource and an offer
    OLATResource randomOres = createResource();
    Offer offer = acService.createOffer(randomOres, "TestOfferAccess");
    offer = acService.save(offer);
    dbInstance.commitAndCloseSession();
    // create a link offer to method
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    assertNotNull(methods);
    assertEquals(1, methods.size());
    AccessMethod method = methods.get(0);
    OfferAccess access = acMethodManager.createOfferAccess(offer, method);
    acMethodManager.save(access);
    dbInstance.commitAndCloseSession();
    // retrieve the link
    List<OfferAccess> retrievedOfferAccess = acMethodManager.getOfferAccess(offer, true);
    assertNotNull(retrievedOfferAccess);
    assertEquals(1, retrievedOfferAccess.size());
    OfferAccess retrievedAccess = retrievedOfferAccess.get(0);
    assertNotNull(retrievedAccess);
    assertNotNull(retrievedAccess.getMethod());
    assertEquals(method, retrievedAccess.getMethod());
    assertNotNull(retrievedAccess.getOffer());
    Assert.assertEquals(offer, retrievedAccess.getOffer());
}
Also used : AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) FreeAccessMethod(org.olat.resource.accesscontrol.model.FreeAccessMethod) ShibbolethAutoAccessMethod(org.olat.shibboleth.manager.ShibbolethAutoAccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 58 with OLATResource

use of org.olat.resource.OLATResource 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;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResource(org.olat.resource.OLATResource)

Example 59 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ProjectBrokerCourseNode method cleanupOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#cleanupOnDelete(
 *      org.olat.course.ICourse)
 */
@Override
public void cleanupOnDelete(ICourse course) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
    Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, this);
    File fDropBox = new File(FolderConfig.getCanonicalRoot() + DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), this));
    if (fDropBox.exists()) {
        FileUtils.deleteDirsAndFiles(fDropBox, true, true);
    }
    File fReturnBox = new File(FolderConfig.getCanonicalRoot() + ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), this));
    if (fReturnBox.exists()) {
        FileUtils.deleteDirsAndFiles(fReturnBox, true, true);
    }
    File attachmentDir = new File(FolderConfig.getCanonicalRoot() + projectBrokerManager.getAttachmentBasePathRelToFolderRoot(course.getCourseEnvironment(), this));
    if (attachmentDir.exists()) {
        FileUtils.deleteDirsAndFiles(attachmentDir, true, true);
    }
    // Delete project-broker, projects and project-groups
    if (projectBrokerId != null) {
        projectBrokerManager.deleteProjectBroker(projectBrokerId, course.getCourseEnvironment(), this);
    }
    // Delete all properties...
    cpm.deleteNodeProperties(this, null);
    OLATResource resource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
    CoreSpringFactory.getImpl(TaskExecutorManager.class).delete(resource, getIdent());
}
Also used : TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) OLATResource(org.olat.resource.OLATResource) ProjectBrokerManager(org.olat.course.nodes.projectbroker.service.ProjectBrokerManager) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 60 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class GroupAssessmentController method doEditComment.

private void doEditComment(UserRequest ureq, AssessmentRow row) {
    removeAsListenerAndDispose(commentCalloutCtrl);
    OLATResource courseOres = courseEntry.getOlatResource();
    editCommentCtrl = new EditCommentController(ureq, getWindowControl(), courseOres, gtaNode, row);
    listenTo(editCommentCtrl);
    commentCalloutCtrl = new CloseableCalloutWindowController(ureq, getWindowControl(), editCommentCtrl.getInitialComponent(), row.getCommentEditLink().getFormDispatchId(), "", true, "");
    listenTo(commentCalloutCtrl);
    commentCalloutCtrl.activate();
}
Also used : CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) OLATResource(org.olat.resource.OLATResource)

Aggregations

OLATResource (org.olat.resource.OLATResource)706 Test (org.junit.Test)304 RepositoryEntry (org.olat.repository.RepositoryEntry)198 Identity (org.olat.core.id.Identity)170 File (java.io.File)80 Date (java.util.Date)72 Feed (org.olat.modules.webFeed.Feed)72 ArrayList (java.util.ArrayList)64 ICourse (org.olat.course.ICourse)64 RepositoryService (org.olat.repository.RepositoryService)62 OLATResourceable (org.olat.core.id.OLATResourceable)60 BusinessGroup (org.olat.group.BusinessGroup)58 Item (org.olat.modules.webFeed.Item)44 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)38 OLATResourceManager (org.olat.resource.OLATResourceManager)34 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)34 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)30 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)30 FreeAccessMethod (org.olat.resource.accesscontrol.model.FreeAccessMethod)28 Group (org.olat.basesecurity.Group)26