use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.
the class ReferencesView method handleTransactionSelection.
private void handleTransactionSelection(Object firstElement) {
TransactionTreeObject transactionTreeObject = (TransactionTreeObject) firstElement;
Transaction transaction = transactionTreeObject.getObject();
String transactionName = transactionTreeObject.getName();
// Get the referencing sequence steps
String transactionProjectName = transaction.getProject().getName();
String transactionConnectorName = transaction.getParent().getName();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
TransactionNode transactionFolder = new TransactionNode(root, transactionName, transaction);
root.addChild(transactionFolder);
IsUsedByNode isUsedByNode = new IsUsedByNode(transactionFolder, "Is used by");
RequiresNode requiresNode = new RequiresNode(transactionFolder, "Requires");
ProjectNode projectFolder = null;
// Searching all objects are required transaction selected
Connector connector = transaction.getConnector();
if (connector instanceof HtmlConnector) {
Project proj = ((HtmlConnector) connector).getProject();
ProjectNode projectNode = new ProjectNode(requiresNode, transactionProjectName, proj);
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
List<Statement> statements = htmlTransaction.getStatements();
List<ScreenClass> screenClassList = new ArrayList<ScreenClass>();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
String screenClassName = scHandlerStatement.getNormalizedScreenClassName();
ScreenClass screenClass = ((HtmlConnector) connector).getScreenClassByName(screenClassName);
if (screenClass != null) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClassName, screenClass));
}
}
}
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 = proj.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connector instanceof JavelinConnector) {
JavelinTransaction javelinTransaction = (JavelinTransaction) transaction;
String handlers = javelinTransaction.handlers;
List<JavelinScreenClass> screenClasses = ((JavelinConnector) connector).getAllScreenClasses();
List<JavelinScreenClass> screenClassList = new ArrayList<JavelinScreenClass>();
for (JavelinScreenClass screenClass : screenClasses) {
if (handlers.indexOf("function on" + screenClass.getName()) != -1) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClass.getName(), screenClass));
}
}
}
}
// Searching all objects are used transaction selected
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, project.getName(), 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.equals(transactionProjectName + "." + transactionConnectorName + "." + transactionName)) {
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> stepList = sequence.getAllSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : stepList) {
getTransactionReferencing(step, projectExplorerView, sequenceNode, transactionProjectName, transactionConnectorName, transactionName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
transactionFolder.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
transactionFolder.addChild(isUsedByNode);
}
if (!transactionFolder.hasChildren()) {
transactionFolder.addChild(new InformationNode(projectFolder, "This transaction is not used in any sequence"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.
the class StatementTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
Statement statement = getObject();
boolean change = false;
if (databaseObject instanceof ScreenClass) {
String oldScreenClassName = StringUtils.normalize((String) oldValue);
String newScreenClassName = StringUtils.normalize((String) newValue);
// ScreenClass and Statement must have the same connector!
if (statement.getConnector().equals(databaseObject.getConnector())) {
// Modify screenclass handlers name
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
if (scHandlerStatement.getNormalizedScreenClassName().equals(oldScreenClassName)) {
String handlerType = scHandlerStatement.getHandlerType();
String beanName = "on" + newScreenClassName + handlerType;
try {
scHandlerStatement.setName(beanName);
scHandlerStatement.setNormalizedScreenClassName(newScreenClassName);
change = true;
} catch (EngineException e) {
ConvertigoPlugin.logWarning(e, "Could not rename ScHandlerStatement from \"" + scHandlerStatement.getName() + "\" to \"" + beanName + "\" !");
}
}
}
if (statement instanceof ITriggerOwner) {
ITriggerOwner ito = (ITriggerOwner) statement;
AbstractTrigger atrigger = ito.getTrigger().getTrigger();
if (atrigger instanceof ScreenClassTrigger) {
ScreenClassTrigger sct = (ScreenClassTrigger) atrigger;
List<String> screenClasses = sct.getScreenClasses();
for (int i = 0; i < screenClasses.size(); i++) if (screenClasses.get(i).equals(oldScreenClassName) && (change = true))
screenClasses.set(i, newScreenClassName);
if (change)
ito.setTrigger(new TriggerXMLizer(sct));
}
}
}
} else // Case of connector rename
if (databaseObject instanceof SiteClipperConnector) {
if (statement instanceof ContinueWithSiteClipperStatement) {
boolean isLocalProject = statement.getProject().equals(databaseObject.getProject());
boolean isSameValue = ((ContinueWithSiteClipperStatement) statement).getSiteClipperConnectorName().equals(oldValue);
if (isSameValue && isLocalProject) {
((ContinueWithSiteClipperStatement) statement).setSiteClipperConnectorName((String) newValue);
hasBeenModified(true);
viewer.refresh();
// refresh editors (e.g labels in combobox)
getDescriptors();
}
}
}
if (statement instanceof CallFunctionStatement && databaseObject.getClass().equals(FunctionStatement.class) && ((FunctionStatement) databaseObject).getParentTransaction().equals(statement.getParentTransaction())) {
CallFunctionStatement callfunction = (CallFunctionStatement) statement;
if (callfunction.getFunctionName().equals(oldValue) && (change = true))
callfunction.setFunctionName(newValue.toString());
}
if (change)
try {
hasBeenModified(true);
ConvertigoPlugin.getDefault().getProjectExplorerView().refreshTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not refresh in tree ScHandlerStatement \"" + statement.getName() + "\" !");
}
}
use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.
the class DboUtils method getTechnology.
public static String getTechnology(DatabaseObject parentObject, Class<? extends DatabaseObject> objectClass) {
String technology = null;
DatabaseObject parent = parentObject;
if (parent != null) {
// case of Variable
if (Variable.class.isAssignableFrom(objectClass)) {
return technology = parent.getClass().getName();
}
// parent is a connector
if (parent instanceof Connector) {
return technology = ((Connector) parent).getClass().getName();
}
// parent is a sequence
if (parent instanceof Sequence) {
return technology = ((Sequence) parent).getClass().getName();
}
// parent is a statement
if (parent instanceof Statement) {
return technology = "com.twinsoft.convertigo.beans.statements.BlockStatement";
}
// parent is a step
if (parent instanceof Step) {
technology = "com.twinsoft.convertigo.beans.steps.BlockStep";
if (getClassName(parent.getClass()).startsWith("XML")) {
technology = parent.getClass().getName();
}
return technology;
}
// parent is a transaction
if (parent instanceof Transaction) {
if (parent instanceof HtmlTransaction) {
return technology = "com.twinsoft.convertigo.beans.transactions.HtmlTransaction";
} else if (parent instanceof SiteClipperTransaction) {
return technology = "com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction";
}
}
// parent is a screenclass
if (parent instanceof ScreenClass) {
while ((parent = parent.getParent()) instanceof ScreenClass) {
;
}
if (parent instanceof JavelinConnector)
technology = ((JavelinConnector) parent).getEmulatorTechnology();
if (parent instanceof HtmlConnector)
technology = "com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass";
if (parent instanceof SiteClipperConnector)
technology = "com.twinsoft.convertigo.beans.screenclasses.SiteClipperScreenClass";
}
}
return technology;
}
use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.
the class Biller method insertCariocaBilling.
public void insertCariocaBilling(Context context, Object data) throws EngineException {
String sSqlRequest = null;
try {
Engine.logBillers.debug("[Biller] Trying to insert the billing into a Carioca database ");
sqlRequester.checkConnection();
int cache = 0;
double cost = getCost(context, data);
if (cost == -1) {
Engine.logBillers.debug("[Biller] Billing aborted because the returned cost is -1, i.e. do not need to bill.");
return;
} else if (cost == -2) {
Engine.logBillers.debug("[Biller] Billing zero cost because the response was in cache.");
cost = 0;
cache = 1;
}
Connector connector = context.getConnector();
CertificateManager certificateManager = null;
if (connector instanceof HttpConnector) {
certificateManager = ((HttpConnector) connector).certificateManager;
} else if (connector instanceof SiteClipperConnector) {
certificateManager = ((SiteClipperConnector) connector).certificateManager;
}
if (!certificateManager.storeInformationCollected) {
certificateManager.collectStoreInformation(context);
}
String certificate = new File(certificateManager.keyStore).getName();
int idx = certificate.indexOf('.');
if (idx != -1) {
certificate = certificate.substring(0, idx);
}
Statement statement = null;
long startBilling = System.currentTimeMillis();
try {
Engine.logBillers.debug("[Biller] Replacements from the context done");
StringEx sqlRequest = new StringEx(sqlRequester.getProperty(Biller.PROPERTIES_SQL_REQUEST_INSERT_BILLING));
try {
Engine.logBillers.debug("[Biller] Replacing TAS IDs");
sqlRequest.replace("{IDSVR}", context.get("IDSVR").toString());
sqlRequest.replace("{IDSERV}", context.get("IDSERV").toString());
sqlRequest.replace("{IDUSER}", context.get("IDUSER").toString());
sqlRequest.replace("{IDPROF}", context.get("IDPROF").toString());
sqlRequest.replace("{IDEMUL}", context.get("IDEMUL").toString());
Engine.logBillers.debug("[Biller] Replacing TAS variables");
sqlRequest.replaceSQL("{NomSv}", context.tasVirtualServerName, '\'');
sqlRequest.replaceSQL("{UserName}", context.tasUserName, '\'');
sqlRequest.replaceSQL("{UserGroup}", context.tasUserGroup, '\'');
sqlRequest.replaceSQL("{Service}", getService(context, data), '\'');
Engine.logBillers.debug("[Biller] Replacing POBI variables");
sqlRequest.replace("{cdbanque}", context.get("cdbanque").toString());
sqlRequest.replace("{cdguichet}", context.get("cdguichet").toString());
sqlRequest.replaceSQL("{certificat}", certificate, '\'');
sqlRequest.replace("{cache}", Integer.toString(cache));
sqlRequest.replaceSQL("{module}", getModule(context, data), '\'');
sqlRequest.replaceSQL("{userdata}", context.get("userdata").toString(), '\'');
sqlRequest.replaceSQL("{BDFKey}", getDataKey(context, data), '\'');
sqlRequest.replaceSQL("{UserGroupAuto}", context.get("UserGroupAuto").toString(), '\'');
} catch (NullPointerException e) {
throw new EngineException("One parameter for SQL replacement is missing.", e);
}
Calendar rightNow = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(sqlRequester.getProperty(Biller.PROPERTIES_SQL_DATE_FORMAT));
String date = df.format(rightNow.getTime());
sqlRequest.replace("{StartHour}", date);
sqlRequest.replace("{EndHour}", date);
Engine.logBillers.debug("[Biller] Start and End hour computed");
sqlRequest.replace("{Cost}", Double.toString(cost));
Engine.logBillers.debug("[Biller] Cost computed");
sSqlRequest = sqlRequest.toString();
Engine.logBillers.debug("[Biller] SQL: " + sSqlRequest);
statement = sqlRequester.connection.createStatement();
int nResult = statement.executeUpdate(sSqlRequest);
Engine.logBillers.debug("[Biller] " + nResult + " row(s) inserted.");
} finally {
if (statement != null) {
statement.close();
}
Engine.logBillers.info("[Biller] insertCariocaBilling, 1 request in " + (System.currentTimeMillis() - startBilling) + " ms");
}
} catch (SQLException e) {
Engine.logBillers.warn("[Biller] Unable to insert the billing.\n" + e.getMessage() + " (error code: " + e.getErrorCode() + ")\nSQL: " + sSqlRequest);
} catch (Exception e) {
Engine.logBillers.error("[Biller] Unable to insert the billing", e);
}
}
use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.
the class Get method createCategories.
private void createCategories(Document document, DatabaseObject dbo, Class<? extends DatabaseObject> databaseObjectClass, Element root) throws Exception {
Element response = document.createElement("response");
try {
List<String> defaultDboList = new ArrayList<>();
Class<? extends DatabaseObject> parentObjectClass = dbo.getClass();
Map<String, DboCategoryData> categoryNameToDboCategory = new HashMap<>();
DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
for (DboGroup group : manager.getGroups()) {
for (DboCategory category : group.getCategories()) {
for (DboBeans beansCategory : category.getBeans()) {
for (DboBean bean : beansCategory.getBeans()) {
// Skip if bean is disabled
if (!bean.isEnable()) {
continue;
}
String className = bean.getClassName();
try {
Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
DboCategoryInfo dboCategoryInfo = DatabaseObject.getDboGroupInfo(beanClass);
if (dboCategoryInfo == null) {
continue;
}
// If one of these cases, do not add the category
if (dbo instanceof ScreenClass) {
ScreenClass sc = (ScreenClass) dbo;
// Do not show Criteria category if it is the default Screen Class
if (sc.getDepth() == 0 && dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Criteria.class))) {
continue;
}
} else if (dbo instanceof CicsConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof JavelinConnector) {
// Do not show ScreenClass category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof SqlConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof HtmlConnector) {
// Do not show Pool and ScreenClass categories
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof HttpConnector) {
// Do not show Pool category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
continue;
}
} else if (dbo instanceof SiteClipperConnector) {
// Do not show Pool and ScreenClass categories
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
continue;
}
} else if (dbo instanceof Transaction) {
// Do not show Statement category
if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Statement.class))) {
continue;
}
}
if (bean.isDefault()) {
defaultDboList.add(className);
}
// The bean should derived from
// DatabaseObject...
boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
if (isDatabaseObject) {
// ... and should derived from the specified class
boolean isFromSpecifiedClass = (databaseObjectClass == null || (databaseObjectClass != null && databaseObjectClass.isAssignableFrom(beanClass)));
if (isFromSpecifiedClass) {
// Check parent
boolean bFound = DatabaseObjectsManager.checkParent(parentObjectClass, bean);
if (bFound) {
String technology = DboUtils.getTechnology(dbo, beanClass);
// Check technology if needed
if (technology != null) {
Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
continue;
}
}
String beanInfoClassName = className + "BeanInfo";
Class<BeanInfo> beanInfoClass = GenericUtils.cast(Class.forName(beanInfoClassName));
if (beanInfoClass != null) {
String categoryName = dboCategoryInfo.getCategoryName();
// Create category
DboCategoryData dboCategoryData = categoryNameToDboCategory.get(categoryName);
if (dboCategoryData == null) {
dboCategoryData = new DboCategoryData(dboCategoryInfo.getCategoryId(), categoryName, dboCategoryInfo.getIconClassCSS());
categoryNameToDboCategory.put(categoryName, dboCategoryData);
}
// Beans name
String beansName = beansCategory.getName();
if (beansName.length() == 0) {
beansName = categoryName;
}
// Create beans
DboBeansData dboBeansData = dboCategoryData.getDboBeans(beansName);
if (dboBeansData == null) {
dboBeansData = new DboBeansData(beansName);
dboCategoryData.addDboBeans(beansName, dboBeansData);
}
// Create bean
DboBeanData dboBeanData = new DboBeanData(beanInfoClass.getConstructor().newInstance());
dboBeansData.addDboBean(dboBeanData);
} else {
String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
throw new Exception(message);
}
}
}
} else {
String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
throw new Exception(message);
}
} catch (ClassNotFoundException e) {
String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" class.\n\nClass not found: {1}", new Object[] { className, e.getMessage() });
throw new Exception(message);
} catch (Throwable e) {
String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
throw new Exception(message);
}
}
}
}
}
// Find the default selected bean for each categories
for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
boolean defaultDboFound = false;
List<DboBeanData> dboBeansList = dboCategory.getAllDboBean(true);
// By default, we chose the first bean as default selected bean
DboBeanData defaultSelectedBean = dboBeansList.get(0);
// Find the default selected bean
for (int i = 0; i < dboBeansList.size() && !defaultDboFound; ++i) {
Class<DatabaseObject> beanClass = dboBeansList.get(i).getBeanClass();
// Another bean is set as default selected bean
if (defaultDboFound = defaultDboList.contains(beanClass.getName())) {
defaultSelectedBean = dboBeansList.get(i);
}
}
defaultSelectedBean.setSelectedByDefault(true);
}
// XmlLize
for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
response.appendChild(dboCategory.toXml(document));
}
} catch (Exception e) {
throw new Exception("Unable to load database objects properties.");
}
root.appendChild(response);
}
Aggregations