September 30, 2017

Most and longest running software developed for consumerfed

Dear readers,

It has been two and a half years since the application is launched at consumerfed kozhikode region and successfully running in the region at 40 trivenis including mobile , godown, neethi medicasl sections and liquor shop.
The whole credit for developing the software goes to the IT section regional office ( Management trainees) But now consumerfed is planning to reduce the size of Management trainees

A great that to I T Section kozhikode.


The project was launched on March 2015 and last updated on September 2017. Report to mobiles are also available now. Backup s are automated

E mail report
footer
Tracking the sales , subsidy monitoring, tracking hardware details are other key features of the application. Reports in html , pdf formats are available, video tutorials are available in youtube channel.


You can contact us on 0091-8218808029

Join us at linkedin  follow us  Hangout group


Mobile phone cover - Buy one Hurry !!! 


September 27, 2017

How to use same method for different objects in java

/**
 *  Main class
 */
package com.belazy.generics;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author belazy
 * @param <T>
 *
 */
public class GenericMethodClass {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
GenericMethodClass g = new GenericMethodClass();

String type ="type";

Employee emp = new Employee();
Student stud = new Student();
g.returnText(emp, type);
g.returnText(stud, type);

}



public <T> String returnText(T element , String type){
String value = null;
try {
Class thisClass = element.getClass();

type = element.getClass().toString();
Method method = thisClass.getMethod("getName");
System.out.println("method with getName "+method.getName());
System.out.println(method.invoke(element));
if(method.invoke(element).toString().equalsIgnoreCase("type")){
System.out.println("inside if ");
Method method2 = thisClass.getMethod("getText");
System.out.println(method2.invoke(element));
value = method2.invoke(element).toString();
}


} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


System.out.println(type);
return value;


}

}

Student class

/**
 *
 */
package com.belazy.generics;

/**
 * @author belazy
 *
 */
public class Student {

String name = "type";
String text = "Student Type";
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text the text to set
*/
public void setText(String text) {
this.text = text;
}



}

Employee Class

/**
 * 
 */
package com.belazy.generics;

/**
 * @author belazy
 *
 */
public class Employee {
String name = "type";
String text = "employee Type";
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text the text to set
*/
public void setText(String text) {
this.text = text;
}

}


September 25, 2017

Difference between maps in java - Hash and Tree map

/**
 *
 */
package com.belazy.misc;

import java.util.HashMap;
import java.util.TreeMap;

/**
 * @author belazy
 *
 */
public class CollectionMaps {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
CollectionMaps colMap = new CollectionMaps();
colMap.callHashMap();
colMap.callTreeMap();

}

private void callTreeMap() {
// TODO Auto-generated method stub
System.out.println("Inside Tree Map");
TreeMap<Integer, String> studentDetails = new TreeMap<Integer, String>();
studentDetails.put(10, "sachin");
studentDetails.put(7, "jadeja");
studentDetails.put(5, "dhoni");
studentDetails.put(1, "virat");
studentDetails.put(3, "saurav");
System.out.println("data in map "+studentDetails);
System.out.println("reverse order :"+studentDetails.descendingMap());
System.out.println("descending key sets : "+studentDetails.descendingKeySet());
System.out.println("first Entry "+studentDetails.firstEntry());
}

private void callHashMap() {
// TODO Auto-generated method stub
System.out.println("Inside Hash Map");
HashMap<Integer, String> studentDetails = new HashMap<Integer, String>();

studentDetails.put(10, "sachin");
studentDetails.put(7, "jadeja");
studentDetails.put(5, "dhoni");
studentDetails.put(1, "virat");
studentDetails.put(3, "saurav");

System.out.println(studentDetails);


}

}

September 24, 2017

To Loop all dates between a start date and end date in java

/**
 *
 */
package com.belazy.misc;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.joda.time.ReadableInstant;

/**
 * @author belazy
 *
 */
public class DateManipulation {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
DateManipulation dateManip = new DateManipulation();
try {
dateManip.printDateBw("2017-10-01","2017-10-10");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

private void printDateBw(String startDate, String endDate) throws ParseException {

int days = Days.daysBetween(LocalDate.parse(startDate), LocalDate.parse(endDate)).getDays();
System.out.println(days);

SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Date stDate = sd.parse(startDate);
System.out.println(" start date :"+stDate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(startDate)); // parsed date and setting to calendar

for(int i=1;i<=days;i++){

calendar.add(Calendar.DATE, 1);  // number of days to add
String destDate = sd.format(calendar.getTime());  // End date
System.out.println(destDate);

}

}

}


program 2

/**
 *
 */
package com.belazy.misc;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.joda.time.ReadableInstant;

/**
 * @author belazy
 *
 */
public class DateManipulation {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
DateManipulation dateManip = new DateManipulation();
try {
dateManip.printDateBw("2017-10-01","2017-10-10");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

private void printDateBw(String startDate, String endDate) throws ParseException {

int days = Days.daysBetween(LocalDate.parse(startDate), LocalDate.parse(endDate)).getDays();
System.out.println(days);

SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Date stDate = sd.parse(startDate);
System.out.println(" start date :"+stDate);
Calendar calendar = Calendar.getInstance();
// parsed date and setting to calendar

for(int i=0;i<days;i++){
calendar.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(startDate));
calendar.add(Calendar.DAY_OF_YEAR, i);  // number of days to add
String destDate = sd.format(calendar.getTime());  // End date
System.out.println(destDate);

}

}

}


September 22, 2017

Cfed Price wizdul

Created a price wizdul webservice


September 20, 2017

Hotel Supplier Integration Java Design pattern


Hotel Supplier Integration Java Design pattern


Hotel.java

package com.travelport.hotels;

public class Hotel {

String name;
String code;
String chain;
String description;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the chain
*/
public String getChain() {
return chain;
}
/**
* @param chain the chain to set
*/
public void setChain(String chain) {
this.chain = chain;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}



}

Room.java

package com.travelport.hotels;

public class Room {

private String room;
private String code;
private String ph;
/**
* @return the room
*/
public String getRoom() {
return room;
}
/**
* @param room the room to set
*/
public void setRoom(String room) {
this.room = room;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the ph
*/
public String getPh() {
return ph;
}
/**
* @param ph the ph to set
*/
public void setPh(String ph) {
this.ph = ph;
}
}

Mainclass

/**
 *
 */
package com.travelport.hotels;

/**
 * @author belazy
 *
 */
public class MainHotelsClass {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SearchHotels srcH = new SearchHotels();
srcH.searchHotel();
SearchRoom req = new SearchRoom();
req.searchRoom();

}

}


SearchHotels

/**
 * 
 */
package com.travelport.hotels;

/**
 * @author nijesh
 *
 */
public class SearchHotels extends TravelPortAbstract{



/* private Hotel getHotelProperties(Hotel hotel) {
// TODO Auto-generated method stub
hotel.setName("Mariot hotel");
hotel.setCode("ABC");
hotel.setDescription("hotel Desctiption");
hotel.setChain("CH1");
return hotel;
}*/

public void searchHotel() {
// TODO Auto-generated method stub
Hotel hotel = new Hotel();
hotel = getHotelProperties(hotel);
System.out.println("auth: "+isAuthenticated());
System.out.println("code: "+hotel.getCode());
}



}


SearchRoom

/**
 * 
 */
package com.travelport.hotels;

/**
 * @author belazy
 *
 */
public class SearchRoom extends TravelPortAbstract {

public void searchRoom() {
// TODO Auto-generated method stub
Hotel hotel = new Hotel();
Room room = new Room();
hotel = getHotelProperties(hotel);
room = getRoom(room);
System.out.println("room :"+room.getCode());
System.out.println("hotel :"+hotel.getCode());
}



}


TravelPortAbstract class

/**
 * 
 */
package com.travelport.hotels;

/**
 * @author nijesh
 *
 */
public abstract class TravelPortAbstract {
protected Hotel getHotelProperties(Hotel hotel) {
// TODO Auto-generated method stub
hotel.setName("Mariot hotel");
hotel.setCode("ABC");
hotel.setDescription("hotel Desctiption");
hotel.setChain("CH1");
return hotel;
}
protected boolean isAuthenticated(){
return true;
}
protected Room getRoom(Room room) {
// TODO Auto-generated method stub
room.setCode("R12");
room.setRoom("Single bed");
return room;
}

}

https://support.travelport.com/webhelp/uapi/Content/Hotel/Shared_Hotel_Topics/Hotel%20Payment%20Types_Pre-Pay_and_Post-Pay.htm

https://support.travelport.com/webhelp/uapi/Content/Hotel/Hotel_TRM/TRM%20Synchronous%20Hotel%20Search.htm

https://support.travelport.com/webhelp/uapi/Content/Hotel/Shared_Hotel_Topics/Hotel%20Payment%20Types_Guarantee_%20Deposit_Pre-Pay.htm




http://javabelazy.blogspot.in/

September 19, 2017

commit and rollback - transaction management in dbms

Data Base management system

commit and rollback

Commit and rollback maintain the integrety of the transaction

try to update a table name value using update query

update tblProduct set qtyavailable = 200 where  productid = 1;

This database query is not a part of any transaction, as soon as you execute the query the change is made premenant to the datbase immediatly.

then if you execute the select query

Select * from tblProduct

you can see the change is effected in database

but in case of transaction

begin transaction
update tblProduct set qtyavailable = 300 where  productid = 1;

the following change will be made in database. but if you


try to establish a new connection , and run the above select query ... you can see "Executing query"

that becase you just begin the transaction, but not commited , the other users cannot see the uncommited database


that is because, sql server default isolation level is read commit data

set transaction isolation level read uncommited;









September 05, 2017

How to copy one object from another in Java

Converting one object into another in java


Main class


import org.dozer.DozerBeanMapper; /** * @author belazy * */ public class MainClass { public static void main(String[] args) { DozerBeanMapper mapper = new DozerBeanMapper(); mapper.setMappingFiles(Arrays.asList("dozer_mapping.xml")); Employee employee = new Employee("Sachin", "tendulkar", 45); EmployeeNew employeeNew = mapper.map(employee, EmployeeNew.class); System.out.println(employeeNew.getEmployeeFirstName()); } }

EmployeeTest


/** * */ package com.belazy.dozer; /** * @author belazy * */ public class EmployeeTest { private String firstName; private String lastName; private int age; public EmployeeTest(String firstName, String lastName, int age) { // TODO Auto-generated constructor stub this.firstName = firstName; this.lastName = lastName; this.age = age; } /** * @return the firstName */ public String getFirstName() { return firstName; } /** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * @return the lastName */ public String getLastName() { return lastName; } /** * @param lastName the lastName to set */ public void setLastName(String lastName) { this.lastName = lastName; } /** * @return the age */ public int getAge() { return age; } /** * @param age the age to set */ public void setAge(int age) { this.age = age; } }

EmployeeNew class

/** * */ package com.belazy.dozer; /** * @author belazy * */ public class EmployeeNew { private String employeeFirstName; private String employeeLastName; private int employeeAge; public EmployeeNew() { // TODO Auto-generated constructor stub } public EmployeeNew(String employeeFirstName,String employeeLastName, int employeeAge ) { // TODO Auto-generated constructor stub this.employeeAge = employeeAge; this.employeeLastName = employeeLastName; this.employeeFirstName = employeeFirstName; } /** * @return the employeeFirstName */ public String getEmployeeFirstName() { return employeeFirstName; } /** * @param employeeFirstName the employeeFirstName to set */ public void setEmployeeFirstName(String employeeFirstName) { this.employeeFirstName = employeeFirstName; } /** * @return the employeeLastName */ public String getEmployeeLastName() { return employeeLastName; } /** * @param employeeLastName the employeeLastName to set */ public void setEmployeeLastName(String employeeLastName) { this.employeeLastName = employeeLastName; } /** * @return the employeeAge */ public int getEmployeeAge() { return employeeAge; } /** * @param employeeAge the employeeAge to set */ public void setEmployeeAge(int employeeAge) { this.employeeAge = employeeAge; } }

Dozer mapping. xml

<mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://dozer.sourceforge.net" xsi:schemalocation="http://dozer.sourceforge.net
      http://dozer.sourceforge.net/schema/beanmapping.xsd">
    <mapping>
        <class-a>com.belazy.dozer.EmployeeTest</class-a>
        <class-b>com.belazy.dozer.EmployeeNew</class-b>
        <field>
            <a href="https://www.blogger.com/null">firstName</a>
            <b>employeeFirstName</b>
        </field>
        <field>
            <a href="https://www.blogger.com/null">lastName</a>
            <b>employeeLastName</b>
        </field>
        <field>
            <a href="https://www.blogger.com/null">age</a>
            <b>employeeAge</b>
        </field>
    </mapping>
</mappings>




http://www.java2s.com/Open-Source/Java_Free_Code/Tutorial/Download_travelport_uapi_tutorial_Free_Java_Code.htm

htm
http://testws.galileo.com/GWSSample/Help/GWSHelp/java_sample_step_2__booking_an_air_reservation.htm

https://support.travelport.com/webhelp/GWS/Content/Overview/Getting_Started/Sample_Web_Service_Calls/Java_Sample_Step_1__Air_Availability_Request.htm


http://www.galileo.co.kr/document/Galileo%20Web%20Services%20Product%20Overview.pdf

Facebook comments