Example usage for org.apache.commons.collections FactoryUtils instantiateFactory

List of usage examples for org.apache.commons.collections FactoryUtils instantiateFactory

Introduction

In this page you can find the example usage for org.apache.commons.collections FactoryUtils instantiateFactory.

Prototype

public static Factory instantiateFactory(Class classToInstantiate) 

Source Link

Document

Creates a Factory that can create objects of a specific type using a no-args constructor.

Usage

From source file:MapHeavenV1.java

private void createMaps() {
    cIMap = new CaseInsensitiveMap();
    identMap = new IdentityMap();
    lazyMap = LazyMap.decorate(new HashMap(), FactoryUtils.instantiateFactory(StringBuffer.class));
}

From source file:gallery.model.command.MultiAutoreplaceCms.java

public MultiAutoreplaceCms(int size) {
    autoreplaces = LazyMap.decorate(new HashMap(), FactoryUtils.instantiateFactory(AutoreplaceL.class));
    /*autoreplaces = new Vector();
    for (int i=0;i<size;i++){/*from  w  w w . ja  v  a  2 s.co  m*/
       Autoreplace a = new Autoreplace();
       a.setActive(Boolean.FALSE);
       AutoreplaceL al = new AutoreplaceL();
       al.setParent(a);
       autoreplaces.add(al);
    }*/
    /*id = Long.valueOf[size];
    text = new String[size];
    code = new String[size];
    sort = Long.valueOf[size];
    active = new Boolean[size];
    java.util.Arrays.fill(active, Boolean.FALSE);*/
}

From source file:org.dspace.app.webui.cris.controller.FormUserWSController.java

@Override
protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Context context = UIUtil.obtainContext(request);
    if (!AuthorizeManager.isAdmin(context)) {
        throw new AuthorizeException("Only system administrator can access to the functionality");
    }//from w w  w .j  a va2s.  c  o  m

    User userws = (User) super.formBackingObject(request);
    String id = request.getParameter("id");
    if (id != null && !id.isEmpty()) {
        userws = applicationService.get(User.class, Integer.parseInt(id));
    }

    if (userws.getCriteria().isEmpty()) {
        for (String criteria : objectTypes) {
            Criteria newCriteria = new Criteria();
            newCriteria.setCriteria(criteria);
            newCriteria.setFilter("");
            newCriteria.setEnabled(false);
            userws.getCriteria().add(newCriteria);
        }
    }
    userws.setCriteria(
            LazyList.decorate(userws.getCriteria(), FactoryUtils.instantiateFactory(Criteria.class)));
    return userws;
}

From source file:org.dspace.app.webui.cris.dto.DynamicAnagraficaObjectDTO.java

/**
 * Decorate list for dynamic binding with spring mvc
 * //from ww w  .  j  a va2 s  .  c  om
 * @param list
 * @return lazy list temporary
 */
private List getLazyList(List<String> list) {
    log.debug("Decorate list for dynamic binding with spring mvc");
    List lazyList = LazyList.decorate(list, FactoryUtils.instantiateFactory(String.class));

    return lazyList;
}

From source file:org.dspace.app.webui.cris.dto.RPAnagraficaObjectDTO.java

/**
 * Decorate list for dynamic binding with spring mvc
 * //from www. j av  a  2  s .c o m
 * @param list
 * @return lazy list temporary
 */
private List getLazyList(List<RestrictedField> list) {
    log.debug("Decorate list for dynamic binding with spring mvc");
    List lazyList = LazyList.decorate(list, FactoryUtils.instantiateFactory(RestrictedField.class));

    return lazyList;
}

From source file:org.opencms.gwt.CmsVfsService.java

/**
 * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#getBrokenLinks(java.lang.String)
 *///w  w  w  . j  ava2 s. c om
public CmsDeleteResourceBean getBrokenLinks(String sitePath) throws CmsRpcException {

    try {
        CmsResource entryResource = getCmsObject().readResource(sitePath, CmsResourceFilter.IGNORE_EXPIRATION);
        CmsDeleteResourceBean result = null;

        CmsListInfoBean info = null;
        List<CmsBrokenLinkBean> brokenLinks = null;

        CmsObject cms = getCmsObject();
        String resourceSitePath = cms.getSitePath(entryResource);

        try {
            ensureSession();

            List<CmsResource> descendants = new ArrayList<CmsResource>();
            HashSet<CmsUUID> deleteIds = new HashSet<CmsUUID>();

            descendants.add(entryResource);
            if (entryResource.isFolder()) {
                descendants.addAll(cms.readResources(resourceSitePath, CmsResourceFilter.IGNORE_EXPIRATION));
            }
            for (CmsResource deleteRes : descendants) {
                deleteIds.add(deleteRes.getStructureId());
            }
            MultiValueMap linkMap = MultiValueMap.decorate(new HashMap<Object, Object>(),
                    FactoryUtils.instantiateFactory(HashSet.class));
            for (CmsResource resource : descendants) {
                List<CmsResource> linkSources = getLinkSources(cms, resource, deleteIds);
                for (CmsResource source : linkSources) {
                    linkMap.put(resource, source);
                }
            }

            brokenLinks = getBrokenLinkBeans(linkMap);
            info = getPageInfo(entryResource);

            result = new CmsDeleteResourceBean(resourceSitePath, info, brokenLinks);

        } catch (Throwable e) {
            error(e);
        }
        return result;
    } catch (CmsException e) {
        error(e);
        return null; // will never be reached 
    }
}

From source file:org.openmrs.web.controller.patient.ShortPatientModel.java

/**
 * Constructor that creates a shortPatientModel object from a given patient object
 *
 * @param patient//from   ww  w .  java  2  s.c  o  m
 */
@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);
            }
        }
    }
}