本文整理汇总了Java中org.sakaiproject.user.api.User.getSortName方法的典型用法代码示例。如果您正苦于以下问题:Java User.getSortName方法的具体用法?Java User.getSortName怎么用?Java User.getSortName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sakaiproject.user.api.User
的用法示例。
在下文中一共展示了User.getSortName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUser
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public org.sakaiproject.kaltura.logic.User getUser(String userId) {
org.sakaiproject.kaltura.logic.User user = null;
if (userId != null) {
User u = null;
try {
u = userDirectoryService.getUserByEid(userId);
} catch (UserNotDefinedException e) {
try {
u = userDirectoryService.getUser(userId);
} catch (UserNotDefinedException e1) {
log.warn("Cannot get user for id: " + userId);
}
}
if (u != null) {
user = new org.sakaiproject.kaltura.logic.User(u.getId(),
u.getEid(), u.getDisplayName(), u.getSortName(), u.getEmail());
user.fname = u.getFirstName();
user.lname = u.getLastName();
}
}
return user;
}
示例2: getEvalUsersByIds
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public Map<String, EvalUser> getEvalUsersByIds(String[] userIds) {
Map<String, EvalUser> users = new HashMap<>();
boolean foundAll = false;
if (userIds == null
|| userIds.length == 0) {
foundAll = true;
}
if (! foundAll) {
// get remaining users from Sakai
Map<String, User> sakaiUsers = getSakaiUsers(userIds);
for (Entry<String, User> entry : sakaiUsers.entrySet()) {
String userId = entry.getKey();
User sakaiUser = entry.getValue();
EvalUser user = new EvalUser(sakaiUser.getId(), EvalConstants.USER_TYPE_EXTERNAL,
sakaiUser.getEmail(), sakaiUser.getEid(), sakaiUser.getDisplayName(), sakaiUser.getSortName(), sakaiUser.getDisplayId());
users.put(userId, user);
}
}
return users;
}
示例3: getSearchedUsers
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
private List<User> getSearchedUsers(String searchString, List<User> userList, boolean retain) {
List<User> rv = new ArrayList<>();
if (StringUtils.isNotBlank(searchString)) {
searchString = searchString.toLowerCase();
for (User u : userList) {
// search on user sortname, eid, email
String[] fields = {u.getSortName(), u.getEid(), u.getEmail()};
List<String> l = Arrays.asList(fields);
for (String s : l) {
if (StringUtils.containsIgnoreCase(s, searchString)) {
rv.add(u);
break;
}
}
}
} else if (retain) {
// retain the original list
rv = userList;
}
return rv;
}
示例4: getUser
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
* Get a user by their unique id
* @param userId user id
* @return the populated User or null if none found
*/
public org.sakaiproject.gradebook.entity.User getUser(String userId) {
org.sakaiproject.gradebook.entity.User user = null;
User u = null;
try {
u = userDirectoryService.getUser(userId);
} catch (UserNotDefinedException e) {
try {
u = userDirectoryService.getUserByEid(userId);
} catch (UserNotDefinedException e1) {
log.warn("Cannot get user for id: " + userId);
}
}
if (u != null) {
user = new org.sakaiproject.gradebook.entity.User(u.getId(),
u.getEid(), u.getDisplayName(), u.getSortName(), u.getEmail());
user.fname = u.getFirstName();
user.lname = u.getLastName();
}
return user;
}
示例5: getUserDisplay
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
* Get the user's display name (including the eid), looking up in a map first.
* @param userEid
* @param userMap
* @return
*/
private String getUserDisplay(String userEid, Map<String, User> userMap) {
String display = userEid;
User user = userMap.get(userEid);
if (user == null) {
try {
user = UserDirectoryService.getUserByEid(userEid);
userMap.put(userEid, user);
} catch (UserNotDefinedException e) {
log.warn("Unable to get user with eid: " + userEid);
}
}
if (user!=null)
display = user.getSortName() + " (" + userEid + ")";
return display;
}
示例6: getUserSortNameById
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
*
* @param id
* @return
*/
public String getUserSortNameById(String id){
try
{
User user=UserDirectoryService.getUser(id) ;
if (ServerConfigurationService.getBoolean("msg.displayEid", true))
{
userName= user.getSortName() + " (" + user.getDisplayId() + ")";
}
else
{
userName= user.getSortName();
}
}
catch (UserNotDefinedException e) {
log.error(e.getMessage(), e);
}
return userName;
}
示例7: getAuthorString
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public String getAuthorString()
{
String authorString = getUserId();
try
{
User user = UserDirectoryService.getUser(getUserId());
if (ServerConfigurationService.getBoolean("msg.displayEid", true))
{
authorString = user.getSortName() + " (" + user.getDisplayId() + ")";
}
else
{
authorString = user.getSortName();
}
}
catch(Exception e)
{
log.error(e.getMessage(), e);
}
return authorString;
}
示例8: getEvalUserById
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public EvalUser getEvalUserById(String userId) {
EvalUser user = makeInvalidUser(userId, null);
if (isUserAnonymous(userId)) {
user = makeAnonymousUser(userId);
} else {
try {
User sakaiUser = userDirectoryService.getUser(userId);
user = new EvalUser(userId, EvalConstants.USER_TYPE_EXTERNAL,
sakaiUser.getEmail(), sakaiUser.getEid(), sakaiUser.getDisplayName(), sakaiUser.getSortName(), sakaiUser.getDisplayId());
} catch(UserNotDefinedException ex) {
LOG.debug("Sakai could not get user from userId: " + userId, ex);
}
}
return user;
}
示例9: getEvalUserByEmail
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public EvalUser getEvalUserByEmail(String email) {
EvalUser user = makeInvalidUser(null, email);
Collection<User> sakaiUsers = userDirectoryService.findUsersByEmail(email);
if (sakaiUsers.size() > 0) {
User sakaiUser = sakaiUsers.iterator().next(); // just get the first one
user = new EvalUser(sakaiUser.getId(), EvalConstants.USER_TYPE_EXTERNAL,
sakaiUser.getEmail(), sakaiUser.getEid(), sakaiUser.getDisplayName(), sakaiUser.getSortName(), sakaiUser.getDisplayId());
}
return user;
}
示例10: getDisplayName
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
private String getDisplayName(User userIn) {
User user = (userIn== null)?userDirectoryService.getCurrentUser():userIn ;
String displayId = user.getDisplayId();
if (displayId != null && displayId.length() > 0) {
return user.getSortName() + " (" + displayId + ")";
}
else {
return user.getSortName();
}
}
示例11: getUserNameForDisplay
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public String getUserNameForDisplay(User user) {
if(isSortUsersByDisplayName()) {
return user.getDisplayName();
}else{
return user.getSortName();
}
}
示例12: addParticipantsFromMemberships
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
* Add participant from provider-defined membership set
* @param participants
* @param realm
* @param providerCourseEid
* @param memberships
*/
public static void addParticipantsFromMemberships(Map participantsMap, AuthzGroup realm, Set memberships, String sectionTitle) {
boolean refreshed = false;
if (memberships != null)
{
Map<String, User> eidToUserMap = getEidUserMapFromCollection(memberships);
for (Iterator<Membership> mIterator = memberships.iterator();mIterator.hasNext();)
{
Membership m = (Membership) mIterator.next();
try
{
User user = eidToUserMap.get(m.getUserId());
if (user == null) {
throw new UserNotDefinedException(m.getUserId());
}
String userId = user.getId();
Member member = realm.getMember(userId);
// this person is in the cm, so they should be in the realm
// force a refresh. Only do this once, since a refresh should get everyone
// it would be nice for AuthzGroupService to expose refresh, but a save
// will do it
if (member == null && !refreshed) {
try {
// do it only once
refreshed = true;
// refresh the realm
AuthzGroup realmEdit = authzGroupService.getAuthzGroup(realm.getId());
authzGroupService.save(realmEdit);
// refetch updated realm
realm = authzGroupService.getAuthzGroup(realm.getId());
member = realm.getMember(userId);
} catch (Exception exc) {
log.warn("SiteParticipantHelper:addParticipantsFromMembership " + exc.getMessage());
}
}
if (member != null)
{
// get or add provided participant
Participant participant;
if (participantsMap.containsKey(userId))
{
participant = (Participant) participantsMap.get(userId);
participant.addSectionEidToList(sectionTitle); }
else
{
participant = new Participant();
participant.credits = "";
participant.name = user.getSortName();
if (member.isProvided())
{
participant.providerRole = member.getRole()!=null?member.getRole().getId():"";
participant.removeable = false;
}
participant.regId = "";
participant.role = member.getRole()!=null?member.getRole().getId():"";
participant.addSectionEidToList(sectionTitle);
participant.uniqname = userId;
participant.active=member.isActive();
}
participantsMap.put(userId, participant);
}
} catch (UserNotDefinedException exception) {
// deal with missing user quietly without throwing a
// warning message
log.debug("SiteParticipantHelper:addParticipantsFromMemberships: user not defined id = " + m.getUserId());
}
}
}
}
示例13: addOfficialInstructorOfRecord
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
private static void addOfficialInstructorOfRecord(Map<String, Participant> participantsMap, AuthzGroup realm, String sectionTitle, EnrollmentSet enrollmentSet) {
if (enrollmentSet != null)
{
Set<String>instructorEids = cms.getInstructorsOfRecordIds(enrollmentSet.getEid());
if ((instructorEids != null) && (instructorEids.size() > 0)) {
for (String userEid : instructorEids) {
// This logic is copied-and-pasted from addParticipantsFromMemberships
// and really should be in a shared method, but refactoring would make
// it harder to merge changes.
try
{
User user = UserDirectoryService.getUserByEid(userEid);
String userId = user.getId();
Member member = realm.getMember(userId);
if (member != null)
{
// get or add provided participant
Participant participant;
if (participantsMap.containsKey(userId))
{
participant = (Participant) participantsMap.get(userId);
if (!participant.section.contains(sectionTitle))
{
participant.section = participant.section.concat(", <br />" + sectionTitle);
}
}
else
{
participant = new Participant();
participant.credits = "";
participant.name = user.getSortName();
if (member.isProvided())
{
participant.providerRole = member.getRole()!=null?member.getRole().getId():"";
participant.removeable = false;
}
participant.regId = "";
participant.removeable = false;
participant.role = member.getRole()!=null?member.getRole().getId():"";
participant.section = sectionTitle;
participant.uniqname = userId;
}
participantsMap.put(userId, participant);
}
} catch (UserNotDefinedException exception) {
// deal with missing user quietly without throwing a
// warning message
log.warn(exception.getMessage());
}
}
}
}
}
示例14: compare
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
public int compare(User u1, User u2) {
String name1 = u1.getSortName();
String name2 = u2.getSortName();
return collator.compare(name1, name2);
}
示例15: getStudentsForCourse
import org.sakaiproject.user.api.User; //导入方法依赖的package包/类
/**
* Get the listing of students from the site gradebook, uses GB security so safe to call
*
* @param siteId
* the id of the site to get students from
* @return the list of Students
*/
public List<Student> getStudentsForCourse(String siteId) {
List<Student> students = new ArrayList<Student>();
Site site;
try {
site = siteService.getSite(siteId);
} catch (IdUnusedException e1) {
throw new IllegalArgumentException("No course found with id (" + siteId + ")");
}
// Get students grades for course. This method handles grade overrides.
Map courseGradeMap = gradebookService.getImportCourseGrade(siteId, false);
String siteRef = site.getReference();
// use the method gradebook uses internally
List<User> studentUsers = securityService.unlockUsers("section.role.student", siteRef);
for (User user : studentUsers) {
Student s = new Student(user.getId(), user.getEid(), user.getDisplayName(), user.getSortName(), user.getEmail());
s.fname = user.getFirstName();
s.lname = user.getLastName();
if (courseGradeMap!= null && courseGradeMap.containsKey(s.username)){
s.courseGrade = (String)courseGradeMap.get(s.username); // Pull student course grade from the map.
}
students.add(s);
}
/*** this only works in the post-2.5 gradebook -AZ
// Let the gradebook tell use how it defines the students The gradebookUID is the siteId
String gbID = siteId;
if (!gradebookService.isGradebookDefined(gbID)) {
throw new IllegalArgumentException("No gradebook found for course (" + siteId
+ "), gradebook must be installed in each course to use with this");
}
Map<String, String> studentToPoints = gradebookService.getImportCourseGrade(gbID);
ArrayList<String> eids = new ArrayList<String>(studentToPoints.keySet());
Collections.sort(eids);
for (String eid : eids) {
try {
User user = userDirectoryService.getUserByEid(eid);
students.add(new Student(user.getId(), user.getEid(), user.getDisplayName()));
} catch (UserNotDefinedException e) {
log.warn("Undefined user eid (" + eid + ") from site/gb (" + siteId + "): " + e);
}
}
***/
return students;
}