use of com.twinsoft.convertigo.engine.dbo_explorer.DboCategory in project convertigo by convertigo.
the class BeansDoc method run.
private int run() throws Exception {
FileUtils.deleteQuietly(outputDirectory);
FileUtils.deleteQuietly(imageDirectory);
// Loggers
Engine.logBeans = Logger.getLogger(BeansDoc.class);
Engine.logContext = Logger.getLogger(BeansDoc.class);
Engine.logEngine = Logger.getLogger(BeansDoc.class);
// Engine properties manager
EnginePropertiesManager.initProperties();
DboExplorerManager manager = new DboExplorerManager();
List<DboGroup> groups = manager.getGroups();
for (DboGroup group : groups) {
groupName = group.getName();
List<DboCategory> categories = group.getCategories();
for (DboCategory category : categories) {
categoryName = category.getName();
List<DboBeans> beansCategories = category.getBeans();
for (DboBeans beansCategory : beansCategories) {
beansCategoryName = beansCategory.getName();
List<DboBean> beans = beansCategory.getBeans();
for (DboBean bean : beans) {
if (bean.isEnable()) {
if (count == max) {
return count;
} else {
count++;
}
System.out.println("handle /" + groupName + "/" + categoryName + "/" + beansCategoryName + "/" + bean.getClassName());
createBeanElement(bean, bean.getDocumentedMode() == DocumentedMode.TRUE);
}
}
}
}
}
generateMobileComponentsMd(outputDirectory);
makeListingPages(outputDirectory);
return count;
}
use of com.twinsoft.convertigo.engine.dbo_explorer.DboCategory in project convertigo by convertigo.
the class DatabaseObjectsManager method acceptDatabaseObjects.
public static boolean acceptDatabaseObjects(DatabaseObject parentObject, Class<? extends DatabaseObject> objectClass, Class<? extends DatabaseObject> folderBeanClass) {
try {
Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
List<DboGroup> groups = manager.getGroups();
for (DboGroup group : groups) {
List<DboCategory> categories = group.getCategories();
for (DboCategory category : categories) {
List<DboBeans> beansCategories = category.getBeans();
for (DboBeans beansCategory : beansCategories) {
List<DboBean> beans = beansCategory.getBeans();
for (DboBean bean : beans) {
String className = bean.getClassName();
Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
if (beanClass.equals(objectClass)) {
// The bean should derived from DatabaseObject...
boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
if (isDatabaseObject) {
// ... and should derived from the specified class
boolean isFromSpecifiedClass = ((folderBeanClass == null) || ((folderBeanClass != null) && (folderBeanClass.isAssignableFrom(beanClass))));
if (isFromSpecifiedClass) {
// Check parent
boolean bFound = checkParent(parentObjectClass, bean);
if (bFound) {
// Check technology if needed
String technology = DboUtils.getTechnology(parentObject, objectClass);
if (technology != null) {
Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
continue;
}
}
return true;
}
}
}
}
}
}
}
}
return false;
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("Unable to load database objects properties.", e);
return false;
}
}
use of com.twinsoft.convertigo.engine.dbo_explorer.DboCategory 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.engine.dbo_explorer.DboCategory in project convertigo by convertigo.
the class ObjectsExplorerComposite method findDatabaseObjects.
protected void findDatabaseObjects() {
if (objectsMap.isEmpty()) {
try {
Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
Map<BeanInfo, DboBeans> beanMap = new HashMap<BeanInfo, DboBeans>();
// Enumeration of the beans
ConvertigoPlugin.logDebug2("Exploring Convertigo database objects list...");
DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
List<DboGroup> groups = manager.getGroups();
Set<DboBeans> beansCategorySet = new LinkedHashSet<DboBeans>();
for (DboGroup group : groups) {
List<DboCategory> categories = group.getCategories();
for (DboCategory category : categories) {
List<DboBeans> beansCategories = category.getBeans();
for (DboBeans beansCategory : beansCategories) {
List<DboBean> beans = beansCategory.getBeans();
for (DboBean bean : beans) {
if (!bean.isEnable())
continue;
String className = bean.getClassName();
if (bean.isDefault()) {
defaultDboList.add(className);
}
if (bean.isDocumented()) {
documentedDboList.add(className);
}
try {
Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
ConvertigoPlugin.logDebug2("Bean class: " + (beanClass != null ? beanClass.getName() : "null"));
// 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) {
// 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) {
beanMap.put(beanInfoClass.getConstructor().newInstance(), beansCategory);
beansCategorySet.add(beansCategory);
} else {
String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
ConvertigoPlugin.logWarning(message);
}
}
}
} else {
String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
ConvertigoPlugin.logWarning(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() });
ConvertigoPlugin.logWarning(message);
}/*
* catch(IntrospectionException e) { String
* message =java.text.MessageFormat.format(
* "Unable to find the bean info linked to the \"{0}\" class."
* , new Object[] {className});
* ConvertigoPlugin.logWarning(message); }
*/
catch (Throwable e) {
String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
ConvertigoPlugin.logException(e, message);
}
}
}
}
}
List<BeanInfo> beanInfoList = new ArrayList<BeanInfo>(beanMap.keySet());
Collections.sort(beanInfoList, new Comparator<BeanInfo>() {
public int compare(BeanInfo o1, BeanInfo o2) {
BeanDescriptor bd1 = o1.getBeanDescriptor();
BeanDescriptor bd2 = o2.getBeanDescriptor();
String name1 = bd1.getDisplayName().toLowerCase();
String name2 = bd2.getDisplayName().toLowerCase();
return name1.compareTo(name2);
}
});
// initialize composites.
RowLayout rowLayout = new RowLayout();
rowLayout.pack = false;
bar = new ExpandBar(scrolledComposite, SWT.NONE);
bar.setSpacing(8);
String itemText = "";
int i = 0;
Iterator<DboBeans> iterator = beansCategorySet.iterator();
if (databaseObjectClass.equals(Connector.class)) {
composites = new Composite[1];
items = new ExpandItem[1];
composites[i] = new Composite(bar, SWT.NONE);
composites[i].setLayout(rowLayout);
composites[i].setBackground(bar.getBackground());
items[i] = new ExpandItem(bar, SWT.NONE, i);
items[i].setControl(composites[i]);
items[i].setExpanded(true);
items[i].setText("Connectors");
} else {
composites = new Composite[beansCategorySet.size()];
items = new ExpandItem[beansCategorySet.size()];
while (iterator.hasNext()) {
composites[i] = new Composite(bar, SWT.NONE);
composites[i].setLayout(rowLayout);
composites[i].setBackground(bar.getBackground());
items[i] = new ExpandItem(bar, SWT.NONE, i);
items[i].setControl(composites[i]);
items[i].setExpanded(true);
itemText = iterator.next().getName();
if (itemText.equals("")) {
itemText = databaseObjectClass.getSimpleName();
if (beanInfoList.size() > 1) {
itemText.concat("s");
}
}
items[i].setText(itemText);
i++;
}
}
handCursor = new Cursor(Display.getDefault(), SWT.CURSOR_HAND);
boolean bSelected = false;
boolean defaultDboFound = false;
Iterator<BeanInfo> it = beanInfoList.iterator();
while (it.hasNext()) {
BeanInfo beanInfo = it.next();
DboBeans beanCategory = beanMap.get(beanInfo);
Class<DatabaseObject> beanClass = GenericUtils.cast(beanInfo.getBeanDescriptor().getBeanClass());
boolean isDefault = defaultDboList.contains(beanClass.getName());
boolean isDocumented = documentedDboList.contains(beanClass.getName());
String beanName = beanInfo.getBeanDescriptor().getDisplayName();
String beanDescription = isDocumented ? beanInfo.getBeanDescriptor().getShortDescription() : "Not yet documented |";
String[] beanDescriptions = beanDescription.split("\\|");
String beanShortDescription = BeansUtils.cleanDescription(beanDescriptions[0], false);
Image beanImage = ConvertigoPlugin.getDefault().getBeanIcon(beanInfo, BeanInfo.ICON_COLOR_32x32);
if (isDefault) {
bSelected = true;
defaultDboFound = true;
}
addLabelEx(beanImage, beanClass, beanName, beanShortDescription, bSelected, beanInfo, beanCategory);
bSelected = false;
}
// We select by default the first item if no default dbo found.
if (!defaultDboFound && currentSelectedObject == null) {
currentSelectedObject = (CLabel) composites[0].getChildren()[0];
}
if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
}
BeanInfo currentSelectedObjectBeanInfo = getCurrentSelectedBeanInfo();
if (currentSelectedObjectBeanInfo != null) {
updateHelpText(currentSelectedObjectBeanInfo);
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to load database objects properties.");
}
}
}
use of com.twinsoft.convertigo.engine.dbo_explorer.DboCategory in project convertigo by convertigo.
the class DatabaseObjectsManager method acceptDatabaseObjects.
public static boolean acceptDatabaseObjects(DatabaseObject parentObject, DatabaseObject object) {
try {
Class<? extends DatabaseObject> parentObjectClass = parentObject.getClass();
Class<? extends DatabaseObject> objectClass = object.getClass();
DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
List<DboGroup> groups = manager.getGroups();
for (DboGroup group : groups) {
List<DboCategory> categories = group.getCategories();
for (DboCategory category : categories) {
List<DboBeans> beansCategories = category.getBeans();
for (DboBeans beansCategory : beansCategories) {
List<DboBean> beans = beansCategory.getBeans();
for (DboBean bean : beans) {
String className = bean.getClassName();
Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
// The bean should derived from DatabaseObject...
boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
if (isDatabaseObject) {
// ... and should derived from the specified class
boolean isFromSpecifiedClass = ((objectClass == null) || ((objectClass != null) && (objectClass.isAssignableFrom(beanClass))));
if (isFromSpecifiedClass) {
// Check parent
boolean bFound = checkParent(parentObjectClass, bean);
if (bFound) {
// Check technology if needed
String technology = DboUtils.getTechnology(parentObject, objectClass);
if (technology != null) {
Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
continue;
}
}
return true;
}
}
}
}
}
}
}
return false;
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("Unable to load database objects properties.", e);
return false;
}
}
Aggregations