use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class PortfolioMapDocument method getContent.
private static String getContent(PortfolioStructure map, SearchResourceContext resourceContext, StringBuilder sb, Filter filter) {
sb.append(' ').append(map.getTitle());
if (StringHelper.containsNonWhitespace(map.getDescription())) {
sb.append(' ').append(filter.filter(map.getDescription()));
}
for (PortfolioStructure child : ePFMgr.loadStructureChildren(map)) {
getContent(child, resourceContext, sb, filter);
}
for (AbstractArtefact artefact : ePFMgr.getArtefacts(map)) {
String reflexion = artefact.getReflexion();
if (StringHelper.containsNonWhitespace(reflexion)) {
sb.append(' ').append(filter.filter(reflexion));
}
OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
SearchResourceContext artefactResourceContext = new SearchResourceContext(resourceContext);
artefactResourceContext.setBusinessControlFor(ores);
OlatDocument doc = handler.getIndexerDocument(artefactResourceContext, artefact, ePFMgr);
sb.append(' ').append(doc.getContent());
}
return sb.toString();
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class AbstractHierarchicalIndexer method checkAccess.
/**
* @param businessControl
* @param identity
* @param roles
* @return
*/
public boolean checkAccess(BusinessControl businessControl, Identity identity, Roles roles) {
boolean debug = isLogDebugEnabled();
if (debug)
logDebug("checkAccess for businessControl=" + businessControl + " identity=" + identity + " roles=" + roles);
ContextEntry contextEntry = businessControl.popLauncherContextEntry();
if (contextEntry != null) {
// there is an other context-entry => go further
OLATResourceable ores = contextEntry.getOLATResourceable();
String type = ores.getResourceableTypeName();
List<Indexer> indexers = getIndexerByType(type);
if (indexers.isEmpty()) {
// loop in child-indexers to check access for businesspath not stacked as on index-run
for (Indexer childIndexer : childIndexers) {
List<Indexer> foundSubChildIndexers = childIndexer instanceof AbstractHierarchicalIndexer ? ((AbstractHierarchicalIndexer) childIndexer).getIndexerByType(type) : null;
if (foundSubChildIndexers != null) {
if (debug)
logDebug("took a childindexer for ores= " + ores + " not directly linked (means businesspath is not the same stack as indexer -> childindexer). type= " + type + " . indexer parent-type not on businesspath=" + childIndexer.getSupportedTypeName());
for (Indexer foundSubChildIndexer : foundSubChildIndexers) {
boolean allow = foundSubChildIndexer.checkAccess(contextEntry, businessControl, identity, roles) && super.checkAccess(contextEntry, businessControl, identity, roles);
if (allow) {
return true;
}
}
}
}
if (debug)
logDebug("could not find an indexer for type=" + type + " businessControl=" + businessControl + " identity=" + identity, null);
} else {
for (Indexer indexer : indexers) {
boolean allow = indexer.checkAccess(contextEntry, businessControl, identity, roles) && super.checkAccess(contextEntry, businessControl, identity, roles);
if (allow) {
return true;
}
}
}
return false;
} else {
// rearch the end context entry list
return super.checkAccess(contextEntry, businessControl, identity, roles);
}
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method createCheckBox.
@Test
public void createCheckBox() {
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-1", 2345l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId = UUID.randomUUID().toString();
DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
dbInstance.commit();
Assert.assertNotNull(checkbox);
Assert.assertNotNull(checkbox.getKey());
Assert.assertNotNull(checkbox.getCreationDate());
Assert.assertEquals(checkboxId, checkbox.getCheckboxId());
Assert.assertEquals("checkbox-1", checkbox.getResName());
Assert.assertEquals(new Long(2345l), checkbox.getResId());
Assert.assertEquals(resSubPath, checkbox.getResSubPath());
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method loadCheck.
@Test
public void loadCheck() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-2");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-6", 2350l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId = UUID.randomUUID().toString();
DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
// create a check
DBCheck check = checkboxManager.createCheck(checkbox, id, new Float(1.0), Boolean.TRUE);
dbInstance.commitAndCloseSession();
// load the check
DBCheck loadedCheck = checkboxManager.loadCheck(checkbox, id);
// paranoia check
Assert.assertNotNull(loadedCheck);
Assert.assertEquals(check, loadedCheck);
Assert.assertEquals(id, loadedCheck.getIdentity());
Assert.assertEquals(checkbox, loadedCheck.getCheckbox());
Assert.assertEquals(Boolean.TRUE, loadedCheck.getChecked());
Assert.assertEquals(1.0f, loadedCheck.getScore().floatValue(), 0.00001);
}
use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.
the class InstantMessageDAOTest method testLoadMessage_byId.
@Test
public void testLoadMessage_byId() {
// create a message
OLATResourceable chatResources = OresHelper.createOLATResourceableInstance("unit-test-2-" + UUID.randomUUID().toString(), System.currentTimeMillis());
Identity id = JunitTestHelper.createAndPersistIdentityAsAdmin("im-2-" + UUID.randomUUID().toString());
InstantMessage msg = imDao.createMessage(id, id.getName(), false, "Hello load by id", chatResources);
Assert.assertNotNull(msg);
dbInstance.commitAndCloseSession();
// load the message
InstantMessage reloadedMsg = imDao.loadMessageById(msg.getKey());
Assert.assertNotNull(reloadedMsg);
Assert.assertEquals(msg.getKey(), reloadedMsg.getKey());
Assert.assertEquals("Hello load by id", reloadedMsg.getBody());
}
Aggregations