當前位置: 首頁>>代碼示例>>Java>>正文


Java ConceptService.saveConcept方法代碼示例

本文整理匯總了Java中org.openmrs.api.ConceptService.saveConcept方法的典型用法代碼示例。如果您正苦於以下問題:Java ConceptService.saveConcept方法的具體用法?Java ConceptService.saveConcept怎麽用?Java ConceptService.saveConcept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openmrs.api.ConceptService的用法示例。


在下文中一共展示了ConceptService.saveConcept方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSubmit_shouldVoidASynonymMarkedAsPreferredWhenItIsRemoved

import org.openmrs.api.ConceptService; //導入方法依賴的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

示例2: shouldVoidShortName

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test removing short name by adding a blank short name
 *
 * @throws Exception
 */
@Test
public void shouldVoidShortName() throws Exception {
	final String CONCEPT_NAME = "default concept name";
	
	ConceptService cs = Context.getConceptService();
	
	final Concept concept = new Concept();
	concept.addName(new ConceptName(CONCEPT_NAME, britishEn));
	concept.setShortName(new ConceptName("shortname", britishEn));
	concept.addDescription(new ConceptDescription("some description", null));
	cs.saveConcept(concept);
	
	Concept actualConcept = cs.getConceptByName(CONCEPT_NAME);
	assertThat(actualConcept.getShortNameInLocale(britishEn), is(notNullValue()));
	assertThat(actualConcept.getShortNames().size(), greaterThan(0));
	assertThat(actualConcept.getNames().size(), is(2));
	
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("conceptId", concept.getConceptId().toString());
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", " ");
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	
	actualConcept = cs.getConceptByName(CONCEPT_NAME);
	assertThat(actualConcept.getShortNameInLocale(britishEn), is(nullValue()));
	assertThat(actualConcept.getShortNames().size(), is(0));
	assertThat(actualConcept.getNames().size(), is(1));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:42,代碼來源:ConceptFormControllerTest.java

示例3: shouldReplacePreviousDescription

import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
 * Test adding a concept with a preferred name, short name, description and synonyms.
 * 
 * @throws Exception
 */
@Test
public void shouldReplacePreviousDescription() throws Exception {
	final String EXPECTED_PREFERRED_NAME = "no such concept";
	final String EXPECTED_SHORT_NAME = "nonesuch";
	final String ORIGINAL_DESCRIPTION = "this is indescribable";
	final String EXPECTED_DESCRIPTION = "this is not really a concept";
	final String EXPECTED_SYNONYM_A = "phantom";
	final String EXPECTED_SYNONYM_B = EXPECTED_SHORT_NAME;
	final String EXPECTED_SYNONYM_C = "mock";
	
	ConceptService cs = Context.getConceptService();
	
	// first, add the concept with an original description
	Concept conceptToUpdate = new Concept();
	conceptToUpdate.addName(new ConceptName("demo name", Context.getLocale()));
	ConceptDescription originalConceptDescription = new ConceptDescription();
	originalConceptDescription.setLocale(britishEn);
	originalConceptDescription.setDescription(ORIGINAL_DESCRIPTION);
	conceptToUpdate.addDescription(originalConceptDescription);
	cs.saveConcept(conceptToUpdate);
	
	// then submit changes through the controller
	ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
	
	MockHttpServletRequest mockRequest = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	
	mockRequest.setMethod("POST");
	mockRequest.setParameter("action", "");
	mockRequest.setParameter("synonymsByLocale[en_GB][0].name", EXPECTED_SYNONYM_A);
	mockRequest.setParameter("synonymsByLocale[en_GB][1].name", EXPECTED_SYNONYM_B);
	mockRequest.setParameter("synonymsByLocale[en_GB][2].name", EXPECTED_SYNONYM_C);
	mockRequest.setParameter("shortNamesByLocale[en_GB].name", EXPECTED_SHORT_NAME);
	mockRequest.setParameter("descriptionsByLocale[en_GB].description", EXPECTED_DESCRIPTION);
	mockRequest.setParameter("namesByLocale[en_GB].name", EXPECTED_PREFERRED_NAME);
	mockRequest.setParameter("concept.datatype", "1");
	
	ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
	assertNotNull(mav);
	assertTrue(mav.getModel().isEmpty());
	
	Concept actualConcept = cs.getConceptByName(EXPECTED_PREFERRED_NAME);
	assertNotNull(actualConcept);
	
	assertNotNull(actualConcept.getDescription(britishEn));
	assertEquals(EXPECTED_DESCRIPTION, actualConcept.getDescription(britishEn).getDescription());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:53,代碼來源:ConceptFormControllerTest.java


注:本文中的org.openmrs.api.ConceptService.saveConcept方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。