本文整理汇总了Java中org.openmrs.api.context.Context类的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于org.openmrs.api.context包,在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doStartTag_shouldIncludeBodyForUserWithoutAnyOfThePrivilegesIfHasAllIsTrueAndInverseIsTrue
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @verifies include body for user without any of the privileges if hasAll is true and inverse is true
* @see PrivilegeTag#doStartTag()
*/
@Test
@SkipBaseSetup
public void doStartTag_shouldIncludeBodyForUserWithoutAnyOfThePrivilegesIfHasAllIsTrueAndInverseIsTrue()
throws Exception {
initializeInMemoryDatabase();
executeDataSet("org/openmrs/web/taglib/include/PrivilegeTagTest.xml");
Context.authenticate("clinician1", "test");
PrivilegeTag tag = new PrivilegeTag();
tag.setPageContext(new MockPageContext());
tag.setPrivilege("Edit Patients,Manage Patients");
tag.setHasAll("true");
tag.setInverse("true");
assertThat(tag.doStartTag(), is(Tag.EVAL_BODY_INCLUDE));
Context.logout();
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:24,代码来源:PrivilegeTagTest.java
示例2: processFormSubmission
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object object,
BindException errors) throws Exception {
Concept concept = (Concept) object;
ConceptService cs = Context.getConceptService();
// check to see if they clicked next/previous concept:
String jumpAction = request.getParameter("jumpAction");
if (jumpAction != null) {
Concept newConcept = null;
if ("previous".equals(jumpAction)) {
newConcept = cs.getPrevConcept(concept);
} else if ("next".equals(jumpAction)) {
newConcept = cs.getNextConcept(concept);
}
if (newConcept != null) {
return new ModelAndView(new RedirectView(getSuccessView() + "?conceptId=" + newConcept.getConceptId()));
}
}
return new ModelAndView(new RedirectView(getSuccessView()));
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:30,代码来源:ConceptStatsFormController.java
示例3: createObservation_shouldCreateObservationWithCodedConcept
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with coded concepts", method = "createObs(Integer, Integer,Integer, String, String)")
public void createObservation_shouldCreateObservationWithCodedConcept() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(21);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
dwrService.createObs(2, null, 21, "7", "1/12/2014");
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListBefore.size() + 1, obsListAfter.size());
Concept answerConcept = conceptService.getConcept(7);
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(answerConcept, addedObs.getValueCoded());
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:DWRObservationServiceTest.java
示例4: formBackingObject
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
Privilege privilege = null;
if (Context.isAuthenticated()) {
UserService us = Context.getUserService();
String r = request.getParameter("privilege");
if (r != null) {
privilege = us.getPrivilege(r);
}
}
if (privilege == null) {
privilege = new Privilege();
}
return privilege;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:25,代码来源:PrivilegeFormController.java
示例5: onSubmit
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(HttpServletRequest,
* HttpServletResponse, Object,
* BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
BindException errors) throws Exception {
if (!Context.hasPrivilege(PrivilegeConstants.MANAGE_MODULES)) {
throw new APIAuthenticationException("Privilege required: " + PrivilegeConstants.MANAGE_MODULES);
}
HttpSession httpSession = request.getSession();
String view = getFormView();
String success = "";
String error = "";
view = getSuccessView();
if (!"".equals(success)) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success);
}
if (!"".equals(error)) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error);
}
return new ModelAndView(new RedirectView(view));
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:33,代码来源:ModulePropertiesFormController.java
示例6: doStartTag
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* Does the actual working of printing the time pattern
*
* @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
*/
@Override
public int doStartTag() {
SimpleDateFormat dateFormat = Context.getTimeFormat();
try {
String pattern;
if ((localize != null) && "false".equals(localize)) {
pattern = dateFormat.toPattern().toLowerCase();
} else {
pattern = dateFormat.toLocalizedPattern();
}
if (null != format && format.equals("jquery")) {
pattern = pattern.toLowerCase().replaceAll("a", "TT");
}
pageContext.getOut().write(pattern);
}
catch (Exception e) {
log.error("error getting date pattern", e);
}
return SKIP_BODY;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:31,代码来源:TimePatternTag.java
示例7: doStartTag_shouldSkipBodyForUserWithAllOfThePrivilegesIfHasAllIsTrueAndInverseIsTrue
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @verifies skip body for user with all of the privileges if hasAll is true and inverse is true
* @see PrivilegeTag#doStartTag()
*/
@Test
@SkipBaseSetup
public void doStartTag_shouldSkipBodyForUserWithAllOfThePrivilegesIfHasAllIsTrueAndInverseIsTrue() throws Exception {
initializeInMemoryDatabase();
executeDataSet("org/openmrs/web/taglib/include/PrivilegeTagTest.xml");
Context.authenticate("dataclerk1", "test");
PrivilegeTag tag = new PrivilegeTag();
tag.setPageContext(new MockPageContext());
tag.setPrivilege("View Patients,Edit Patients,Manage Patients");
tag.setHasAll("true");
tag.setInverse("true");
assertThat(tag.doStartTag(), is(Tag.SKIP_BODY));
Context.logout();
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:23,代码来源:PrivilegeTagTest.java
示例8: formBackingObject
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
@Override
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
Encounter encounter = null;
if (Context.isAuthenticated()) {
EncounterService es = Context.getEncounterService();
String encounterId = request.getParameter("encounterId");
if (encounterId != null) {
encounter = es.getEncounter(Integer.valueOf(encounterId));
}
}
if (encounter == null) {
encounter = new Encounter();
}
return encounter;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:26,代码来源:EncounterFormController.java
示例9: doStartTag
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* Does the actual working of printing the date pattern
*
* @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
*/
@Override
public int doStartTag() {
SimpleDateFormat dateFormat = Context.getDateFormat();
try {
String pattern = dateFormat.toLocalizedPattern().toLowerCase();
if ((localize != null) && "false".equals(localize)) {
pattern = dateFormat.toPattern().toLowerCase();
}
pageContext.getOut().write(pattern);
}
catch (Exception e) {
log.error("error getting date pattern", e);
}
return SKIP_BODY;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:26,代码来源:DatePatternTag.java
示例10: formBackingObject
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
VisitAttributeType visitAttributeType = null;
if (Context.isAuthenticated()) {
VisitService os = Context.getVisitService();
String visitAttributeTypeId = request.getParameter("visitAttributeTypeId");
if (visitAttributeTypeId != null) {
visitAttributeType = os.getVisitAttributeType(Integer.valueOf(visitAttributeTypeId));
}
}
if (visitAttributeType == null) {
visitAttributeType = new VisitAttributeType();
}
return visitAttributeType;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:25,代码来源:VisitAttributeTypeFormController.java
示例11: onSubmit_shouldVoidASynonymMarkedAsPreferredWhenItIsRemoved
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @see ConceptFormController#onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
*/
@Test
@Verifies(value = "should void a synonym marked as preferred when it is removed", method = "onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)")
public void onSubmit_shouldVoidASynonymMarkedAsPreferredWhenItIsRemoved() throws Exception {
ConceptService cs = Context.getConceptService();
Concept concept = cs.getConcept(5497);
//mark one of the synonyms as preferred
ConceptName preferredName = new ConceptName("pref name", britishEn);
preferredName.setLocalePreferred(true);
concept.addName(preferredName);
cs.saveConcept(concept);
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "5497");
//remove the synonym that is marked as preferred
mockRequest.setParameter("synonymsByLocale[en_GB][0].voided", "true");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Assert.assertEquals(true, preferredName.isVoided());
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:29,代码来源:ConceptFormControllerTest.java
示例12: formBackingObject
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
ConceptProposal cp = new ConceptProposal();
if (Context.isAuthenticated()) {
ConceptService cs = Context.getConceptService();
EncounterService es = Context.getEncounterService();
String id = ServletRequestUtils.getStringParameter(request, "encounterId");
if (id != null) {
cp.setEncounter(es.getEncounter(Integer.valueOf(id)));
}
id = ServletRequestUtils.getStringParameter(request, "obsConceptId");
if (id != null) {
cp.setObsConcept(cs.getConcept(Integer.valueOf(id)));
}
}
return cp;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:28,代码来源:ProposeConceptFormController.java
示例13: formBackingObject
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
ConceptSource conceptSource = null;
if (Context.isAuthenticated()) {
ConceptService cs = Context.getConceptService();
String conceptSourceId = request.getParameter("conceptSourceId");
if (conceptSourceId != null) {
conceptSource = cs.getConceptSource(Integer.valueOf(conceptSourceId));
}
}
if (conceptSource == null) {
conceptSource = new ConceptSource();
}
return conceptSource;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:25,代码来源:ConceptSourceFormController.java
示例14: doStartTag_shouldIncludeBodyForUserWithAllOfThePrivilegesIfHasAllIsTrue
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @verifies include body for user with all of the privileges if hasAll is true
* @see PrivilegeTag#doStartTag()
*/
@Test
@SkipBaseSetup
public void doStartTag_shouldIncludeBodyForUserWithAllOfThePrivilegesIfHasAllIsTrue() throws Exception {
initializeInMemoryDatabase();
executeDataSet("org/openmrs/web/taglib/include/PrivilegeTagTest.xml");
Context.authenticate("dataclerk1", "test");
PrivilegeTag tag = new PrivilegeTag();
tag.setPageContext(new MockPageContext());
tag.setPrivilege("View Patients,Edit Patients,Manage Patients");
tag.setHasAll("true");
assertThat(tag.doStartTag(), is(Tag.EVAL_BODY_INCLUDE));
Context.logout();
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:PrivilegeTagTest.java
示例15: backupDHIS2APIImport
import org.openmrs.api.context.Context; //导入依赖的package包/类
@RequestMapping(value = "/module/dhisconnector/dhis2BackupImport", method = RequestMethod.POST)
public void backupDHIS2APIImport(ModelMap model,
@RequestParam(value = "dhis2APIbBackup", required = false) MultipartFile dhis2APIbBackup) {
if (StringUtils.isNotBlank(dhis2APIbBackup.getOriginalFilename())
&& dhis2APIbBackup.getOriginalFilename().endsWith(".zip")) {
String msg = Context.getService(DHISConnectorService.class).uploadDHIS2APIBackup(dhis2APIbBackup);
if (msg.startsWith("Successfully")) {
failureOrSuccessFeedback(model, "", msg);
} else {
failureOrSuccessFeedback(model, msg, "");
}
} else {
failureOrSuccessFeedback(model,
Context.getMessageSourceService().getMessage("dhisconnector.dhis2backup.wrongUpload"), "");
}
}
开发者ID:jembi,项目名称:openmrs-module-dhisconnector,代码行数:18,代码来源:DHISConnectorController.java
示例16: doStartTag_shouldIncludeBodyForUserWithoutThePrivilegeIfInverseIsTrue
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @verifies include body for user without the privilege if inverse is true
* @see PrivilegeTag#doStartTag()
*/
@Test
@SkipBaseSetup
public void doStartTag_shouldIncludeBodyForUserWithoutThePrivilegeIfInverseIsTrue() throws Exception {
initializeInMemoryDatabase();
executeDataSet("org/openmrs/web/taglib/include/PrivilegeTagTest.xml");
Context.authenticate("clinician1", "test");
PrivilegeTag tag = new PrivilegeTag();
tag.setPageContext(new MockPageContext());
tag.setPrivilege("Manage Patients");
tag.setInverse("true");
assertThat(tag.doStartTag(), is(Tag.EVAL_BODY_INCLUDE));
Context.logout();
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:PrivilegeTagTest.java
示例17: addEncounterAndObservationCounts
import org.openmrs.api.context.Context; //导入依赖的package包/类
private void addEncounterAndObservationCounts(Visit visit, List<Integer> encounterIds, ModelMap model) {
int encounterCount = 0;
int observationCount = 0;
EncounterService encounterService = Context.getEncounterService();
if (visit != null && visit.getId() != null) {
List<Encounter> encounters = encounterService.getEncountersByVisit(visit, false);
encounterCount = encounters.size();
if (!encounters.isEmpty()) {
observationCount = Context.getObsService().getObservationCount(null, encounters, null, null, null, null,
null, null, null, false);
}
}
if (encounterIds != null) {
List<Encounter> visitEncounters = new ArrayList<Encounter>();
for (Integer encounterId : encounterIds) {
visitEncounters.add(encounterService.getEncounter(encounterId));
}
model.put("visitEncounters", visitEncounters);
}
model.put("encounterCount", encounterCount);
model.put("observationCount", observationCount);
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:26,代码来源:VisitFormController.java
示例18: handleSubmission
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* Handle the add new ConceptStopWord
*
* @param httpSession
* @param conceptStopWord
* @param errors
* @return path to forward to or an error message
* @should add new ConceptStopWord
* @should return error message if a duplicate ConceptStopWord is added
* @should return error message for an empty ConceptStopWord
*/
@RequestMapping(method = RequestMethod.POST)
public String handleSubmission(HttpSession httpSession, @ModelAttribute("command") ConceptStopWord conceptStopWord,
BindingResult errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "value", "ConceptStopWord.error.value.empty");
if (errors.hasErrors()) {
return showForm();
}
try {
Context.getConceptService().saveConceptStopWord(conceptStopWord);
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ConceptStopWord.saved");
}
catch (ConceptStopWordException e) {
log.error("Error on adding concept stop word", e);
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
return showForm();
}
return "redirect:conceptStopWord.list";
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:34,代码来源:ConceptStopWordFormController.java
示例19: showPage
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* Called for GET requests only on the databaseChangesInfo page. POST page
* requests are invalid and ignored.
*
* @param model the key value pair that will be accessible from the jsp page
* @throws Exception if there is trouble getting the database changes from liquibase
*/
@RequestMapping(method = RequestMethod.GET, value = "admin/maintenance/localesAndThemes")
public String showPage(ModelMap model) throws Exception {
String theme = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_THEME);
model.addAttribute("theme", theme);
String locale = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE);
model.addAttribute("locale", locale);
String allowedLocales = Context.getAdministrationService().getGlobalProperty(
OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST);
model.addAttribute("allowedLocales", allowedLocales);
return "/module/legacyui/admin/maintenance/localesAndThemes";
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:23,代码来源:LocalesAndThemesFormController.java
示例20: doStartTag_shouldIncludeBodyForUserWithThePrivilege
import org.openmrs.api.context.Context; //导入依赖的package包/类
/**
* @verifies include body for user with the privilege
* @see PrivilegeTag#doStartTag()
*/
@Test
@SkipBaseSetup
public void doStartTag_shouldIncludeBodyForUserWithThePrivilege() throws Exception {
initializeInMemoryDatabase();
executeDataSet("org/openmrs/web/taglib/include/PrivilegeTagTest.xml");
Context.authenticate("dataclerk1", "test");
PrivilegeTag tag = new PrivilegeTag();
tag.setPageContext(new MockPageContext());
tag.setPrivilege("View Patients");
assertThat(tag.doStartTag(), is(Tag.EVAL_BODY_INCLUDE));
Context.logout();
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:21,代码来源:PrivilegeTagTest.java
注:本文中的org.openmrs.api.context.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论