Posts

Showing posts from 2017

Organization Administrator and Organization Owner

Image
In Liferay, we can assign the users to the Organization and can assign the Organization role to the users. There are 3 types of organization roles . After assigning the role ,  If we want to fetch the users who has the Organization administartor. Below is the code. long orgId = ParamUtil.getLong(request, "organizationId"); List<User> users = OrganizationUtil.getUsers(orgId); Group organizationGroup = OrganizationLocalServiceUtil.getOrganization(orgId).getGroup(); for(User user: users){   long organizationGroupId = organizationGroup.getGroupId();   if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(   user.getUserId(), organizationGroupId, RoleConstants.ORGANIZATION_ADMINISTRATOR)) {                   System.out.println("User is: "+ user);                                   } } First, we are fetching the users with Organizationid, Using that Organization, we are fetching the "Group" ,

Theme display in javascript

We know that we can access the themedisplay in java as ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY) But how can we access in javascript? Here we go Liferay.ThemeDisplay.getScopeGroupId() Liferay.ThemeDisplay.getCompanyId() Liferay.ThemeDisplay.getPlid() Liferay.ThemeDisplay.getLayoutId() By this we can access the groupId, companyid ... etc

Get Text from language properties via javascript

We know that we can get the text from the properties as   Language.properties     you-have-processed-sucessfully = Your Request processed successfully.   JSP: <liferay-ui : message key = "you-have-processed-sucessfully" /> CLASS: LanguageUtil . get ( pageContext , " you-have-processed-sucessfully " ); But if want to retrieve via javascript , Here is the one <script>      <custom code> ---               ----     Liferay . Language . get ( ' you-have-processed-sucessfully ' ); </script> But this Liferay.Language will get from the Portal properties not from the portlet properties There is way to solve this problem writing Hook and specifing the properties.

Introduction to Selenium

Image
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. Different languages support by selenium Java PHP Perl Python C# ObjectC Ruby Javascript Selenium Versions Selenium IDE ( I ntegrated D evelopment E nvironment) Selenium RC ( R emote C ontrol) Selenium Webdriver Latest version is  Selenium Webdriver Selenium IDE  Implemented by shinya from JAPAN  Released in 2006  Functional  Automation tool supports only webapplications It is UI based and record/playback tool It is implemented plugin or add-on for the firefox browser Supports only firefox browser Selenium RC Implemented  by jsonhuggins from thoughtwork company Released in 2004 First automation open-source tool in the market It is Collections of javascript's. It's not a UI based, it doen't contain record/playback feature It Supports all browser and platform's Selenium Webdriver Implemented by

Introduction to Automation

What is Automation A process of converting any manual test case into automation test scripts using some automation tools with scripting or programming language is called automation. Automation tools QTP [VB] - Scripting language Selenium : IDE[HTML] Webdriver : [JAVA/.NET/Perl/python] Commerical tools - Paid/Licenced based tools (QTP) OpenSource - Source code is avaliable in internet (webdriver) Freewar : Source Code is not avaliable but is freely avalible in internet (Playstore, SOAP UI) Types of Applications:   Web Applications: Any application uses browser or URL to open like GMail,FB,Flipkar  Standalone Applications: The Application which doesn't uses browser or URL to open like           M.S.Excel, Notepad Mobile Applications:  The Application which opens through Mobile. Under mobile Applications we have Native:Default applications available in Mobile ex: Contacts, Message.  Web: Application open through URL in Mobile ex: open FB throu

Service Bulider SQL Types

Service-Builder provides flexibility to map Java data types into SQL data types as follows: <column name="type" type="String" /> <column name="type" type="long" /> <column name="answerOrder" type="int" /> Java data type                     SQL data type                   Description boolean, Boolean                 BOOLEAN                            Boolean type Double, Double                    DOUBLE                               Double type float, Float                            FLOAT                                  Float type int, Integer                            INTEGER                              Integer type long, Long                            BIGINT                                  Long type short, Short                           INTEGER                              Short type Date                                      TIMESTAMP                        Date type String          

Details about Site roles - Adding and getting

Related to Site Roles we can use  UserGroupRoleLocalServiceUtil method. To add site role to the user we can use  UserGroupRoleLocalServiceUtil .addUserGroupRoles(long userId, long groupId, long[] roleIds) To get site role for the user we can use getUserGroupRoles( long userId, long groupId); Also there are several methods to Delete site roles and to check the site roles. All these implementation we can check in the  UserGroupRoleLocalServiceImpl .

Running Custom SQL

In Liferay by default , ServiceBuilder generated LocalServiceBaseImpl class contains a method call runSQL. We can use that method to execute our CustomSQL Query of that Entity. If we want to execute the customSQL of Blogs Entity we can use that method by call in the localserviceImpl. Example: 1. I have a table call " Employee " and i want to execute the Employee table  related custom SQL 2. So i have written a custom method in EmployeeLocalServiceImpl  as below and calling runSQL method  public void executeCustomQuery(String cusQuery) throws SystemException{ super.runSQL(query); } 3. Build the service and call the sql query as  EmployeeLocalServiceUtil.executeCustomQuery(' update table Employee set EmpName = 'Liferay' where EmpId = 2 '); So here it is , We can Execute the SQL queries