Search in sources :

Example 11 with HtmlScreenClass

use of com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass in project convertigo by convertigo.

the class HtmlTransaction method generateWsdlType.

/* (non-Javadoc)
	 * @see com.twinsoft.convertigo.beans.core.Transaction#generateWsdlType(org.w3c.dom.Document)
	 */
@Override
public String generateWsdlType(Document document) throws Exception {
    HtmlConnector connector = (HtmlConnector) getParent();
    String prefix = getXsdTypePrefix();
    // First regenerates wsdltype for default transaction : will contains all types!!
    if (!isDefault) {
        HtmlTransaction defaultTransaction = (HtmlTransaction) connector.getDefaultTransaction();
        defaultTransaction.generateWsdlType(document);
        defaultTransaction.hasChanged = true;
    }
    // Retrieve extraction rules schemas
    List<HtmlScreenClass> screenClasses = connector.getAllScreenClasses();
    Map<String, ScreenClass> ht = new HashMap<String, ScreenClass>(screenClasses.size());
    String normalizedScreenClassName;
    int i;
    for (ScreenClass screenClass : screenClasses) {
        normalizedScreenClassName = StringUtils.normalize(screenClass.getName());
        ht.put(normalizedScreenClassName, screenClass);
    }
    Map<String, String> names = new HashMap<String, String>();
    Map<String, String> types = new HashMap<String, String>();
    List<String> schemas = new LinkedList<String>();
    screenClass = connector.getDefaultScreenClass();
    if (screenClass != null) {
        addExtractionRuleShemas(names, types, schemas, screenClass);
    }
    // Retrieve statements schemas
    for (Statement statement : getStatements()) {
        addStatementSchemas(schemas, statement);
    }
    // Construct transaction schema
    String transactionName = StringUtils.normalize(prefix + getName(), true) + "Response";
    String schema = "<?xml version=\"1.0\" encoding=\"" + getEncodingCharSet() + "\" ?>\n";
    schema += "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n";
    String all, obSchema;
    all = "";
    for (i = 0; i < schemas.size(); i++) {
        obSchema = schemas.get(i);
        all += obSchema;
    }
    if (isDefault) {
        String group = "";
        String groupName = StringUtils.normalize(connector.getName(), true) + "Types";
        group += "<xsd:group name=\"" + groupName + "\">\n";
        group += "<xsd:sequence>\n";
        group += all;
        group += "</xsd:sequence>\n";
        group += "</xsd:group>\n";
        schema += "<xsd:complexType name=\"" + transactionName + "\">\n";
        schema += "<xsd:sequence>\n";
        schema += "<xsd:element minOccurs=\"0\" maxOccurs=\"1\" name=\"error\" type=\"p_ns:ConvertigoError\"/>\n";
        schema += "<xsd:group minOccurs=\"0\" maxOccurs=\"1\" ref=\"p_ns:" + groupName + "\"/>\n";
        schema += "</xsd:sequence>\n";
        schema += "</xsd:complexType>\n";
        schema += group;
        for (Enumeration<String> e = Collections.enumeration(types.keySet()); e.hasMoreElements(); ) {
            String typeSchema = (String) types.get(e.nextElement());
            schema += typeSchema;
        }
    } else {
        schema += "<xsd:complexType name=\"" + transactionName + "\">\n";
        schema += "<xsd:sequence>\n";
        schema += "<xsd:element minOccurs=\"0\" maxOccurs=\"1\" name=\"error\" type=\"p_ns:ConvertigoError\"/>\n";
        schema += all;
        schema += "</xsd:sequence>\n";
        schema += "</xsd:complexType>\n";
    }
    schema += "</xsd:schema>\n";
    String prettyPrintedText = XMLUtils.prettyPrintDOM(schema);
    int index = prettyPrintedText.indexOf("<xsd:schema") + "<xsd:schema".length();
    index = prettyPrintedText.indexOf('\n', index);
    prettyPrintedText = prettyPrintedText.substring(index + 1);
    prettyPrintedText = prettyPrintedText.substring(0, prettyPrintedText.indexOf("</xsd:schema>"));
    // prettyPrintedText = removeTab(prettyPrintedText);
    return prettyPrintedText;
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) HashMap(java.util.HashMap) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) ContextAddTextNodeStatement(com.twinsoft.convertigo.beans.statements.ContextAddTextNodeStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) LinkedList(java.util.LinkedList) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)

Example 12 with HtmlScreenClass

use of com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass in project convertigo by convertigo.

the class TreeDropAdapter method createHtmlScreenClass.

private HtmlScreenClass createHtmlScreenClass(long priority) throws EngineException {
    HtmlScreenClass htmlSc = new HtmlScreenClass();
    htmlSc.priority = priority;
    htmlSc.hasChanged = true;
    htmlSc.bNew = true;
    return htmlSc;
}
Also used : HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)

Example 13 with HtmlScreenClass

use of com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass 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)

Aggregations

HtmlScreenClass (com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)13 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)5 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)5 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)4 NewObjectWizard (com.twinsoft.convertigo.eclipse.wizards.new_object.NewObjectWizard)4 EngineException (com.twinsoft.convertigo.engine.EngineException)4 ObjectWithSameNameException (com.twinsoft.convertigo.engine.ObjectWithSameNameException)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 HtmlExtractionRule (com.twinsoft.convertigo.beans.extractionrules.HtmlExtractionRule)2 HTTPStatement (com.twinsoft.convertigo.beans.statements.HTTPStatement)2 HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)2 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)2 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)2 EngineEvent (com.twinsoft.convertigo.engine.EngineEvent)2 IOException (java.io.IOException)2 DefaultBlockFactory (com.twinsoft.convertigo.beans.common.DefaultBlockFactory)1 EmulatorTechnology (com.twinsoft.convertigo.beans.common.EmulatorTechnology)1 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)1 XPath (com.twinsoft.convertigo.beans.common.XPath)1