/** * @see org.openmrs.api.db.PersonDAO#getSavedPersonAttributeTypeName(org.openmrs.PersonAttributeType) */ @Override public String getSavedPersonAttributeTypeName(PersonAttributeType personAttributeType) { SQLQuery sql = sessionFactory.getCurrentSession().createSQLQuery( "select name from person_attribute_type where person_attribute_type_id = :personAttributeTypeId"); sql.setInteger("personAttributeTypeId", personAttributeType.getId()); return (String) sql.uniqueResult(); }
if (type.getId() != null) { updateExisting = true;
/** * @see Person#getAttribute(Integer) */ @Test public void getAttribute_shouldreturnPersonAttributeBasedOnAttributeTypeId() { Person person = personHelper(false, 1, 2, 3, "name1", "name2", "name3", "value1", "value2", "value3"); Assert.assertEquals(new Integer(3), person.getAttribute(3).getAttributeType().getId()); }
/** * @see PersonService#purgePersonAttributeType(PersonAttributeType) */ @Test public void purgePersonAttributeType_shouldDeletePersonAttributeTypeFromDatabase() throws Exception { PersonService service = Context.getPersonService(); PersonAttributeType pat = new PersonAttributeType(); pat.setName("attr type name"); pat.setDescription("attr type desc"); pat.setFormat("java.lang.String"); service.savePersonAttributeType(pat); assertNotNull(pat.getId()); service.purgePersonAttributeType(pat); PersonAttributeType deletedPersonAttributeType = service.getPersonAttributeType(pat.getId()); Assert.assertNull(deletedPersonAttributeType); }