removeAttribute(currentAttribute);
p.getAttributes().size() == 3); p.removeAttribute(pa3); assertTrue("There should be only 2 attribute in the person object now", p.getAttributes().size() == 2); p.removeAttribute(pa3); assertTrue("There should be only 2 attribute in the person object now", p.getAttributes().size() == 2); p.removeAttribute(pa2); assertTrue("There should be only 1 attribute in the person object now", p.getAttributes().size() == 1); p.removeAttribute(pa2); assertTrue("There should still be only 1 attribute in the person object now", p.getAttributes().size() == 1); p.removeAttribute(pa1); assertTrue("There shouldn't be any attributes in the person object now", p.getAttributes().size() == 0);
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void purge(PersonAttribute delegate, RequestContext context) throws ResponseException { delegate.getPerson().removeAttribute(delegate); Context.getPersonService().savePerson(delegate.getPerson()); }
/** * Sets attributes on the given person. * * @param instance * @param attrs */ @PropertySetter("attributes") public static void setAttributes(Person instance, List<PersonAttribute> attrs) { for (PersonAttribute attr : attrs) { PersonAttribute existingAttribute = instance.getAttribute(Context.getPersonService() .getPersonAttributeTypeByUuid(attr.getAttributeType().getUuid())); if (existingAttribute != null) { if (attr.getValue() == null) { instance.removeAttribute(existingAttribute); } else { existingAttribute.setValue(attr.getValue()); } } else { instance.addAttribute(attr); } } }
PersonAttribute personAttribute = personToUpdate.getAttribute(attribute.getName()); if (personAttribute != null) { personToUpdate.removeAttribute(personAttribute);