use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class CourseEditorTreeModel method insertCourseNodeAt.
/**
* @param newNode
* @param parentNode
* @param pos
*/
public CourseEditorTreeNode insertCourseNodeAt(CourseNode newNode, CourseNode parentNode, int pos) {
// update editor tree model
CourseEditorTreeNode ctnParent = (CourseEditorTreeNode) getNodeById(parentNode.getIdent());
if (ctnParent == null)
throw new AssertException("Corrupt CourseEditorTreeModel.");
CourseEditorTreeNode newCetn = new CourseEditorTreeNode(newNode);
newCetn.setNewnode(true);
newCetn.setDirty(true);
ctnParent.insert(newCetn, pos);
log.debug("insertCourseNodeAt - nodeId: " + newNode.getIdent());
return newCetn;
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class CourseEditorTreeModel method markUnDeleted.
/**
* marks an couse node and all it's children as undeleted
* @param courseNode
*/
public void markUnDeleted(CourseNode courseNode) {
CourseEditorTreeNode cetNode = (CourseEditorTreeNode) getNodeById(courseNode.getIdent());
if (cetNode == null)
throw new AssertException("Corrupt CourseEditorTreeModel.");
markUnDeleted(cetNode);
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class StatisticUpdateManagerImpl method updateStatistics.
@Override
public boolean updateStatistics(final boolean fullRecalculation, final Runnable finishedCallback) {
synchronized (this) {
if (!enabled_) {
log_.warn("updateStatistics: cannot update statistics, manager is not enabled!", new Exception("updateStatistics"));
return false;
}
if (updateOngoing_) {
log_.warn("updateStatistics: cannot update statistics since an update is currently ongoing");
return false;
}
updateOngoing_ = true;
}
Runnable r = new Runnable() {
@Override
public void run() {
final long start = System.currentTimeMillis();
try {
log_.info("updateStatistics: initialization for update");
long nowInMilliseconds = System.currentTimeMillis();
long lastUpdatedInMilliseconds = getAndUpdateLastUpdated(nowInMilliseconds);
if (fullRecalculation || (lastUpdatedInMilliseconds == -1)) {
Calendar nineteennintyeight = Calendar.getInstance();
nineteennintyeight.set(1998, 12, 31);
lastUpdatedInMilliseconds = nineteennintyeight.getTimeInMillis();
}
Date lastUpdatedDate = new Date(lastUpdatedInMilliseconds);
Date nowDate = new Date(nowInMilliseconds);
log_.info("updateStatistics: starting the update");
DBFactory.getInstance().intermediateCommit();
for (Iterator<IStatisticUpdater> it = updaters_.iterator(); it.hasNext(); ) {
IStatisticUpdater statisticUpdater = it.next();
log_.info("updateStatistics: starting updater " + statisticUpdater);
statisticUpdater.updateStatistic(fullRecalculation || (lastUpdatedInMilliseconds == -1), lastUpdatedDate, nowDate, StatisticUpdateManagerImpl.this);
log_.info("updateStatistics: done with updater " + statisticUpdater);
DBFactory.getInstance().intermediateCommit();
}
} finally {
synchronized (StatisticUpdateManagerImpl.this) {
updateOngoing_ = false;
}
final long diff = System.currentTimeMillis() - start;
log_.info("updateStatistics: total time for updating all statistics was " + diff + " milliseconds");
if (finishedCallback != null) {
finishedCallback.run();
}
}
}
};
try {
taskExecutorManager.execute(r);
log_.info("updateStatistics: starting the update in its own thread");
return true;
} catch (AssertException ae) {
log_.info("updateStatistics: Could not start update due to TaskExecutorManager not yet initialized. Will be done next time Cron/User calls!");
synchronized (StatisticUpdateManagerImpl.this) {
updateOngoing_ = false;
}
return false;
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class Response_label method render.
/**
* @see org.olat.ims.qti.container.qtielements.QTIElement#render(StringBuilder,
* RenderInstructions)
*/
@Override
public void render(StringBuilder buffer, RenderInstructions ri) {
ItemInput iinput = (ItemInput) ri.get(RenderInstructions.KEY_ITEM_INPUT);
String responseIdent = (String) ri.get(RenderInstructions.KEY_RESPONSE_IDENT);
// find parent render_xxx element
String renderClass = (String) ri.get(RenderInstructions.KEY_RENDER_CLASS);
if (renderClass == null) {
// we don't know what to do
} else if (renderClass.equals("choice")) {
renderChoice(buffer, ri, iinput);
} else if (renderClass.equals("kprim")) {
buffer.append("<tr><td class='o_qti_item_kprim_input'><input id=\"QTI_").append(ri.get(RenderInstructions.KEY_ITEM_IDENT)).append(getQTIIdent()).append("\" type=\"radio\" class=\"radio\" name=\"");
appendParameterIdent(buffer, ri);
buffer.append("\" value=\"" + getQTIIdent() + ":correct");
if (iinput != null && !iinput.isEmpty()) {
List<String> responses = iinput.getAsList(responseIdent);
if (responses != null && responses.contains(getQTIIdent() + ":correct"))
buffer.append("\" checked=\"checked");
}
buffer.append("\" onchange=\"return setFormDirty('ofo_iq_item')\" onclick=\"return setFormDirty('ofo_iq_item')\"/>");
buffer.append("</td><td class='o_qti_item_kprim_input'><input id=\"QTI_").append(ri.get(RenderInstructions.KEY_ITEM_IDENT)).append(getQTIIdent()).append("\" type=\"radio\" class=\"radio\" name=\"");
appendParameterIdent(buffer, ri);
buffer.append("\" value=\"" + getQTIIdent() + ":wrong");
if (iinput != null && !iinput.isEmpty()) {
List<String> responses = iinput.getAsList(responseIdent);
if (responses != null && responses.contains(getQTIIdent() + ":wrong"))
buffer.append("\" checked=\"checked");
}
buffer.append("\" onchange=\"return setFormDirty('ofo_iq_item')\" onclick=\"return setFormDirty('ofo_iq_item')\"/>");
buffer.append("</td><td>");
super.render(buffer, ri);
buffer.append("</td></tr>");
ri.put(RenderInstructions.KEY_FLOW_LABEL, new Integer(RenderInstructions.RENDER_FLOW_BLOCK));
addBr(ri, buffer);
} else if (renderClass.equals("fib")) {
Integer rows = (Integer) ri.get(RenderInstructions.KEY_FIB_ROWS);
Integer columns = (Integer) ri.get(RenderInstructions.KEY_FIB_COLUMNS);
Integer maxlength = (Integer) ri.get(RenderInstructions.KEY_FIB_MAXLENGTH);
if (rows == null || columns == null || maxlength == null)
throw new AssertException("Rows and/or columns attribute not specified for render_fib.");
if (rows.intValue() > 1) {
// render as textarea
buffer.append("<textarea id=\"QTI_").append(getQTIIdent()).append("\" name=\"");
appendParameterIdent(buffer, ri);
buffer.append("\" class='form-control' rows=\"").append(rows).append("\" cols=\"").append(columns).append("\" onchange=\"return setFormDirty('ofo_iq_item')\" onclick=\"return setFormDirty('ofo_iq_item')\">");
if (iinput != null && !iinput.isEmpty() && iinput.getSingle(responseIdent) != null) {
buffer.append(iinput.getSingle(getQTIIdent()));
}
buffer.append("</textarea>");
} else {
// render as input string
buffer.append("<span> </span><input id=\"QTI_").append(getQTIIdent()).append("\" name=\"");
appendParameterIdent(buffer, ri);
buffer.append("\" type=\"text\" size=\"").append(columns).append("\" maxlength=\"").append(maxlength);
if (iinput != null && !iinput.isEmpty() && iinput.getSingle(responseIdent) != null) {
buffer.append("\" value=\"").append(StringHelper.escapeHtml(iinput.getSingle(getQTIIdent())));
}
buffer.append("\" onchange=\"return setFormDirty('ofo_iq_item')\" onclick=\"return setFormDirty('ofo_iq_item')\" /><span> </span>");
}
addBr(ri, buffer);
}
}
use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method filterArtefactsByDate.
/**
* date comparison will first set startDate to 00:00:00 and set endDate to
* 23:59:59 else there might be no results if start = end date. dateList must
* be set according to: dateList(0) = startDate dateList(1) = endDate
*/
private void filterArtefactsByDate(List<AbstractArtefact> artefacts, List<Date> dateList) {
if (dateList != null && dateList.size() != 0) {
if (dateList.size() == 2) {
Date startDate = dateList.get(0);
Date endDate = dateList.get(1);
Calendar cal = Calendar.getInstance();
if (startDate == null) {
cal.set(1970, 1, 1);
} else {
cal.setTime(startDate);
}
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
startDate = cal.getTime();
cal.setTime(endDate);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
endDate = cal.getTime();
List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
for (AbstractArtefact artefact : artefacts) {
Date creationDate = artefact.getCreationDate();
if (!(creationDate.before(endDate) && creationDate.after(startDate))) {
toRemove.add(artefact);
}
}
artefacts.removeAll(toRemove);
} else
throw new AssertException("provided DateList must contain exactly two Date-objects");
}
}
Aggregations