Java User类代码示例

本文整理汇总了Java中org.openmrs.User的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Java User类代码示例

User类属于org.openmrs包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: UserListItem

import org.openmrs.User; //导入依赖的package包/类
public UserListItem(User user) {
	super((user == null) ? null : user.getPerson());
	
	if (user != null) {
		userId = user.getUserId();
		systemId = user.getSystemId();
		username = user.getUsername();
		int i = 0;
		roles = new String[user.getRoles().size()];
		for (Role r : user.getRoles()) {
			roles[i++] = r.getRole();
		}
		this.retired = user.isRetired();
		setVoided(retired); // so the parent PersonListItem class works is someone tries to use .voided
	}
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:17,代码来源:UserListItem.java

示例2: handleSubmission

import org.openmrs.User; //导入依赖的package包/类
/**
 * Method to save changes of the new password for a user. The password will be validated against
 * the current rules and will display error messages in case the password is not strong enough.
 * 
 * @should display an error message when the password and confirm password entries are different
 * @should not display error message if password and confirm password are the same
 * @should display error message when the password is empty
 * @should display error message if password is weak
 * @should display error message when question is empty and answer is not empty
 * @should display error message when the answer and the confirm answer entered are not the same
 * @should display error message when the answer is empty and question is not empty
 * @should navigate to the home page if the authentication is successful
 * @should set the user property forcePassword to false after successful password change
 * @should not set the user property forcePassword to false after unsuccessful password change
 * @should remain on the changePasswordForm page if there are errors
 * @should set the secret question and answer of the user
 * @param password to be applied
 * @param confirmPassword confirmation for the password to be applied
 * @param question in case of a forgotten password
 * @param answer answer for the question
 * @param confirmAnswer confirmation of the answer for the question
 * @param errors while processing the form
 */
@RequestMapping(method = RequestMethod.POST)
public String handleSubmission(HttpSession httpSession,
		@RequestParam(required = true, value = "oldPassword") String oldPassword,
        @RequestParam(required = true, value = "password") String password,
        @RequestParam(required = true, value = "confirmPassword") String confirmPassword,
        @RequestParam(required = false, value = "question") String question,
        @RequestParam(required = false, value = "answer") String answer,
        @RequestParam(required = false, value = "confirmAnswer") String confirmAnswer,
        @ModelAttribute("user") User user, BindingResult errors) {
	
	NewPassword newPassword = new NewPassword(password, confirmPassword);
	NewQuestionAnswer newQuestionAnswer = new NewQuestionAnswer(question, answer, confirmAnswer);
	new NewPasswordValidator(user).validate(newPassword, errors);
	new NewQuestionAnswerValidator().validate(newQuestionAnswer, errors);
	
	if (errors.hasErrors()) {
		return showForm(httpSession);
	}
	
	changeUserPasswordAndQuestion(user, oldPassword, newPassword, newQuestionAnswer);
	httpSession.removeAttribute(WebConstants.OPENMRS_MSG_ATTR);
	return "redirect:/index.htm";
	
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:48,代码来源:ChangePasswordFormController.java

示例3: changeUserPasswordAndQuestion

import org.openmrs.User; //导入依赖的package包/类
/**
 * Utility method to change the password and question/answer of the currently logged in user.
 * 
 * @param user for whom the password has to to be changed
 * @param password new password
 * @param questionAnswer (optional) security question and answer
 */
private void changeUserPasswordAndQuestion(User user, String oldPassword, NewPassword password, NewQuestionAnswer questionAnswer) {
	try {
		Context.addProxyPrivilege(PrivilegeConstants.EDIT_USERS);
		Context.addProxyPrivilege(PrivilegeConstants.GET_USERS);
		Context.addProxyPrivilege(PrivilegeConstants.EDIT_USER_PASSWORDS);
		
		UserService userService = Context.getUserService();
		User currentUser = userService.getUser(user.getId());
		
		userService.changePassword(currentUser, oldPassword, password.getPassword());
		
		new UserProperties(currentUser.getUserProperties()).setSupposedToChangePassword(false);
		userService.saveUser(currentUser);
		if (StringUtils.isNotBlank(questionAnswer.getQuestion()) || StringUtils.isNotBlank(questionAnswer.getAnswer())) {
			userService.changeQuestionAnswer(currentUser, questionAnswer.getQuestion(), questionAnswer.getAnswer());
		}
		
		Context.refreshAuthenticatedUser();
	}
	finally {
		Context.removeProxyPrivilege(PrivilegeConstants.EDIT_USERS);
		Context.removeProxyPrivilege(PrivilegeConstants.GET_USERS);
		Context.removeProxyPrivilege(PrivilegeConstants.EDIT_USER_PASSWORDS);
	}
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:33,代码来源:ChangePasswordFormController.java

示例4: getUsers

import org.openmrs.User; //导入依赖的package包/类
protected List<User> getUsers(String action, String name, Role role, Boolean includeDisabled) {
	// only do the search if there are search parameters or 
	if (action != null || StringUtils.hasText(name) || role != null) {
		if (includeDisabled == null) {
			includeDisabled = false;
		}
		List<Role> roles = null;
		if (role != null && StringUtils.hasText(role.getRole())) {
			roles = Collections.singletonList(role);
		}
		
		if (!StringUtils.hasText(name)) {
			name = null;
		}
		
		return Context.getUserService().getUsers(name, roles, includeDisabled);
	}
	
	return new ArrayList<User>();
	
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:UserListController.java

示例5: createAlert

import org.openmrs.User; //导入依赖的package包/类
/**
 * Creates and saves a new {@link Alert}
 *
 * @param text the string to set as the alert text
 * @return true if the alert was successfully created and saved otherwise false
 */
public boolean createAlert(String text) {
	if (StringUtils.isNotBlank(text)) {
		try {
			Context.addProxyPrivilege(PrivilegeConstants.MANAGE_ALERTS);
			Context.addProxyPrivilege(PrivilegeConstants.GET_USERS);
			Context.addProxyPrivilege(PrivilegeConstants.GET_ROLES);
			
			Role role = Context.getUserService().getRole("System Developer");
			Collection<User> users = Context.getUserService().getUsersByRole(role);
			Context.getAlertService().saveAlert(new Alert(text, users));
			
			return true;
		}
		catch (Exception e) {
			log.error("Error while creating an alert ", e);
		}
		finally {
			Context.removeProxyPrivilege(PrivilegeConstants.MANAGE_ALERTS);
			Context.removeProxyPrivilege(PrivilegeConstants.GET_USERS);
			Context.removeProxyPrivilege(PrivilegeConstants.GET_ROLES);
		}
	}
	
	return false;
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:32,代码来源:DWRAlertService.java

示例6: handleSubmission_createUserProviderAccountWhenProviderAccountCheckboxIsSelected

import org.openmrs.User; //导入依赖的package包/类
/**
 * @see UserFormController#handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)
 *
 */
@Test
@Verifies(value = "Creates Provider Account when Provider Account Checkbox is selected", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)")
public void handleSubmission_createUserProviderAccountWhenProviderAccountCheckboxIsSelected() throws Exception {
	executeDataSet(TEST_DATA);
	WebRequest request = new ServletWebRequest(new MockHttpServletRequest());
	//A user with userId=2 is preset in the Test DataSet and the relevant details are passed
	User user = Context.getUserService().getUser(2);
	Assert.assertTrue(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty());
	ModelMap model = new ModelMap();
	model.addAttribute("isProvider", false);
	controller.showForm(2, "true", user, model);
	controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "", null, "Test1234", "valid secret question", "valid secret answer", "Test1234",
			false, new String[] {"Provider"}, "true", "addToProviderTable", user, new BindException(user, "user"));
	Assert.assertFalse(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty());
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:20,代码来源:UserFormControllerTest.java

示例7: handleSubmission_shouldChangeTheUserPropertyForcePasswordChangeToFalse

import org.openmrs.User; //导入依赖的package包/类
/**
 * @see ChangePasswordFormController#handleSubmission(HttpSession, String, String, String, String, String, User, BindingResult)
 */
@Test
@Verifies(value = "set the user property forcePassword to false after successful password change", method = "handleSubmission()")
public void handleSubmission_shouldChangeTheUserPropertyForcePasswordChangeToFalse() throws Exception {
	User user = Context.getAuthenticatedUser();
	new UserProperties(user.getUserProperties()).setSupposedToChangePassword(true);
	
	UserService us = Context.getUserService();
	us.saveUser(user);
	
	ChangePasswordFormController controller = new ChangePasswordFormController();
	BindException errors = new BindException(controller.formBackingObject(), "user");
	
	controller.handleSubmission(new MockHttpSession(), oldPassword, "Passw0rd", "Passw0rd", "", "", "", Context
	        .getAuthenticatedUser(), errors);
	
	User modifiedUser = us.getUser(user.getId());
	assertTrue(!new UserProperties(modifiedUser.getUserProperties()).isSupposedToChangePassword());
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:ChangePasswordFormControllerTest.java

示例8: handleSubmission_shouldNotChangeTheUserPropertyForcePasswordChangeToFalse

import org.openmrs.User; //导入依赖的package包/类
/**
 * @see ChangePasswordFormController#handleSubmission(HttpSession, String, String, String, String, String, User, BindingResult)
 */
@Test
@Verifies(value = "do not set the user property forcePassword to false after unsuccessful password change", method = "handleSubmission()")
public void handleSubmission_shouldNotChangeTheUserPropertyForcePasswordChangeToFalse() throws Exception {
	User user = Context.getAuthenticatedUser();
	new UserProperties(user.getUserProperties()).setSupposedToChangePassword(true);
	
	UserService us = Context.getUserService();
	us.saveUser(user);
	
	ChangePasswordFormController controller = new ChangePasswordFormController();
	BindException errors = new BindException(controller.formBackingObject(), "user");
	
	controller.handleSubmission(new MockHttpSession(), oldPassword, "Passw0rd", "Pasw0rd", "", "", "",
	    Context.getAuthenticatedUser(), errors);
	
	User modifiedUser = us.getUser(user.getId());
	assertTrue(new UserProperties(modifiedUser.getUserProperties()).isSupposedToChangePassword());
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:ChangePasswordFormControllerTest.java

示例9: handleSubmission_shouldSetTheUserSecretQuestionAndAnswer

import org.openmrs.User; //导入依赖的package包/类
/**
 * @see ChangePasswordFormController#handleSubmission(HttpSession, String, String, String, String, String, User, BindingResult)
 */
@Test
@Verifies(value = "set the secret question and answer of the user", method = "handleSubmission()")
public void handleSubmission_shouldSetTheUserSecretQuestionAndAnswer() throws Exception {
	User user = Context.getAuthenticatedUser();
	new UserProperties(user.getUserProperties()).setSupposedToChangePassword(true);
	
	UserService us = Context.getUserService();
	us.saveUser(user);
	
	ChangePasswordFormController controller = new ChangePasswordFormController();
	BindException errors = new BindException(controller.formBackingObject(), "user");
	
	controller.handleSubmission(new MockHttpSession(), oldPassword, "Passw0rd", "Passw0rd", "test_question", "test_answer",
	    "test_answer", Context.getAuthenticatedUser(), errors);
	
	User modifiedUser = us.getUser(user.getId());
	
	assertTrue(us.isSecretAnswer(modifiedUser, "test_answer"));
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:23,代码来源:ChangePasswordFormControllerTest.java

示例10: isSupposedToChangePassword_shouldReturnTrueOrFalseBasedOnTheValueInUserProperties

import org.openmrs.User; //导入依赖的package包/类
/**
 * @see UserProperties#isSupposedToChangePassword()
 */
@Test
@Verifies(value = "return true or false depending on the presence or absence of forcePassword key in "
        + "the user properties", method = "isSupposedToChangePassword()")
public void isSupposedToChangePassword_shouldReturnTrueOrFalseBasedOnTheValueInUserProperties() throws Exception {
	User user = new User();
	UserProperties userProperties = new UserProperties(user.getUserProperties());
	assertFalse(userProperties.isSupposedToChangePassword());
	
	userProperties.setSupposedToChangePassword(true);
	assertTrue(userProperties.isSupposedToChangePassword());
	
	userProperties.setSupposedToChangePassword(false);
	assertFalse(userProperties.isSupposedToChangePassword());
	
	userProperties.setSupposedToChangePassword(null);
	assertFalse(userProperties.isSupposedToChangePassword());
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:21,代码来源:UserPropertiesTest.java

示例11: printObject

import org.openmrs.User; //导入依赖的package包/类
/**
 * Formats anything and prints it to string builder. (Delegates to other methods here)
 * @param sb the string builder to print object with
 * @param o the object to print
 */
private void printObject(StringBuilder sb, Object o) {
	if (o instanceof Collection<?>) {
		for (Iterator<?> i = ((Collection<?>) o).iterator(); i.hasNext();) {
			printObject(sb, i.next());
			if (i.hasNext()) {
				sb.append(", ");
			}
		}
	} else if (o instanceof Date) {
		printDate(sb, (Date) o);
	} else if (o instanceof Concept) {
		printConcept(sb, (Concept) o);
	} else if (o instanceof Obs) {
		sb.append(StringEscapeUtils.escapeHtml(((Obs) o).getValueAsString(Context.getLocale())));
	} else if (o instanceof User) {
		printUser(sb, (User) o);
	} else if (o instanceof Encounter) {
		printEncounter(sb, (Encounter) o);
	} else if (o instanceof Visit) {
		printVisit(sb, (Visit) o);
	} else if (o instanceof Program) {
		printProgram(sb, (Program) o);
	} else if (o instanceof Provider) {
		printProvider(sb, (Provider) o);
	} else if (o instanceof Form) {
		printForm(sb, (Form) o);
	} else if (o instanceof SingleCustomValue<?>) {
		printSingleCustomValue(sb, (SingleCustomValue<?>) o);
	} else if (o instanceof OpenmrsMetadata) {
		printMetadata(sb, (OpenmrsMetadata) o);
	} else {
		sb.append("" + StringEscapeUtils.escapeHtml(o.toString()));
	}
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:40,代码来源:FormatTag.java

示例12: printUser

import org.openmrs.User; //导入依赖的package包/类
/**
 * formats a user and prints it to sb
 *
 * @param sb
 * @param u
 */
private void printUser(StringBuilder sb, User u) {
	sb.append("<span class=\"user\">");
	sb.append("<span class=\"username\">");
	sb.append(StringEscapeUtils.escapeHtml(u.getUsername()));
	sb.append("</span>");
	if (u.getPerson() != null) {
		sb.append("<span class=\"personName\">");
		sb.append(" (").append(StringEscapeUtils.escapeHtml(u.getPersonName().getFullName())).append(")");
		sb.append("</span>");
	}
	sb.append("</span>");
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:19,代码来源:FormatTag.java

示例13: run

import org.openmrs.User; //导入依赖的package包/类
public void run() {
	htmlInclude("/scripts/dojoConfig.js");
	htmlInclude("/scripts/dojo/dojo.js");
	htmlInclude("/scripts/dojoUserSearchIncludes.js");
	
	setUrl(defaultUrl);
	checkEmptyVal((User) null);
	if (fieldGenTag != null) {
		Object initialValue = this.fieldGenTag.getVal();
		setParameter("initialValue", initialValue == null ? "" : initialValue);
	}
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:13,代码来源:UserHandler.java

示例14: doStartTag

import org.openmrs.User; //导入依赖的package包/类
public int doStartTag() {
	User user = Context.getUserService().getUser(userId);
	
	try {
		JspWriter w = pageContext.getOut();
		w.print(user.getPersonName());
		if ("full".equals(size)) {
			w.print(" <i>(" + user.getUsername() + ")</i>");
		}
	}
	catch (IOException ex) {
		log.error("Error while starting userWidget tag", ex);
	}
	return SKIP_BODY;
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:16,代码来源:UserWidgetTag.java

示例15: compare

import org.openmrs.User; //导入依赖的package包/类
public int compare(User user1, User user2) {
	
	// compare on full name (and then on user id in case the names are identical) 
	String name1 = "" + user1.getPersonName() + user1.getUserId();
	String name2 = "" + user2.getPersonName() + user2.getUserId();
	
	return name1.compareTo(name2);
} 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:9,代码来源:DWRUserService.java

本文标签属性:

示例:示例英语

代码:代码大全可复制

java:java模拟器

User:userprofileservice服务登录失败重装系统也没用

上一篇:C++ FactMgr::set_fact_in方法代码示例(c++factmgr::set_fact_in方法的典型用法代码示例)
下一篇:农博会是干什么的(中国有哪些农产品博览会)(2023年长春农博会门票)

为您推荐