Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/poppa/java-lime-pro

A Java interface to the web services of the CRM Lime PRO
https://github.com/poppa/java-lime-pro

Last synced: 12 days ago
JSON representation

A Java interface to the web services of the CRM Lime PRO

Awesome Lists containing this project

README

        

java-lime-pro
=============

A Java helper module for the web services of the CRM **Lime PRO** by
[Lundalogik](https://github.com/lundalogik).

There's a [PHP version](https://github.com/poppa/php-lime-pro) and a
[C# version](https://github.com/poppa/csharp-lime-pro) of this module
as well.

This is not a full Lime PRO client but rather a helper module for building the
XML queries to send to Lime as well as parsing the result. There is however
a [sample client](https://github.com/poppa/java-lime-pro/blob/master/src/se/poppanator/lime/SampleClient.java)
using [Metro](https://metro.java.net/).

## Buildning an XML query

The easiest way to build a Lime XML query is by using the SQL to XML class. It
takes an SQL query and converts it into a [Node](https://github.com/poppa/java-lime-pro/blob/master/src/se/poppanator/lime/xml/Node.java)
object.

```java
import se.poppanator.lime.sql.Parser;
import se.poppanator.lime.xml.Node;

// ...

String sql =
"SELECT DISTINCT\n" +
" idsostype, descriptive, soscategory, soscategory.sosbusinessarea,\n" +
" webcompany, webperson, web, department, name\n" +
"FROM sostype\n" +
"WHERE active='1':numeric AND\n" +
" soscategory.sosbusinessarea != 2701 AND\n" +
" web=1 AND (webperson=1 OR webcompany=1)\n" +
"ORDER BY descriptive, soscategory DESC\n" +
"LIMIT 100";

Node limeQuery = Parser.sql(sql);

String result = myWSClient.getXmlQueryData(limeQuery.toString());
```

The SQL query above will result in an XML document like this:

```xml


sostype



active
1


soscategory.sosbusinessarea
2701


web
1





webperson
1


webcompany
1






idsostype
descriptive
soscategory
soscategory.sosbusinessarea
webcompany
webperson
web
department
name

```

The webservice method `getXmlQueryData` will return a string which is an XML
tree. This XML tree can be passed to the static `Node.parse` method which
will turn the result into a `Node` object which also is an `Iterator` object
so it can easily be traversed.

```java
// ...
String result = myWSClient.getXmlQueryData(limeQuery.toString());
Node res = Node.parse(result);

for (Object child : res) {
HashMap row = ((Node) child).getAttributes();
System.out.println(" * " + row.get("descriptive"));
}
```

\# 2015-06-01