use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectDetailsDisplayController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (projectBrokerManager.existsProject(project.getKey())) {
if (source == editProjectButton) {
fireEvent(ureq, new Event("switchToEditMode"));
} else if (source == deleteProjectButton) {
OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey());
this.lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(projectOres, ureq.getIdentity(), null);
if (lock.isSuccess()) {
deleteConfirmController = activateOkCancelDialog(ureq, null, translate("delete.confirm", project.getTitle()), deleteConfirmController);
} else {
this.showInfo("info.project.already.edit", project.getTitle());
}
return;
} else if (event.getCommand().equals(CMD_OPEN_PROJECT_LEADER_DETAIL)) {
if (source instanceof Link) {
Link projectLeaderLink = (Link) source;
final Identity identity = (Identity) projectLeaderLink.getUserObject();
ControllerCreator ctrlCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new UserInfoMainController(lureq, lwControl, identity, true, false);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
this.openInNewBrowserWindow(ureq, layoutCtrlr);
}
} else if (source == attachedFileLink) {
doFileDelivery(ureq, project, courseEnv, courseNode);
} else if (source == changeProjectStateToNotAssignButton) {
projectBrokerManager.setProjectState(project, Project.STATE_NOT_ASSIGNED);
myContent.remove(changeProjectStateToNotAssignButton);
changeProjectStateToAssignButton = LinkFactory.createButtonSmall("change.project.state.assign.button", myContent, this);
} else if (source == changeProjectStateToAssignButton) {
projectBrokerManager.setProjectState(project, Project.STATE_ASSIGNED);
myContent.remove(changeProjectStateToAssignButton);
changeProjectStateToNotAssignButton = LinkFactory.createButtonSmall("change.project.state.not_assign.button", myContent, this);
}
} else {
this.showInfo("info.project.nolonger.exist", project.getTitle());
}
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectEditDetailsFormController method initForm.
/**
* Initialize form.
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// create form elements
projectTitle = uifactory.addTextElement("title", "detailsform.title.label", 100, project.getTitle(), formLayout);
// account-Managers
StringBuilder projectLeaderString = new StringBuilder();
for (Iterator<Identity> iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
Identity identity = iterator.next();
String last = identity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
if (projectLeaderString.length() > 0) {
projectLeaderString.append(",");
}
projectLeaderString.append(first);
projectLeaderString.append(" ");
projectLeaderString.append(last);
}
projectLeaders = uifactory.addTextElement("projectleaders", "detailsform.projectleaders.label", 100, projectLeaderString.toString(), formLayout);
projectLeaders.setEnabled(false);
// add the learning objectives rich text input element
projectDescription = uifactory.addRichTextElementForStringData("description", "detailsform.description.label", project.getDescription(), 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
projectDescription.setMaxLength(2500);
stateLayout = FormLayoutContainer.createHorizontalFormLayout("stateLayout", getTranslator());
stateLayout.setLabel("detailsform.state.label", null);
formLayout.add(stateLayout);
String stateValue = getTranslator().translate(projectBrokerManager.getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
projectState = uifactory.addStaticTextElement("detailsform.state", stateValue + " ", stateLayout);
projectState.setLabel(null, null);
String keyDetailsformMax = null;
if (projectBrokerModuleConfiguration.isAcceptSelectionManually()) {
keyDetailsformMax = "detailsform.max.candidates.label";
} else {
keyDetailsformMax = "detailsform.max.members.label";
}
selectionMaxMembers = uifactory.addCheckboxesHorizontal(keyDetailsformMax, formLayout, keys, values);
maxMembers = uifactory.addIntegerElement("form.options.number.of.participants.per.topic_nbr", project.getMaxMembers(), formLayout);
maxMembers.setMinValueCheck(0, null);
maxMembers.setDisplaySize(3);
if (project.getMaxMembers() == Project.MAX_MEMBERS_UNLIMITED) {
maxMembers.setVisible(false);
selectionMaxMembers.select(keys[0], false);
} else {
selectionMaxMembers.select(keys[0], true);
}
selectionMaxMembers.addActionListener(FormEvent.ONCLICK);
String[] deselectValues = new String[] { translate("detailsform.allow.deselection.hint") };
allowDeselection = uifactory.addCheckboxesHorizontal("detailsform.allow.deselection", formLayout, keys, deselectValues);
allowDeselection.select(keys[0], projectGroupManager.isDeselectionAllowed(project));
allowDeselection.addActionListener(FormEvent.ONCLICK);
uifactory.addSpacerElement("spacer_1", formLayout, false);
// customfields
List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
int customFieldIndex = 0;
for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext(); ) {
CustomField customField = iterator.next();
getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
StringTokenizer tok = new StringTokenizer(customField.getValue(), ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
if (customField.getValue() == null || customField.getValue().equals("") || !tok.hasMoreTokens()) {
// no value define => Text-input
// Add StaticTextElement as workaroung for non translated label
// null > no label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
TextElement textElement = uifactory.addTextElement("customField_" + customFieldIndex, "", 150, project.getCustomFieldValue(customFieldIndex), formLayout);
textElement.setDisplaySize(60);
// textElement.setTranslator(null);
// textElement.setLabel(customField.getName(), null);
textElement.showLabel(false);
customfieldElementList.add(textElement);
} else {
// values define => dropdown selection
List<String> valueList = new ArrayList<String>();
while (tok.hasMoreTokens()) {
String value = tok.nextToken();
valueList.add(value);
getLogger().debug("valueList add: " + value);
}
String[] theValues = new String[valueList.size() + 1];
String[] theKeys = new String[valueList.size() + 1];
int arrayIndex = 0;
theValues[arrayIndex] = translate(DROPDOWN_NO_SELECETION);
theKeys[arrayIndex] = DROPDOWN_NO_SELECETION;
arrayIndex++;
for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext(); ) {
String value = iterator2.next();
theValues[arrayIndex] = value;
theKeys[arrayIndex] = Integer.toString(arrayIndex);
arrayIndex++;
}
// Add StaticTextElement as workaround for non translated label
// null > no label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
SingleSelection selectionElement = uifactory.addDropdownSingleselect("customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
if (project.getCustomFieldValue(customFieldIndex) != null && !project.getCustomFieldValue(customFieldIndex).equals("")) {
if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
// '+1' because no-selection at the beginning
String key = Integer.toString(valueList.indexOf(project.getCustomFieldValue(customFieldIndex)) + 1);
selectionElement.select(key, true);
} else {
this.showInfo("warn.customfield.key.does.not.exist", project.getCustomFieldValue(customFieldIndex));
}
}
customfieldElementList.add(selectionElement);
}
uifactory.addSpacerElement("customField_spacer" + customFieldIndex, formLayout, false);
customFieldIndex++;
}
// Events
for (Project.EventType eventType : Project.EventType.values()) {
if (projectBrokerModuleConfiguration.isProjectEventEnabled(eventType)) {
ProjectEvent projectEvent = project.getProjectEvent(eventType);
DateChooser dateChooserStart = uifactory.addDateChooser(eventType + "start", eventType.getI18nKey() + ".start.label", null, formLayout);
dateChooserStart.setDateChooserTimeEnabled(true);
dateChooserStart.setDisplaySize(CUSTOM_DATE_FORMAT.length());
getLogger().info("Event=" + eventType + ", startDate=" + projectEvent.getStartDate());
dateChooserStart.setDate(projectEvent.getStartDate());
eventStartElementList.put(eventType, dateChooserStart);
DateChooser dateChooserEnd = uifactory.addDateChooser(eventType + "end", eventType.getI18nKey() + ".end.label", null, formLayout);
dateChooserEnd.setDateChooserTimeEnabled(true);
dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
getLogger().debug("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
dateChooserEnd.setDate(projectEvent.getEndDate());
eventEndElementList.put(eventType, dateChooserEnd);
uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
}
}
attachmentFileName = uifactory.addFileElement(getWindowControl(), "detailsform.attachmentfilename.label", formLayout);
attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
removeAttachmentLink = uifactory.addFormLink("detailsform.remove.attachment", formLayout, Link.BUTTON_XSMALL);
}
attachmentFileName.addActionListener(FormEvent.ONCHANGE);
mailNotification = uifactory.addCheckboxesHorizontal("detailsform.mail.notification.label", formLayout, keys, values);
mailNotification.select(keys[0], project.isMailNotificationEnabled());
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
formLayout.add(buttonGroupLayout);
uifactory.addFormSubmitButton("save", buttonGroupLayout);
if (this.enableCancel) {
// TODO: Frage an PB: Warum flc hier noetig ???
uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectListController method createTableController.
private TableController createTableController(final UserRequest ureq, WindowControl wControl) {
numberOfCustomFieldInTable = 0;
numberOfEventInTable = 0;
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("projectlist.no.projects"));
tableConfig.setPreferencesOffered(true, "projectbrokerList");
// Do not allow show all because many entries takes too long to render
tableConfig.setShowAllLinkEnabled(false);
removeAsListenerAndDispose(tableController);
tableController = new TableController(tableConfig, ureq, wControl, this.getTranslator(), true);
listenTo(tableController);
int dataColumn = 0;
tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.title", dataColumn++, TABLE_ACTION_SHOW_DETAIL, getLocale()));
CustomRenderColumnDescriptor projectManagerDescriptor = new CustomRenderColumnDescriptor("projectlist.tableheader.account.manager", dataColumn++, TABLE_ACTION_ACCOUNT_MANAGER, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectManagerColumnRenderer()) {
/**
* @see org.olat.core.gui.components.table.DefaultColumnDescriptor#compareTo(int, int)
*/
@Override
public int compareTo(int rowa, int rowb) {
return super.compareTo(rowa, rowb);
}
/**
* @see org.olat.core.gui.components.table.CustomRenderColumnDescriptor#renderValue(org.olat.core.gui.render.StringOutput, int, org.olat.core.gui.render.Renderer)
*/
@Override
public void renderValue(StringOutput sb, int row, Renderer renderer) {
Object val = getModelData(row);
// to get info about row in Renderer!
String rowSt = Integer.toString(row);
getCustomCellRenderer().render(sb, renderer, val, getLocale(), getAlignment(), rowSt);
}
};
tableController.addColumnDescriptor(projectManagerDescriptor);
// Custom-Fields
List<CustomField> customFieldList = moduleConfig.getCustomFields();
for (Iterator<CustomField> iterator = customFieldList.iterator(); iterator.hasNext(); ) {
CustomField customField = iterator.next();
if (customField.isTableViewEnabled()) {
numberOfCustomFieldInTable++;
DefaultColumnDescriptor columnDescriptor = new DefaultColumnDescriptor(customField.getName(), dataColumn++, null, getLocale());
columnDescriptor.setTranslateHeaderKey(false);
tableController.addColumnDescriptor(columnDescriptor);
}
}
// Project Events
for (Project.EventType eventType : Project.EventType.values()) {
if (moduleConfig.isProjectEventEnabled(eventType) && moduleConfig.isProjectEventTableViewEnabled(eventType)) {
numberOfEventInTable++;
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.event." + eventType.getI18nKey(), dataColumn++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectEventColumnRenderer()));
}
}
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.state", dataColumn++, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectStateColumnRenderer()));
tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.numbers", dataColumn++, null, getLocale()) {
@Override
public int compareTo(int rowa, int rowb) {
Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
if (a == null || b == null) {
boolean bb = (b == null);
return (a == null) ? (bb ? 0 : -1) : (bb ? 1 : 0);
}
try {
Long la = new Long((String) a);
Long lb = new Long((String) b);
return la.compareTo(lb);
} catch (NumberFormatException e) {
return super.compareTo(rowa, rowb);
}
}
});
String selectCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_SELECT;
tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.select", dataColumn++, selectCmd, translate("table.action.select"), "-"));
String cancelCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_CANCEL_SELECT;
tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.cancel.select", dataColumn++, cancelCmd, translate("projectlist.tableheader.cancel.select"), "-"));
return tableController;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectListController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == createNewProjectButton) {
String projectTitle = translate("new.project.title");
int i = 1;
while (projectBrokerManager.existProjectName(projectBrokerId, projectTitle)) {
projectTitle = translate("new.project.title") + i++;
}
String projectGroupName = translate("project.member.groupname", projectTitle);
String projectGroupDescription = translate("project.member.groupdescription", projectTitle);
BusinessGroup projectGroup = projectGroupManager.createProjectGroupFor(projectBrokerId, ureq.getIdentity(), projectGroupName, projectGroupDescription, courseId);
Project project = projectBrokerManager.createAndSaveProjectFor(projectTitle, projectTitle, projectBrokerId, projectGroup);
projectGroupManager.sendGroupChangeEvent(project, courseId, ureq.getIdentity());
getLogger().debug("Created a new project=" + project);
projectController = new ProjectController(ureq, this.getWindowControl(), userCourseEnv, courseNode, project, true, moduleConfig);
listenTo(projectController);
mainPanel.pushContent(projectController.getInitialComponent());
} else if (event.getCommand().equals(OPEN_IDENTITY_CMD)) {
Link link = (Link) source;
if (calloutCtrl != null) {
calloutCtrl.deactivate();
removeAsListenerAndDispose(calloutCtrl);
calloutCtrl = null;
}
openUserInPopup(ureq, (Identity) link.getUserObject());
}
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectBrokerCourseNode method exportNode.
@Override
public void exportNode(File exportDirectory, ICourse course) {
// initialize managers
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
ProjectBroker pb = projectBrokerManager.getProjectBroker(projectBrokerManager.getProjectBrokerId(cpm, this));
ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
XStream xstream = XStreamHelper.createXStreamInstance();
// folder for the pb node
File pbNodeFolder = new File(exportDirectory, getIdent());
pbNodeFolder.mkdirs();
// for the broker prefs
ProjectBrokerConfig brokerConfig = new ProjectBrokerConfig();
brokerConfig.setAccountGroupKey(projectGroupManager.getAccountManagerGroupKey(cpm, this));
File projectBrokerFile = new File(pbNodeFolder, "projectbroker.xml");
XStreamHelper.writeObject(xstream, projectBrokerFile, brokerConfig);
// get all the projects available in the pb
List<Project> projects = projectBrokerManager.getProjectListBy(pb.getKey());
for (Project project : projects) {
File projectFolder = new File(pbNodeFolder, project.getKey().toString());
projectFolder.mkdirs();
// create a hashmap with the project configuration and insert the
// project data
File projectFile = new File(projectFolder, project.getKey() + ".xml");
HashMap<String, Object> projectData = new HashMap<String, Object>();
projectData.put("title", project.getTitle());
projectData.put("description", project.getDescription());
projectData.put("customFieldSize", project.getCustomFieldSize());
projectData.put("maxMembers", project.getMaxMembers());
projectData.put("mailNotificationEnabled", project.isMailNotificationEnabled());
projectData.put("attachmentFileName", project.getAttachmentFileName());
projectData.put("allowDeselection", projectGroupManager.isDeselectionAllowed(project));
projectData.put("customeFieldSize", project.getCustomFieldSize());
projectData.put("businessGroupKey", project.getProjectGroup().getKey());
// iterate through the customFields
for (int i = 0; i < project.getCustomFieldSize(); i++) {
projectData.put("customFieldValue" + i, project.getCustomFieldValue(i));
}
// writeout the project data
XStreamHelper.writeObject(xstream, projectFile, projectData);
// add attachment file
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(projectBrokerManager.getAttamchmentRelativeRootPath(project, course.getCourseEnvironment(), this), null);
VFSItem item = rootFolder.resolve(project.getAttachmentFileName());
if (item instanceof VFSLeaf) {
VFSLeaf itemLeaf = (VFSLeaf) item;
File attachmentFolder = new File(projectFolder, "attachment");
File attachment = new File(attachmentFolder, Base64.encodeBase64String(project.getAttachmentFileName().getBytes()));
try {
attachmentFolder.mkdirs();
attachment.createNewFile();
FileOutputStream attachmentOutputStream = new FileOutputStream(attachment);
InputStream leafInputStream = itemLeaf.getInputStream();
FileUtils.copy(leafInputStream, attachmentOutputStream);
attachmentOutputStream.close();
leafInputStream.close();
} catch (IOException e) {
log.error("Error while exporting attachments for projectbroker " + project.getTitle(), e);
}
}
}
}
Aggregations