Java 类org.apache.commons.collections.FactoryUtils 实例源码

项目:openmrs-module-legacyui    文件:ShortPatientModel.java   
/**
 * Constructor that creates a shortPatientModel object from a given patient object
 *
 * @param patient
 */
@SuppressWarnings("unchecked")
public ShortPatientModel(Patient patient) {
    if (patient != null) {
        this.patient = patient;
        this.personName = patient.getPersonName();
        this.personAddress = patient.getPersonAddress();
        List<PatientIdentifier> activeIdentifiers = patient.getActiveIdentifiers();
        if (activeIdentifiers.isEmpty()) {
            final PatientIdentifierType defaultIdentifierType = getDefaultIdentifierType();
            activeIdentifiers.add(new PatientIdentifier(null, defaultIdentifierType, (LocationUtility
                    .getUserDefaultLocation() != null) ? LocationUtility.getUserDefaultLocation() : LocationUtility
                    .getDefaultLocation()));
        }

        identifiers = ListUtils.lazyList(new ArrayList<PatientIdentifier>(activeIdentifiers), FactoryUtils
                .instantiateFactory(PatientIdentifier.class));

        List<PersonAttributeType> viewableAttributeTypes = Context.getPersonService().getPersonAttributeTypes(
            PERSON_TYPE.PATIENT, ATTR_VIEW_TYPE.VIEWING);

        personAttributes = new ArrayList<PersonAttribute>();
        if (!CollectionUtils.isEmpty(viewableAttributeTypes)) {
            for (PersonAttributeType personAttributeType : viewableAttributeTypes) {
                PersonAttribute persistedAttribute = patient.getAttribute(personAttributeType);
                //This ensures that empty attributes are added for those we want to display 
                //in the view, but have no values
                PersonAttribute formAttribute = new PersonAttribute(personAttributeType, null);

                //send a clone to the form so that we can use the original to track changes in the values
                if (persistedAttribute != null) {
                    BeanUtils.copyProperties(persistedAttribute, formAttribute);
                }

                personAttributes.add(formAttribute);
            }
        }
    }
}
项目:openmrs-module-legacyui    文件:ConceptReferenceTermFormController.java   
/**
 * Constructor that creates a concept reference term model object from the specified term
 *
 * @param conceptReferenceTerm
 */
@SuppressWarnings("unchecked")
public ConceptReferenceTermModel(ConceptReferenceTerm conceptReferenceTerm) {
    this.conceptReferenceTerm = conceptReferenceTerm;
    List<ConceptReferenceTermMap> maps = null;
    if (conceptReferenceTerm.getConceptReferenceTermMaps().size() == 0) {
        maps = new ArrayList<ConceptReferenceTermMap>();
        maps.add(new ConceptReferenceTermMap(null, null));
    } else {
        maps = new ArrayList<ConceptReferenceTermMap>(conceptReferenceTerm.getConceptReferenceTermMaps());
    }

    termMaps = ListUtils.lazyList(maps, FactoryUtils.instantiateFactory(ConceptReferenceTermMap.class));
}