Search in sources :

Example 1 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class GetBlacklist method setList.

public void setList(ArrayList<User> list) {
    clearTable();
    this.list.addAll(list);
    for (User user : list) {
        oracle.add(user.getFullName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : User(cz.metacentrum.perun.webgui.model.User)

Example 2 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class GetUsers method retrieveData.

/**
	 * Retrieves data from RPC
	 */
public void retrieveData() {
    // empty
    if (this.attributesToSearchBy.size() == 0) {
        session.getUiElements().setLogText("No keywords.");
        return;
    }
    // ok, start
    loaderImage.loadingStart();
    // build request
    JSONObject attributesWithSearchingValues = new JSONObject();
    for (Map.Entry<String, String> entry : attributesToSearchBy.entrySet()) {
        String name = entry.getKey();
        String value = entry.getValue();
        attributesWithSearchingValues.put(name, new JSONString(value));
    }
    JSONObject req = new JSONObject();
    req.put("attributesWithSearchingValues", attributesWithSearchingValues);
    // send request
    JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Error while loading users.");
            loaderImage.loadingError(error);
            events.onError(error);
        }

        public void onLoadingStart() {
            loaderImage.loadingStart();
            session.getUiElements().setLogText("Loading users started.");
            events.onLoadingStart();
        }

        public void onFinished(JavaScriptObject jso) {
            loaderImage.loadingFinished();
            setList(JsonUtils.<User>jsoAsList(jso));
            sortTable();
            session.getUiElements().setLogText("Users loaded: " + list.size());
            events.onFinished(jso);
        }
    });
    js.sendData(JSON_URL, req);
    return;
}
Also used : User(cz.metacentrum.perun.webgui.model.User) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JSONString(com.google.gwt.json.client.JSONString) PerunError(cz.metacentrum.perun.webgui.model.PerunError) HashMap(java.util.HashMap) Map(java.util.Map) JSONString(com.google.gwt.json.client.JSONString)

Example 3 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class GetCompleteRichUsers method onFinished.

/**
	 * Called, when operation finishes successfully.
	 */
public void onFinished(JavaScriptObject jso) {
    ArrayList<User> list = JsonUtils.jsoAsList(jso);
    for (User u : list) {
        if (hideService && u.isServiceUser()) {
        // if service hidden, skip service users
        } else if (hidePerson && !u.isServiceUser() && !u.isSponsoredUser()) {
        // if person hidden, skip person
        } else if (hideSponsored && !u.isSponsoredUser()) {
        // if sponsored hidden, skip person
        } else {
            addToTable(u);
        }
    }
    sortTable();
    session.getUiElements().setLogText("Users loaded: " + list.size());
    events.onFinished(jso);
    loaderImage.loadingFinished();
}
Also used : User(cz.metacentrum.perun.webgui.model.User)

Example 4 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class GetCompleteRichUsers method getTable.

/**
	 * Returns table of users.
	 * @return
	 */
public CellTable<User> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<User>(list);
    // Cell table
    table = new PerunTable<User>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("User ID", tableFieldUpdater);
    // NAME COLUMN
    Column<User, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User user) {
            return user.getFullName();
        }
    }, tableFieldUpdater);
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<User>() {

        public int compare(User o1, User o2) {
            return o1.getLastName().compareToIgnoreCase(o2.getLastName());
        }
    });
    // Create organization column.
    Column<User, String> organizationColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
            String value = "";
            if (at != null) {
                value = at.getValue();
            }
            return value;
        }
    }, this.tableFieldUpdater);
    // Create e-mail column.
    Column<User, String> emailColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
            String value = "";
            if (at != null) {
                value = at.getValue();
                // replace "," to " " in emails
                value = value.replace(",", " ");
            }
            return value;
        }
    }, this.tableFieldUpdater);
    // Create name column.
    Column<User, String> loginsColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            return object.getLogins();
        }
    }, this.tableFieldUpdater);
    organizationColumn.setSortable(true);
    columnSortHandler.setComparator(organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));
    emailColumn.setSortable(true);
    columnSortHandler.setComparator(emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));
    // SERVICE COLUMN
    Column<User, String> serviceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User user) {
            if (user.isServiceUser()) {
                return "Service";
            } else if (user.isSponsoredUser()) {
                return "Sponsored";
            } else {
                return "Person";
            }
        }
    }, tableFieldUpdater);
    serviceColumn.setSortable(true);
    columnSortHandler.setComparator(serviceColumn, new Comparator<User>() {

        public int compare(User o1, User o2) {
            String type1 = "Person";
            if (o1.isServiceUser()) {
                type1 = "Service";
            } else if (o1.isSponsoredUser()) {
                type1 = "Sponsored";
            }
            String type2 = "Person";
            if (o2.isServiceUser()) {
                type2 = "Service";
            } else if (o2.isSponsoredUser()) {
                type2 = "Sponsored";
            }
            return type1.compareTo(type2);
        }
    });
    // Add the other columns.
    table.addColumn(nameColumn, "Name");
    table.addColumn(organizationColumn, "Organization");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginsColumn, "Logins");
    table.addColumn(serviceColumn, "User type");
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) User(cz.metacentrum.perun.webgui.model.User) RichUserComparator(cz.metacentrum.perun.webgui.json.comparators.RichUserComparator) Attribute(cz.metacentrum.perun.webgui.model.Attribute)

Example 5 with User

use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.

the class GetSpecificUsersByUser method onFinished.

/**
	 * Called, when operation finishes successfully.
	 */
public void onFinished(JavaScriptObject jso) {
    for (User user : JsonUtils.<User>jsoAsList(jso)) {
        if (hideService && user.isServiceUser()) {
        // skip service
        } else if (hideSponsored && user.isSponsoredUser()) {
        // skip sponsored
        } else {
            addToTable(user);
        }
    }
    sortTable();
    session.getUiElements().setLogText("Users loaded: " + list.size());
    events.onFinished(jso);
    loaderImage.loadingFinished();
}
Also used : User(cz.metacentrum.perun.webgui.model.User)

Aggregations

User (cz.metacentrum.perun.webgui.model.User)48 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)22 ArrayList (java.util.ArrayList)20 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)19 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)19 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)18 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)18 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)17 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)15 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)9 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)8 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)6 FindUsersByIdsNotInRpc (cz.metacentrum.perun.webgui.json.usersManager.FindUsersByIdsNotInRpc)5 GetSpecificUsersByUser (cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)4 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)4