User Management, is one of the new functionalities available in OrangeScape Applications created after the late september release. For those applications which were created before that release, during migration, the required fields would have been created. But, the developers will have to make the additional changes like, process, forms by going thru the User Management available in the newer applications.
This post is not about explaining the UserManagement part or about what changes have to be made for UserManagement to work in older applications. This post is about creating users and managing user roles via the backend, directly in the database.
First a small understanding about the models of User Management. UserManagement is made of the following models: User, UserChanges, RoleSubscription, AppRole
So there is the AppRole model, which has all the roles which you have defined in the application. You don’t have to insert anything there, the application reads your process and creates the required records for the roles defined there. Next there is the User model, where all the user records are stored. Then There is the Role Subscription model, where you define the roles to which the user is assigned / subscribed to. The UserChanges model has the change history of the user’s details.
When you create a user a record is created in UserChanges model, and all required details are entered. Once you save the record, the actual User record is created. Once this is done, you can assign roles to the User, by inserting records to the RoleSubscription Model. To know how to do these things from the application, please refer the corresponding section in http://learn.orangescape.com.
If you are wondering why the initial User details are being captured in UserDetails,. Once a record is created in User model for a User, the whole process of user creation is complete. When you do a create new in Orangescape Application, that record is immediately saved in the backend, and then only it is given for you to edit. Which means, when doing a create new in User Model, a new, empty User record will be created. which is BAD. I you want to know how this data entered in UserChanges syncs up with User and how all changes done for the User in UserChanges are listed from User, read the post here.
Ok. so now, we know a little of how User Management Works, (any questions / doubts, for the better good of other people, please ask them in the community forums). There is a beautiful & easy UI provided in the application. Make sure you do check it out. But, as everyone knows, it is a pain to enter 60 or 70 user records. Well, then you have the CSV import option available, which even validates if your data is right or not. But, for some, for some reason, they need to insert data into the database directly. (In the case of integration). Lets proceed with inserting data directly back in to the backend.
This is for those versions where you use a database for backend. On Premise or GAE SQL. not for GAE noSQL (BigTABLE).
download this SQL. It has the sample queries, and the minimum required Columns and the data required for those columns. use those queries as templates, and insert the data as required in the backend. Since updates would never make sense, with Cache in place, Modification are to be done via the application.