Skip to content

Commit 3ccbc5f

Browse files
committed
Added geo functions and some more commands
see README
1 parent f16889f commit 3ccbc5f

20 files changed

Lines changed: 577 additions & 26 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ proxies
1717

1818
.mendix-cache
1919
.settings
20-
.svn
20+
.svn

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Redis has built-in replication, Lua scripting, LRU eviction, transactions and di
2424
* check the unit tests for example implementations
2525
Once you have imported the RedisConnector module in your mendix application, you will have *Redis connector* available in the Toolbox.
2626

27-
It supports now 8 actions *LPUSH*, *RPUSH*, *LRANGE*, *DEL*, *HSET*, *HMGETALL*, *HMGET*, *HMSET* and more to come!
27+
It supports now 15 commands *AddGeoPosition*, *AddMultipleGeoPositions*, *AddValueAtBegin*, *AddValueAtEnd*, *AddValueToSortedList*, *DeleteFromSortedList*, *DeleteKey*, *GetAllHashMaps*, *GetGeoHash*, *GetGeoPosition*, *GetGeoPositions*, *GetHashMap*, *GetValues*, *RedisDestroy*, *SetHashMap*, *SetMultipleHasmaps* and more to come!
28+
2829
In order to use any of these in your Mendix application, you can just drag and drop them to your microflow.
2930
Next step would be to provide all the arguments to the selected action and choose the output result name.
3031

@@ -50,3 +51,4 @@ Licensed under the Apache license.
5051

5152
# Version history
5253
0.1 first commands for Redis implemented
54+
0.2 added a few commands for geo and some more, see https://redis.io/commands/geoadd

RedisConnector.mpr

0 Bytes
Binary file not shown.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This file was generated by Mendix Modeler.
2+
//
3+
// WARNING: Only the following code will be retained when actions are regenerated:
4+
// - the import list
5+
// - the code between BEGIN USER CODE and END USER CODE
6+
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
7+
// Other code you write will be lost the next time you deploy the project.
8+
// Special characters, e.g., é, ö, à, etc. are supported in comments.
9+
10+
package redisconnector.actions;
11+
12+
import com.mendix.systemwideinterfaces.core.IContext;
13+
import com.mendix.webui.CustomJavaAction;
14+
import redisconnector.impl.RedisConnector;
15+
16+
/**
17+
* GEOADD key longitude latitude member [longitude latitude member ...]
18+
*
19+
* Available since 3.2.0.
20+
* Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set.
21+
* Adds the specified geospatial items (latitude, longitude, name) to the specified key. Data is stored into the key as a sorted set, in a way that makes it possible to later retrieve items using a query by radius with the GEORADIUS or GEORADIUSBYMEMBER commands.
22+
* The command takes arguments in the standard format x,y so the longitude must be specified before the latitude. There are limits to the coordinates that can be indexed: areas very near to the poles are not indexable. The exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following:
23+
* Valid longitudes are from -180 to 180 degrees.
24+
* Valid latitudes are from -85.05112878 to 85.05112878 degrees.
25+
* The command will report an error when the user attempts to index coordinates outside the specified ranges.
26+
* Note: there is no GEODEL command because you can use ZREM in order to remove elements. The Geo index structure is just a sorted set.
27+
*/
28+
public class AddGeoPosition extends CustomJavaAction<Boolean>
29+
{
30+
private String Key;
31+
private java.math.BigDecimal Latitude;
32+
private java.math.BigDecimal Longitude;
33+
private String Name;
34+
35+
public AddGeoPosition(IContext context, String Key, java.math.BigDecimal Latitude, java.math.BigDecimal Longitude, String Name)
36+
{
37+
super(context);
38+
this.Key = Key;
39+
this.Latitude = Latitude;
40+
this.Longitude = Longitude;
41+
this.Name = Name;
42+
}
43+
44+
@Override
45+
public Boolean executeAction() throws Exception
46+
{
47+
// BEGIN USER CODE
48+
RedisConnector redisconnector = new RedisConnector();
49+
50+
double LatitudeConverted = Latitude.doubleValue();
51+
double LongitudeConverted = Longitude.doubleValue();
52+
53+
redisconnector.geoadd(Key, LatitudeConverted, LongitudeConverted, Name);
54+
return true;
55+
// END USER CODE
56+
}
57+
58+
/**
59+
* Returns a string representation of this action
60+
*/
61+
@Override
62+
public String toString()
63+
{
64+
return "AddGeoPosition";
65+
}
66+
67+
// BEGIN EXTRA CODE
68+
// END EXTRA CODE
69+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// This file was generated by Mendix Modeler.
2+
//
3+
// WARNING: Only the following code will be retained when actions are regenerated:
4+
// - the import list
5+
// - the code between BEGIN USER CODE and END USER CODE
6+
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
7+
// Other code you write will be lost the next time you deploy the project.
8+
// Special characters, e.g., é, ö, à, etc. are supported in comments.
9+
10+
package redisconnector.actions;
11+
12+
import com.mendix.systemwideinterfaces.core.IContext;
13+
import com.mendix.webui.CustomJavaAction;
14+
import com.mendix.systemwideinterfaces.core.IMendixObject;
15+
16+
public class AddMultipleGeoPositions extends CustomJavaAction<Boolean>
17+
{
18+
private String Key;
19+
private java.util.List<IMendixObject> __GeoPositions;
20+
private java.util.List<redisconnector.proxies.GeoPosition> GeoPositions;
21+
22+
public AddMultipleGeoPositions(IContext context, String Key, java.util.List<IMendixObject> GeoPositions)
23+
{
24+
super(context);
25+
this.Key = Key;
26+
this.__GeoPositions = GeoPositions;
27+
}
28+
29+
@Override
30+
public Boolean executeAction() throws Exception
31+
{
32+
this.GeoPositions = new java.util.ArrayList<redisconnector.proxies.GeoPosition>();
33+
if (__GeoPositions != null)
34+
for (IMendixObject __GeoPositionsElement : __GeoPositions)
35+
this.GeoPositions.add(redisconnector.proxies.GeoPosition.initialize(getContext(), __GeoPositionsElement));
36+
37+
// BEGIN USER CODE
38+
throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Java action was not implemented");
39+
// END USER CODE
40+
}
41+
42+
/**
43+
* Returns a string representation of this action
44+
*/
45+
@Override
46+
public String toString()
47+
{
48+
return "AddMultipleGeoPositions";
49+
}
50+
51+
// BEGIN EXTRA CODE
52+
// END EXTRA CODE
53+
}

javasource/redisconnector/actions/LPUSH.java renamed to javasource/redisconnector/actions/AddValueAtBegin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
* 2) "world"
3434
* redis>
3535
*/
36-
public class LPUSH extends CustomJavaAction<Long>
36+
public class AddValueAtBegin extends CustomJavaAction<Long>
3737
{
3838
private String Key;
3939
private String Value;
4040

41-
public LPUSH(IContext context, String Key, String Value)
41+
public AddValueAtBegin(IContext context, String Key, String Value)
4242
{
4343
super(context);
4444
this.Key = Key;
@@ -60,7 +60,7 @@ public Long executeAction() throws Exception
6060
@Override
6161
public String toString()
6262
{
63-
return "LPUSH";
63+
return "AddValueAtBegin";
6464
}
6565

6666
// BEGIN EXTRA CODE

javasource/redisconnector/actions/RPUSH.java renamed to javasource/redisconnector/actions/AddValueAtEnd.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
* 2) "world"
3333
* redis>
3434
*/
35-
public class RPUSH extends CustomJavaAction<Long>
35+
public class AddValueAtEnd extends CustomJavaAction<Long>
3636
{
3737
private String Key;
3838
private String Value;
3939

40-
public RPUSH(IContext context, String Key, String Value)
40+
public AddValueAtEnd(IContext context, String Key, String Value)
4141
{
4242
super(context);
4343
this.Key = Key;
@@ -59,7 +59,7 @@ public Long executeAction() throws Exception
5959
@Override
6060
public String toString()
6161
{
62-
return "RPUSH";
62+
return "AddValueAtEnd";
6363
}
6464

6565
// BEGIN EXTRA CODE
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This file was generated by Mendix Modeler.
2+
//
3+
// WARNING: Only the following code will be retained when actions are regenerated:
4+
// - the import list
5+
// - the code between BEGIN USER CODE and END USER CODE
6+
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
7+
// Other code you write will be lost the next time you deploy the project.
8+
// Special characters, e.g., é, ö, à, etc. are supported in comments.
9+
10+
package redisconnector.actions;
11+
12+
import com.mendix.systemwideinterfaces.core.IContext;
13+
import com.mendix.webui.CustomJavaAction;
14+
15+
public class AddValueToSortedList extends CustomJavaAction<Boolean>
16+
{
17+
private String Member;
18+
private Long Score;
19+
20+
public AddValueToSortedList(IContext context, String Member, Long Score)
21+
{
22+
super(context);
23+
this.Member = Member;
24+
this.Score = Score;
25+
}
26+
27+
@Override
28+
public Boolean executeAction() throws Exception
29+
{
30+
// BEGIN USER CODE
31+
throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Java action was not implemented");
32+
// END USER CODE
33+
}
34+
35+
/**
36+
* Returns a string representation of this action
37+
*/
38+
@Override
39+
public String toString()
40+
{
41+
return "AddValueToSortedList";
42+
}
43+
44+
// BEGIN EXTRA CODE
45+
// END EXTRA CODE
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file was generated by Mendix Modeler.
2+
//
3+
// WARNING: Only the following code will be retained when actions are regenerated:
4+
// - the import list
5+
// - the code between BEGIN USER CODE and END USER CODE
6+
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
7+
// Other code you write will be lost the next time you deploy the project.
8+
// Special characters, e.g., é, ö, à, etc. are supported in comments.
9+
10+
package redisconnector.actions;
11+
12+
import com.mendix.systemwideinterfaces.core.IContext;
13+
import com.mendix.webui.CustomJavaAction;
14+
import redisconnector.impl.RedisConnector;
15+
16+
public class DeleteFromSortedList extends CustomJavaAction<Long>
17+
{
18+
private String Key;
19+
private String Member;
20+
21+
public DeleteFromSortedList(IContext context, String Key, String Member)
22+
{
23+
super(context);
24+
this.Key = Key;
25+
this.Member = Member;
26+
}
27+
28+
@Override
29+
public Long executeAction() throws Exception
30+
{
31+
// BEGIN USER CODE
32+
RedisConnector redisconnector = new RedisConnector();
33+
return redisconnector.zrem(Key, Member);
34+
// END USER CODE
35+
}
36+
37+
/**
38+
* Returns a string representation of this action
39+
*/
40+
@Override
41+
public String toString()
42+
{
43+
return "DeleteFromSortedList";
44+
}
45+
46+
// BEGIN EXTRA CODE
47+
// END EXTRA CODE
48+
}

javasource/redisconnector/actions/DEL.java renamed to javasource/redisconnector/actions/DeleteKey.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
* (integer) 2
3131
* redis>
3232
*/
33-
public class DEL extends CustomJavaAction<Long>
33+
public class DeleteKey extends CustomJavaAction<Long>
3434
{
3535
private String Key;
3636

37-
public DEL(IContext context, String Key)
37+
public DeleteKey(IContext context, String Key)
3838
{
3939
super(context);
4040
this.Key = Key;
@@ -55,7 +55,7 @@ public Long executeAction() throws Exception
5555
@Override
5656
public String toString()
5757
{
58-
return "DEL";
58+
return "DeleteKey";
5959
}
6060

6161
// BEGIN EXTRA CODE

0 commit comments

Comments
 (0)