+ tous les champs generiques

This commit is contained in:
nicobo 2012-11-10 08:56:11 +01:00
parent 0a9b396782
commit 8c9c29ede1
25 changed files with 154 additions and 18 deletions

14
bin/AndroidManifest.xml Normal file
View file

@ -0,0 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="groomservice.dataprovence"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
</application>
</manifest>

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/dataprovence.jar Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package groomservice.dataprovence;
public final class BuildConfig {
public final static boolean DEBUG = true;
}

View file

@ -0,0 +1,47 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package groomservice.dataprovence;
public final class R {
public static final class attr {
}
public static final class drawable {
public static int ic_launcher=0x7f020000;
}
public static final class string {
public static int app_name=0x7f030000;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
API 11 theme customizations can go here.
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
API 14 theme customizations can go here.
*/
public static int AppBaseTheme=0x7f040000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static int AppTheme=0x7f040001;
}
}

View file

@ -0,0 +1,30 @@
package bma.groomservice.data;
public class Filter {
/** opérateur */
public String op;
/** Nom du filtre */
public String name;
/** Valeur à appliquer au filtre */
public Object value;
public Filter(String op, String name, Object value) {
super();
this.op = op;
this.name = name;
this.value = value;
}
public static Filter eq(String name, Object valeur) {
return new Filter("eq", name, valeur);
}
public static Filter lt(String name, double borneSup) {
return new Filter("lt", name, String.valueOf(borneSup));
}
public static Filter gt(String name, double borneInf) {
return new Filter("gt", name, String.valueOf(borneInf));
}
}

View file

@ -2,18 +2,48 @@ package bma.groomservice.data;
public class Poi {
/** Ex: "65c6fb5e-aa10-4711-8002-74d1ec31f9d6" */
public String entityid;
/** Ex: "La Galinière - Mercure" */
public String raisonsociale;
/** Ex: "04 42 20 21 51" */
public String tlphone;
/**
* Ex:
* "http://www.restaurantlagaliniere.fr↵http://www.hotelmercureaixsaintevictoire.fr "
*/
public String adresseWeb;
/** Ex: "43.4896481" */
public double latitude;
/** Ex: "5.5689422" */
public double longitude;
/** Ex: "0402648822_0000000000" */
public String PartitionKey;
/** Ex: "1fb5e5aa-6385-4eae-b350-df0c50bbb94c" */
public String RowKey;
/** Ex: "2012-10-04T06:53:42.4684973Z" */
public String Timestamp;
/** Ex: "CHATEAUNEUF LE ROUGE" */
public String bureaudistributeur;
/** Ex: "13790"" */
public String codepostal;
/** Ex: "cdt:Restaurant" */
public String type;
/** Ex: "Châteauneuf le Rouge" */
public String ville;
/** Ex: "RD7" */
public String voie;
@Override
public String toString() {
return "Poi [entityid=" + entityid + ", raisonsociale=" + raisonsociale
+ ", tlphone=" + tlphone + ", adresseWeb=" + adresseWeb
+ ", latitude=" + latitude + ", longitude=" + longitude + "]";
+ ", latitude=" + latitude + ", longitude=" + longitude
+ ", PartitionKey=" + PartitionKey + ", RowKey=" + RowKey
+ ", Timestamp=" + Timestamp + ", bureaudistributeur="
+ bureaudistributeur + ", codepostal=" + codepostal + ", type="
+ type + ", ville=" + ville + ", voie=" + voie + "]";
}
}

View file

@ -3,8 +3,9 @@ package bma.groomservice.data.dataprovence;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.Map;
import java.util.Collection;
import bma.groomservice.data.Filter;
import bma.groomservice.data.PoiList;
/**
@ -28,7 +29,7 @@ public class DataprovenceFileHelper extends DataprovenceHelper {
}
@Override
protected PoiList parse(Map<String, Object> filters) throws IOException,
protected PoiList parse(Collection<Filter> filters) throws IOException,
ParseException {
InputStream fis = null;
try {

View file

@ -7,12 +7,13 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import bma.groomservice.data.Filter;
import bma.groomservice.data.Poi;
import bma.groomservice.data.PoiList;
@ -24,10 +25,10 @@ public class DataprovenceHelper {
private final String rootUrl;
private final String datasetName;
private final Map<String, Object> filters;
private final Collection<Filter> filters;
public DataprovenceHelper(String rootUrl, String datasetName,
Map<String, Object> filters) {
Collection<Filter> filters) {
this.rootUrl = rootUrl;
this.datasetName = datasetName;
this.filters = filters;
@ -68,10 +69,10 @@ public class DataprovenceHelper {
return all;
}
protected PoiList parse(Map<String, Object> filters)
throws IOException, ParseException {
protected PoiList parse(Collection<Filter> filters) throws IOException,
ParseException {
Map<String, Object> ff = filters;
Collection<Filter> ff = filters;
if (ff == null) {
ff = this.filters;
}
@ -79,10 +80,15 @@ public class DataprovenceHelper {
StringBuilder surl = new StringBuilder(rootUrl + "/" + datasetName
+ "?format=json");
if (ff != null) {
for (String filter : filters.keySet()) {
for (Filter filter : filters) {
// ex : filter = "type" -> value = "cdt:Restaurant"
surl.append("&$filter=eq%20'").append(filters.get(filter))
.append("'");
surl.append("&$filter=").append(filter.op).append("%20");
if (filter.value instanceof String) {
surl.append("'").append(filter.value).append("'");
} else {
surl.append(filter.value);
}
}
}
@ -102,8 +108,8 @@ public class DataprovenceHelper {
}
}
public List<Poi> find(Map<String, Object> filters)
throws IOException, ParseException {
public List<Poi> find(Collection<Filter> filters) throws IOException,
ParseException {
PoiList gl = parse(filters);
return Arrays.asList(gl.d);
}

View file

@ -1,14 +1,15 @@
package bma.groomservice.data.dataprovence;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import bma.groomservice.data.Filter;
import bma.groomservice.data.Poi;
public class DataprovenceParserTest extends TestCase {
@ -16,8 +17,8 @@ public class DataprovenceParserTest extends TestCase {
Logger logger = LoggerFactory.getLogger(DataprovenceParserTest.class);
public void testRestaurantsGastronomiques() {
Map<String, Object> filters = new HashMap<String, Object>();
filters.put("type", "cdt:Restaurant");
Collection<Filter> filters = new ArrayList<Filter>();
filters.add(Filter.eq("type", "cdt:Restaurant"));
try {
// DataprovenceHelper parser = new DataprovenceHelper(
// "RestaurantsGastronomiques");