Telosys : How can i get database table records in template? - code-generation

I am using Telosys tools for code generation. It's very nice tool and help me a lot.
But there is one problem, that is, it provides database schema information and i can access in templates (templates are formerly velocity templates), which is good, but how can i get selected entity's data from database? There is no way i can find, by which i can get that selected table data.
Please provide solution if any, or provide alternate way to do it.
Thanking You!

Telosys Tools is designed to retrieve the model from the database,
not the data stored in the tables.
But it allows to create your own specific tooling classes usable
in the templates, so it's possible to create a specific Java Class to retrieve the data from the database.
There's an example of this kind of specific class in the "database-doc" bundle
https://github.com/telosys-tools/database-doc-bundle-TT210 ( in classes folder )
To simplify the loading the simplest way is to create the class in the "default package" (no java package)
NB:
The problem is that the jar containing the JDBC driver
is not accessible by the generator class-loader, so you will have to use a specific class-loader and to connect directly with the JDBC driver.
Here is an example : https://gist.github.com/l-gu/ed0c8726807e5e8dd83a
Don't use it as is (the connection is never closed) but it can be easily adapted.

Related

Generated classes

I try to sync data via GraphQL from my backend. Therefore I use the artemis package to generate my classes. However I then want to cache the data localy and therefore use the sqfentity_gen package to generate classes to safe my data via sql. I can use a json constructor with each framework to convert the data between.However I want to encapsulate certain functionality since I dont want to just safe changed data localy but sync it to the backend and handle certain errors like merge conflicts or missing network. Therefore I am thinking about wrapping the classes with an other one since I cant change the generated code. Is this a good idea or are there other solutions which work better? Would you use a completly diffrent setup? Glad for any suggestions
Instead of generate and/or re-generate (update) classes which are based on db-tables (I assume), you can use solution from the box, in example, NReco.GraphQL
It allows you set db-schema in the json file and just set db-connection. If you have a lot of tables, you can just generate that json file based on metatable info.
Storing and updating classes, from my point of view is useless.

Oracle Data Modeler generated column name from datamodel too long

I'm trying to create a datamodel in the Oracle Data Modeler module that is available in Oracle SQL Developer. I would like to maintain my data dictionary from this model. To do this (I think) I need a generated DDL file for which the attributes are not longer than 30 characters.
I have just discovered Oracle SQL Developer and am completely new to creating these kind of models. What I have done so far. I have created a logical model and have engineered it to a relational model. From the relational model I can then generate DDL scripts that I can run on the database to make the changes I want.
When doing this I run into a problem. When engineering the logical model to a relational model I can see that the foreign keys I have made become more than 30 characters. This is because it seems to generate the name as (see picture)
From searching it seems you should be able to fix this with naming standard templates. I have looked for this menu option but can't find it. I have found the name abbreviations functionality for which you can upload .csv files but I think this is for something different.
Rightclicking on the logical model in the datamodeler browser view gives me the opportunity to Apply naming standards, but this gives me a message that I should turn off the keep as the name of the originating attribute option (see picture). I have looked for this but can't find this option.
My version of Oracle SQL Developer is 4.1.3.20, Build MAIN-20.78.
Please let me know if my story is not clear. Thanks.
Generated column name
Applying name standards message
You will find the option under Tools/Preferences/Data Modeler/Model/Logical

CRUD operation Grails

I need to read data from existing database is it possible using
compile "org.grails.plugins:db-reverse-engineer:4.0.0"?
My operations are: user should read data from existing table, create new record, create new coulmn, edit coulmn name, edit records.
View format will be in grid like xml grid.
Which technology is the best for these operations in grails, I have plan to work on javascript using jaxrs, is it good to do?
DB Reverse Engineering Plugin (org.grails.plugins:db-reverse-engineer:4.0.0) allows you to generate domain classes using existing DB. After you generate them - just use GORM to perform CRUD operations. You can read about GORM here
You can implement REST api in Grails using standart ways, check this answer to get high level understanding. If you need jaxrs- there is a plugin for that.

Yii Gii with MongoDB

Could anyone please tell me how MongoDB can be used with YII?
How can we create controller and model functions using Gii if the database used is MongoDB?
I've used YiiMongoDBSuite (YMDS), which has some very rough support for Gii. You can generate starter classes, but given that MongoDB does not have a fixed schema you will need to edit the model to make them useful. There is an odd kludge that lets you generate MongoDB models from a SQL table, but this seems more effort than it's worth.
YMDS' EMongoDocument class extends the standard Yii CModel class, so this is a useful base if you want to build apps with CRUDS.
The unfortunate caveat is that YMDS is no longer maintained by the original author, and there are a few community forks to chose between.
The way of creating controllers is same as usual but you have to use an extension to talk to mongoDB from Yii ,
You need to use direct Mongo suite of yii . It is an extension which has a collection of components for the mongoDB .

TG2.1: Proper location to store a database session instance?

I am using a custom database (MongoDB) with TG 2.1 and i am wondering where the proper place to store the PyMongo connection/database instances would be?
Eg, at the moment they are getting created inside of my inherited instance of AppConfig. Is there a standard location to store this? Would shoving the variables into the project.model.__init__ be the best location, given that under SQLAlchemy, the database seems to commonly be retrieved via:
from project.model import DBSession, metadata
Anyway, just curious what the best practice is.
As of TurboGears 2.1.3, MongoDB support is integrated via the Ming ORM. I would look at a quickstarted project using the --ming option to get best practices if you want to do some customization: http://turbogears.org/2.1/docs/main/Ming.html