Skip to content

The Dozer RETS Client is java library used to access data on RETS compliant servers.

License

Notifications You must be signed in to change notification settings

vangulo-trulia/dozer-rets-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dozer-rets-client

The Dozer RETS Client is java library used to access data on RETS compliant servers.

Simple example of a search:

public static void main(String[] args) throws MalformedURLException {

	//Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability)
	RetsHttpClient httpClient = new CommonsHttpClient();
	RetsVersion retsVersion = RetsVersion.RETS_1_7_2;
	String loginUrl = "http://theurloftheretsserver.com";

	//Create a RetesSession with RetsHttpClient
	RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion);    

	String username = "username";
	String password = "password";

	//Set method as GET or POST
	session.setMethod("POST");
	try {
		//Login
		session.login(username, password);
	} catch (RetsException e) {
		e.printStackTrace();
	}

	String sQuery = "(Member_num=.ANY.)";
	String sResource = "Property";
	String sClass = "Residential";

	//Create a SearchRequest
	SearchRequest request = new SearchRequest(sResource, sClass, sQuery);

	//Select only available fields
	String select ="field1,field2,field3,field4,field5";
	request.setSelect(select);

	//Set request to retrive count if desired
	request.setCountFirst();

	SearchResultImpl response;
	try {
		//Execute the search
		response= (SearchResultImpl) session.search(request);

		//Print out count and columns
		int count = response.getCount();
		System.out.println("COUNT: " + count);
		System.out.println("COLUMNS: " + StringUtils.join(response.getColumns(), "\t"));

		//Iterate over, print records
		for (int row = 0; row < response.getRowCount(); row++){
			System.out.println("ROW"+ row +": " + StringUtils.join(response.getRow(row), "\t"));
		}
	} catch (RetsException e) {
		e.printStackTrace();
	} 
	finally {
		if(session != null) { 
			try {
				session.logout(); 
			} 
			catch(RetsException e) {
				e.printStackTrace();
			}
		}
	}

License

Dozer RETS Client is licensed under the MIT License

About

The Dozer RETS Client is java library used to access data on RETS compliant servers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages