Search in sources :

Example 1 with RequestableHttpVariable

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

the class SwaggerUtils method createRestConnector.

@SuppressWarnings("unused")
private static HttpConnector createRestConnector(JSONObject json) throws Exception {
    try {
        HttpConnector httpConnector = new HttpConnector();
        httpConnector.bNew = true;
        JSONObject info = json.getJSONObject("info");
        httpConnector.setName(StringUtils.normalize(info.getString("title")));
        String host = json.getString("host");
        int index = host.indexOf(":");
        String server = index == -1 ? host : host.substring(0, index);
        int port = index == -1 ? 0 : Integer.parseInt(host.substring(index + 1, 10));
        httpConnector.setServer(server);
        httpConnector.setPort(port <= 0 ? 80 : port);
        String basePath = json.getString("basePath");
        httpConnector.setBaseDir(basePath);
        JSONArray _consumes = new JSONArray();
        if (json.has("consumes")) {
            _consumes = json.getJSONArray("consumes");
        }
        JSONArray _produces = new JSONArray();
        if (json.has("produces")) {
            _produces = json.getJSONArray("produces");
        }
        Map<String, JSONObject> models = new HashMap<String, JSONObject>();
        JSONObject definitions = new JSONObject();
        if (json.has("definitions")) {
            definitions = json.getJSONObject("definitions");
            for (Iterator<String> i = GenericUtils.cast(definitions.keys()); i.hasNext(); ) {
                String key = i.next();
                JSONObject model = definitions.getJSONObject(key);
                models.put(key, model);
            }
        }
        JSONObject paths = json.getJSONObject("paths");
        for (Iterator<String> i1 = GenericUtils.cast(paths.keys()); i1.hasNext(); ) {
            String subDir = i1.next();
            JSONObject path = paths.getJSONObject(subDir);
            for (Iterator<String> i2 = GenericUtils.cast(path.keys()); i2.hasNext(); ) {
                String httpVerb = i2.next();
                JSONObject verb = path.getJSONObject(httpVerb);
                XMLVector<XMLVector<String>> httpParameters = new XMLVector<XMLVector<String>>();
                AbstractHttpTransaction transaction = new HttpTransaction();
                JSONArray consumes = verb.has("consumes") ? verb.getJSONArray("consumes") : _consumes;
                List<String> consumeList = new ArrayList<String>();
                for (int i = 0; i < consumes.length(); i++) {
                    consumeList.add(consumes.getString(i));
                }
                String h_ContentType = null;
                if (consumeList.contains(MimeType.Xml.value())) {
                    h_ContentType = MimeType.Xml.value();
                } else if (consumeList.contains(MimeType.Json.value())) {
                    h_ContentType = MimeType.Json.value();
                } else {
                    h_ContentType = consumeList.size() > 0 ? consumeList.get(0) : MimeType.WwwForm.value();
                }
                JSONArray produces = verb.has("produces") ? verb.getJSONArray("produces") : _produces;
                List<String> produceList = new ArrayList<String>();
                for (int i = 0; i < produces.length(); i++) {
                    produceList.add(produces.getString(i));
                }
                String h_Accept = null;
                if (produceList.contains(h_ContentType)) {
                    h_Accept = h_ContentType;
                } else {
                    if (produceList.contains(MimeType.Xml.value())) {
                        h_Accept = MimeType.Xml.value();
                    } else if (produceList.contains(MimeType.Json.value())) {
                        h_Accept = MimeType.Json.value();
                    }
                }
                if (h_Accept != null) {
                    XMLVector<String> xmlv = new XMLVector<String>();
                    xmlv.add("Accept");
                    xmlv.add(h_Accept);
                    httpParameters.add(xmlv);
                    if (h_Accept.equals(MimeType.Xml.value())) {
                        transaction = new XmlHttpTransaction();
                        ((XmlHttpTransaction) transaction).setXmlEncoding("UTF-8");
                    } else if (h_Accept.equals(MimeType.Json.value())) {
                        transaction = new JsonHttpTransaction();
                        ((JsonHttpTransaction) transaction).setIncludeDataType(false);
                    }
                }
                if (h_ContentType != null) {
                    XMLVector<String> xmlv = new XMLVector<String>();
                    xmlv.add(HeaderName.ContentType.value());
                    xmlv.add(h_ContentType);
                    httpParameters.add(xmlv);
                }
                String operationId = "";
                if (verb.has("operationId")) {
                    operationId = verb.getString("operationId");
                }
                String summary = "";
                if (verb.has("summary")) {
                    summary = verb.getString("summary");
                }
                String description = "";
                if (verb.has("description")) {
                    description = verb.getString("description");
                }
                String name = StringUtils.normalize(operationId);
                if (name.isEmpty()) {
                    name = StringUtils.normalize(summary);
                    if (name.isEmpty()) {
                        name = "operation";
                    }
                }
                String comment = summary;
                if (comment.isEmpty()) {
                    comment = description;
                }
                JSONArray parameters = new JSONArray();
                if (verb.has("parameters")) {
                    parameters = verb.getJSONArray("parameters");
                    for (int i = 0; i < parameters.length(); i++) {
                        JSONObject parameter = (JSONObject) parameters.get(i);
                        String type = "string";
                        if (parameter.has("collectionFormat")) {
                            type = parameter.getString("type");
                        }
                        String collectionFormat = "csv";
                        if (parameter.has("collectionFormat")) {
                            collectionFormat = parameter.getString("collectionFormat");
                        }
                        boolean isMultiValued = type.equalsIgnoreCase("array") && collectionFormat.equals("multi");
                        RequestableHttpVariable httpVariable = isMultiValued ? new RequestableHttpMultiValuedVariable() : new RequestableHttpVariable();
                        httpVariable.bNew = true;
                        httpVariable.setName(parameter.getString("name"));
                        httpVariable.setHttpName(parameter.getString("name"));
                        String in = parameter.getString("in");
                        if (in.equals("query") || in.equals("path") || in.equals("header")) {
                            httpVariable.setHttpMethod(HttpMethodType.GET.name());
                            if (in.equals("header")) {
                                // overrides variable's name : will be treated as dynamic header
                                httpVariable.setName(com.twinsoft.convertigo.engine.enums.Parameter.HttpHeader.getName() + parameter.getString("name"));
                                // do not post on target server
                                httpVariable.setHttpName("");
                            }
                        } else if (in.equals("formData") || in.equals("body")) {
                            httpVariable.setHttpMethod(HttpMethodType.POST.name());
                            if (in.equals("body")) {
                                // overrides variable's name for internal use
                                httpVariable.setName(com.twinsoft.convertigo.engine.enums.Parameter.HttpBody.getName());
                                // add internal __contentType variable
                                RequestableHttpVariable ct = new RequestableHttpVariable();
                                ct.setName(com.twinsoft.convertigo.engine.enums.Parameter.HttpContentType.getName());
                                // do not post on target server
                                ct.setHttpName("");
                                ct.setHttpMethod(HttpMethodType.POST.name());
                                ct.setValueOrNull(null);
                                ct.bNew = true;
                                transaction.addVariable(ct);
                                // 
                                if (parameter.has("schema")) {
                                // String schema = parameter.getString("schema");
                                }
                            }
                        } else {
                            httpVariable.setHttpMethod("");
                        }
                        Object defaultValue = null;
                        if (parameter.has("default")) {
                            defaultValue = parameter.get("default");
                        }
                        if (defaultValue == null && type.equalsIgnoreCase("array")) {
                            JSONObject items = parameter.getJSONObject("items");
                            if (items.has("default")) {
                                defaultValue = items.get("default");
                            }
                        }
                        httpVariable.setValueOrNull(defaultValue);
                        if (parameter.has("description")) {
                            httpVariable.setDescription(parameter.getString("description"));
                        }
                        transaction.addVariable(httpVariable);
                    }
                }
                transaction.bNew = true;
                transaction.setName(name);
                transaction.setComment(comment);
                transaction.setSubDir(subDir);
                transaction.setHttpVerb(HttpMethodType.valueOf(httpVerb.toUpperCase()));
                transaction.setHttpParameters(httpParameters);
                transaction.setHttpInfo(true);
                httpConnector.add(transaction);
            }
        }
        return httpConnector;
    } catch (Throwable t) {
        System.out.println(t);
        throw new Exception("Invalid Swagger format", t);
    }
}
Also used : XmlHttpTransaction(com.twinsoft.convertigo.beans.transactions.XmlHttpTransaction) HttpTransaction(com.twinsoft.convertigo.beans.transactions.HttpTransaction) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) JsonHttpTransaction(com.twinsoft.convertigo.beans.transactions.JsonHttpTransaction) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) HashMap(java.util.HashMap) XmlHttpTransaction(com.twinsoft.convertigo.beans.transactions.XmlHttpTransaction) JSONArray(org.codehaus.jettison.json.JSONArray) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) JSONObject(org.codehaus.jettison.json.JSONObject) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) JsonHttpTransaction(com.twinsoft.convertigo.beans.transactions.JsonHttpTransaction) JSONObject(org.codehaus.jettison.json.JSONObject)

Example 2 with RequestableHttpVariable

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

the class ChangeToSingleValuedVariableAction 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 multi = (Variable) databaseObject;
                    Variable simple = null;
                    if (databaseObject instanceof TestCaseMultiValuedVariable)
                        simple = new TestCaseVariable();
                    if (databaseObject instanceof StepMultiValuedVariable)
                        simple = new StepVariable();
                    if (databaseObject instanceof RequestableMultiValuedVariable)
                        simple = new RequestableVariable();
                    if (databaseObject instanceof RequestableHttpMultiValuedVariable)
                        simple = new RequestableHttpVariable();
                    if (databaseObject instanceof HttpStatementMultiValuedVariable)
                        simple = new HttpStatementVariable();
                    if (simple != null) {
                        if (multi instanceof StepMultiValuedVariable) {
                            ((StepVariable) simple).setSourceDefinition(((StepVariable) multi).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) simple).setXmlTypeAffectation(((RequestableVariable) multi).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) simple).setHttpName(((RequestableHttpVariable) multi).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) simple).setHttpMethod(((RequestableHttpVariable) multi).getHttpMethod());
                        }
                        XMLVector<Object> xmlv = GenericUtils.cast(multi.getValueOrNull());
                        Object value = (xmlv == null) ? null : (xmlv.isEmpty() ? "" : xmlv.get(0).toString());
                        simple.setValueOrNull(value);
                        simple.setVisibility(multi.getVisibility());
                        // Comment
                        simple.setComment(multi.getComment());
                        // Description
                        simple.setDescription(multi.getDescription());
                        // Required
                        simple.setRequired(multi.isRequired());
                        simple.bNew = true;
                        simple.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = multi.getParent();
                        parentDbo.add(simple);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(simple, multi.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, simple);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        multi.delete();
                        // Set correct name
                        simple.setName(multi.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(simple));
                    }
                }
            }
        }
    } 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 3 with RequestableHttpVariable

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

the class TransactionTreeObject method treeObjectPropertyChanged.

@Override
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
    super.treeObjectPropertyChanged(treeObjectEvent);
    String propertyName = (String) treeObjectEvent.propertyName;
    propertyName = ((propertyName == null) ? "" : propertyName);
    TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
        // If a bean name has changed
        if ("name".equals(propertyName)) {
            handlesBeanNameChanged(treeObjectEvent);
        } else if ("sqlQuery".equals(propertyName)) {
            if (treeObject.equals(this)) {
                try {
                    SqlTransaction sqlTransaction = (SqlTransaction) databaseObject;
                    sqlTransaction.initializeQueries(true);
                    String oldValue = (String) treeObjectEvent.oldValue;
                    detectVariables(sqlTransaction.getSqlQuery(), oldValue, sqlTransaction.getVariablesList());
                    ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
                } catch (Exception e) {
                    ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
                }
            }
        } else if ("subDir".equals(propertyName)) {
            if (treeObject.equals(this)) {
                try {
                    Object oldValue = treeObjectEvent.oldValue;
                    Object newValue = treeObjectEvent.newValue;
                    AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) databaseObject;
                    List<String> oldPathVariableList = AbstractHttpTransaction.getPathVariableList(oldValue.toString());
                    List<String> newPathVariableList = AbstractHttpTransaction.getPathVariableList(newValue.toString());
                    // Check for variables to be renamed
                    if (oldValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}").equals(newValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}"))) {
                        for (int i = 0; i < oldPathVariableList.size(); i++) {
                            String oldVariableName = oldPathVariableList.get(i);
                            String newVariableName = newPathVariableList.get(i);
                            if (!oldVariableName.equals(newVariableName)) {
                                RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(oldVariableName);
                                if (httpVariable != null) {
                                    try {
                                        VariableTreeObject2 vto = (VariableTreeObject2) findTreeObjectByUserObject(httpVariable);
                                        int update = TreeObjectEvent.UPDATE_NONE;
                                        CustomDialog customDialog = new CustomDialog(viewer.getControl().getShell(), "Update object references", "Do you want to update " + "variable" + " references ?\n You can replace '" + oldVariableName + "' by '" + newVariableName + "' in all loaded projects \n or replace '" + oldVariableName + "' by '" + newVariableName + "' 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) {
                                            update = TreeObjectEvent.UPDATE_ALL;
                                        }
                                        if (response == 1) {
                                            update = TreeObjectEvent.UPDATE_LOCAL;
                                        }
                                        if (update != 0) {
                                            httpVariable.setName(newVariableName);
                                            httpVariable.hasChanged = true;
                                            TreeObjectEvent toEvent = new TreeObjectEvent(vto, "name", oldVariableName, newVariableName, update);
                                            ConvertigoPlugin.getDefault().getProjectExplorerView().fireTreeObjectPropertyChanged(toEvent);
                                        }
                                    } catch (Exception e) {
                                        ConvertigoPlugin.logWarning(e, "Could not rename variable for Transaction \"" + databaseObject.getName() + "\" !");
                                    }
                                }
                            }
                        }
                    } else {
                        // Check for variables to be added
                        for (String variableName : newPathVariableList) {
                            if (httpTransaction.getVariable(variableName) == null) {
                                RequestableHttpVariable httpVariable = new RequestableHttpVariable();
                                httpVariable.setName(variableName);
                                httpVariable.setHttpMethod("GET");
                                httpVariable.setHttpName("");
                                httpVariable.bNew = true;
                                httpVariable.hasChanged = true;
                                httpTransaction.addVariable(httpVariable);
                                httpTransaction.hasChanged = true;
                            }
                        }
                        // Check for variables to be deleted
                        for (String variableName : oldPathVariableList) {
                            RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(variableName);
                            if (httpVariable != null) {
                                if (!newPathVariableList.contains(variableName)) {
                                    try {
                                        MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                                        messageBox.setMessage("Do you want to delete the variable \"" + variableName + "\"?");
                                        messageBox.setText("Delete \"" + variableName + "\"?");
                                        if (messageBox.open() == SWT.YES) {
                                            httpVariable.delete();
                                            httpTransaction.hasChanged = true;
                                        }
                                    } catch (EngineException e) {
                                        ConvertigoPlugin.logException(e, "Error when deleting the variable \"" + variableName + "\"");
                                    }
                                }
                            }
                        }
                    }
                    if (httpTransaction.hasChanged) {
                        ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
                    }
                } catch (Exception e) {
                    ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
                }
            }
        }
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) PartInitException(org.eclipse.ui.PartInitException) EngineException(com.twinsoft.convertigo.engine.EngineException) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) MessageBox(org.eclipse.swt.widgets.MessageBox) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)

Example 4 with RequestableHttpVariable

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

the class AbstractHttpTransaction 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++) {
            RequestableHttpVariable variable = (RequestableHttpVariable) 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());
            v.add(variable.getHttpMethod());
            v.add(variable.getHttpName());
            xmlv.add(v);
        }
    }
    return xmlv;
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 5 with RequestableHttpVariable

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

the class WsReference method createHttpVariable.

private static RequestableHttpVariable createHttpVariable(boolean multi, String variableName, QName schemaTypeName) throws EngineException {
    RequestableHttpVariable httpVariable = (multi ? new RequestableHttpMultiValuedVariable() : new RequestableHttpVariable());
    httpVariable.setName(variableName);
    httpVariable.setDescription(variableName);
    httpVariable.setWsdl(Boolean.TRUE);
    httpVariable.setPersonalizable(Boolean.FALSE);
    httpVariable.setCachedKey(Boolean.TRUE);
    httpVariable.setHttpMethod("POST");
    httpVariable.setHttpName(variableName.toUpperCase());
    httpVariable.setXmlTypeAffectation(new XmlQName(schemaTypeName));
    httpVariable.bNew = true;
    return httpVariable;
}
Also used : XmlQName(com.twinsoft.convertigo.beans.common.XmlQName) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable)

Aggregations

RequestableHttpVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpVariable)17 RequestableHttpMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable)8 AbstractHttpTransaction (com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction)7 EngineException (com.twinsoft.convertigo.engine.EngineException)6 IOException (java.io.IOException)6 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)5 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)5 HTTPStatement (com.twinsoft.convertigo.beans.statements.HTTPStatement)4 XmlHttpTransaction (com.twinsoft.convertigo.beans.transactions.XmlHttpTransaction)4 HttpStatementVariable (com.twinsoft.convertigo.beans.variables.HttpStatementVariable)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 XmlQName (com.twinsoft.convertigo.beans.common.XmlQName)3 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)3 TestCase (com.twinsoft.convertigo.beans.core.TestCase)3 HttpStatementMultiValuedVariable (com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable)3 RequestableMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)3 StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)3 HttpMethodType (com.twinsoft.convertigo.engine.enums.HttpMethodType)3 File (java.io.File)3