Indentify unused grails domain classes - grails

I have to identify all domain classes which are not used in my grails application the project has approximately 300+ domain classes, is there any(plugin) way to identify the domain which are currently not used

There isn't any plugin or tool that will do this for you. It's going to be up to you to determine if a domain class is used. Some ways to approach this would be:
Does it exist persisted in your data store? If not, it may not be used.
Remove it from the system. Do all the tests pass?
Aside from auditing the code (searching for domain classes by name) there isn't going to be a definitive way to determine this.

Related

Archive data in Grails

In my grails application I have some domain objects with lots of data in it. I now want to archive the old data in a seperate table, but the user should have access to it.
Do I have to make an extra domain class? Or is there some plugin which will help me to solve this problem?
There is no plugin that would meet your requirements. You would need to model this with a new Domain class (or something similar) in order to address your requirements.

Is there recomended/standard way to keep Grails domain classes instances persist with open-dolphins presentation models

I'd like to make my usage of open-dolphin in grails sever as easy as possible. So, I'm looking for way to handle CRUD actions on domain classes(on the server side) automaticaly. In demos from open-dolphin project I havent found any idea how to achieve this(if I missed something, please point me where I should study). Instances are pulled from server on request and until it would be pulled/updated again there is no way to recognize changes that happen on server(I've been investigating mainly crudDemo in open-dolphin project).
Since CRUD actions can come not only from user via web or remote client, but also as consequence of other actions, cascade deletes, from services etc.(changes made to the database via sql, are probably untreatable), I thing that handle actions in classes controllers is not enough.
I came up with idea of handling CRUD actions using GORM events, with those I can keep dolphin models persistent with database, check PMs before update or delete, and probably handle all changes on domain classes instances that grails is doing. But, I have to write very similar logic to each class, be sure I havent missed any event on any class(scaffolding may help) and there are probably other consequences that I do not realize now..
So my question is: Is there any documentation, pattern, plugin, open-source code, etc., where open-dolphin is implemented into grails that way, that it autamaticaly propagates CRUD actions on domain classes instances to its presentation models? Or anything that aims to achieve this, using scaffolding, observing instances lists and properties, or something else?
Maybe, I misunderstood concept of using open-dolphin with grails, if so, I appreciate any good advice.
Thanks a lot!
for some reason I haven't seen your question before.
You can happily use Grails domain classes and GORM with OpenDolphin on the server side. The "CrudDemo" in OpenDolphin does exactly that.
Here are the domain classes: https://github.com/canoo/open-dolphin/tree/master/dolphin-grails/grails-app/domain/dolphin/grails
Here are the actions: https://github.com/canoo/open-dolphin/tree/master/subprojects/demo-javafx/server/src/main/groovy/org/opendolphin/demo/crud
Note that when we do testing and client and server-side actions run in-memory, there is no grails support available. Therefore, the server-side actions use service interfaces with DTOs instead of Grails domain classes. The implementation as a Grails service then uses Grails domain classes and GORM.
enjoy
Dierk

Multiple Grails apps accessing the same database

I am considering breaking my Grails app into two separate apps: admin and customer facing. The admin app would also do a lot of backend heavy lifting.
Has anyone done this? Lessons learned? I'm particularly wondering about the best way to handle domain objects as well as potential issues with concurrency.
You could run into race/locking conditions but I've seen this done on many occasions. My only suggestion is that you not maintain separate domain classes. Put common domain classes in a plugin and install said plugin in both applications.
If you really want to do that, the best way is to separate existing Domain classes too, instead of enable multiple direct access from all the apps. Keep each Domain class persisted by the app mostly closed to it. For other apps, they should access the data through RESTful service provided by the data-hosting app.
You might want to keep the domain classes exactly the same, therefore generating same db tables.
I don't think concurrency will be much of a problem, as modern dbms usually handle that really well.

Do grails domain classes have to be tied to a database?

I am a complete noob when it comes to grails (and still very noobish when it comes to groovy) so I apologise if this is a dumb question.
I am building a simple web app and I want to control portions of the domain in my app based on file system objects (i.e. directory structure and file type) rather than database data. How easy is it to do this or are the domain objects so entwined with GORM that it is not worth the effort to try?
I ran into this question myself a couple of weeks ago.
You can just add the following snippet to the Domain Class.
def isAttached()
{
return false
}
Now it isn't connected to your database. Voila!
You can also use:
class YourDomainClass {
static mapWith = "none" // disable persistence for this domain class
See grails documentation and this answer. Appears to have been added in Grails 2.0.1 but not documented until version 2.3.0.
There is no built-in way to map domain classes to file system objects as you've described, but equally there is no requirement that your domain classes map to a relational database. The subject of how to create a Grails app that doesn't use a relational database is addressed
here and here (and possibly elsewhere).
A couple of ways to do this.
First, you can declare your properties that map to file system data as transient, and go to file system when getters / setters are called (you have to override them). You can also load them using onLoad if you need them to be in memory always.
Second - Hibernate handles the persistence. Hibernate allows for you to define your own user type, which can handle the persistence whichever way you want. This way it might happen for you more transparently (though you'd have to make sure you understand hibernate fairly well, to make sure there aren't any side effects, I am not sure).
http://i-proving.com/space/Technologies/Hibernate/User+Types+in+Hibernate

Grails - Multiple domain names, related websites

Im building a Grails app that will have multiple similar websites (each it's own domain name) with the same code but different design and configuration. (think of blogger)
What is the best method for using different view and even some different logic on a single app without too much hacking?
I'm new to Grails and the method I have in mind is to check all the time to see what the domain name is and to serve the right controller/view. Is there a better way?
I would have a go with the MultiTenant plugin. You mention that views and logic differ, but I'm guessing what will differ most is the data? Use MultiTenant to cleanly separate the data for each site without too much hazzle, and if you store the configuration of views and logic in the DB you get that unique per site as well.
I think MultiTenant is being updated to the latest Grails release, at least I've seen that mentioned in the Grails mail list. I think you need to use an 1.2 release until then.
I'm doing something similar to separate data using the Hibernate Filter plugin. My views are the same but I have per-site texts and messages by looking up message "SITE-A.hello.world" first and if not found the default message "hello.world" is retrieved. Just to give you an idea how views may be customized, though you probably need to take it further than that for your system...

Resources