use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class InfoMessagesWebService method createEmptyCourse.
/**
* Creates a new info message
* @response.representation.200.qname {http://www.example.com}infoMessageVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The info message
* @response.representation.200.example {@link org.olat.commons.info.restapi.Examples#SAMPLE_INFOMESSAGEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param resName The OLAT Resourceable name
* @param resId The OLAT Resourceable id
* @param resSubPath The resource sub path (optional)
* @param businessPath The business path
* @param authorKey The identity key of the author
* @param title The title
* @param message The message
* @param request The HTTP request
* @return It returns the id of the newly info message
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createEmptyCourse(@QueryParam("resName") final String resName, @QueryParam("resId") final Long resId, @QueryParam("resSubPath") String resSubPath, @QueryParam("businessPath") String businessPath, @QueryParam("authorKey") Long authorKey, @QueryParam("title") String title, @QueryParam("message") String message, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
OLATResourceable ores = new OLATResourceable() {
@Override
public String getResourceableTypeName() {
return resName;
}
@Override
public Long getResourceableId() {
return resId;
}
};
Identity author;
UserRequest ureq = getUserRequest(request);
if (authorKey == null) {
author = ureq.getIdentity();
} else {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
author = securityManager.loadIdentityByKey(authorKey, false);
if (author == null) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.createInfoMessage(ores, resSubPath, businessPath, author);
msg.setTitle(title);
msg.setMessage(message);
messageManager.sendInfoMessage(msg, null, ureq.getLocale(), ureq.getIdentity(), Collections.<Identity>emptyList());
InfoMessageVO infoVO = new InfoMessageVO(msg);
return Response.ok(infoVO).build();
}
use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class InfoDisplayController method loadMessages.
/**
* This is the main method which push the messages in the layout container,
* and clean-up old links.
*/
protected void loadMessages() {
// first clear the current message if any
for (Long key : previousDisplayKeys) {
flc.contextRemove("info.date." + key);
if (flc.getComponent("info.delete." + key) != null) {
flc.remove("info.delete." + key);
}
if (flc.getComponent("info.edit." + key) != null) {
flc.remove("info.edit." + key);
}
}
previousDisplayKeys.clear();
deleteLinks.clear();
List<InfoMessage> msgs = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, businessPath, after, null, 0, maxResults);
List<InfoMessageForDisplay> infoDisplays = new ArrayList<>(msgs.size());
Map<Long, VFSLeaf> keyToDisplay = new HashMap<>();
for (InfoMessage info : msgs) {
previousDisplayKeys.add(info.getKey());
InfoMessageForDisplay infoDisplay = createInfoMessageForDisplay(info);
infoDisplays.add(infoDisplay);
if (infoDisplay.getAttachment() != null) {
keyToDisplay.put(info.getKey(), infoDisplay.getAttachment());
}
String dateCmpName = "info.date." + info.getKey();
DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
flc.add(dateCmpName, dateEl);
if (secCallback.canEdit(info)) {
String editName = "info.edit." + info.getKey();
FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_edit_msg");
link.setUserObject(info);
editLinks.add(link);
flc.add(link);
}
if (secCallback.canDelete()) {
String delName = "info.delete." + info.getKey();
FormLink link = uifactory.addFormLink(delName, "delete", "delete", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_delete_msg");
link.setUserObject(info);
deleteLinks.add(link);
flc.add(link);
}
}
flc.contextPut("infos", infoDisplays);
infoKeyToAttachment = keyToDisplay;
int numOfInfos = infoMessageManager.countInfoMessageByResource(ores, resSubPath, businessPath, null, null);
oldMsgsLink.setVisible((msgs.size() < numOfInfos));
newMsgsLink.setVisible((msgs.size() == numOfInfos) && (numOfInfos > maxResultsConfig) && (maxResultsConfig > 0));
}
use of org.olat.commons.info.InfoMessage in project openolat by klemens.
the class InfoPeekViewController method init.
private void init(UserRequest ureq) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("peekview.noInfos"));
tableConfig.setDisplayTableHeader(false);
tableConfig.setCustomCssClass("o_portlet_table");
tableConfig.setDisplayRowCount(false);
tableConfig.setPageingEnabled(false);
tableConfig.setDownloadOffered(false);
tableConfig.setSortingEnabled(false);
removeAsListenerAndDispose(tableController);
tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("peekview.title", 0, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new InfoNodeRenderer()));
String resSubPath = courseNode.getIdent();
List<InfoMessage> infos = infoService.loadInfoMessageByResource(ores, resSubPath, null, null, null, 0, 5);
InfosTableModel model = new InfosTableModel(infos);
tableController.setTableDataModel(model);
listenTo(tableController);
}
use of org.olat.commons.info.InfoMessage in project openolat by klemens.
the class InfoDisplayController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == newInfoLink) {
InfoMessage msg = infoMessageManager.createInfoMessage(ores, resSubPath, businessPath, getIdentity());
start = new CreateInfoStep(ureq, sendMailOptions, msg);
newInfoWizard = new StepsMainRunController(ureq, getWindowControl(), start, new FinishedCallback(), new CancelCallback(), translate("create_message"), "o_sel_info_messages_create_wizard");
listenTo(newInfoWizard);
getWindowControl().pushAsModalDialog(newInfoWizard.getInitialComponent());
} else if (deleteLinks.contains(source)) {
InfoMessage msg = (InfoMessage) source.getUserObject();
popupDelete(ureq, msg);
} else if (editLinks.contains(source)) {
InfoMessage msg = (InfoMessage) source.getUserObject();
popupEdit(ureq, msg);
} else if (source == oldMsgsLink) {
maxResults = -1;
after = null;
loadMessages();
} else if (source == newMsgsLink) {
maxResults = maxResultsConfig;
after = afterConfig;
loadMessages();
} else {
super.formInnerEvent(ureq, source, event);
}
}
use of org.olat.commons.info.InfoMessage in project openolat by klemens.
the class InfoDisplayController method loadMessages.
/**
* This is the main method which push the messages in the layout container,
* and clean-up old links.
*/
protected void loadMessages() {
// first clear the current message if any
for (Long key : previousDisplayKeys) {
flc.contextRemove("info.date." + key);
if (flc.getComponent("info.delete." + key) != null) {
flc.remove("info.delete." + key);
}
if (flc.getComponent("info.edit." + key) != null) {
flc.remove("info.edit." + key);
}
}
previousDisplayKeys.clear();
deleteLinks.clear();
List<InfoMessage> msgs = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, businessPath, after, null, 0, maxResults);
List<InfoMessageForDisplay> infoDisplays = new ArrayList<>(msgs.size());
Map<Long, VFSLeaf> keyToDisplay = new HashMap<>();
for (InfoMessage info : msgs) {
previousDisplayKeys.add(info.getKey());
InfoMessageForDisplay infoDisplay = createInfoMessageForDisplay(info);
infoDisplays.add(infoDisplay);
if (infoDisplay.getAttachment() != null) {
keyToDisplay.put(info.getKey(), infoDisplay.getAttachment());
}
String dateCmpName = "info.date." + info.getKey();
DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
flc.add(dateCmpName, dateEl);
if (secCallback.canEdit(info)) {
String editName = "info.edit." + info.getKey();
FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_edit_msg");
link.setUserObject(info);
editLinks.add(link);
flc.add(link);
}
if (secCallback.canDelete()) {
String delName = "info.delete." + info.getKey();
FormLink link = uifactory.addFormLink(delName, "delete", "delete", flc, Link.BUTTON_SMALL);
link.setElementCssClass("o_sel_info_delete_msg");
link.setUserObject(info);
deleteLinks.add(link);
flc.add(link);
}
}
flc.contextPut("infos", infoDisplays);
infoKeyToAttachment = keyToDisplay;
int numOfInfos = infoMessageManager.countInfoMessageByResource(ores, resSubPath, businessPath, null, null);
oldMsgsLink.setVisible((msgs.size() < numOfInfos));
newMsgsLink.setVisible((msgs.size() == numOfInfos) && (numOfInfos > maxResultsConfig) && (maxResultsConfig > 0));
}
Aggregations