Exemplo n.º 1
0
 @Override
 protected void updateDetailsAvailability() {
   if (getSelectedItem() != null) {
     DbUser adUser = (DbUser) getSelectedItem();
     userGroupListModel.setIsAvailable(!adUser.isGroup());
     userEventNotifierListModel.setIsAvailable(!adUser.isGroup());
   }
 }
Exemplo n.º 2
0
  public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> userIds = new ArrayList<Guid>();
    ArrayList<Guid> grpIds = new ArrayList<Guid>();

    for (Object item : getSelectedItems()) {
      DbUser user = (DbUser) item;
      if (user.isGroup()) {
        grpIds.add(user.getId());
      } else {
        userIds.add(user.getId());
      }
    }

    // prepare attach/detach lists
    ArrayList<Guid> tagsToAttach = new ArrayList<Guid>();
    ArrayList<Guid> tagsToDetach = new ArrayList<Guid>();

    if (model.getItems() != null && ((ArrayList<TagModel>) model.getItems()).size() > 0) {
      ArrayList<TagModel> tags = (ArrayList<TagModel>) model.getItems();
      TagModel rootTag = tags.get(0);
      TagModel.recursiveEditAttachDetachLists(rootTag, attachedTags, tagsToAttach, tagsToDetach);
    }

    ArrayList<VdcActionParametersBase> usersToAttach = new ArrayList<VdcActionParametersBase>();
    ArrayList<VdcActionParametersBase> grpsToAttach = new ArrayList<VdcActionParametersBase>();
    for (Guid tag_id : tagsToAttach) {
      if (userIds.size() > 0) {
        usersToAttach.add(new AttachEntityToTagParameters(tag_id, userIds));
      }
      if (grpIds.size() > 0) {
        grpsToAttach.add(new AttachEntityToTagParameters(tag_id, grpIds));
      }
    }
    if (usersToAttach.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.AttachUserToTag, usersToAttach);
    }
    if (grpsToAttach.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.AttachUserGroupToTag, grpsToAttach);
    }

    ArrayList<VdcActionParametersBase> usersToDetach = new ArrayList<VdcActionParametersBase>();
    ArrayList<VdcActionParametersBase> grpsToDetach = new ArrayList<VdcActionParametersBase>();
    for (Guid tag_id : tagsToDetach) {
      if (userIds.size() > 0) {
        usersToDetach.add(new AttachEntityToTagParameters(tag_id, userIds));
      }
      if (grpIds.size() > 0) {
        grpsToDetach.add(new AttachEntityToTagParameters(tag_id, grpIds));
      }
    }
    if (usersToDetach.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.DetachUserFromTag, usersToDetach);
    }
    if (grpsToDetach.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.DetachUserGroupFromTag, grpsToDetach);
    }

    cancel();
  }
Exemplo n.º 3
0
  public void onRemove() {
    ArrayList<DbUser> items = Linq.<DbUser>cast(getSelectedItems());

    ArrayList<VdcActionParametersBase> userPrms = new ArrayList<VdcActionParametersBase>();
    ArrayList<VdcActionParametersBase> groupPrms = new ArrayList<VdcActionParametersBase>();
    for (DbUser item : items) {
      if (!item.isGroup()) {
        userPrms.add(new IdParameters(item.getId()));
      } else {
        groupPrms.add(new IdParameters(item.getId()));
      }
    }

    if (userPrms.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.RemoveUser, userPrms);
    }

    if (groupPrms.size() > 0) {
      Frontend.getInstance().runMultipleAction(VdcActionType.RemoveGroup, groupPrms);
    }

    cancel();
  }
  private void onAttach() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    for (Object item : model.getItems()) {
      EntityModel entityModel = (EntityModel) item;
      if (entityModel.getIsSelected()) {
        items.add((DbUser) entityModel.getEntity());
      }
    }

    Role role = model.getRole().getSelectedItem();

    ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>();
    for (DbUser user : items) {
      Permission perm = new Permission(user.getId(), role.getId(), null, null);

      if (user.isGroup()) {
        DbGroup group = new DbGroup();
        group.setId(user.getId());
        group.setName(user.getFirstName());
        group.setDomain(user.getDomain());
        group.setExternalId(user.getExternalId());
        group.setNamespace(user.getNamespace());
        PermissionsOperationsParameters tempVar2 = new PermissionsOperationsParameters();
        tempVar2.setPermission(perm);
        tempVar2.setGroup(group);
        list.add(tempVar2);
      } else {
        PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
        tempVar3.setPermission(perm);
        tempVar3.setUser(user);
        list.add(tempVar3);
      }
    }

    model.startProgress(null);

    Frontend.getInstance()
        .runMultipleAction(
            VdcActionType.AddSystemPermission,
            list,
            new IFrontendMultipleActionAsyncCallback() {
              @Override
              public void executed(FrontendMultipleActionAsyncResult result) {

                AdElementListModel localModel = (AdElementListModel) result.getState();
                localModel.stopProgress();
                cancel();
              }
            },
            model);
  }
Exemplo n.º 5
0
  public void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    for (Object item : model.getItems()) {
      EntityModel entityModel = (EntityModel) item;
      if (entityModel.getIsSelected()) {
        items.add((DbUser) entityModel.getEntity());
      }
    }

    ArrayList<VdcActionType> actionsList = new ArrayList<VdcActionType>(items.size());
    ArrayList<VdcActionParametersBase> parametersList =
        new ArrayList<VdcActionParametersBase>(items.size());
    VdcActionParametersBase parameters = null;
    for (DbUser item : items) {
      if (item.isGroup()) {
        actionsList.add(VdcActionType.AddGroup);
        DbGroup grp = new DbGroup();
        grp.setExternalId(item.getExternalId());
        grp.setName(item.getFirstName());
        grp.setNamespace(item.getNamespace());
        grp.setId(item.getId());
        grp.setDomain(item.getDomain());
        grp.setActive(item.isActive());
        parameters = new AddGroupParameters(grp);
      } else {
        actionsList.add(VdcActionType.AddUser);
        parameters = new AddUserParameters(item);
      }
      parametersList.add(parameters);
    }

    model.startProgress(null);

    IFrontendActionAsyncCallback nopCallback =
        new IFrontendActionAsyncCallback() {
          @Override
          public void executed(FrontendActionAsyncResult result) {
            // Nothing.
          }
        };

    IFrontendActionAsyncCallback lastCallback =
        new IFrontendActionAsyncCallback() {
          @Override
          public void executed(FrontendActionAsyncResult result) {
            AdElementListModel localModel = (AdElementListModel) result.getState();
            localModel.stopProgress();
            cancel();
          }
        };

    ArrayList<IFrontendActionAsyncCallback> callbacksList =
        new ArrayList<IFrontendActionAsyncCallback>(items.size());
    for (int i = 1; i < items.size(); i++) {
      callbacksList.add(nopCallback);
    }
    callbacksList.add(lastCallback);

    Frontend.getInstance()
        .runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
  }
Exemplo n.º 6
0
  private void getAttachedTagsToSelectedUsers(TagListModel model) {
    ArrayList<Guid> userIds = new ArrayList<Guid>();
    ArrayList<Guid> grpIds = new ArrayList<Guid>();

    attachedTagsToEntities = new HashMap<Guid, Boolean>();
    allAttachedTags = new ArrayList<Tags>();
    selectedItemsCounter = 0;

    for (Object item : getSelectedItems()) {
      DbUser user = (DbUser) item;
      if (!user.isGroup()) {
        userIds.add(user.getId());
      } else {
        grpIds.add(user.getId());
      }
    }

    for (Guid userId : userIds) {
      AsyncDataProvider.getInstance()
          .getAttachedTagsToUser(
              new AsyncQuery(
                  new Object[] {this, model},
                  new INewAsyncCallback() {
                    @Override
                    public void onSuccess(Object target, Object returnValue) {

                      Object[] array = (Object[]) target;
                      UserListModel userListModel = (UserListModel) array[0];
                      TagListModel tagListModel = (TagListModel) array[1];
                      userListModel.allAttachedTags.addAll((ArrayList<Tags>) returnValue);
                      userListModel.selectedItemsCounter++;
                      if (userListModel.selectedItemsCounter
                          == userListModel.getSelectedItems().size()) {
                        postGetAttachedTags(userListModel, tagListModel);
                      }
                    }
                  }),
              userId);
    }
    for (Guid grpId : grpIds) {
      AsyncDataProvider.getInstance()
          .getAttachedTagsToUserGroup(
              new AsyncQuery(
                  new Object[] {this, model},
                  new INewAsyncCallback() {
                    @Override
                    public void onSuccess(Object target, Object returnValue) {

                      Object[] array = (Object[]) target;
                      UserListModel userListModel = (UserListModel) array[0];
                      TagListModel tagListModel = (TagListModel) array[1];
                      userListModel.allAttachedTags.addAll((ArrayList<Tags>) returnValue);
                      userListModel.selectedItemsCounter++;
                      if (userListModel.selectedItemsCounter
                          == userListModel.getSelectedItems().size()) {
                        postGetAttachedTags(userListModel, tagListModel);
                      }
                    }
                  }),
              grpId);
    }
  }
Exemplo n.º 7
0
  private void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (!model.getIsEveryoneSelected() && model.getSelectedItems() == null) {
      cancel();
      return;
    }

    ArrayList<DbUser> items = new ArrayList<DbUser>();
    if (model.getIsEveryoneSelected()) {
      DbUser tempVar = new DbUser();
      tempVar.setId(ApplicationGuids.everyone.asGuid());
      items.add(tempVar);
    } else {
      for (Object item : model.getItems()) {
        EntityModel entityModel = (EntityModel) item;
        if (entityModel.getIsSelected()) {
          items.add((DbUser) entityModel.getEntity());
        }
      }
    }

    Role role = (Role) model.getRole().getSelectedItem();
    // adGroup/user

    ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>();
    for (DbUser user : items) {
      Permissions tempVar2 = new Permissions();
      tempVar2.setad_element_id(user.getId());
      tempVar2.setrole_id(role.getId());
      Permissions perm = tempVar2;
      perm.setObjectId(getEntityGuid());
      perm.setObjectType(this.getObjectType());

      if (user.isGroup()) {
        DbGroup group = new DbGroup();
        group.setId(user.getId());
        group.setExternalId(user.getExternalId());
        group.setName(user.getFirstName());
        group.setDomain(user.getDomain());
        group.setNamespace(user.getNamespace());
        PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
        tempVar3.setPermission(perm);
        tempVar3.setGroup(group);
        list.add(tempVar3);
      } else {
        PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
        tempVar4.setPermission(perm);
        tempVar4.setUser(user);
        list.add(tempVar4);
      }
    }

    model.startProgress(null);

    Frontend.getInstance()
        .runMultipleAction(
            VdcActionType.AddPermission,
            list,
            new IFrontendMultipleActionAsyncCallback() {
              @Override
              public void executed(FrontendMultipleActionAsyncResult result) {

                AdElementListModel localModel = (AdElementListModel) result.getState();
                localModel.stopProgress();
                cancel();
              }
            },
            model);
  }