Search in sources :

Example 26 with RequestableVariable

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

the class MobileUIComponentTreeObject method handlesBeanNameChanged.

protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
    DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
    DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
    Object oldValue = treeObjectEvent.oldValue;
    Object newValue = treeObjectEvent.newValue;
    int update = treeObjectEvent.update;
    if (update != TreeObjectEvent.UPDATE_NONE) {
        // Case a UIStackVariable has been renamed
        if (databaseObject instanceof UIStackVariable) {
            UIStackVariable variable = (UIStackVariable) databaseObject;
            UIActionStack stack = variable.getSharedAction();
            if (stack != null) {
                // rename variable for InvokeAction
                if (getObject() instanceof UIDynamicInvoke) {
                    UIDynamicInvoke udi = (UIDynamicInvoke) getObject();
                    if (udi.getSharedActionQName().equals(stack.getQName())) {
                        boolean isLocalProject = variable.getProject().equals(udi.getProject());
                        boolean isSameValue = variable.getName().equals(oldValue);
                        boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
                        if (!isSameValue && shouldUpdate) {
                            Iterator<UIComponent> it = udi.getUIComponentList().iterator();
                            while (it.hasNext()) {
                                UIComponent component = (UIComponent) it.next();
                                if (component instanceof UIControlVariable) {
                                    UIControlVariable uicv = (UIControlVariable) component;
                                    if (uicv.getName().equals(oldValue)) {
                                        try {
                                            uicv.setName((String) newValue);
                                            uicv.hasChanged = true;
                                            hasBeenModified(true);
                                            viewer.refresh();
                                            markMainAsDirty(udi);
                                            notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
                                            break;
                                        } catch (EngineException e) {
                                            ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for InvokeAction !");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // Case a UICompVariable has been renamed
        if (databaseObject instanceof UICompVariable) {
            UICompVariable variable = (UICompVariable) databaseObject;
            UISharedComponent comp = variable.getSharedComponent();
            if (comp != null) {
                // rename variable for UseShared
                if (getObject() instanceof UIUseShared) {
                    UIUseShared uus = (UIUseShared) getObject();
                    if (uus.getSharedComponentQName().equals(comp.getQName())) {
                        boolean isLocalProject = variable.getProject().equals(uus.getProject());
                        boolean isSameValue = variable.getName().equals(oldValue);
                        boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
                        if (!isSameValue && shouldUpdate) {
                            Iterator<UIComponent> it = uus.getUIComponentList().iterator();
                            while (it.hasNext()) {
                                UIComponent component = (UIComponent) it.next();
                                if (component instanceof UIControlVariable) {
                                    UIControlVariable uicv = (UIControlVariable) component;
                                    if (uicv.getName().equals(oldValue)) {
                                        try {
                                            uicv.setName((String) newValue);
                                            uicv.hasChanged = true;
                                            hasBeenModified(true);
                                            viewer.refresh();
                                            markMainAsDirty(uus);
                                            notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
                                            break;
                                        } catch (EngineException e) {
                                            ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for UseShared !");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else // Case a RequestableVariable has been renamed
        if (databaseObject instanceof RequestableVariable) {
            RequestableVariable variable = (RequestableVariable) databaseObject;
            DatabaseObject parent = variable.getParent();
            if (getObject() instanceof UIDynamicAction) {
                UIDynamicAction uia = (UIDynamicAction) getObject();
                IonBean ionBean = uia.getIonBean();
                if (ionBean != null) {
                    // rename variable for CallSequenceAction
                    if (ionBean.getName().equals("CallSequenceAction")) {
                        Object p_val = ionBean.getProperty("requestable").getValue();
                        if (!p_val.equals(false)) {
                            if (parent.getQName().equals(p_val.toString())) {
                                boolean isLocalProject = variable.getProject().equals(uia.getProject());
                                boolean isSameValue = variable.getName().equals(oldValue);
                                boolean shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
                                if (!isSameValue && shouldUpdate) {
                                    Iterator<UIComponent> it = uia.getUIComponentList().iterator();
                                    while (it.hasNext()) {
                                        UIComponent component = (UIComponent) it.next();
                                        if (component instanceof UIControlVariable) {
                                            UIControlVariable uicv = (UIControlVariable) component;
                                            if (uicv.getName().equals(oldValue)) {
                                                try {
                                                    uicv.setName((String) newValue);
                                                    uicv.hasChanged = true;
                                                    hasBeenModified(true);
                                                    viewer.refresh();
                                                    markMainAsDirty(uia);
                                                    notifyDataseObjectPropertyChanged(uicv, "name", oldValue, newValue, new HashSet<Object>());
                                                    break;
                                                } catch (EngineException e) {
                                                    ConvertigoPlugin.logException(e, "Unable to refactor the references of '" + newValue + "' variable for CallSequenceAction !");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : UICompVariable(com.twinsoft.convertigo.beans.mobile.components.UICompVariable) IonBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) EngineException(com.twinsoft.convertigo.engine.EngineException) UIStackVariable(com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) UIControlVariable(com.twinsoft.convertigo.beans.mobile.components.UIControlVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) UIActionStack(com.twinsoft.convertigo.beans.mobile.components.UIActionStack) UIDynamicAction(com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) UIDynamicInvoke(com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke) Iterator(java.util.Iterator) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) HashSet(java.util.HashSet)

Example 27 with RequestableVariable

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

the class ChangeToMultiValuedVariableAction method run.

@Override
public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            TreeParent treeParent = treeObject.getParent();
            DatabaseObjectTreeObject parentTreeObject = null;
            if (treeParent instanceof DatabaseObjectTreeObject)
                parentTreeObject = (DatabaseObjectTreeObject) treeParent;
            else
                parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
            if (parentTreeObject != null) {
                Object databaseObject = treeObject.getObject();
                if (databaseObject != null) {
                    Variable simple = (Variable) databaseObject;
                    Variable multi = null;
                    if (databaseObject instanceof TestCaseVariable)
                        multi = new TestCaseMultiValuedVariable();
                    if (databaseObject instanceof StepVariable)
                        multi = new StepMultiValuedVariable();
                    if (databaseObject instanceof RequestableVariable)
                        multi = new RequestableMultiValuedVariable();
                    if (databaseObject instanceof RequestableHttpVariable)
                        multi = new RequestableHttpMultiValuedVariable();
                    if (databaseObject instanceof HttpStatementVariable)
                        multi = new HttpStatementMultiValuedVariable();
                    if (multi != null) {
                        if (multi instanceof StepVariable) {
                            ((StepVariable) multi).setSourceDefinition(((StepVariable) simple).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) multi).setXmlTypeAffectation(((RequestableVariable) simple).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) multi).setHttpName(((RequestableHttpVariable) simple).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) multi).setHttpMethod(((RequestableHttpVariable) simple).getHttpMethod());
                        }
                        Object value = simple.getValueOrNull();
                        multi.setValueOrNull(value);
                        multi.setVisibility(simple.getVisibility());
                        // Comment
                        multi.setComment(simple.getComment());
                        // Description
                        multi.setDescription(simple.getDescription());
                        // Required
                        multi.setRequired(simple.isRequired());
                        multi.bNew = true;
                        multi.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = simple.getParent();
                        parentDbo.add(multi);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(multi, simple.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(multi, simple.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, multi);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        simple.delete();
                        // Set correct name
                        multi.setName(simple.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(multi));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Cursor(org.eclipse.swt.graphics.Cursor) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TestCase(com.twinsoft.convertigo.beans.core.TestCase) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 28 with RequestableVariable

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

the class CouchAddVariables method cleanProps.

private PropertyDescriptor[] cleanProps(AbstractCouchDbTransaction couchDbTransaction, PropertyDescriptor[] props) {
    List<PropertyDescriptor> cleanProps = new ArrayList<PropertyDescriptor>();
    List<RequestableVariable> vars = couchDbTransaction.getVariablesList();
    for (PropertyDescriptor prop : props) {
        String propName = prop.getName();
        boolean find = false;
        int i = 0;
        if (propName.startsWith("p_") || propName.startsWith("q_")) {
            while (!find && i < vars.size()) {
                String varName = vars.get(i).getName();
                if (varName.startsWith(CouchParam.prefix)) {
                    if (varName.equals(CouchParam.prefix + propName.substring(2))) {
                        find = true;
                    }
                }
                ++i;
            }
            if (!find) {
                cleanProps.add(prop);
            }
        }
    }
    PropertyDescriptor[] array = new PropertyDescriptor[cleanProps.size()];
    cleanProps.toArray(array);
    return array;
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) ArrayList(java.util.ArrayList) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Example 29 with RequestableVariable

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

the class CreateFormFromTransactionAction method generateXSLForm.

private String generateXSLForm(Connector connector, TransactionWithVariables tr) throws Exception {
    // Build a source DOM containing all the variable part of the generatedXSL file
    Document doc = new DefaultRequester().createDomWithNoXMLDeclaration(tr.getEncodingCharSet());
    Element variables = doc.createElement("variables");
    doc.appendChild(variables);
    /*int size = tr.getVariablesDefinitionSize();
		for (int i = 0 ; i < size ; i++) {
			Element variable = doc.createElement("variable");
			
			Element elt = doc.createElement("variableDefinitionName");
			elt.appendChild(doc.createTextNode(tr.getVariableDefinitionName(i)));
			variable.appendChild(elt);

			elt = doc.createElement("variableDefinitionDefaultValue");
			elt.appendChild(doc.createTextNode((String)tr.getVariableDefinitionDefaultValue(i)));
			variable.appendChild(elt);
			
			elt = doc.createElement("VariableDefinitionDescription");
			elt.appendChild(doc.createTextNode(tr.getVariableDefinitionDescription(i)));
			variable.appendChild(elt);
			
			variables.appendChild(variable);
		}*/
    int size = tr.numberOfVariables();
    for (int i = 0; i < size; i++) {
        RequestableVariable rVariable = (RequestableVariable) tr.getVariable(i);
        if (rVariable != null) {
            Element variable = doc.createElement("variable");
            Element elt = doc.createElement("variableDefinitionName");
            elt.appendChild(doc.createTextNode(rVariable.getName()));
            variable.appendChild(elt);
            elt = doc.createElement("variableDefinitionDefaultValue");
            elt.appendChild(doc.createTextNode(rVariable.getDefaultValue().toString()));
            variable.appendChild(elt);
            elt = doc.createElement("VariableDefinitionDescription");
            elt.appendChild(doc.createTextNode(rVariable.getDescription()));
            variable.appendChild(elt);
            variables.appendChild(variable);
        }
    }
    Element elt = doc.createElement("transactionName");
    elt.appendChild(doc.createTextNode(tr.getName()));
    variables.appendChild(elt);
    // Transform using the GenerateForm.xsl template
    // System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
    // TransformerFactory tFactory = TransformerFactory.newInstance();
    TransformerFactory tFactory = new org.apache.xalan.xsltc.trax.TransformerFactoryImpl();
    String filePath = Engine.TEMPLATES_PATH + "/xsl/GenerateForm.xsl";
    StreamSource streamSource = new StreamSource(new File(filePath).toURI().toASCIIString());
    Transformer transformer = tFactory.newTransformer(streamSource);
    StringWriter sw = new StringWriter();
    transformer.transform(new DOMSource(doc), new StreamResult(sw));
    String xslContent = sw.toString();
    xslContent = XMLUtils.prettyPrintDOM(xslContent);
    return xslContent;
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) Element(org.w3c.dom.Element) StreamSource(javax.xml.transform.stream.StreamSource) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Document(org.w3c.dom.Document) DefaultRequester(com.twinsoft.convertigo.engine.requesters.DefaultRequester) StringWriter(java.io.StringWriter) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 30 with RequestableVariable

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

the class TreeDropAdapter method paste.

private boolean paste(Node node, TreeObject targetTreeObject) throws EngineException {
    if (targetTreeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
        DatabaseObject databaseObject = paste(node, null, true);
        Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
        // SEQUENCER
        if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
            if (parent instanceof XMLElementStep)
                return false;
            if (parent instanceof IThenElseContainer)
                return false;
            // Add a TransactionStep
            if (databaseObject instanceof Transaction) {
                String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                String connectorName = ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name");
                Transaction transaction = (Transaction) databaseObject;
                TransactionStep transactionStep = new TransactionStep();
                transactionStep.setSourceTransaction(projectName + TransactionStep.SOURCE_SEPARATOR + connectorName + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
                transactionStep.bNew = true;
                parent.add(transactionStep);
                parent.hasChanged = true;
                if (transaction instanceof TransactionWithVariables) {
                    for (Variable variable : ((TransactionWithVariables) transaction).getVariablesList()) {
                        StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
                        stepVariable.setName(variable.getName());
                        stepVariable.setComment(variable.getComment());
                        stepVariable.setDescription(variable.getDescription());
                        stepVariable.setRequired(variable.isRequired());
                        stepVariable.setValueOrNull(variable.getValueOrNull());
                        stepVariable.setVisibility(variable.getVisibility());
                        transactionStep.addVariable(stepVariable);
                    }
                }
                return true;
            } else // Add a SequenceStep
            if (databaseObject instanceof Sequence) {
                String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                Sequence seq = (Sequence) databaseObject;
                SequenceStep sequenceStep = new SequenceStep();
                sequenceStep.setSourceSequence(projectName + SequenceStep.SOURCE_SEPARATOR + seq.getName());
                sequenceStep.bNew = true;
                parent.add(sequenceStep);
                parent.hasChanged = true;
                for (Variable variable : seq.getVariablesList()) {
                    StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
                    stepVariable.setName(variable.getName());
                    stepVariable.setComment(variable.getComment());
                    stepVariable.setDescription(variable.getDescription());
                    stepVariable.setRequired(variable.isRequired());
                    stepVariable.setValueOrNull(variable.getValueOrNull());
                    stepVariable.setVisibility(variable.getVisibility());
                    sequenceStep.addVariable(stepVariable);
                }
                return true;
            }
        } else // URLMAPPER
        if (parent instanceof UrlMappingOperation) {
            // Set associated requestable, add all parameters for operation
            if (databaseObject instanceof RequestableObject) {
                String dboQName = "";
                if (databaseObject instanceof Sequence) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
                } else if (databaseObject instanceof Transaction) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
                }
                UrlMappingOperation operation = (UrlMappingOperation) parent;
                operation.setTargetRequestable(dboQName);
                if (operation.getComment().isEmpty()) {
                    operation.setComment(databaseObject.getComment());
                }
                operation.hasChanged = true;
                try {
                    StringTokenizer st = new StringTokenizer(dboQName, ".");
                    int count = st.countTokens();
                    Project p = Engine.theApp.databaseObjectsManager.getProjectByName(st.nextToken());
                    List<RequestableVariable> variables = new ArrayList<RequestableVariable>();
                    if (count == 2) {
                        variables = p.getSequenceByName(st.nextToken()).getVariablesList();
                    } else if (count == 3) {
                        variables = ((TransactionWithVariables) p.getConnectorByName(st.nextToken()).getTransactionByName(st.nextToken())).getVariablesList();
                    }
                    for (RequestableVariable variable : variables) {
                        String variableName = variable.getName();
                        Object variableValue = variable.getValueOrNull();
                        UrlMappingParameter parameter = null;
                        try {
                            parameter = operation.getParameterByName(variableName);
                        } catch (Exception e) {
                        }
                        if (parameter == null) {
                            boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
                            parameter = acceptForm ? new FormParameter() : new QueryParameter();
                            parameter.setName(variableName);
                            parameter.setComment(variable.getComment());
                            parameter.setArray(false);
                            parameter.setExposed(((RequestableVariable) variable).isWsdl());
                            parameter.setMultiValued(variable.isMultiValued());
                            parameter.setRequired(variable.isRequired());
                            parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
                            parameter.setMappedVariableName(variableName);
                            parameter.bNew = true;
                            operation.add(parameter);
                            operation.hasChanged = true;
                        }
                    }
                } catch (Exception e) {
                }
                return true;
            } else // Add a parameter to mapping operation
            if (databaseObject instanceof RequestableVariable) {
                RequestableVariable variable = (RequestableVariable) databaseObject;
                UrlMappingOperation operation = (UrlMappingOperation) parent;
                UrlMappingParameter parameter = null;
                String variableName = variable.getName();
                Object variableValue = variable.getValueOrNull();
                try {
                    parameter = operation.getParameterByName(variableName);
                } catch (Exception e) {
                }
                if (parameter == null) {
                    boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
                    parameter = acceptForm ? new FormParameter() : new QueryParameter();
                    parameter.setName(variableName);
                    parameter.setComment(variable.getComment());
                    parameter.setArray(false);
                    parameter.setExposed(((RequestableVariable) variable).isWsdl());
                    parameter.setMultiValued(variable.isMultiValued());
                    parameter.setRequired(variable.isRequired());
                    parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
                    parameter.setMappedVariableName(variableName);
                    parameter.bNew = true;
                    operation.add(parameter);
                    operation.hasChanged = true;
                }
                return true;
            }
        } else // MOBILE COMPONENTS
        if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            return pasteMobileComponent(parent, databaseObject, element);
        } else // NGX COMPONENTS
        if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            return pasteNgxComponent(parent, databaseObject, element);
        }
    }
    return false;
}
Also used : QueryParameter(com.twinsoft.convertigo.beans.rest.QueryParameter) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IThenElseContainer(com.twinsoft.convertigo.beans.steps.IThenElseContainer) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) FormParameter(com.twinsoft.convertigo.beans.rest.FormParameter) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Project(com.twinsoft.convertigo.beans.core.Project) StringTokenizer(java.util.StringTokenizer) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)

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