提交 e468ff2f 编写于 作者: R roo00

修正神经网络无法删除的bug

上级 8637873e
......@@ -29,6 +29,9 @@ public class WrapModule extends GsonPropertyObject {
@FieldDescribe("说明")
private String description;
@FieldDescribe("下载次数")
private Integer downloadCount;
@FieldDescribe("流程")
private List<WrapProcessPlatform> processPlatformList = new ArrayList<>();
......@@ -150,4 +153,12 @@ public class WrapModule extends GsonPropertyObject {
this.icon = icon;
}
public Integer getDownloadCount() {
return downloadCount;
}
public void setDownloadCount(Integer downloadCount) {
this.downloadCount = downloadCount;
}
}
......@@ -32,6 +32,8 @@ class ActionDeleteModel extends BaseAction {
}
this.cleanOutValue(business, model);
this.cleanInValue(business, model);
this.cleanInText(business, model);
this.cleanOutText(business, model);
this.cleanEntry(business, model);
emc.beginTransaction(Model.class);
emc.remove(model, CheckRemoveType.all);
......
......@@ -8,8 +8,10 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.neural.Entry;
import com.x.query.core.entity.neural.InText;
import com.x.query.core.entity.neural.InValue;
import com.x.query.core.entity.neural.Model;
import com.x.query.core.entity.neural.OutText;
import com.x.query.core.entity.neural.OutValue;
abstract class BaseAction extends StandardJaxrsAction {
......@@ -40,6 +42,30 @@ abstract class BaseAction extends StandardJaxrsAction {
return count;
}
protected Long cleanInText(Business business, Model project) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(InText.class, InText.model_FIELDNAME,
project.getId());
Long count = 0L;
for (List<String> os : ListTools.batch(ids, 2000)) {
business.entityManagerContainer().beginTransaction(InText.class);
count = count + business.entityManagerContainer().delete(InText.class, os);
business.entityManagerContainer().commit();
}
return count;
}
protected Long cleanOutText(Business business, Model project) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(OutText.class, OutText.model_FIELDNAME,
project.getId());
Long count = 0L;
for (List<String> os : ListTools.batch(ids, 2000)) {
business.entityManagerContainer().beginTransaction(OutText.class);
count = count + business.entityManagerContainer().delete(OutText.class, os);
business.entityManagerContainer().commit();
}
return count;
}
protected Long cleanEntry(Business business, Model project) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(Entry.class, Entry.model_FIELDNAME,
project.getId());
......
......@@ -19,6 +19,8 @@ import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.Query;
......@@ -26,15 +28,19 @@ import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
class ActionEdit extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionEdit.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Statement statement = emc.flag(flag, Statement.class);
if (null == statement) {
throw new ExceptionEntityNotExist(flag, Statement.class);
}
Table table = emc.flag(statement.getTable(), Table.class);
Table table = emc.flag(wi.getTable(), Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(statement.getTable(), Table.class);
}
......@@ -45,7 +51,6 @@ class ActionEdit extends BaseAction {
if (!business.editable(effectivePerson, query)) {
throw new ExceptionAccessDenied(effectivePerson, query);
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Wi.copier.copy(wi, statement);
if (StringUtils.isEmpty(statement.getName())) {
throw new ExceptionEntityFieldEmpty(Statement.class, Statement.name_FIELDNAME);
......
......@@ -7,6 +7,7 @@ import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
......@@ -14,8 +15,8 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -55,7 +56,19 @@ class ActionExecute extends BaseAction {
EntityManager em = emc.get(cls);
Query query = em.createQuery(statement.getData());
for (Entry<String, Object> en : parameter.entrySet()) {
query.setParameter(en.getKey(), en.getValue());
if (StringUtils.equals(en.getKey(), "firstResult") && (en.getValue() != null)) {
int firstResult = NumberUtils.toInt(en.getValue().toString(), -1);
if (firstResult > 0) {
query.setFirstResult(firstResult);
}
} else if (StringUtils.equals(en.getKey(), "maxResults") && (en.getValue() != null)) {
int maxResults = NumberUtils.toInt(en.getValue().toString(), -1);
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
} else {
query.setParameter(en.getKey(), en.getValue());
}
}
Object data = null;
if (StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
......
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
......@@ -27,6 +27,10 @@ public class FilterEntry extends GsonPropertyObject {
public static final String FORMAT_DATETIMEVALUE = "dateTimeValue";
public static final String FORMAT_DATEVALUE = "dateValue";
public static final String FORMAT_TIMEVALUE = "timeValue";
public static final String DEFINE_TIME = "@time";
public static final String DEFINE_DATE = "@date";
......@@ -83,13 +87,37 @@ public class FilterEntry extends GsonPropertyObject {
return true;
}
case FORMAT_DATETIMEVALUE:
if (DateTools.isDateTimeOrDateOrTime(value)) {
if (DateTools.isDateTimeOrDateOrTime(value) || StringUtils.equalsIgnoreCase(DEFINE_TIME, value)
|| StringUtils.equalsIgnoreCase(DEFINE_DATE, value)
|| StringUtils.equalsIgnoreCase(DEFINE_MONTH, value)
|| StringUtils.equalsIgnoreCase(DEFINE_SEASON, value)
|| StringUtils.equalsIgnoreCase(DEFINE_YEAR, value)) {
return true;
} else {
return false;
}
case FORMAT_DATEVALUE:
if (DateTools.isDateTimeOrDateOrTime(value) || StringUtils.equalsIgnoreCase(DEFINE_TIME, value)
|| StringUtils.equalsIgnoreCase(DEFINE_DATE, value)
|| StringUtils.equalsIgnoreCase(DEFINE_MONTH, value)
|| StringUtils.equalsIgnoreCase(DEFINE_SEASON, value)
|| StringUtils.equalsIgnoreCase(DEFINE_YEAR, value)) {
return true;
} else {
return false;
}
case FORMAT_TIMEVALUE:
if (DateTools.isDateTimeOrDateOrTime(value) || StringUtils.equalsIgnoreCase(DEFINE_TIME, value)
|| StringUtils.equalsIgnoreCase(DEFINE_DATE, value)
|| StringUtils.equalsIgnoreCase(DEFINE_MONTH, value)
|| StringUtils.equalsIgnoreCase(DEFINE_SEASON, value)
|| StringUtils.equalsIgnoreCase(DEFINE_YEAR, value)) {
return true;
} else {
return false;
}
case FORMAT_NUMBERVALUE:
if (NumberUtils.isNumber(value)) {
if (NumberUtils.isCreatable(value)) {
return true;
} else {
return false;
......@@ -179,82 +207,47 @@ public class FilterEntry extends GsonPropertyObject {
p = cb.and(p, cb.equal(root.get(Item_.numberValue), doubleValue));
}
}
} else if (StringUtils.equals(this.formatType, FORMAT_DATETIMEVALUE)) {
/* 时间值比较 */
} else if (StringUtils.equals(this.formatType, FORMAT_DATEVALUE)) {
/* 日期值比较 */
if (StringUtils.isNotEmpty(compareValue)) {
Date value = null;
Date otherValue = null;
if (DateTools.isDateTime(compareValue)) {
Date dateTimeValue = DateTools.parseDateTime(compareValue);
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateTimeValue)),
cb.equal(root.get(Item_.dateTimeValue), dateTimeValue)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), dateTimeValue));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), dateTimeValue));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), dateTimeValue));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), dateTimeValue));
} else if (Comparison.isBetween(this.comparison)) {
if (StringUtils.isNotEmpty(compareOtherValue) && DateTools.isDateTime(compareOtherValue)) {
Date dateTimeOtherValue = DateTools.parseDateTime(compareOtherValue);
if (null != dateTimeOtherValue) {
p = cb.and(p,
cb.between(root.get(Item_.dateTimeValue), dateTimeValue, dateTimeOtherValue));
}
}
} else {
p = cb.and(p, cb.equal(root.get(Item_.dateTimeValue), dateTimeValue));
}
value = DateTools.parseDateTime(compareValue);
} else if (DateTools.isDate(compareValue)) {
Date dateValue = DateTools.parseDate(compareValue);
value = DateTools.parseDate(compareValue);
}
if (DateTools.isDateTime(compareOtherValue)) {
otherValue = DateTools.parseDateTime(compareOtherValue);
} else if (DateTools.isDate(compareOtherValue)) {
otherValue = DateTools.parseDate(compareOtherValue);
}
if (null != otherValue) {
otherValue = DateTools.ceilDate(otherValue, 0);
}
if (null != value) {
value = DateTools.ceilDate(value, 0);
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateValue)),
cb.equal(root.get(Item_.dateValue), dateValue)));
cb.equal(root.get(Item_.dateValue), value)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateValue), dateValue));
p = cb.and(p, cb.greaterThan(root.get(Item_.dateValue), value));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateValue), dateValue));
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateValue), value));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateValue), dateValue));
p = cb.and(p, cb.lessThan(root.get(Item_.dateValue), value));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateValue), dateValue));
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateValue), value));
} else if (Comparison.isBetween(this.comparison)) {
if (StringUtils.isNotEmpty(compareOtherValue) && DateTools.isDate(compareOtherValue)) {
Date dateOtherValue = DateTools.parseDate(compareOtherValue);
if (null != dateOtherValue) {
p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), dateValue, dateOtherValue));
}
if (null != otherValue) {
p = cb.and(p, cb.between(root.get(Item_.dateValue), value, otherValue));
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
} else {
p = cb.and(p, cb.equal(root.get(Item_.dateValue), value));
}
} else if (DateTools.isTime(compareValue)) {
Date timeValue = DateTools.parseTime(compareValue);
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.timeValue)),
cb.equal(root.get(Item_.timeValue), timeValue)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.timeValue), timeValue));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.timeValue), timeValue));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.timeValue), timeValue));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.timeValue), timeValue));
} else if (Comparison.isBetween(this.comparison)) {
if (StringUtils.isNotEmpty(compareOtherValue) && DateTools.isTime(compareOtherValue)) {
Date timeOtherValue = DateTools.parseTime(compareOtherValue);
if (null != timeOtherValue) {
p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), timeValue, timeOtherValue));
}
}
} else {
p = cb.and(p, cb.equal(root.get(Item_.timeValue), value));
}
} else if (StringUtils.equals(compareValue, DEFINE_DATE)
|| StringUtils.equals(compareValue, DEFINE_MONTH)
|| StringUtils.equals(compareValue, DEFINE_SEASON)
......@@ -276,33 +269,89 @@ public class FilterEntry extends GsonPropertyObject {
}
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateTimeValue)),
cb.between(root.get(Item_.dateTimeValue), floor, ceil)));
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateValue)),
cb.between(root.get(Item_.dateValue), floor, ceil)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), ceil));
p = cb.and(p, cb.greaterThan(root.get(Item_.dateValue), ceil));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), floor));
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateValue), floor));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), floor));
p = cb.and(p, cb.lessThan(root.get(Item_.dateValue), floor));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), ceil));
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateValue), ceil));
} else if (Comparison.isBetween(this.comparison)) {
p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), floor, ceil));
// throw new Exception("unkown comparison:" + this.comparison);
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateValue)),
cb.equal(root.get(Item_.dateValue), new Date())));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateValue), new Date()));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateValue), new Date()));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateValue), new Date()));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateValue), new Date()));
} else if (Comparison.isBetween(this.comparison)) {
// throw new Exception("unkown comparison:" + this.comparison);
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
}
}
} else if (StringUtils.equals(this.formatType, FORMAT_TIMEVALUE)) {
/* 时间值比较 */
if (StringUtils.isNotEmpty(compareValue)) {
Date value = null;
Date otherValue = null;
if (DateTools.isDateTime(compareValue)) {
value = DateTools.parseDateTime(compareValue);
} else if (DateTools.isTime(compareValue)) {
value = DateTools.parseTime(compareValue);
}
if (DateTools.isDateTime(compareOtherValue)) {
otherValue = DateTools.parseDateTime(compareOtherValue);
} else if (DateTools.isTime(compareOtherValue)) {
otherValue = DateTools.parseTime(compareOtherValue);
}
if (null != value) {
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.timeValue)),
cb.equal(root.get(Item_.timeValue), value)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.timeValue), value));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.timeValue), value));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.timeValue), value));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.timeValue), value));
} else if (Comparison.isBetween(this.comparison)) {
if (null != otherValue) {
p = cb.and(p, cb.between(root.get(Item_.timeValue), value, otherValue));
}
} else {
p = cb.and(p, cb.equal(root.get(Item_.timeValue), value));
}
} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.timeValue)),
cb.equal(root.get(Item_.timeValue), new Date())));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), new Date()));
p = cb.and(p, cb.greaterThan(root.get(Item_.timeValue), new Date()));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), new Date()));
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.timeValue), new Date()));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), new Date()));
p = cb.and(p, cb.lessThan(root.get(Item_.timeValue), new Date()));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), new Date()));
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.timeValue), new Date()));
} else if (Comparison.isBetween(this.comparison)) {
throw new Exception("unkown comparison:" + this.comparison);
} else {
......@@ -310,6 +359,95 @@ public class FilterEntry extends GsonPropertyObject {
}
}
}
} else if (StringUtils.equals(this.formatType, FORMAT_DATETIMEVALUE)) {
Date value = null;
Date otherValue = null;
if (DateTools.isDateTime(compareValue)) {
value = DateTools.parseDateTime(compareValue);
} else if (DateTools.isDate(compareValue)) {
value = DateTools.parseDate(compareValue);
}
if (DateTools.isDateTime(compareOtherValue)) {
otherValue = DateTools.parseDateTime(compareOtherValue);
} else if (DateTools.isDate(compareOtherValue)) {
otherValue = DateTools.parseDate(compareOtherValue);
}
if (null != value) {
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateTimeValue)),
cb.equal(root.get(Item_.dateTimeValue), value)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), value));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), value));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), value));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), value));
} else if (Comparison.isBetween(this.comparison)) {
if (null != otherValue) {
p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), value, otherValue));
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
} else {
p = cb.and(p, cb.equal(root.get(Item_.dateTimeValue), value));
}
} else if (StringUtils.equals(compareValue, DEFINE_DATE) || StringUtils.equals(compareValue, DEFINE_MONTH)
|| StringUtils.equals(compareValue, DEFINE_SEASON)
|| StringUtils.equals(compareValue, DEFINE_YEAR)) {
Date floor = null;
Date ceil = null;
if (StringUtils.equals(compareValue, DEFINE_DATE)) {
floor = DateTools.floorDate(new Date(), 0);
ceil = DateTools.ceilDate(new Date(), 0);
} else if (StringUtils.equals(compareValue, DEFINE_MONTH)) {
floor = DateTools.floorMonth(new Date(), 0);
ceil = DateTools.ceilMonth(new Date(), 0);
} else if (StringUtils.equals(compareValue, DEFINE_SEASON)) {
floor = DateTools.floorSeason(new Date(), 0);
ceil = DateTools.ceilSeason(new Date(), 0);
} else {
floor = DateTools.floorYear(new Date(), 0);
ceil = DateTools.ceilYear(new Date(), 0);
}
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateTimeValue)),
cb.between(root.get(Item_.dateTimeValue), floor, ceil)));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), ceil));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), floor));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), floor));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), ceil));
} else if (Comparison.isBetween(this.comparison)) {
// p = cb.and(p, cb.between(root.get(Item_.dateTimeValue), floor, ceil));
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
} else if (StringUtils.equals(compareValue, DEFINE_TIME)) {
if (Comparison.isNotEquals(this.comparison)) {
/** 不等于返回等于值,在外部运算 */
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.dateTimeValue)),
cb.equal(root.get(Item_.dateTimeValue), new Date())));
} else if (Comparison.isGreaterThan(this.comparison)) {
p = cb.and(p, cb.greaterThan(root.get(Item_.dateTimeValue), new Date()));
} else if (Comparison.isGreaterThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.greaterThanOrEqualTo(root.get(Item_.dateTimeValue), new Date()));
} else if (Comparison.isLessThan(this.comparison)) {
p = cb.and(p, cb.lessThan(root.get(Item_.dateTimeValue), new Date()));
} else if (Comparison.isLessThanOrEqualTo(this.comparison)) {
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Item_.dateTimeValue), new Date()));
} else if (Comparison.isBetween(this.comparison)) {
throw new Exception("unkown comparison:" + this.comparison);
} else {
throw new Exception("unkown comparison:" + this.comparison);
}
}
} else {
/* TEXT 内容值 */
if (StringUtils.equals(compareValue, DEFINE_PERSON)) {
......
......@@ -307,13 +307,7 @@ public class Learn {
}
return count;
}
// private void saveNeuralNetwork(NeuralNetwork<MomentumBackpropagation> neuralNetwork, model model,
// String surffix) throws Exception {
// File file = new File(Config.base(), "local/temp/" + model.getName() + "_" + surffix + ".nnet");
// neuralNetwork.save(file.getAbsolutePath());
// }
private void saveDataSet(DataSet dataSet, Model model, String surffix) throws Exception {
File file = new File(Config.base(), "local/temp/" + model.getName() + "_" + surffix + ".txt");
dataSet.save(file.getAbsolutePath());
......
var Describe = function() {
//20180730
// 20180730
}
Describe.splitValue = function(str) {
......@@ -38,7 +38,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -55,7 +55,7 @@ Describe.doPost = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -74,7 +74,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
}).always(function(resultJson) {
$('#result').html(JSON.stringify(resultJson, null, 4));
Describe.writeOut(m.outs, resultJson);
......@@ -91,7 +91,7 @@ Describe.doPut = function(address, m, data) {
xhrFields : {
'withCredentials' : true
},
data : ((m.contentType.indexOf('application/json') > -1) ? JSON.stringify(data) : data)
data : ((m.contentType.indexOf('application/json') > -1) && (!m.useStringParameter) ? JSON.stringify(data) : data)
});
}
}
......@@ -269,6 +269,14 @@ Describe.prototype = {
txt += '</table>';
txt += '</fieldset>';
}
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
}
if (m.outs && m.outs.length > 0) {
txt += '<fieldset id="outs"><legend>Out</legend>';
txt += '<table>';
......@@ -318,6 +326,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPost(address, m, data);
break;
......@@ -340,6 +350,8 @@ Describe.prototype = {
});
} else if (m.useJsonElementParameter) {
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
}
Describe.doPut(address, m, data);
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册