Browse Source

修改Model类型

roo00 7 years ago
parent
commit
b082f09073
40 changed files with 735 additions and 673 deletions
  1. 19 0
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/Module.java
  2. 16 10
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionCreateModel.java
  3. 19 19
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionDeleteModel.java
  4. 10 10
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionGenerate.java
  5. 9 9
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionGetModel.java
  6. 12 12
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionLearn.java
  7. 6 6
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionListModel.java
  8. 7 7
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionResetStatus.java
  9. 6 6
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionStopGenerating.java
  10. 6 6
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionStopLearning.java
  11. 20 14
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionUpdateModel.java
  12. 7 7
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/BaseAction.java
  13. 2 2
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionEntryEmpty.java
  14. 2 2
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionGenerating.java
  15. 2 2
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionLearning.java
  16. 43 43
      o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/NeuralAction.java
  17. 0 46
      o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionCalculate.java
  18. 69 0
      o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionListCalculate.java
  19. 5 3
      o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/NeuralAction.java
  20. 2 2
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/PersistenceProperties.java
  21. 13 13
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/Entry.java
  22. 13 13
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/InText.java
  23. 13 14
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/InValue.java
  24. 63 93
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/Model.java
  25. 13 13
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/OutText.java
  26. 13 13
      o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/OutValue.java
  27. 86 55
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionCalculateWithWork.java
  28. 8 8
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionGenerate.java
  29. 8 8
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionLearn.java
  30. 5 5
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionStopGenerating.java
  31. 5 5
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionStopLearning.java
  32. 2 2
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/BaseAction.java
  33. 2 2
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionBundleEmpty.java
  34. 2 2
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionGenerate.java
  35. 2 2
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionLearn.java
  36. 3 3
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionModelNotReady.java
  37. 106 108
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/Generate.java
  38. 75 76
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/Learn.java
  39. 19 17
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/NeuralAction.java
  40. 22 15
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/schedule/Crawl.java

+ 19 - 0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/Module.java

@@ -0,0 +1,19 @@
+package com.x.base.core.project.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 标记所有可启动模块
+ * @author zhour
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+public @interface Module {
+	String name() default "";
+}

+ 16 - 10
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionCreateProject.java → o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionCreateModel.java

@@ -11,23 +11,23 @@ import com.x.base.core.project.cache.ApplicationCache;
 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.tools.ListTools;
 import com.x.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
-class ActionCreateProject extends BaseAction {
+class ActionCreateModel extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Business business = new Business(emc);
-			emc.beginTransaction(Project.class);
-			Project project = Wi.copier.copy(wi);
-			// project.setStatus(Project.STATUS_NEW);
-			emc.persist(project, CheckPersistType.all);
+			emc.beginTransaction(Model.class);
+			Model model = Wi.copier.copy(wi);
+			emc.persist(model, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Project.class);
+			ApplicationCache.notify(Model.class);
 			Wo wo = new Wo();
-			wo.setId(project.getId());
+			wo.setId(model.getId());
 			result.setData(wo);
 			return result;
 		}
@@ -37,11 +37,17 @@ class ActionCreateProject extends BaseAction {
 
 	}
 
-	public static class Wi extends Project {
+	public static class Wi extends Model {
 
 		private static final long serialVersionUID = -5237741099036357033L;
 
-		static WrapCopier<Wi, Project> copier = WrapCopierFactory.wi(Wi.class, Project.class, null,
+		static WrapCopier<Wi, Model> copier = WrapCopierFactory.wi(Wi.class, Model.class,
+				ListTools.toList(Model.id_FIELDNAME, Model.neuralNetworkType_FIELDNAME, Model.dataType_FIELDNAME,
+						Model.name_FIELDNAME, Model.description_FIELDNAME, Model.alias_FIELDNAME,
+						Model.inValueScriptText_FIELDNAME, Model.outValueScriptText_FIELDNAME,
+						Model.attachmentScriptText_FIELDNAME, Model.processList_FIELDNAME,
+						Model.applicationList_FIELDNAME, Model.inValueCount_FIELDNAME, Model.outValueCount_FIELDNAME,
+						Model.maxResult_FIELDNAME, Model.propertyMap_FIELDNAME, Model.analyzeType_FIELDNAME),
 				JpaObject.FieldsUnmodifyExcludeId);
 
 	}

+ 19 - 19
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionDeleteProject.java → o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionDeleteModel.java

@@ -13,42 +13,42 @@ 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.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
-class ActionDeleteProject extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+class ActionDeleteModel extends BaseAction {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (StringUtils.equals(Project.STATUS_GENERATING, project.getStatus())) {
-				throw new ExceptionGenerating(project.getName());
+			if (StringUtils.equals(Model.STATUS_GENERATING, model.getStatus())) {
+				throw new ExceptionGenerating(model.getName());
 			}
-			if (StringUtils.equals(Project.STATUS_LEARNING, project.getStatus())) {
-				throw new ExceptionLearning(project.getName());
+			if (StringUtils.equals(Model.STATUS_LEARNING, model.getStatus())) {
+				throw new ExceptionLearning(model.getName());
 			}
-			this.cleanOutValue(business, project);
-			this.cleanInValue(business, project);
-			this.cleanEntry(business, project);
-			emc.beginTransaction(Project.class);
-			emc.remove(project, CheckRemoveType.all);
+			this.cleanOutValue(business, model);
+			this.cleanInValue(business, model);
+			this.cleanEntry(business, model);
+			emc.beginTransaction(Model.class);
+			emc.remove(model, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(Project.class);
+			ApplicationCache.notify(Model.class);
 			Wo wo = new Wo();
-			wo.setId(project.getId());
+			wo.setId(model.getId());
 			result.setData(wo);
 			return result;
 		}
 	}
 
-	public static class Wo extends Project {
+	public static class Wo extends Model {
 
 		private static final long serialVersionUID = -6541538280679110474L;
 
-		static WrapCopier<Project, Wo> copier = WrapCopierFactory.wo(Project.class, Wo.class, null,
+		static WrapCopier<Model, Wo> copier = WrapCopierFactory.wo(Model.class, Wo.class, null,
 				JpaObject.FieldsInvisible);
 
 	}

+ 10 - 10
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionGenerate.java

@@ -37,26 +37,26 @@ import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.query.assemble.designer.ThisApplication;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionGenerate extends BaseAction {
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = new Wo();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (StringUtils.equals(Project.STATUS_GENERATING, project.getStatus())) {
-				throw new ExceptionGenerating(project.getName());
+			if (StringUtils.equals(Model.STATUS_GENERATING, model.getStatus())) {
+				throw new ExceptionGenerating(model.getName());
 			}
-			if (StringUtils.equals(Project.STATUS_LEARNING, project.getStatus())) {
-				throw new ExceptionLearning(project.getName());
+			if (StringUtils.equals(Model.STATUS_LEARNING, model.getStatus())) {
+				throw new ExceptionLearning(model.getName());
 			}
 			ThisApplication.context().applications().getQuery(x_query_service_processing.class,
-					Applications.joinQueryUri("neural", "generate", "project", project.getId()));
+					Applications.joinQueryUri("neural", "generate", "model", model.getId()));
 			wo.setValue(true);
 			result.setData(wo);
 			return result;

+ 9 - 9
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionGetProject.java → o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionGetModel.java

@@ -9,28 +9,28 @@ 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.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
-class ActionGetProject extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+class ActionGetModel extends BaseAction {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			Wo wo = Wo.copier.copy(project);
+			Wo wo = Wo.copier.copy(model);
 			result.setData(wo);
 			return result;
 		}
 	}
 
-	public static class Wo extends Project {
+	public static class Wo extends Model {
 
 		private static final long serialVersionUID = -6541538280679110474L;
 
-		static WrapCopier<Project, Wo> copier = WrapCopierFactory.wo(Project.class, Wo.class, null,
+		static WrapCopier<Model, Wo> copier = WrapCopierFactory.wo(Model.class, Wo.class, null,
 				JpaObject.FieldsInvisible);
 
 	}

+ 12 - 12
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionLearn.java

@@ -13,29 +13,29 @@ import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.query.assemble.designer.Business;
 import com.x.query.assemble.designer.ThisApplication;
 import com.x.query.core.entity.neural.Entry;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionLearn extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
 			Wo wo = new Wo();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (emc.countEqual(Entry.class, Entry.project_FIELDNAME, project.getId()) == 0) {
-				throw new ExceptionEntryEmpty(project.getName());
+			if (emc.countEqual(Entry.class, Entry.model_FIELDNAME, model.getId()) == 0) {
+				throw new ExceptionEntryEmpty(model.getName());
 			}
-			if (StringUtils.equals(Project.STATUS_GENERATING, project.getStatus())) {
-				throw new ExceptionGenerating(project.getName());
+			if (StringUtils.equals(Model.STATUS_GENERATING, model.getStatus())) {
+				throw new ExceptionGenerating(model.getName());
 			}
-			if (StringUtils.equals(Project.STATUS_LEARNING, project.getStatus())) {
-				throw new ExceptionLearning(project.getName());
+			if (StringUtils.equals(Model.STATUS_LEARNING, model.getStatus())) {
+				throw new ExceptionLearning(model.getName());
 			}
 			ThisApplication.context().applications().getQuery(x_query_service_processing.class,
-					Applications.joinQueryUri("neural", "learn", "project", project.getId()));
+					Applications.joinQueryUri("neural", "learn", "model", model.getId()));
 			wo.setValue(true);
 			result.setData(wo);
 			return result;

+ 6 - 6
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionListProject.java → o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionListModel.java

@@ -14,11 +14,11 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.organization.OrganizationDefinition;
 import com.x.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
-class ActionListProject extends BaseAction {
+class ActionListModel extends BaseAction {
 
-	private static Logger logger = LoggerFactory.getLogger(ActionListProject.class);
+	private static Logger logger = LoggerFactory.getLogger(ActionListModel.class);
 
 	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
@@ -28,17 +28,17 @@ class ActionListProject extends BaseAction {
 					OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
 				throw new ExceptionAccessDenied(effectivePerson);
 			}
-			List<Project> os = emc.listAll(Project.class);
+			List<Model> os = emc.listAll(Model.class);
 			result.setData(Wo.copier.copy(os));
 			return result;
 		}
 	}
 
-	public static class Wo extends Project {
+	public static class Wo extends Model {
 
 		private static final long serialVersionUID = -6541538280679110474L;
 
-		static WrapCopier<Project, Wo> copier = WrapCopierFactory.wo(Project.class, Wo.class, null,
+		static WrapCopier<Model, Wo> copier = WrapCopierFactory.wo(Model.class, Wo.class, null,
 				JpaObject.FieldsInvisible);
 
 	}

+ 7 - 7
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionResetStatus.java

@@ -7,19 +7,19 @@ import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionResetStatus extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			emc.beginTransaction(Project.class);
-			project.setStatus("");
+			emc.beginTransaction(Model.class);
+			model.setStatus("");
 			emc.commit();
 			Wo wo = new Wo();
 			wo.setValue(true);

+ 6 - 6
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionStopGenerating.java

@@ -35,20 +35,20 @@ import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.query.assemble.designer.ThisApplication;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionStopGenerating extends BaseAction {
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = new Wo();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			ThisApplication.context().applications().getQuery(x_query_service_processing.class,
-					Applications.joinQueryUri("neural", "stop", "generating", "project", project.getId()));
+					Applications.joinQueryUri("neural", "stop", "generating", "model", model.getId()));
 			wo.setValue(true);
 			result.setData(wo);
 			return result;

+ 6 - 6
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionStopLearning.java

@@ -35,20 +35,20 @@ import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.query.assemble.designer.ThisApplication;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionStopLearning extends BaseAction {
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = new Wo();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			ThisApplication.context().applications().getQuery(x_query_service_processing.class,
-					Applications.joinQueryUri("neural", "stop", "learning", "project", project.getId()));
+					Applications.joinQueryUri("neural", "stop", "learning", "model", model.getId()));
 			wo.setValue(true);
 			result.setData(wo);
 			return result;

+ 20 - 14
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionUpdateProject.java → o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ActionUpdateModel.java

@@ -12,27 +12,28 @@ 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.tools.ListTools;
 import com.x.query.assemble.designer.Business;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
-class ActionUpdateProject extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag, JsonElement jsonElement)
+class ActionUpdateModel extends BaseAction {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag, JsonElement jsonElement)
 			throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 			Business business = new Business(emc);
-			emc.beginTransaction(Project.class);
-			Wi.copier.copy(wi, project);
-			emc.check(project, CheckPersistType.all);
+			emc.beginTransaction(Model.class);
+			Wi.copier.copy(wi, model);
+			emc.check(model, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Project.class);
+			ApplicationCache.notify(Model.class);
 			Wo wo = new Wo();
-			wo.setId(project.getId());
+			wo.setId(model.getId());
 			result.setData(wo);
 			return result;
 		}
@@ -42,13 +43,18 @@ class ActionUpdateProject extends BaseAction {
 
 	}
 
-	public static class Wi extends Project {
+	public static class Wi extends Model {
 
 		private static final long serialVersionUID = -5237741099036357033L;
 
-		static WrapCopier<Wi, Project> copier = WrapCopierFactory.wi(Wi.class, Project.class, null,
+		static WrapCopier<Wi, Model> copier = WrapCopierFactory.wi(Wi.class, Model.class,
+				ListTools.toList(Model.neuralNetworkType_FIELDNAME, Model.dataType_FIELDNAME, Model.name_FIELDNAME,
+						Model.description_FIELDNAME, Model.alias_FIELDNAME, Model.inValueScriptText_FIELDNAME,
+						Model.outValueScriptText_FIELDNAME, Model.attachmentScriptText_FIELDNAME,
+						Model.processList_FIELDNAME, Model.applicationList_FIELDNAME, Model.inValueCount_FIELDNAME,
+						Model.outValueCount_FIELDNAME, Model.maxResult_FIELDNAME, Model.propertyMap_FIELDNAME,
+						Model.analyzeType_FIELDNAME),
 				JpaObject.FieldsUnmodify);
-
 	}
 
 }

+ 7 - 7
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/BaseAction.java

@@ -10,14 +10,14 @@ import com.x.query.assemble.designer.Business;
 import com.x.query.core.entity.neural.Entry;
 import com.x.query.core.entity.neural.InValue;
 import com.x.query.core.entity.neural.OutValue;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
 	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
 
-	protected Long cleanOutValue(Business business, Project project) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(OutValue.class, OutValue.project_FIELDNAME,
+	protected Long cleanOutValue(Business business, Model project) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(OutValue.class, OutValue.model_FIELDNAME,
 				project.getId());
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
@@ -28,8 +28,8 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return count;
 	}
 
-	protected Long cleanInValue(Business business, Project project) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(InValue.class, InValue.project_FIELDNAME,
+	protected Long cleanInValue(Business business, Model project) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(InValue.class, InValue.model_FIELDNAME,
 				project.getId());
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
@@ -40,8 +40,8 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return count;
 	}
 
-	protected Long cleanEntry(Business business, Project project) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(Entry.class, Entry.project_FIELDNAME,
+	protected Long cleanEntry(Business business, Model project) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(Entry.class, Entry.model_FIELDNAME,
 				project.getId());
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {

+ 2 - 2
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionEntryEmpty.java

@@ -6,7 +6,7 @@ class ExceptionEntryEmpty extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionEntryEmpty(String projectName) {
-		super("神经网络多层感知机({})项目训练数据集为空.", projectName);
+	ExceptionEntryEmpty(String model) {
+		super("神经网络多层感知机({})项目训练数据集为空.", model);
 	}
 }

+ 2 - 2
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionGenerating.java

@@ -6,7 +6,7 @@ class ExceptionGenerating extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionGenerating(String projectName) {
-		super("神经网络多层感知机({})项目正在生成中.", projectName);
+	ExceptionGenerating(String model) {
+		super("神经网络多层感知机({})项目正在生成中.", model);
 	}
 }

+ 2 - 2
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/ExceptionLearning.java

@@ -6,7 +6,7 @@ class ExceptionLearning extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionLearning(String projectName) {
-		super("神经网络多层感知机({})项目正在学习中.", projectName);
+	ExceptionLearning(String model) {
+		super("神经网络多层感知机({})项目正在学习中.", model);
 	}
 }

+ 43 - 43
o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/neural/NeuralAction.java

@@ -34,16 +34,16 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	private static Logger logger = LoggerFactory.getLogger(NeuralAction.class);
 
-	@JaxrsMethodDescribe(value = "列示所有项目.", action = ActionListProject.class)
+	@JaxrsMethodDescribe(value = "列示所有模型.", action = ActionListModel.class)
 	@GET
-	@Path("list/project")
+	@Path("list/model")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void listProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
-		ActionResult<List<ActionListProject.Wo>> result = new ActionResult<>();
+	public void listModel(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
+		ActionResult<List<ActionListModel.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionListProject().execute(effectivePerson);
+			result = new ActionListModel().execute(effectivePerson);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -51,17 +51,17 @@ public class NeuralAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
 	}
 
-	@JaxrsMethodDescribe(value = "创建项目.", action = ActionCreateProject.class)
+	@JaxrsMethodDescribe(value = "创建模型.", action = ActionCreateModel.class)
 	@POST
-	@Path("project")
+	@Path("model")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void createProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+	public void createModel(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			JsonElement jsonElement) {
-		ActionResult<ActionCreateProject.Wo> result = new ActionResult<>();
+		ActionResult<ActionCreateModel.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionCreateProject().execute(effectivePerson, jsonElement);
+			result = new ActionCreateModel().execute(effectivePerson, jsonElement);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, jsonElement);
 			result.error(e);
@@ -69,17 +69,17 @@ public class NeuralAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
 	}
 
-	@JaxrsMethodDescribe(value = "更新项目.", action = ActionUpdateProject.class)
+	@JaxrsMethodDescribe(value = "更新模型.", action = ActionUpdateModel.class)
 	@PUT
-	@Path("project/{projectFlag}")
+	@Path("model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void updateProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag, JsonElement jsonElement) {
-		ActionResult<ActionUpdateProject.Wo> result = new ActionResult<>();
+	public void updateModel(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag, JsonElement jsonElement) {
+		ActionResult<ActionUpdateModel.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionUpdateProject().execute(effectivePerson, projectFlag, jsonElement);
+			result = new ActionUpdateModel().execute(effectivePerson, modelFlag, jsonElement);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, jsonElement);
 			result.error(e);
@@ -87,17 +87,17 @@ public class NeuralAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
 	}
 
-	@JaxrsMethodDescribe(value = "获取项目.", action = ActionGetProject.class)
+	@JaxrsMethodDescribe(value = "获取模型.", action = ActionGetModel.class)
 	@GET
-	@Path("project/{projectFlag}")
+	@Path("model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void getProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
-		ActionResult<ActionGetProject.Wo> result = new ActionResult<>();
+	public void getModel(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
+		ActionResult<ActionGetModel.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionGetProject().execute(effectivePerson, projectFlag);
+			result = new ActionGetModel().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -105,17 +105,17 @@ public class NeuralAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
 	}
 
-	@JaxrsMethodDescribe(value = "删除项目.", action = ActionDeleteProject.class)
+	@JaxrsMethodDescribe(value = "删除项目.", action = ActionDeleteModel.class)
 	@DELETE
-	@Path("project/{projectFlag}")
+	@Path("model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void deleteProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
-		ActionResult<ActionDeleteProject.Wo> result = new ActionResult<>();
+	public void deleteModel(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
+		ActionResult<ActionDeleteModel.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionDeleteProject().execute(effectivePerson, projectFlag);
+			result = new ActionDeleteModel().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -125,15 +125,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "创建条目.", action = ActionGenerate.class)
 	@GET
-	@Path("generate/project/{projectFlag}")
+	@Path("generate/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void generate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionGenerate.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionGenerate().execute(effectivePerson, projectFlag);
+			result = new ActionGenerate().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -143,15 +143,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "停止创建条目.", action = ActionStopGenerating.class)
 	@GET
-	@Path("stop/generating/project/{projectFlag}")
+	@Path("stop/generating/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void stopGenerating(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionStopGenerating.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionStopGenerating().execute(effectivePerson, projectFlag);
+			result = new ActionStopGenerating().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -161,15 +161,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "学习.", action = ActionLearn.class)
 	@GET
-	@Path("learn/project/{projectFlag}")
+	@Path("learn/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void learn(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionLearn.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionLearn().execute(effectivePerson, projectFlag);
+			result = new ActionLearn().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -179,15 +179,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "停止学习.", action = ActionStopLearning.class)
 	@GET
-	@Path("stop/learn/project/{projectFlag}")
+	@Path("stop/learn/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void stopLearning(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionStopLearning.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionStopLearning().execute(effectivePerson, projectFlag);
+			result = new ActionStopLearning().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -197,15 +197,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "重置状态.", action = ActionResetStatus.class)
 	@GET
-	@Path("project/{projectFlag}/reset/status")
+	@Path("model/{modelFlag}/reset/status")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void resetStatus(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionResetStatus.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionResetStatus().execute(effectivePerson, projectFlag);
+			result = new ActionResetStatus().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);

+ 0 - 46
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionCalculate.java

@@ -1,46 +0,0 @@
-package com.x.query.assemble.surface.jaxrs.neural;
-
-import com.x.base.core.container.EntityManagerContainer;
-import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.Applications;
-import com.x.base.core.project.x_query_service_processing;
-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.WrapStringList;
-import com.x.base.core.project.logger.Logger;
-import com.x.base.core.project.logger.LoggerFactory;
-import com.x.processplatform.core.entity.content.Work;
-import com.x.query.assemble.surface.ThisApplication;
-import com.x.query.core.entity.neural.Project;
-
-class ActionCalculate extends BaseAction {
-
-	private static Logger logger = LoggerFactory.getLogger(ActionCalculate.class);
-
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag, String workId) throws Exception {
-		logger.debug(effectivePerson, "projectFlag:{}, workId:{}.", projectFlag, workId);
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
-			}
-			Work work = emc.flag(workId, Work.class);
-			if (null == work) {
-				throw new ExceptionEntityNotExist(workId, Work.class);
-			}
-			Wo wo = ThisApplication
-					.context().applications().getQuery(x_query_service_processing.class, Applications
-							.joinQueryUri("neural", "calculate", "project", project.getId(), "work", work.getId()))
-					.getData(Wo.class);
-			result.setData(wo);
-			return result;
-		}
-	}
-
-	public static class Wo extends WrapStringList {
-
-	}
-
-}

+ 69 - 0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/ActionListCalculate.java

@@ -0,0 +1,69 @@
+package com.x.query.assemble.surface.jaxrs.neural;
+
+import java.util.List;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.Applications;
+import com.x.base.core.project.x_query_service_processing;
+import com.x.base.core.project.exception.ExceptionEntityNotExist;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.processplatform.core.entity.content.Work;
+import com.x.query.assemble.surface.ThisApplication;
+import com.x.query.core.entity.neural.Model;
+
+class ActionListCalculate extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionListCalculate.class);
+
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String projectFlag, String workId)
+			throws Exception {
+		logger.debug(effectivePerson, "projectFlag:{}, workId:{}.", projectFlag, workId);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			ActionResult<List<Wo>> result = new ActionResult<>();
+			Model model = emc.flag(projectFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(projectFlag, Model.class);
+			}
+			Work work = emc.flag(workId, Work.class);
+			if (null == work) {
+				throw new ExceptionEntityNotExist(workId, Work.class);
+			}
+			List<Wo> wos = ThisApplication
+					.context().applications().getQuery(x_query_service_processing.class, Applications
+							.joinQueryUri("neural", "list", "calculate", "model", model.getId(), "work", work.getId()))
+					.getDataAsList(Wo.class);
+			result.setData(wos);
+			return result;
+		}
+	}
+
+	public static class Wo extends GsonPropertyObject {
+
+		private Double score;
+
+		private String value;
+
+		public Double getScore() {
+			return score;
+		}
+
+		public void setScore(Double score) {
+			this.score = score;
+		}
+
+		public String getValue() {
+			return value;
+		}
+
+		public void setValue(String value) {
+			this.value = value;
+		}
+
+	}
+
+}

+ 5 - 3
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/neural/NeuralAction.java

@@ -1,5 +1,7 @@
 package com.x.query.assemble.surface.jaxrs.neural;
 
+import java.util.List;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
@@ -27,7 +29,7 @@ public class NeuralAction extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(NeuralAction.class);
 
-	@JaxrsMethodDescribe(value = "获取指定的Application信息,并在Control段附带其操作权限.", action = ActionCalculate.class)
+	@JaxrsMethodDescribe(value = "获取指定的Application信息,并在Control段附带其操作权限.", action = ActionListCalculate.class)
 	@GET
 	@Path("calculate/project/{projectFlag}/work/{workId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@@ -35,10 +37,10 @@ public class NeuralAction extends BaseAction {
 	public void calculate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag,
 			@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
-		ActionResult<ActionCalculate.Wo> result = new ActionResult<>();
+		ActionResult<List<ActionListCalculate.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionCalculate().execute(effectivePerson, projectFlag, workId);
+			result = new ActionListCalculate().execute(effectivePerson, projectFlag, workId);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);

+ 2 - 2
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/PersistenceProperties.java

@@ -38,9 +38,9 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
 
 	public static class Neural {
 
-		public static class Project {
+		public static class Model {
 
-			public static final String table = "QRY_NRL_PROJECT";
+			public static final String table = "QRY_NRL_MODEL";
 		}
 
 		public static class OutValue {

+ 13 - 13
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/Entry.java

@@ -83,12 +83,12 @@ public class Entry extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String title;
 
-	public static final String project_FIELDNAME = "project";
-	@FieldDescribe("project")
-	@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
+	public static final String model_FIELDNAME = "model";
+	@FieldDescribe("模型")
+	@Column(length = length_id, name = ColumnNamePrefix + model_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + model_FIELDNAME)
 	@CheckPersist(allowEmpty = false)
-	private String project;
+	private String model;
 
 	public static final String inValueLabelList_FIELDNAME = "inValueLabelList";
 	@FieldDescribe("输入标签")
@@ -144,10 +144,6 @@ public class Entry extends SliceJpaObject {
 		this.title = title;
 	}
 
-	public String getProject() {
-		return project;
-	}
-
 	public List<Integer> getInValueLabelList() {
 		return inValueLabelList;
 	}
@@ -180,10 +176,6 @@ public class Entry extends SliceJpaObject {
 		this.outValueCount = outValueCount;
 	}
 
-	public void setProject(String project) {
-		this.project = project;
-	}
-
 	public String getType() {
 		return type;
 	}
@@ -192,4 +184,12 @@ public class Entry extends SliceJpaObject {
 		this.type = type;
 	}
 
+	public String getModel() {
+		return model;
+	}
+
+	public void setModel(String model) {
+		this.model = model;
+	}
+
 }

+ 13 - 13
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/InText.java

@@ -58,12 +58,12 @@ public class InText extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String text;
 
-	public static final String project_FIELDNAME = "project";
-	@FieldDescribe("项目")
-	@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
+	public static final String model_FIELDNAME = "model";
+	@FieldDescribe("模型")
+	@Column(length = length_id, name = ColumnNamePrefix + model_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + model_FIELDNAME)
 	@CheckPersist(allowEmpty = false)
-	private String project;
+	private String model;
 
 	public static final String serial_FIELDNAME = "serial";
 	@FieldDescribe("编号")
@@ -87,14 +87,6 @@ public class InText extends SliceJpaObject {
 		this.text = text;
 	}
 
-	public String getProject() {
-		return project;
-	}
-
-	public void setProject(String project) {
-		this.project = project;
-	}
-
 	public Integer getCount() {
 		return count;
 	}
@@ -111,4 +103,12 @@ public class InText extends SliceJpaObject {
 		this.serial = serial;
 	}
 
+	public String getModel() {
+		return model;
+	}
+
+	public void setModel(String model) {
+		this.model = model;
+	}
+
 }

+ 13 - 14
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/InValue.java

@@ -58,12 +58,12 @@ public class InValue extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String text;
 
-	public static final String project_FIELDNAME = "project";
-	@FieldDescribe("项目")
-	@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
+	public static final String model_FIELDNAME = "model";
+	@FieldDescribe("模型")
+	@Column(length = length_id, name = ColumnNamePrefix + model_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + model_FIELDNAME)
 	@CheckPersist(allowEmpty = false)
-	private String project;
+	private String model;
 
 	public static final String serial_FIELDNAME = "serial";
 	@FieldDescribe("编号")
@@ -94,14 +94,6 @@ public class InValue extends SliceJpaObject {
 		this.text = text;
 	}
 
-	public String getProject() {
-		return project;
-	}
-
-	public void setProject(String project) {
-		this.project = project;
-	}
-
 	public Integer getCount() {
 		return count;
 	}
@@ -110,7 +102,6 @@ public class InValue extends SliceJpaObject {
 		this.count = count;
 	}
 
- 
 	public Integer getSerial() {
 		return serial;
 	}
@@ -127,4 +118,12 @@ public class InValue extends SliceJpaObject {
 		this.inTextSerial = inTextSerial;
 	}
 
+	public String getModel() {
+		return model;
+	}
+
+	public void setModel(String model) {
+		this.model = model;
+	}
+
 }

+ 63 - 93
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/Project.java → o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/Model.java

@@ -54,16 +54,16 @@ import com.x.query.core.entity.PersistenceProperties;
 
 @Entity
 @ContainerEntity
-@Table(name = PersistenceProperties.Neural.Project.table, uniqueConstraints = {
-		@UniqueConstraint(name = PersistenceProperties.Neural.Project.table + JpaObject.IndexNameMiddle
+@Table(name = PersistenceProperties.Neural.Model.table, uniqueConstraints = {
+		@UniqueConstraint(name = PersistenceProperties.Neural.Model.table + JpaObject.IndexNameMiddle
 				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
 						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
-public class Project extends SliceJpaObject {
+public class Model extends SliceJpaObject {
 
 	private static final long serialVersionUID = -5610293696763235753L;
 
-	private static final String TABLE = PersistenceProperties.Neural.Project.table;
+	private static final String TABLE = PersistenceProperties.Neural.Model.table;
 
 	public String getId() {
 		return id;
@@ -76,11 +76,11 @@ public class Project extends SliceJpaObject {
 	@FieldDescribe("数据库主键,自动生成.")
 	@Id
 	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
-	@CheckRemove(citationNotExists = { @CitationNotExist(type = Entry.class, fields = Entry.project_FIELDNAME),
-			@CitationNotExist(type = InText.class, fields = InText.project_FIELDNAME),
-			@CitationNotExist(type = OutText.class, fields = OutText.project_FIELDNAME),
-			@CitationNotExist(type = InValue.class, fields = InValue.project_FIELDNAME),
-			@CitationNotExist(type = OutValue.class, fields = OutValue.project_FIELDNAME) })
+	@CheckRemove(citationNotExists = { @CitationNotExist(type = Entry.class, fields = Entry.model_FIELDNAME),
+			@CitationNotExist(type = InText.class, fields = InText.model_FIELDNAME),
+			@CitationNotExist(type = OutText.class, fields = OutText.model_FIELDNAME),
+			@CitationNotExist(type = InValue.class, fields = InValue.model_FIELDNAME),
+			@CitationNotExist(type = OutValue.class, fields = OutValue.model_FIELDNAME) })
 	private String id = createId();
 
 	/* 以上为 JpaObject 默认字段 */
@@ -121,8 +121,8 @@ public class Project extends SliceJpaObject {
 	public static final String STATUS_GENERATING = "generating";
 	public static final String STATUS_LEARNING = "learning";
 
-	public static final String TYPE_PROCESSPLATFORM = "processPlatform";
-	public static final String TYPE_CMS = "cms";
+	public static final String DATATYPE_PROCESSPLATFORM = "processPlatform";
+	public static final String DATATYPE_CMS = "cms";
 
 	public static final String NEURALNETWORKTYPE_MLP = "mlp";
 
@@ -195,16 +195,16 @@ public class Project extends SliceJpaObject {
 	}
 
 	public static final String neuralNetworkType_FIELDNAME = "neuralNetworkType";
-	@FieldDescribe(NEURALNETWORKTYPE_MLP)
+	@FieldDescribe("神经网络类型:" + NEURALNETWORKTYPE_MLP + ".")
 	@Column(length = length_32B, name = ColumnNamePrefix + neuralNetworkType_FIELDNAME)
 	@CheckPersist(allowEmpty = true, simplyString = false)
 	private String neuralNetworkType;
 
-	public static final String type_FIELDNAME = "type";
-	@FieldDescribe(TYPE_CMS + "," + TYPE_PROCESSPLATFORM)
-	@Column(length = length_32B, name = ColumnNamePrefix + type_FIELDNAME)
+	public static final String dataType_FIELDNAME = "dataType";
+	@FieldDescribe("数据类型:" + DATATYPE_CMS + "," + DATATYPE_PROCESSPLATFORM)
+	@Column(length = length_32B, name = ColumnNamePrefix + dataType_FIELDNAME)
 	@CheckPersist(allowEmpty = true, simplyString = false)
-	private String type;
+	private String dataType;
 
 	public static final String name_FIELDNAME = "name";
 	@Flag
@@ -213,7 +213,7 @@ public class Project extends SliceJpaObject {
 	@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
 	@CheckPersist(allowEmpty = false, citationNotExists =
 	/* 检查不重名 */
-	@CitationNotExist(type = Project.class, fields = { "id", "name", "alias" }))
+	@CitationNotExist(type = Model.class, fields = { "id", "name", "alias" }))
 	private String name;
 
 	public static final String description_FIELDNAME = "description";
@@ -228,7 +228,7 @@ public class Project extends SliceJpaObject {
 	@Column(length = length_255B, name = ColumnNamePrefix + alias_FIELDNAME)
 	@CheckPersist(allowEmpty = true, citationNotExists =
 	/* 同一个应用下不可重名 */
-	@CitationNotExist(type = Project.class, fields = { "id", "name", "alias" }))
+	@CitationNotExist(type = Model.class, fields = { "id", "name", "alias" }))
 	private String alias;
 
 	public static final String inValueScriptText_FIELDNAME = "inValueScriptText";
@@ -277,6 +277,42 @@ public class Project extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private List<String> applicationList;
 
+	public static final String analyzeType_FIELDNAME = "analyzeType";
+	@FieldDescribe("分析类型,default,full,customized")
+	@Column(length = length_32B, name = ColumnNamePrefix + analyzeType_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String analyzeType;
+
+	public static final String maxResult_FIELDNAME = "maxResult";
+	@FieldDescribe("最大输出值")
+	@Column(name = ColumnNamePrefix + maxResult_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Integer maxResult;
+
+	public static final String inValueCount_FIELDNAME = "inValueCount";
+	@FieldDescribe("输入数量")
+	@Column(name = ColumnNamePrefix + inValueCount_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Integer inValueCount;
+
+	public static final String outValueCount_FIELDNAME = "outValueCount";
+	@FieldDescribe("输出数量")
+	@Column(name = ColumnNamePrefix + outValueCount_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private Integer outValueCount;
+
+	public static final String propertyMap_FIELDNAME = "propertyMap";
+	@FieldDescribe("神经网络参数.")
+	@CheckPersist(allowEmpty = true)
+	@PersistentMap(fetch = FetchType.EAGER)
+	@ContainerTable(name = TABLE + ContainerTableNameMiddle + propertyMap_FIELDNAME, joinIndex = @Index(name = TABLE
+			+ IndexNameMiddle + propertyMap_FIELDNAME + JoinIndexNameSuffix))
+	@KeyColumn(name = ColumnNamePrefix + key_FIELDNAME)
+	@ElementColumn(length = length_255B, name = ColumnNamePrefix + propertyMap_FIELDNAME)
+	@ElementIndex(name = TABLE + IndexNameMiddle + propertyMap_FIELDNAME + ElementIndexNameSuffix)
+	@KeyIndex(name = TABLE + IndexNameMiddle + propertyMap_FIELDNAME + KeyIndexNameSuffix)
+	private LinkedHashMap<String, String> propertyMap;
+
 	public static final String startDate_FIELDNAME = "startDate";
 	@FieldDescribe("开始时间")
 	@Column(name = ColumnNamePrefix + startDate_FIELDNAME)
@@ -327,36 +363,6 @@ public class Project extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String intermediateNnet;
 
-//	public static final String learningRate_FIELDNAME = "learningRate";
-//	@FieldDescribe("学习率")
-//	@Column(name = ColumnNamePrefix + learningRate_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Double learningRate;
-//
-//	public static final String momentum_FIELDNAME = "momentum";
-//	@FieldDescribe("动量")
-//	@Column(name = ColumnNamePrefix + momentum_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Double momentum;
-//
-//	public static final String maxIteration_FIELDNAME = "maxIteration";
-//	@FieldDescribe("最大学习遍数")
-//	@Column(name = ColumnNamePrefix + maxIteration_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Integer maxIteration;
-//
-//	public static final String generatingPercent_FIELDNAME = "generatingPercent";
-//	@FieldDescribe("当前条目生成进度")
-//	@Column(name = ColumnNamePrefix + generatingPercent_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Integer generatingPercent;
-//
-//	public static final String maxError_FIELDNAME = "maxError";
-//	@FieldDescribe("最大错误,使用的是均方误差")
-//	@Column(name = ColumnNamePrefix + maxError_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Double maxError;
-
 	public static final String generatingPercent_FIELDNAME = "generatingPercent";
 	@FieldDescribe("当前条目生成进度")
 	@Column(name = ColumnNamePrefix + generatingPercent_FIELDNAME)
@@ -369,24 +375,6 @@ public class Project extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private Double totalError;
 
-	public static final String inValueCount_FIELDNAME = "inValueCount";
-	@FieldDescribe("输入数量")
-	@Column(name = ColumnNamePrefix + inValueCount_FIELDNAME)
-	@CheckPersist(allowEmpty = true)
-	private Integer inValueCount;
-
-	public static final String outValueCount_FIELDNAME = "outValueCount";
-	@FieldDescribe("输出数量")
-	@Column(name = ColumnNamePrefix + outValueCount_FIELDNAME)
-	@CheckPersist(allowEmpty = true)
-	private Integer outValueCount;
-
-	public static final String maxResult_FIELDNAME = "maxResult";
-	@FieldDescribe("最大输出值")
-	@Column(name = ColumnNamePrefix + maxResult_FIELDNAME)
-	@CheckPersist(allowEmpty = true)
-	private Integer maxResult;
-
 	public static final String learnEntryCount_FIELDNAME = "learnEntryCount";
 	@FieldDescribe("学习条目数量")
 	@Column(name = ColumnNamePrefix + learnEntryCount_FIELDNAME)
@@ -400,37 +388,11 @@ public class Project extends SliceJpaObject {
 	private Integer validationEntryCount;
 
 	public static final String validationMeanSquareError_FIELDNAME = "validationMeanSquareError";
-	@FieldDescribe("测试比例")
+	@FieldDescribe("测试结果")
 	@Column(name = ColumnNamePrefix + validationMeanSquareError_FIELDNAME)
 	@CheckPersist(allowEmpty = true)
 	private Double validationMeanSquareError;
 
-	public static final String analyzeType_FIELDNAME = "analyzeType";
-	@FieldDescribe("分析类型,default,full,customized")
-	@Column(length = length_32B, name = ColumnNamePrefix + analyzeType_FIELDNAME)
-	@CheckPersist(allowEmpty = true)
-	private String analyzeType;
-
-	public static final String propertyMap_FIELDNAME = "propertyMap";
-	@FieldDescribe("神经网络参数.")
-	@CheckPersist(allowEmpty = true)
-	@PersistentMap(fetch = FetchType.EAGER)
-	@ContainerTable(name = TABLE + ContainerTableNameMiddle + propertyMap_FIELDNAME, joinIndex = @Index(name = TABLE
-			+ IndexNameMiddle + propertyMap_FIELDNAME + JoinIndexNameSuffix))
-	@KeyColumn(name = ColumnNamePrefix + key_FIELDNAME)
-	@ElementColumn(length = length_255B, name = ColumnNamePrefix + propertyMap_FIELDNAME)
-	@ElementIndex(name = TABLE + IndexNameMiddle + propertyMap_FIELDNAME + ElementIndexNameSuffix)
-	@KeyIndex(name = TABLE + IndexNameMiddle + propertyMap_FIELDNAME + KeyIndexNameSuffix)
-	private LinkedHashMap<String, String> propertyMap;
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
 	public String getName() {
 		return name;
 	}
@@ -635,4 +597,12 @@ public class Project extends SliceJpaObject {
 		this.propertyMap = propertyMap;
 	}
 
+	public String getDataType() {
+		return dataType;
+	}
+
+	public void setDataType(String dataType) {
+		this.dataType = dataType;
+	}
+
 }

+ 13 - 13
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/OutText.java

@@ -58,12 +58,12 @@ public class OutText extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String text;
 
-	public static final String project_FIELDNAME = "project";
-	@FieldDescribe("项目")
-	@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
+	public static final String model_FIELDNAME = "model";
+	@FieldDescribe("模型")
+	@Column(length = length_id, name = ColumnNamePrefix + model_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + model_FIELDNAME)
 	@CheckPersist(allowEmpty = false)
-	private String project;
+	private String model;
 
 	public static final String serial_FIELDNAME = "serial";
 	@FieldDescribe("编号")
@@ -79,14 +79,6 @@ public class OutText extends SliceJpaObject {
 	@CheckPersist(allowEmpty = false)
 	private Integer count;
 
-	public String getProject() {
-		return project;
-	}
-
-	public void setProject(String project) {
-		this.project = project;
-	}
-
 	public String getText() {
 		return text;
 	}
@@ -111,4 +103,12 @@ public class OutText extends SliceJpaObject {
 		this.serial = serial;
 	}
 
+	public String getModel() {
+		return model;
+	}
+
+	public void setModel(String model) {
+		this.model = model;
+	}
+
 }

+ 13 - 13
o2server/x_query_core_entity/src/main/java/com/x/query/core/entity/neural/OutValue.java

@@ -58,12 +58,12 @@ public class OutValue extends SliceJpaObject {
 	@CheckPersist(allowEmpty = true)
 	private String text;
 
-	public static final String project_FIELDNAME = "project";
-	@FieldDescribe("项目")
-	@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
+	public static final String model_FIELDNAME = "model";
+	@FieldDescribe("模型")
+	@Column(length = length_id, name = ColumnNamePrefix + model_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + model_FIELDNAME)
 	@CheckPersist(allowEmpty = false)
-	private String project;
+	private String model;
 
 	public static final String serial_FIELDNAME = "serial";
 	@FieldDescribe("编号")
@@ -79,14 +79,6 @@ public class OutValue extends SliceJpaObject {
 	@CheckPersist(allowEmpty = false)
 	private Integer count;
 
-	public String getProject() {
-		return project;
-	}
-
-	public void setProject(String project) {
-		this.project = project;
-	}
-
 	public String getText() {
 		return text;
 	}
@@ -111,4 +103,12 @@ public class OutValue extends SliceJpaObject {
 		this.serial = serial;
 	}
 
+	public String getModel() {
+		return model;
+	}
+
+	public void setModel(String model) {
+		this.model = model;
+	}
+
 }

+ 86 - 55
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionCalculateWithWork.java

@@ -3,11 +3,11 @@ package com.x.query.service.processing.jaxrs.neural;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Objects;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.math3.stat.StatUtils;
 import org.neuroph.core.NeuralNetwork;
 import org.neuroph.nnet.learning.MomentumBackpropagation;
 import org.neuroph.util.NeuralNetworkCODEC;
@@ -20,9 +20,9 @@ import com.x.base.core.entity.dataitem.ItemCategory;
 import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
+import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
-import com.x.base.core.project.jaxrs.WrapStringList;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.scripting.ScriptHelper;
@@ -33,8 +33,8 @@ import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.query.core.entity.Item;
 import com.x.query.core.entity.neural.InValue;
+import com.x.query.core.entity.neural.Model;
 import com.x.query.core.entity.neural.OutValue;
-import com.x.query.core.entity.neural.Project;
 import com.x.query.service.processing.Business;
 import com.x.query.service.processing.ThisApplication;
 import com.x.query.service.processing.helper.ExtractTextHelper;
@@ -46,30 +46,30 @@ class ActionCalculateWithWork extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionCalculateWithWork.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag, String workId) throws Exception {
-		logger.debug(effectivePerson, "projectFlag:{}, workId:{}.", projectFlag, workId);
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String modelFlag, String workId) throws Exception {
+		logger.debug(effectivePerson, "modelFlag:{}, workId:{}.", modelFlag, workId);
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			ActionResult<Wo> result = new ActionResult<>();
+			ActionResult<List<Wo>> result = new ActionResult<>();
 			Business business = new Business(emc);
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (StringUtils.isEmpty(project.getNnet())) {
-				throw new ExceptionProjectNotReady(project.getName());
+			if (StringUtils.isEmpty(model.getNnet())) {
+				throw new ExceptionModelNotReady(model.getName());
 			}
 			NeuralNetwork<MomentumBackpropagation> neuralNetwork = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), project.getId());
+			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), model.getId());
 			Element element = cache.get(cacheKey);
 			if (null != element && (null != element.getObjectValue())) {
 				neuralNetwork = ((NeuralNetwork<MomentumBackpropagation>) element.getObjectValue());
 			} else {
-				if (StringUtils.isEmpty(project.getNnet())) {
-					throw new ExceptionProjectNotReady(project.getName());
+				if (StringUtils.isEmpty(model.getNnet())) {
+					throw new ExceptionModelNotReady(model.getName());
 				}
-				neuralNetwork = project.createNeuralNetwork();
+				neuralNetwork = model.createNeuralNetwork();
 				NeuralNetworkCODEC.array2network(
-						DoubleTools.byteToDoubleArray(ByteTools.decompressBase64String(project.getNnet())),
+						DoubleTools.byteToDoubleArray(ByteTools.decompressBase64String(model.getNnet())),
 						neuralNetwork);
 				cache.put(new Element(cacheKey, neuralNetwork));
 			}
@@ -78,34 +78,34 @@ class ActionCalculateWithWork extends BaseAction {
 			if (null == work) {
 				throw new ExceptionEntityNotExist(workId, Work.class);
 			}
-			TreeSet<String> inValue = this.convert(business, project, work);
-			double[] inputs = this.inputData(business, project, inValue);
+			TreeSet<String> inValue = this.convert(business, model, work);
+			double[] inputs = this.inputData(business, model, inValue);
 			neuralNetwork.setInput(inputs);
 			neuralNetwork.calculate();
 			double[] outputs = neuralNetwork.getOutput();
-			double mean = StatUtils.mean(outputs);
+			// double mean = StatUtils.mean(outputs);
 			List<Pair> pairs = new ArrayList<>();
 			for (int i = 0; i < outputs.length; i++) {
-				if (outputs[i] > mean) {
-					Pair p = new Pair();
-					p.setOut(outputs[i]);
-					p.setSerial(i);
-					pairs.add(p);
-				}
+				// if (outputs[i] > mean) {
+				Pair p = new Pair();
+				p.setOut(outputs[i]);
+				p.setSerial(i);
+				pairs.add(p);
+				// }
 			}
 			pairs = pairs.stream().sorted(Comparator.comparing(Pair::getOut).reversed()).collect(Collectors.toList());
-			Integer maxResult = MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_MAXRESULT,
-					Project.DEFAULT_MLP_MAXRESULT);
+			Integer maxResult = MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_MAXRESULT,
+					Model.DEFAULT_MLP_MAXRESULT);
 			if (pairs.size() > maxResult) {
 				pairs = pairs.stream().limit(maxResult).collect(Collectors.toList());
 			}
-			wo.getValueList().addAll(this.outputData(business, project, pairs));
-			result.setData(wo);
+			List<Wo> wos = this.outputData(business, model, pairs);
+			result.setData(wos);
 			return result;
 		}
 	}
 
-	private TreeSet<String> convert(Business business, Project project, Work work) throws Exception {
+	private TreeSet<String> convert(Business business, Model model, Work work) throws Exception {
 		ScriptHelper scriptHelper = new ScriptHelper();
 		LanguageProcessingHelper lph = new LanguageProcessingHelper();
 		DataItemConverter<Item> converter = new DataItemConverter<Item>(Item.class);
@@ -126,58 +126,70 @@ class ActionCalculateWithWork extends BaseAction {
 				}
 			}
 		}
-		switch (StringUtils.trimToEmpty(project.getAnalyzeType())) {
-		case Project.ANALYZETYPE_FULL:
-			lph.word(text.toString()).stream().limit(MapTools.getInteger(project.getPropertyMap(),
-					Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
+		switch (StringUtils.trimToEmpty(model.getAnalyzeType())) {
+		case Model.ANALYZETYPE_FULL:
+			lph.word(text.toString()).stream().limit(MapTools.getInteger(model.getPropertyMap(),
+					Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
 					.forEach(o -> {
 						inValue.add(o.getValue());
 					});
 			break;
-		case Project.ANALYZETYPE_CUSTOMIZED:
+		case Model.ANALYZETYPE_CUSTOMIZED:
 			break;
 		default:
 			inValue.addAll(HanLP
 					.extractKeyword(text.toString(),
-							MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
-									Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE) * 2)
-					.stream().filter(o -> o.length() > 1)
-					.limit(MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
-							Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
+							MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
+									Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE) * 2)
+					.stream().filter(o -> o.length() > 1).limit(MapTools.getInteger(model.getPropertyMap(),
+							Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
 					.collect(Collectors.toList()));
 			break;
 		}
-		if (StringUtils.isNotBlank(project.getInValueScriptText())) {
+		if (StringUtils.isNotBlank(model.getInValueScriptText())) {
 			scriptHelper.put(PROPERTY_INVALUES, inValue);
-			scriptHelper.eval(project.getInValueScriptText());
+			scriptHelper.eval(model.getInValueScriptText());
 		}
 		return inValue;
 	}
 
-	private double[] inputData(Business business, Project project, TreeSet<String> inputs) throws Exception {
+	private double[] inputData(Business business, Model model, TreeSet<String> inputs) throws Exception {
 		List<String> values = new ArrayList<>();
 		values.addAll(inputs);
-		List<InValue> os = business.entityManagerContainer().listEqualAndIn(InValue.class, InValue.project_FIELDNAME,
-				project.getId(), InValue.text_FIELDNAME, values);
-		double[] data = new double[project.getInValueCount()];
+		List<InValue> os = business.entityManagerContainer().listEqualAndIn(InValue.class, InValue.model_FIELDNAME,
+				model.getId(), InValue.text_FIELDNAME, values);
+		double[] data = new double[model.getInValueCount()];
 		for (InValue in : os) {
 			data[in.getSerial()] = 1.0d;
 		}
 		return data;
 	}
 
-	private List<String> outputData(Business business, Project project, List<Pair> pairs) throws Exception {
-		List<String> list = new ArrayList<>();
+	private List<Wo> outputData(Business business, Model model, List<Pair> pairs) throws Exception {
+		List<Wo> wos = new ArrayList<>();
 		List<Integer> values = new ArrayList<>();
 		for (Pair p : pairs) {
 			values.add(p.getSerial());
 		}
-		List<OutValue> os = business.entityManagerContainer().listEqualAndIn(OutValue.class, OutValue.project_FIELDNAME,
-				project.getId(), OutValue.serial_FIELDNAME, values);
-		os.stream().forEach(o -> {
-			list.add(o.getText());
-		});
-		return list;
+		List<OutValue> os = business.entityManagerContainer().listEqualAndIn(OutValue.class, OutValue.model_FIELDNAME,
+				model.getId(), OutValue.serial_FIELDNAME, values);
+		String text = "";
+		for (Pair pair : pairs) {
+			text = "";
+			for (OutValue o : os) {
+				if (Objects.equals(o.getSerial(), pair.getSerial())) {
+					text = o.getText();
+					break;
+				}
+			}
+			if (StringUtils.isNotEmpty(text)) {
+				Wo wo = new Wo();
+				wo.setScore(pair.getOut());
+				wo.setValue(text);
+				wos.add(wo);
+			}
+		}
+		return wos;
 	}
 
 	public static class Pair {
@@ -201,7 +213,26 @@ class ActionCalculateWithWork extends BaseAction {
 		}
 	}
 
-	public static class Wo extends WrapStringList {
+	public static class Wo extends GsonPropertyObject {
+
+		private Double score;
+		private String value;
+
+		public Double getScore() {
+			return score;
+		}
+
+		public void setScore(Double score) {
+			this.score = score;
+		}
+
+		public String getValue() {
+			return value;
+		}
+
+		public void setValue(String value) {
+			this.value = value;
+		}
 
 	}
 

+ 8 - 8
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionGenerate.java

@@ -36,28 +36,28 @@ import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionGenerate extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionGenerate.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (StringUtils.isNotEmpty(Generate.generatingProject())) {
-				throw new ExceptionGenerate(project.getName());
+			if (StringUtils.isNotEmpty(Generate.generatingModel())) {
+				throw new ExceptionGenerate(model.getName());
 			}
 			new Thread() {
 				public void run() {
 					Generate generate;
 					try {
 						generate = Generate.newInstance();
-						generate.execute(project.getId());
+						generate.execute(model.getId());
 					} catch (Exception e) {
 						logger.error(e);
 					}

+ 8 - 8
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionLearn.java

@@ -10,28 +10,28 @@ import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionLearn extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionLearn.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
-			if (StringUtils.isNotEmpty(Learn.learningProject())) {
-				throw new ExceptionLearn(project.getName());
+			if (StringUtils.isNotEmpty(Learn.learningModel())) {
+				throw new ExceptionLearn(model.getName());
 			}
 			new Thread() {
 				public void run() {
 					Learn learn;
 					try {
 						learn = Learn.newInstance();
-						learn.execute(project.getId());
+						learn.execute(model.getId());
 					} catch (Exception e) {
 						logger.error(e);
 					}

+ 5 - 5
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionStopGenerating.java

@@ -32,15 +32,15 @@ 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.WrapBoolean;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionStopGenerating extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			Generate.stop();
 			Wo wo = new Wo();

+ 5 - 5
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ActionStopLearning.java

@@ -32,15 +32,15 @@ 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.WrapBoolean;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 class ActionStopLearning extends BaseAction {
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String projectFlag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String modelFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Project project = emc.flag(projectFlag, Project.class);
-			if (null == project) {
-				throw new ExceptionEntityNotExist(projectFlag, Project.class);
+			Model model = emc.flag(modelFlag, Model.class);
+			if (null == model) {
+				throw new ExceptionEntityNotExist(modelFlag, Model.class);
 			}
 			Learn.stop();
 			Wo wo = new Wo();

+ 2 - 2
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/BaseAction.java

@@ -4,13 +4,13 @@ import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 
 import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache cache = ApplicationCache.instance().getCache(Project.class);
+	protected Ehcache cache = ApplicationCache.instance().getCache(Model.class);
 
 	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
 

+ 2 - 2
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionBundleEmpty.java

@@ -6,7 +6,7 @@ class ExceptionBundleEmpty extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionBundleEmpty(String projectName) {
-		super("神经网络({})范围内的数据为空.");
+	ExceptionBundleEmpty(String model) {
+		super("神经网络({})范围内的数据为空.", model);
 	}
 }

+ 2 - 2
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionGenerate.java

@@ -6,7 +6,7 @@ class ExceptionGenerate extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionGenerate(String project) {
-		super("神经网络({})项目正在生成中.", project);
+	ExceptionGenerate(String model) {
+		super("神经网络({})项目正在生成中.", model);
 	}
 }

+ 2 - 2
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionLearn.java

@@ -6,7 +6,7 @@ class ExceptionLearn extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionLearn(String project) {
-		super("神经网络({})正在学习中.", project);
+	ExceptionLearn(String model) {
+		super("神经网络({})正在学习中.", model);
 	}
 }

+ 3 - 3
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionProjectNotReady.java → o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/ExceptionModelNotReady.java

@@ -2,11 +2,11 @@ package com.x.query.service.processing.jaxrs.neural;
 
 import com.x.base.core.project.exception.PromptException;
 
-class ExceptionProjectNotReady extends PromptException {
+class ExceptionModelNotReady extends PromptException {
 
 	private static final long serialVersionUID = -9089355008820123519L;
 
-	ExceptionProjectNotReady(String projectName) {
-		super("神经网络({})尚未准备就绪");
+	ExceptionModelNotReady(String model) {
+		super("神经网络({})尚未准备就绪.", model);
 	}
 }

+ 106 - 108
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/Generate.java

@@ -54,7 +54,6 @@ import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import com.x.base.core.project.queue.AbstractQueue;
 import com.x.base.core.project.scripting.ScriptHelper;
 import com.x.base.core.project.tools.ListTools;
 import com.x.base.core.project.tools.MapTools;
@@ -67,8 +66,8 @@ import com.x.processplatform.core.entity.content.WorkCompleted_;
 import com.x.query.core.entity.Item;
 import com.x.query.core.entity.neural.Entry;
 import com.x.query.core.entity.neural.InText;
+import com.x.query.core.entity.neural.Model;
 import com.x.query.core.entity.neural.OutText;
-import com.x.query.core.entity.neural.Project;
 import com.x.query.service.processing.Business;
 import com.x.query.service.processing.ThisApplication;
 import com.x.query.service.processing.helper.ExtractTextHelper;
@@ -78,7 +77,7 @@ public class Generate {
 
 	private static Logger logger = LoggerFactory.getLogger(Generate.class);
 
-	private volatile static String generatingProject = "";
+	private volatile static String generatingModel = "";
 
 	private volatile static boolean stop = false;
 
@@ -86,8 +85,8 @@ public class Generate {
 
 	}
 
-	public static String generatingProject() {
-		return generatingProject;
+	public static String generatingModel() {
+		return generatingModel;
 	}
 
 	public static void stop() {
@@ -95,41 +94,41 @@ public class Generate {
 	}
 
 	public static Generate newInstance() throws Exception {
-		if (StringUtils.isNotEmpty(generatingProject)) {
-			throw new Exception("Generate already concreted for project:" + generatingProject + ".");
+		if (StringUtils.isNotEmpty(generatingModel)) {
+			throw new Exception("Generate already concreted for model:" + generatingModel + ".");
 		}
 		return new Generate();
 	}
 
-	protected void execute(final String projectId) throws Exception {
-		generatingProject = projectId;
+	protected void execute(final String modelId) throws Exception {
+		generatingModel = modelId;
 		stop = false;
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			TimeStamp stamp = new TimeStamp();
 			Business business = new Business(emc);
-			Project project = refreshProject(business, projectId);
-			logger.info("神经网络多层感知机 ({}) 生成条目开始.", project.getName());
-			if (StringUtils.equals(Project.STATUS_GENERATING, project.getStatus())) {
-				throw new ExceptionGenerate(project.getName());
+			Model model = refreshModel(business, modelId);
+			logger.info("神经网络多层感知机 ({}) 生成条目开始.", model.getName());
+			if (StringUtils.equals(Model.STATUS_GENERATING, model.getStatus())) {
+				throw new ExceptionGenerate(model.getName());
 			}
-			final Double validationRate = (MapTools.getDouble(project.getPropertyMap(),
-					Project.PROPERTY_MLP_VALIDATIONRATE, Project.DEFAULT_MLP_VALIDATIONRATE));
-			List<String> bundles = this.listBundle(business, project);
+			final Double validationRate = (MapTools.getDouble(model.getPropertyMap(),
+					Model.PROPERTY_MLP_VALIDATIONRATE, Model.DEFAULT_MLP_VALIDATIONRATE));
+			List<String> bundles = this.listBundle(business, model);
 			if (ListTools.isEmpty(bundles)) {
-				throw new ExceptionBundleEmpty(project.getName());
+				throw new ExceptionBundleEmpty(model.getName());
 			}
 			/* 用于测试的bundle */
 			List<String> validationBundles = ListTools.randomWithRate(bundles, validationRate);
 			/* 用于学习的bandle */
 			List<String> learnBundles = ListUtils.subtract(bundles, validationBundles);
-			emc.beginTransaction(Project.class);
-			project.setStatus(Project.STATUS_GENERATING);
-			project.setGeneratingPercent(0);
-			project.setValidationEntryCount(0);
-			project.setLearnEntryCount(0);
+			emc.beginTransaction(Model.class);
+			model.setStatus(Model.STATUS_GENERATING);
+			model.setGeneratingPercent(0);
+			model.setValidationEntryCount(0);
+			model.setLearnEntryCount(0);
 			emc.commit();
 			/* 准备运算,清空数据 */
-			this.clean(business, project);
+			this.clean(business, model);
 			ScriptHelper scriptHelper = new ScriptHelper();
 			LanguageProcessingHelper lph = new LanguageProcessingHelper();
 			DataItemConverter<Item> converter = new DataItemConverter<Item>(Item.class);
@@ -145,14 +144,14 @@ public class Generate {
 				if (null != workCompleted) {
 					inValues.clear();
 					outValues.clear();
-					this.convert(business, converter, scriptHelper, lph, project, workCompleted, inValues, outValues);
+					this.convert(business, converter, scriptHelper, lph, model, workCompleted, inValues, outValues);
 					if ((!inValues.isEmpty()) && (!outValues.isEmpty())) {
-						this.createLearnEntry(business, project, workCompleted, inBag, outBag, inValues, outValues);
+						this.createLearnEntry(business, model, workCompleted, inBag, outBag, inValues, outValues);
 						learnEntryCount++;
 					}
 				}
 				if (total % 100 == 99) {
-					if (checkStop(business, projectId, bundles, total)) {
+					if (checkStop(business, modelId, bundles, total)) {
 						return;
 					}
 				}
@@ -163,52 +162,52 @@ public class Generate {
 				if (null != workCompleted) {
 					inValues.clear();
 					outValues.clear();
-					this.convert(business, converter, scriptHelper, lph, project, workCompleted, inValues, outValues);
+					this.convert(business, converter, scriptHelper, lph, model, workCompleted, inValues, outValues);
 					if ((!inValues.isEmpty()) && (!outValues.isEmpty())) {
-						this.createValidationEntry(business, project, workCompleted, inBag, outBag, inValues,
+						this.createValidationEntry(business, model, workCompleted, inBag, outBag, inValues,
 								outValues);
 						testEntryCount++;
 					}
 				}
 				if (total % 100 == 99) {
-					if (checkStop(business, projectId, bundles, total)) {
+					if (checkStop(business, modelId, bundles, total)) {
 						return;
 					}
 				}
 				total++;
 			}
-			inBag.save(business, project);
-			outBag.save(business, project);
-			project = this.refreshProject(business, projectId);
-			emc.beginTransaction(Project.class);
-			project.setStatus("");
-			project.setEntryCount(bundles.size());
-			project.setGeneratingPercent(100);
-			project.setLearnEntryCount(learnEntryCount);
-			project.setValidationEntryCount(testEntryCount);
-			emc.check(project, CheckPersistType.all);
+			inBag.save(business, model);
+			outBag.save(business, model);
+			model = this.refreshModel(business, modelId);
+			emc.beginTransaction(Model.class);
+			model.setStatus("");
+			model.setEntryCount(bundles.size());
+			model.setGeneratingPercent(100);
+			model.setLearnEntryCount(learnEntryCount);
+			model.setValidationEntryCount(testEntryCount);
+			emc.check(model, CheckPersistType.all);
 			emc.commit();
-			logger.info("神经网络多层感知机 ({}) 完成条目生成, 耗时: {}.", project.getName(), stamp.consumingMilliseconds());
+			logger.info("神经网络多层感知机 ({}) 完成条目生成, 耗时: {}.", model.getName(), stamp.consumingMilliseconds());
 		} finally {
-			generatingProject = "";
+			generatingModel = "";
 			stop = false;
 		}
 	}
 
-	private boolean checkStop(Business business, final String projectId, List<String> bundles, int i) throws Exception {
-		Project project = this.refreshProject(business, projectId);
+	private boolean checkStop(Business business, final String modelId, List<String> bundles, int i) throws Exception {
+		Model model = this.refreshModel(business, modelId);
 		if (stop) {
-			business.entityManagerContainer().beginTransaction(Project.class);
-			project.setStatus("");
+			business.entityManagerContainer().beginTransaction(Model.class);
+			model.setStatus("");
 			business.entityManagerContainer().commit();
-			logger.info("神经网络多层感知机 ({}) 项目条目生成过程被取消.", project.getName());
+			logger.info("神经网络多层感知机 ({}) 项目条目生成过程被取消.", model.getName());
 			return true;
 		} else {
-			business.entityManagerContainer().beginTransaction(Project.class);
-			project.setStatus(Project.STATUS_GENERATING);
+			business.entityManagerContainer().beginTransaction(Model.class);
+			model.setStatus(Model.STATUS_GENERATING);
 			int percent = (int) (Math.ceil(i * 100.0 / bundles.size()));
-			project.setGeneratingPercent(percent);
-			logger.info("神经网络多层感知机 ({}) 条目生成进度 {}%, 共计: {} 个条目.", project.getName(), percent, bundles.size());
+			model.setGeneratingPercent(percent);
+			logger.info("神经网络多层感知机 ({}) 条目生成进度 {}%, 共计: {} 个条目.", model.getName(), percent, bundles.size());
 			business.entityManagerContainer().commit();
 			return false;
 		}
@@ -236,12 +235,12 @@ public class Generate {
 			return idx;
 		}
 
-		public void save(Business business, Project project) throws Exception {
+		public void save(Business business, Model model) throws Exception {
 			List<InText> list = this.convert();
 			for (List<InText> os : ListTools.batch(list, 2000)) {
 				business.entityManagerContainer().beginTransaction(InText.class);
 				for (InText o : os) {
-					o.setProject(project.getId());
+					o.setModel(model.getId());
 					business.entityManagerContainer().persist(o, CheckPersistType.all);
 				}
 				business.entityManagerContainer().commit();
@@ -283,12 +282,12 @@ public class Generate {
 			return idx;
 		}
 
-		public void save(Business business, Project project) throws Exception {
+		public void save(Business business, Model model) throws Exception {
 			List<OutText> list = this.convert();
 			for (List<OutText> os : ListTools.batch(list, 2000)) {
 				business.entityManagerContainer().beginTransaction(OutText.class);
 				for (OutText o : os) {
-					o.setProject(project.getId());
+					o.setModel(model.getId());
 					business.entityManagerContainer().persist(o, CheckPersistType.all);
 				}
 				business.entityManagerContainer().commit();
@@ -310,60 +309,60 @@ public class Generate {
 
 	}
 
-	private List<String> listBundle(Business business, Project project) throws Exception {
-		if (StringUtils.equals(project.getType(), Project.TYPE_CMS)) {
-			return listCmsBundle(business, project);
+	private List<String> listBundle(Business business, Model model) throws Exception {
+		if (StringUtils.equals(model.getDataType(), Model.DATATYPE_CMS)) {
+			return listCmsBundle(business, model);
 		} else {
-			return listProcessPlatformBundle(business, project);
+			return listProcessPlatformBundle(business, model);
 		}
 
 	}
 
-	private List<String> listCmsBundle(Business business, Project project) throws Exception {
+	private List<String> listCmsBundle(Business business, Model model) throws Exception {
 		return null;
 	}
 
-	private List<String> listProcessPlatformBundle(Business business, Project project) throws Exception {
+	private List<String> listProcessPlatformBundle(Business business, Model model) throws Exception {
 		EntityManager em = business.entityManagerContainer().get(WorkCompleted.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<WorkCompleted> root = cq.from(WorkCompleted.class);
 		Predicate p = cb.conjunction();
-		if (ListTools.isNotEmpty(project.getApplicationList())) {
+		if (ListTools.isNotEmpty(model.getApplicationList())) {
 			p = cb.and(p, cb.isMember(root.get(WorkCompleted.application_FIELDNAME),
-					cb.literal(project.getApplicationList())));
+					cb.literal(model.getApplicationList())));
 		}
-		if (ListTools.isNotEmpty(project.getProcessList())) {
-			p = cb.and(p, cb.isMember(root.get(WorkCompleted.process_FIELDNAME), cb.literal(project.getProcessList())));
+		if (ListTools.isNotEmpty(model.getProcessList())) {
+			p = cb.and(p, cb.isMember(root.get(WorkCompleted.process_FIELDNAME), cb.literal(model.getProcessList())));
 		}
-		if (null != project.getStartDate()) {
-			p = cb.and(p, cb.greaterThanOrEqualTo(root.get(WorkCompleted_.startTime), project.getStartDate()));
+		if (null != model.getStartDate()) {
+			p = cb.and(p, cb.greaterThanOrEqualTo(root.get(WorkCompleted_.startTime), model.getStartDate()));
 		}
-		if (null != project.getEndDate()) {
-			p = cb.and(p, cb.lessThanOrEqualTo(root.get(WorkCompleted_.startTime), project.getEndDate()));
+		if (null != model.getEndDate()) {
+			p = cb.and(p, cb.lessThanOrEqualTo(root.get(WorkCompleted_.startTime), model.getEndDate()));
 		}
 		cq.select(root.get(WorkCompleted_.id)).where(p);
 		return em.createQuery(cq).getResultList();
 	}
 
-	private Project refreshProject(Business business, String projectId) throws Exception {
-		Project project = business.entityManagerContainer().find(projectId, Project.class);
-		if (null == project) {
-			throw new ExceptionEntityNotExist(projectId, Project.class);
+	private Model refreshModel(Business business, String modelId) throws Exception {
+		Model model = business.entityManagerContainer().find(modelId, Model.class);
+		if (null == model) {
+			throw new ExceptionEntityNotExist(modelId, Model.class);
 		}
-		return project;
+		return model;
 	}
 
-	private void clean(Business business, Project project) throws Exception {
-		Long cleanInText = this.cleanInText(business, project.getId());
-		Long cleanOutText = this.cleanOutText(business, project.getId());
-		Long cleanEntryCount = this.cleanEntry(business, project.getId());
-		logger.print("神经网络多层感知机 ({}) 清理训练数据集, entry: {}, inText: {}, outText: {}.", project.getName(), cleanEntryCount,
+	private void clean(Business business, Model model) throws Exception {
+		Long cleanInText = this.cleanInText(business, model.getId());
+		Long cleanOutText = this.cleanOutText(business, model.getId());
+		Long cleanEntryCount = this.cleanEntry(business, model.getId());
+		logger.print("神经网络多层感知机 ({}) 清理训练数据集, entry: {}, inText: {}, outText: {}.", model.getName(), cleanEntryCount,
 				cleanInText, cleanOutText);
 	}
 
-	private Long cleanEntry(Business business, String projectId) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(Entry.class, Entry.project_FIELDNAME, projectId);
+	private Long cleanEntry(Business business, String modelId) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(Entry.class, Entry.model_FIELDNAME, modelId);
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
 			business.entityManagerContainer().beginTransaction(Entry.class);
@@ -373,9 +372,9 @@ public class Generate {
 		return count;
 	}
 
-	private Long cleanInText(Business business, String projectId) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(InText.class, InText.project_FIELDNAME,
-				projectId);
+	private Long cleanInText(Business business, String modelId) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(InText.class, InText.model_FIELDNAME,
+				modelId);
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
 			business.entityManagerContainer().beginTransaction(InText.class);
@@ -385,9 +384,9 @@ public class Generate {
 		return count;
 	}
 
-	private Long cleanOutText(Business business, String projectId) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(OutText.class, OutText.project_FIELDNAME,
-				projectId);
+	private Long cleanOutText(Business business, String modelId) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(OutText.class, OutText.model_FIELDNAME,
+				modelId);
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
 			business.entityManagerContainer().beginTransaction(OutText.class);
@@ -398,17 +397,17 @@ public class Generate {
 	}
 
 	private void convert(Business business, DataItemConverter<Item> converter, ScriptHelper scriptHelper,
-			LanguageProcessingHelper lph, Project project, WorkCompleted workCompleted, TreeSet<String> inValue,
+			LanguageProcessingHelper lph, Model model, WorkCompleted workCompleted, TreeSet<String> inValue,
 			TreeSet<String> outValue) throws Exception {
-		logger.debug("神经网络多层感知机 ({}) 正在生成条目: {}.", project.getName(), workCompleted.getTitle());
+		logger.debug("神经网络多层感知机 ({}) 正在生成条目: {}.", model.getName(), workCompleted.getTitle());
 		List<Item> items = business.entityManagerContainer().listEqualAndEqual(Item.class, Item.itemCategory_FIELDNAME,
 				ItemCategory.pp, Item.bundle_FIELDNAME, workCompleted.getJob());
 		/* 先计算output,在后面可以在data的text先把output替换掉 */
 		Data data = XGsonBuilder.convert(converter.assemble(items), Data.class);
 		scriptHelper.put(BaseAction.PROPERTY_WORKCOMPLETED, workCompleted);
 		scriptHelper.put(BaseAction.PROPERTY_DATA, data);
-		if (StringUtils.isNotBlank(project.getOutValueScriptText())) {
-			outValue.addAll(scriptHelper.evalAsStringList(project.getOutValueScriptText()));
+		if (StringUtils.isNotBlank(model.getOutValueScriptText())) {
+			outValue.addAll(scriptHelper.evalAsStringList(model.getOutValueScriptText()));
 		}
 		StringBuffer text = new StringBuffer();
 		String dataText = converter.text(items, true, true, true, true, true, ",");
@@ -418,11 +417,11 @@ public class Generate {
 		List<Attachment> attachmentObjects = business.entityManagerContainer().listEqual(Attachment.class,
 				Attachment.job_FIELDNAME, workCompleted.getJob());
 		/* 把不需要的附件过滤掉 */
-		if (StringUtils.isNotBlank(project.getAttachmentScriptText())) {
+		if (StringUtils.isNotBlank(model.getAttachmentScriptText())) {
 			List<String> attachments = ListTools.extractProperty(attachmentObjects, Attachment.name_FIELDNAME,
 					String.class, true, true);
 			scriptHelper.put(BaseAction.PROPERTY_ATTACHMENTS, attachments);
-			scriptHelper.eval(project.getAttachmentScriptText());
+			scriptHelper.eval(model.getAttachmentScriptText());
 			attachmentObjects = ListTools.removePropertyNotIn(attachmentObjects, Attachment.name_FIELDNAME,
 					attachments);
 		}
@@ -437,41 +436,40 @@ public class Generate {
 				}
 			}
 		}
-		switch (StringUtils.trimToEmpty(project.getAnalyzeType())) {
-		case Project.ANALYZETYPE_FULL:
-			lph.word(text.toString()).stream().limit(MapTools.getInteger(project.getPropertyMap(),
-					Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
+		switch (StringUtils.trimToEmpty(model.getAnalyzeType())) {
+		case Model.ANALYZETYPE_FULL:
+			lph.word(text.toString()).stream().limit(MapTools.getInteger(model.getPropertyMap(),
+					Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
 					.forEach(o -> {
 						inValue.add(o.getValue());
 					});
 			break;
-		case Project.ANALYZETYPE_CUSTOMIZED:
+		case Model.ANALYZETYPE_CUSTOMIZED:
 			break;
 		default:
 			inValue.addAll(HanLP
 					.extractKeyword(text.toString(),
-							MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
-									Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE) * 2)
-					.stream().filter(o -> o.length() > 1)
-					.limit(MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
-							Project.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
+							MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE,
+									Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE) * 2)
+					.stream().filter(o -> o.length() > 1).limit(MapTools.getInteger(model.getPropertyMap(),
+							Model.PROPERTY_MLP_GENERATEINTEXTCUTOFFSIZE, Model.DEFAULT_MLP_GENERATEINTEXTCUTOFFSIZE))
 					.collect(Collectors.toList()));
 			break;
 		}
-		if (StringUtils.isNotBlank(project.getInValueScriptText())) {
+		if (StringUtils.isNotBlank(model.getInValueScriptText())) {
 			scriptHelper.put(BaseAction.PROPERTY_INVALUES, inValue);
-			scriptHelper.eval(project.getInValueScriptText());
+			scriptHelper.eval(model.getInValueScriptText());
 		}
 	}
 
-	private void createLearnEntry(Business business, Project project, WorkCompleted workCompleted, InBag inBag,
+	private void createLearnEntry(Business business, Model model, WorkCompleted workCompleted, InBag inBag,
 			OutBag outBag, TreeSet<String> inValues, TreeSet<String> outValues) throws Exception {
 		Entry entry = new Entry();
 		entry.setType(Entry.TYPE_LEARN);
 		entry.setInValueLabelList(new ArrayList<Integer>());
 		entry.setOutValueLabelList(new ArrayList<Integer>());
 		entry.setBundle(workCompleted.getId());
-		entry.setProject(project.getId());
+		entry.setModel(model.getId());
 		entry.setTitle(workCompleted.getTitle());
 		entry.setInValueCount(inValues.size());
 		entry.setOutValueCount(outValues.size());
@@ -486,14 +484,14 @@ public class Generate {
 		business.entityManagerContainer().commit();
 	}
 
-	private void createValidationEntry(Business business, Project project, WorkCompleted workCompleted, InBag inBag,
+	private void createValidationEntry(Business business, Model model, WorkCompleted workCompleted, InBag inBag,
 			OutBag outBag, TreeSet<String> inValues, TreeSet<String> outValues) throws Exception {
 		Entry entry = new Entry();
 		entry.setType(Entry.TYPE_VALIDATION);
 		entry.setInValueLabelList(new ArrayList<Integer>());
 		entry.setOutValueLabelList(new ArrayList<Integer>());
 		entry.setBundle(workCompleted.getId());
-		entry.setProject(project.getId());
+		entry.setModel(model.getId());
 		entry.setTitle(workCompleted.getTitle());
 		entry.setInValueCount(inValues.size());
 		entry.setOutValueCount(outValues.size());

+ 75 - 76
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/Learn.java

@@ -69,14 +69,14 @@ import com.x.query.core.entity.neural.InText_;
 import com.x.query.core.entity.neural.InValue;
 import com.x.query.core.entity.neural.OutText;
 import com.x.query.core.entity.neural.OutValue;
-import com.x.query.core.entity.neural.Project;
+import com.x.query.core.entity.neural.Model;
 import com.x.query.service.processing.Business;
 
 public class Learn {
 
 	private static Logger logger = LoggerFactory.getLogger(Learn.class);
 
-	private volatile static String learningProject = "";
+	private volatile static String learningModel = "";
 
 	private volatile static boolean stop = false;
 
@@ -84,13 +84,13 @@ public class Learn {
 
 	}
 
-	public static String learningProject() {
-		return learningProject;
+	public static String learningModel() {
+		return learningModel;
 	}
 
 	public static Learn newInstance() throws Exception {
-		if (StringUtils.isNotEmpty(learningProject)) {
-			throw new Exception("Learn already concreted for project:" + learningProject + ".");
+		if (StringUtils.isNotEmpty(learningModel)) {
+			throw new Exception("Learn already concreted for model:" + learningModel + ".");
 		}
 		return new Learn();
 	}
@@ -99,48 +99,48 @@ public class Learn {
 		stop = true;
 	}
 
-	public void execute(final String projectId) throws Exception {
-		learningProject = projectId;
+	public void execute(final String modelId) throws Exception {
+		learningModel = modelId;
 		stop = false;
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			TimeStamp stamp = new TimeStamp();
 			Business business = new Business(emc);
-			Project project = this.refreshProject(business, projectId);
-			final String projectName = project.getName();
-			logger.info("神经网络多层感知机 ({}) 学习开始.", projectName);
-			emc.beginTransaction(Project.class);
-			project.setStatus(Project.STATUS_LEARNING);
-			project.setTotalError(1.0d);
+			Model model = this.refreshmodel(business, modelId);
+			final String modelName = model.getName();
+			logger.info("神经网络多层感知机 ({}) 学习开始.", modelName);
+			emc.beginTransaction(Model.class);
+			model.setStatus(Model.STATUS_LEARNING);
+			model.setTotalError(1.0d);
 			emc.commit();
-			Integer hiddenLayerCount = MapTools.getInteger(project.getPropertyMap(),
-					Project.PROPERTY_MLP_HIDDENLAYERCOUNT, Project.DEFAULT_MLP_HIDDENLAYERCOUNT);
-			Double maxError = MapTools.getDouble(project.getPropertyMap(), Project.PROPERTY_MLP_MAXERROR,
-					Project.DEFAULT_MLP_MAXERROR);
-			Integer maxIteration = MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_MAXITERATION,
-					Project.DEFAULT_MLP_MAXITERATION);
-			InTextBag inTextBag = this.inTextBag(business, project);
-			OutTextBag outTextBag = this.outTextBag(business, project);
+			Integer hiddenLayerCount = MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_HIDDENLAYERCOUNT,
+					Model.DEFAULT_MLP_HIDDENLAYERCOUNT);
+			Double maxError = MapTools.getDouble(model.getPropertyMap(), Model.PROPERTY_MLP_MAXERROR,
+					Model.DEFAULT_MLP_MAXERROR);
+			Integer maxIteration = MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_MAXITERATION,
+					Model.DEFAULT_MLP_MAXITERATION);
+			InTextBag inTextBag = this.inTextBag(business, model);
+			OutTextBag outTextBag = this.outTextBag(business, model);
 			try {
-				NeuralNetwork<MomentumBackpropagation> neuralNetwork = project.createNeuralNetwork(inTextBag.size(),
+				NeuralNetwork<MomentumBackpropagation> neuralNetwork = model.createNeuralNetwork(inTextBag.size(),
 						outTextBag.size(), hiddenLayerCount);
 				neuralNetwork.getLearningRule().addListener(new LearningEventListener() {
 					@Override
 					public void handleLearningEvent(LearningEvent learningEvent) {
 						try {
-							Project o = refreshProject(business, projectId);
+							Model o = refreshmodel(business, modelId);
 							if (Objects.equals(LearningEvent.Type.EPOCH_ENDED, learningEvent.getEventType())) {
-								emc.beginTransaction(Project.class);
+								emc.beginTransaction(Model.class);
 								o.setIntermediateNnet(encode(neuralNetwork));
-								logger.info("神经网络多层感知机 ({}) 学习进度 {} / {}, 总误差: {}, 单次耗时: {}.", projectName,
+								logger.info("神经网络多层感知机 ({}) 学习进度 {} / {}, 总误差: {}, 单次耗时: {}.", modelName,
 										neuralNetwork.getLearningRule().getCurrentIteration(), maxIteration,
 										neuralNetwork.getLearningRule().getErrorFunction().getTotalError(),
 										stamp.stampSeconds());
 								if (stop) {
 									neuralNetwork.stopLearning();
-									logger.info("神经网络多层感知机 ({}) 学习停止.", projectName);
+									logger.info("神经网络多层感知机 ({}) 学习停止.", modelName);
 									o.setStatus("");
 								} else {
-									o.setStatus(Project.STATUS_LEARNING);
+									o.setStatus(Model.STATUS_LEARNING);
 									o.setTotalError(neuralNetwork.getLearningRule().getErrorFunction().getTotalError());
 								}
 								emc.commit();
@@ -150,42 +150,41 @@ public class Learn {
 						}
 					}
 				});
-				logger.info("神经网络多层感知机 ({}) 数据集准备就绪.", projectName);
+				logger.info("神经网络多层感知机 ({}) 数据集准备就绪.", modelName);
 				/* 训练数据集 */
-				DataSet learnSet = this.learnOrValidationSet(business, project, inTextBag, outTextBag,
-						Entry.TYPE_LEARN);
-				this.saveDataSet(learnSet, project, Entry.TYPE_LEARN);
+				DataSet learnSet = this.learnOrValidationSet(business, model, inTextBag, outTextBag, Entry.TYPE_LEARN);
+				this.saveDataSet(learnSet, model, Entry.TYPE_LEARN);
 				/* 测试数据集 */
-				DataSet validationSet = this.learnOrValidationSet(business, project, inTextBag, outTextBag,
+				DataSet validationSet = this.learnOrValidationSet(business, model, inTextBag, outTextBag,
 						Entry.TYPE_VALIDATION);
-				this.saveDataSet(validationSet, project, Entry.TYPE_VALIDATION);
+				this.saveDataSet(validationSet, model, Entry.TYPE_VALIDATION);
 				neuralNetwork.learn(learnSet);
-				project = refreshProject(business, projectId);
-				emc.beginTransaction(Project.class);
-				project.setNnet(this.encode(neuralNetwork));
-				project.setStatus("");
-				project.setInValueCount(inTextBag.size());
-				project.setOutValueCount(outTextBag.size());
+				model = refreshmodel(business, modelId);
+				emc.beginTransaction(Model.class);
+				model.setNnet(this.encode(neuralNetwork));
+				model.setStatus("");
+				model.setInValueCount(inTextBag.size());
+				model.setOutValueCount(outTextBag.size());
 				emc.commit();
-				this.cleanInValue(business, project);
+				this.cleanInValue(business, model);
 				inTextBag.saveToInValue(business);
-				this.cleanOutValue(business, project);
+				this.cleanOutValue(business, model);
 				outTextBag.saveToOutValue(business);
 				if (neuralNetwork.getLearningRule().getErrorFunction().getTotalError() > maxError) {
-					logger.print("神经网络多层感知机 ({}) 学习失败, 耗时: {}, 总误差: {}, 未能达到预期值: {}.", projectName,
+					logger.print("神经网络多层感知机 ({}) 学习失败, 耗时: {}, 总误差: {}, 未能达到预期值: {}.", modelName,
 							stamp.consumingMilliseconds(),
 							neuralNetwork.getLearningRule().getErrorFunction().getTotalError(), maxError);
 				} else {
-					logger.print("神经网络多层感知机 ({}) 学习完成.", projectName);
+					logger.print("神经网络多层感知机 ({}) 学习完成.", modelName);
 					if (!validationSet.isEmpty()) {
 						Evaluation evaluation = new Evaluation();
 						evaluation.addEvaluator(new ClassifierEvaluator.MultiClass(validationSet.getColumnNames()));
 						EvaluationResult evaluationResult = evaluation.evaluateDataSet(neuralNetwork, validationSet);
-						project = refreshProject(business, projectId);
-						emc.beginTransaction(Project.class);
-						project.setValidationMeanSquareError(evaluationResult.getMeanSquareError());
+						model = refreshmodel(business, modelId);
+						emc.beginTransaction(Model.class);
+						model.setValidationMeanSquareError(evaluationResult.getMeanSquareError());
 						emc.commit();
-						logger.print("神经网络多层感知机 ({}) 测试数据数量: {}, 测试结果集标准方差: {}.", projectName, validationSet.size(),
+						logger.print("神经网络多层感知机 ({}) 测试数据数量: {}, 测试结果集标准方差: {}.", modelName, validationSet.size(),
 								evaluationResult.getMeanSquareError());
 					}
 					// logger.info("##############################################################################");
@@ -211,7 +210,7 @@ public class Learn {
 				logger.error(e);
 			}
 		} finally {
-			learningProject = "";
+			learningModel = "";
 			stop = false;
 		}
 	}
@@ -223,22 +222,22 @@ public class Learn {
 		return ByteTools.compressBase64String(bytes);
 	}
 
-	private Project refreshProject(Business business, String projectId) throws Exception {
-		Project project = business.entityManagerContainer().find(projectId, Project.class);
-		if (null == project) {
-			throw new ExceptionEntityNotExist(projectId, Project.class);
+	private Model refreshmodel(Business business, String modelId) throws Exception {
+		Model model = business.entityManagerContainer().find(modelId, Model.class);
+		if (null == model) {
+			throw new ExceptionEntityNotExist(modelId, Model.class);
 		}
-		return project;
+		return model;
 	}
 
-	private DataSet learnOrValidationSet(Business business, Project project, InTextBag inTextBag, OutTextBag outTextBag,
+	private DataSet learnOrValidationSet(Business business, Model model, InTextBag inTextBag, OutTextBag outTextBag,
 			String type) throws Exception {
 		DataSet data = new DataSet(inTextBag.size(), outTextBag.size());
 		Entry entry = null;
 		double[] ins = null;
 		double[] outs = null;
-		for (String id : business.entityManagerContainer().idsEqualAndEqual(Entry.class, Entry.project_FIELDNAME,
-				project.getId(), Entry.type_FIELDNAME, type)) {
+		for (String id : business.entityManagerContainer().idsEqualAndEqual(Entry.class, Entry.model_FIELDNAME,
+				model.getId(), Entry.type_FIELDNAME, type)) {
 			entry = business.entityManagerContainer().find(id, Entry.class);
 			if (null != entry) {
 				ins = new double[inTextBag.size()];
@@ -259,33 +258,33 @@ public class Learn {
 	}
 
 	/* 生成输入值包 */
-	private InTextBag inTextBag(Business business, Project project) throws Exception {
+	private InTextBag inTextBag(Business business, Model model) throws Exception {
 		EntityManager em = business.entityManagerContainer().get(InText.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<InText> cq = cb.createQuery(InText.class);
 		Root<InText> root = cq.from(InText.class);
-		Predicate p = cb.equal(root.get(InText_.project), project.getId());
+		Predicate p = cb.equal(root.get(InText_.model), model.getId());
 		cq.select(root).where(p).orderBy(cb.desc(root.get(InText_.count)));
-		Integer cutoff = MapTools.getInteger(project.getPropertyMap(), Project.PROPERTY_MLP_LEARNINTEXTCUTOFFSIZE,
-				Project.DEFAULT_MLP_LEARNINTEXTCUTOFFSIZE);
+		Integer cutoff = MapTools.getInteger(model.getPropertyMap(), Model.PROPERTY_MLP_LEARNINTEXTCUTOFFSIZE,
+				Model.DEFAULT_MLP_LEARNINTEXTCUTOFFSIZE);
 		List<InText> os = em.createQuery(cq.distinct(true)).setMaxResults(cutoff).getResultList();
 		InTextBag inTextBag = new InTextBag(os);
 		return inTextBag;
 	}
 
 	/* 生成输出值包 */
-	private OutTextBag outTextBag(Business business, Project project) throws Exception {
-		List<OutText> os = business.entityManagerContainer().listEqual(OutText.class, OutText.project_FIELDNAME,
-				project.getId());
+	private OutTextBag outTextBag(Business business, Model model) throws Exception {
+		List<OutText> os = business.entityManagerContainer().listEqual(OutText.class, OutText.model_FIELDNAME,
+				model.getId());
 		os = os.stream().sorted(Comparator.comparing(OutText::getSerial, Comparator.nullsLast(Integer::compareTo)))
 				.collect(Collectors.toList());
 		OutTextBag outTextBag = new OutTextBag(os);
 		return outTextBag;
 	}
 
-	private Long cleanInValue(Business business, Project project) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(InValue.class, InValue.project_FIELDNAME,
-				project.getId());
+	private Long cleanInValue(Business business, Model model) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(InValue.class, InValue.model_FIELDNAME,
+				model.getId());
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
 			business.entityManagerContainer().beginTransaction(InValue.class);
@@ -295,20 +294,20 @@ public class Learn {
 		return count;
 	}
 
-//	private void saveNeuralNetwork(NeuralNetwork<MomentumBackpropagation> neuralNetwork, Project project,
+//	private void saveNeuralNetwork(NeuralNetwork<MomentumBackpropagation> neuralNetwork, model model,
 //			String surffix) throws Exception {
-//		File file = new File(Config.base(), "local/temp/" + project.getName() + "_" + surffix + ".nnet");
+//		File file = new File(Config.base(), "local/temp/" + model.getName() + "_" + surffix + ".nnet");
 //		neuralNetwork.save(file.getAbsolutePath());
 //	}
 
-	private void saveDataSet(DataSet dataSet, Project project, String surffix) throws Exception {
-		File file = new File(Config.base(), "local/temp/" + project.getName() + "_" + surffix + ".txt");
+	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());
 	}
 
-	private Long cleanOutValue(Business business, Project project) throws Exception {
-		List<String> ids = business.entityManagerContainer().idsEqual(OutValue.class, OutValue.project_FIELDNAME,
-				project.getId());
+	private Long cleanOutValue(Business business, Model model) throws Exception {
+		List<String> ids = business.entityManagerContainer().idsEqual(OutValue.class, OutValue.model_FIELDNAME,
+				model.getId());
 		Long count = 0L;
 		for (List<String> os : ListTools.batch(ids, 2000)) {
 			business.entityManagerContainer().beginTransaction(OutValue.class);
@@ -337,7 +336,7 @@ public class Learn {
 				OutValue outValue = new OutValue();
 				outValue.setText(text.getText());
 				outValue.setCount(text.getCount());
-				outValue.setProject(text.getProject());
+				outValue.setModel(text.getModel());
 				outValue.setSerial(text.getSerial());
 				os.add(outValue);
 			}
@@ -382,7 +381,7 @@ public class Learn {
 				InValue inValue = new InValue();
 				inValue.setText(text.getText());
 				inValue.setCount(text.getCount());
-				inValue.setProject(text.getProject());
+				inValue.setModel(text.getModel());
 				inValue.setSerial(i);
 				inValue.setInTextSerial(text.getSerial());
 				os.add(inValue);

+ 19 - 17
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/neural/NeuralAction.java

@@ -1,5 +1,7 @@
 package com.x.query.service.processing.jaxrs.neural;
 
+import java.util.List;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
@@ -30,15 +32,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "创建用于学习的数据集.", action = ActionGenerate.class)
 	@GET
-	@Path("generate/project/{projectFlag}")
+	@Path("generate/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void generate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionGenerate.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionGenerate().execute(effectivePerson, projectFlag);
+			result = new ActionGenerate().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -48,15 +50,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "停止数据生成.", action = ActionStopGenerating.class)
 	@GET
-	@Path("stop/generating/project/{projectFlag}")
+	@Path("stop/generating/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void stopGenerating(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("项目标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionStopGenerating.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionStopGenerating().execute(effectivePerson, projectFlag);
+			result = new ActionStopGenerating().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -66,15 +68,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "学习.", action = ActionLearn.class)
 	@GET
-	@Path("learn/project/{projectFlag}")
+	@Path("learn/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void trainProject(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+	public void learn(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionLearn.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionLearn().execute(effectivePerson, projectFlag);
+			result = new ActionLearn().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -84,15 +86,15 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "停止学习.", action = ActionStopLearning.class)
 	@GET
-	@Path("stop/learning/project/{projectFlag}")
+	@Path("stop/learning/model/{modelFlag}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void stopLearning(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag) {
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag) {
 		ActionResult<ActionStopLearning.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionStopLearning().execute(effectivePerson, projectFlag);
+			result = new ActionStopLearning().execute(effectivePerson, modelFlag);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -102,16 +104,16 @@ public class NeuralAction extends StandardJaxrsAction {
 
 	@JaxrsMethodDescribe(value = "计算输入工作ID进行计算.", action = ActionCalculateWithWork.class)
 	@GET
-	@Path("calculate/project/{projectFlag}/work/{workId}")
+	@Path("list/calculate/model/{modelFlag}/work/{workId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void calculateWithWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("项目标识") @PathParam("projectFlag") String projectFlag,
+			@JaxrsParameterDescribe("模型标识") @PathParam("modelFlag") String modelFlag,
 			@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
-		ActionResult<ActionCalculateWithWork.Wo> result = new ActionResult<>();
+		ActionResult<List<ActionCalculateWithWork.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionCalculateWithWork().execute(effectivePerson, projectFlag, workId);
+			result = new ActionCalculateWithWork().execute(effectivePerson, modelFlag, workId);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);

+ 22 - 15
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/schedule/Crawl.java

@@ -22,6 +22,8 @@ public abstract class Crawl implements Job {
 	public static String[] SKIP_START_WITH = new String[] { "~", "!", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">",
 			"[", "]", "{", "}", "\\", "?" };
 
+	public static final long MAX_ATTACHMENT_BYTE_LENGTH = 10 * 1024 * 1024;
+
 	public static LanguageProcessingHelper languageProcessingHelper = new LanguageProcessingHelper();
 
 	protected List<Item> toWord(String content) {
@@ -29,23 +31,28 @@ public abstract class Crawl implements Job {
 	}
 
 	protected String text(StorageObject storageObject) throws Exception {
-		if (ExtractTextTools.support(storageObject.getName())) {
-			try {
-				StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
-						storageObject.getStorage());
-				if (null != mapping) {
-					return ExtractTextTools.extract(storageObject.readContent(mapping), storageObject.getName(),
-							Config.query().getExtractOffice(), Config.query().getExtractPdf(),
-							Config.query().getExtractText(), Config.query().getExtractImage());
-				} else {
-					logger.print(
-							"storageMapping is null can not extract storageObject text, storageObject:{}, name:{}.",
-							storageObject.getId(), storageObject.getName());
+		if (storageObject.getLength() < MAX_ATTACHMENT_BYTE_LENGTH) {
+			if (ExtractTextTools.support(storageObject.getName())) {
+				try {
+					StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
+							storageObject.getStorage());
+					if (null != mapping) {
+						return ExtractTextTools.extract(storageObject.readContent(mapping), storageObject.getName(),
+								Config.query().getExtractOffice(), Config.query().getExtractPdf(),
+								Config.query().getExtractText(), Config.query().getExtractImage());
+					} else {
+						logger.print(
+								"storageMapping is null can not extract storageObject text, storageObject:{}, name:{}.",
+								storageObject.getId(), storageObject.getName());
+					}
+				} catch (Exception e) {
+					logger.print("error extract attachment text, storageObject:{}, name:{}.", storageObject.getId(),
+							storageObject.getName());
 				}
-			} catch (Exception e) {
-				logger.print("error extract attachment text, storageObject:{}, name:{}.", storageObject.getId(),
-						storageObject.getName());
 			}
+		} else {
+			logger.print("忽略过大的附件:{}, size:{}, id:{}.", storageObject.getName(), storageObject.getLength(),
+					storageObject.getId());
 		}
 		return "";
 	}