Skip to content

Commit 862c895

Browse files
committed
added JsonMapper module
added JSONatorBean
1 parent 7d7d27b commit 862c895

28 files changed

+2232
-1
lines changed

clownfish/src/main/java/io/clownfish/clownfish/Clownfish.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public class Clownfish {
206206
UploadTemplateBean uploadbean;
207207
ImportTemplateBean importbean;
208208
PDFTemplateBean pdfbean;
209+
JSONatorBean jsonatorbean;
209210
ExternalClassProvider externalclassproviderbean;
210211
CfClassCompiler cfclassCompiler;
211212
CfClassLoader cfclassLoader;
@@ -1481,7 +1482,8 @@ public ClownfishResponse makeResponse(String name, List<JsonFormParameter> postm
14811482
contentUtil.init(markdownUtil, name, urlParams);
14821483
contentbean = new ContentTemplateBean(propertyUtil, contentUtil);
14831484
contentbean.init(cfclasscontentService, cfattributcontentService, cflistService, cflistcontentService, cfclassService, cfassetlistService, cfassetlistcontentService, cfassetService, useHibernate);
1484-
1485+
jsonatorbean = new JSONatorBean();
1486+
jsonatorbean.init(cftemplateService);
14851487
if (isScripted) { // NORMAL Template
14861488
switch (cftemplate.getScriptlanguage()) {
14871489
case 0: // FREEMARKER
@@ -1506,6 +1508,7 @@ public ClownfishResponse makeResponse(String name, List<JsonFormParameter> postm
15061508
fmRoot.put("pdfBean", pdfbean);
15071509
fmRoot.put("classBean", externalclassproviderbean);
15081510
fmRoot.put("contentBean", contentbean);
1511+
fmRoot.put("jsonatorBean", jsonatorbean);
15091512

15101513
fmRoot.put("parameter", parametermap);
15111514
if (!searchmetadata.isEmpty()) {
@@ -1622,6 +1625,7 @@ public ClownfishResponse makeResponse(String name, List<JsonFormParameter> postm
16221625
velContext.put("pdfBean", pdfbean);
16231626
velContext.put("classBean", externalclassproviderbean);
16241627
velContext.put("contentBean", contentbean);
1628+
velContext.put("jsonatorBean", jsonatorbean);
16251629

16261630
velContext.put("parameter", parametermap);
16271631
velContext.put("property", propertyUtil.getPropertymap());
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.conditions;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import java.util.ArrayList;
9+
10+
/**
11+
*
12+
* @author SulzbachR
13+
*/
14+
@JsonIgnoreProperties(ignoreUnknown = true)
15+
public class ConditionsWrapper {
16+
private ArrayList<ICondition> conditions;
17+
18+
public ArrayList<ICondition> getConditions() {
19+
return conditions;
20+
}
21+
22+
public void setConditions(ArrayList<ICondition> conditions) {
23+
this.conditions = conditions;
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.conditions;
6+
7+
import com.fasterxml.jackson.annotation.JsonSubTypes;
8+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
9+
10+
/**
11+
*
12+
* @author SulzbachR
13+
*/
14+
@JsonTypeInfo(
15+
use = JsonTypeInfo.Id.NAME,
16+
include = JsonTypeInfo.As.PROPERTY,
17+
property = "type",
18+
visible = true
19+
)
20+
@JsonSubTypes({
21+
@JsonSubTypes.Type(value = StringCondition.class, name = "string"),
22+
@JsonSubTypes.Type(value = JsonCondition.class, name = "json")
23+
})
24+
public interface ICondition {
25+
public String getType();
26+
public String getReference();
27+
public String getCondition();
28+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.conditions;
6+
7+
import com.fasterxml.jackson.core.JsonProcessingException;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import java.util.logging.Level;
10+
import java.util.logging.Logger;
11+
12+
/**
13+
*
14+
* @author SulzbachR
15+
*/
16+
public class JsonCondition implements ICondition {
17+
private String type;
18+
private String reference;
19+
private Object condition;
20+
21+
@Override
22+
public String getReference() {
23+
return reference;
24+
}
25+
26+
@Override
27+
public String getCondition() {
28+
try {
29+
ObjectMapper objectMapper = new ObjectMapper();
30+
String jsonString = objectMapper.writeValueAsString(condition);
31+
32+
return jsonString;
33+
} catch (JsonProcessingException ex) {
34+
Logger.getLogger(JsonCondition.class.getName()).log(Level.SEVERE, null, ex);
35+
return null;
36+
}
37+
}
38+
39+
@Override
40+
public String getType() {
41+
return type;
42+
}
43+
44+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.conditions;
6+
7+
/**
8+
*
9+
* @author SulzbachR
10+
*/
11+
public class StringCondition implements ICondition {
12+
private String type;
13+
private String reference;
14+
private String condition;
15+
16+
@Override
17+
public String getReference() {
18+
return reference;
19+
}
20+
21+
@Override
22+
public String getCondition() {
23+
return condition;
24+
}
25+
26+
@Override
27+
public String getType() {
28+
return type;
29+
}
30+
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.datasource;
6+
7+
/**
8+
*
9+
* @author SulzbachR
10+
*/
11+
public class Auth {
12+
private String url;
13+
private String token;
14+
15+
public String getUrl() {
16+
return url;
17+
}
18+
19+
public void setUrl(String url) {
20+
this.url = url;
21+
}
22+
23+
public String getToken() {
24+
return token;
25+
}
26+
27+
public void setToken(String token) {
28+
this.token = token;
29+
}
30+
31+
32+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.datasource;
6+
7+
/**
8+
*
9+
* @author SulzbachR
10+
*/
11+
public class DatabaseDatasource implements IDatasource {
12+
private String name;
13+
private String type;
14+
private String connection;
15+
private String user;
16+
private String password;
17+
private String format;
18+
private String method;
19+
private Auth auth;
20+
21+
@Override
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
@Override
31+
public String getType() {
32+
return type;
33+
}
34+
35+
public void setType(String type) {
36+
this.type = type;
37+
}
38+
39+
@Override
40+
public String getConnection() {
41+
return connection;
42+
}
43+
44+
public void setConnection(String connection) {
45+
this.connection = connection;
46+
}
47+
48+
@Override
49+
public String getUser() {
50+
return user;
51+
}
52+
53+
public void setUser(String user) {
54+
this.user = user;
55+
}
56+
57+
@Override
58+
public String getPassword() {
59+
return password;
60+
}
61+
62+
public void setPassword(String password) {
63+
this.password = password;
64+
}
65+
66+
@Override
67+
public String getFormat() {
68+
return format;
69+
}
70+
71+
public void setFormat(String format) {
72+
this.format = format;
73+
}
74+
75+
@Override
76+
public String getMethod() {
77+
return method;
78+
}
79+
80+
@Override
81+
public Auth getAuth() {
82+
return auth;
83+
}
84+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.datasource;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import java.util.ArrayList;
9+
10+
/**
11+
*
12+
* @author SulzbachR
13+
*/
14+
@JsonIgnoreProperties(ignoreUnknown = true)
15+
public class DatasourceWrapper {
16+
private ArrayList<IDatasource> datasources;
17+
18+
public ArrayList<IDatasource> getDatasources() {
19+
return datasources;
20+
}
21+
22+
public void setDatasources(ArrayList<IDatasource> datasources) {
23+
this.datasources = datasources;
24+
}
25+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package io.clownfish.clownfish.jsonator.datasource;
6+
7+
/**
8+
*
9+
* @author SulzbachR
10+
*/
11+
public class FileDatasource implements IDatasource {
12+
private String name;
13+
private String type;
14+
private String connection;
15+
private String user;
16+
private String password;
17+
private String format;
18+
private String method;
19+
private Auth auth;
20+
21+
@Override
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
@Override
31+
public String getType() {
32+
return type;
33+
}
34+
35+
public void setType(String type) {
36+
this.type = type;
37+
}
38+
39+
@Override
40+
public String getConnection() {
41+
return connection;
42+
}
43+
44+
public void setConnection(String connection) {
45+
this.connection = connection;
46+
}
47+
48+
@Override
49+
public String getUser() {
50+
return user;
51+
}
52+
53+
public void setUser(String user) {
54+
this.user = user;
55+
}
56+
57+
@Override
58+
public String getPassword() {
59+
return password;
60+
}
61+
62+
public void setPassword(String password) {
63+
this.password = password;
64+
}
65+
66+
@Override
67+
public String getFormat() {
68+
return format;
69+
}
70+
71+
public void setFormat(String format) {
72+
this.format = format;
73+
}
74+
75+
@Override
76+
public String getMethod() {
77+
return method;
78+
}
79+
80+
@Override
81+
public Auth getAuth() {
82+
return auth;
83+
}
84+
85+
}

0 commit comments

Comments
 (0)