use of org.projectforge.framework.persistence.user.entities.GroupDO in project projectforge by micromata.
the class ToDoDao method setGroup.
public void setGroup(final ToDoDO todo, final Integer groupId) {
final GroupDO group = groupDao.getOrLoad(groupId);
todo.setGroup(group);
}
use of org.projectforge.framework.persistence.user.entities.GroupDO in project projectforge by micromata.
the class AccessEditForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newGridPanel();
{
// Task
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(data, "task"), parentPage, "taskId");
fs.add(taskSelectPanel.setRequired(true));
taskSelectPanel.init();
}
{
// Group
final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new PropertyModel<GroupDO>(data, "group"), parentPage, "groupId");
fs.add(groupSelectPanel.setRequired(true));
groupSelectPanel.init();
}
{
// Option recursive
gridBuilder.newFieldset(getString("recursive")).addCheckBox(new PropertyModel<Boolean>(data, "recursive"), null).setTooltip(getString("access.recursive.help"));
}
{
// Access entries table
final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.accessTable")).suppressLabelForWarning();
final AccessEditTablePanel accessEditTablePanel = new AccessEditTablePanel(fs.newChildId(), data);
fs.add(accessEditTablePanel);
accessEditTablePanel.init();
}
{
// Templates
final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.templates")).suppressLabelForWarning();
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("clear")) {
@Override
public final void onSubmit() {
data.clear();
}
}, getString("access.templates.clear"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("guest")) {
@Override
public final void onSubmit() {
data.guest();
}
}, getString("access.templates.guest"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("employee")) {
@Override
public final void onSubmit() {
data.employee();
}
}, getString("access.templates.employee"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("leader")) {
@Override
public final void onSubmit() {
data.leader();
}
}, getString("access.templates.leader"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("administrator")) {
@Override
public final void onSubmit() {
data.administrator();
}
}, getString("access.templates.administrator"), SingleButtonPanel.DANGER));
}
{
// Description
final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"));
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description")), true);
}
}
use of org.projectforge.framework.persistence.user.entities.GroupDO in project projectforge by micromata.
the class AccessListForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newSplitPanel(GridSize.COL66);
{
// Group
final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new Model<GroupDO>() {
@Override
public GroupDO getObject() {
return groupService.getGroup(getSearchFilter().getGroupId());
}
@Override
public void setObject(final GroupDO object) {
if (object == null) {
getSearchFilter().setGroupId(null);
} else {
getSearchFilter().setGroupId(object.getId());
}
}
}, parentPage, "groupId");
fs.add(groupSelectPanel);
groupSelectPanel.setDefaultFormProcessing(false);
groupSelectPanel.init();
}
gridBuilder.newSplitPanel(GridSize.COL33);
{
// User
final FieldsetPanel fs = gridBuilder.newFieldset(getString("user")).suppressLabelForWarning();
final UserSelectPanel assigneeSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject() {
return userGroupCache.getUser(getSearchFilter().getUserId());
}
@Override
public void setObject(final PFUserDO object) {
if (object == null) {
getSearchFilter().setUserId(null);
} else {
getSearchFilter().setUserId(object.getId());
}
}
}, parentPage, "userId");
fs.add(assigneeSelectPanel);
assigneeSelectPanel.setDefaultFormProcessing(false);
assigneeSelectPanel.init().withAutoSubmit(true);
fs.addHelpIcon(getString("access.tooltip.filter.user"));
}
gridBuilder.newGridPanel();
{
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task")).suppressLabelForWarning();
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new Model<TaskDO>() {
@Override
public TaskDO getObject() {
return taskTree.getTaskById(getSearchFilter().getTaskId());
}
@Override
public void setObject(final TaskDO task) {
if (task != null) {
getSearchFilter().setTaskId(task.getId());
} else {
getSearchFilter().setTaskId(null);
}
}
}, parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
taskSelectPanel.setRequired(false);
}
}
use of org.projectforge.framework.persistence.user.entities.GroupDO in project projectforge by micromata.
the class GroupDao method afterUpdate.
/**
* Creates for every user an history if the user is assigned or unassigned from this updated group.
*/
@Override
protected void afterUpdate(final GroupDO group, final GroupDO dbGroup) {
if (doHistoryUpdate) {
final Set<PFUserDO> origAssignedUsers = dbGroup.getAssignedUsers();
final Set<PFUserDO> assignedUsers = group.getAssignedUsers();
// List of new assigned users.
final Collection<PFUserDO> assignedList = new ArrayList<>();
// List of unassigned users.
final Collection<PFUserDO> unassignedList = new ArrayList<>();
for (final PFUserDO user : group.getAssignedUsers()) {
if (!origAssignedUsers.contains(user)) {
assignedList.add(user);
}
}
for (final PFUserDO user : dbGroup.getAssignedUsers()) {
if (!assignedUsers.contains(user)) {
unassignedList.add(user);
}
}
final Collection<GroupDO> groupList = new ArrayList<>();
groupList.add(group);
// Create history entry of PFUserDO for all new assigned users:
for (final PFUserDO user : assignedList) {
createHistoryEntry(user, null, groupList);
}
// Create history entry of PFUserDO for all unassigned users:
for (final PFUserDO user : unassignedList) {
createHistoryEntry(user, groupList, null);
}
}
}
use of org.projectforge.framework.persistence.user.entities.GroupDO in project projectforge by micromata.
the class DatabaseService method addGroup.
private void addGroup(final ProjectForgeGroup projectForgeGroup, final String description, final Set<PFUserDO> users) {
final GroupDO group = new GroupDO();
group.setName(projectForgeGroup.toString());
group.setDescription(description);
if (users != null) {
group.setAssignedUsers(users);
}
// group.setNestedGroupsAllowed(false);
// Do not synchronize group with external user management system by default.
group.setLocalGroup(true);
groupDao.internalSave(group);
}
Aggregations