use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ReferencesView method getSequenceReferencingRequires.
private void getSequenceReferencingRequires(Step step, Sequence sequenceSelected, ProjectExplorerView projectExplorerView, RequiresNode requiresNode, List<String> transactionList, List<String> sequenceList) {
try {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String projectName = sequenceStep.getProjectName();
String sequenceName = sequenceStep.getSequenceName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Sequence sequence = null;
try {
if (project != null)
sequence = project.getSequenceByName(sequenceStep.getSequenceName());
} catch (EngineException e) {
sequence = null;
}
SequenceNode sequenceNode = new SequenceNode(projectNode, sequenceName, sequence);
projectNode.addChild(sequenceNode);
if (!sequenceList.contains(projectName + sequenceName)) {
sequenceList.add(projectName + sequenceName);
requiresNode.addChild(projectNode);
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String projectName = transactionStep.getProjectName();
String connectorName = transactionStep.getConnectorName();
String transactionName = transactionStep.getTransactionName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Connector connector = null;
Transaction transaction = null;
try {
if (project != null) {
connector = project.getConnectorByName(connectorName);
if (connector != null) {
transaction = connector.getTransactionByName(transactionName);
}
}
} catch (EngineException e) {
connector = null;
transaction = null;
}
ConnectorNode connectorNode = getConnectorNode(projectNode, connector);
if (connectorNode == null)
connectorNode = new ConnectorNode(projectNode, connectorName, connector);
projectNode.addChild(connectorNode);
TransactionNode transactionNode = new TransactionNode(projectNode, transactionName, transaction);
connectorNode.addChild(transactionNode);
if (!transactionList.contains(projectName + connectorName + transactionName)) {
transactionList.add(projectName + connectorName + transactionName);
requiresNode.addChild(projectNode);
}
} else if (isStepContainer(step)) {
List<Step> steps = getStepList(step);
for (Step s : steps) {
getSequenceReferencingRequires(s, sequenceSelected, projectExplorerView, requiresNode, transactionList, sequenceList);
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to load the project", true);
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ReferencesView method getRequiredRequestables.
private void getRequiredRequestables(Step step, Project projectSelected, ProjectExplorerView projectExplorerView, AbstractParentNode parentNode, List<String> transactionList, List<String> sequenceList) {
try {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String sourceProjectName = sequenceStep.getProjectName();
if (!sourceProjectName.equals(projectSelected.getName())) {
Project project;
project = getProject(sourceProjectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
Sequence sourceSequence = null;
String sourceSequenceName = sequenceStep.getSequenceName();
try {
if (project != null)
sourceSequence = project.getSequenceByName(sourceSequenceName);
} catch (EngineException e) {
sourceSequence = null;
}
projectNode.addChild(new SequenceNode(projectNode, sourceSequenceName, sourceSequence));
if (!sequenceList.contains(sourceProjectName + sourceSequenceName)) {
sequenceList.add(sourceProjectName + sourceSequenceName);
parentNode.addChild(projectNode);
}
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String sourceProjectName = transactionStep.getProjectName();
if (!sourceProjectName.equals(projectSelected.getName())) {
Project project;
project = getProject(sourceProjectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
if (project != null) {
Connector connector = project.getConnectorByName(transactionStep.getConnectorName());
ConnectorNode connectorNode = null;
connectorNode = getConnectorNode(projectNode, connector);
projectNode.addChild(connectorNode);
Transaction sourceTransaction = null;
String sourceTransactionName = transactionStep.getTransactionName();
try {
if (connector != null)
sourceTransaction = connector.getTransactionByName(sourceTransactionName);
} catch (Exception e) {
sourceTransaction = null;
}
connectorNode.addChild(new TransactionNode(connectorNode, sourceTransactionName, sourceTransaction));
if (!transactionList.contains(project.getName() + connector.getName() + sourceTransactionName)) {
transactionList.add(project.getName() + connector.getName() + sourceTransactionName);
parentNode.addChild(projectNode);
}
}
}
} else if (isStepContainer(step)) {
List<Step> steps = getStepList(step);
if (steps != null) {
for (Step s : steps) {
getRequiredRequestables(s, projectSelected, projectExplorerView, parentNode, transactionList, sequenceList);
}
}
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to load the project", true);
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ComponentInfoWizardPage method fillTree.
public void fillTree(Class<? extends DatabaseObject> beanClass) {
treeItemName = null;
tree.removeAll();
if (parentObject instanceof Transaction) {
Connector connector = (Connector) ((Transaction) parentObject).getParent();
boolean isScreenClassAware = connector instanceof IScreenClassContainer<?>;
if (beanClass.equals(ScEntryHandlerStatement.class) || beanClass.equals(ScExitHandlerStatement.class)) {
if (isScreenClassAware) {
if (connector instanceof HtmlConnector) {
HtmlConnector htmlConnector = (HtmlConnector) connector;
ScreenClass defaultScreenClass = htmlConnector.getDefaultScreenClass();
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText(defaultScreenClass.getName());
List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
for (ScreenClass screenClass : screenClasses) {
getInHeritedScreenClass(screenClass, branch);
}
} else if (connector instanceof JavelinConnector) {
JavelinConnector javelinConnector = (JavelinConnector) connector;
ScreenClass defaultScreenClass = javelinConnector.getDefaultScreenClass();
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText(defaultScreenClass.getName());
List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
for (ScreenClass screenClass : screenClasses) {
getInHeritedScreenClass(screenClass, branch);
}
}
tree.setVisible(true);
}
} else if (beanClass.equals(HandlerStatement.class)) {
TreeItem branch;
branch = new TreeItem(tree, SWT.NONE);
branch.setText(HandlerStatement.EVENT_TRANSACTION_STARTED);
branch = new TreeItem(tree, SWT.NONE);
branch.setText(HandlerStatement.EVENT_XML_GENERATED);
tree.setVisible(true);
} else
tree.setVisible(false);
}
}
use of com.twinsoft.convertigo.beans.core.Transaction 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);
}
use of com.twinsoft.convertigo.beans.core.Transaction 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;
}
Aggregations