Skip to content

Commit 107c8fe

Browse files
author
JelteMX
committed
🔥 First setup
0 parents  commit 107c8fe

21 files changed

+649
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The Apache License v2.0
2+
3+
Copyright Jelte Lagendijk <jelte.lagendijk@mendix.com> 2019
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Fake Data Module for Mendix
2+
3+
![Icon](/assets/FakeDataIcon.png)
4+
5+
Want to generate fake data in Mendix? The Fake Data Module for Mendix does this for you. It uses the popular [Faker](https://github.com/DiUS/java-faker) library.
6+
7+
![screenshot](/assets/FakeDataScreenshot1.png)
8+
9+
## Libraries used
10+
11+
- Apache Commons Lang
12+
- Version 3.7
13+
- License: Apache 2.0
14+
- [link](https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.7)
15+
- SnakeYAML
16+
- Version 1.25
17+
- License: Apache 2.0
18+
- [link](https://mvnrepository.com/artifact/org.yaml/snakeyaml/1.25)
19+
- JavaFaker
20+
- Version 1.0.1
21+
- License: Apache 2.0
22+
- [link](https://mvnrepository.com/artifact/com.github.javafaker/javafaker/1.0.1)
23+
24+
## Adding new Java Actions
25+
26+
You can create new Java Actions using the Faker library. See [API docs](http://dius.github.io/java-faker/apidocs/index.html).
27+
28+
## License
29+
30+
Apache 2

assets/FakeDataIcon.png

36.6 KB
Loading

assets/FakeDataScreenshot1.png

20.3 KB
Loading

assets/FakeDataScreenshot2.png

28.8 KB
Loading
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// This file was generated by Mendix Studio Pro.
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 fakedata.actions;
11+
12+
import com.github.javafaker.Faker;
13+
import com.mendix.core.Core;
14+
import com.mendix.systemwideinterfaces.core.IContext;
15+
import com.mendix.webui.CustomJavaAction;
16+
import fakedata.proxies.App;
17+
import com.mendix.systemwideinterfaces.core.IMendixObject;
18+
19+
public class GenerateApp extends CustomJavaAction<IMendixObject>
20+
{
21+
public GenerateApp(IContext context)
22+
{
23+
super(context);
24+
}
25+
26+
@java.lang.Override
27+
public IMendixObject executeAction() throws Exception
28+
{
29+
// BEGIN USER CODE
30+
Faker faker = new Faker();
31+
com.github.javafaker.App app = faker.app();
32+
33+
IMendixObject object = Core.instantiate(getContext(), App.getType());
34+
35+
object.setValue(getContext(), App.MemberNames.Name.toString(), app.name());
36+
object.setValue(getContext(), App.MemberNames.Author.toString(), app.author());
37+
object.setValue(getContext(), App.MemberNames.Version.toString(), app.version());
38+
39+
return object;
40+
// END USER CODE
41+
}
42+
43+
/**
44+
* Returns a string representation of this action
45+
*/
46+
@java.lang.Override
47+
public java.lang.String toString()
48+
{
49+
return "GenerateApp";
50+
}
51+
52+
// BEGIN EXTRA CODE
53+
// END EXTRA CODE
54+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This file was generated by Mendix Studio Pro.
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 fakedata.actions;
11+
12+
import com.github.javafaker.Faker;
13+
import com.mendix.core.Core;
14+
import com.mendix.systemwideinterfaces.core.IContext;
15+
import com.mendix.webui.CustomJavaAction;
16+
import fakedata.proxies.Artist;
17+
import com.mendix.systemwideinterfaces.core.IMendixObject;
18+
19+
public class GenerateArtist extends CustomJavaAction<IMendixObject>
20+
{
21+
public GenerateArtist(IContext context)
22+
{
23+
super(context);
24+
}
25+
26+
@java.lang.Override
27+
public IMendixObject executeAction() throws Exception
28+
{
29+
// BEGIN USER CODE
30+
Faker faker = new Faker();
31+
com.github.javafaker.Artist artist = faker.artist();
32+
33+
IMendixObject object = Core.instantiate(getContext(), Artist.getType());
34+
35+
object.setValue(getContext(), Artist.MemberNames.Name.toString(), artist.name());
36+
37+
return object;
38+
// END USER CODE
39+
}
40+
41+
/**
42+
* Returns a string representation of this action
43+
*/
44+
@java.lang.Override
45+
public java.lang.String toString()
46+
{
47+
return "GenerateArtist";
48+
}
49+
50+
// BEGIN EXTRA CODE
51+
// END EXTRA CODE
52+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// This file was generated by Mendix Studio Pro.
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 fakedata.actions;
11+
12+
import com.github.javafaker.Faker;
13+
import com.mendix.core.Core;
14+
import com.mendix.systemwideinterfaces.core.IContext;
15+
import com.mendix.webui.CustomJavaAction;
16+
import fakedata.proxies.Cat;
17+
import com.mendix.systemwideinterfaces.core.IMendixObject;
18+
19+
public class GenerateCat extends CustomJavaAction<IMendixObject>
20+
{
21+
public GenerateCat(IContext context)
22+
{
23+
super(context);
24+
}
25+
26+
@java.lang.Override
27+
public IMendixObject executeAction() throws Exception
28+
{
29+
// BEGIN USER CODE
30+
Faker faker = new Faker();
31+
com.github.javafaker.Cat cat = faker.cat();
32+
33+
IMendixObject object = Core.instantiate(getContext(), Cat.getType());
34+
35+
object.setValue(getContext(), Cat.MemberNames.Name.toString(), cat.name());
36+
object.setValue(getContext(), Cat.MemberNames.Breed.toString(), cat.breed());
37+
object.setValue(getContext(), Cat.MemberNames.Registry.toString(), cat.registry());
38+
39+
return object;
40+
// END USER CODE
41+
}
42+
43+
/**
44+
* Returns a string representation of this action
45+
*/
46+
@java.lang.Override
47+
public java.lang.String toString()
48+
{
49+
return "GenerateCat";
50+
}
51+
52+
// BEGIN EXTRA CODE
53+
// END EXTRA CODE
54+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// This file was generated by Mendix Studio Pro.
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 fakedata.actions;
11+
12+
import com.github.javafaker.Faker;
13+
import com.mendix.core.Core;
14+
import com.mendix.systemwideinterfaces.core.IContext;
15+
import com.mendix.webui.CustomJavaAction;
16+
import fakedata.proxies.Commerce;
17+
import com.mendix.systemwideinterfaces.core.IMendixObject;
18+
19+
public class GenerateCommerce extends CustomJavaAction<IMendixObject>
20+
{
21+
private java.math.BigDecimal MinPrice;
22+
private java.math.BigDecimal MaxPrice;
23+
private java.lang.Long PromotionCodeDigits;
24+
25+
public GenerateCommerce(IContext context, java.math.BigDecimal MinPrice, java.math.BigDecimal MaxPrice, java.lang.Long PromotionCodeDigits)
26+
{
27+
super(context);
28+
this.MinPrice = MinPrice;
29+
this.MaxPrice = MaxPrice;
30+
this.PromotionCodeDigits = PromotionCodeDigits;
31+
}
32+
33+
@java.lang.Override
34+
public IMendixObject executeAction() throws Exception
35+
{
36+
// BEGIN USER CODE
37+
Faker faker = new Faker();
38+
com.github.javafaker.Commerce commerce = faker.commerce();
39+
40+
IMendixObject object = Core.instantiate(getContext(), Commerce.getType());
41+
42+
object.setValue(getContext(), Commerce.MemberNames.Color.toString(), commerce.color());
43+
object.setValue(getContext(), Commerce.MemberNames.Department.toString(), commerce.department());
44+
object.setValue(getContext(), Commerce.MemberNames.Material.toString(), commerce.material());
45+
object.setValue(getContext(), Commerce.MemberNames.Price.toString(), commerce.price(this.MinPrice.doubleValue(), this.MaxPrice.doubleValue()));
46+
object.setValue(getContext(), Commerce.MemberNames.ProductName.toString(), commerce.productName());
47+
object.setValue(getContext(), Commerce.MemberNames.PromotionCode.toString(), commerce.promotionCode(this.PromotionCodeDigits.intValue()));
48+
49+
return object;
50+
// END USER CODE
51+
}
52+
53+
/**
54+
* Returns a string representation of this action
55+
*/
56+
@java.lang.Override
57+
public java.lang.String toString()
58+
{
59+
return "GenerateCommerce";
60+
}
61+
62+
// BEGIN EXTRA CODE
63+
// END EXTRA CODE
64+
}

0 commit comments

Comments
 (0)