use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveAssessmentID.
/**
* @param courseNode
* @param assessedIdentity
* @param assessmentID
* @param coursePropManager
*/
void saveAssessmentID(CourseNode courseNode, Identity assessedIdentity, Long assessmentID, CoursePropertyManager coursePropManager) {
if (assessmentID != null) {
Property assessmentIDProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, ASSESSMENT_ID);
if (assessmentIDProperty == null) {
assessmentIDProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ASSESSMENT_ID, null, assessmentID, null, null);
coursePropManager.saveProperty(assessmentIDProperty);
} else {
assessmentIDProperty.setLongValue(assessmentID);
coursePropManager.updateProperty(assessmentIDProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, assessmentIDProperty);
}
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveNodeComment.
/**
* @see org.olat.course.assessment.AssessmentManager#saveNodeComment(org.olat.course.nodes.CourseNode,
* org.olat.core.id.Identity, org.olat.core.id.Identity,
* java.lang.String)
*/
public void saveNodeComment(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final String comment) {
ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {
public void execute() {
Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COMMENT);
if (commentProperty == null) {
commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COMMENT, null, null, null, comment);
cpm.saveProperty(commentProperty);
} else {
commentProperty.setTextValue(comment);
cpm.updateProperty(commentProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, commentProperty);
}
});
// node log
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, COMMENT + " set to: " + comment);
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_8_1_0 method getEfficiencyStatement.
private List<Property> getEfficiencyStatement(int firstResult) {
StringBuilder query = new StringBuilder();
query.append("select p from ").append(Property.class.getName()).append(" as p ");
query.append(" where p.category='efficiencyStatement' order by p.key");
DBQuery dbQuery = dbInstance.createQuery(query.toString());
dbQuery.setFirstResult(firstResult);
dbQuery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
@SuppressWarnings("unchecked") List<Property> props = dbQuery.list();
return props;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_9_4_0 method upgradeDisplayMembers.
private boolean upgradeDisplayMembers(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_DISPLAY_MEMBERS)) {
int counter = 0;
List<BusinessGroupImpl> groups;
do {
groups = findGroups(counter, BATCH_SIZE);
for (BusinessGroupImpl group : groups) {
Property prop = findProperty(group);
if (prop != null) {
boolean changed = false;
Long internValue = prop.getLongValue();
if (internValue != null && internValue.longValue() > 0) {
long value = internValue.longValue();
boolean owners = (value & showOwnersVal) == showOwnersVal;
boolean participants = (value & showPartipsVal) == showPartipsVal;
boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
group.setOwnersVisibleIntern(owners);
group.setParticipantsVisibleIntern(participants);
group.setWaitingListVisibleIntern(waiting);
changed = true;
}
String publicValue = prop.getStringValue();
if (publicValue != null && publicValue.length() > 0 && Character.isDigit(publicValue.toCharArray()[0])) {
try {
int value = Integer.parseInt(publicValue);
boolean owners = (value & showOwnersVal) == showOwnersVal;
boolean participants = (value & showPartipsVal) == showPartipsVal;
boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
group.setOwnersVisiblePublic(owners);
group.setParticipantsVisiblePublic(participants);
group.setWaitingListVisiblePublic(waiting);
} catch (NumberFormatException e) {
log.error("", e);
}
changed = true;
}
Float downloadValue = prop.getFloatValue();
if (downloadValue != null && downloadValue != 0.0f) {
float value = downloadValue.floatValue();
// paranoid check
if (value > 0.9 && value < 1.1) {
group.setDownloadMembersLists(true);
changed = true;
} else if (value < -0.9 && value > -1.1) {
group.setDownloadMembersLists(true);
changed = true;
}
}
if (changed) {
prop.setCategory("configMoved");
dbInstance.getCurrentEntityManager().merge(group);
}
}
}
counter += groups.size();
log.audit("Business groups processed: " + groups.size());
dbInstance.commitAndCloseSession();
} while (groups.size() == BATCH_SIZE);
uhd.setBooleanDataValue(TASK_DISPLAY_MEMBERS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class CustomDBController method addCustomDb.
private void addCustomDb(final String category) {
final ICourse course = CourseFactory.loadCourse(courseKey);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(course, new SyncerExecutor() {
@Override
public void execute() {
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
if (p == null) {
p = cpm.createCourseNodePropertyInstance(rootNode, null, null, CustomDBMainController.CUSTOM_DB, null, null, null, category);
cpm.saveProperty(p);
} else {
String currentDbs = p.getTextValue();
p.setTextValue(currentDbs + ":" + category);
cpm.updateProperty(p);
}
}
});
}
Aggregations