package com.anand.model;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import org.json.JSONException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
public class Test {
public static void main(String[] args) throws JsonProcessingException, JSONException {
ArrayList dataList = buildData();
ArrayList uniqueList = getUniqueList(dataList);
ArrayList> response = buildResponse(uniqueList);
response = buildCompleteResponse(dataList, uniqueList, response);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(response);
System.out.println(json);
}
private static ArrayList> buildCompleteResponse(ArrayList dataList,
ArrayList uniqueList, ArrayList> response) {
for (int i = 0; i < dataList.size(); i++) {
int poistion = i;
int mtd = dataList.get(i).getMTD() > 0 ? response.get(poistion).get(0).getMTD() + 1
: response.get(poistion).get(0).getMTD() + 0;
response.get(poistion).get(0).setMTD(mtd);
int ytd = dataList.get(i).getYTD() > 0 ? response.get(poistion).get(0).getYTD() + 1
: response.get(poistion).get(0).getYTD() + 0;
response.get(poistion).get(0).setYTD(ytd);
int inflight = dataList.get(i).getIN_FLIGHT() > 0 ? response.get(poistion).get(0).getIN_FLIGHT() + 1
: response.get(poistion).get(0).getIN_FLIGHT() + 0;
response.get(poistion).get(0).setIN_FLIGHT(inflight);
response.get(poistion).get(0).setName(dataList.get(i).getName());
response.get(poistion).get(0).getNFIDArray().add(dataList.get(i).getNFID());
}
return response;
}
public static ArrayList getUniqueList(ArrayList dataList) {
ArrayList uniqueList = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
uniqueList.add(dataList.get(i).getName());
}
Set uniqueSet = new HashSet(uniqueList);
ArrayList mainList = new ArrayList();
mainList.addAll(uniqueSet);
return mainList;
}
public static ArrayList> buildResponse(ArrayList uniqueList) {
ArrayList> response = new ArrayList<>();
for (int i = 0; i < uniqueList.size(); i++) {
Values values = new Values();
ArrayList valueList = new ArrayList();
ArrayList nfidLsit = new ArrayList();
values.setNFIDArray(nfidLsit);
valueList.add(values);
response.add(valueList);
}
return response;
}
public static ArrayList buildData() {
ArrayList dataList = new ArrayList<>();
for (int i = 0; i <10000; i++) {
dataList.add(new Data("SA", "Design"+i, "2000"+i, 1, 0, 1, 1, 0, 1));
}
return dataList;
}
}
Apache Tomcat is an open source web server used to deploy and serve JavaServer Pages (JSP) and Java servlets.
Pre-Flight Check
- These instructions are intended specifically for installing Apache Tomcat 8 on Ubuntu 12.04.
- I’ll be working from a Liquid Web Core Managed Ubuntu 12.04 server, and I’ll be logged in as root.
- As of the publication of this tutorial Apache Tomcat 8 is in beta. To install a production version visit our tutorial oninstalling Apache Tomcat 7.
Step 1: Install Tomcat from Binary
First, head-on-over to the Apache Tomcat 8 Download site.
Then, under the heading 8.0.5 (the current version as of May 2014), or whichever is the newest version at the time you read this article, you’ll see Binary Distributions . Under Binary Distributions you’ll see Core and then tar.gz . Right click on tar.gz and copy the URL.
From your server, download Apache Tomcat 8 from the URL you copied in the previous step:
wget http://mirrors.ibiblio.org/apache/tomcat/tomcat-8/v8.0.5/bin/apache-tomcat-8.0.5.tar.gz
Alternatively, if you download the file to your local desktop, you’ll want to transfer the file to your Liquid Web server. If you need help with that, check out this article: Using SFTP and SCP Instead of FTP
After the download completes, decompress the file:
tar xvzf apache-tomcat-8.0.5.tar.gz
Now, move the file into a proper location:
mv apache-tomcat-8.0.5 /opt/tomcat
Step 2: Install Java 7
Before you can use Tomcat you’ll have to install the Java Development Kit (JDK) 7. First let’s check to see if Java is installed:
java -version
If that returns the following then Java hasn’t yet been installed:
The program 'java' can be found in the following packages:
To install Java, simply run the following command (and at the prompt enter Y to continue):
apt-get install openjdk-7-jdk
Step 3: Configure .bashrc
Now let’s set the environment variables in .bashrc:
vim ~/.bashrc
Note: If you have questions about Vim, check out our new user tutorial on Vim!
Add this information to the end of the file:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export CATALINA_HOME=/opt/tomcat
Simply save and exit .bashrc, then make the changes effective by running the following command:
. ~/.bashrc
Step 4: Test Run
Tomcat and Java should now be installed and configured on your server. To activate Tomcat, run the following script:
$CATALINA_HOME/bin/startup.sh
You should get a result similar to:
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-amd64/
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.
Verify that Tomcat is working by visiting the_IP_of_your_server:8080. For example: http://127.0.0.1:8080














.jpg)












