use of com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction in project convertigo by convertigo.
the class NewObjectWizard method doFinish.
private void doFinish(IProgressMonitor monitor) throws CoreException {
String dboName, name;
boolean bContinue = true;
int index = 0;
try {
int total = 0;
Class<?> c = getCreatedBeanClass();
if (c != null) {
total = 4;
if (c.equals(WebServiceReference.class)) {
total += ImportWsReference.getTotalTaskNumber();
}
}
monitor.beginTask("Creating new object", total);
newBean = getCreatedBean();
if (newBean != null) {
monitor.setTaskName("Object created");
monitor.worked(1);
dboName = newBean.getName();
if (!StringUtils.isNormalized(dboName))
throw new EngineException("Bean name is not normalized : \"" + dboName + "\".");
// Verify if a child object with same name exist and change name
while (bContinue) {
if (index == 0)
name = dboName;
else
name = dboName + index;
newBean.setName(name);
newBean.hasChanged = true;
newBean.bNew = true;
try {
new WalkHelper() {
boolean root = true;
boolean find = false;
@Override
protected boolean before(DatabaseObject dbo, Class<? extends DatabaseObject> dboClass) {
boolean isInstance = dboClass.isInstance(newBean);
find |= isInstance;
return isInstance;
}
@Override
protected void walk(DatabaseObject dbo) throws Exception {
if (root) {
root = false;
super.walk(dbo);
if (!find) {
throw new EngineException("You cannot add to a " + newBean.getClass().getSimpleName() + " a database object of type " + parentObject.getClass().getSimpleName());
}
} else {
if (newBean.getName().equalsIgnoreCase(dbo.getName())) {
throw new ObjectWithSameNameException("Unable to add the object because an object with the same name already exists in target.");
}
}
}
}.init(parentObject);
bContinue = false;
} catch (ObjectWithSameNameException owsne) {
if ((parentObject instanceof HtmlTransaction) && (newBean instanceof Statement)) {
throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
}
// Silently ignore
index++;
} catch (EngineException ee) {
throw ee;
} catch (Exception e) {
throw new EngineException("Exception in create", e);
}
}
// Now add bean to target
try {
boolean hasChanged = parentObject.hasChanged;
if ((newBean instanceof Statement) && (parentObject instanceof Transaction)) {
newBean.priority = 0;
}
if (newBean instanceof ScreenClass)
newBean.priority = parentObject.priority + 1;
if (newBean instanceof Criteria) {
Connector connector = parentObject.getConnector();
if (parentObject.equals(((IScreenClassContainer<?>) connector).getDefaultScreenClass()))
throw new EngineException("You cannot add a new criterion on default screenclass.");
}
parentObject.add(newBean);
monitor.setTaskName("Object added");
monitor.worked(1);
if (newBean instanceof HTTPStatement) {
HTTPStatement httpStatement = (HTTPStatement) newBean;
HtmlConnector connector = (HtmlConnector) httpStatement.getParentTransaction().getParent();
httpStatement.setMethod("GET");
httpStatement.setHost(connector.getServer());
httpStatement.setPort(connector.getPort());
httpStatement.setHttps(connector.isHttps());
}
if (newBean instanceof ContinueWithSiteClipperStatement) {
Project project = newBean.getProject();
if (project != null) {
String[] connectorWithSiteClipperConnector = ContinueWithSiteClipperStatement.getSiteClippersConnectorNames(project);
if (connectorWithSiteClipperConnector.length > 0) {
((ContinueWithSiteClipperStatement) newBean).setSiteClipperConnectorName(connectorWithSiteClipperConnector[0]);
}
}
}
if (newBean instanceof Connector) {
Project project = (Project) parentObject;
if (project.getDefaultConnector() == null)
project.setDefaultConnector((Connector) newBean);
Connector.setupConnector(newBean);
}
if (newBean instanceof PageComponent) {
ApplicationComponent application = (ApplicationComponent) parentObject;
if (application.getRootPage() == null)
application.setRootPage((PageComponent) newBean);
}
if (newBean instanceof SequenceStep) {
Project project = newBean.getProject();
((SequenceStep) newBean).setSourceSequence(project.getName() + TransactionStep.SOURCE_SEPARATOR + project.getSequencesList().get(0));
}
if (newBean instanceof TransactionStep) {
Project project = newBean.getProject();
Connector connector = project.getDefaultConnector();
Transaction transaction = connector.getDefaultTransaction();
((TransactionStep) newBean).setSourceTransaction(project.getName() + TransactionStep.SOURCE_SEPARATOR + connector.getName() + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
}
if (newBean instanceof IThenElseContainer) {
ThenStep thenStep = new ThenStep();
((IThenElseContainer) newBean).addStep(thenStep);
ElseStep elseStep = new ElseStep();
((IThenElseContainer) newBean).addStep(elseStep);
}
if (newBean instanceof IThenElseStatementContainer) {
ThenStatement thenStatement = new ThenStatement();
((IThenElseStatementContainer) newBean).addStatement(thenStatement);
ElseStatement elseStatement = new ElseStatement();
((IThenElseStatementContainer) newBean).addStatement(elseStatement);
}
if (newBean instanceof Sheet) {
InputStream is = null;
try {
String sheetName = newBean.getName() + ".xsl";
is = new FileInputStream(new File(Engine.XSL_PATH + "/customsheet.xsl"));
String projectName = ((DatabaseObject) parentObject).getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
final IFile file = project.getFile(sheetName);
if (!file.exists())
file.create(is, true, null);
((Sheet) newBean).setUrl(sheetName);
} catch (Exception e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
}
if (newBean instanceof TestCase) {
TestCase testCase = (TestCase) newBean;
testCase.importRequestableVariables((RequestableObject) testCase.getParent());
}
if (newBean instanceof RequestableHttpVariable) {
RequestableHttpVariable variable = (RequestableHttpVariable) newBean;
AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) variable.getParent();
HttpMethodType httpMethodType = httpTransaction.getHttpVerb();
boolean isVarPost = httpMethodType.equals(HttpMethodType.PUT) || httpMethodType.equals(HttpMethodType.POST);
variable.setHttpMethod(isVarPost ? HttpMethodType.POST.name() : HttpMethodType.GET.name());
if (!(httpTransaction instanceof HtmlTransaction)) {
variable.setHttpName(variable.getName());
}
}
if (newBean instanceof WebServiceReference) {
try {
Project project = (Project) parentObject;
WebServiceReference webServiceReference = (WebServiceReference) newBean;
ImportWsReference wsr = new ImportWsReference(webServiceReference);
wsr.importInto(project);
} catch (Exception e) {
if (newBean != null) {
parentObject.remove(newBean);
parentObject.hasChanged = hasChanged;
}
throw new Exception(e);
}
}
if (newBean instanceof RestServiceReference) {
try {
Project project = (Project) parentObject;
RestServiceReference restServiceReference = (RestServiceReference) newBean;
ImportWsReference wsr = new ImportWsReference(restServiceReference);
wsr.importInto(project);
} catch (Exception e) {
if (newBean != null) {
parentObject.remove(newBean);
parentObject.hasChanged = hasChanged;
}
throw new Exception(e);
}
}
if (newBean instanceof SqlTransaction) {
SqlTransaction sqlTransaction = (SqlTransaction) newBean;
sqlTransaction.setSqlQuery(sqlQueriesWizardPage.getSQLQueries());
sqlTransaction.initializeQueries(true);
}
if (newBean instanceof SapJcoLogonTransaction) {
SapJcoLogonTransaction sapLogonTransaction = (SapJcoLogonTransaction) newBean;
sapLogonTransaction.addCredentialsVariables();
}
if (newBean instanceof AbstractCouchDbTransaction) {
AbstractCouchDbTransaction abstractCouchDbTransaction = (AbstractCouchDbTransaction) newBean;
List<CouchVariable> selectedVariables = objectInfoPage.getSelectedParameters();
abstractCouchDbTransaction.createVariables(selectedVariables);
}
ConvertigoPlugin.logInfo("New object class '" + this.className + "' named '" + newBean.getName() + "' has been added");
monitor.setTaskName("Object setted up");
monitor.worked(1);
bContinue = false;
} catch (com.twinsoft.convertigo.engine.ObjectWithSameNameException owsne) {
if (newBean instanceof HandlerStatement) {
throw owsne;
}
}
} else {
throw new Exception("Could not instantiate bean!");
}
} catch (Exception e) {
String message = "Unable to create a new object from class '" + this.className + "'.";
ConvertigoPlugin.logException(e, message);
if (objectExplorerPage != null) {
objectExplorerPage.doCancel();
}
}
}
use of com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction 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);
}
}
Aggregations