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());
}
}
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());
}
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;
}
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());
}
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();
}
Aggregations