@Override protected PersonEditor getNewEditor() { return new PersonEditor(); }
/** * @see java.beans.PropertyEditorSupport#getAsText() */ @Override public String getAsText() { Person t = (Person) getValue(); if (t == null) { return ""; } else { return (t.getPersonId() == null) ? "" : t.getPersonId().toString(); } }
/** * @should set using id * @should set using uuid * * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) */ @Override public void setAsText(String text) throws IllegalArgumentException { PersonService ps = Context.getPersonService(); if (StringUtils.hasText(text)) { try { Integer personId = Integer.valueOf(text); setValue(ps.getPerson(personId)); } catch (NumberFormatException e) { Person person = ps.getPersonByUuid(text); setValue(person); if (person == null) { throw new IllegalArgumentException("Failed to find person for value [" + text + "]"); } } } else { setValue(null); } }
return ed.getValue(); } else if (Person.class.isAssignableFrom(clazz)) { PersonEditor ed = new PersonEditor(); ed.setAsText(val); return ed.getValue(); } else if (EncounterType.class.isAssignableFrom(clazz)) { EncounterTypeEditor ed = new EncounterTypeEditor();
wdb.registerCustomEditor(PersonAttribute.class, new PersonAttributeEditor()); wdb.registerCustomEditor(PersonAttributeType.class, new PersonAttributeTypeEditor()); wdb.registerCustomEditor(Person.class, new PersonEditor()); wdb.registerCustomEditor(Privilege.class, new PrivilegeEditor()); wdb.registerCustomEditor(Program.class, new ProgramEditor());