use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.
the class GetTestPlatform method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element root = document.getDocumentElement();
String projectName = request.getParameter("projectName");
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
Element e_project = createDatabaseObjectElement(document, project);
Connector defaultConnector = project.getDefaultConnector();
e_project.setAttribute("defaultConnector", defaultConnector.getName());
e_project.setAttribute("defaultTransaction", defaultConnector.getDefaultTransaction().getName());
boolean bTpHiddenRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_HIDDEN);
boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
for (Connector connector : project.getConnectorsList()) {
Element e_connector = createDatabaseObjectElement(document, connector);
for (Transaction transaction : connector.getTransactionsList()) {
// WEB_ADMIN role is allowed to execute all requestables
if (transaction.isPublicAccessibility() || (transaction.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
e_connector.appendChild(createRequestableElement(document, transaction));
}
}
e_project.appendChild(e_connector);
}
for (Sequence sequence : project.getSequencesList()) {
// WEB_ADMIN role is allowed to execute all requestables
if (sequence.isPublicAccessibility() || (sequence.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
e_project.appendChild(createRequestableElement(document, sequence));
}
}
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null && (mobileApplication.getAccessibility() == Accessibility.Public || (mobileApplication.getAccessibility() == Accessibility.Hidden && bTpHiddenRole) || bTpPrivateRole)) {
Element e_mobileApplication = createDatabaseObjectElement(document, mobileApplication);
String applicationID = mobileApplication.getComputedApplicationId();
e_mobileApplication.setAttribute("applicationID", applicationID);
String endpoint = mobileApplication.getComputedEndpoint(request);
e_mobileApplication.setAttribute("endpoint", endpoint);
String version = mobileApplication.getComputedApplicationVersion();
e_mobileApplication.setAttribute("applicationVersion", version);
e_project.appendChild(e_mobileApplication);
for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
Element e_device = createDatabaseObjectElement(document, platform);
e_device.setAttribute("classname", platform.getClass().getSimpleName());
e_device.setAttribute("displayName", CachedIntrospector.getBeanInfo(platform.getClass()).getBeanDescriptor().getDisplayName());
e_device.setAttribute("packageType", platform.getPackageType());
e_device.setAttribute("revision", "computing...");
e_mobileApplication.appendChild(e_device);
}
try {
String mobileProjectName = mobileApplication.getComputedApplicationName();
e_mobileApplication.setAttribute("mobileProjectName", mobileProjectName);
} catch (Exception e) {
Engine.logAdmin.error("Failed to retrieve the application mobile name", e);
}
IApplicationComponent app = mobileApplication.getApplicationComponent();
String msg = app != null ? app.getUnbuiltMessage() : null;
if (msg != null) {
e_mobileApplication.setAttribute("unbuiltMessage", msg);
}
}
root.appendChild(e_project);
}
use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.
the class CacheManager method getDocument.
public Document getDocument(Requester requester, Context context) throws EngineException {
Document response = null;
CacheEntry cacheEntry;
String supervision = null;
if (context.isStubRequested) {
String stubFileName = null;
if (context.requestedObject instanceof Transaction) {
stubFileName = context.requestedObject.getProject().getDirPath() + "/stubs/" + context.requestedObject.getParent().getName() + "." + context.requestedObject.getName() + ".xml";
} else if (context.requestedObject instanceof Sequence) {
stubFileName = context.requestedObject.getProject().getDirPath() + "/stubs/" + context.requestedObject.getName() + ".xml";
}
try {
response = XMLUtils.parseDOM(stubFileName);
response.getDocumentElement().setAttribute("fromStub", "true");
} catch (Exception e) {
Engine.logCacheManager.error("Error while parsing " + stubFileName + " file");
throw new EngineException("Unable to load response from Stub", e);
}
} else {
context.requestedObject.parseInputDocument(context);
if (context.httpServletRequest != null) {
try {
supervision = context.httpServletRequest.getParameter(Parameter.Supervision.getName());
} catch (Exception e) {
Engine.logCacheManager.warn("Error while getting '" + Parameter.Supervision.getName() + "' parameter, probably in async job ?");
}
}
long expiryDate = context.requestedObject.getResponseExpiryDateInMillis();
// Cache not enabled
if (EnginePropertiesManager.getPropertyAsBoolean(PropertyName.DISABLE_CACHE)) {
Engine.logCacheManager.debug("Cache not enabled explicitly");
response = context.requestedObject.run(requester, context);
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
} else // Not cached transaction
if (expiryDate <= 0) {
Engine.logCacheManager.trace("The response is not cachable");
response = context.requestedObject.run(requester, context);
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
} else // Cached transaction
{
String requestString = context.requestedObject.getRequestString(context);
if (context.noCache) {
Engine.logCacheManager.debug("Ignoring cache for request: " + requestString);
try {
cacheEntry = (CacheEntry) getCacheEntry(requestString);
if (cacheEntry != null) {
removeStoredResponse(cacheEntry);
}
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("Unable to remove the stored response from the cache repository!", e);
}
} else {
Engine.logCacheManager.debug("Searched request string: " + requestString);
try {
cacheEntry = (CacheEntry) getCacheEntry(requestString);
} catch (Exception e) {
Engine.logCacheManager.error("Unable to find the cache entry!", e);
cacheEntry = null;
}
Engine.logCacheManager.debug("Found cache entry: " + cacheEntry);
if (cacheEntry != null) {
if (cacheEntryHasExpired(cacheEntry)) {
Engine.logCacheManager.debug("Response [" + cacheEntry.toString() + "] has expired! Removing the current response and requesting a new response...");
try {
removeStoredResponse(cacheEntry);
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("Unable to remove the stored response from the cache repository!", e);
}
} else if ((cacheEntry.sheetUrl == null) && (context.isXsltRequest) && (context.requestedObject.getSheetLocation() == Transaction.SHEET_LOCATION_FROM_LAST_DETECTED_OBJECT_OF_REQUESTABLE)) {
Engine.logCacheManager.debug("Ignoring cache for request: " + requestString + " because a XSLT procees has been required and no sheet information has been stored into the cache entry.");
try {
removeStoredResponse(cacheEntry);
cacheEntry = null;
} catch (Exception e) {
Engine.logCacheManager.error("(CacheManager) Unable to remove the stored response from the cache repository!", e);
}
} else {
context.cacheEntry = cacheEntry;
// Update the statistics events
context.requestedObject.setStatisticsOfRequestFromCache();
String t = context.statistics.start(EngineStatistics.GENERATE_DOM);
try {
response = getStoredResponse(requester, cacheEntry);
if (response != null) {
response.getDocumentElement().setAttribute("fromcache", "true");
response.getDocumentElement().setAttribute("fromStub", "false");
ProcessingInstruction pi = response.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + context.requestedObject.getEncodingCharSet() + "\"");
response.insertBefore(pi, response.getFirstChild());
// response has been overridden - needed by billings!
context.outputDocument = response;
if (context.requestedObject != null) {
context.requestedObject.onCachedResponse();
}
} else {
Engine.logCacheManager.debug("Response from cache is null: removing the cache entry.");
removeStoredResponse(cacheEntry);
}
} catch (Exception e) {
Engine.logCacheManager.error("Unable to get the stored response from the cache repository!", e);
response = null;
} finally {
context.statistics.stop(t);
}
}
}
}
if (response == null) {
response = context.requestedObject.run(requester, context);
if (Engine.logCacheManager.isTraceEnabled())
Engine.logCacheManager.trace("Cache manager: document returned:\n" + XMLUtils.prettyPrintDOM(response));
response.getDocumentElement().setAttribute("fromcache", "false");
response.getDocumentElement().setAttribute("fromStub", "false");
// disabled the cache feature...
if (supervision != null) {
Engine.logCacheManager.debug("Supervision mode => disable caching");
context.isCacheEnabled = false;
}
if (context.isCacheEnabled) {
try {
response.getDocumentElement().setAttribute("expires", new Date(expiryDate).toString());
cacheEntry = storeResponse(response, requestString, expiryDate);
context.cacheEntry = cacheEntry;
Engine.logCacheManager.info("The expiration Date " + new Date(expiryDate).toString());
} catch (Exception e) {
Engine.logCacheManager.error("(CacheManager) Unable to store the response into the cache repository!", e);
}
} else {
Engine.logCacheManager.debug("Cache has been disabled!");
}
}
}
}
if (context.removeNamespaces) {
try {
Engine.logEngine.debug("Removing namespaces...");
response = XMLUtils.copyDocumentWithoutNamespace(response);
if (Engine.logEngine.isDebugEnabled()) {
String result = XMLUtils.prettyPrintDOM(response);
Engine.logEngine.debug("Namespaces removed:\n" + result);
}
} catch (ParserConfigurationException e) {
Engine.logCacheManager.error("(CacheManager) Failed to remove namespaces!", e);
}
}
if ("true".equals(response.getDocumentElement().getAttribute("fromcache")) && context.parentContext == null) {
HttpUtils.terminateNewSession(context.httpSession);
}
return response;
}
use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.
the class GenericRequester method createDOM.
@Override
public synchronized org.w3c.dom.Document createDOM(String encodingCharSet) throws EngineException {
boolean bLog = !(context.requestedObject instanceof Sequence);
if (bLog)
Engine.logContext.trace("[" + getName() + "] creating DOM");
Document document = XMLUtils.getDefaultDocumentBuilder().newDocument();
if (bLog)
Engine.logContext.trace("XML class: " + document.getClass().getName());
ProcessingInstruction pi = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + encodingCharSet + "\"");
document.appendChild(pi);
return document;
}
use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.
the class JavelinMashupEventEditorComposite method fillRequestableCombo.
private void fillRequestableCombo() {
if (project != null) {
int index = -1;
req_combo.removeAll();
if (getComboConnectorName().equals(""))
req_combo.add("");
if (btnTransaction.getSelection()) {
try {
Connector connector = project.getConnectorByName(getComboConnectorName());
for (Transaction transaction : connector.getTransactionsList()) req_combo.add(transaction.getName());
if (jsonTransactionName != null)
index = req_combo.indexOf(jsonTransactionName);
} catch (EngineException e) {
}
}
if (btnSequence.getSelection()) {
for (Sequence sequence : project.getSequencesList()) req_combo.add(sequence.getName());
if (jsonSequenceName != null)
index = req_combo.indexOf(jsonSequenceName);
}
req_combo.select(index >= 0 ? index : 0);
}
}
use of com.twinsoft.convertigo.beans.core.Sequence 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;
}
Aggregations