use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectGroupManagerImpl method acceptCandidates.
@Override
public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) {
final Project reloadedProject = projectDao.loadProject(project.getKey());
final BusinessGroupAddResponse response = new BusinessGroupAddResponse();
BusinessGroupAddResponse state = businessGroupService.addParticipants(actionIdentity, null, identities, reloadedProject.getProjectGroup(), null);
response.getAddedIdentities().addAll(state.getAddedIdentities());
response.getIdentitiesAlreadyInGroup().addAll(state.getIdentitiesAlreadyInGroup());
Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
for (final Identity identity : identities) {
if (businessGroupService.hasRoles(identity, reloadedProject.getProjectGroup(), GroupRoles.participant.name())) {
securityManager.removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup());
log.audit("ProjectBroker: Accept candidate, identity=" + identity + " project=" + reloadedProject);
}
}
return Boolean.TRUE;
}
});
if (autoSignOut && result.booleanValue()) {
projectBrokerManager.signOutFormAllCandidateList(response.getAddedIdentities(), reloadedProject.getProjectBroker().getKey());
}
if (isAcceptSelectionManually && (reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers()) {
projectBrokerManager.setProjectState(reloadedProject, Project.STATE_ASSIGNED);
log.info("ProjectBroker: Accept candidate, change project-state=" + Project.STATE_ASSIGNED);
}
return response;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
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 klemens.
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 klemens.
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 klemens.
the class ProjectBrokerManagerImpl method updateProjectAndInvalidateCache.
private void updateProjectAndInvalidateCache(final Project project) {
// avoid hibernate exception : object with same identifier already exist in session.
// reload object from db, because project is a detached object but could be already in hibernate session
Project reloadedProject = (Project) dbInstance.loadObject(project, true);
// set all value on reloadedProject with values from updated project
reloadedProject.setTitle(project.getTitle());
reloadedProject.setState(project.getState());
for (Project.EventType eventType : Project.EventType.values()) {
reloadedProject.setProjectEvent(project.getProjectEvent(eventType));
}
reloadedProject.setMaxMembers(project.getMaxMembers());
reloadedProject.setMailNotificationEnabled(project.isMailNotificationEnabled());
reloadedProject.setDescription(project.getDescription());
for (int index = 0; index < project.getCustomFieldSize(); index++) {
reloadedProject.setCustomFieldValue(index, project.getCustomFieldValue(index));
}
reloadedProject.setAttachedFileName(project.getAttachmentFileName());
dbInstance.updateObject(reloadedProject);
// invalide with removing from cache
projectCache.remove(project.getProjectBroker().getKey().toString());
}
Aggregations