Search in sources :

Example 16 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class Migration5_0_0 method newVariable.

private static Variable newVariable(String classname, XMLVector<?> xmlv, int index) throws EngineException {
    Class<? extends DatabaseObject> beanClass;
    try {
        beanClass = GenericUtils.cast(Class.forName(classname));
        if (AbstractHttpTransaction.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(4);
            RequestableHttpVariable variable;
            variable = (isMulti ? new RequestableHttpMultiValuedVariable() : new RequestableHttpVariable());
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setWsdl(((Boolean) xmlv.get(3)));
            variable.setPersonalizable(((Boolean) xmlv.get(5)));
            variable.setCachedKey(((Boolean) xmlv.get(6)));
            variable.setHttpMethod((String) xmlv.get(7));
            variable.setHttpName((String) xmlv.get(8));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (TransactionWithVariables.class.isAssignableFrom(beanClass) || Sequence.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(4);
            RequestableVariable variable = (isMulti ? new RequestableMultiValuedVariable() : new RequestableVariable());
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setWsdl(((Boolean) xmlv.get(3)));
            variable.setPersonalizable(((Boolean) xmlv.get(5)));
            variable.setCachedKey(((Boolean) xmlv.get(6)));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (RequestableStep.class.isAssignableFrom(beanClass)) {
            StepVariable variable = new StepVariable();
            variable.setName((String) xmlv.get(0));
            variable.setDescription((String) xmlv.get(1));
            variable.setSourceDefinition(GenericUtils.<XMLVector<String>>cast(xmlv.get(2)));
            variable.setValueOrNull(xmlv.get(3));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else if (com.twinsoft.convertigo.beans.statements.HTTPStatement.class.isAssignableFrom(beanClass)) {
            Boolean isMulti = (Boolean) xmlv.get(3);
            HttpStatementVariable variable;
            variable = (isMulti ? new HttpStatementMultiValuedVariable() : new HttpStatementVariable());
            try {
                variable.setName((String) xmlv.get(0));
            } catch (Exception e) {
                variable.setName("variable" + index);
                Engine.logDatabaseObjectManager.warn("[Migration 4.6.0] For variable at index " + index + ", empty name has been replaced by 'variable" + index + "'!");
            }
            variable.setDescription((String) xmlv.get(1));
            variable.setValueOrNull(xmlv.get(2));
            variable.setHttpMethod((String) xmlv.get(4));
            variable.setHttpName((String) xmlv.get(5));
            variable.bNew = true;
            variable.hasChanged = true;
            return variable;
        } else {
            throw new EngineException("[Migration 4.6.0] Unsupported classname \"" + classname + "\"");
        }
    } catch (Exception e) {
        throw new EngineException("[Migration 4.6.0] Unable to create variable bean", e);
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)

Example 17 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class ProjectExplorerView method edit.

private void edit(TreeObject treeObject) {
    final Tree tree = viewer.getTree();
    final TreeEditor editor = new TreeEditor(tree);
    final Color black = getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK);
    TreeItem[] items = tree.getSelection();
    if (items.length > 0) {
        final TreeItem item = items[0];
        final TreeObject theTreeObject = treeObject;
        if (treeObject instanceof ProjectTreeObject) {
            if (((ProjectTreeObject) treeObject).getModified()) {
                // Project need to be saved to avoid xsd/wsdl modification errors - Fix ticket #2265
                ConvertigoPlugin.warningMessageBox("Please save project before renaming it.");
                return;
            }
        }
        if (treeObject.getObject() instanceof HandlerStatement) {
            return;
        }
        if ((item != null) && lastItem.length > 0 && (item == lastItem[0])) {
            boolean isCarbon = SWT.getPlatform().equals("carbon");
            final Composite composite = new Composite(tree, SWT.NONE);
            if (!isCarbon) {
                composite.setBackground(black);
            }
            final Text text = new Text(composite, SWT.NONE);
            final int inset = isCarbon ? 0 : 1;
            composite.addListener(SWT.Resize, new Listener() {

                public void handleEvent(Event e) {
                    Rectangle rect = composite.getClientArea();
                    text.setBounds(rect.x + inset, rect.y + inset, rect.width - inset * 2, rect.height - inset * 2);
                }
            });
            Listener textListener = new Listener() {

                public void handleEvent(final Event e) {
                    MobileBuilder mba = null;
                    MobileBuilder mbo = null;
                    IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
                    if (editorPart != null) {
                        IEditorInput input = editorPart.getEditorInput();
                        if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
                            com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
                            mba = editorInput.getApplication().getProject().getMobileBuilder();
                        }
                        if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
                            com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
                            mba = editorInput.getApplication().getProject().getMobileBuilder();
                        }
                    }
                    if (theTreeObject instanceof DatabaseObjectTreeObject) {
                        mbo = ((DatabaseObjectTreeObject) theTreeObject).getObject().getProject().getMobileBuilder();
                    }
                    String newName = null;
                    String oldName = null;
                    boolean needRefresh = false;
                    boolean needProjectReload = false;
                    if (theTreeObject instanceof DatabaseObjectTreeObject) {
                        oldName = ((DatabaseObject) ((DatabaseObjectTreeObject) theTreeObject).getObject()).getName();
                    } else if (theTreeObject instanceof TraceTreeObject) {
                        oldName = ((TraceTreeObject) theTreeObject).getName();
                    } else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
                        oldName = ((DesignDocumentViewTreeObject) theTreeObject).getName();
                    } else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
                        oldName = ((DesignDocumentFunctionTreeObject) theTreeObject).getName();
                    }
                    switch(e.type) {
                        case SWT.FocusOut:
                            editingTextCtrl = null;
                            composite.dispose();
                            break;
                        case SWT.Verify:
                            String newText = text.getText();
                            String leftText = newText.substring(0, e.start);
                            String rightText = newText.substring(e.end, newText.length());
                            GC gc = new GC(text);
                            Point size = gc.textExtent(leftText + e.text + rightText);
                            gc.dispose();
                            size = text.computeSize(size.x, SWT.DEFAULT);
                            editor.horizontalAlignment = SWT.LEFT;
                            Rectangle itemRect = item.getBounds(), rect = tree.getClientArea();
                            editor.minimumWidth = Math.max(size.x, itemRect.width) + inset * 2;
                            int left = itemRect.x, right = rect.x + rect.width;
                            editor.minimumWidth = Math.min(editor.minimumWidth, right - left);
                            editor.minimumHeight = size.y + inset * 2;
                            editor.layout();
                            break;
                        case SWT.Traverse:
                            switch(e.detail) {
                                case SWT.TRAVERSE_RETURN:
                                    Engine.logStudio.info("---------------------- Rename started ----------------------");
                                    if (mba != null) {
                                        mba.prepareBatchBuild();
                                    }
                                    newName = text.getText();
                                    // Save and close editors
                                    if (theTreeObject instanceof IClosableTreeObject) {
                                        ((IClosableTreeObject) theTreeObject).closeAllEditors(true);
                                    }
                                    if (theTreeObject instanceof DatabaseObjectTreeObject) {
                                        DatabaseObjectTreeObject dbObjectTreeObject = (DatabaseObjectTreeObject) theTreeObject;
                                        if (dbObjectTreeObject.rename(newName, Boolean.TRUE)) {
                                            item.setText(newName);
                                            needRefresh = true;
                                            if (theTreeObject instanceof ProjectTreeObject) {
                                                needProjectReload = true;
                                            }
                                        }
                                    } else if (theTreeObject instanceof TraceTreeObject) {
                                        TraceTreeObject traceTreeObject = (TraceTreeObject) theTreeObject;
                                        traceTreeObject.rename(newName);
                                        if (traceTreeObject.hasChanged) {
                                            item.setText(newName);
                                            traceTreeObject.hasChanged = false;
                                            needRefresh = true;
                                        }
                                    } else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
                                        DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) theTreeObject;
                                        if (ddvto.rename(newName, Boolean.TRUE)) {
                                            item.setText(newName);
                                            needRefresh = true;
                                        }
                                    } else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
                                        DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject) theTreeObject;
                                        if (ddfto.rename(newName, Boolean.TRUE)) {
                                            item.setText(newName);
                                            needRefresh = true;
                                        }
                                    }
                                // FALL THROUGH
                                case SWT.TRAVERSE_ESCAPE:
                                    editingTextCtrl = null;
                                    composite.dispose();
                                    e.doit = false;
                            }
                            break;
                    }
                    if (needRefresh) {
                        boolean updateDlg = false;
                        boolean updateReferences = false;
                        int update = 0;
                        // Updates references to object if needed
                        if ((theTreeObject instanceof ProjectTreeObject) || (theTreeObject instanceof SequenceTreeObject) || (theTreeObject instanceof ConnectorTreeObject) || (theTreeObject instanceof TransactionTreeObject) || (theTreeObject instanceof VariableTreeObject2) || (theTreeObject instanceof IDesignTreeObject) || (theTreeObject instanceof MobilePageComponentTreeObject) || (theTreeObject instanceof MobileUIComponentTreeObject) || (theTreeObject instanceof NgxPageComponentTreeObject) || (theTreeObject instanceof NgxUIComponentTreeObject)) {
                            String objectType = "";
                            if (theTreeObject instanceof ProjectTreeObject) {
                                objectType = "project";
                                updateDlg = true;
                            } else if (theTreeObject instanceof SequenceTreeObject) {
                                objectType = "sequence";
                                updateDlg = true;
                            } else if (theTreeObject instanceof ConnectorTreeObject) {
                                objectType = "connector";
                                updateDlg = true;
                            } else if (theTreeObject instanceof TransactionTreeObject) {
                                objectType = "transaction";
                                updateDlg = true;
                            } else if (theTreeObject instanceof VariableTreeObject2) {
                                objectType = "variable";
                                updateDlg = ((DatabaseObject) theTreeObject.getObject()) instanceof RequestableVariable ? true : false;
                            } else if (theTreeObject instanceof DesignDocumentTreeObject) {
                                objectType = "document";
                                updateDlg = true;
                            } else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
                                objectType = "view";
                                updateDlg = true;
                            } else if (theTreeObject instanceof DesignDocumentFilterTreeObject) {
                                objectType = "filter";
                                updateDlg = true;
                            } else if (theTreeObject instanceof DesignDocumentUpdateTreeObject) {
                                objectType = "update";
                                updateDlg = true;
                            } else if (theTreeObject instanceof DesignDocumentValidateTreeObject) {
                                objectType = "validate";
                                updateDlg = true;
                            } else if (theTreeObject instanceof MobilePageComponentTreeObject) {
                                objectType = "page";
                                updateDlg = true;
                            } else if (theTreeObject instanceof NgxPageComponentTreeObject) {
                                objectType = "page";
                                updateDlg = true;
                            } else if (theTreeObject instanceof MobileUIComponentTreeObject) {
                                DatabaseObject dbo = (DatabaseObject) theTreeObject.getObject();
                                if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                                    objectType = "menu";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
                                    objectType = "shared action";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
                                    objectType = "shared component";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) {
                                    objectType = "variable";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.mobile.components.UICompVariable) {
                                    objectType = "variable";
                                    updateDlg = true;
                                }
                            } else if (theTreeObject instanceof NgxUIComponentTreeObject) {
                                DatabaseObject dbo = (DatabaseObject) theTreeObject.getObject();
                                if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                                    objectType = "menu";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                                    objectType = "shared action";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
                                    objectType = "shared component";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) {
                                    objectType = "variable";
                                    updateDlg = true;
                                }
                                if (dbo instanceof com.twinsoft.convertigo.beans.ngx.components.UICompVariable) {
                                    objectType = "variable";
                                    updateDlg = true;
                                }
                            }
                            if (updateDlg) {
                                Shell shell = Display.getDefault().getActiveShell();
                                CustomDialog customDialog = new CustomDialog(shell, "Update object references", "Do you want to update " + objectType + " references ?\n You can replace '" + oldName + "' by '" + newName + "' in all loaded projects \n or replace '" + oldName + "' by '" + newName + "' in current project only.", 670, 200, new ButtonSpec("Replace in all loaded projects", true), new ButtonSpec("Replace in current project", false), new ButtonSpec("Do not replace anywhere", false));
                                int response = customDialog.open();
                                if (response == 0) {
                                    updateReferences = true;
                                    update = TreeObjectEvent.UPDATE_ALL;
                                }
                                if (response == 1) {
                                    updateReferences = true;
                                    update = TreeObjectEvent.UPDATE_LOCAL;
                                }
                            }
                        }
                        TreeObjectEvent treeObjectEvent = null;
                        if (updateReferences) {
                            treeObjectEvent = new TreeObjectEvent(theTreeObject, "name", oldName, newName, update);
                        } else {
                            treeObjectEvent = new TreeObjectEvent(theTreeObject, "name", oldName, newName);
                        }
                        BatchOperationHelper.start();
                        ProjectExplorerView.this.refreshTree();
                        ProjectExplorerView.this.setSelectedTreeObject(theTreeObject);
                        ProjectExplorerView.this.fireTreeObjectPropertyChanged(treeObjectEvent);
                        if (updateReferences && needProjectReload) {
                            ((ProjectTreeObject) theTreeObject).save(false);
                        }
                        if (mbo != null) {
                            if (theTreeObject instanceof MobilePageComponentTreeObject) {
                                try {
                                    mbo.pageRenamed((com.twinsoft.convertigo.beans.mobile.components.PageComponent) theTreeObject.getObject(), oldName);
                                } catch (EngineException e1) {
                                    e1.printStackTrace();
                                }
                            }
                            if (theTreeObject instanceof NgxPageComponentTreeObject) {
                                try {
                                    mbo.pageRenamed((com.twinsoft.convertigo.beans.ngx.components.PageComponent) theTreeObject.getObject(), oldName);
                                } catch (EngineException e1) {
                                    e1.printStackTrace();
                                }
                            }
                        }
                        BatchOperationHelper.stop();
                        Engine.logStudio.info("---------------------- Rename ended   ----------------------");
                        StructuredSelection structuredSelection = new StructuredSelection(theTreeObject);
                        ISelectionListener listener = null;
                        // refresh properties view
                        listener = ConvertigoPlugin.getDefault().getPropertiesView();
                        if (listener != null)
                            listener.selectionChanged((IWorkbenchPart) ProjectExplorerView.this, structuredSelection);
                        // refresh references view
                        listener = ConvertigoPlugin.getDefault().getReferencesView();
                        if (listener != null)
                            listener.selectionChanged((IWorkbenchPart) ProjectExplorerView.this, structuredSelection);
                    }
                    if (needProjectReload) {
                        Engine.theApp.databaseObjectsManager.clearCache(newName);
                        reloadProject(theTreeObject);
                        refreshTree();
                    }
                }
            };
            text.addListener(SWT.FocusOut, textListener);
            text.addListener(SWT.Traverse, textListener);
            text.addListener(SWT.Verify, textListener);
            editor.setEditor(composite, item);
            if (theTreeObject instanceof DatabaseObjectTreeObject) {
                text.setText(((DatabaseObjectTreeObject) theTreeObject).getName());
            } else if (theTreeObject instanceof TraceTreeObject) {
                text.setText(((TraceTreeObject) theTreeObject).getName());
            } else if (theTreeObject instanceof DesignDocumentViewTreeObject) {
                text.setText(((DesignDocumentViewTreeObject) theTreeObject).getName());
            } else if (theTreeObject instanceof DesignDocumentFunctionTreeObject) {
                text.setText(((DesignDocumentFunctionTreeObject) theTreeObject).getName());
            }
            text.selectAll();
            text.setFocus();
            editingTextCtrl = text;
        }
        lastItem[0] = item;
    }
}
Also used : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeItem(org.eclipse.swt.widgets.TreeItem) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) Rectangle(org.eclipse.swt.graphics.Rectangle) EngineException(com.twinsoft.convertigo.engine.EngineException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ISelectionListener(org.eclipse.ui.ISelectionListener) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) Tree(org.eclipse.swt.widgets.Tree) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) Color(org.eclipse.swt.graphics.Color) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) 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) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) 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) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) Shell(org.eclipse.swt.widgets.Shell) GC(org.eclipse.swt.graphics.GC) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) TreeEditor(org.eclipse.swt.custom.TreeEditor) Composite(org.eclipse.swt.widgets.Composite) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) Text(org.eclipse.swt.widgets.Text) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) DatabaseObjectImportedEvent(com.twinsoft.convertigo.engine.DatabaseObjectImportedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) DatabaseObjectLoadedEvent(com.twinsoft.convertigo.engine.DatabaseObjectLoadedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Event(org.eclipse.swt.widgets.Event) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) IEditorInput(org.eclipse.ui.IEditorInput) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject)

Example 18 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class PostBulkDocumentsTransaction method invoke.

@Override
protected Object invoke() throws Exception {
    FullSyncContext.get().setFsAclPolicy(getFullSyncAclPolicy());
    JSONObject jsonDoc = null;
    JSONArray jsonDocuments;
    String json_base = getParameterStringValue(CouchParam.json_base);
    try {
        jsonDocuments = new JSONArray(json_base);
    } catch (Throwable t1) {
        try {
            jsonDoc = new JSONObject(json_base);
        } catch (Throwable t2) {
        // ignore json_base
        }
        jsonDocuments = new JSONArray();
    }
    // add document members from variables
    for (RequestableVariable variable : getVariablesList()) {
        String variableName = variable.getName();
        if (variable.isMultiValued() && !variableName.startsWith(CouchParam.prefix) && !variableName.startsWith("__")) {
            Object jsonv = toJson(getParameterValue(variableName));
            if (jsonv != null && jsonv instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) jsonv;
                while (jsonDocuments.length() < jsonArray.length()) {
                    jsonDocuments.put(jsonDoc == null ? new JSONObject() : new JSONObject(json_base));
                }
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonDocument = jsonDocuments.getJSONObject(i);
                    addJson(jsonDocument, variableName, jsonArray.get(i), getParameterDataTypeClass(variableName));
                }
            }
        }
    }
    for (RequestableVariable variable : getVariablesList()) {
        String variableName = variable.getName();
        if (!variable.isMultiValued() && !variableName.startsWith(CouchParam.prefix) && !variableName.startsWith("__")) {
            Object jsonv = toJson(getParameterValue(variableName));
            for (int i = 0; i < jsonDocuments.length(); i++) {
                JSONObject jsonDocument = jsonDocuments.getJSONObject(i);
                addJson(jsonDocument, variableName, jsonv, getParameterDataTypeClass(variableName));
            }
        }
    }
    Map<List<String>, String> mergeRules = policy.mergeRules(getParameterStringValue(CouchParam.merge));
    boolean all_or_nothing = getParameterBooleanValue(CouchParam.all_or_nothing, false);
    boolean new_edits = getParameterBooleanValue(CouchParam.new_edits, true);
    JSONObject response = getCouchClient().postBulkDocs(getTargetDatabase(), jsonDocuments, all_or_nothing, new_edits, policy, mergeRules, useHash);
    return response;
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) JSONObject(org.codehaus.jettison.json.JSONObject) List(java.util.List)

Example 19 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class Sequence method generateXsdArrayOfData.

@Override
public String generateXsdArrayOfData() throws Exception {
    String xsdArrayData = "";
    RequestableVariable variable = null;
    for (int i = 0; i < numberOfVariables(); i++) {
        variable = (RequestableVariable) getVariable(i);
        if (variable.isWsdl()) {
            if (variable.isMultiValued()) {
                xsdArrayData += Engine.getArrayOfSchema(variable.getSchemaType());
            }
        }
    }
    return xsdArrayData;
}
Also used : RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Example 20 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class Sequence method getVariablesDefinition.

/**
 * Compatibility for version older than 4.6.0 *
 */
@Deprecated
public XMLVector<XMLVector<Object>> getVariablesDefinition() {
    XMLVector<XMLVector<Object>> xmlv = new XMLVector<XMLVector<Object>>();
    getVariablesList();
    if (hasVariables()) {
        for (int i = 0; i < numberOfVariables(); i++) {
            RequestableVariable variable = (RequestableVariable) getVariable(i);
            XMLVector<Object> v = new XMLVector<Object>();
            v.add(variable.getName());
            v.add(variable.getDescription());
            v.add(variable.getDefaultValue());
            v.add(variable.isWsdl());
            v.add(variable.isMultiValued());
            v.add(variable.isPersonalizable());
            v.add(variable.isCachedKey());
            xmlv.add(v);
        }
    }
    return xmlv;
}
Also used : XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Aggregations

RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)54 EngineException (com.twinsoft.convertigo.engine.EngineException)23 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 Sequence (com.twinsoft.convertigo.beans.core.Sequence)11 Element (org.w3c.dom.Element)9 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)8 RequestableMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)7 StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)7 TestCaseVariable (com.twinsoft.convertigo.beans.variables.TestCaseVariable)7 Shell (org.eclipse.swt.widgets.Shell)6 TransactionWithVariables (com.twinsoft.convertigo.beans.core.TransactionWithVariables)5 Variable (com.twinsoft.convertigo.beans.core.Variable)5 RequestableHttpVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpVariable)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)5 Cursor (org.eclipse.swt.graphics.Cursor)5 Display (org.eclipse.swt.widgets.Display)5 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)3