Search in sources :

Example 1 with GroupDO

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);
}
Also used : GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Example 2 with GroupDO

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);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) MaxLengthTextArea(org.projectforge.web.wicket.components.MaxLengthTextArea) TaskSelectPanel(org.projectforge.web.task.TaskSelectPanel) NewGroupSelectPanel(org.projectforge.web.user.NewGroupSelectPanel) Button(org.apache.wicket.markup.html.form.Button) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel) GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Example 3 with GroupDO

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);
    }
}
Also used : UserSelectPanel(org.projectforge.web.user.UserSelectPanel) TaskDO(org.projectforge.business.task.TaskDO) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) TaskSelectPanel(org.projectforge.web.task.TaskSelectPanel) NewGroupSelectPanel(org.projectforge.web.user.NewGroupSelectPanel) PFUserDO(org.projectforge.framework.persistence.user.entities.PFUserDO) GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Example 4 with GroupDO

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);
        }
    }
}
Also used : PFUserDO(org.projectforge.framework.persistence.user.entities.PFUserDO) GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Example 5 with GroupDO

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);
}
Also used : GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Aggregations

GroupDO (org.projectforge.framework.persistence.user.entities.GroupDO)50 PFUserDO (org.projectforge.framework.persistence.user.entities.PFUserDO)18 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)6 Model (org.apache.wicket.model.Model)6 PropertyModel (org.apache.wicket.model.PropertyModel)6 Serializable (java.io.Serializable)5 Label (org.apache.wicket.markup.html.basic.Label)5 AccessException (org.projectforge.framework.access.AccessException)5 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)5 HashSet (java.util.HashSet)4 IModel (org.apache.wicket.model.IModel)4 ProjektDO (org.projectforge.business.fibu.ProjektDO)4 UserRightDO (org.projectforge.framework.persistence.user.entities.UserRightDO)4 TaskSelectPanel (org.projectforge.web.task.TaskSelectPanel)4 NewGroupSelectPanel (org.projectforge.web.user.NewGroupSelectPanel)4 MaxLengthTextArea (org.projectforge.web.wicket.components.MaxLengthTextArea)4 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 Item (org.apache.wicket.markup.repeater.Item)3