Search in sources :

Example 1 with Pool

use of com.twinsoft.convertigo.beans.core.Pool in project convertigo by convertigo.

the class ConvertigoPlugin method getDefaultBeanIcon.

private Image getDefaultBeanIcon(Class<?> beanClass, int iconKind) {
    String iconBaseName, iconType;
    iconBaseName = "default";
    if (beanClass != null) {
        if (Criteria.class.isAssignableFrom(beanClass)) {
            iconBaseName = "criteria";
        } else if (ExtractionRule.class.isAssignableFrom(beanClass)) {
            iconBaseName = "extractionrule";
        } else if (Transaction.class.isAssignableFrom(beanClass)) {
            iconBaseName = "transaction";
        } else if (BlockFactory.class.isAssignableFrom(beanClass)) {
            iconBaseName = "blockfactory";
        } else if (Project.class.isAssignableFrom(beanClass)) {
            iconBaseName = "project";
        } else if (ScreenClass.class.isAssignableFrom(beanClass)) {
            iconBaseName = "screenclass";
        } else if (Sheet.class.isAssignableFrom(beanClass)) {
            iconBaseName = "sheet";
        } else if (Pool.class.isAssignableFrom(beanClass)) {
            iconBaseName = "pool";
        }
    }
    switch(iconKind) {
        case java.beans.BeanInfo.ICON_COLOR_16x16:
            iconType = "_color_16x16.png";
            break;
        default:
        case java.beans.BeanInfo.ICON_COLOR_32x32:
            iconType = "_color_32x32.png";
            break;
        case java.beans.BeanInfo.ICON_MONO_16x16:
            iconType = "_mono_16x16.png";
            break;
        case java.beans.BeanInfo.ICON_MONO_32x32:
            iconType = "_mono_32x32.png";
            break;
    }
    Image beanIcon = (Image) icons.get(iconBaseName + iconType);
    if (beanIcon == null) {
        ConvertigoPlugin.studioLog.debug("Getting default icon: " + iconBaseName + iconType);
        String iconName = "/com/twinsoft/convertigo/beans/core/images/" + iconBaseName + iconType;
        Device device = getDisplay();
        InputStream inputStream = ConvertigoPlugin.class.getResourceAsStream(iconName);
        beanIcon = new Image(device, inputStream);
        icons.put(iconBaseName + iconType, beanIcon);
    }
    return beanIcon;
}
Also used : BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Device(org.eclipse.swt.graphics.Device) InputStream(java.io.InputStream) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) Pool(com.twinsoft.convertigo.beans.core.Pool) Image(org.eclipse.swt.graphics.Image)

Example 2 with Pool

use of com.twinsoft.convertigo.beans.core.Pool in project convertigo by convertigo.

the class ProjectExplorerView method loadDatabaseObject.

private void loadDatabaseObject(TreeParent parentTreeObject, DatabaseObject parentDatabaseObject, ProjectLoadingJob projectLoadingJob, final IProgressMonitor monitor) throws EngineException, IOException {
    try {
        new WalkHelper() {

            // recursion parameters
            TreeParent parentTreeObject;

            ProjectLoadingJob projectLoadingJob;

            // sibling parameters
            ObjectsFolderTreeObject currentTreeFolder = null;

            public void init(DatabaseObject databaseObject, TreeParent parentTreeObject, ProjectLoadingJob projectLoadingJob) throws Exception {
                this.parentTreeObject = parentTreeObject;
                this.projectLoadingJob = projectLoadingJob;
                walkInheritance = true;
                super.init(databaseObject);
            }

            protected ObjectsFolderTreeObject getFolder(TreeParent treeParent, int folderType) {
                ObjectsFolderTreeObject ofto = null;
                for (TreeObject to : treeParent.getChildren()) {
                    if (to instanceof ObjectsFolderTreeObject) {
                        if (((ObjectsFolderTreeObject) to).folderType == folderType) {
                            ofto = (ObjectsFolderTreeObject) to;
                            break;
                        }
                    }
                }
                if (ofto == null) {
                    ofto = new ObjectsFolderTreeObject(viewer, folderType);
                    treeParent.addChild(ofto);
                }
                return ofto;
            }

            @Override
            protected void walk(DatabaseObject databaseObject) throws Exception {
                // retrieve recursion parameters
                final TreeParent parentTreeObject = this.parentTreeObject;
                final ProjectLoadingJob projectLoadingJob = this.projectLoadingJob;
                // retrieve sibling parameters
                ObjectsFolderTreeObject currentTreeFolder = this.currentTreeFolder;
                String dboName = (databaseObject instanceof Step) ? ((Step) databaseObject).getStepNodeName() : databaseObject.getName();
                monitor.subTask("Loading databaseObject '" + dboName + "'...");
                DatabaseObjectTreeObject databaseObjectTreeObject = null;
                // first call case, the tree object already exists and its content is just refreshed
                if (parentTreeObject.getObject() == databaseObject) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) parentTreeObject;
                } else // recursive call case, the tree object doesn't exist and must be added to the parent tree object
                {
                    int folderType = Integer.MIN_VALUE;
                    if (databaseObject instanceof Connector) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONNECTORS;
                        databaseObjectTreeObject = new ConnectorTreeObject(viewer, (Connector) databaseObject, false);
                    } else if (databaseObject instanceof Sequence) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SEQUENCES;
                        databaseObjectTreeObject = new SequenceTreeObject(viewer, (Sequence) databaseObject, false);
                    } else if (databaseObject instanceof MobileApplication) {
                        databaseObjectTreeObject = new MobileApplicationTreeObject(viewer, (MobileApplication) databaseObject, false);
                    } else if (databaseObject instanceof MobilePlatform) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PLATFORMS;
                        databaseObjectTreeObject = new MobilePlatformTreeObject(viewer, (MobilePlatform) databaseObject, false);
                    } else /**
                     ***********************************************************************************************
                     */
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                        if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                            databaseObjectTreeObject = new MobileApplicationComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ROUTES;
                            databaseObjectTreeObject = new MobileRouteComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            databaseObjectTreeObject = new MobileRouteEventComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ACTIONS;
                            databaseObjectTreeObject = new MobileRouteActionComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PAGES;
                            databaseObjectTreeObject = new MobilePageComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_ACTIONS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_COMPONENTS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MENUS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAttribute) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlAttr) {
                                    folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONTROLS;
                                }
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIStyle) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STYLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UICompVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIFormValidator) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VALIDATORS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIEventSubscriber) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            }
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        }
                    } else /**
                     ***********************************************************************************************
                     */
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                        if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                            databaseObjectTreeObject = new NgxApplicationComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PAGES;
                            databaseObjectTreeObject = new NgxPageComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_ACTIONS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_COMPONENTS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MENUS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                            if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAttribute) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlAttr) {
                                    folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONTROLS;
                                }
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAttr) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIStyle) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STYLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UICompVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIEventSubscriber) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            }
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        }
                    } else if (databaseObject instanceof UrlMapper) {
                        databaseObjectTreeObject = new UrlMapperTreeObject(viewer, (UrlMapper) databaseObject, false);
                    } else if (databaseObject instanceof UrlAuthentication) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_AUTHENTICATIONS;
                        databaseObjectTreeObject = new UrlAuthenticationTreeObject(viewer, (UrlAuthentication) databaseObject, false);
                    } else if (databaseObject instanceof UrlMapping) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MAPPINGS;
                        databaseObjectTreeObject = new UrlMappingTreeObject(viewer, (UrlMapping) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingOperation) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_OPERATIONS;
                        databaseObjectTreeObject = new UrlMappingOperationTreeObject(viewer, (UrlMappingOperation) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingParameter) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PARAMETERS;
                        databaseObjectTreeObject = new UrlMappingParameterTreeObject(viewer, (UrlMappingParameter) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingResponse) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_RESPONSES;
                        databaseObjectTreeObject = new UrlMappingResponseTreeObject(viewer, (UrlMappingResponse) databaseObject, false);
                    } else if (databaseObject instanceof Reference) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_REFERENCES;
                        databaseObjectTreeObject = new ReferenceTreeObject(viewer, (Reference) databaseObject, false);
                    } else if (databaseObject instanceof Pool) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_POOLS;
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    } else if (databaseObject instanceof Transaction) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_TRANSACTIONS;
                        databaseObjectTreeObject = new TransactionTreeObject(viewer, (Transaction) databaseObject, false);
                    } else if (databaseObject instanceof ScreenClass) {
                        if (databaseObject.getParent() instanceof IScreenClassContainer<?>) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SCREEN_CLASSES;
                            databaseObjectTreeObject = new ScreenClassTreeObject(viewer, (ScreenClass) databaseObject, false);
                        } else {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_INHERITED_SCREEN_CLASSES;
                            databaseObjectTreeObject = new ScreenClassTreeObject(viewer, (ScreenClass) databaseObject, false);
                        }
                    } else if (databaseObject instanceof Sheet) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHEETS;
                        databaseObjectTreeObject = new SheetTreeObject(viewer, (Sheet) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof TestCase) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_TESTCASES;
                        databaseObjectTreeObject = new TestCaseTreeObject(viewer, (TestCase) databaseObject, false);
                    } else if (databaseObject instanceof Variable) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                        databaseObjectTreeObject = new VariableTreeObject2(viewer, (Variable) databaseObject, false);
                    } else if (databaseObject instanceof Step) {
                        if (databaseObject.getParent() instanceof Sequence) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STEPS;
                        }
                        databaseObjectTreeObject = new StepTreeObject(viewer, (Step) databaseObject, false);
                    } else if (databaseObject instanceof Statement) {
                        if (databaseObject.getParent() instanceof Transaction) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS;
                        }
                        databaseObjectTreeObject = new StatementTreeObject(viewer, (Statement) databaseObject, false);
                    } else if (databaseObject instanceof Criteria) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CRITERIAS;
                        databaseObjectTreeObject = new CriteriaTreeObject(viewer, (Criteria) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof ExtractionRule) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EXTRACTION_RULES;
                        databaseObjectTreeObject = new ExtractionRuleTreeObject(viewer, (ExtractionRule) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof BlockFactory) {
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Document) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_DOCUMENTS;
                        com.twinsoft.convertigo.beans.core.Document document = (com.twinsoft.convertigo.beans.core.Document) databaseObject;
                        String documentRenderer = document.getRenderer();
                        if (documentRenderer.equals("DesignDocumentTreeObject"))
                            databaseObjectTreeObject = new DesignDocumentTreeObject(viewer, document, false);
                        else
                            databaseObjectTreeObject = new DocumentTreeObject(viewer, document, false);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Listener) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_LISTENERS;
                        com.twinsoft.convertigo.beans.core.Listener listener = (com.twinsoft.convertigo.beans.core.Listener) databaseObject;
                        String listenerRenderer = listener.getRenderer();
                        if (listenerRenderer.equals("FullSyncListenerTreeObject")) {
                            databaseObjectTreeObject = new FullSyncListenerTreeObject(viewer, listener, false);
                        } else {
                            databaseObjectTreeObject = new ListenerTreeObject(viewer, listener, false);
                        }
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Index) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_INDEXES;
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    } else {
                        // unknow DBO case !!!
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    }
                    // no virtual folder
                    if (folderType == Integer.MIN_VALUE) {
                        parentTreeObject.addChild(databaseObjectTreeObject);
                    } else // virtual folder creation or reuse
                    {
                        /* fixed #5416 */
                        // if (currentTreeFolder == null || currentTreeFolder.folderType != folderType) {
                        // currentTreeFolder = new ObjectsFolderTreeObject(viewer, folderType);
                        // parentTreeObject.addChild(currentTreeFolder);
                        // }
                        currentTreeFolder = getFolder(parentTreeObject, folderType);
                        currentTreeFolder.addChild(databaseObjectTreeObject);
                    }
                    // case databaseObject has been changed through dbo::preconfigure, mark projectTreeObject as modified
                    if ((databaseObject.bNew) || (databaseObject.hasChanged && !databaseObject.bNew)) {
                        databaseObjectTreeObject.hasBeenModified(true);
                    }
                    // new value of recursion parameters
                    this.parentTreeObject = databaseObjectTreeObject;
                }
                // special databaseObject cases
                if (databaseObject instanceof Project) {
                    Project project = (Project) databaseObject;
                    // Creates directories and files
                    createDirsAndFiles(project.getName());
                    // Creates or Refresh xsd and wsdl folders
                    IFolder xsdFolder, wsdlFolder = null;
                    IFolder xsdInternalFolder = null;
                    try {
                        wsdlFolder = ((ProjectTreeObject) parentTreeObject).getFolder("wsdl");
                        if (!wsdlFolder.exists())
                            wsdlFolder.create(true, true, null);
                        else
                            wsdlFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                        xsdFolder = ((ProjectTreeObject) parentTreeObject).getFolder("xsd");
                        if (!xsdFolder.exists())
                            xsdFolder.create(true, true, null);
                        else {
                            xsdInternalFolder = xsdFolder.getFolder("internal");
                            if (!xsdInternalFolder.exists())
                                xsdInternalFolder.create(true, true, null);
                            xsdFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    // Connectors
                    IFolder xsdConnectorInternalFolder = null;
                    Collection<Connector> connectors = project.getConnectorsList();
                    if (connectors.size() != 0) {
                        // Set default connector if none
                        if (project.getDefaultConnector() == null) {
                            // Report from 4.5: fix #401
                            ConvertigoPlugin.logWarning(null, "Project \"" + project.getName() + "\" has no default connector. Try to set a default one.");
                            Connector defaultConnector = connectors.iterator().next();
                            try {
                                project.setDefaultConnector(defaultConnector);
                                defaultConnector.hasChanged = true;
                            } catch (Exception e) {
                                ConvertigoPlugin.logWarning(e, "Unable to set a default connector for project \"" + project.getName() + "\"");
                            }
                        }
                        // Refresh Traces folder
                        IFolder ifolder = ((ProjectTreeObject) parentTreeObject).getFolder("Traces");
                        if (ifolder.exists()) {
                            try {
                                ifolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (CoreException e) {
                            }
                        }
                        // Creates or Refresh internal xsd connector folders
                        for (Connector connector : connectors) {
                            try {
                                xsdConnectorInternalFolder = xsdInternalFolder.getFolder(connector.getName());
                                if (!xsdConnectorInternalFolder.exists())
                                    xsdConnectorInternalFolder.create(true, true, null);
                                else
                                    xsdConnectorInternalFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } else if (databaseObject instanceof Connector) {
                    Connector connector = (Connector) databaseObject;
                    // Open connector editor
                    if (projectLoadingJob != null && connector.isDefault) {
                        projectLoadingJob.setDefaultConnectorTreeObject((ConnectorTreeObject) databaseObjectTreeObject);
                    }
                    // Traces
                    if (connector instanceof JavelinConnector) {
                        String projectName = databaseObject.getProject().getName();
                        if (projectLoadingJob == null) {
                            if (MigrationManager.isProjectMigrated(projectName)) {
                                UnloadedProjectTreeObject unloadedProjectTreeObject = new UnloadedProjectTreeObject(databaseObjectTreeObject.viewer, projectName);
                                this.projectLoadingJob = new ProjectLoadingJob(databaseObjectTreeObject.viewer, unloadedProjectTreeObject);
                                this.projectLoadingJob.loadTrace(databaseObjectTreeObject, new File(Engine.projectDir(projectName) + "/Traces/" + connector.getName()));
                            }
                        }
                        if (projectLoadingJob != null) {
                            projectLoadingJob.loadTrace(databaseObjectTreeObject, new File(Engine.projectDir(projectName) + "/Traces/" + connector.getName()));
                        }
                    }
                } else if (databaseObject instanceof Transaction) {
                    Transaction transaction = (Transaction) databaseObject;
                    // Functions
                    List<HandlersDeclarationTreeObject> treeObjects = new LinkedList<HandlersDeclarationTreeObject>();
                    String line, lineReaded;
                    int lineNumber = 0;
                    BufferedReader br = new BufferedReader(new StringReader(transaction.handlers));
                    line = br.readLine();
                    while (line != null) {
                        lineReaded = line.trim();
                        lineNumber++;
                        if (lineReaded.startsWith("function ")) {
                            try {
                                String functionName = lineReaded.substring(9, lineReaded.indexOf(')') + 1);
                                HandlersDeclarationTreeObject handlersDeclarationTreeObject = null;
                                if (functionName.endsWith(JavelinTransaction.EVENT_ENTRY_HANDLER + "()")) {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_FUNCTION_SCREEN_CLASS_ENTRY, lineNumber);
                                } else if (functionName.endsWith(JavelinTransaction.EVENT_EXIT_HANDLER + "()")) {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_FUNCTION_SCREEN_CLASS_EXIT, lineNumber);
                                } else {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_OTHER, lineNumber);
                                }
                                if (handlersDeclarationTreeObject != null) {
                                    treeObjects.add(handlersDeclarationTreeObject);
                                }
                            } catch (StringIndexOutOfBoundsException e) {
                                throw new EngineException("Exception in reading line of a transaction", e);
                            }
                        }
                        line = br.readLine();
                    }
                    if (treeObjects.size() != 0) {
                        ObjectsFolderTreeObject objectsFolderTreeObject = new ObjectsFolderTreeObject(viewer, ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS);
                        databaseObjectTreeObject.addChild(objectsFolderTreeObject);
                        for (HandlersDeclarationTreeObject handlersDeclarationTreeObject : treeObjects) {
                            objectsFolderTreeObject.addChild(handlersDeclarationTreeObject);
                        }
                    }
                } else if (databaseObject instanceof Sheet) {
                    addTemplates((Sheet) databaseObject, databaseObjectTreeObject);
                } else if (databaseObject instanceof ITablesProperty) {
                    ITablesProperty iTablesProperty = (ITablesProperty) databaseObject;
                    String[] tablePropertyNames = iTablesProperty.getTablePropertyNames();
                    for (int i = 0; i < tablePropertyNames.length; i++) {
                        String tablePropertyName = tablePropertyNames[i];
                        String tableRenderer = iTablesProperty.getTableRenderer(tablePropertyName);
                        XMLVector<XMLVector<Object>> xmlv = iTablesProperty.getTableData(tablePropertyName);
                        if (tableRenderer.equals("XMLTableDescriptionTreeObject")) {
                            XMLTableDescriptionTreeObject propertyXMLTableTreeObject = new XMLTableDescriptionTreeObject(viewer, tablePropertyName, xmlv, databaseObjectTreeObject);
                            databaseObjectTreeObject.addChild(propertyXMLTableTreeObject);
                        } else if (tableRenderer.equals("XMLRecordDescriptionTreeObject")) {
                            XMLRecordDescriptionTreeObject propertyXMLRecordTreeObject = new XMLRecordDescriptionTreeObject(viewer, tablePropertyName, xmlv, databaseObjectTreeObject);
                            databaseObjectTreeObject.addChild(propertyXMLRecordTreeObject);
                        }
                    }
                }
                monitor.worked(1);
                // children cannot be added in the current virtual folder
                this.currentTreeFolder = null;
                super.walk(databaseObject);
                // restore recursion parameters
                this.parentTreeObject = parentTreeObject;
                this.projectLoadingJob = projectLoadingJob;
                // restore sibling parameters
                this.currentTreeFolder = currentTreeFolder;
            }
        }.init(parentDatabaseObject, parentTreeObject, projectLoadingJob);
    } catch (EngineException e) {
        throw e;
    } catch (Exception e) {
        throw new EngineException("Exception in copyDatabaseObject", e);
    }
}
Also used : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) Document(org.w3c.dom.Document) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) Pool(com.twinsoft.convertigo.beans.core.Pool) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) IEditableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) IEditableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) IScreenClassContainer(com.twinsoft.convertigo.beans.core.IScreenClassContainer) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) StringReader(java.io.StringReader) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) UrlMapper(com.twinsoft.convertigo.beans.core.UrlMapper) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) IEditorReference(org.eclipse.ui.IEditorReference) Reference(com.twinsoft.convertigo.beans.core.Reference) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) TestCase(com.twinsoft.convertigo.beans.core.TestCase) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) BufferedReader(java.io.BufferedReader) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) UrlAuthentication(com.twinsoft.convertigo.beans.core.UrlAuthentication) IFolder(org.eclipse.core.resources.IFolder) UrlMapping(com.twinsoft.convertigo.beans.core.UrlMapping) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ListenerList(org.eclipse.core.runtime.ListenerList) LinkedList(java.util.LinkedList) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) Transaction(com.twinsoft.convertigo.beans.core.Transaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) CoreException(org.eclipse.core.runtime.CoreException) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) Collection(java.util.Collection) IFile(org.eclipse.core.resources.IFile) File(java.io.File) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) MigrationListener(com.twinsoft.convertigo.engine.MigrationListener) TreeDragListener(com.twinsoft.convertigo.eclipse.dnd.TreeDragListener) ISelectionListener(org.eclipse.ui.ISelectionListener) CompositeListener(com.twinsoft.convertigo.eclipse.editors.CompositeListener) DatabaseObjectListener(com.twinsoft.convertigo.engine.DatabaseObjectListener) Listener(org.eclipse.swt.widgets.Listener) EngineListener(com.twinsoft.convertigo.engine.EngineListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) UrlMappingResponse(com.twinsoft.convertigo.beans.core.UrlMappingResponse) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) FunctionStep(com.twinsoft.convertigo.beans.steps.FunctionStep) Step(com.twinsoft.convertigo.beans.core.Step) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) ITablesProperty(com.twinsoft.convertigo.beans.core.ITablesProperty) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException) Point(org.eclipse.swt.graphics.Point) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 3 with Pool

use of com.twinsoft.convertigo.beans.core.Pool in project convertigo by convertigo.

the class ContextManager method managePoolContexts.

private void managePoolContexts() {
    if (Engine.isStudioMode()) {
        return;
    }
    if (!Engine.isStarted) {
        Engine.logContextManager.debug("Engine is stopped => do not manage pools");
        return;
    }
    Engine.logContextManager.debug("Executing vulture thread for context pooling");
    try {
        long timeout = manage_poll_timeout;
        long now = System.currentTimeMillis();
        if (timeout != -1) {
            timeout += now;
        }
        pooledContextsToCreateSet.clear();
        Map<String, Integer> counters = new HashMap<String, Integer>();
        // with the auto-start transaction
        for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
            if (!isRunning)
                return;
            Engine.logContextManager.trace("Analyzing project " + projectName);
            Project project = null;
            try {
                project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
            } catch (Exception e) {
                Engine.logContextManager.warn("Unable to load project '" + projectName + "'; avorting pool research for this project", e);
                continue;
            }
            Collection<Connector> vConnectors = project.getConnectorsList();
            Engine.logContextManager.trace("Connectors: " + vConnectors);
            for (Connector connector : vConnectors) {
                if (!isRunning)
                    return;
                Engine.logContextManager.trace("Connector: " + connector);
                Collection<Pool> vPools = connector.getPoolsList();
                Engine.logContextManager.trace("Pools: " + vPools);
                String poolName;
                for (Pool pool : vPools) {
                    if (!isRunning)
                        return;
                    poolName = pool.getName();
                    Engine.logContextManager.trace("Pool: " + poolName);
                    int pooledContexts = pool.getNumberOfContexts();
                    Engine.logContextManager.debug("Pool size: " + pooledContexts);
                    String poolNameWithPath = pool.getNameWithPath();
                    pooledContextsInUse = 0;
                    pooledContextsLocked = 0;
                    pooledContextsZombie = 0;
                    pooledContextsToCreate = 0;
                    counters.put(poolNameWithPath, 0);
                    if (pooledContexts > 0) {
                        for (int i = 1; i <= pool.getNumberOfContexts(); i++) {
                            if (!isRunning)
                                return;
                            Project localProject = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
                            Connector localConnector = localProject.getConnectorByName(connector.getName());
                            Pool localPool = localConnector.getPoolByName(pool.getName());
                            String servCode = localPool.getServiceCode();
                            if (servCode != null && !servCode.equals("")) {
                                if (localConnector instanceof JavelinConnector) {
                                    ((JavelinConnector) localConnector).setServiceCode(servCode);
                                    Engine.logContextManager.trace("Connector service code overridden to : " + servCode);
                                }
                            // TODO add code for each specific connector to use pools serviceCode property
                            }
                            managePoolContext(localProject, localConnector, localPool, i);
                        }
                        int pooledContextsInUsePercentage = 100 * pooledContextsInUse / pooledContexts;
                        int pooledContextsLockedPercentage = 100 * pooledContextsLocked / pooledContexts;
                        String poolStatistics = "Pool '" + poolNameWithPath + "' usage: pool size: " + pooledContexts + "; in use contexts: " + pooledContextsInUse + " (" + pooledContextsInUsePercentage + "%); zombie contexts: " + pooledContextsZombie;
                        ;
                        if (pooledContextsZombie > 0) {
                            Engine.logContextManager.warn("Pool '" + poolNameWithPath + "' had zombie contexts!");
                            Engine.logContextManager.warn(poolStatistics);
                        }
                        if (pooledContextsInUsePercentage > 80) {
                            Engine.logContextManager.warn("Pool '" + poolNameWithPath + "' is overloaded!");
                            Engine.logContextManager.warn(poolStatistics);
                        }
                        Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + poolNameWithPath + "' size", pooledContexts);
                        Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + poolNameWithPath + "' in use contexts", pooledContextsInUse + " (" + pooledContextsInUsePercentage + "%)");
                        Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + poolNameWithPath + "' locked contexts", pooledContextsLocked + " (" + pooledContextsLockedPercentage + "%)");
                        Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + poolNameWithPath + "' zombie contexts", pooledContextsZombie);
                        Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + poolNameWithPath + "' to be created contexts", pooledContextsToCreate);
                    }
                }
            }
        }
        for (Pair<Pool, Integer> pooledContextToCreate : pooledContextsToCreateSet) {
            if (!isRunning)
                return;
            String key = pooledContextToCreate.getKey().getNameWithPath();
            createPoolContext(pooledContextToCreate.getKey(), pooledContextToCreate.getValue());
            counters.put(key, counters.get(key) + 1);
            if (timeout != -1 && (now = System.currentTimeMillis()) > timeout)
                break;
        }
        for (Entry<String, Integer> entry : counters.entrySet()) {
            if (!isRunning)
                return;
            Engine.theApp.usageMonitor.setUsageCounter("[Pool] '" + entry.getKey() + "' (re)created contexts", entry.getValue());
        }
    } catch (EngineException e) {
        Engine.logContextManager.error("An unexpected error has occured in the ContextManager vulture while managing the pool contexts.", e);
    }
    Engine.logContextManager.debug("Pools creation successfully finished");
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Project(com.twinsoft.convertigo.beans.core.Project) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Pool(com.twinsoft.convertigo.beans.core.Pool) DevicePool(com.twinsoft.util.DevicePool)

Example 4 with Pool

use of com.twinsoft.convertigo.beans.core.Pool in project convertigo by convertigo.

the class ContextManager method findPoolContext.

private Context findPoolContext(String contextName, String projectName, String connectorName, String poolName) throws EngineException {
    Engine.logContextManager.debug("Trying to find a pooled context");
    Engine.logContextManager.debug("   contextName=" + contextName);
    Engine.logContextManager.debug("   projectName=" + projectName);
    Engine.logContextManager.debug("   connectorName=" + connectorName);
    Engine.logContextManager.debug("   poolName=" + poolName);
    Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
    Connector connector;
    if (connectorName == null) {
        connector = project.getDefaultConnector();
        connectorName = connector.getName();
    } else
        connector = project.getConnectorByName(connectorName);
    // If we cannot find the pool, abort the process
    Pool pool = connector.getPoolByName(poolName);
    if (pool == null) {
        Engine.logContextManager.debug("No pool named '" + poolName + "'; aborting pool management");
        return null;
    }
    Engine.logContextManager.debug("Found pool=" + pool);
    pool.checkSymbols();
    String contextIDPrefix = ContextManager.getPoolContextID(projectName, connectorName, poolName, "");
    if (contextName != null && !contextName.equals("default") && !contextName.equals("default*")) {
        Engine.logContextManager.debug("Explicit pooled context '" + contextIDPrefix + contextName + "' has been required");
        Context context = get(contextIDPrefix + contextName);
        if (context == null)
            throw new EngineException("Explicit pooled context '" + contextIDPrefix + contextName + "' does not exist!");
        Engine.logContextManager.debug("context.waitingRequests=" + context.waitingRequests);
        Engine.logContextManager.debug("context.lockPooledContext=" + context.lockPooledContext);
        if (!context.lockPooledContext)
            throw new EngineException("Explicit pooled context '" + contextIDPrefix + contextName + "' has not been locked!");
        Engine.logContextManager.debug("The context has been previously locked and has been explicitely requested");
        return context;
    } else {
        Engine.logContextManager.debug("Searching for good candidate");
        for (Map.Entry<String, Context> entry : contexts.entrySet()) {
            Engine.logContextManager.debug("Analyzing context " + entry.getKey());
            if (entry.getKey().startsWith(contextIDPrefix)) {
                Context context = entry.getValue();
                Engine.logContextManager.debug("context.waitingRequests=" + context.waitingRequests);
                Engine.logContextManager.debug("context.lockPooledContext=" + context.lockPooledContext);
                if ((context.waitingRequests == 0) && (!context.lockPooledContext) && verifyPoolContext(context)) {
                    Engine.logContextManager.debug("Good candidate for election: " + context.contextID);
                    return entry.getValue();
                }
            }
        }
        throw new EngineException("No more available context on the pool " + poolName + "; please try again later.");
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Pool(com.twinsoft.convertigo.beans.core.Pool) DevicePool(com.twinsoft.util.DevicePool) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 5 with Pool

use of com.twinsoft.convertigo.beans.core.Pool in project convertigo by convertigo.

the class DatabaseObjectTreeObject method treeObjectRemoved.

public void treeObjectRemoved(TreeObjectEvent treeObjectEvent) {
    checkDone(treeObjectEvent);
    TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
    if (!(treeObject.equals(this))) {
        // this is a pool
        if (getObject() instanceof Pool) {
            Pool pool = (Pool) getObject();
            // case transaction deleted
            if (treeObject instanceof TransactionTreeObject) {
                if (treeObject.getConnectorTreeObject().equals(getConnectorTreeObject())) {
                    if (pool.getStartTransaction().equals(treeObject.getName())) {
                        pool.setStartTransaction("");
                        hasBeenModified(true);
                        viewer.refresh();
                    }
                }
            }
            // case screenclass deleted
            if (treeObject instanceof ScreenClassTreeObject) {
                if (treeObject.getConnectorTreeObject().equals(getConnectorTreeObject())) {
                    if (pool.getInitialScreenClass().equals(treeObject.getName())) {
                        pool.setInitialScreenClass("");
                        hasBeenModified(true);
                        viewer.refresh();
                    }
                }
            }
        }
    }
    if (!(treeObject.equals(this)) && (!getParents().contains(treeObject)))
        // refresh editors (e.g labels in combobox)
        getDescriptors();
}
Also used : Pool(com.twinsoft.convertigo.beans.core.Pool)

Aggregations

Pool (com.twinsoft.convertigo.beans.core.Pool)7 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)4 Connector (com.twinsoft.convertigo.beans.core.Connector)4 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)4 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 ExtractionRule (com.twinsoft.convertigo.beans.core.ExtractionRule)3 Project (com.twinsoft.convertigo.beans.core.Project)3 Transaction (com.twinsoft.convertigo.beans.core.Transaction)3 HashMap (java.util.HashMap)3 BlockFactory (com.twinsoft.convertigo.beans.core.BlockFactory)2 Criteria (com.twinsoft.convertigo.beans.core.Criteria)2 Sequence (com.twinsoft.convertigo.beans.core.Sequence)2 Sheet (com.twinsoft.convertigo.beans.core.Sheet)2 Statement (com.twinsoft.convertigo.beans.core.Statement)2 Step (com.twinsoft.convertigo.beans.core.Step)2 TestCase (com.twinsoft.convertigo.beans.core.TestCase)2 Variable (com.twinsoft.convertigo.beans.core.Variable)2 HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)2 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)2 DevicePool (com.twinsoft.util.DevicePool)2