Search in sources :

Example 1 with DboBeans

use of com.twinsoft.convertigo.engine.dbo_explorer.DboBeans in project convertigo by convertigo.

the class BeansDoc method run.

private int run() throws Exception {
    FileUtils.deleteQuietly(outputDirectory);
    FileUtils.deleteQuietly(imageDirectory);
    // Loggers
    Engine.logBeans = Logger.getLogger(BeansDoc.class);
    Engine.logContext = Logger.getLogger(BeansDoc.class);
    Engine.logEngine = Logger.getLogger(BeansDoc.class);
    // Engine properties manager
    EnginePropertiesManager.initProperties();
    DboExplorerManager manager = new DboExplorerManager();
    List<DboGroup> groups = manager.getGroups();
    for (DboGroup group : groups) {
        groupName = group.getName();
        List<DboCategory> categories = group.getCategories();
        for (DboCategory category : categories) {
            categoryName = category.getName();
            List<DboBeans> beansCategories = category.getBeans();
            for (DboBeans beansCategory : beansCategories) {
                beansCategoryName = beansCategory.getName();
                List<DboBean> beans = beansCategory.getBeans();
                for (DboBean bean : beans) {
                    if (bean.isEnable()) {
                        if (count == max) {
                            return count;
                        } else {
                            count++;
                        }
                        System.out.println("handle /" + groupName + "/" + categoryName + "/" + beansCategoryName + "/" + bean.getClassName());
                        createBeanElement(bean, bean.getDocumentedMode() == DocumentedMode.TRUE);
                    }
                }
            }
        }
    }
    generateMobileComponentsMd(outputDirectory);
    makeListingPages(outputDirectory);
    return count;
}
Also used : DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Example 2 with DboBeans

use of com.twinsoft.convertigo.engine.dbo_explorer.DboBeans in project convertigo by convertigo.

the class DatabaseObjectsManager method acceptDatabaseObjects.

public static boolean acceptDatabaseObjects(DatabaseObject parentObject, Class<? extends DatabaseObject> objectClass, Class<? extends DatabaseObject> folderBeanClass) {
    try {
        Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
        DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
        List<DboGroup> groups = manager.getGroups();
        for (DboGroup group : groups) {
            List<DboCategory> categories = group.getCategories();
            for (DboCategory category : categories) {
                List<DboBeans> beansCategories = category.getBeans();
                for (DboBeans beansCategory : beansCategories) {
                    List<DboBean> beans = beansCategory.getBeans();
                    for (DboBean bean : beans) {
                        String className = bean.getClassName();
                        Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
                        if (beanClass.equals(objectClass)) {
                            // The bean should derived from DatabaseObject...
                            boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
                            if (isDatabaseObject) {
                                // ... and should derived from the specified class
                                boolean isFromSpecifiedClass = ((folderBeanClass == null) || ((folderBeanClass != null) && (folderBeanClass.isAssignableFrom(beanClass))));
                                if (isFromSpecifiedClass) {
                                    // Check parent
                                    boolean bFound = checkParent(parentObjectClass, bean);
                                    if (bFound) {
                                        // Check technology if needed
                                        String technology = DboUtils.getTechnology(parentObject, objectClass);
                                        if (technology != null) {
                                            Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
                                            if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
                                                continue;
                                            }
                                        }
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    } catch (Exception e) {
        Engine.logDatabaseObjectManager.error("Unable to load database objects properties.", e);
        return false;
    }
}
Also used : DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Example 3 with DboBeans

use of com.twinsoft.convertigo.engine.dbo_explorer.DboBeans in project convertigo by convertigo.

the class Get method createCategories.

private void createCategories(Document document, DatabaseObject dbo, Class<? extends DatabaseObject> databaseObjectClass, Element root) throws Exception {
    Element response = document.createElement("response");
    try {
        List<String> defaultDboList = new ArrayList<>();
        Class<? extends DatabaseObject> parentObjectClass = dbo.getClass();
        Map<String, DboCategoryData> categoryNameToDboCategory = new HashMap<>();
        DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
        for (DboGroup group : manager.getGroups()) {
            for (DboCategory category : group.getCategories()) {
                for (DboBeans beansCategory : category.getBeans()) {
                    for (DboBean bean : beansCategory.getBeans()) {
                        // Skip if bean is disabled
                        if (!bean.isEnable()) {
                            continue;
                        }
                        String className = bean.getClassName();
                        try {
                            Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
                            DboCategoryInfo dboCategoryInfo = DatabaseObject.getDboGroupInfo(beanClass);
                            if (dboCategoryInfo == null) {
                                continue;
                            }
                            // If one of these cases, do not add the category
                            if (dbo instanceof ScreenClass) {
                                ScreenClass sc = (ScreenClass) dbo;
                                // Do not show Criteria category if it is the default Screen Class
                                if (sc.getDepth() == 0 && dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Criteria.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof CicsConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof JavelinConnector) {
                                // Do not show ScreenClass category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof SqlConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof HtmlConnector) {
                                // Do not show Pool and ScreenClass categories
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof HttpConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof SiteClipperConnector) {
                                // Do not show Pool and ScreenClass categories
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof Transaction) {
                                // Do not show Statement category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Statement.class))) {
                                    continue;
                                }
                            }
                            if (bean.isDefault()) {
                                defaultDboList.add(className);
                            }
                            // The bean should derived from
                            // DatabaseObject...
                            boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
                            if (isDatabaseObject) {
                                // ... and should derived from the specified class
                                boolean isFromSpecifiedClass = (databaseObjectClass == null || (databaseObjectClass != null && databaseObjectClass.isAssignableFrom(beanClass)));
                                if (isFromSpecifiedClass) {
                                    // Check parent
                                    boolean bFound = DatabaseObjectsManager.checkParent(parentObjectClass, bean);
                                    if (bFound) {
                                        String technology = DboUtils.getTechnology(dbo, beanClass);
                                        // Check technology if needed
                                        if (technology != null) {
                                            Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
                                            if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
                                                continue;
                                            }
                                        }
                                        String beanInfoClassName = className + "BeanInfo";
                                        Class<BeanInfo> beanInfoClass = GenericUtils.cast(Class.forName(beanInfoClassName));
                                        if (beanInfoClass != null) {
                                            String categoryName = dboCategoryInfo.getCategoryName();
                                            // Create category
                                            DboCategoryData dboCategoryData = categoryNameToDboCategory.get(categoryName);
                                            if (dboCategoryData == null) {
                                                dboCategoryData = new DboCategoryData(dboCategoryInfo.getCategoryId(), categoryName, dboCategoryInfo.getIconClassCSS());
                                                categoryNameToDboCategory.put(categoryName, dboCategoryData);
                                            }
                                            // Beans name
                                            String beansName = beansCategory.getName();
                                            if (beansName.length() == 0) {
                                                beansName = categoryName;
                                            }
                                            // Create beans
                                            DboBeansData dboBeansData = dboCategoryData.getDboBeans(beansName);
                                            if (dboBeansData == null) {
                                                dboBeansData = new DboBeansData(beansName);
                                                dboCategoryData.addDboBeans(beansName, dboBeansData);
                                            }
                                            // Create bean
                                            DboBeanData dboBeanData = new DboBeanData(beanInfoClass.getConstructor().newInstance());
                                            dboBeansData.addDboBean(dboBeanData);
                                        } else {
                                            String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
                                            throw new Exception(message);
                                        }
                                    }
                                }
                            } else {
                                String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
                                throw new Exception(message);
                            }
                        } catch (ClassNotFoundException e) {
                            String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" class.\n\nClass not found: {1}", new Object[] { className, e.getMessage() });
                            throw new Exception(message);
                        } catch (Throwable e) {
                            String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
                            throw new Exception(message);
                        }
                    }
                }
            }
        }
        // Find the default selected bean for each categories
        for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
            boolean defaultDboFound = false;
            List<DboBeanData> dboBeansList = dboCategory.getAllDboBean(true);
            // By default, we chose the first bean as default selected bean
            DboBeanData defaultSelectedBean = dboBeansList.get(0);
            // Find the default selected bean
            for (int i = 0; i < dboBeansList.size() && !defaultDboFound; ++i) {
                Class<DatabaseObject> beanClass = dboBeansList.get(i).getBeanClass();
                // Another bean is set as default selected bean
                if (defaultDboFound = defaultDboList.contains(beanClass.getName())) {
                    defaultSelectedBean = dboBeansList.get(i);
                }
            }
            defaultSelectedBean.setSelectedByDefault(true);
        }
        // XmlLize
        for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
            response.appendChild(dboCategory.toXml(document));
        }
    } catch (Exception e) {
        throw new Exception("Unable to load database objects properties.");
    }
    root.appendChild(response);
}
Also used : HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) HashMap(java.util.HashMap) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Element(org.w3c.dom.Element) BeanInfo(java.beans.BeanInfo) ArrayList(java.util.ArrayList) DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) DboBeansData(com.twinsoft.convertigo.beans.dbo_explorer.DboBeansData) DboBeanData(com.twinsoft.convertigo.beans.dbo_explorer.DboBeanData) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) DboCategoryInfo(com.twinsoft.convertigo.beans.core.DatabaseObject.DboCategoryInfo) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) DboCategoryData(com.twinsoft.convertigo.beans.dbo_explorer.DboCategoryData) DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Example 4 with DboBeans

use of com.twinsoft.convertigo.engine.dbo_explorer.DboBeans in project convertigo by convertigo.

the class ObjectsExplorerComposite method findDatabaseObjects.

protected void findDatabaseObjects() {
    if (objectsMap.isEmpty()) {
        try {
            Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
            Map<BeanInfo, DboBeans> beanMap = new HashMap<BeanInfo, DboBeans>();
            // Enumeration of the beans
            ConvertigoPlugin.logDebug2("Exploring Convertigo database objects list...");
            DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
            List<DboGroup> groups = manager.getGroups();
            Set<DboBeans> beansCategorySet = new LinkedHashSet<DboBeans>();
            for (DboGroup group : groups) {
                List<DboCategory> categories = group.getCategories();
                for (DboCategory category : categories) {
                    List<DboBeans> beansCategories = category.getBeans();
                    for (DboBeans beansCategory : beansCategories) {
                        List<DboBean> beans = beansCategory.getBeans();
                        for (DboBean bean : beans) {
                            if (!bean.isEnable())
                                continue;
                            String className = bean.getClassName();
                            if (bean.isDefault()) {
                                defaultDboList.add(className);
                            }
                            if (bean.isDocumented()) {
                                documentedDboList.add(className);
                            }
                            try {
                                Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
                                ConvertigoPlugin.logDebug2("Bean class: " + (beanClass != null ? beanClass.getName() : "null"));
                                // The bean should derived from DatabaseObject...
                                boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
                                if (isDatabaseObject) {
                                    // ... and should derived from the specified class
                                    boolean isFromSpecifiedClass = ((databaseObjectClass == null) || ((databaseObjectClass != null) && (databaseObjectClass.isAssignableFrom(beanClass))));
                                    if (isFromSpecifiedClass) {
                                        // Check parent
                                        boolean bFound = DatabaseObjectsManager.checkParent(parentObjectClass, bean);
                                        if (bFound) {
                                            // Check technology if needed
                                            if (technology != null) {
                                                Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
                                                if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
                                                    continue;
                                                }
                                            }
                                            String beanInfoClassName = className + "BeanInfo";
                                            Class<BeanInfo> beanInfoClass = GenericUtils.cast(Class.forName(beanInfoClassName));
                                            if (beanInfoClass != null) {
                                                beanMap.put(beanInfoClass.getConstructor().newInstance(), beansCategory);
                                                beansCategorySet.add(beansCategory);
                                            } else {
                                                String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
                                                ConvertigoPlugin.logWarning(message);
                                            }
                                        }
                                    }
                                } else {
                                    String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
                                    ConvertigoPlugin.logWarning(message);
                                }
                            } catch (ClassNotFoundException e) {
                                String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" class.\n\nClass not found: {1}", new Object[] { className, e.getMessage() });
                                ConvertigoPlugin.logWarning(message);
                            }/*
								 * catch(IntrospectionException e) { String
								 * message =java.text.MessageFormat.format(
								 * "Unable to find the bean info linked to the \"{0}\" class."
								 * , new Object[] {className});
								 * ConvertigoPlugin.logWarning(message); }
								 */
                             catch (Throwable e) {
                                String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
                                ConvertigoPlugin.logException(e, message);
                            }
                        }
                    }
                }
            }
            List<BeanInfo> beanInfoList = new ArrayList<BeanInfo>(beanMap.keySet());
            Collections.sort(beanInfoList, new Comparator<BeanInfo>() {

                public int compare(BeanInfo o1, BeanInfo o2) {
                    BeanDescriptor bd1 = o1.getBeanDescriptor();
                    BeanDescriptor bd2 = o2.getBeanDescriptor();
                    String name1 = bd1.getDisplayName().toLowerCase();
                    String name2 = bd2.getDisplayName().toLowerCase();
                    return name1.compareTo(name2);
                }
            });
            // initialize composites.
            RowLayout rowLayout = new RowLayout();
            rowLayout.pack = false;
            bar = new ExpandBar(scrolledComposite, SWT.NONE);
            bar.setSpacing(8);
            String itemText = "";
            int i = 0;
            Iterator<DboBeans> iterator = beansCategorySet.iterator();
            if (databaseObjectClass.equals(Connector.class)) {
                composites = new Composite[1];
                items = new ExpandItem[1];
                composites[i] = new Composite(bar, SWT.NONE);
                composites[i].setLayout(rowLayout);
                composites[i].setBackground(bar.getBackground());
                items[i] = new ExpandItem(bar, SWT.NONE, i);
                items[i].setControl(composites[i]);
                items[i].setExpanded(true);
                items[i].setText("Connectors");
            } else {
                composites = new Composite[beansCategorySet.size()];
                items = new ExpandItem[beansCategorySet.size()];
                while (iterator.hasNext()) {
                    composites[i] = new Composite(bar, SWT.NONE);
                    composites[i].setLayout(rowLayout);
                    composites[i].setBackground(bar.getBackground());
                    items[i] = new ExpandItem(bar, SWT.NONE, i);
                    items[i].setControl(composites[i]);
                    items[i].setExpanded(true);
                    itemText = iterator.next().getName();
                    if (itemText.equals("")) {
                        itemText = databaseObjectClass.getSimpleName();
                        if (beanInfoList.size() > 1) {
                            itemText.concat("s");
                        }
                    }
                    items[i].setText(itemText);
                    i++;
                }
            }
            handCursor = new Cursor(Display.getDefault(), SWT.CURSOR_HAND);
            boolean bSelected = false;
            boolean defaultDboFound = false;
            Iterator<BeanInfo> it = beanInfoList.iterator();
            while (it.hasNext()) {
                BeanInfo beanInfo = it.next();
                DboBeans beanCategory = beanMap.get(beanInfo);
                Class<DatabaseObject> beanClass = GenericUtils.cast(beanInfo.getBeanDescriptor().getBeanClass());
                boolean isDefault = defaultDboList.contains(beanClass.getName());
                boolean isDocumented = documentedDboList.contains(beanClass.getName());
                String beanName = beanInfo.getBeanDescriptor().getDisplayName();
                String beanDescription = isDocumented ? beanInfo.getBeanDescriptor().getShortDescription() : "Not yet documented |";
                String[] beanDescriptions = beanDescription.split("\\|");
                String beanShortDescription = BeansUtils.cleanDescription(beanDescriptions[0], false);
                Image beanImage = ConvertigoPlugin.getDefault().getBeanIcon(beanInfo, BeanInfo.ICON_COLOR_32x32);
                if (isDefault) {
                    bSelected = true;
                    defaultDboFound = true;
                }
                addLabelEx(beanImage, beanClass, beanName, beanShortDescription, bSelected, beanInfo, beanCategory);
                bSelected = false;
            }
            // We select by default the first item if no default dbo found.
            if (!defaultDboFound && currentSelectedObject == null) {
                currentSelectedObject = (CLabel) composites[0].getChildren()[0];
            }
            if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
                currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
                currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
            }
            BeanInfo currentSelectedObjectBeanInfo = getCurrentSelectedBeanInfo();
            if (currentSelectedObjectBeanInfo != null) {
                updateHelpText(currentSelectedObjectBeanInfo);
            }
        } catch (Exception e) {
            ConvertigoPlugin.logException(e, "Unable to load database objects properties.");
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExpandBar(org.eclipse.swt.widgets.ExpandBar) HashMap(java.util.HashMap) BeanInfo(java.beans.BeanInfo) ArrayList(java.util.ArrayList) DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) Cursor(org.eclipse.swt.graphics.Cursor) Image(org.eclipse.swt.graphics.Image) DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) ExpandItem(org.eclipse.swt.widgets.ExpandItem) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) RowLayout(org.eclipse.swt.layout.RowLayout) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) BeanDescriptor(java.beans.BeanDescriptor) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Example 5 with DboBeans

use of com.twinsoft.convertigo.engine.dbo_explorer.DboBeans in project convertigo by convertigo.

the class DatabaseObjectsManager method acceptDatabaseObjects.

public static boolean acceptDatabaseObjects(DatabaseObject parentObject, DatabaseObject object) {
    try {
        Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
        Class<? extends DatabaseObject> objectClass = object.getClass();
        DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
        List<DboGroup> groups = manager.getGroups();
        for (DboGroup group : groups) {
            List<DboCategory> categories = group.getCategories();
            for (DboCategory category : categories) {
                List<DboBeans> beansCategories = category.getBeans();
                for (DboBeans beansCategory : beansCategories) {
                    List<DboBean> beans = beansCategory.getBeans();
                    for (DboBean bean : beans) {
                        String className = bean.getClassName();
                        Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
                        // The bean should derived from DatabaseObject...
                        boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
                        if (isDatabaseObject) {
                            // ... and should derived from the specified class
                            boolean isFromSpecifiedClass = ((objectClass == null) || ((objectClass != null) && (objectClass.isAssignableFrom(beanClass))));
                            if (isFromSpecifiedClass) {
                                // Check parent
                                boolean bFound = checkParent(parentObjectClass, bean);
                                if (bFound) {
                                    // Check technology if needed
                                    String technology = DboUtils.getTechnology(parentObject, objectClass);
                                    if (technology != null) {
                                        Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
                                        if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
                                            continue;
                                        }
                                    }
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    } catch (Exception e) {
        Engine.logDatabaseObjectManager.error("Unable to load database objects properties.", e);
        return false;
    }
}
Also used : DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Aggregations

DboBean (com.twinsoft.convertigo.engine.dbo_explorer.DboBean)5 DboBeans (com.twinsoft.convertigo.engine.dbo_explorer.DboBeans)5 DboCategory (com.twinsoft.convertigo.engine.dbo_explorer.DboCategory)5 DboExplorerManager (com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager)5 DboGroup (com.twinsoft.convertigo.engine.dbo_explorer.DboGroup)5 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)4 BeanInfo (java.beans.BeanInfo)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 SAXException (org.xml.sax.SAXException)2 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)1 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)1 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)1 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)1 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)1 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)1 DboCategoryInfo (com.twinsoft.convertigo.beans.core.DatabaseObject.DboCategoryInfo)1