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);
}
}
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;
}
Aggregations