use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class ClipboardManager method cutAndPaste.
public void cutAndPaste(final DatabaseObject object, DatabaseObject parentDatabaseObject) throws ConvertigoException {
// Verifying if a sheet with the same browser does not already exist
if (object instanceof Sheet) {
String browser = ((Sheet) object).getBrowser();
Sheet sheet = null;
if (parentDatabaseObject instanceof ScreenClass) {
sheet = ((ScreenClass) parentDatabaseObject).getLocalSheet(browser);
} else if (parentDatabaseObject instanceof RequestableObject) {
sheet = ((RequestableObject) parentDatabaseObject).getSheet(browser);
}
if (sheet != null) {
throw new EngineException("You cannot cut and paste the sheet because a sheet is already defined for the browser \"" + browser + "\" in the screen class \"" + parentDatabaseObject.getName() + "\".");
}
}
if (object instanceof Step) {
if (object instanceof ThenStep) {
throw new EngineException("You cannot cut the \"Then\" step");
}
if (object instanceof ElseStep) {
throw new EngineException("You cannot cut the \"Else\" step");
}
}
if (object instanceof Statement) {
if (object instanceof ThenStatement)
throw new EngineException("You cannot cut the \"Then\" statement");
if (object instanceof ElseStatement)
throw new EngineException("You cannot cut the \"Else\" statement");
}
// Verify object is accepted for paste
if (!DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
String tplVersion = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getTplRequired(object);
throw new EngineException("Template project " + tplVersion + " compatibility required");
}
} else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
String tplVersion = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getTplRequired(object);
throw new EngineException("Template project " + tplVersion + " compatibility required");
}
}
// Verify if a child object with same name exist
boolean bContinue = true;
boolean bIncName = false;
String dboName = object.getName();
while (bContinue) {
try {
if (bIncName) {
dboName = DatabaseObject.incrementName(dboName);
object.setName(dboName);
}
new WalkHelper() {
boolean root = true;
boolean find = false;
@Override
protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
boolean isInstance = dboClass.isInstance(object);
find |= isInstance;
return isInstance;
}
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (root) {
root = false;
if (databaseObject instanceof Project) {
if (object instanceof Connector && ((Connector) object).isDefault) {
throw new EngineException("You cannot cut the default connector to another project");
}
} else if (databaseObject instanceof Connector) {
if (object instanceof ScreenClass) {
throw new EngineException("You cannot cut the default screen class to another connector");
} else if (object instanceof Transaction && ((Transaction) object).isDefault) {
throw new EngineException("You cannot cut the default transaction to another connector");
}
} else if (databaseObject instanceof ScreenClass) {
if (object instanceof Criteria && databaseObject.getParent() instanceof Connector) {
throw new EngineException("You cannot cut the criterion of default screen class");
}
} else if (databaseObject instanceof MobileObject) {
if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
if (object instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
com.twinsoft.convertigo.beans.mobile.components.PageComponent pc = GenericUtils.cast(object);
if (pc.isRoot) {
throw new EngineException("You cannot cut the root page to another application");
}
}
} else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
if (object instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
com.twinsoft.convertigo.beans.ngx.components.PageComponent pc = GenericUtils.cast(object);
if (pc.isRoot) {
throw new EngineException("You cannot cut the root page to another application");
}
}
}
}
super.walk(databaseObject);
if (!find) {
throw new EngineException("You cannot cut and paste to a " + databaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
} else {
if (object != databaseObject && object.getName().equalsIgnoreCase(databaseObject.getName())) {
throw new ObjectWithSameNameException("Unable to cut the object because an object with the same name already exists in target.");
}
}
}
}.init(parentDatabaseObject);
bContinue = false;
} catch (ObjectWithSameNameException e) {
bIncName = true;
} catch (EngineException e) {
throw e;
} catch (Exception e) {
throw new EngineException("Exception in cutAndPaste", e);
}
}
move(object, parentDatabaseObject);
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class HtmlConnector method prepareForHTTPStatement.
public void prepareForHTTPStatement(Context context) throws EngineException {
Engine.logBeans.debug("(HtmlConnector) Preparing for http statement");
// Retrieve current executing transaction
HtmlTransaction htmlTransaction = getCurrentHtmlTransaction(context);
if ((htmlTransaction == null) || (!htmlTransaction.runningThread.bContinue)) {
return;
}
// Retrieve current statement : the statement being executed
Statement statement = htmlTransaction.currentStatement;
if (statement == null) {
return;
}
if (!(statement instanceof HTTPStatement)) {
return;
}
HTTPStatement httpStatement = (HTTPStatement) statement;
handleCookie = httpStatement.isHandleCookie();
httpParameters = httpStatement.getHttpParameters();
sUrl = httpStatement.getUrl(isHttps(), getServer(), getPort());
Engine.logBeans.debug("(HtmlConnector) URL: " + sUrl);
// Parse input document for HTTPStatement variables
httpStatement.parseInputDocument(context);
// Getting all input variables marked as GET
Engine.logBeans.trace("(HtmlConnector) Loading all GET input variables");
String queryString = httpStatement.getQueryString(context);
if (Engine.logBeans.isDebugEnabled())
Engine.logBeans.debug("(HtmlConnector) GET query: " + Visibility.Logs.replaceVariables(httpStatement.getVariables(), queryString));
// Encodes URL if it contains special characters
sUrl = URLUtils.encodeAbsoluteURL(sUrl, htmlTransaction.getComputedUrlEncodingCharset());
if (queryString.length() != 0) {
sUrl += (sUrl.indexOf('?') == -1 ? "?" : "&") + queryString;
}
// Posting all input variables marked as POST
Engine.logBeans.trace("(HtmlConnector) Loading all POST input variables");
postQuery = httpStatement.getPostQuery(context);
if (Engine.logBeans.isDebugEnabled()) {
Engine.logBeans.debug("(HtmlConnector) POST query: " + Visibility.Logs.replaceVariables(httpStatement.getVariables(), postQuery));
}
// Setup the SSL properties if needed
if (isHttps() || httpStatement.isHttps()) {
Engine.logBeans.debug("(HtmlConnector) Setting up SSL properties");
certificateManager.collectStoreInformation(context);
}
Engine.logBeans.debug("(HtmlConnector) Connector successfully prepared for statement");
}
use of com.twinsoft.convertigo.beans.core.Statement 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;
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class ProjectUtils method getStatByProject.
public static Map<String, String> getStatByProject(Project project) throws Exception {
final Map<String, String> result = new HashMap<String, String>();
try {
if (project != null) {
try {
new WalkHelper() {
String displayString = "";
@SuppressWarnings("unused")
int depth = 0;
int sequenceJavascriptLines;
int sequenceJavascriptFunction;
int connectorCount = 0;
int httpConnectorCount = 0;
int httpsConnectorCount = 0;
int htmlConnectorCount = 0;
int cicsConnectorCount = 0;
int siteClipperConnectorCount = 0;
int sqlConnectorCount = 0;
int javelinConnectorCount = 0;
int htmlScreenclassCount = 0;
int htmlCriteriaCount = 0;
int siteClipperScreenclassCount = 0;
int siteClipperCriteriaCount = 0;
int htmlExtractionRuleCount = 0;
int htmlTransactionVariableCount = 0;
int sqlTransactionVariableCount = 0;
int javelinTransactionVariableCount = 0;
int javelinScreenclassCount = 0;
int javelinCriteriaCount = 0;
int javelinExtractionRuleCount = 0;
int javelinEntryHandlerCount = 0;
int javelinExitHandlerCount = 0;
int javelinHandlerCount = 0;
int javelinJavascriptLines = 0;
int statementCount = 0;
int poolCount = 0;
int handlerstatementCount = 0;
@SuppressWarnings("unused")
int reqVariableCount = 0;
int sequenceVariableCount = 0;
@SuppressWarnings("unused")
int transactionVariableCount = 0;
int testcaseVariableCount = 0;
int testcaseCount = 0;
int sequenceCount = 0;
int stepCount = 0;
int sheetCount = 0;
int referenceCount = 0;
int selectInQueryCount = 0;
/*
* transaction counters
*/
@SuppressWarnings("unused")
int transactionCount = 0;
@SuppressWarnings("unused")
int transactionWithVariablesCount = 0;
int htmltransactionCount = 0;
int httpTransactionCount = 0;
int httpsTransactionCount = 0;
int xmlHttpTransactionCount = 0;
int xmlHttpsTransactionCount = 0;
int jsonHttpTransactionCount = 0;
int jsonHttpsTransactionCount = 0;
int proxyTransactionCount = 0;
int siteClipperTransactionCount = 0;
int javelinTransactionCount = 0;
int sqlTransactionCount = 0;
int totalC8oObjects = 0;
public void go(DatabaseObject project) {
try {
String projectName = project.getName();
init(project);
connectorCount = htmlConnectorCount + httpConnectorCount + httpsConnectorCount + cicsConnectorCount + siteClipperConnectorCount + sqlConnectorCount + javelinConnectorCount;
totalC8oObjects = 1 + // connectors
connectorCount + htmlScreenclassCount + htmlCriteriaCount + htmlExtractionRuleCount + htmlTransactionVariableCount + handlerstatementCount + statementCount + javelinScreenclassCount + javelinCriteriaCount + javelinExtractionRuleCount + javelinTransactionCount + javelinEntryHandlerCount + javelinExitHandlerCount + javelinHandlerCount + javelinTransactionVariableCount + sqlTransactionCount + sqlTransactionVariableCount + sheetCount + jsonHttpTransactionCount + jsonHttpsTransactionCount + xmlHttpTransactionCount + xmlHttpsTransactionCount + httpTransactionCount + httpsTransactionCount + proxyTransactionCount + siteClipperTransactionCount + siteClipperScreenclassCount + siteClipperCriteriaCount + sequenceCount + stepCount + sequenceVariableCount + sequenceJavascriptFunction + poolCount + referenceCount + testcaseCount + testcaseVariableCount;
displayString = // ok
totalC8oObjects + " object(s)<br/>" + connectorCount + // ok
" connector(s)";
result.put(projectName, displayString);
if (htmltransactionCount > 0) {
displayString = // ok
(htmlScreenclassCount > 0 ? " screenclassCount = " + htmlScreenclassCount + "<br/>" : "") + (htmlCriteriaCount > 0 ? " criteriaCount = " + htmlCriteriaCount + "<br/>" : "") + (htmlExtractionRuleCount > 0 ? " extractionRuleCount = " + htmlExtractionRuleCount + "<br/>" : "") + " transactionCount = " + htmltransactionCount + // ok
"<br/>" + (htmlTransactionVariableCount > 0 ? " transactionVariableCount = " + htmlTransactionVariableCount + "<br/>" : "") + " statementCount (handlers=" + handlerstatementCount + ", statements=" + statementCount + ", total=" + (int) (handlerstatementCount + statementCount) + ")";
result.put("HTML connector", displayString);
}
/*
* javelin connector
*/
if (javelinScreenclassCount > 0) {
displayString = // ok
" screenclassCount = " + javelinScreenclassCount + "<br/>" + (javelinCriteriaCount > 0 ? " criteriaCount = " + javelinCriteriaCount + "<br/>" : "") + (javelinExtractionRuleCount > 0 ? " extractionRuleCount = " + javelinExtractionRuleCount + "<br/>" : "") + // ok
(javelinTransactionCount > 0 ? " transactionCount = " + javelinTransactionCount + "<br/>" : "") + " handlerCount (Entry = " + javelinEntryHandlerCount + ", Exit = " + javelinExitHandlerCount + ", Screenclass = " + javelinHandlerCount + "), total = " + (int) (javelinEntryHandlerCount + javelinExitHandlerCount + javelinHandlerCount) + " in " + javelinJavascriptLines + " lines<br/>" + (javelinTransactionVariableCount > 0 ? " variableCount = " + javelinTransactionVariableCount : "");
result.put("Javelin connector", displayString);
}
/*
* SQL connector
*/
if (sqlTransactionCount > 0) {
displayString = // ok
" sqltransactionCount = " + sqlTransactionCount + "<br/>" + // ok
(selectInQueryCount > 0 ? " selectInQueryCount = " + selectInQueryCount + "<br/>" : "") + (sqlTransactionVariableCount > 0 ? " transactionVariableCount = " + sqlTransactionVariableCount : "");
if (sheetCount > 0) {
displayString += "<br/>Sheets<br/>" + " sheetCount = " + sheetCount;
}
result.put("SQL connector", displayString);
}
/*
* Http connector
*/
if (httpConnectorCount > 0) {
displayString = " connectorCount = " + httpConnectorCount + "<br/>";
}
if (jsonHttpTransactionCount > 0) {
displayString += // ok
" JSONTransactionCount = " + jsonHttpTransactionCount + "<br/>" + // ok
(xmlHttpTransactionCount > 0 ? " XmlTransactionCount = " + xmlHttpTransactionCount + "<br/>" : "") + (httpTransactionCount > 0 ? " HTTPtransactionCount = " + httpTransactionCount : "");
result.put("HTTP connector", displayString);
}
/*
* Https connector
*/
if (httpsConnectorCount > 0) {
displayString = " connectorCount = " + httpsConnectorCount + "<br/>" + // ok
(jsonHttpsTransactionCount > 0 ? " JSONTransactionCount = " + jsonHttpsTransactionCount + "<br/>" : "") + // ok
(xmlHttpsTransactionCount > 0 ? " XmlTransactionCount = " + xmlHttpsTransactionCount + "<br/>" : "") + // ok
(httpsTransactionCount > 0 ? " HTTPStransactionCount = " + httpsTransactionCount : "");
result.put("HTTPS connector", displayString);
}
/*
* Proxy connector
*/
if (proxyTransactionCount > 0) {
displayString = " TransactionCount = " + proxyTransactionCount;
result.put("Proxy connector", displayString);
}
/*
* Siteclipper connector
*/
if (siteClipperTransactionCount > 0) {
displayString = // ok
" TransactionCount = " + siteClipperTransactionCount + "<br/>" + // ok
(siteClipperScreenclassCount > 0 ? " screenclassCount = " + siteClipperScreenclassCount + "<br/>" : "") + (siteClipperCriteriaCount > 0 ? " criteriaCount = " + siteClipperCriteriaCount : "");
result.put("SiteClipper connector", displayString);
}
/*
* Sequencer
*/
if (sequenceCount > 0) {
displayString = // ok
" sequenceCount = " + sequenceCount + "<br/>" + // ok
(stepCount > 0 ? " stepCount = " + stepCount + "<br/>" : "") + (sequenceVariableCount > 0 ? " variableCount = " + sequenceVariableCount + "<br/>" : "") + " javascriptCode = " + sequenceJavascriptFunction + " functions in " + sequenceJavascriptLines + " lines" + ((boolean) (sequenceJavascriptFunction == 0) ? " (declarations or so)" : "");
result.put("Sequencer", displayString);
}
if (poolCount > 0) {
displayString = " poolCount = " + poolCount;
result.put("Pools", displayString);
}
if (referenceCount > 0) {
displayString = " referenceCount = " + referenceCount;
result.put("References", displayString);
}
if (testcaseCount > 0) {
displayString = " testcaseCount = " + testcaseCount + "<br/>" + (testcaseVariableCount > 0 ? " testcaseVariableCount = " + testcaseVariableCount : "");
result.put("Test cases", displayString);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
depth++;
// deal with connectors
if (databaseObject instanceof Connector) {
if (databaseObject instanceof HtmlConnector) {
htmlConnectorCount++;
} else if (databaseObject instanceof HttpConnector) {
if (((HttpConnector) databaseObject).isHttps())
httpsConnectorCount++;
else
httpConnectorCount++;
} else if (databaseObject instanceof CicsConnector) {
cicsConnectorCount++;
} else if (databaseObject instanceof SiteClipperConnector) {
siteClipperConnectorCount++;
} else if (databaseObject instanceof SqlConnector) {
sqlConnectorCount++;
} else if (databaseObject instanceof JavelinConnector) {
javelinConnectorCount++;
}
} else // deal with screenclasses
if (databaseObject instanceof ScreenClass) {
if (databaseObject instanceof JavelinScreenClass) {
// deal with javelinScreenClasses
javelinScreenclassCount++;
} else if (databaseObject instanceof SiteClipperScreenClass) {
// deal with siteClipperScreenClasses
siteClipperScreenclassCount++;
} else {
// deal with html ScreenClasses
htmlScreenclassCount++;
}
} else if (databaseObject instanceof Criteria) {
if (databaseObject.getParent() instanceof JavelinScreenClass) {
javelinCriteriaCount++;
} else if (databaseObject.getParent() instanceof SiteClipperScreenClass) {
siteClipperCriteriaCount++;
} else {
htmlCriteriaCount++;
}
} else if (databaseObject instanceof ExtractionRule) {
if (databaseObject.getParent() instanceof JavelinScreenClass) {
javelinExtractionRuleCount++;
} else {
htmlExtractionRuleCount++;
}
} else if (databaseObject instanceof Transaction) {
if (databaseObject instanceof TransactionWithVariables) {
if (databaseObject instanceof HtmlTransaction) {
htmltransactionCount++;
} else if (databaseObject instanceof JsonHttpTransaction) {
if (((HttpConnector) databaseObject.getParent()).isHttps())
jsonHttpsTransactionCount++;
else
jsonHttpTransactionCount++;
} else if (databaseObject instanceof HttpTransaction) {
if (((HttpConnector) databaseObject.getParent()).isHttps())
httpsTransactionCount++;
else
httpTransactionCount++;
} else if (databaseObject instanceof XmlHttpTransaction) {
if (((HttpConnector) databaseObject.getParent()).isHttps())
xmlHttpsTransactionCount++;
else
xmlHttpTransactionCount++;
} else if (databaseObject instanceof ProxyTransaction) {
proxyTransactionCount++;
} else if (databaseObject instanceof SiteClipperTransaction) {
siteClipperTransactionCount++;
} else if (databaseObject instanceof JavelinTransaction) {
JavelinTransaction javelinTransaction = (JavelinTransaction) databaseObject;
// Functions
String line;
int lineNumber = 0;
BufferedReader br = new BufferedReader(new StringReader(javelinTransaction.handlers));
while ((line = br.readLine()) != null) {
line = line.trim();
lineNumber++;
if (line.startsWith("function ")) {
try {
String functionName = line.substring(9, line.indexOf(')') + 1);
if (functionName.endsWith(JavelinTransaction.EVENT_ENTRY_HANDLER + "()")) {
// TYPE_FUNCTION_SCREEN_CLASS_ENTRY
javelinEntryHandlerCount++;
} else if (functionName.endsWith(JavelinTransaction.EVENT_EXIT_HANDLER + "()")) {
// TYPE_FUNCTION_SCREEN_CLASS_EXIT
javelinExitHandlerCount++;
} else {
// TYPE_OTHER
javelinHandlerCount++;
}
} catch (StringIndexOutOfBoundsException e) {
// Ignore
}
}
}
// compute total number of lines of javascript
javelinJavascriptLines += lineNumber;
javelinTransactionCount++;
} else if (databaseObject instanceof SqlTransaction) {
SqlTransaction sqlTransaction = (SqlTransaction) databaseObject;
/*
* count the number of SELECT
*/
String query = sqlTransaction.getSqlQuery();
if (query != null) {
query = query.toLowerCase();
String pattern = "select";
int lastIndex = 0;
while (lastIndex != -1) {
lastIndex = query.indexOf(pattern, lastIndex);
if (lastIndex != -1) {
selectInQueryCount++;
lastIndex += pattern.length();
}
}
}
sqlTransactionCount++;
}
transactionWithVariablesCount++;
} else {
// transaction with no variables
transactionCount++;
}
} else // deal with statements
if (databaseObject instanceof Statement) {
// System.out.println(databaseObject.getClass().getName() + "\r\n");
if (databaseObject instanceof HandlerStatement) {
handlerstatementCount++;
} else {
statementCount++;
}
} else // deal with variables
if (databaseObject instanceof Variable) {
if (databaseObject.getParent() instanceof Transaction) {
if (databaseObject.getParent() instanceof JavelinTransaction) {
javelinTransactionVariableCount++;
} else if (databaseObject.getParent() instanceof HtmlTransaction) {
htmlTransactionVariableCount++;
} else if (databaseObject.getParent() instanceof SqlTransaction) {
sqlTransactionVariableCount++;
} else {
// should be zero
transactionVariableCount++;
}
} else if (databaseObject.getParent() instanceof Sequence) {
sequenceVariableCount++;
} else if (databaseObject.getParent() instanceof TestCase) {
testcaseVariableCount++;
}
} else if (databaseObject instanceof TestCase) {
testcaseCount++;
} else if (databaseObject instanceof Sequence) {
sequenceCount++;
} else if (databaseObject instanceof Step) {
if (databaseObject instanceof SimpleStep) {
SimpleStep simpleStep = (SimpleStep) databaseObject;
// Functions
String line;
int lineNumber = 0;
BufferedReader br = new BufferedReader(new StringReader(simpleStep.getExpression()));
while ((line = br.readLine()) != null) {
line = line.trim();
lineNumber++;
if (line.startsWith("function ")) {
try {
sequenceJavascriptFunction++;
} catch (StringIndexOutOfBoundsException e) {
// Ignore
}
}
}
sequenceJavascriptLines += lineNumber;
stepCount++;
} else
stepCount++;
} else if (databaseObject instanceof Sheet) {
sheetCount++;
} else if (databaseObject instanceof Pool) {
poolCount++;
}
super.walk(databaseObject);
}
}.go(project);
} catch (Exception e) {
// Just ignore, should never happen
}
}
} catch (Throwable e) {
throw new Exception("Unable to compute statistics of the project!: \n" + e.getMessage());
} finally {
}
return result;
}
use of com.twinsoft.convertigo.beans.core.Statement in project convertigo by convertigo.
the class ReferencesView method handleConnectorSelection.
private void handleConnectorSelection(Object firstElement) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) firstElement;
Connector connectorSelected = connectorTreeObject.getObject();
String connectorSelectedName = connectorSelected.getName();
Project projectConnectorSelected = connectorSelected.getProject();
String connectorProjectName = connectorSelected.getProject().getName();
List<Transaction> transactions = connectorSelected.getTransactionsList();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
ConnectorNode connectorNode = null;
connectorNode = getConnectorNode(root, connectorSelected);
root.addChild(connectorNode);
IsUsedByNode isUsedByNode = new IsUsedByNode(connectorNode, "Is used by");
RequiresNode requiresNode = new RequiresNode(connectorNode, "Requires");
ProjectNode projectFolder = null;
// Search handlers are that referenced by the selected connector for continue with site Clipper
if (connectorSelected instanceof HtmlConnector) {
ProjectNode projectNode = new ProjectNode(requiresNode, connectorProjectName, projectConnectorSelected);
for (Transaction transaction : transactions) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
String siteClipperconnectorName = continueWithSiteClipperStatement.getSiteClipperConnectorName();
if (!siteClipperConnectorNames.contains(siteClipperconnectorName)) {
siteClipperConnectorNames.add(siteClipperconnectorName);
Connector siteClipperConnector = projectConnectorSelected.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connectorSelected instanceof SiteClipperConnector) {
List<Connector> connectors = projectConnectorSelected.getConnectorsList();
ProjectNode projectNode = new ProjectNode(isUsedByNode, connectorProjectName, projectConnectorSelected);
for (Connector connector : connectors) {
if (connector instanceof HtmlConnector) {
List<Transaction> transactionList = ((HtmlConnector) connector).getTransactionsList();
for (Transaction transaction : transactionList) {
List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
for (Statement statement : statements) {
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
String sourceSiteClipperConnectorName = ((ContinueWithSiteClipperStatement) st).getSiteClipperConnectorName();
if (sourceSiteClipperConnectorName.equals(connectorSelectedName)) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
HtmlConnectorNode htmlConnectorNode = new HtmlConnectorNode(projectNode, connector.getName(), connector);
projectNode.addChild(htmlConnectorNode);
TransactionNode transactionNode = new TransactionNode(htmlConnectorNode, transaction.getName(), continueWithSiteClipperStatement);
htmlConnectorNode.addChild(transactionNode);
}
}
}
}
}
}
}
if (projectNode.hasChildren()) {
isUsedByNode.addChild(projectNode);
}
}
// Searching all objects that are referenced by the selected connector
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, projectName, project);
UrlMapper urlMapper = project.getUrlMapper();
if (urlMapper != null) {
MapperNode mapperNode = new MapperNode(projectFolder, urlMapper.getName(), urlMapper);
List<UrlMapping> mappings = urlMapper.getMappingList();
for (UrlMapping mapping : mappings) {
MappingPathNode pathNode = new MappingPathNode(mapperNode, mapping.getPath(), mapping);
List<UrlMappingOperation> operations = mapping.getOperationList();
for (UrlMappingOperation operation : operations) {
String targetRequestable = operation.getTargetRequestable();
if (targetRequestable.startsWith(projectConnectorSelected + "." + connectorSelectedName + ".")) {
MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
pathNode.addChild(operationNode);
}
}
if (pathNode.hasChildren()) {
mapperNode.addChild(pathNode);
}
}
if (mapperNode.hasChildren()) {
projectFolder.addChild(mapperNode);
}
}
List<Sequence> sequences = project.getSequencesList();
for (Sequence sequence : sequences) {
List<Step> steps = sequence.getSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : steps) {
getConnectorReferencingIsUsedBy(step, projectExplorerView, sequenceNode, transactions, connectorProjectName, connectorSelectedName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
connectorNode.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
connectorNode.addChild(isUsedByNode);
}
if (!connectorNode.hasChildren()) {
connectorNode.addChild(new InformationNode(connectorNode, "This connector is not used by any other objects"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
Aggregations