Skip to content

Commit

Permalink
Merge pull request #80 from acalvoa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
acalvoa authored Jun 27, 2018
2 parents e1435a4 + 88be00d commit 7ab507e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog

### [Feature: Add the charset & ORM operations ](https://github.com/acalvoa/earlgrey/pull/79) (27/06/2018)
### [Feature: Add cluster section ](https://github.com/acalvoa/earlgrey/pull/76) (29/05/2018)
### [Feature: Add configs section ](https://github.com/acalvoa/earlgrey/pull/75) (29/05/2018)
### [Feature: Add users section](https://github.com/acalvoa/earlgrey/pull/74) (29/05/2018)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.4.1
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>earlgrey</groupId>
<artifactId>earlgrey</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
<name>earlgrey</name>
<packaging>jar</packaging>
<profiles>
Expand Down
2 changes: 1 addition & 1 deletion src/earlgrey/core/Earlgrey.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void setAutors(){
this.log.Info("* BACKEND SYSTEM *");
this.log.Info("****************************************************************************************");
this.log.Info("");
this.log.Info("Version : 0.23");
this.log.Info("Version : 0.4.1");
this.log.Info("Design by : Angelo Alejandro Calvo Alfaro");
this.log.Info("Code by : Angelo Alejandro Calvo Alfaro, Sebastian Gonzalez Villena");
this.log.Info("");
Expand Down
22 changes: 19 additions & 3 deletions src/earlgrey/core/Gear.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
Expand Down Expand Up @@ -178,7 +179,23 @@ private void digest(int verbose){
private JSONObject extract_params() {
String content = this.request.getHeader("Content-Type");
JSONObject params = new JSONObject();
if(content != null && content.equals("application/json")){
String charset = "UTF-8";
if(content != null && content.indexOf("application/json") == 0){
String[] chunks = content.split(";");
// Search Charset
if(chunks.length > 1) {
for(int i=0; i<chunks.length; i++) {
if(chunks[i].indexOf("charset=") != -1) {
charset = chunks[i].trim().replace("charset=", "").trim().toUpperCase();
break;
}
}
}
try {
this.request.setCharacterEncoding(charset);
} catch (UnsupportedEncodingException e1) {
this.response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE);
}
StringBuffer jb = new StringBuffer();
String line = null;
try {
Expand Down Expand Up @@ -213,15 +230,14 @@ private JSONObject extract_params() {
for(String key : keys) {
String[] value = param_body.get(key);
if(value.length > 0) {
params.put(key, URLDecoder.decode(value[0], StandardCharsets.UTF_8.toString()));
params.put(key, URLDecoder.decode(value[0], charset));
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

return params;
}

Expand Down
68 changes: 63 additions & 5 deletions src/earlgrey/core/ModelCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,72 @@ else if(ModelJoin.class.isAssignableFrom(anotaciones[l].getClass())){
}
}
}
public void mayorOrEqual(String string, String from) {
// TODO Auto-generated method stub

// Operaciones comparativas.
public void mayorOrEqual(String key, String value) {
this.where_field.add(key+" >= "+value);
}
public void minorOrEqual(String string, String from) {
// TODO Auto-generated method stub
public void minorOrEqual(String key, String value) {
this.where_field.add(key+" <= "+value);
}
public void mayor(String key, String value) {
this.where_field.add(key+" > "+value);
}
public void minor(String key, String value) {
this.where_field.add(key+" < "+value);
}
public void between(String key, String value1, String value2) {
this.where_field.add(key+" BETWEEN '"+value1+"' AND '"+value2+"'");
}
public void like(String key, String value){
this.where_field.add(key+" LIKE '"+value+"'");
}
public void mayorOrEqual(String key, int value) {
this.where_field.add(key+" >= "+value);
}
public void minorOrEqual(String key, int value) {
this.where_field.add(key+" <= "+value);
}
public void mayor(String key, int value) {
this.where_field.add(key+" > "+value);
}
public void minor(String key, int value) {
this.where_field.add(key+" < "+value);
}
public void between(String key, int value1, int value2) {
this.where_field.add(key+" BETWEEN "+value1+" AND "+value2+"");
}
public void like(String key, int value){
this.where_field.add(key+" LIKE "+value);
}

//Double
public void mayorOrEqual(String key, double value) {
this.where_field.add(key+" >= "+value);
}
public void minorOrEqual(String key, double value) {
this.where_field.add(key+" <= "+value);
}
public void mayor(String key, double value) {
this.where_field.add(key+" > "+value);
}
public void minor(String key, double value) {
this.where_field.add(key+" < "+value);
}
public void between(String key, double value1, double value2) {
this.where_field.add(key+" BETWEEN "+value1+" AND "+value2+"");
}
public void like(String key, double value){
this.where_field.add(key+" LIKE "+value);
}


public void where(String key, String operator, String value){
this.where_field.add(key+" "+operator+" '"+value+"'");
}
public void where(String key, String operator, int value){
this.where_field.add(key+" "+operator+" "+value);
}
public void where(String key, String operator, double value){
this.where_field.add(key+" "+operator+" "+value);
}
@Override
Expand Down

0 comments on commit 7ab507e

Please sign in to comment.