1 package com.terradue.jcatalogue.client.internal.digester;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import static com.terradue.jcatalogue.client.internal.digester.Namespaces.ATOM;
20 import static com.terradue.jcatalogue.client.internal.digester.Namespaces.GML;
21
22 import org.apache.commons.digester3.binder.AbstractNamespaceURIBasedRulesModule;
23
24 import com.terradue.jcatalogue.client.DataSet;
25 import com.terradue.jcatalogue.client.geo.Box;
26 import com.terradue.jcatalogue.client.geo.Line;
27 import com.terradue.jcatalogue.client.geo.Point;
28 import com.terradue.jcatalogue.client.geo.Polygon;
29
30
31
32
33 public final class SingleDataSetRulesModule
34 extends AbstractNamespaceURIBasedRulesModule
35 {
36
37 public SingleDataSetRulesModule()
38 {
39 super( ATOM );
40 }
41
42 @Override
43 protected void configure()
44 {
45 forPattern( "feed" ).createObject().ofType( DataSet.class );
46 forPattern( "feed/title" ).setBeanProperty();
47 forPattern( "feed/subtitle" ).setBeanProperty();
48 forPattern( "feed/id" ).setBeanProperty();
49
50 forPattern( "feed/entry/published" ).setBeanProperty();
51 forPattern( "feed/entry/updated" ).setBeanProperty();
52
53 forPattern( "feed/entry/validTime/TimePeriod/beginPosition" )
54 .withNamespaceURI( GML )
55 .setBeanProperty().withName( "beginPosition" );
56 forPattern( "feed/entry/validTime/TimePeriod/endPosition" )
57 .withNamespaceURI( GML )
58 .setBeanProperty().withName( "endPosition" );
59
60 forPattern( "feed/where/Envelope" )
61 .withNamespaceURI( GML )
62 .createObject().ofType( Box.class );
63 forPattern( "feed/where/Envelope/lowerCorner" )
64 .withNamespaceURI( GML )
65 .setBeanProperty().withName( "lowerCorner" );
66 forPattern( "feed/where/Envelope/upperCorner" )
67 .withNamespaceURI( GML )
68 .setBeanProperty().withName( "upperCorner" );
69 forPattern( "feed/where/LineString/posList" )
70 .withNamespaceURI( GML )
71 .addRuleCreatedBy( new SetGeoDataLocationRule.Factory( Line.class ) );
72 forPattern( "feed/where/Polygon/exterior/LinearRing/posList" )
73 .withNamespaceURI( GML )
74 .addRuleCreatedBy( new SetGeoDataLocationRule.Factory( Polygon.class ) );
75 forPattern( "feed/where/Point/pos" )
76 .withNamespaceURI( GML )
77 .addRuleCreatedBy( new SetGeoDataLocationRule.Factory( Point.class ) );
78
79 forPattern( "feed/entry/link" ).callMethod( "addLink" )
80 .withParamTypes( String.class, String.class, String.class, Integer.class )
81 .then()
82 .callParam()
83 .fromAttribute( "rel" )
84 .ofIndex( 0 )
85 .then()
86 .callParam()
87 .fromAttribute( "type" )
88 .ofIndex( 1 )
89 .then()
90 .callParam()
91 .fromAttribute( "href" )
92 .ofIndex( 2 )
93 .then()
94 .addRuleCreatedBy( new PriorityParamRule.PriorityParamRuleProvider( 3 ) );
95 }
96
97 }