Recently I spent two weeks working on Liferay Organization Custom Field with Twitter API. It was frustrating to deal with Twitter API, because it has Rate limit, even though we use Streaming API, it also has connection limit.
In the blog, I'll record what I understand Organization Custom Field and organization logo from database. To my surprise, in the organization_ table, there's no column to store logo, I have to join other tables to get that.
1. organization_
This is the organization table structure, what I get from the table is organizationId, parentOrganizationId, name. I need parentOrganizationId to get the organization hiearchery the user is in.
2. If we login in Liferay as admin, we can go to control panel. In the left Nav bar, we can find custom fields link, then we go and find Organization. Here we can add custom field like Facebook account, Twitter account.
3. Where do Liferay store custom_field, which tables do they use? Apparently, we can see there's no column to store custom field. In fact, custom filed relates four tables.
3.1) exapndovalue
In the table, we can get the data which we input in our custom field. And the classPK is our organizationId.
3.2) expandocolumn
The table stores our custom field names. Here we can see I define three custom fields in Organization: twitter, facebook and myspace.
3.3)expandotable
The table defines if we set up custom field for which model like organization or User or other component in Liferay.
3.4) className_
In the table, we can get Organization Mode, then we can get classNameId. When we get classNameId, we can get tableId from expandotable. When we get tableId, we can get columnId according to tableId and name. Then we can get a list of organizations' custom fields data.
4. How can we get organization logo?
The logo image is stored in image table, I don't want to give details about it. One thing which is very strange that there's no a table directly store the relationship between organization and logo(image). Instead, it uses group_, layoutset to build the relationship.
4.1) group_: which stores the relationship between classpk and groupId. Here classPK is organizationId. You can see classPK used in many tables. In my case, I just need to get groupId through classPK.
4.2) layoutset: Here is the place to store relationship between logoId and groupId. When you upload a logo in Organization detail page, it will store two rows in layoutset table, one is for public page, the other is for private page. I don't dive into the area. The column privateLayout decides it.
That's all the tables I used to get a list of organizations' twitter screen name.