Wednesday, August 16, 2017

SonarQube for code review

Sonar Qube is code review tool available in market for different language like java,javascript, C#, C, Cobol.
SonarQube is capable enough to show the health of an application and also highlight issues and risk introduced into the project due to new code/existing code merge.. With help of Sonar Qube we can improve code quality systematically.
To use SonarQube we need to follow below given steps. This include setup of SonarQube Server on local Machine along with Eclipse plugin to analysis the code.

Step 1:- How to do setup of SonarQube Server on Localhost.
Please refer to https://www.sonarqube.org/#_ and click on Dowload icon and select the latest version of SonarQube. While writing this blog we had 6.5 version as the laterst one. Extract the sonarqube-6.5.zip and move to the bin folder C:\sonarqube-6.5\sonarqube-6.5\bin.
Here we will find many subfolder that contains *.sh and *.bat file to start server in different O/S. As we are using windows-x86-64 move inside C:\sonarqube-6.5\sonarqube-6.5\bin\windows-x86-64 and execute following command.
C:\sonarqube-6.5\sonarqube-6.5\bin\windows-x86-64>StartSonar.bat
.......
jvm 1 | 2017.08.16 13:42:58 INFO app[][o.s.a.SchedulerImpl] SonarQube is up
Above line indicate that our server is started on local host @ port 9000. Cross verify https://localhost:9000 and u will be able to see this screen. Click on Login and use default userid and passwrod admin/admin to get logged into the SonarQube server.

Image1Image2
Step 2:- Performing Code Analysing using Eclipse Plug in for SonarLite
As a java developer we generally prefer Eclipse IDE. Eclipse come with many plugin for development one of them is sonar Qube. We can install this plugin from below given loacation
https://marketplace.eclipse.org/content/sonarlint
Once the plugin is installed in the Eclipse restart it and reconfirm successful installtion by checking availability of option Window-->preference->SolarLit
Image3
Step 3:- configure the Sonar server in eclipse
Lets now configure our Local host server inside Eclipse SolanLite Plugin. To do this Create a new SolarQube server using eclipse "File -> New -> Other... -> SonarLint -> New Server".
Here we had two option
1- Cloude
2- using Local host
Chose option 2 and follow below steps

Image5Image4Image6
It will ask you for Token or User+password. If we chose to use Token by generating token from follwing below screen of our localhost SonarQube server.
Image7
Or we can directly use userid and password admin/admin to configure Localhost SonarQube server.

Image8Image9Image10
Step 4:- Run the sonar Plugin and modify the code.
Now we are ready to run the sonarQube code analyser on our code. Right click on the java file and find/modify the leak code .
Image11Image12

Monday, August 14, 2017

Apache Solr

Apache Solr is server provided by Apache Community for having better and quick serach of document at the server side.Solr enables you to easily create search engines which searches websites, databases and files.
To understand the concept of Apache Solr lets try to install it.
Step 1:- Download Solr server from below given location
http://lucene.apache.org/solr/mirrors-solr-latest-redir.html
Step 2:- Extract the solr-6.6.0.zip file
Step 3:- Start the server using following command i.e. here we are keeping our project name as siddhuapachesolrproject
C:\solr-6.6.0\solr-6.6.0\bin\solr -e siddhuapachesolrproject
Step 4:- Now lets try to see how our Newly created Apache Solr server helps us in searing the documents. For this lets try to index one the file on the server.
If we see the C:\solr-6.6.0\solr-6.6.0\example\exampledocs folder we will find there are many *.xml, *.pdf, *.cvs files are kept for testing and demo purpose. We will index one of the *.xml into our Apache solr server.
This can be done using post.jar which is provided by Apache Solr server inside exampledocs folder. Execute following command
C:\solr-6.6.0\solr-6.6.0\example\exampledocs>java -Dc=techproducts -jar post.jar sd500.xml
Now we can confirm if our server is able to find this file using following command
http://localhost:8983/solr/siddhuapachesolrproject/select?q=sd500&wt=json

Now lets try to use java code to perform indexing and finding the text from the Apache Solr
Use following java code to upload or indexing the file on Apache Solr
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.common.SolrInputDocument;
import java.io.IOException;
public class SiddhuUploadFile {
public static void main(String[] args) throws IOException, SolrServerException {
SolrClient client = new HttpSolrClient.Builder("http://localhost:8983/solr/siddhuapachesolrproject").build();
for(int i=0;i<1000 i="" span="">
SolrInputDocument doc = new SolrInputDocument();
doc.addField("cat", "book");
doc.addField("id", "book-" + i);
doc.addField("name", "The Legend of the Hobbit part " + i);
client.add(doc);
if(i%100==0) client.commit(); // periodically flush
}
client.commit();
}
}

And use below code to find the perticular file from Apache Solr
import java.io.IOException;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;
public class SiddhuSearchFile {
public static void main(String[] args) throws IOException, SolrServerException {
SolrClient client = new HttpSolrClient.Builder("http://localhost:8983/solr/techproducts").build();
SolrQuery query = new SolrQuery();
query.setQuery("Canon PowerShot SD500");
query.addFilterQuery("cat:electronics","manu_id_s:canon");
query.setFields("id","price","cat","store");
query.setStart(0);
query.set("defType", "edismax");
QueryResponse response = client.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
System.out.println(results.get(i));
}
}
}

Project

You can find all the required jar  inside solr-6.6.0.zip folder which we had downloaded to setup the server.
C:\solr-6.6.0\solr-6.6.0\dist\solrj-lib
Note:- To Shutdown the server use following command
bin/solr stop
- You can learn different Query Syntex of Lucene for finding and searching the file on Apache Solr server.

Monday, June 19, 2017

How to export data to excel in OutSystem

Step 1:- Create a link and add Destination as a new action to the it

Image1

Step 2:- Double click on Action and have your work flow as shown below

Image2

Step 3:- click on Excel icon in work Flow and fill the parameter as shown below

Image3

Step 4:- Click on download icon in Work flow and fill the parameter as shown below


Image4


Step 5:- Run the appication and click on the link and excel will be downloaded to your system

Image5Image6

How to Create Graph in Outsystem

Step 1:- To create a graph we need to create a list i.e. collection of record on which we want to plot the graph
Step 2:- Lets assum we want to crate a graph on our Employees List Screen.
- Create a Container component
- Create local Varable and name it as saaryGraph
- Make sure to give the Data Type as Employee List
Image1Image2
Step 3:- Create a graph i.e. we are creating bar chart select Column Chart

Image3
Step 4:- click on the bar cart window and fill parameter as shown below
Image4
Step 5:- Run the application and see the graph displayed on the screenImage5

Thursday, June 15, 2017

Calling SOAP Web Service API Example using Outsystem Application

Step 1:- Create One text field and button as shown in the above screen
Step 2:- Create Destination as shown in the below figure
Image6
Step 3:- Go to logic and create a new SOAP Service as shown in the below figure.
Image1Image2Image3
Step 4:- Double click on the button and keep your button Flow diagram as shown below i.e. drag drop our SOAP Method to flow and assign the output to variable we had assigned to Text field.
Image4
Step 5:- Compile and run the application
Image5

Calling REST API Example using Outsystem

Step 1:- Create One text field and button as shown in the above screen
Image1
Step 2:- Create Destination as shown in the below figure
Image2
Step 3:- Go to logic and create a new REST Service as shown in the below figure.


Image3Image4Image5Image6
Step 4:- Double click on the button and keep your button Flow diagram as shown below i.e. drag drop our REST Method to flow and assign the output to variable we had assinged to Text field.

Image7
Step 5:- Compile and run the application

Image8

OutSystems CRUD Operation Example

Step 1:- Please refer to the below given link before starting the application

http://siddharathadhumale.blogspot.in/2017/06/addition-of-two-value-in-outsystems.html

Step 2:- We are going to add a button that will move us to a screen that will perform CRUD operation
Step 3:- Goto Data Tab and right click and create a table ie Employee
Image1
Step 4:- Create necessary Field in that table, Note:- By default we will have ID as a PK in the table ready.
Image2
Step 5: - Click on Main flow and Drag and drop List and Detail Screen and select Employee option as shown in below figure.

Image3Image4
Step 6:- Lets add back button on the Screen that will navigate us to Home page

Image5
Step 7:- Click on Back Button and add this to it

Image6

Wednesday, June 14, 2017

Addition of two value in outsystems application

Step1:- Create your login in outsystems
Step 2:- Download Environment IDE from the site. i.e. https://www.outsystems.com/home
Step 3:- Install the new exe DevelopmentEnvironment-10.0.502.0.exe to your system
Step 4:- Login to IDE and input your Environment name i.e. abc-xyz.outsystemscloud.com and use your login credential to get access your Development Environment on cloud.
Step 5:- Click on Home screen icon shown in below image.
Image1Image2
Step 6:- Create your Addition of two value programe using inbuild component like Label, Textfield, Button as shown in below image

Image3
Step 7:- Make sure to assign local variable to your Textfield. This Local variable is used to identify out component by applications.

Image4Image5Image6Image7
Step 8:- Double click on Add button and used Assign component in flow, and see the right hand side below component to apply logic


Image8
Note:- Dont Forget to make your Var1,Var2 and Var3 Interger else value be concatinated.


Image10Image9