How to load related entities in Jetbrain's Exposed DSL approach - jetbrains-ide

How to load related entities in Jetbrain's Exposed using DSL approach?
For example: - I am having entity "User" and now I want to load its "Role" details along with every user row whenever I hit select query on it.

Related

Preventing EntityReference Checks from occuring when Creating/Updating an Entity in Dynamics CRM

When executing a CreateRequest using the MS CRM OrganizationService, it seems that any attribute of type 'EntityReference' is checked by the internal CRM pipeline using a SQL query against the respective base table looking for the key specified in the EntityReference object. It's basically a foreign key check substitute since CRM doesn't define actual foreign keys when you relate entities.
I'm trying to import some data into the system where I know the specified EntityReference's already exist since I just retrieved them (race conditions aside). Is there any way to bypass that internal check from happening when using the web services? I'd like to avoid having to do any direct SQL updates since it invalidates the auditbase and modifiedby information.
For example, inserting 100,000 entity instances which each have 5 entity reference attributes on them turns into 500,000 selects being issued, often for the same value. Please tell me there is a supported way around this?
No. The only supported way to create records inside Dynamics CRM is to use the API.

Liferay database table work flow?

I am new to Liferay. Now I need to create the flow chart which has the Liferay table work flow in following scenarios,
1) What are the list of table will reflect/update if we create the site admin?
2) What are the list of table will reflect/update if we create the site?
I tried by opening database tables and noticed that USER_, CONTACT_ will reflect, But I need list of all the related tables which will reflect when we create the site and siteadmin? I am using Liferay 6.2 version.
Thanks in advance.
When you want to know the internals of any system it is always best to check the relevant source-code. So in this case you can check the source-code for those classes which are used for CRUD operations on User and Site.
1) What are the list of table will reflect/update if we create the site admin?
Site-administrator is a Role, which can be applied to a User created in Liferay.
So if you want all the tables that are created from User-creation till User is assigned the Site-administrator role for a particular site, there here are some which I can recollect:
User_ (Obvious)
Contact_ (not so obvious :-) )
Group_ (Users are also created as a record in this table since Users have public and private pages)
Address (if you add an address)
Phone (if you add a Phone)
Users_Roles (Power user role is assigned by default)
UserGroupRole (user and site-role relationship, Site-administrator is a Site-role)
Users_Groups (user and site relationship)
For others you should refer the source-code for UserLocalServiceImpl, RoleLocalServiceImpl and GroupLocalServiceImpl, check the relevant methods prefixed add, update etc.
The corresponding service.xml for these module would reveal the database tables being used.
2) What are the list of table will reflect/update if we create the site?
Sites are nothing but Groups in Liferay. So its obvious Group_ table is playing a big role.
Other tables also depend upon what configuration you are doing while creating a Site.
Then there would be other tables like Layout when you start creating pages for a Site.
I would strongly encourage to go ahead and explore the source code for the classes and you would understand the flow - when and what tables are affected.
Here is some convention which might help you traverse the source-code, almost every *LocalServiceImpl is associated with a *Model like UserLocalServiceImpl with UserModel and almost every *Model has a corresponding database table with the same name.
Also the name of the functionality would in most cases hints at what service classes are being used to connect to database, like adding a User would hint at using UserLocalServiceImpl.
Hope I have understood your question and have been able to give some proper direction.
If you want to know this because you also want to write to these tables: Don't go there! You should purely use the API to change the data that Liferay stores. Otherwise you will run into disasters some time in the future - promised.
For just getting the SQL commands that Liferay actually uses, configure portal-ext.properties and change this default value:
hibernate.show_sql=false
Then go to "Server Administration/Log Levels" and add a new category "org.hibernate.SQL", configure it to the level DEBUG. Then the results show up in the logs. Note that this log configuration is transient and will be reverted on next server start. If you want the setting to be persistent, you'll need to go into Liferay's log4j configuration files.
Remember: You don't want to write to the tables ever. Promise!

Getting ViewModelReference in another ViewModel

We have an application wich has a typical Master/Detail view. The master view displays a list of ticket titles and if you click on a ticket title you see a view with the ticket details.
The master view has a model wich is a list of "ticket" objects each containing more information about a specific ticket. We bound a handler on click which basically instantiates a new detail view and displays it. This works fine, except that we have to give all the config values as primitive data types to the constructor (we know we can't use objects when instantiating)
We thought about another way to do this but couldn't get it working. In the Init() (of the detail view model) we only pass the ID (of the clicked ticket) and wanted to use Mvx.Resolve to get the master view model. So question one would be, can you fetch arbitrary view models inside other view models?
A second idea would be write a base view model class from which all view models in our app inherit, which registers the view model on instantiation to a service so that you can call that service and fetch the view model from anywhere (mediator pattern). Would that be against the framework?
An answer that I have found is "use messages" but to me it seems sort of bulky, at least how I understood this. The detail view model would have to send a message to the master view model "Ok I'm ready now" and then the master view model would say "Alright, heres the configuration".
So to sum up the questions:
Is it possible to fetch certain view models from the framework inside other view models?
Would implementing this by hand be against the framework?
Did we understand the message approach correctly and if no, what would be a more lightweight/generic way of doing it?
Cheers and thanks
Tom
Usually when I have to share data across View Models, I use a Service to manage it. The service is typically injected via IoC.
I treat View Models as a mediator between the Services and the View. Most of my logic is stored in the Service. The only things I have in the View Model are properties for data binding, commands that dispatch to a service, and other presentation level concerns.
For your scenario, I would have the MasterViewModel pass an identifier to the DetailViewModel, where it will ask the ConfigurationService for the configuration by id.
Hope this helps.

Lookup fields in CRM 2011

Entity Application has a look up to Contact. Now, Entity Application Document has a look up to Application. In my Application Document form, I want to display the Contact who is associated with the Application Document. I do not want to be creating a look up to Contact as it is just bad database design.
How can I show the related contact in the Application Document form. It is after all a look up - alright, a two level look up right? I can go from the Application Document to the Application to which it is related and from there to the Contact.
My suggested solution would be to have a read only text field in the Application Document entity. Populate it with Contact (Primary Field) onloadform with a JavaScript.
I'd resolve it as a call to the DB, fetching the linked entity and then fetch it's linked entity. JavaScript seems to be the wises choice in this case.
However, you mention that you find this solution bad, so I might be missing a requirement.

How to provide Detail and Summary objects for my REST api with Node.js and Mongoose?

I want to provide some venue information over my node.js REST API build by mongoose and express.
In my model, I should take care of every details for a venue.
But when requested for summary, I should show only some of them.
And If requested for 1 venue in detail, I should show more.
What is the best way to do it?
If you want to achieve something like this why not create some custom queries for your detail and summary actions?
Basically what you need to do.
Create your custom queries that received the custom data.Do this in your model. (e.g the data for summary or details)
Create specific actions for these speficic type of API calls in your controllers and server it as you wish. (E.g create /getVenueDetail/venueId=213235 )

Resources