Monday, March 3, 2014

Enable Liferay development (IDE) on mule studio

I have installed the liferay on mule studio, So now I am holding the great two thing on one point.
Following steps to bring you for that point.
Prerequisites:
Have venial mule studio 3.5 its come with (eclipse 3.8 - juno) and we gonna install liferay 2.0 IDE.
Steps:

Note : During this installation the eclipse IDE may ask for restart several time. Give the way to restart

1)Spring Core: (For portlet spring capability)
 Install Spring Code / Spring IDE using http://springide.org/updatesite


2) WTP (Web tool platform)
Install the following plugin dependency in the <Web , xml , Java EE OSI enterprise development> category available in the

Eclipse Juno repository - http://download.eclipse.org/releases/juno/
Plugin dependency :
    Eclipse Faceted Project Framework-3.4.0.v201202292300-377F8N8s735555393B7B
    Eclipse Faceted Project Framework JDT Enablement-3.4.0.v201108231500-377DG8s73543J5H6D66
Eclipse Java EE Developer Tools-3.4.2.v201301240600-7b7JINbFSK2WM3QNAEr799V-TyUp
JavaScript Development Tools-1.4.1.v201208171701-7H7DFg0FC7sReqSyfqesWi
JavaServer Faces Tools (JSF) Project-3.5.0.v201301161500-7E7U-F9JgLWrLWXMXBLL
JST Server Adapters-3.2.201.v20130123_1813-20A87w31241234a2924
JST Server Adapters Extensions-3.3.102.v20130108_1103-777HFL7CcNBDnBcIVFHFD8
JST Server UI-3.4.0.v20120503_1042-7A77FHr9xFcC2CFLZBCJMHLg7D64
WST Server Adapters-3.2.203.v20130123_1813-7L3FA4CcNBGVCZL_l8OCG

3)Liferay
Now the final plugin installation thats our liferay,
go ahead with this update site url
Liferay IDE repository - http://releases.liferay.com/tools/ide/latest/stable/
install Liferay IDE and Maven or any one.


4) Test the installation 
File -> new -> project -> find for Liferay catogory

or type the above box with liferay. If you get some result thats all your liferay ready on mule studio.
If failed post the comments.


Sunday, March 2, 2014

Programaticaly creating DDL and using expando bridge

Liferay 6.2 webcontent like DDL.

Follow the code with template and create a web content display.
Programaticaly creating DDL and using expando bridge

Organisation Name :
$Text1519.getData()


#set ($locale = $localeUtil.fromLanguageId($request.get("locale")))
#set ($dateFormatDateTime = $dateFormats.getDateTime($locale))

<h1>First Expando Bank</h1>

##
## Define the "name" for our ExpandoTable.
##

#set ($accountsTableName = "AccountsTable")

##
## Get/Create the ExpandoTable to hold our data.
##

#set ($accountsTable = $expandoTableLocalService.getTable($accountsTableName, $accountsTableName))

#if (!$accountsTable)
#set ($accountsTable = $expandoTableLocalService.addTable($accountsTableName, $accountsTableName))

#set ($accountsTableId = $accountsTable.getTableId())

##
## Create an ExpandoColumn for each field in the form.
##

#set ($V = $expandoColumnLocalService.addColumn($accountsTableId, "firstName", 15)) ## STRING
#set ($V = $expandoColumnLocalService.addColumn($accountsTableId, "lastName", 15)) ## STRING
#set ($V = $expandoColumnLocalService.addColumn($accountsTableId, "balance", 5)) ## DOUBLE
#set ($V = $expandoColumnLocalService.addColumn($accountsTableId, "modifiedDate", 3)) ## DATE
#end

##
## Do some request handling setup.
##

#set ($renderUrl = $request.get("render-url"))
#set ($namespace = $request.get("portlet-namespace"))
#set ($cmd = $request.get("parameters").get("cmd"))

#set ($firstName = '')
#set ($lastName = '')
#set ($balance = 0.0)

##
## Check to see if a classPK was passed in the request.
##

#set ($classPK = $getterUtil.getLong($request.get("parameters").get("classPK")))

##
## Check if we have received a form submission?
##

#if ($cmd.equals("add") || $cmd.equals("update"))
##
## Let's get the form values from the request.
##

#set ($firstName = $request.get("parameters").get("firstName"))
#set ($lastName = $request.get("parameters").get("lastName"))
#set ($balance = $getterUtil.getDouble($request.get("parameters").get("balance")))
#set ($date = $dateTool.getDate())

##
## Validate the params to see if we should proceed.
##

#if (($cmd.equals("add") && !$firstName.equals("") && !$lastName.equals("") && $balance >= 50) || ($cmd.equals("update") && !$firstName.equals("") && !$lastName.equals("")))
##
## Check to see if it's a new Account.
##

#if ($classPK <= 0)
#set ($classPK = $dateTool.getDate().getTime())
#end

#set ($V = $expandoValueLocalService.addValue($accountsTableName, $accountsTableName, "firstName", $classPK, $firstName))
#set ($V = $expandoValueLocalService.addValue($accountsTableName, $accountsTableName, "lastName", $classPK, $lastName))
#set ($V = $expandoValueLocalService.addValue($accountsTableName, $accountsTableName, "balance", $classPK, $balance))
#set ($V = $expandoValueLocalService.addValue($accountsTableName, $accountsTableName, "modifiedDate", $classPK, $date))

##
## Show a response.
##

#if ($cmd.equals("update"))
Thank you, ${firstName}, for updating your account with our bank!
#else
Thank you, ${firstName}, for creating an account with our bank!
#end

#else
Please fill the form completely in order to create an account. The minimum amount of cash required to create an account is $50.
#end

#set ($classPK = 0)
#set ($firstName = '')
#set ($lastName = '')
#set ($balance = 0.0)

#elseif ($cmd.equals("delete"))
##
## Delete the specified Row.
##

#if ($classPK > 0)
#set ($V = $expandoRowLocalService.deleteRow($accountsTableName, $accountsTableName, $classPK))

Account deleted!

#set ($classPK = 0)
#end
#elseif ($cmd.equals("edit"))
##
## Edit the specified Row.
##

Editting...

#if ($classPK > 0)
##
## Get the account specific values
##

#set ($firstName = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "firstName", $classPK, ""))
#set ($lastName = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "lastName", $classPK, ""))
#set ($balance = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "balance", $classPK, 0.0))
#end
#end

<span style="display: block; border-top: 1px solid #CCC; margin: 5px 0px 5px 0px;"></span>

#if (!$cmd.equals("edit"))
##
## Now we're into the display logic.
##

<input type="button" value="Create Account" onClick="self.location = '${renderUrl}&${namespace}cmd=edit';" />

<br /><br />

<table class="lfr-table">
<tr>
<th>Account Number</th>
<th>First Name</th>
<th>Last Name</th>
<th>Balance</th>
<th>Modified Date</th>
<th><!----></th>
</tr>

##
## Get all the current records in our ExpandoTable. We can paginate by passing a
## "begin" and "end" params.
##

#set ($rowsCount = $expandoRowLocalService.getRowsCount($accountsTableName, $accountsTableName))
#set ($rows = $expandoRowLocalService.getRows($accountsTableName, $accountsTableName, -1, -1))

#foreach($row in $rows)
##
## Get the classPK of this row.
##

#set ($currentClassPK = $row.getClassPK())

<tr>
<td>${currentClassPK}</td>

#set ($currentFirstName = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "firstName", $currentClassPK, ""))
<td>${currentFirstName}</td>

#set ($currentLastName = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "lastName", $currentClassPK, ""))
<td>${currentLastName}</td>

#set ($currentBalance = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "balance", $currentClassPK, 0.0))
<td align="right">${numberTool.currency($currentBalance)}</td>

#set ($currentModifiedDate = $expandoValueLocalService.getData($accountsTableName, $accountsTableName, "modifiedDate", $currentClassPK, $dateTool.getDate()))
<td>${dateFormatDateTime.format($currentModifiedDate)}</td>

<td>
<a href="${renderUrl}&amp;${namespace}cmd=edit&amp;${namespace}classPK=${currentClassPK}">Edit</a> |
<a href="${renderUrl}&amp;${namespace}cmd=delete&amp;${namespace}classPK=${currentClassPK}">Delete</a>
</td>
</tr>
#end

#if ($rowsCount <= 0)
<tr>
<td colspan="5">No Accounts were found.</td>
</tr>
#end

</table>

# of Accounts: ${rowsCount}
#else
##
## Here we have our input form.
##

<form action="$renderUrl" method="post" name="${namespace}fm10">
<input type="hidden" name="${namespace}classPK" value="${classPK}" />
<input type="hidden" name="${namespace}cmd"
#if ($classPK > 0)
value="update"
#else
value="add"
#end
/>

<table class="lfr-table">
<tr>
<td>First Name:</td>
<td>
<input type="text" name="${namespace}firstName" value="${firstName}" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<input type="text" name="${namespace}lastName" value="${lastName}" />
</td>
</tr>
<tr>
<td>Balance:</td>
<td>
<input type="text" name="${namespace}balance" value="${numberTool.format($balance)}" />
</td>
</tr>
</table>

<br />

<input type="submit" value="Save" />
<input type="button" value="Cancel" onclick="self.location = '${renderUrl}'" />
</form>
#end

<br /><br />

Merging two sorted arrays - Big O (n+m) time complexity

 Problem :  Merge the two sorted arrays. Edge case :  Array can empty Arrays can be in different size let getMaxLength = ( input1 , input...