Example usage for org.springframework.ide.eclipse.beans.core.model IBeansProject getConfigs

List of usage examples for org.springframework.ide.eclipse.beans.core.model IBeansProject getConfigs

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.beans.core.model IBeansProject getConfigs.

Prototype

Set<IBeansConfig> getConfigs();

Source Link

Document

Returns a collection of all configs defined in this project.

Usage

From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java

public static String getClassNameForCCI(IFile mappingIFile, String customConverterId) {
    IBean bean = getDozerBeanForMappingFile(mappingIFile);

    if (bean == null)
        return null;

    BeansMapEntry beansMapEntry = getCCIModelElementForMappingFile(bean, customConverterId);

    if (beansMapEntry != null) {
        if (beansMapEntry.getValue() instanceof Bean) {
            Bean cciBean = (Bean) beansMapEntry.getValue();
            return cciBean.getBeanDefinition().getBeanClassName();
        } else if (beansMapEntry.getValue() instanceof BeanReference) {
            BeanReference beanRef = (BeanReference) beansMapEntry.getValue();
            String beanName = beanRef.getBeanName();

            Set<IBeansProject> projects = BeansCorePlugin.getModel().getProjects();
            for (IBeansProject beansProject : projects) {
                Set<IBeansConfig> tempConfigs = beansProject.getConfigs();
                for (IBeansConfig config : tempConfigs) {
                    IBean foundBean = config.getBean(beanName);
                    if (foundBean != null) {
                        return foundBean.getClassName();
                    }/* w  w  w . j  a v  a2  s  . c om*/
                }
            }
        }
    }

    return null;
}

From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java

public static IBean getDozerBeanForMappingFile(IFile mappingIFile) {
    Set<IBean> beans = new HashSet<IBean>();
    IBean returnBean = null;//from   www.j  a  v a2 s.  c om

    //The mapping file that we are in
    File mappingFile = new File(mappingIFile.getName());
    String mappingFileName = mappingFile.getName();

    //First get direct references
    IBeansProject beansProject = BeansCorePlugin.getModel().getProject(mappingIFile.getProject());

    if (beansProject == null)
        return null;

    Set<IBeansConfig> tempConfigs = beansProject.getConfigs();

    if (tempConfigs == null)
        return null;

    //We need some File to later get allBeans from ConfigSets
    IFile someBeansModelFile = null;

    //check local beans
    for (IBeansConfig config : tempConfigs) {
        if (someBeansModelFile == null)
            someBeansModelFile = (IFile) config.getElementResource();

        beans.addAll(config.getBeans());
    }
    returnBean = getDozerBeanFromBeans(beans, mappingFileName);

    //no local bean for mappingfile found
    if (returnBean == null && someBeansModelFile != null) {
        //check configsets
        Set<IBean> allBeans = BeansEditorUtils.getBeansFromConfigSets(someBeansModelFile);
        returnBean = getDozerBeanFromBeans(allBeans, mappingFileName);
    }

    return returnBean;
}