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();
}
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;
}
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();
}
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;
}
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();
}
Aggregations