Search in sources :

Example 56 with RequestableVariable

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

the class Connector method setupConnector.

public static void setupConnector(DatabaseObject connector) throws EngineException {
    if (connector instanceof JavelinConnector) {
        JavelinConnector javelinConnector = (JavelinConnector) connector;
        JavelinScreenClass defaultScreenClass = new JavelinScreenClass();
        defaultScreenClass.setName("Default_screen_class");
        defaultScreenClass.hasChanged = true;
        defaultScreenClass.bNew = true;
        javelinConnector.setDefaultScreenClass(defaultScreenClass);
        DefaultBlockFactory blockFactory = new DefaultBlockFactory();
        blockFactory.setName("Block_factory");
        blockFactory.hasChanged = true;
        blockFactory.bNew = true;
        defaultScreenClass.setBlockFactory(blockFactory);
        EmulatorTechnology emulatorTechnology = new EmulatorTechnology();
        emulatorTechnology.hasChanged = true;
        emulatorTechnology.bNew = true;
        emulatorTechnology.setName("Emulator_technology");
        defaultScreenClass.add(emulatorTechnology);
        JavelinTransaction transaction = new JavelinTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("XMLize");
        javelinConnector.add(transaction);
        javelinConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof HtmlConnector) {
        HtmlConnector htmlConnector = (HtmlConnector) connector;
        htmlConnector.setServer("www.convertigo.com");
        HtmlScreenClass defaultScreenClass = new HtmlScreenClass();
        defaultScreenClass.setName("Default_screen_class");
        defaultScreenClass.hasChanged = true;
        defaultScreenClass.bNew = true;
        htmlConnector.setDefaultScreenClass(defaultScreenClass);
        HtmlTransaction transaction = new HtmlTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("XMLize");
        htmlConnector.add(transaction);
        htmlConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof HttpConnector) {
        HttpConnector httpConnector = (HttpConnector) connector;
        HttpTransaction transaction = new HttpTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("Default_transaction");
        httpConnector.add(transaction);
        httpConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof SapJcoConnector) {
        SapJcoConnector sapConnector = (SapJcoConnector) connector;
        SapJcoLogonTransaction sapLogon = new SapJcoLogonTransaction();
        sapLogon.hasChanged = true;
        sapLogon.bNew = true;
        sapLogon.setName("Logon");
        sapLogon.addCredentialsVariables();
        sapConnector.add(sapLogon);
        sapConnector.setDefaultTransaction(sapLogon);
        SapJcoTransaction transaction = new SapJcoTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("RFC_FUNCTION_SEARCH");
        transaction.setBapiName("RFC_FUNCTION_SEARCH");
        RequestableVariable variable = new RequestableVariable();
        variable.hasChanged = true;
        variable.bNew = true;
        variable.setName("FUNCNAME");
        variable.setValueOrNull("BAPI_*");
        transaction.add(variable);
        sapConnector.add(transaction);
    } else if (connector instanceof SqlConnector) {
        SqlConnector sqlConnector = (SqlConnector) connector;
        sqlConnector.setJdbcDriverClassName("org.hsqldb.jdbcDriver");
        SqlTransaction transaction = new SqlTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("Default_transaction");
        sqlConnector.add(transaction);
        sqlConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof CicsConnector) {
        CicsConnector cicsConnector = (CicsConnector) connector;
        CicsTransaction transaction = new CicsTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("Default_transaction");
        cicsConnector.add(transaction);
        cicsConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof SiteClipperConnector) {
        SiteClipperConnector siteClipperConnector = (SiteClipperConnector) connector;
        SiteClipperScreenClass defaultScreenClass = new SiteClipperScreenClass();
        defaultScreenClass.setName("Default_screen_class");
        defaultScreenClass.hasChanged = true;
        defaultScreenClass.bNew = true;
        siteClipperConnector.setDefaultScreenClass(defaultScreenClass);
        SiteClipperTransaction transaction = new SiteClipperTransaction();
        transaction.hasChanged = true;
        transaction.bNew = true;
        transaction.setName("Default_transaction");
        siteClipperConnector.add(transaction);
        siteClipperConnector.setDefaultTransaction(transaction);
    } else if (connector instanceof CouchDbConnector) {
        CouchDbConnector couchDbConnector = (CouchDbConnector) connector;
        String couchDbXsdPath = AbstractCouchDbTransaction.COUCHDB_XSD_LOCATION;
        boolean existReference = false;
        for (Reference reference : couchDbConnector.getProject().getReferenceList()) {
            if (reference instanceof XsdSchemaReference) {
                String urlPath = ((XsdSchemaReference) reference).getUrlpath();
                if (urlPath.equals(couchDbXsdPath)) {
                    existReference = true;
                    break;
                }
            }
        }
        if (!existReference) {
            ImportXsdSchemaReference reference = new ImportXsdSchemaReference();
            reference.setName("CouchDb_schema");
            reference.setUrlpath(couchDbXsdPath);
            couchDbConnector.getProject().add(reference);
        }
        GetServerInfoTransaction transaction = new GetServerInfoTransaction();
        couchDbConnector.add(transaction);
        couchDbConnector.setDefaultTransaction(transaction);
    }
}
Also used : EmulatorTechnology(com.twinsoft.convertigo.beans.common.EmulatorTechnology) HttpTransaction(com.twinsoft.convertigo.beans.transactions.HttpTransaction) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) SapJcoLogonTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction) SiteClipperScreenClass(com.twinsoft.convertigo.beans.screenclasses.SiteClipperScreenClass) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) ImportXsdSchemaReference(com.twinsoft.convertigo.beans.references.ImportXsdSchemaReference) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) SapJcoTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoTransaction) XsdSchemaReference(com.twinsoft.convertigo.beans.references.XsdSchemaReference) ImportXsdSchemaReference(com.twinsoft.convertigo.beans.references.ImportXsdSchemaReference) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) SiteClipperTransaction(com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction) XsdSchemaReference(com.twinsoft.convertigo.beans.references.XsdSchemaReference) ImportXsdSchemaReference(com.twinsoft.convertigo.beans.references.ImportXsdSchemaReference) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) DefaultBlockFactory(com.twinsoft.convertigo.beans.common.DefaultBlockFactory) CicsTransaction(com.twinsoft.convertigo.beans.transactions.CicsTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) GetServerInfoTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.GetServerInfoTransaction) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SapJcoConnector(com.twinsoft.convertigo.beans.connectors.SapJcoConnector)

Example 57 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)

Aggregations

RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)57 EngineException (com.twinsoft.convertigo.engine.EngineException)24 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)14 Sequence (com.twinsoft.convertigo.beans.core.Sequence)11 Element (org.w3c.dom.Element)11 RequestableHttpVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpVariable)10 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)8 StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)7 TestCaseVariable (com.twinsoft.convertigo.beans.variables.TestCaseVariable)7 Variable (com.twinsoft.convertigo.beans.core.Variable)6 Shell (org.eclipse.swt.widgets.Shell)6 TransactionWithVariables (com.twinsoft.convertigo.beans.core.TransactionWithVariables)5 RequestableMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)5 Cursor (org.eclipse.swt.graphics.Cursor)5 Display (org.eclipse.swt.widgets.Display)5 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)4 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)4 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)4