zhourui 5 gadi atpakaļ
vecāks
revīzija
4d9de8d8c2
80 mainītis faili ar 1004 papildinājumiem un 1111 dzēšanām
  1. 1 1
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/ApplicationCache.java
  2. 0 8
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/Cache.java
  3. 3 1
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheEhcacheImpl.java
  4. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionCreate.java
  5. 25 25
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionDelete.java
  6. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionEdit.java
  7. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionSetIcon.java
  8. 4 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionCreate.java
  9. 3 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionDelete.java
  10. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionEdit.java
  11. 10 11
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionContent.java
  12. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionCopy.java
  13. 2 4
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionCreate.java
  14. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionDelete.java
  15. 10 13
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionDownload.java
  16. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionEdit.java
  17. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionUpload.java
  18. 5 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/BaseAction.java
  19. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionCreate.java
  20. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionDelete.java
  21. 2 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionEdit.java
  22. 8 8
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/ActionCover.java
  23. 5 5
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/BaseAction.java
  24. 2 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionCreate.java
  25. 2 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionDelete.java
  26. 2 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionEdit.java
  27. 2 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionList.java
  28. 4 3
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionSelect.java
  29. 13 9
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionSelectFile.java
  30. 3 4
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/BaseAction.java
  31. 30 18
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/process/BaseAction.java
  32. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionCreate.java
  33. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionDelete.java
  34. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionEdit.java
  35. 6 5
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionListPaging.java
  36. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/templateform/ActionCreate.java
  37. 2 2
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/templateform/ActionDelete.java
  38. 23 21
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/Business.java
  39. 1 4
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/AgentFactory.java
  40. 4 3
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ApplicationDictItemFactory.java
  41. 6 49
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ApplicationFactory.java
  42. 14 29
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/BeginFactory.java
  43. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/CancelFactory.java
  44. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ChoiceFactory.java
  45. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/DelayFactory.java
  46. 41 30
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ElementFactory.java
  47. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/EmbedFactory.java
  48. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/EndFactory.java
  49. 21 64
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/FileFactory.java
  50. 2 1
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/FormFactory.java
  51. 3 3
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/InvokeFactory.java
  52. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ManualFactory.java
  53. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/MergeFactory.java
  54. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/MessageFactory.java
  55. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ParallelFactory.java
  56. 62 108
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ProcessFactory.java
  57. 116 116
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/QueryStatFactory.java
  58. 117 117
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/QueryViewFactory.java
  59. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/RouteFactory.java
  60. 15 13
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ScriptFactory.java
  61. 3 3
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ServiceFactory.java
  62. 3 3
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/SplitFactory.java
  63. 35 27
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompleted.java
  64. 41 31
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompletedStream.java
  65. 10 5
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java
  66. 15 10
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadWorkInfo.java
  67. 26 21
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java
  68. 8 7
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImage.java
  69. 10 7
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImageResult.java
  70. 8 13
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdf.java
  71. 10 5
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdfResult.java
  72. 51 37
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
  73. 37 33
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
  74. 10 11
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/file/ActionContent.java
  75. 11 10
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/file/ActionDownload.java
  76. 2 2
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/process/ActionGetWithProcessWithApplication.java
  77. 16 12
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/script/ActionGetImported.java
  78. 1 5
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/script/BaseAction.java
  79. 87 120
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/factory/ElementFactory.java
  80. 3 3
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/applicationdict/ActionUpdate.java

+ 1 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/ApplicationCache.java

@@ -19,7 +19,7 @@ import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
 @SuppressWarnings("unchecked")
-public class ApplicationCache extends AbstractApplicationCache {
+public class ApplicationCache111 extends AbstractApplicationCache {
 
 	private NotifyThread notifyThread;
 	private ReceiveThread receiveThread;

+ 0 - 8
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/Cache.java

@@ -26,14 +26,6 @@ public interface Cache {
 
 	public abstract void notify(Class<?> clz, List<Object> keys) throws Exception;
 
-	public static CacheCategory cacheCategory(Object... parts) {
-		return new CacheCategory(parts);
-	}
-
-	public static CacheKey cacheKey(Object... parts) {
-		return new CacheKey(parts);
-	}
-
 	public static class CacheCategory {
 
 		public static final String SPLIT = "#";

+ 3 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/cache/CacheEhcacheImpl.java

@@ -68,7 +68,9 @@ public class CacheEhcacheImpl implements Cache {
 
 	@Override
 	public void put(CacheCategory category, CacheKey key, Object o) throws Exception {
-		this.getCache(category.toString()).put(new Element(key.toString(), o));
+		if (null != o) {
+			this.getCache(category.toString()).put(new Element(key.toString(), o));
+		}
 	}
 
 	@Override

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionCreate.java

@@ -10,7 +10,7 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -40,7 +40,7 @@ class ActionCreate extends BaseAction {
 			application.setLastUpdateTime(new Date());
 			emc.persist(application, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Application.class);
+			CacheManager.notify(Application.class);
 			Wo wo = new Wo();
 			wo.setId(application.getId());
 			result.setData(wo);

+ 25 - 25
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionDelete.java

@@ -11,7 +11,7 @@ import org.apache.commons.lang3.StringUtils;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -150,30 +150,30 @@ class ActionDelete extends BaseAction {
 			/** 应用本体 1种 */
 			emc.remove(application);
 			emc.commit();
-			ApplicationCache.notify(Application.class);
-			ApplicationCache.notify(Process.class);
-			ApplicationCache.notify(Agent.class);
-			ApplicationCache.notify(Begin.class);
-			ApplicationCache.notify(Cancel.class);
-			ApplicationCache.notify(Choice.class);
-			ApplicationCache.notify(Delay.class);
-			ApplicationCache.notify(Embed.class);
-			ApplicationCache.notify(End.class);
-			ApplicationCache.notify(Invoke.class);
-			ApplicationCache.notify(Manual.class);
-			ApplicationCache.notify(Merge.class);
-			ApplicationCache.notify(Message.class);
-			ApplicationCache.notify(Parallel.class);
-			ApplicationCache.notify(Service.class);
-			ApplicationCache.notify(Split.class);
-			ApplicationCache.notify(Route.class);
-			ApplicationCache.notify(FormField.class);
-			ApplicationCache.notify(Form.class);
-			ApplicationCache.notify(File.class);
-			ApplicationCache.notify(Script.class);
-			ApplicationCache.notify(SerialNumber.class);
-			ApplicationCache.notify(QueryView.class);
-			ApplicationCache.notify(QueryStat.class);
+			CacheManager.notify(Application.class);
+			CacheManager.notify(Process.class);
+			CacheManager.notify(Agent.class);
+			CacheManager.notify(Begin.class);
+			CacheManager.notify(Cancel.class);
+			CacheManager.notify(Choice.class);
+			CacheManager.notify(Delay.class);
+			CacheManager.notify(Embed.class);
+			CacheManager.notify(End.class);
+			CacheManager.notify(Invoke.class);
+			CacheManager.notify(Manual.class);
+			CacheManager.notify(Merge.class);
+			CacheManager.notify(Message.class);
+			CacheManager.notify(Parallel.class);
+			CacheManager.notify(Service.class);
+			CacheManager.notify(Split.class);
+			CacheManager.notify(Route.class);
+			CacheManager.notify(FormField.class);
+			CacheManager.notify(Form.class);
+			CacheManager.notify(File.class);
+			CacheManager.notify(Script.class);
+			CacheManager.notify(SerialNumber.class);
+			CacheManager.notify(QueryView.class);
+			CacheManager.notify(QueryStat.class);
 			Wo wo = new Wo();
 			wo.setId(application.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionEdit.java

@@ -9,7 +9,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -36,7 +36,7 @@ class ActionEdit extends BaseAction {
 			application.setLastUpdatePerson(effectivePerson.getDistinguishedName());
 			application.setLastUpdateTime(new Date());
 			emc.commit();
-			ApplicationCache.notify(Application.class);
+			CacheManager.notify(Application.class);
 			Wo wo = new Wo();
 			wo.setId(application.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/application/ActionSetIcon.java

@@ -12,7 +12,7 @@ import org.imgscalr.Scalr;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -46,7 +46,7 @@ class ActionSetIcon extends BaseAction {
 				application.setIcon(icon);
 				application.setIconHue(iconHue);
 				emc.commit();
-				ApplicationCache.notify(Application.class);
+				CacheManager.notify(Application.class);
 				Wo wo = new Wo();
 				wo.setId(application.getId());
 				result.setData(wo);

+ 4 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionCreate.java

@@ -13,7 +13,7 @@ import com.x.base.core.entity.dataitem.ItemCategory;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -39,7 +39,6 @@ class ActionCreate extends BaseAction {
 			}
 			emc.beginTransaction(ApplicationDict.class);
 			emc.beginTransaction(ApplicationDictItem.class);
-			//emc.beginTransaction(ApplicationDictLobItem.class);
 			ApplicationDict applicationDict = new ApplicationDict();
 			Wi.copier.copy(wi, applicationDict);
 			applicationDict.setApplication(application.getId());
@@ -54,7 +53,7 @@ class ActionCreate extends BaseAction {
 				emc.persist(o, CheckPersistType.all);
 			}
 			emc.commit();
-			ApplicationCache.notify(ApplicationDict.class);
+			CacheManager.notify(ApplicationDict.class);
 			Wo wo = new Wo();
 			wo.setId(applicationDict.getId());
 			result.setData(wo);
@@ -63,6 +62,8 @@ class ActionCreate extends BaseAction {
 	}
 
 	public static class Wo extends WoId {
+
+		private static final long serialVersionUID = -2714867252705825023L;
 	}
 
 	public static class Wi extends ApplicationDict {

+ 3 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionDelete.java

@@ -5,7 +5,7 @@ import java.util.List;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -37,7 +37,7 @@ class ActionDelete extends BaseAction {
 			emc.beginTransaction(ApplicationDict.class);
 			emc.remove(dict, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(ApplicationDict.class);
+			CacheManager.notify(ApplicationDict.class);
 			Wo wo = new Wo();
 			wo.setId(dict.getId());
 			result.setData(wo);
@@ -49,7 +49,7 @@ class ActionDelete extends BaseAction {
 		for (int i = 0; i < ids.size(); i++) {
 			if (i % 100 == 0) {
 				emc.beginTransaction(ApplicationDictItem.class);
-				//emc.beginTransaction(ApplicationDictLobItem.class);
+				// emc.beginTransaction(ApplicationDictLobItem.class);
 			}
 			ApplicationDictItem o = emc.find(ids.get(i), ApplicationDictItem.class);
 			if (null != o) {

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/applicationdict/ActionEdit.java

@@ -13,7 +13,7 @@ import com.x.base.core.entity.dataitem.ItemCategory;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -64,7 +64,7 @@ class ActionEdit extends BaseAction {
 				emc.persist(o, CheckPersistType.all);
 			}
 			emc.commit();
-			ApplicationCache.notify(ApplicationDict.class);
+			CacheManager.notify(ApplicationDict.class);
 			Wo wo = new Wo();
 			wo.setId(dict.getId());
 			result.setData(wo);

+ 10 - 11
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionContent.java

@@ -1,34 +1,33 @@
 package com.x.processplatform.assemble.designer.jaxrs.file;
 
+import java.util.Optional;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 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.StandardJaxrsAction;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.File;
 
-import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
-class ActionContent extends StandardJaxrsAction {
-
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
+class ActionContent extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheKey cacheKey = new CacheKey(this.getClass(), flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				File file = emc.flag(flag, File.class);
 				if (null == file) {
@@ -48,7 +47,7 @@ class ActionContent extends StandardJaxrsAction {
 				 * 对10M以下的文件进行缓存
 				 */
 				if (bs.length < (1024 * 1024 * 10)) {
-					cache.put(new Element(cacheKey, wo));
+					CacheManager.put(cacheCategory, cacheKey, wo);
 				}
 			}
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionCopy.java

@@ -11,7 +11,7 @@ import javax.persistence.criteria.Root;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckPersistType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -57,7 +57,7 @@ class ActionCopy extends BaseAction {
 			emc.beginTransaction(File.class);
 			emc.persist(toFile, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(File.class);
+			CacheManager.notify(File.class);
 			Wo wo = new Wo();
 			wo.setId(toFile.getId());
 			result.setData(wo);

+ 2 - 4
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionCreate.java

@@ -1,7 +1,5 @@
 package com.x.processplatform.assemble.designer.jaxrs.file;
 
-import java.util.Date;
-
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
@@ -11,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionDuplicateFlag;
 import com.x.base.core.project.exception.ExceptionDuplicateRestrictFlag;
@@ -58,7 +56,7 @@ class ActionCreate extends BaseAction {
 			}
 			emc.persist(file, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(File.class);
+			CacheManager.notify(File.class);
 			Wo wo = new Wo();
 			wo.setId(file.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionDelete.java

@@ -3,7 +3,7 @@ package com.x.processplatform.assemble.designer.jaxrs.file;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -32,7 +32,7 @@ class ActionDelete extends BaseAction {
 			emc.beginTransaction(File.class);
 			emc.remove(file, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(File.class);
+			CacheManager.notify(File.class);
 			Wo wo = new Wo();
 			wo.setId(file.getId());
 			result.setData(wo);

+ 10 - 13
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionDownload.java

@@ -1,34 +1,31 @@
 package com.x.processplatform.assemble.designer.jaxrs.file;
 
+import java.util.Optional;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 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.StandardJaxrsAction;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.File;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
-class ActionDownload extends StandardJaxrsAction {
-
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
+class ActionDownload extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
-			Element element = cache.get(cacheKey);
-			if ((null != element) && (null != element.getObjectValue())) {
-				wo = (Wo) element.getObjectValue();
+			CacheKey cacheKey = new CacheKey(this.getClass(), flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				File file = emc.flag(flag, File.class);
 				if (null == file) {
@@ -48,7 +45,7 @@ class ActionDownload extends StandardJaxrsAction {
 				 * 对10M以下的文件进行缓存
 				 */
 				if (bs.length < (1024 * 1024 * 10)) {
-					cache.put(new Element(cacheKey, wo));
+					CacheManager.put(cacheCategory, cacheKey, wo);
 				}
 			}
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionEdit.java

@@ -9,7 +9,7 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionDuplicateFlag;
 import com.x.base.core.project.exception.ExceptionDuplicateRestrictFlag;
@@ -57,7 +57,7 @@ class ActionEdit extends BaseAction {
 			}
 			emc.check(file, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(File.class);
+			CacheManager.notify(File.class);
 			Wo wo = new Wo();
 			wo.setId(file.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/ActionUpload.java

@@ -6,7 +6,7 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -43,7 +43,7 @@ class ActionUpload extends BaseAction {
 				file.setFileName(fileName);
 			}
 			emc.commit();
-			ApplicationCache.notify(File.class);
+			CacheManager.notify(File.class);
 			Wo wo = new Wo();
 			wo.setValue(true);
 			result.setData(wo);

+ 5 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/file/BaseAction.java

@@ -2,13 +2,16 @@ package com.x.processplatform.assemble.designer.jaxrs.file;
 
 import java.util.Date;
 
+import com.x.base.core.project.cache.Cache.CacheCategory;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.processplatform.core.entity.element.File;
 
 abstract class BaseAction extends StandardJaxrsAction {
-	
-	protected void updateCreator(File file,EffectivePerson effectivePerson){
+
+	protected static CacheCategory cacheCategory = new CacheCategory(File.class);
+
+	protected void updateCreator(File file, EffectivePerson effectivePerson) {
 		file.setLastUpdatePerson(effectivePerson.getDistinguishedName());
 		file.setLastUpdateTime(new Date());
 	}

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionCreate.java

@@ -12,7 +12,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -54,7 +54,7 @@ class ActionCreate extends BaseAction {
 				emc.persist(o, CheckPersistType.all);
 			}
 			emc.commit();
-			ApplicationCache.notify(Form.class);
+			CacheManager.notify(Form.class);
 			Wo wo = new Wo();
 			wo.setId(form.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionDelete.java

@@ -5,7 +5,7 @@ import java.util.List;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -70,7 +70,7 @@ class ActionDelete extends BaseAction {
 			}
 			emc.remove(form, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(Form.class);
+			CacheManager.notify(Form.class);
 			Wo wo = new Wo();
 			wo.setId(form.getId());
 			result.setData(wo);

+ 2 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/form/ActionEdit.java

@@ -12,7 +12,7 @@ import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -23,7 +23,6 @@ import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Form;
 import com.x.processplatform.core.entity.element.FormField;
 import com.x.processplatform.core.entity.element.FormVersion;
-import com.x.processplatform.core.entity.element.ScriptVersion;
 
 class ActionEdit extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
@@ -65,7 +64,7 @@ class ActionEdit extends BaseAction {
 			form.setLastUpdateTime(new Date());
 			emc.check(form, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Form.class);
+			CacheManager.notify(Form.class);
 			/* 保存历史版本 */
 			ThisApplication.formVersionQueue.send(new FormVersion(form.getId(), jsonElement));
 			Wo wo = new Wo();

+ 8 - 8
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/ActionCover.java

@@ -10,7 +10,6 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -22,6 +21,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.dataitem.DataItemConverter;
 import com.x.base.core.project.bean.WrapCopier;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -324,13 +324,13 @@ class ActionCover extends BaseAction {
 		business.entityManagerContainer().beginTransaction(Route.class);
 		business.entityManagerContainer().commit();
 
-		ApplicationCache.notify(ApplicationDictItem.class);
-		ApplicationCache.notify(ApplicationDict.class);
-		ApplicationCache.notify(FormField.class);
-		ApplicationCache.notify(Form.class);
-		ApplicationCache.notify(Script.class);
-		ApplicationCache.notify(Process.class);
-		ApplicationCache.notify(Application.class);
+		CacheManager.notify(ApplicationDictItem.class);
+		CacheManager.notify(ApplicationDict.class);
+		CacheManager.notify(FormField.class);
+		CacheManager.notify(Form.class);
+		CacheManager.notify(Script.class);
+		CacheManager.notify(Process.class);
+		CacheManager.notify(Application.class);
 
 		return application;
 	}

+ 5 - 5
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/input/BaseAction.java

@@ -13,19 +13,19 @@ import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.entity.JpaObject;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.designer.Business;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Application_;
 
-import net.sf.ehcache.Ehcache;
-
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache inputCache = ApplicationCache.instance().getCache(BaseAction.class.getName(), 100,
-			ApplicationCache.MINUTES_20, ApplicationCache.MINUTES_20);
+//	protected Ehcache inputCache = ApplicationCache.instance().getCache(BaseAction.class.getName(), 100,
+//			ApplicationCache.MINUTES_20, ApplicationCache.MINUTES_20);
+	
+	protected CacheCategory cacheCategory= new CacheCategory(BaseAction.class);
 
 	public enum Method {
 		cover, create, ignore;

+ 2 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionCreate.java

@@ -14,9 +14,8 @@ import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.dynamic.DynamicEntity;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityFieldEmpty;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -76,7 +75,7 @@ class ActionCreate extends BaseAction {
 			emc.beginTransaction(Mapping.class);
 			emc.persist(mapping, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Mapping.class);
+			CacheManager.notify(Mapping.class);
 			Wo wo = new Wo();
 			wo.setId(mapping.getId());
 			result.setData(wo);

+ 2 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionDelete.java

@@ -3,7 +3,7 @@ package com.x.processplatform.assemble.designer.jaxrs.mapping;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -36,8 +36,7 @@ class ActionDelete extends BaseAction {
 			emc.beginTransaction(Mapping.class);
 			emc.remove(mapping, CheckRemoveType.all);
 			emc.commit();
-
-			ApplicationCache.notify(Mapping.class);
+			CacheManager.notify(Mapping.class);
 			Wo wo = new Wo();
 			wo.setId(mapping.getId());
 			result.setData(wo);

+ 2 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/mapping/ActionEdit.java

@@ -13,9 +13,8 @@ import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.dynamic.DynamicEntity;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityFieldEmpty;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -76,7 +75,7 @@ class ActionEdit extends BaseAction {
 			emc.beginTransaction(Mapping.class);
 			emc.check(mapping, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Mapping.class);
+			CacheManager.notify(Mapping.class);
 			Wo wo = new Wo();
 			wo.setId(mapping.getId());
 			result.setData(wo);

+ 2 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionList.java

@@ -1,10 +1,11 @@
 package com.x.processplatform.assemble.designer.jaxrs.output;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
@@ -26,8 +27,6 @@ import com.x.processplatform.core.entity.element.wrap.WrapForm;
 import com.x.processplatform.core.entity.element.wrap.WrapProcess;
 import com.x.processplatform.core.entity.element.wrap.WrapProcessPlatform;
 import com.x.processplatform.core.entity.element.wrap.WrapScript;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
 
 class ActionList extends BaseAction {
 

+ 4 - 3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionSelect.java

@@ -14,6 +14,8 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.dataitem.DataItemConverter;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -67,8 +69,6 @@ import com.x.processplatform.core.entity.element.wrap.WrapScript;
 import com.x.processplatform.core.entity.element.wrap.WrapService;
 import com.x.processplatform.core.entity.element.wrap.WrapSplit;
 
-import net.sf.ehcache.Element;
-
 class ActionSelect extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String applicationFlag, JsonElement jsonElement)
@@ -90,7 +90,8 @@ class ActionSelect extends BaseAction {
 			outputCacheObject.setName(application.getName());
 			outputCacheObject.setApplication(wrapApplication);
 			String flag = StringTools.uniqueToken();
-			cache.put(new Element(flag, outputCacheObject));
+			CacheKey cacheKey = new CacheKey(flag);
+			CacheManager.put(cacheCategory, cacheKey, outputCacheObject);
 			Wo wo = gson.fromJson(gson.toJson(wrapApplication), Wo.class);
 			wo.setFlag(flag);
 			result.setData(wo);

+ 13 - 9
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/ActionSelectFile.java

@@ -1,14 +1,16 @@
 package com.x.processplatform.assemble.designer.jaxrs.output;
 
+import java.util.Optional;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.tools.DefaultCharset;
 
-import net.sf.ehcache.Element;
-
 class ActionSelectFile extends BaseAction {
 
 	private static String extension = ".xapp";
@@ -16,15 +18,17 @@ class ActionSelectFile extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
-			Element element = cache.get(flag);
-			if (null == element || null == element.getObjectValue()) {
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				OutputCacheObject outputCacheObject = (OutputCacheObject) optional.get();
+				Wo wo = new Wo(gson.toJson(outputCacheObject.getApplication()).getBytes(DefaultCharset.name),
+						this.contentType(true, outputCacheObject.getName() + extension),
+						this.contentDisposition(true, outputCacheObject.getName() + extension));
+				result.setData(wo);
+			} else {
 				throw new ExceptionFlagNotExist(flag);
 			}
-			OutputCacheObject outputCacheObject = (OutputCacheObject) element.getObjectValue();
-			Wo wo = new Wo(gson.toJson(outputCacheObject.getApplication()).getBytes(DefaultCharset.name),
-					this.contentType(true, outputCacheObject.getName() + extension),
-					this.contentDisposition(true, outputCacheObject.getName() + extension));
-			result.setData(wo);
 			return result;
 		}
 	}

+ 3 - 4
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/output/BaseAction.java

@@ -1,14 +1,13 @@
 package com.x.processplatform.assemble.designer.jaxrs.output;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.processplatform.core.entity.element.wrap.WrapProcessPlatform;
 
-import net.sf.ehcache.Ehcache;
-
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache cache = ApplicationCache.instance().getCache(OutputCacheObject.class);
+//	protected Ehcache cache = ApplicationCache.instance().getCache(OutputCacheObject.class);
+	protected CacheCategory cacheCategory = new CacheCategory(OutputCacheObject.class);
 
 	public static class OutputCacheObject {
 

+ 30 - 18
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/process/BaseAction.java

@@ -5,7 +5,6 @@ import java.util.List;
 
 import javax.persistence.EntityManager;
 
-import com.x.processplatform.core.entity.content.*;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -13,12 +12,25 @@ import org.apache.commons.lang3.StringUtils;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.designer.Business;
 import com.x.processplatform.assemble.designer.ThisApplication;
+import com.x.processplatform.core.entity.content.Attachment;
+import com.x.processplatform.core.entity.content.DocumentVersion;
+import com.x.processplatform.core.entity.content.Draft;
+import com.x.processplatform.core.entity.content.Read;
+import com.x.processplatform.core.entity.content.ReadCompleted;
+import com.x.processplatform.core.entity.content.Record;
+import com.x.processplatform.core.entity.content.Review;
+import com.x.processplatform.core.entity.content.SerialNumber;
+import com.x.processplatform.core.entity.content.Task;
+import com.x.processplatform.core.entity.content.TaskCompleted;
+import com.x.processplatform.core.entity.content.Work;
+import com.x.processplatform.core.entity.content.WorkCompleted;
+import com.x.processplatform.core.entity.content.WorkLog;
 import com.x.processplatform.core.entity.element.Agent;
 import com.x.processplatform.core.entity.element.Begin;
 import com.x.processplatform.core.entity.element.Cancel;
@@ -877,22 +889,22 @@ abstract class BaseAction extends StandardJaxrsAction {
 	}
 
 	void cacheNotify() throws Exception {
-		ApplicationCache.notify(Process.class);
-		ApplicationCache.notify(Agent.class);
-		ApplicationCache.notify(Begin.class);
-		ApplicationCache.notify(Cancel.class);
-		ApplicationCache.notify(Choice.class);
-		ApplicationCache.notify(Delay.class);
-		ApplicationCache.notify(Embed.class);
-		ApplicationCache.notify(End.class);
-		ApplicationCache.notify(Invoke.class);
-		ApplicationCache.notify(Manual.class);
-		ApplicationCache.notify(Merge.class);
-		ApplicationCache.notify(Message.class);
-		ApplicationCache.notify(Parallel.class);
-		ApplicationCache.notify(Route.class);
-		ApplicationCache.notify(Service.class);
-		ApplicationCache.notify(Split.class);
+		CacheManager.notify(Process.class);
+		CacheManager.notify(Agent.class);
+		CacheManager.notify(Begin.class);
+		CacheManager.notify(Cancel.class);
+		CacheManager.notify(Choice.class);
+		CacheManager.notify(Delay.class);
+		CacheManager.notify(Embed.class);
+		CacheManager.notify(End.class);
+		CacheManager.notify(Invoke.class);
+		CacheManager.notify(Manual.class);
+		CacheManager.notify(Merge.class);
+		CacheManager.notify(Message.class);
+		CacheManager.notify(Parallel.class);
+		CacheManager.notify(Route.class);
+		CacheManager.notify(Service.class);
+		CacheManager.notify(Split.class);
 	}
 
 	// public static class WiAgent extends Agent {

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionCreate.java

@@ -10,7 +10,7 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -40,7 +40,7 @@ class ActionCreate extends BaseAction {
 			script.setLastUpdateTime(new Date());
 			emc.persist(script, CheckPersistType.all);
 			emc.commit();
-			ApplicationCache.notify(Script.class);
+			CacheManager.notify(Script.class);
 			Wo wo = new Wo();
 			wo.setId(script.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionDelete.java

@@ -3,7 +3,7 @@ package com.x.processplatform.assemble.designer.jaxrs.script;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -31,7 +31,7 @@ class ActionDelete extends BaseAction {
 			emc.beginTransaction(Script.class);
 			emc.remove(script, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(Script.class);
+			CacheManager.notify(Script.class);
 			Wo wo = new Wo();
 			wo.setId(script.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionEdit.java

@@ -9,7 +9,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -42,7 +42,7 @@ class ActionEdit extends BaseAction {
 			script.setLastUpdatePerson(effectivePerson.getDistinguishedName());
 			script.setLastUpdateTime(new Date());
 			emc.commit();
-			ApplicationCache.notify(Script.class);
+			CacheManager.notify(Script.class);
 			ThisApplication.scriptVersionQueue.send(new ScriptVersion(script.getId(), jsonElement));
 			Wo wo = new Wo();
 			wo.setId(script.getId());

+ 6 - 5
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionListPaging.java

@@ -1,5 +1,11 @@
 package com.x.processplatform.assemble.designer.jaxrs.script;
 
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.Predicate;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
@@ -12,11 +18,6 @@ import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Script;
 
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.Predicate;
-import java.util.List;
-
 class ActionListPaging extends BaseAction {
 	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer page, Integer size) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/templateform/ActionCreate.java

@@ -11,7 +11,7 @@ import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -44,7 +44,7 @@ class ActionCreate extends BaseAction {
 				emc.persist(o, CheckPersistType.all);
 			}
 			emc.commit();
-			ApplicationCache.notify(TemplateForm.class);
+			CacheManager.notify(TemplateForm.class);
 			Wo wo = new Wo();
 			wo.setId(o.getId());
 			result.setData(wo);

+ 2 - 2
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/templateform/ActionDelete.java

@@ -3,7 +3,7 @@ package com.x.processplatform.assemble.designer.jaxrs.templateform;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckRemoveType;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -28,7 +28,7 @@ class ActionDelete extends BaseAction {
 			emc.beginTransaction(TemplateForm.class);
 			emc.remove(template, CheckRemoveType.all);
 			emc.commit();
-			ApplicationCache.notify(TemplateForm.class);
+			CacheManager.notify(TemplateForm.class);
 			Wo wo = new Wo();
 			wo.setId(template.getId());
 			result.setData(wo);

+ 23 - 21
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/Business.java

@@ -2,15 +2,19 @@ package com.x.processplatform.assemble.surface;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import com.x.base.core.project.config.StorageMapping;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.PromptException;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.organization.OrganizationDefinition;
@@ -46,8 +50,6 @@ import com.x.processplatform.assemble.surface.factory.element.MergeFactory;
 import com.x.processplatform.assemble.surface.factory.element.MessageFactory;
 import com.x.processplatform.assemble.surface.factory.element.ParallelFactory;
 import com.x.processplatform.assemble.surface.factory.element.ProcessFactory;
-import com.x.processplatform.assemble.surface.factory.element.QueryStatFactory;
-import com.x.processplatform.assemble.surface.factory.element.QueryViewFactory;
 import com.x.processplatform.assemble.surface.factory.element.RouteFactory;
 import com.x.processplatform.assemble.surface.factory.element.ScriptFactory;
 import com.x.processplatform.assemble.surface.factory.element.ServiceFactory;
@@ -385,23 +387,23 @@ public class Business {
 		return script;
 	}
 
-	private QueryViewFactory queryView;
-
-	public QueryViewFactory queryView() throws Exception {
-		if (null == this.queryView) {
-			this.queryView = new QueryViewFactory(this);
-		}
-		return queryView;
-	}
-
-	private QueryStatFactory queryStat;
-
-	public QueryStatFactory queryStat() throws Exception {
-		if (null == this.queryStat) {
-			this.queryStat = new QueryStatFactory(this);
-		}
-		return queryStat;
-	}
+//	private QueryViewFactory queryView;
+//
+//	public QueryViewFactory queryView() throws Exception {
+//		if (null == this.queryView) {
+//			this.queryView = new QueryViewFactory(this);
+//		}
+//		return queryView;
+//	}
+//
+//	private QueryStatFactory queryStat;
+//
+//	public QueryStatFactory queryStat() throws Exception {
+//		if (null == this.queryStat) {
+//			this.queryStat = new QueryStatFactory(this);
+//		}
+//		return queryStat;
+//	}
 
 	private FileFactory file;
 

+ 1 - 4
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/AgentFactory.java

@@ -12,15 +12,12 @@ public class AgentFactory extends ElementFactory {
 		super(abstractBusiness);
 	}
 
- 
-
 	public Agent pick(String flag) throws Exception {
 		return this.pick(flag, Agent.class);
 	}
 
 	public List<Agent> listWithProcess(Process process) throws Exception {
-		List<Agent> list = this.listWithProcess(Agent.class, process);
-		return list;
+		return this.listWithProcess(Agent.class, process);
 	}
 
 }

+ 4 - 3
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ApplicationDictItemFactory.java

@@ -55,7 +55,8 @@ public class ApplicationDictItemFactory extends AbstractFactory {
 		Root<ApplicationDictItem> root = cq.from(ApplicationDictItem.class);
 		Predicate p = cb.equal(root.get(ApplicationDictItem_.bundle), applicationDict);
 		if (StringUtils.isEmpty(path0)) {
-			p = cb.and(p, cb.or(cb.equal(root.get(ApplicationDictItem_.path0), path0), cb.isNull(root.get(ApplicationDictItem_.path0))));
+			p = cb.and(p, cb.or(cb.equal(root.get(ApplicationDictItem_.path0), path0),
+					cb.isNull(root.get(ApplicationDictItem_.path0))));
 		} else {
 			p = cb.and(p, cb.equal(root.get(ApplicationDictItem_.path0), path0));
 		}
@@ -68,7 +69,7 @@ public class ApplicationDictItemFactory extends AbstractFactory {
 		p = cb.and(p, cb.equal(root.get("path7"), path7));
 		cq.select(root).where(p);
 		List<ApplicationDictItem> list = em.createQuery(cq).getResultList();
-		if (list.size() == 0) {
+		if (list.isEmpty()) {
 			return null;
 		}
 		if (list.size() == 1) {
@@ -94,7 +95,7 @@ public class ApplicationDictItemFactory extends AbstractFactory {
 		}
 		cq.select(root).where(p).orderBy(cb.desc(root.get("path" + paths.length + "Location")));
 		List<ApplicationDictItem> list = em.createQuery(cq).setMaxResults(1).getResultList();
-		if (list.size() == 0) {
+		if (list.isEmpty()) {
 			return null;
 		} else {
 			return list.get(0).get("path" + paths.length + "Location", Integer.class);

+ 6 - 49
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ApplicationFactory.java

@@ -1,6 +1,5 @@
 package com.x.processplatform.assemble.surface.factory.element;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -12,10 +11,9 @@ import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 
-import com.x.base.core.project.cache.ApplicationCache;
-import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.organization.OrganizationDefinition;
 import com.x.base.core.project.tools.ListTools;
@@ -23,57 +21,18 @@ import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Application_;
 
-import net.sf.ehcache.Element;
-
 public class ApplicationFactory extends ElementFactory {
 
 	public ApplicationFactory(Business abstractBusiness) throws Exception {
 		super(abstractBusiness);
-		this.cache = ApplicationCache.instance().getCache(Application.class);
 	}
 
 	public List<Application> pick(List<String> flags) throws Exception {
-		List<Application> list = new ArrayList<>();
-		for (String str : flags) {
-			Element element = cache.get(str);
-			if (null != element) {
-				if (null != element.getObjectValue()) {
-					list.add((Application) element.getObjectValue());
-				}
-			} else {
-				Application o = this.pickObject(str);
-				cache.put(new Element(str, o));
-				if (null != o) {
-					list.add(o);
-				}
-			}
-		}
-		return list;
+		return this.pick(flags, Application.class);
 	}
 
 	public Application pick(String flag) throws Exception {
-		if (StringUtils.isEmpty(flag)) {
-			return null;
-		}
-		Application o = null;
-		Element element = cache.get(flag);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (Application) element.getObjectValue();
-			}
-		} else {
-			o = this.pickObject(flag);
-			cache.put(new Element(flag, o));
-		}
-		return o;
-	}
-
-	private Application pickObject(String flag) throws Exception {
-		Application o = this.business().entityManagerContainer().flag(flag, Application.class);
-		if (o != null) {
-			this.entityManagerContainer().get(Application.class).detach(o);
-		}
-		return o;
+		return this.pick(flag, Application.class);
 	}
 
 	/* 判断用户是否有管理权限 */
@@ -108,8 +67,8 @@ public class ApplicationFactory extends ElementFactory {
 		if (application.getAvailableIdentityList().isEmpty() && application.getAvailableUnitList().isEmpty()) {
 			return true;
 		}
-		if (this.business().organization().person().hasRole(effectivePerson, OrganizationDefinition.Manager,
-				OrganizationDefinition.ProcessPlatformManager)) {
+		if (BooleanUtils.isTrue(this.business().organization().person().hasRole(effectivePerson,
+				OrganizationDefinition.Manager, OrganizationDefinition.ProcessPlatformManager))) {
 			return true;
 		}
 		if (CollectionUtils.containsAny(application.getAvailableIdentityList(), identities)) {
@@ -124,7 +83,6 @@ public class ApplicationFactory extends ElementFactory {
 	/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
 	public List<String> listAvailable(EffectivePerson effectivePerson, List<String> roles, List<String> identities,
 			List<String> units) throws Exception {
-		List<String> list = new ArrayList<>();
 		EntityManager em = this.entityManagerContainer().get(Application.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
@@ -144,8 +102,7 @@ public class ApplicationFactory extends ElementFactory {
 			}
 			cq.where(p);
 		}
-		list = em.createQuery(cq.distinct(true)).getResultList();
-		return list;
+		return em.createQuery(cq.distinct(true)).getResultList();
 	}
 
 	public <T extends Application> List<T> sort(List<T> list) {

+ 14 - 29
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/BeginFactory.java

@@ -1,22 +1,16 @@
 package com.x.processplatform.assemble.surface.factory.element;
 
-import java.util.List;
+import java.util.Optional;
 
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.entity.element.Begin;
 import com.x.processplatform.core.entity.element.Process;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 public class BeginFactory extends ElementFactory {
 
 	public BeginFactory(Business abstractBusiness) throws Exception {
@@ -27,32 +21,23 @@ public class BeginFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Begin pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Begin.class);
 	}
 
 	public Begin getWithProcess(Process process) throws Exception {
 		Begin o = null;
-		Ehcache cache = ApplicationCache.instance().getCache(Begin.class);
-		String cacheKey = "getWithProcess#" + process.getId();
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			Object obj = element.getObjectValue();
-			if (null != obj) {
-				o = (Begin) obj;
-			}
+		CacheCategory cacheCategory = new CacheCategory(Begin.class);
+		CacheKey cacheKey = new CacheKey("getWithProcess", process.getId());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			o = (Begin) optional.get();
 		} else {
-			EntityManager em = this.entityManagerContainer().get(Begin.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<Begin> cq = cb.createQuery(Begin.class);
-			Root<Begin> root = cq.from(Begin.class);
-			Predicate p = cb.equal(root.get("process"), process.getId());
-			cq.select(root).where(p);
-			List<Begin> list = em.createQuery(cq).setMaxResults(1).getResultList();
-			if (!list.isEmpty()) {
-				o = list.get(0);
+			o = this.entityManagerContainer().firstEqual(Begin.class, Activity.process_FIELDNAME, process.getId());
+			if (null != o) {
+				CacheManager.put(cacheCategory, cacheKey, o);
 			}
-			cache.put(new Element(cacheKey, o));
 		}
 		return o;
 	}

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/CancelFactory.java

@@ -17,12 +17,12 @@ public class CancelFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Cancel pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Cancel.class);
 	}
 
 	public List<Cancel> listWithProcess(Process process) throws Exception {
-		List<Cancel> list = this.listWithProcess(Cancel.class, process);
-		return list;
+		return this.listWithProcess(Cancel.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ChoiceFactory.java

@@ -17,12 +17,12 @@ public class ChoiceFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Choice pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Choice.class);
 	}
 
 	public List<Choice> listWithProcess(Process process) throws Exception {
-		List<Choice> list = this.listWithProcess(Choice.class, process);
-		return list;
+		return this.listWithProcess(Choice.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/DelayFactory.java

@@ -17,12 +17,12 @@ public class DelayFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Delay pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Delay.class);
 	}
 
 	public List<Delay> listWithProcess(Process process) throws Exception {
-		List<Delay> list = this.listWithProcess(Delay.class, process);
-		return list;
+		return this.listWithProcess(Delay.class, process);
 	}
 }

+ 41 - 30
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ElementFactory.java

@@ -1,8 +1,10 @@
 package com.x.processplatform.assemble.surface.factory.element;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -11,15 +13,16 @@ import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
 import com.x.base.core.entity.JpaObject;
-import com.x.base.core.project.cache.ApplicationCache;
-import com.x.base.core.project.exception.ExceptionWhen;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.processplatform.assemble.surface.AbstractFactory;
 import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Process;
 
 import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
 
 public abstract class ElementFactory extends AbstractFactory {
 
@@ -31,74 +34,82 @@ public abstract class ElementFactory extends AbstractFactory {
 
 	@SuppressWarnings("unchecked")
 	protected <T extends JpaObject> T pick(String flag, Class<T> clz) throws Exception {
-		Ehcache cache = ApplicationCache.instance().getCache(clz);
+		CacheCategory cacheCategory = new CacheCategory(clz);
+		CacheKey cacheKey = new CacheKey(flag);
 		T t = null;
-		Element element = cache.get(flag);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				t = (T) element.getObjectValue();
-			}
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			t = (T) optional.get();
 		} else {
 			t = this.entityManagerContainer().flag(flag, clz);
 			if (t != null) {
 				this.entityManagerContainer().get(clz).detach(t);
+				CacheManager.put(cacheCategory, cacheKey, t);
 			}
-			cache.put(new Element(flag, t));
 		}
 		return t;
 	}
 
+	protected <T extends JpaObject> List<T> pick(Collection<String> flags, Class<T> clz) throws Exception {
+		List<T> list = new ArrayList<>();
+		for (String str : flags) {
+			T t = pick(str, clz);
+			if (null != t) {
+				list.add(t);
+			}
+		}
+		return list;
+	}
+
 	@SuppressWarnings("unchecked")
 	protected <T extends JpaObject> T pick(Application application, String flag, Class<T> clz) throws Exception {
 		if (null == application) {
 			return null;
 		}
-		Ehcache cache = ApplicationCache.instance().getCache(clz);
+		CacheCategory cacheCategory = new CacheCategory(clz);
+		CacheKey cacheKey = new CacheKey(application.getId(), flag);
 		T t = null;
-		String cacheKey = ApplicationCache.concreteCacheKey(application.getId(), flag);
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				t = (T) element.getObjectValue();
-			}
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			t = (T) optional.get();
 		} else {
 			t = this.entityManagerContainer().restrictFlag(flag, clz, Process.application_FIELDNAME,
 					application.getId());
 			if (t != null) {
 				this.entityManagerContainer().get(clz).detach(t);
+				CacheManager.put(cacheCategory, cacheKey, t);
 			}
-			cache.put(new Element(cacheKey, t));
 		}
 		return t;
 	}
 
-	/* 取得属于指定Process 的设计元素 */
+	// 取得属于指定Process 的设计元素
 	@SuppressWarnings("unchecked")
 	protected <T extends JpaObject> List<T> listWithProcess(Class<T> clz, Process process) throws Exception {
 		List<T> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(clz);
-		String cacheKey = "listWithProcess#" + process.getId() + "#" + clz.getName();
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			Object obj = element.getObjectValue();
-			if (null != obj) {
-				list = (List<T>) obj;
-			}
+		if (null == process) {
+			return list;
+		}
+		CacheCategory cacheCategory = new CacheCategory(clz);
+		CacheKey cacheKey = new CacheKey("listWithProcess", process.getId());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<T>) optional.get();
 		} else {
 			EntityManager em = this.entityManagerContainer().get(clz);
 			CriteriaBuilder cb = em.getCriteriaBuilder();
 			CriteriaQuery<T> cq = cb.createQuery(clz);
 			Root<T> root = cq.from(clz);
-			Predicate p = cb.equal(root.get("process"), process.getId());
+			Predicate p = cb.equal(root.get(Activity.process_FIELDNAME), process.getId());
 			cq.select(root).where(p);
 			List<T> os = em.createQuery(cq).getResultList();
 			for (T t : os) {
 				em.detach(t);
 				list.add(t);
 			}
-			/* 将object改为unmodifiable */
+			// 将object改为unmodifiable
 			list = Collections.unmodifiableList(list);
-			cache.put(new Element(cacheKey, list));
+			CacheManager.put(cacheCategory, cacheKey, list);
 		}
 		return list;
 	}

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/EmbedFactory.java

@@ -17,12 +17,12 @@ public class EmbedFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Embed pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Embed.class);
 	}
 
 	public List<Embed> listWithProcess(Process process) throws Exception {
-		List<Embed> list = this.listWithProcess(Embed.class, process);
-		return list;
+		return this.listWithProcess(Embed.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/EndFactory.java

@@ -17,12 +17,12 @@ public class EndFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public End pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, End.class);
 	}
 
 	public List<End> listWithProcess(Process process) throws Exception {
-		List<End> list = this.listWithProcess(End.class, process);
-		return list;
+		return this.listWithProcess(End.class, process);
 	}
 }

+ 21 - 64
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/FileFactory.java

@@ -1,88 +1,45 @@
 package com.x.processplatform.assemble.surface.factory.element;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.x.base.core.project.cache.ApplicationCache;
-import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.element.File;
-import com.x.processplatform.core.entity.element.File_;
-
-import net.sf.ehcache.Element;
 
 public class FileFactory extends ElementFactory {
 
 	public FileFactory(Business abstractBusiness) throws Exception {
 		super(abstractBusiness);
-		this.cache = ApplicationCache.instance().getCache(File.class);
 	}
 
 	public List<File> pick(List<String> flags) throws Exception {
-		List<File> list = new ArrayList<>();
-		for (String str : flags) {
-			Element element = cache.get(str);
-			if (null != element) {
-				if (null != element.getObjectValue()) {
-					list.add((File) element.getObjectValue());
-				}
-			} else {
-				File o = this.pickObject(str);
-				cache.put(new Element(str, o));
-				if (null != o) {
-					list.add(o);
-				}
-			}
-		}
-		return list;
+		return this.pick(flags, File.class);
 	}
 
 	public File pick(String flag) throws Exception {
-		if (StringUtils.isEmpty(flag)) {
-			return null;
-		}
-		File o = null;
-		Element element = cache.get(flag);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (File) element.getObjectValue();
-			}
-		} else {
-			o = this.pickObject(flag);
-			cache.put(new Element(flag, o));
-		}
-		return o;
+		return this.pick(flag, File.class);
 	}
 
-	private File pickObject(String flag) throws Exception {
-		File o = this.business().entityManagerContainer().flag(flag, File.class);
-		if (o != null) {
-			this.entityManagerContainer().get(File.class).detach(o);
-		}
-		if (null == o) {
-			EntityManager em = this.entityManagerContainer().get(File.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<File> cq = cb.createQuery(File.class);
-			Root<File> root = cq.from(File.class);
-			Predicate p = cb.equal(root.get(File_.name), flag);
-			List<File> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
-			if (os.size() == 1) {
-				o = os.get(0);
-				em.detach(o);
-			}
-		}
-		return o;
-	}
+//	private File pickObject(String flag) throws Exception {
+//		File o = this.business().entityManagerContainer().flag(flag, File.class);
+//		if (o != null) {
+//			this.entityManagerContainer().get(File.class).detach(o);
+//		}
+//		if (null == o) {
+//			EntityManager em = this.entityManagerContainer().get(File.class);
+//			CriteriaBuilder cb = em.getCriteriaBuilder();
+//			CriteriaQuery<File> cq = cb.createQuery(File.class);
+//			Root<File> root = cq.from(File.class);
+//			Predicate p = cb.equal(root.get(File_.name), flag);
+//			List<File> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
+//			if (os.size() == 1) {
+//				o = os.get(0);
+//				em.detach(o);
+//			}
+//		}
+//		return o;
+//	}
 
 	public <T extends File> List<T> sort(List<T> list) {
 		list = list.stream()

+ 2 - 1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/FormFactory.java

@@ -19,8 +19,9 @@ public class FormFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Form pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
-		return this.pick(flag, Form.class );
+		return this.pick(flag, Form.class);
 	}
 
 }

+ 3 - 3
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/InvokeFactory.java

@@ -17,12 +17,12 @@ public class InvokeFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Invoke pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
-		return this.pick(flag, Invoke.class );
+		return this.pick(flag, Invoke.class);
 	}
 
 	public List<Invoke> listWithProcess(Process process) throws Exception {
-		List<Invoke> list = this.listWithProcess(Invoke.class, process);
-		return list;
+		return this.listWithProcess(Invoke.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ManualFactory.java

@@ -17,12 +17,12 @@ public class ManualFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Manual pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Manual.class);
 	}
 
 	public List<Manual> listWithProcess(Process process) throws Exception {
-		List<Manual> list = this.listWithProcess(Manual.class, process);
-		return list;
+		return this.listWithProcess(Manual.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/MergeFactory.java

@@ -17,12 +17,12 @@ public class MergeFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Merge pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Merge.class);
 	}
 
 	public List<Merge> listWithProcess(Process process) throws Exception {
-		List<Merge> list = this.listWithProcess(Merge.class, process);
-		return list;
+		return this.listWithProcess(Merge.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/MessageFactory.java

@@ -17,12 +17,12 @@ public class MessageFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Message pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Message.class );
 	}
 
 	public List<Message> listWithProcess(Process process) throws Exception {
-		List<Message> list = this.listWithProcess(Message.class, process);
-		return list;
+		return this.listWithProcess(Message.class, process);
 	}
 }

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ParallelFactory.java

@@ -17,12 +17,12 @@ public class ParallelFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Parallel pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Parallel.class );
 	}
 
 	public List<Parallel> listWithProcess(Process process) throws Exception {
-		List<Parallel> list = this.listWithProcess(Parallel.class, process);
-		return list;
+		return this.listWithProcess(Parallel.class, process);
 	}
 }

+ 62 - 108
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ProcessFactory.java

@@ -3,12 +3,22 @@ package com.x.processplatform.assemble.surface.factory.element;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import javax.persistence.EntityManager;
-import javax.persistence.criteria.*;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.criteria.Subquery;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.organization.OrganizationDefinition;
 import com.x.base.core.project.tools.ListTools;
@@ -17,139 +27,86 @@ import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Process;
 import com.x.processplatform.core.entity.element.Process_;
 
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import net.sf.ehcache.Element;
-
 public class ProcessFactory extends ElementFactory {
 
 	public ProcessFactory(Business abstractBusiness) throws Exception {
 		super(abstractBusiness);
-		this.cache = ApplicationCache.instance().getCache(Process.class);
 	}
 
 	public List<Process> pick(List<String> flags) throws Exception {
-		List<Process> list = new ArrayList<>();
-		for (String str : flags) {
-			Element element = cache.get(str);
-			if (null != element) {
-				if (null != element.getObjectValue()) {
-					list.add((Process) element.getObjectValue());
-				}
-			} else {
-				Process o = this.pickObject(str);
-				cache.put(new Element(str, o));
-				if (null != o) {
-					list.add(o);
-				}
-			}
-		}
-		return list;
+		return this.pick(flags, Process.class);
 	}
 
 	public Process pick(String flag) throws Exception {
-		if (StringUtils.isEmpty(flag)) {
-			return null;
-		}
-		Process o = null;
-		Element element = cache.get(flag);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (Process) element.getObjectValue();
-			}
-		} else {
-			o = this.pickObject(flag);
-			cache.put(new Element(flag, o));
-		}
-		return o;
+		return this.pick(flag, Process.class);
 	}
 
 	public Process pick(Application application, String flag) throws Exception {
-		if ((null == application) || StringUtils.isEmpty(flag)) {
-			return null;
-		}
-		Process o = null;
-		String cacheKey = ApplicationCache.concreteCacheKey(application.getId(), flag);
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (Process) element.getObjectValue();
-			}
-		} else {
-			o = this.restrictProcess(application.getId(), flag);
-			if (null != o) {
-				this.entityManagerContainer().get(Process.class).detach(o);
-				cache.put(new Element(cacheKey, o));
-			}
-		}
-		return o;
+		return this.pick(application, flag, Process.class);
 	}
 
 	public Process pickEnabled(String application, String edition) throws Exception {
 		if (StringUtils.isEmpty(application) || StringUtils.isEmpty(edition)) {
 			return null;
 		}
+		CacheCategory cacheCategory = new CacheCategory(Process.class);
+		CacheKey cacheKey = new CacheKey(application, edition);
 		Process o = null;
-		String cacheKey = ApplicationCache.concreteCacheKey(application, "e:" + edition);
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (Process) element.getObjectValue();
-			}
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			o = (Process) optional.get();
 		} else {
 			o = this.getEnabledProcess(application, edition);
 			if (null != o) {
 				this.entityManagerContainer().get(Process.class).detach(o);
-				cache.put(new Element(cacheKey, o));
+				CacheManager.put(cacheCategory, cacheKey, o);
 			}
 		}
 		return o;
 	}
 
-	private Process pickObject(String flag) throws Exception {
-		Process o = this.business().entityManagerContainer().flag(flag, Process.class);
-		if (o != null) {
-			this.entityManagerContainer().get(Process.class).detach(o);
-		}
-		if (null == o) {
-			EntityManager em = this.entityManagerContainer().get(Process.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<Process> cq = cb.createQuery(Process.class);
-			Root<Process> root = cq.from(Process.class);
-			Predicate p = cb.equal(root.get(Process_.name), flag);
-			List<Process> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
-			if (os.size() == 1) {
-				o = os.get(0);
-				em.detach(o);
-			}
-		}
-		return o;
-	}
+//	private Process pickObject(String flag) throws Exception {
+//		Process o = this.business().entityManagerContainer().flag(flag, Process.class);
+//		if (o != null) {
+//			this.entityManagerContainer().get(Process.class).detach(o);
+//		}
+//		if (null == o) {
+//			EntityManager em = this.entityManagerContainer().get(Process.class);
+//			CriteriaBuilder cb = em.getCriteriaBuilder();
+//			CriteriaQuery<Process> cq = cb.createQuery(Process.class);
+//			Root<Process> root = cq.from(Process.class);
+//			Predicate p = cb.equal(root.get(Process_.name), flag);
+//			List<Process> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
+//			if (os.size() == 1) {
+//				o = os.get(0);
+//				em.detach(o);
+//			}
+//		}
+//		return o;
+//	}
 
-	public Process pickObject(Application application, String flag) throws Exception {
-		if (null == application || StringUtils.isEmpty(flag)) {
-			return null;
-		}
-		Process o = null;
-		String cacheKey = ApplicationCache.concreteCacheKey(Process.class, application.getId(), flag);
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (Process) element.getObjectValue();
-			}
-		} else {
-			o = this.restrictProcess(application.getId(), flag);
-			if (null != o) {
-				cache.put(new Element(cacheKey, o));
-			}
-		}
-		return o;
-	}
+//	public Process pickObject(Application application, String flag) throws Exception {
+//		if (null == application || StringUtils.isEmpty(flag)) {
+//			return null;
+//		}
+//		Process o = null;
+//		String cacheKey = ApplicationCache.concreteCacheKey(Process.class, application.getId(), flag);
+//		Element element = cache.get(cacheKey);
+//		if (null != element) {
+//			if (null != element.getObjectValue()) {
+//				o = (Process) element.getObjectValue();
+//			}
+//		} else {
+//			o = this.restrictProcess(application.getId(), flag);
+//			if (null != o) {
+//				cache.put(new Element(cacheKey, o));
+//			}
+//		}
+//		return o;
+//	}
 
 	/* 获取Application下的所有流程 */
 	public List<String> listWithApplication(Application application) throws Exception {
-		List<String> list = new ArrayList<>();
 		EntityManager em = this.entityManagerContainer().get(Process.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
@@ -157,8 +114,7 @@ public class ProcessFactory extends ElementFactory {
 		Predicate p = cb.equal(root.get(Process_.application), application.getId());
 		p = cb.and(p, cb.or(cb.isTrue(root.get(Process_.editionEnable)), cb.isNull(root.get(Process_.editionEnable))));
 		cq.select(root.get(Process_.id)).where(p).distinct(true);
-		list = em.createQuery(cq).getResultList();
-		return list;
+		return em.createQuery(cq).getResultList();
 	}
 
 	/* 获取用户可启动的流程,如果applicationId 为空则取到所有可启动流程 */
@@ -217,10 +173,8 @@ public class ProcessFactory extends ElementFactory {
 		List<String> list = new ArrayList<>();
 		for (String str : ids) {
 			Process o = this.pick(str);
-			if (null != o) {
-				if (effectivePerson.isPerson(o.getControllerList())) {
-					list.add(str);
-				}
+			if ((null != o) && (effectivePerson.isPerson(o.getControllerList()))) {
+				list.add(str);
 			}
 		}
 		return list;

+ 116 - 116
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/QueryStatFactory.java

@@ -1,116 +1,116 @@
-package com.x.processplatform.assemble.surface.factory.element;
-
-import java.util.List;
-import java.util.Objects;
-
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.x.base.core.project.cache.ApplicationCache;
-import com.x.base.core.project.exception.ExceptionWhen;
-import com.x.base.core.project.http.EffectivePerson;
-import com.x.base.core.project.tools.ListTools;
-import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.core.entity.element.Application;
-import com.x.processplatform.core.entity.element.QueryStat;
-import com.x.processplatform.core.entity.element.QueryStat_;
-
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
-public class QueryStatFactory extends ElementFactory {
-
-	public QueryStatFactory(Business abstractBusiness) throws Exception {
-		super(abstractBusiness);
-	}
-
-	public QueryStat pick(String flag, Application application) throws Exception {
-		return this.pick(flag, application, ExceptionWhen.none);
-	}
-
-	public QueryStat pick(String flag, Application application, ExceptionWhen exceptionWhen) throws Exception {
-		Ehcache cache = ApplicationCache.instance().getCache(QueryStat.class);
-		String cacheKey = flag + "#" + application.getId();
-		Element element = cache.get(cacheKey);
-		QueryStat o = null;
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (QueryStat) element.getObjectValue();
-			}
-		} else {
-			EntityManager em = this.entityManagerContainer().get(QueryStat.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<QueryStat> cq = cb.createQuery(QueryStat.class);
-			Root<QueryStat> root = cq.from(QueryStat.class);
-			Predicate p = cb.equal(root.get(QueryStat_.application), application.getId());
-			p = cb.and(p, cb.or(cb.equal(root.get(QueryStat_.id), flag), cb.equal(root.get(QueryStat_.alias), flag),
-					cb.equal(root.get(QueryStat_.name), flag)));
-			cq.select(root).where(p);
-			List<QueryStat> list = em.createQuery(cq).getResultList();
-			if (list.isEmpty()) {
-				cache.put(new Element(cacheKey, o));
-			} else if (list.size() == 1) {
-				o = list.get(0);
-				em.detach(o);
-				cache.put(new Element(cacheKey, o));
-			} else {
-				throw new Exception("multiple queryStat with flag:" + flag + ".");
-			}
-		}
-		if (o == null && Objects.equals(ExceptionWhen.not_found, exceptionWhen)) {
-			throw new Exception("can not find queryStat with flag:" + flag + ".");
-		}
-		return o;
-	}
-
-	public Boolean allowRead(EffectivePerson effectivePerson, QueryStat queryStat, Application application)
-			throws Exception {
-		if (!StringUtils.equals(queryStat.getApplication(), application.getId())) {
-			throw new Exception(
-					"queryStat:{id:" + queryStat.getId() + "} not in application{id:" + application.getId() + "}");
-		}
-		/* 全部为空,没有设置范围 */
-		if (ListTools.isEmpty(queryStat.getAvailableUnitList())
-				&& ListTools.isEmpty(queryStat.getAvailableIdentityList())
-				&& ListTools.isEmpty(queryStat.getAvailablePersonList())) {
-			return true;
-		}
-		if (effectivePerson.isPerson(queryStat.getCreatorPerson())) {
-			return true;
-		}
-		if (effectivePerson.isManager()) {
-			return true;
-		}
-		if (effectivePerson.isPerson(application.getControllerList())) {
-			return true;
-		}
-		if (effectivePerson.isPerson(queryStat.getControllerList())) {
-			return true;
-		}
-		if (ListTools.isNotEmpty(queryStat.getAvailablePersonList())) {
-			if (ListTools.contains(queryStat.getAvailableIdentityList(), effectivePerson.getDistinguishedName())) {
-				return true;
-			}
-		}
-		if (ListTools.isNotEmpty(queryStat.getAvailableIdentityList())) {
-			List<String> list = this.business().organization().identity()
-					.listWithPerson(effectivePerson.getDistinguishedName());
-			if (ListTools.containsAny(list, queryStat.getAvailableIdentityList())) {
-				return true;
-			}
-		}
-		if (ListTools.isNotEmpty(queryStat.getAvailableUnitList())) {
-			List<String> list = this.business().organization().unit().listWithPerson(effectivePerson);
-			if (ListTools.containsAny(list, queryStat.getAvailableUnitList())) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-}
+//package com.x.processplatform.assemble.surface.factory.element;
+//
+//import java.util.List;
+//import java.util.Objects;
+//
+//import javax.persistence.EntityManager;
+//import javax.persistence.criteria.CriteriaBuilder;
+//import javax.persistence.criteria.CriteriaQuery;
+//import javax.persistence.criteria.Predicate;
+//import javax.persistence.criteria.Root;
+//
+//import org.apache.commons.lang3.StringUtils;
+//
+//import com.x.base.core.project.cache.ApplicationCache;
+//import com.x.base.core.project.exception.ExceptionWhen;
+//import com.x.base.core.project.http.EffectivePerson;
+//import com.x.base.core.project.tools.ListTools;
+//import com.x.processplatform.assemble.surface.Business;
+//import com.x.processplatform.core.entity.element.Application;
+//import com.x.processplatform.core.entity.element.QueryStat;
+//import com.x.processplatform.core.entity.element.QueryStat_;
+//
+//import net.sf.ehcache.Ehcache;
+//import net.sf.ehcache.Element;
+//
+//public class QueryStatFactory extends ElementFactory {
+//
+//	public QueryStatFactory(Business abstractBusiness) throws Exception {
+//		super(abstractBusiness);
+//	}
+//
+//	public QueryStat pick(String flag, Application application) throws Exception {
+//		return this.pick(flag, application, ExceptionWhen.none);
+//	}
+//
+//	public QueryStat pick(String flag, Application application, ExceptionWhen exceptionWhen) throws Exception {
+//		Ehcache cache = ApplicationCache.instance().getCache(QueryStat.class);
+//		String cacheKey = flag + "#" + application.getId();
+//		Element element = cache.get(cacheKey);
+//		QueryStat o = null;
+//		if (null != element) {
+//			if (null != element.getObjectValue()) {
+//				o = (QueryStat) element.getObjectValue();
+//			}
+//		} else {
+//			EntityManager em = this.entityManagerContainer().get(QueryStat.class);
+//			CriteriaBuilder cb = em.getCriteriaBuilder();
+//			CriteriaQuery<QueryStat> cq = cb.createQuery(QueryStat.class);
+//			Root<QueryStat> root = cq.from(QueryStat.class);
+//			Predicate p = cb.equal(root.get(QueryStat_.application), application.getId());
+//			p = cb.and(p, cb.or(cb.equal(root.get(QueryStat_.id), flag), cb.equal(root.get(QueryStat_.alias), flag),
+//					cb.equal(root.get(QueryStat_.name), flag)));
+//			cq.select(root).where(p);
+//			List<QueryStat> list = em.createQuery(cq).getResultList();
+//			if (list.isEmpty()) {
+//				cache.put(new Element(cacheKey, o));
+//			} else if (list.size() == 1) {
+//				o = list.get(0);
+//				em.detach(o);
+//				cache.put(new Element(cacheKey, o));
+//			} else {
+//				throw new Exception("multiple queryStat with flag:" + flag + ".");
+//			}
+//		}
+//		if (o == null && Objects.equals(ExceptionWhen.not_found, exceptionWhen)) {
+//			throw new Exception("can not find queryStat with flag:" + flag + ".");
+//		}
+//		return o;
+//	}
+//
+//	public Boolean allowRead(EffectivePerson effectivePerson, QueryStat queryStat, Application application)
+//			throws Exception {
+//		if (!StringUtils.equals(queryStat.getApplication(), application.getId())) {
+//			throw new Exception(
+//					"queryStat:{id:" + queryStat.getId() + "} not in application{id:" + application.getId() + "}");
+//		}
+//		/* 全部为空,没有设置范围 */
+//		if (ListTools.isEmpty(queryStat.getAvailableUnitList())
+//				&& ListTools.isEmpty(queryStat.getAvailableIdentityList())
+//				&& ListTools.isEmpty(queryStat.getAvailablePersonList())) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(queryStat.getCreatorPerson())) {
+//			return true;
+//		}
+//		if (effectivePerson.isManager()) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(application.getControllerList())) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(queryStat.getControllerList())) {
+//			return true;
+//		}
+//		if (ListTools.isNotEmpty(queryStat.getAvailablePersonList())) {
+//			if (ListTools.contains(queryStat.getAvailableIdentityList(), effectivePerson.getDistinguishedName())) {
+//				return true;
+//			}
+//		}
+//		if (ListTools.isNotEmpty(queryStat.getAvailableIdentityList())) {
+//			List<String> list = this.business().organization().identity()
+//					.listWithPerson(effectivePerson.getDistinguishedName());
+//			if (ListTools.containsAny(list, queryStat.getAvailableIdentityList())) {
+//				return true;
+//			}
+//		}
+//		if (ListTools.isNotEmpty(queryStat.getAvailableUnitList())) {
+//			List<String> list = this.business().organization().unit().listWithPerson(effectivePerson);
+//			if (ListTools.containsAny(list, queryStat.getAvailableUnitList())) {
+//				return true;
+//			}
+//		}
+//		return false;
+//	}
+//
+//}

+ 117 - 117
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/QueryViewFactory.java

@@ -1,117 +1,117 @@
-package com.x.processplatform.assemble.surface.factory.element;
-
-import java.util.List;
-import java.util.Objects;
-
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.x.base.core.project.cache.ApplicationCache;
-import com.x.base.core.project.exception.ExceptionWhen;
-import com.x.base.core.project.http.EffectivePerson;
-import com.x.base.core.project.tools.ListTools;
-import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.core.entity.element.Application;
-import com.x.processplatform.core.entity.element.QueryView;
-import com.x.processplatform.core.entity.element.QueryView_;
-
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
-public class QueryViewFactory extends ElementFactory {
-
-	public QueryViewFactory(Business abstractBusiness) throws Exception {
-		super(abstractBusiness);
-	}
-
-	public QueryView pick(String flag, Application application) throws Exception {
-		return this.pick(flag, application, ExceptionWhen.none);
-	}
-
-	public QueryView pick(String flag, Application application, ExceptionWhen exceptionWhen) throws Exception {
-		Ehcache cache = ApplicationCache.instance().getCache(QueryView.class);
-		String cacheKey = flag + "#" + application.getId();
-		Element element = cache.get(cacheKey);
-		QueryView o = null;
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				o = (QueryView) element.getObjectValue();
-			}
-		} else {
-			EntityManager em = this.entityManagerContainer().get(QueryView.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<QueryView> cq = cb.createQuery(QueryView.class);
-			Root<QueryView> root = cq.from(QueryView.class);
-			Predicate p = cb.equal(root.get(QueryView_.application), application.getId());
-			p = cb.and(p, cb.or(cb.equal(root.get(QueryView_.id), flag), cb.equal(root.get(QueryView_.alias), flag),
-					cb.equal(root.get(QueryView_.name), flag)));
-			cq.select(root).where(p);
-			List<QueryView> list = em.createQuery(cq).getResultList();
-			if (list.isEmpty()) {
-				cache.put(new Element(cacheKey, o));
-			} else if (list.size() == 1) {
-				o = list.get(0);
-				em.detach(o);
-				cache.put(new Element(cacheKey, o));
-			} else {
-				throw new Exception("multiple queryView with flag:" + flag + ".");
-			}
-		}
-		if (o == null && Objects.equals(ExceptionWhen.not_found, exceptionWhen)) {
-			throw new Exception("can not find queryView with flag:" + flag + ".");
-		}
-		return o;
-	}
-
-	public Boolean allowRead(EffectivePerson effectivePerson, QueryView queryView, Application application)
-			throws Exception {
-		if (!StringUtils.equals(queryView.getApplication(), application.getId())) {
-			throw new Exception(
-					"queryView:{id:" + queryView.getId() + "} not in application{id:" + application.getId() + "}");
-		}
-		/* 全部为空,没有设置范围 */
-		if (ListTools.isEmpty(queryView.getAvailableUnitList())
-				&& ListTools.isEmpty(queryView.getAvailableIdentityList())
-				&& ListTools.isEmpty(queryView.getAvailablePersonList())) {
-			return true;
-		}
-		if (effectivePerson.isPerson(queryView.getCreatorPerson())) {
-			return true;
-		}
-		if (effectivePerson.isManager()) {
-			return true;
-		}
-		if (effectivePerson.isPerson(application.getControllerList())) {
-			return true;
-		}
-		if (effectivePerson.isPerson(queryView.getControllerList())) {
-			return true;
-		}
-		if (ListTools.isNotEmpty(queryView.getAvailablePersonList())) {
-			if (ListTools.contains(queryView.getAvailableIdentityList(), effectivePerson.getDistinguishedName())) {
-				return true;
-			}
-		}
-		if (ListTools.isNotEmpty(queryView.getAvailableIdentityList())) {
-			List<String> list = this.business().organization().identity()
-					.listWithPerson(effectivePerson.getDistinguishedName());
-			if (ListTools.containsAny(list, queryView.getAvailableIdentityList())) {
-				return true;
-			}
-		}
-		if (ListTools.isNotEmpty(queryView.getAvailableUnitList())) {
-			List<String> list = this.business().organization().unit()
-					.listWithPerson(effectivePerson.getDistinguishedName());
-			if (ListTools.containsAny(list, queryView.getAvailableUnitList())) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-}
+//package com.x.processplatform.assemble.surface.factory.element;
+//
+//import java.util.List;
+//import java.util.Objects;
+//
+//import javax.persistence.EntityManager;
+//import javax.persistence.criteria.CriteriaBuilder;
+//import javax.persistence.criteria.CriteriaQuery;
+//import javax.persistence.criteria.Predicate;
+//import javax.persistence.criteria.Root;
+//
+//import org.apache.commons.lang3.StringUtils;
+//
+//import com.x.base.core.project.cache.ApplicationCache;
+//import com.x.base.core.project.exception.ExceptionWhen;
+//import com.x.base.core.project.http.EffectivePerson;
+//import com.x.base.core.project.tools.ListTools;
+//import com.x.processplatform.assemble.surface.Business;
+//import com.x.processplatform.core.entity.element.Application;
+//import com.x.processplatform.core.entity.element.QueryView;
+//import com.x.processplatform.core.entity.element.QueryView_;
+//
+//import net.sf.ehcache.Ehcache;
+//import net.sf.ehcache.Element;
+//
+//public class QueryViewFactory extends ElementFactory {
+//
+//	public QueryViewFactory(Business abstractBusiness) throws Exception {
+//		super(abstractBusiness);
+//	}
+//
+//	public QueryView pick(String flag, Application application) throws Exception {
+//		return this.pick(flag, application, ExceptionWhen.none);
+//	}
+//
+//	public QueryView pick(String flag, Application application, ExceptionWhen exceptionWhen) throws Exception {
+//		Ehcache cache = ApplicationCache.instance().getCache(QueryView.class);
+//		String cacheKey = flag + "#" + application.getId();
+//		Element element = cache.get(cacheKey);
+//		QueryView o = null;
+//		if (null != element) {
+//			if (null != element.getObjectValue()) {
+//				o = (QueryView) element.getObjectValue();
+//			}
+//		} else {
+//			EntityManager em = this.entityManagerContainer().get(QueryView.class);
+//			CriteriaBuilder cb = em.getCriteriaBuilder();
+//			CriteriaQuery<QueryView> cq = cb.createQuery(QueryView.class);
+//			Root<QueryView> root = cq.from(QueryView.class);
+//			Predicate p = cb.equal(root.get(QueryView_.application), application.getId());
+//			p = cb.and(p, cb.or(cb.equal(root.get(QueryView_.id), flag), cb.equal(root.get(QueryView_.alias), flag),
+//					cb.equal(root.get(QueryView_.name), flag)));
+//			cq.select(root).where(p);
+//			List<QueryView> list = em.createQuery(cq).getResultList();
+//			if (list.isEmpty()) {
+//				cache.put(new Element(cacheKey, o));
+//			} else if (list.size() == 1) {
+//				o = list.get(0);
+//				em.detach(o);
+//				cache.put(new Element(cacheKey, o));
+//			} else {
+//				throw new Exception("multiple queryView with flag:" + flag + ".");
+//			}
+//		}
+//		if (o == null && Objects.equals(ExceptionWhen.not_found, exceptionWhen)) {
+//			throw new Exception("can not find queryView with flag:" + flag + ".");
+//		}
+//		return o;
+//	}
+//
+//	public Boolean allowRead(EffectivePerson effectivePerson, QueryView queryView, Application application)
+//			throws Exception {
+//		if (!StringUtils.equals(queryView.getApplication(), application.getId())) {
+//			throw new Exception(
+//					"queryView:{id:" + queryView.getId() + "} not in application{id:" + application.getId() + "}");
+//		}
+//		/* 全部为空,没有设置范围 */
+//		if (ListTools.isEmpty(queryView.getAvailableUnitList())
+//				&& ListTools.isEmpty(queryView.getAvailableIdentityList())
+//				&& ListTools.isEmpty(queryView.getAvailablePersonList())) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(queryView.getCreatorPerson())) {
+//			return true;
+//		}
+//		if (effectivePerson.isManager()) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(application.getControllerList())) {
+//			return true;
+//		}
+//		if (effectivePerson.isPerson(queryView.getControllerList())) {
+//			return true;
+//		}
+//		if (ListTools.isNotEmpty(queryView.getAvailablePersonList())) {
+//			if (ListTools.contains(queryView.getAvailableIdentityList(), effectivePerson.getDistinguishedName())) {
+//				return true;
+//			}
+//		}
+//		if (ListTools.isNotEmpty(queryView.getAvailableIdentityList())) {
+//			List<String> list = this.business().organization().identity()
+//					.listWithPerson(effectivePerson.getDistinguishedName());
+//			if (ListTools.containsAny(list, queryView.getAvailableIdentityList())) {
+//				return true;
+//			}
+//		}
+//		if (ListTools.isNotEmpty(queryView.getAvailableUnitList())) {
+//			List<String> list = this.business().organization().unit()
+//					.listWithPerson(effectivePerson.getDistinguishedName());
+//			if (ListTools.containsAny(list, queryView.getAvailableUnitList())) {
+//				return true;
+//			}
+//		}
+//		return false;
+//	}
+//
+//}

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/RouteFactory.java

@@ -18,6 +18,7 @@ public class RouteFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Route pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Route.class);
 	}
@@ -34,7 +35,6 @@ public class RouteFactory extends ElementFactory {
 	}
 
 	public List<Route> listWithProcess(Process process) throws Exception {
-		List<Route> list = this.listWithProcess(Route.class, process);
-		return list;
+		return this.listWithProcess(Route.class, process);
 	}
 }

+ 15 - 13
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ScriptFactory.java

@@ -3,6 +3,7 @@ package com.x.processplatform.assemble.surface.factory.element;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -10,16 +11,15 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Script;
 import com.x.processplatform.core.entity.element.Script_;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 public class ScriptFactory extends ElementFactory {
 
 	public ScriptFactory(Business abstractBusiness) throws Exception {
@@ -30,6 +30,7 @@ public class ScriptFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
 		return this.pick(flag, Script.class);
 	}
@@ -38,14 +39,15 @@ public class ScriptFactory extends ElementFactory {
 	public List<Script> listScriptNestedWithApplicationWithUniqueName(Application application, String uniqueName)
 			throws Exception {
 		List<Script> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Script.class);
-		String cacheKey = ApplicationCache.concreteCacheKey("listScriptNestedWithWithApplicationWithUniqueName",
-				application.getId(), uniqueName);
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			if (null != element.getObjectValue()) {
-				list = (List<Script>) element.getObjectValue();
-			}
+		if (null == application) {
+			return list;
+		}
+		CacheCategory cacheCategory = new CacheCategory(Script.class);
+		CacheKey cacheKey = new CacheKey("listScriptNestedWithApplicationWithUniqueName", application.getId(),
+				uniqueName);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<Script>) optional.get();
 		} else {
 			List<String> names = new ArrayList<>();
 			names.add(uniqueName);
@@ -62,7 +64,7 @@ public class ScriptFactory extends ElementFactory {
 			}
 			if (!list.isEmpty()) {
 				Collections.reverse(list);
-				cache.put(new Element(cacheKey, list));
+				CacheManager.put(cacheCategory, cacheKey, list);
 			}
 		}
 		return list;

+ 3 - 3
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ServiceFactory.java

@@ -17,12 +17,12 @@ public class ServiceFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Service pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
-		return this.pick(flag, Service.class );
+		return this.pick(flag, Service.class);
 	}
 
 	public List<Service> listWithProcess(Process process) throws Exception {
-		List<Service> list = this.listWithProcess(Service.class, process);
-		return list;
+		return this.listWithProcess(Service.class, process);
 	}
 }

+ 3 - 3
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/SplitFactory.java

@@ -17,12 +17,12 @@ public class SplitFactory extends ElementFactory {
 		return this.pick(flag, ExceptionWhen.none);
 	}
 
+	@Deprecated
 	public Split pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
-		return this.pick(flag, Split.class );
+		return this.pick(flag, Split.class);
 	}
 
 	public List<Split> listWithProcess(Process process) throws Exception {
-		List<Split> list = this.listWithProcess(Split.class, process);
-		return list;
+		return this.listWithProcess(Split.class, process);
 	}
 }

+ 35 - 27
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompleted.java

@@ -1,14 +1,22 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
 import java.io.ByteArrayOutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 
-import net.sf.ehcache.Element;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -17,7 +25,6 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DateTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.assemble.surface.WorkCompletedControl;
 import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
@@ -26,26 +33,27 @@ class ActionBatchDownloadWithWorkOrWorkCompleted extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionBatchDownloadWithWorkOrWorkCompleted.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String site, String fileName, String flag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String site, String fileName, String flag)
+			throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
 			String title = "";
 			String job = "";
 			Work work = emc.find(workId, Work.class);
-			if(work == null){
+			if (work == null) {
 				WorkCompleted workCompleted = emc.find(workId, WorkCompleted.class);
 				if (null == workCompleted) {
-					throw new Exception("workId: "+workId+" not exist in work or workCompleted");
+					throw new Exception("workId: " + workId + " not exist in work or workCompleted");
 				}
-				if(!business.readable(effectivePerson, workCompleted)){
+				if (!business.readable(effectivePerson, workCompleted)) {
 					throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(),
 							workCompleted.getTitle(), workCompleted.getId());
 				}
 				title = workCompleted.getTitle();
 				job = workCompleted.getJob();
-			}else{
-				if(!business.readable(effectivePerson, work)){
+			} else {
+				if (!business.readable(effectivePerson, work)) {
 					throw new ExceptionAccessDenied(effectivePerson, work);
 				}
 				title = work.getTitle();
@@ -54,10 +62,12 @@ class ActionBatchDownloadWithWorkOrWorkCompleted extends BaseAction {
 			List<Attachment> attachmentList;
 			if (StringUtils.isBlank(site) || EMPTY_SYMBOL.equals(site)) {
 				attachmentList = business.attachment().listWithJobObject(job);
-			}else if(site.indexOf("~")==-1){
-				attachmentList = emc.listEqualAndEqual(Attachment.class, Attachment.job_FIELDNAME, job, Attachment.site_FIELDNAME, site);
-			}else {
-				attachmentList = emc.listEqualAndIn(Attachment.class, Attachment.job_FIELDNAME, job, Attachment.site_FIELDNAME, Arrays.asList(site.split("~")));
+			} else if (site.indexOf("~") == -1) {
+				attachmentList = emc.listEqualAndEqual(Attachment.class, Attachment.job_FIELDNAME, job,
+						Attachment.site_FIELDNAME, site);
+			} else {
+				attachmentList = emc.listEqualAndIn(Attachment.class, Attachment.job_FIELDNAME, job,
+						Attachment.site_FIELDNAME, Arrays.asList(site.split("~")));
 			}
 
 			List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
@@ -68,30 +78,31 @@ class ActionBatchDownloadWithWorkOrWorkCompleted extends BaseAction {
 					readableAttachmentList.add(attachment);
 				}
 			}
-			if(StringUtils.isBlank(fileName)){
-				fileName = title + DateTools.format(new Date(),DateTools.formatCompact_yyyyMMddHHmmss) + ".zip";
-			}else{
+			if (StringUtils.isBlank(fileName)) {
+				fileName = title + DateTools.format(new Date(), DateTools.formatCompact_yyyyMMddHHmmss) + ".zip";
+			} else {
 				String extension = FilenameUtils.getExtension(fileName);
-				if(StringUtils.isEmpty(extension)){
+				if (StringUtils.isEmpty(extension)) {
 					fileName = fileName + ".zip";
 				}
 			}
 
 			Map<String, byte[]> map = new HashMap<>();
-			if(StringUtils.isNotEmpty(flag)) {
-				Element element = cache.get(flag);
-				if ((null != element) && (null != element.getObjectValue())) {
-					CacheResultObject ro = (CacheResultObject) element.getObjectValue();
+			if (StringUtils.isNotEmpty(flag)) {
+				CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+				CacheKey cacheKey = new CacheKey(flag);
+				Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+				if (optional.isPresent()) {
+					CacheResultObject ro = (CacheResultObject) optional.get();
 					map.put(ro.getName(), ro.getBytes());
 				}
 			}
 
-			logger.info("batchDown to {},att size {}, from work {}",fileName, attachmentList.size(), workId);
+			logger.info("batchDown to {},att size {}, from work {}", fileName, attachmentList.size(), workId);
 			try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
 				business.downToZip(readableAttachmentList, os, map);
 				byte[] bs = os.toByteArray();
-				Wo wo = new Wo(bs, this.contentType(false, fileName),
-						this.contentDisposition(false, fileName));
+				Wo wo = new Wo(bs, this.contentType(false, fileName), this.contentDisposition(false, fileName));
 				result.setData(wo);
 			}
 
@@ -107,7 +118,4 @@ class ActionBatchDownloadWithWorkOrWorkCompleted extends BaseAction {
 
 	}
 
-	public static class WoControl extends WorkCompletedControl {
-	}
-
 }

+ 41 - 31
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionBatchDownloadWithWorkOrWorkCompletedStream.java

@@ -1,7 +1,22 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -10,41 +25,35 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DateTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.assemble.surface.WorkCompletedControl;
 import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import net.sf.ehcache.Element;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.ByteArrayOutputStream;
-import java.util.*;
 
 class ActionBatchDownloadWithWorkOrWorkCompletedStream extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionBatchDownloadWithWorkOrWorkCompletedStream.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String site, String fileName, String flag) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String site, String fileName, String flag)
+			throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
 			String title = "";
 			String job = "";
 			Work work = emc.find(workId, Work.class);
-			if(work == null){
+			if (work == null) {
 				WorkCompleted workCompleted = emc.find(workId, WorkCompleted.class);
 				if (null == workCompleted) {
-					throw new Exception("workId: "+workId+" not exist in work or workCompleted");
+					throw new Exception("workId: " + workId + " not exist in work or workCompleted");
 				}
-				if(!business.readable(effectivePerson, workCompleted)){
+				if (!business.readable(effectivePerson, workCompleted)) {
 					throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(),
 							workCompleted.getTitle(), workCompleted.getId());
 				}
 				title = workCompleted.getTitle();
 				job = workCompleted.getJob();
-			}else{
-				if(!business.readable(effectivePerson, work)){
+			} else {
+				if (!business.readable(effectivePerson, work)) {
 					throw new ExceptionAccessDenied(effectivePerson, work);
 				}
 				title = work.getTitle();
@@ -54,10 +63,12 @@ class ActionBatchDownloadWithWorkOrWorkCompletedStream extends BaseAction {
 			List<Attachment> attachmentList;
 			if (StringUtils.isBlank(site) || EMPTY_SYMBOL.equals(site)) {
 				attachmentList = business.attachment().listWithJobObject(job);
-			}else if(site.indexOf("~")==-1){
-				attachmentList = emc.listEqualAndEqual(Attachment.class, Attachment.job_FIELDNAME, job, Attachment.site_FIELDNAME, site);
-			}else {
-				attachmentList = emc.listEqualAndIn(Attachment.class, Attachment.job_FIELDNAME, job, Attachment.site_FIELDNAME, Arrays.asList(site.split("~")));
+			} else if (site.indexOf("~") == -1) {
+				attachmentList = emc.listEqualAndEqual(Attachment.class, Attachment.job_FIELDNAME, job,
+						Attachment.site_FIELDNAME, site);
+			} else {
+				attachmentList = emc.listEqualAndIn(Attachment.class, Attachment.job_FIELDNAME, job,
+						Attachment.site_FIELDNAME, Arrays.asList(site.split("~")));
 			}
 			List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
 			List<String> units = business.organization().unit().listWithPerson(effectivePerson);
@@ -67,30 +78,32 @@ class ActionBatchDownloadWithWorkOrWorkCompletedStream extends BaseAction {
 					readableAttachmentList.add(attachment);
 				}
 			}
-			if(StringUtils.isBlank(fileName)){
-				fileName = title + DateTools.format(new Date(),DateTools.formatCompact_yyyyMMddHHmmss) + ".zip";
-			}else{
+			if (StringUtils.isBlank(fileName)) {
+				fileName = title + DateTools.format(new Date(), DateTools.formatCompact_yyyyMMddHHmmss) + ".zip";
+			} else {
 				String extension = FilenameUtils.getExtension(fileName);
-				if(StringUtils.isEmpty(extension)){
+				if (StringUtils.isEmpty(extension)) {
 					fileName = fileName + ".zip";
 				}
 			}
 
 			Map<String, byte[]> map = new HashMap<>();
-			if(StringUtils.isNotEmpty(flag)) {
-				Element element = cache.get(flag);
-				if ((null != element) && (null != element.getObjectValue())) {
-					CacheResultObject ro = (CacheResultObject) element.getObjectValue();
+			if (StringUtils.isNotEmpty(flag)) {
+				CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+				CacheKey cacheKey = new CacheKey(flag);
+				Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+				if (optional.isPresent()) {
+					CacheResultObject ro = (CacheResultObject) optional.get();
 					map.put(ro.getName(), ro.getBytes());
 				}
 			}
 
-			logger.info("batchDown to {},att size {}, from work {}, has form {}",fileName, attachmentList.size(), workId, map.size());
+			logger.info("batchDown to {},att size {}, from work {}, has form {}", fileName, attachmentList.size(),
+					workId, map.size());
 			try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
 				business.downToZip(readableAttachmentList, os, map);
 				byte[] bs = os.toByteArray();
-				Wo wo = new Wo(bs, this.contentType(true, fileName),
-						this.contentDisposition(true, fileName));
+				Wo wo = new Wo(bs, this.contentType(true, fileName), this.contentDisposition(true, fileName));
 				result.setData(wo);
 			}
 
@@ -106,7 +119,4 @@ class ActionBatchDownloadWithWorkOrWorkCompletedStream extends BaseAction {
 
 	}
 
-	public static class WoControl extends WorkCompletedControl {
-	}
-
 }

+ 10 - 5
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java

@@ -1,13 +1,17 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.util.Optional;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import net.sf.ehcache.Element;
 
 class ActionDownloadTransfer extends BaseAction {
 
@@ -17,13 +21,14 @@ class ActionDownloadTransfer extends BaseAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			Element element = cache.get(flag);
-			if ((null != element) && (null != element.getObjectValue())) {
-				CacheResultObject ro = (CacheResultObject) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				CacheResultObject ro = (CacheResultObject) optional.get();
 				wo = new Wo(ro.getBytes(), this.contentType(false, ro.getName()),
 						this.contentDisposition(false, ro.getName()));
 			}
-
 			result.setData(wo);
 			return result;
 		}

+ 15 - 10
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadWorkInfo.java

@@ -1,7 +1,12 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.util.Optional;
+
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -11,7 +16,6 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import net.sf.ehcache.Element;
 
 class ActionDownloadWorkInfo extends BaseAction {
 
@@ -22,28 +26,29 @@ class ActionDownloadWorkInfo extends BaseAction {
 			ActionResult<Wo> result = new ActionResult<>();
 			Business business = new Business(emc);
 			Work work = emc.find(workId, Work.class);
-			if(work == null){
+			if (work == null) {
 				WorkCompleted workCompleted = emc.find(workId, WorkCompleted.class);
 				if (null == workCompleted) {
-					throw new Exception("workId: "+workId+" not exist in work or workCompleted");
+					throw new Exception("workId: " + workId + " not exist in work or workCompleted");
 				}
-				if(!business.readable(effectivePerson, workCompleted)){
+				if (!business.readable(effectivePerson, workCompleted)) {
 					throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(),
 							workCompleted.getTitle(), workCompleted.getId());
 				}
-			}else{
-				if(!business.readable(effectivePerson, work)){
+			} else {
+				if (!business.readable(effectivePerson, work)) {
 					throw new ExceptionAccessDenied(effectivePerson, work);
 				}
 			}
 			Wo wo = null;
-			Element element = cache.get(flag);
-			if ((null != element) && (null != element.getObjectValue())) {
-				CacheResultObject ro = (CacheResultObject) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+			CacheKey cacheKey = new CacheKey(flag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				CacheResultObject ro = (CacheResultObject) optional.get();
 				wo = new Wo(ro.getBytes(), this.contentType(false, ro.getName()),
 						this.contentDisposition(false, ro.getName()));
 			}
-
 			result.setData(wo);
 			return result;
 		}

+ 26 - 21
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java

@@ -1,5 +1,9 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.io.ByteArrayOutputStream;
+
+import org.apache.commons.lang3.StringUtils;
+
 import com.google.gson.JsonElement;
 import com.itextpdf.html2pdf.ConverterProperties;
 import com.itextpdf.html2pdf.HtmlConverter;
@@ -10,7 +14,9 @@ import com.itextpdf.kernel.pdf.PdfWriter;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
@@ -19,11 +25,7 @@ import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DateTools;
-import net.sf.ehcache.Element;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.*;
-import java.util.UUID;
+import com.x.base.core.project.tools.StringTools;
 
 class ActionHtmlToPdf extends BaseAction {
 
@@ -45,32 +47,32 @@ class ActionHtmlToPdf extends BaseAction {
 
 	}
 
-	private String savePdf(Wi wi, String person){
+	private String savePdf(Wi wi, String person) {
 		try {
 			CacheResultObject ro = new CacheResultObject();
 			ro.setPerson(person);
 
 			String workHtml = wi.getWorkHtml();
-			if(StringUtils.isEmpty(workHtml)){
+			if (StringUtils.isEmpty(workHtml)) {
 				workHtml = "无内容";
 			}
-			if(workHtml.toLowerCase().indexOf("<html") == -1){
+			if (workHtml.toLowerCase().indexOf("<html") == -1) {
 				workHtml = "<html><head></head><body>" + workHtml + "</body></html>";
 			}
-			String title = person + DateTools.now()+".pdf";
-			if(StringUtils.isNotEmpty(wi.getTitle())){
-				title = wi.getTitle()+".pdf";
+			String title = person + DateTools.now() + ".pdf";
+			if (StringUtils.isNotEmpty(wi.getTitle())) {
+				title = wi.getTitle() + ".pdf";
 			}
 			try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 				ConverterProperties props = new ConverterProperties();
 				DefaultFontProvider dfp = new DefaultFontProvider(false, false, false);
-				//dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
-				dfp.addDirectory(Config.base()+"/commons/fonts");
+				// dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
+				dfp.addDirectory(Config.base() + "/commons/fonts");
 				props.setFontProvider(dfp);
 				PdfWriter writer = new PdfWriter(out);
 				PdfDocument pdf = new PdfDocument(writer);
 				float width = PageSize.A4.getWidth();
-				if(wi.getPageWidth()!=null && wi.getPageWidth()>100){
+				if (wi.getPageWidth() != null && wi.getPageWidth() > 100) {
 					width = wi.getPageWidth().floatValue();
 				}
 				pdf.setDefaultPageSize(new PageSize(width, PageSize.A4.getHeight()));
@@ -78,12 +80,13 @@ class ActionHtmlToPdf extends BaseAction {
 				ro.setBytes(out.toByteArray());
 				ro.setName(title + ".pdf");
 			}
-
-			String cacheKey = ApplicationCache.concreteCacheKey(UUID.randomUUID().toString());
-			cache.put(new Element(cacheKey,ro));
-			return cacheKey;
+			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+			String key = StringTools.uniqueToken();
+			CacheKey cacheKey = new CacheKey();
+			CacheManager.put(cacheCategory, cacheKey, ro);
+			return key;
 		} catch (Exception e) {
-			logger.warn("写work信息异常"+e.getMessage());
+			logger.warn("写work信息异常" + e.getMessage());
 		}
 		return "";
 	}
@@ -99,7 +102,9 @@ class ActionHtmlToPdf extends BaseAction {
 		@FieldDescribe("pdf标题")
 		private String title;
 
-		public String getWorkHtml() { return workHtml; }
+		public String getWorkHtml() {
+			return workHtml;
+		}
 
 		public void setWorkHtml(String workHtml) {
 			this.workHtml = workHtml;

+ 8 - 7
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImage.java

@@ -5,6 +5,9 @@ import org.apache.commons.io.FilenameUtils;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.ActionLogger;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -15,12 +18,8 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DocumentTools;
 import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.assemble.surface.WorkCompletedControl;
-import com.x.processplatform.assemble.surface.WorkControl;
 import com.x.processplatform.core.entity.content.Attachment;
 
-import net.sf.ehcache.Element;
-
 class ActionPreviewImage extends BaseAction {
 
 	@ActionLogger
@@ -47,10 +46,12 @@ class ActionPreviewImage extends BaseAction {
 		obj.setBytes(bytes);
 		obj.setName(FilenameUtils.getBaseName(attachment.getName()) + ".png");
 
-		String cacheKey = StringTools.uniqueToken();
-		cachePreviewImage.put(new Element(cacheKey, obj));
+		String key = StringTools.uniqueToken();
+		CacheCategory cacheCategory = new CacheCategory(PreviewImageResultObject.class);
+		CacheKey cacheKey = new CacheKey(key);
+		CacheManager.put(cacheCategory, cacheKey, obj);
 		Wo wo = new Wo();
-		wo.setId(cacheKey);
+		wo.setId(key);
 		result.setData(wo);
 		return result;
 	}

+ 10 - 7
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewImageResult.java

@@ -1,9 +1,12 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.util.Optional;
+
 import org.apache.commons.lang3.StringUtils;
 
-import com.x.base.core.container.EntityManagerContainer;
-import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -11,18 +14,18 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 
-import net.sf.ehcache.Element;
-
 class ActionPreviewImageResult extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionPreviewImageResult.class);
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
-		Element element = cachePreviewImage.get(flag);
 		ActionResult<Wo> result = new ActionResult<>();
+		CacheCategory cacheCategory = new CacheCategory(PreviewImageResultObject.class);
+		CacheKey cacheKey = new CacheKey(flag);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		Wo wo = null;
-		if (null != element && null != element.getObjectValue()) {
-			PreviewImageResultObject obj = (PreviewImageResultObject) element.getObjectValue();
+		if (optional.isPresent()) {
+			PreviewImageResultObject obj = (PreviewImageResultObject) optional.get();
 			if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
 				throw new ExceptionAccessDenied(effectivePerson);
 			}

+ 8 - 13
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdf.java

@@ -4,6 +4,9 @@ import org.apache.commons.io.FilenameUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
@@ -14,12 +17,8 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DocumentTools;
 import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.assemble.surface.WorkCompletedControl;
-import com.x.processplatform.assemble.surface.WorkControl;
 import com.x.processplatform.core.entity.content.Attachment;
 
-import net.sf.ehcache.Element;
-
 class ActionPreviewPdf extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionPreviewPdf.class);
@@ -47,10 +46,12 @@ class ActionPreviewPdf extends BaseAction {
 		obj.setBytes(bytes);
 		obj.setName(FilenameUtils.getBaseName(attachment.getName()) + ".pdf");
 
-		String cacheKey = StringTools.uniqueToken();
-		cachePreviewPdf.put(new Element(cacheKey, obj));
+		String key = StringTools.uniqueToken();
+		CacheCategory cacheCategory = new CacheCategory(PreviewPdfResultObject.class);
+		CacheKey cacheKey = new CacheKey(key);
+		CacheManager.put(cacheCategory, cacheKey, obj);
 		Wo wo = new Wo();
-		wo.setId(cacheKey);
+		wo.setId(key);
 		result.setData(wo);
 		return result;
 	}
@@ -59,10 +60,4 @@ class ActionPreviewPdf extends BaseAction {
 
 	}
 
-	public static class WoWorkControl extends WorkControl {
-	}
-
-	public static class WoWorkCompletedControl extends WorkCompletedControl {
-	}
-
 }

+ 10 - 5
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionPreviewPdfResult.java

@@ -1,8 +1,13 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.util.Optional;
+
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.project.annotation.ActionLogger;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -10,19 +15,19 @@ import com.x.base.core.project.jaxrs.WoFile;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 
-import net.sf.ehcache.Element;
-
 class ActionPreviewPdfResult extends BaseAction {
 
 	@ActionLogger
 	private static Logger logger = LoggerFactory.getLogger(ActionPreviewPdfResult.class);
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
-		Element element = cachePreviewPdf.get(flag);
 		ActionResult<Wo> result = new ActionResult<>();
 		Wo wo = null;
-		if (null != element && null != element.getObjectValue()) {
-			PreviewPdfResultObject obj = (PreviewPdfResultObject) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(PreviewPdfResultObject.class);
+		CacheKey cacheKey = new CacheKey(flag);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			PreviewPdfResultObject obj = (PreviewPdfResultObject) optional.get();
 			if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
 				throw new ExceptionAccessDenied(effectivePerson);
 			}

+ 51 - 37
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java

@@ -1,5 +1,14 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
 import com.google.gson.JsonElement;
 import com.itextpdf.html2pdf.ConverterProperties;
 import com.itextpdf.html2pdf.HtmlConverter;
@@ -10,7 +19,9 @@ import com.itextpdf.kernel.pdf.PdfWriter;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.config.Config;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.gson.GsonPropertyObject;
@@ -20,47 +31,45 @@ import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DefaultCharset;
+import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import net.sf.ehcache.Element;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-
-import java.io.*;
-import java.util.UUID;
 
 class ActionUploadWorkInfo extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionEdit.class);
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String flag, JsonElement jsonElement) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId, String flag, 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);
 			Work work = emc.find(workId, Work.class);
 			String title = "";
-			if(work == null){
+			if (work == null) {
 				WorkCompleted workCompleted = emc.find(workId, WorkCompleted.class);
 				if (null == workCompleted) {
-					throw new Exception("workId: "+workId+" not exist in work or workCompleted");
+					throw new Exception("workId: " + workId + " not exist in work or workCompleted");
 				}
-				if(!business.readable(effectivePerson, workCompleted)){
+				if (!business.readable(effectivePerson, workCompleted)) {
 					throw new ExceptionWorkCompletedAccessDenied(effectivePerson.getDistinguishedName(),
 							workCompleted.getTitle(), workCompleted.getId());
 				}
 				title = workCompleted.getTitle();
-			}else{
-				if(!business.readable(effectivePerson, work)){
+			} else {
+				if (!business.readable(effectivePerson, work)) {
 					throw new ExceptionAccessDenied(effectivePerson, work);
 				}
 				title = work.getTitle();
 			}
 			String workHtml = wi.getWorkHtml();
-			if(workHtml!=null && workHtml.toLowerCase().indexOf("<html") == -1){
+			if (workHtml != null && workHtml.toLowerCase().indexOf("<html") == -1) {
 				workHtml = "<html><head></head><body>" + workHtml + "</body></html>";
 			}
-			String id = saveHtml(workId, flag, workHtml, effectivePerson.getDistinguishedName(), title, wi.getPageWidth());
+			String id = saveHtml(workId, flag, workHtml, effectivePerson.getDistinguishedName(), title,
+					wi.getPageWidth());
 			Wo wo = new Wo();
 			wo.setId(id);
 			result.setData(wo);
@@ -71,47 +80,50 @@ class ActionUploadWorkInfo extends BaseAction {
 	public static class Wo extends WoId {
 	}
 
-	private String saveHtml(String workId, String flag, String workHtml, String person, String title, Float pageWidth){
+	private String saveHtml(String workId, String flag, String workHtml, String person, String title, Float pageWidth) {
 		try {
 			CacheResultObject ro = new CacheResultObject();
 			ro.setPerson(person);
-			if("word".equals(flag)){
+			if ("word".equals(flag)) {
 				try (POIFSFileSystem fs = new POIFSFileSystem();
-					 InputStream is = new ByteArrayInputStream(workHtml.getBytes("UTF-8"));
-					 ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+						InputStream is = new ByteArrayInputStream(workHtml.getBytes("UTF-8"));
+						ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 					fs.createDocument(is, "WordDocument");
 					fs.writeFilesystem(out);
 					ro.setBytes(out.toByteArray());
 					ro.setName(title + "-处理单.doc");
 				}
-			}else if("pdf".equals(flag)){
-                try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-                    ConverterProperties props = new ConverterProperties();
+			} else if ("pdf".equals(flag)) {
+				try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+					ConverterProperties props = new ConverterProperties();
 					DefaultFontProvider dfp = new DefaultFontProvider(false, false, false);
-					//dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
-					dfp.addDirectory(Config.base()+"/commons/fonts");
+					// dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
+					dfp.addDirectory(Config.base() + "/commons/fonts");
 					props.setFontProvider(dfp);
 					PdfWriter writer = new PdfWriter(out);
 					PdfDocument pdf = new PdfDocument(writer);
 					float width = PageSize.A4.getWidth();
-					if(pageWidth!=null && pageWidth>100){
+					if (pageWidth != null && pageWidth > 100) {
 						width = pageWidth.floatValue();
 					}
 					pdf.setDefaultPageSize(new PageSize(width, PageSize.A4.getHeight()));
-                    HtmlConverter.convertToPdf(workHtml, pdf, props);
-                    ro.setBytes(out.toByteArray());
-                    ro.setName(title + "-处理单.pdf");
-                }
-            }else {
+					HtmlConverter.convertToPdf(workHtml, pdf, props);
+					ro.setBytes(out.toByteArray());
+					ro.setName(title + "-处理单.pdf");
+				}
+			} else {
 				ro.setBytes(workHtml.getBytes(DefaultCharset.charset));
 				ro.setName(title + "-处理单.html");
 			}
-
-			String cacheKey = ApplicationCache.concreteCacheKey(workId, UUID.randomUUID().toString());
-			cache.put(new Element(cacheKey,ro));
-			return cacheKey;
+			CacheCategory cacheCategory = new CacheCategory(CacheResultObject.class);
+			String key = StringTools.uniqueToken();
+			CacheKey cacheKey = new CacheKey(key);
+			// String cacheKey = ApplicationCache.concreteCacheKey(workId,
+			// UUID.randomUUID().toString());
+			CacheManager.put(cacheCategory, cacheKey, ro);
+			return key;
 		} catch (Exception e) {
-			logger.warn("写work信息异常"+e.getMessage());
+			logger.warn("写work信息异常" + e.getMessage());
 		}
 		return "";
 	}
@@ -124,7 +136,9 @@ class ActionUploadWorkInfo extends BaseAction {
 		@FieldDescribe("转pdf页面宽度,默认A4.")
 		private Float pageWidth;
 
-		public String getWorkHtml() { return workHtml; }
+		public String getWorkHtml() {
+			return workHtml;
+		}
 
 		public void setWorkHtml(String workHtml) {
 			this.workHtml = workHtml;
@@ -142,8 +156,8 @@ class ActionUploadWorkInfo extends BaseAction {
 	public static void main(String[] args) throws Exception {
 		System.out.println(11);
 		String fileName = "测试公司函下载哦哦哦哦哦哦哦-表单信息.html";
-		File file = new File("/Users/chengjian/Downloads/",fileName);
-		File outfile = new File(file.getAbsolutePath()+"3.pdf");
+		File file = new File("/Users/chengjian/Downloads/", fileName);
+		File outfile = new File(file.getAbsolutePath() + "3.pdf");
 		FileInputStream in = new FileInputStream(file);
 		FileOutputStream out = new FileOutputStream(outfile);
 		PdfWriter writer = new PdfWriter(out);

+ 37 - 33
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java

@@ -1,28 +1,26 @@
 package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
-import com.x.base.core.project.cache.ApplicationCache;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.apache.commons.collections4.ListUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-
 import com.x.base.core.project.tools.ListTools;
 import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Attachment;
 import com.x.processplatform.core.entity.content.Attachment_;
-import com.x.processplatform.core.entity.content.Work;
-import net.sf.ehcache.Ehcache;
-import org.apache.commons.collections4.ListUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.List;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
@@ -49,7 +47,8 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
-	public static Ehcache cache = ApplicationCache.instance().getCache(CacheResultObject.class);
+	// public static Ehcache cache =
+	// ApplicationCache.instance().getCache(CacheResultObject.class);
 
 	public static class CacheResultObject extends GsonPropertyObject {
 
@@ -83,7 +82,8 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
-	public static Ehcache cachePreviewPdf = ApplicationCache.instance().getCache(PreviewPdfResultObject.class);
+	// public static Ehcache cachePreviewPdf =
+	// ApplicationCache.instance().getCache(PreviewPdfResultObject.class);
 
 	public static class PreviewPdfResultObject extends GsonPropertyObject {
 
@@ -117,7 +117,8 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
-	public static Ehcache cachePreviewImage = ApplicationCache.instance().getCache(PreviewImageResultObject.class);
+	// public static Ehcache cachePreviewImage =
+	// ApplicationCache.instance().getCache(PreviewImageResultObject.class);
 
 	public static class PreviewImageResultObject extends GsonPropertyObject {
 
@@ -172,14 +173,15 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return list.get(0);
 	}
 
-	public boolean read(Attachment attachment, EffectivePerson effectivePerson, List<String> identities, List<String> units)
-			throws Exception {
+	public boolean read(Attachment attachment, EffectivePerson effectivePerson, List<String> identities,
+			List<String> units) throws Exception {
 		boolean value = false;
-		if(effectivePerson.isManager()) {
+		if (effectivePerson.isManager()) {
 			value = true;
-		}else if (effectivePerson.isPerson(attachment.getPerson())) {
+		} else if (effectivePerson.isPerson(attachment.getPerson())) {
 			value = true;
-		} else if (ListTools.isEmpty(attachment.getReadIdentityList()) && ListTools.isEmpty(attachment.getReadUnitList())) {
+		} else if (ListTools.isEmpty(attachment.getReadIdentityList())
+				&& ListTools.isEmpty(attachment.getReadUnitList())) {
 			value = true;
 		} else {
 			if (ListTools.containsAny(identities, attachment.getReadIdentityList())
@@ -190,14 +192,15 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return value;
 	}
 
-	public boolean edit(Attachment attachment, EffectivePerson effectivePerson, List<String> identities, List<String> units)
-			throws Exception {
+	public boolean edit(Attachment attachment, EffectivePerson effectivePerson, List<String> identities,
+			List<String> units) throws Exception {
 		boolean value = false;
-		if(effectivePerson.isManager()) {
+		if (effectivePerson.isManager()) {
 			value = true;
-		}else if (effectivePerson.isPerson(attachment.getPerson())) {
+		} else if (effectivePerson.isPerson(attachment.getPerson())) {
 			value = true;
-		} else if (ListTools.isEmpty(attachment.getEditIdentityList()) && ListTools.isEmpty(attachment.getEditUnitList())) {
+		} else if (ListTools.isEmpty(attachment.getEditIdentityList())
+				&& ListTools.isEmpty(attachment.getEditUnitList())) {
 			value = true;
 		} else {
 			if (ListTools.containsAny(identities, attachment.getEditIdentityList())
@@ -208,14 +211,15 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return value;
 	}
 
-	public boolean control(Attachment attachment, EffectivePerson effectivePerson, List<String> identities, List<String> units)
-			throws Exception {
+	public boolean control(Attachment attachment, EffectivePerson effectivePerson, List<String> identities,
+			List<String> units) throws Exception {
 		boolean value = false;
-		if(effectivePerson.isManager()) {
+		if (effectivePerson.isManager()) {
 			value = true;
-		}else if (effectivePerson.isPerson(attachment.getPerson())) {
+		} else if (effectivePerson.isPerson(attachment.getPerson())) {
 			value = true;
-		} else if (ListTools.isEmpty(attachment.getControllerUnitList()) && ListTools.isEmpty(attachment.getControllerIdentityList())) {
+		} else if (ListTools.isEmpty(attachment.getControllerUnitList())
+				&& ListTools.isEmpty(attachment.getControllerIdentityList())) {
 			value = true;
 		} else {
 			if (ListTools.containsAny(identities, attachment.getControllerIdentityList())

+ 10 - 11
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/file/ActionContent.java

@@ -1,6 +1,7 @@
 package com.x.processplatform.assemble.surface.jaxrs.file;
 
 import java.util.List;
+import java.util.Optional;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -13,7 +14,9 @@ import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -24,21 +27,17 @@ import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.File;
 import com.x.processplatform.core.entity.element.File_;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionContent extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
-
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, applicationFlag);
-			Element element = cache.get(cacheKey);
-			if (null != element && (null != element.getObjectValue())) {
-				wo = ((Wo) element.getObjectValue());
+			CacheCategory cacheCategory = new CacheCategory(File.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), flag, applicationFlag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				Business business = new Business(emc);
 				Application application = business.application().pick(applicationFlag);
@@ -56,7 +55,7 @@ class ActionContent extends StandardJaxrsAction {
 				}
 				wo = new Wo(bs, this.contentType(false, file.getFileName()),
 						this.contentDisposition(false, file.getFileName()));
-				cache.put(new Element(cacheKey, wo));
+				CacheManager.put(cacheCategory, cacheKey, wo);
 			}
 			result.setData(wo);
 			return result;

+ 11 - 10
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/file/ActionDownload.java

@@ -1,6 +1,7 @@
 package com.x.processplatform.assemble.surface.jaxrs.file;
 
 import java.util.List;
+import java.util.Optional;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -13,7 +14,9 @@ import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -24,21 +27,19 @@ import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.File;
 import com.x.processplatform.core.entity.element.File_;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 class ActionDownload extends StandardJaxrsAction {
 
-	private Ehcache cache = ApplicationCache.instance().getCache(File.class);
+	// private Ehcache cache = ApplicationCache.instance().getCache(File.class);
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, String applicationFlag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			ActionResult<Wo> result = new ActionResult<>();
 			Wo wo = null;
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, applicationFlag);
-			Element element = cache.get(cacheKey);
-			if (null != element && (null != element.getObjectValue())) {
-				wo = ((Wo) element.getObjectValue());
+			CacheCategory cacheCategory = new CacheCategory(File.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), flag, applicationFlag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				Business business = new Business(emc);
 				Application application = business.application().pick(applicationFlag);
@@ -56,7 +57,7 @@ class ActionDownload extends StandardJaxrsAction {
 				}
 				wo = new Wo(bs, this.contentType(true, file.getFileName()),
 						this.contentDisposition(true, file.getFileName()));
-				cache.put(new Element(cacheKey, wo));
+				CacheManager.put(cacheCategory, cacheKey, wo);
 			}
 			result.setData(wo);
 			return result;

+ 2 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/process/ActionGetWithProcessWithApplication.java

@@ -24,11 +24,11 @@ public class ActionGetWithProcessWithApplication extends BaseAction {
 			if (null == application) {
 				throw new ExceptionEntityNotExist(applicationFlag, Application.class);
 			}
-			Process process = business.process().pickObject(application, flag);
+			Process process = business.process().pick(application, flag);
 			if (null == process) {
 				throw new ExceptionEntityNotExist(flag, Process.class);
 			}
-			if(StringUtils.isNotEmpty(process.getEdition()) && BooleanUtils.isFalse(process.getEditionEnable())){
+			if (StringUtils.isNotEmpty(process.getEdition()) && BooleanUtils.isFalse(process.getEditionEnable())) {
 				process = business.process().pickEnabled(process.getApplication(), process.getEdition());
 			}
 			Wo wo = Wo.copier.copy(process);

+ 16 - 12
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/script/ActionGetImported.java

@@ -2,13 +2,16 @@ package com.x.processplatform.assemble.surface.jaxrs.script;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -18,8 +21,6 @@ import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Script;
 
-import net.sf.ehcache.Element;
-
 class ActionGetImported extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionGetImported.class);
@@ -28,10 +29,11 @@ class ActionGetImported extends BaseAction {
 		ActionResult<Wo> result = new ActionResult<>();
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			Wo wo = new Wo();
-			String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, applicationFlag);
-			Element element = CACHE.get(cacheKey);
-			if (null != element && null != element.getObjectValue()) {
-				wo = (Wo) element.getObjectValue();
+			CacheCategory cacheCategory = new CacheCategory(Script.class);
+			CacheKey cacheKey = new CacheKey(this.getClass(), flag, applicationFlag);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				wo = (Wo) optional.get();
 			} else {
 				Business business = new Business(emc);
 				Application application = business.application().pick(applicationFlag);
@@ -42,11 +44,11 @@ class ActionGetImported extends BaseAction {
 				for (Script o : business.script().listScriptNestedWithApplicationWithUniqueName(application, flag)) {
 					list.add(o);
 				}
-				StringBuffer buffer = new StringBuffer("");
+				StringBuilder sb = new StringBuilder("");
 				List<String> imported = new ArrayList<>();
 				for (Script o : list) {
-					buffer.append(o.getText());
-					buffer.append(System.lineSeparator());
+					sb.append(o.getText());
+					sb.append(System.lineSeparator());
 					imported.add(o.getId());
 					if (StringUtils.isNotEmpty(o.getName())) {
 						imported.add(o.getName());
@@ -56,8 +58,8 @@ class ActionGetImported extends BaseAction {
 					}
 				}
 				wo.setImportedList(imported);
-				wo.setText(buffer.toString());
-				CACHE.put(new Element(cacheKey, wo));
+				wo.setText(sb.toString());
+				CacheManager.put(cacheCategory, cacheKey, wo);
 			}
 			result.setData(wo);
 			return result;
@@ -66,6 +68,8 @@ class ActionGetImported extends BaseAction {
 
 	public class Wo extends GsonPropertyObject {
 
+		private static final long serialVersionUID = -7633183122160854183L;
+
 		@FieldDescribe("脚本内容")
 		private String text;
 

+ 1 - 5
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/script/BaseAction.java

@@ -1,13 +1,9 @@
 package com.x.processplatform.assemble.surface.jaxrs.script;
 
-import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
-import com.x.processplatform.core.entity.element.Script;
-
-import net.sf.ehcache.Ehcache;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
-	protected Ehcache CACHE = ApplicationCache.instance().getCache(Script.class);
+//	protected Ehcache CACHE = ApplicationCache.instance().getCache(Script.class);
 
 }

+ 87 - 120
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/factory/ElementFactory.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import javax.persistence.EntityManager;
@@ -17,7 +18,9 @@ import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.entity.JpaObject;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.Cache.CacheCategory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.script.ScriptFactory;
@@ -25,9 +28,7 @@ import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.entity.element.ActivityType;
 import com.x.processplatform.core.entity.element.Agent;
-import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Begin;
-import com.x.processplatform.core.entity.element.Begin_;
 import com.x.processplatform.core.entity.element.Cancel;
 import com.x.processplatform.core.entity.element.Choice;
 import com.x.processplatform.core.entity.element.Delay;
@@ -50,9 +51,6 @@ import com.x.processplatform.core.entity.element.Split;
 import com.x.processplatform.service.processing.AbstractFactory;
 import com.x.processplatform.service.processing.Business;
 
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
 public class ElementFactory extends AbstractFactory {
 
 	private static Logger logger = LoggerFactory.getLogger(ElementFactory.class);
@@ -61,50 +59,40 @@ public class ElementFactory extends AbstractFactory {
 		super(business);
 	}
 
-	/* 取得属于指定Process 的设计元素 */
+	// 取得属于指定Process 的设计元素
 	@SuppressWarnings("unchecked")
 	public <T extends JpaObject> List<T> listWithProcess(Class<T> clz, Process process) throws Exception {
 		List<T> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(clz);
-		String cacheKey = ApplicationCache.concreteCacheKey("listWithProcess", process.getId(), clz.getName());
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			Object obj = element.getObjectValue();
-			if (null != obj) {
-				list = (List<T>) obj;
-			}
+		CacheCategory cacheCategory = new CacheCategory(clz);
+		CacheKey cacheKey = new CacheKey("listWithProcess", process.getId());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<T>) optional.get();
 		} else {
 			EntityManager em = this.entityManagerContainer().get(clz);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<T> cq = cb.createQuery(clz);
-			Root<T> root = cq.from(clz);
-			Predicate p = cb.equal(root.get(Agent.process_FIELDNAME), process.getId());
-			cq.select(root).where(p);
-			List<T> os = em.createQuery(cq).getResultList();
+			List<T> os = this.entityManagerContainer().listEqual(clz, Activity.process_FIELDNAME, process.getId());
 			for (T t : os) {
 				em.detach(t);
 				list.add(t);
 			}
-			/* 将object改为unmodifiable */
+			// 将object改为unmodifiable
 			list = Collections.unmodifiableList(list);
-			cache.put(new Element(cacheKey, list));
+			CacheManager.put(cacheCategory, cacheKey, list);
 		}
 		return list;
 	}
 
 	@SuppressWarnings("unchecked")
 	public <T extends JpaObject> T get(String id, Class<T> clz) throws Exception {
-		Ehcache cache = ApplicationCache.instance().getCache(clz);
+		CacheCategory cacheCategory = new CacheCategory(clz);
+		CacheKey cacheKey = new CacheKey(id);
 		T t = null;
-		String cacheKey = id;
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			t = (T) element.getObjectValue();
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			t = (T) optional.get();
 		} else {
 			t = this.entityManagerContainer().find(id, clz);
-			if (null != t) {
-				cache.put(new Element(cacheKey, t));
-			}
+			CacheManager.put(cacheCategory, cacheKey, t);
 		}
 		return t;
 	}
@@ -189,28 +177,17 @@ public class ElementFactory extends AbstractFactory {
 		}
 	}
 
-	/* 用Process的updateTime作为缓存值 */
+	// 用Process的updateTime作为缓存值
 	public Begin getBeginWithProcess(String id) throws Exception {
 		Begin begin = null;
-		Ehcache cache = ApplicationCache.instance().getCache(Begin.class);
-		String cacheKey = id;
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			begin = (Begin) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(Begin.class);
+		CacheKey cacheKey = new CacheKey("getBeginWithProcess", id);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			begin = (Begin) optional.get();
 		} else {
-			EntityManager em = this.entityManagerContainer().get(Begin.class);
-			Process process = this.get(id, Process.class);
-			if (null != process) {
-				CriteriaBuilder cb = em.getCriteriaBuilder();
-				CriteriaQuery<Begin> cq = cb.createQuery(Begin.class);
-				Root<Begin> root = cq.from(Begin.class);
-				Predicate p = cb.equal(root.get(Begin_.process), process.getId());
-				List<Begin> list = em.createQuery(cq.where(p)).setMaxResults(1).getResultList();
-				if (!list.isEmpty()) {
-					begin = list.get(0);
-					cache.put(new Element(cacheKey, begin));
-				}
-			}
+			begin = this.entityManagerContainer().firstEqual(Begin.class, Activity.process_FIELDNAME, id);
+			CacheManager.put(cacheCategory, cacheKey, begin);
 		}
 		return begin;
 	}
@@ -218,11 +195,11 @@ public class ElementFactory extends AbstractFactory {
 	@SuppressWarnings("unchecked")
 	public List<Route> listRouteWithChoice(String id) throws Exception {
 		List<Route> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Route.class);
-		String cacheKey = ApplicationCache.concreteCacheKey(id, Choice.class.getCanonicalName());
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			list = (List<Route>) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(Route.class);
+		CacheKey cacheKey = new CacheKey(id, Choice.class.getName());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<Route>) optional.get();
 		} else {
 			EntityManager em = this.entityManagerContainer().get(Route.class);
 			Choice choice = this.get(id, Choice.class);
@@ -232,9 +209,7 @@ public class ElementFactory extends AbstractFactory {
 				Root<Route> root = cq.from(Route.class);
 				Predicate p = root.get(Route_.id).in(choice.getRouteList());
 				list = em.createQuery(cq.where(p).orderBy(cb.asc(root.get(Route_.orderNumber)))).getResultList();
-				if (!list.isEmpty()) {
-					cache.put(new Element(cacheKey, list));
-				}
+				CacheManager.put(cacheCategory, cacheKey, list);
 			}
 		}
 		return list;
@@ -243,11 +218,11 @@ public class ElementFactory extends AbstractFactory {
 	@SuppressWarnings("unchecked")
 	public List<Route> listRouteWithManual(String id) throws Exception {
 		List<Route> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Manual.class);
-		String cacheKey = ApplicationCache.concreteCacheKey(id, Manual.class.getCanonicalName());
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			list = (List<Route>) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(Route.class);
+		CacheKey cacheKey = new CacheKey(id, Manual.class.getName());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<Route>) optional.get();
 		} else {
 			EntityManager em = this.entityManagerContainer().get(Route.class);
 			Manual manual = this.get(id, Manual.class);
@@ -257,9 +232,7 @@ public class ElementFactory extends AbstractFactory {
 				Root<Route> root = cq.from(Route.class);
 				Predicate p = root.get(Route_.id).in(manual.getRouteList());
 				list = em.createQuery(cq.where(p).orderBy(cb.asc(root.get(Route_.orderNumber)))).getResultList();
-				if (!list.isEmpty()) {
-					cache.put(new Element(cacheKey, list));
-				}
+				CacheManager.put(cacheCategory, cacheKey, list);
 			}
 		}
 		return list;
@@ -268,11 +241,11 @@ public class ElementFactory extends AbstractFactory {
 	@SuppressWarnings("unchecked")
 	public List<Route> listRouteWithParallel(String id) throws Exception {
 		List<Route> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Parallel.class);
-		String cacheKey = ApplicationCache.concreteCacheKey(id, Parallel.class.getCanonicalName());
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			list = (List<Route>) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(Route.class);
+		CacheKey cacheKey = new CacheKey(id, Parallel.class.getName());
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<Route>) optional.get();
 		} else {
 			EntityManager em = this.entityManagerContainer().get(Route.class);
 			Parallel parallel = this.get(id, Parallel.class);
@@ -282,9 +255,7 @@ public class ElementFactory extends AbstractFactory {
 				Root<Route> root = cq.from(Route.class);
 				Predicate p = root.get(Route_.id).in(parallel.getRouteList());
 				list = em.createQuery(cq.where(p).orderBy(cb.asc(root.get(Route_.orderNumber)))).getResultList();
-				if (!list.isEmpty()) {
-					cache.put(new Element(cacheKey, list));
-				}
+				CacheManager.put(cacheCategory, cacheKey, list);
 			}
 		}
 		return list;
@@ -294,11 +265,11 @@ public class ElementFactory extends AbstractFactory {
 	public List<Script> listScriptNestedWithApplicationWithUniqueName(String applicationId, String uniqueName)
 			throws Exception {
 		List<Script> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Script.class);
-		String cacheKey = applicationId + "." + uniqueName;
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			list = (List<Script>) element.getObjectValue();
+		CacheCategory cacheCategory = new CacheCategory(Script.class);
+		CacheKey cacheKey = new CacheKey("listScriptNestedWithApplicationWithUniqueName", applicationId, uniqueName);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list = (List<Script>) optional.get();
 		} else {
 			List<String> names = new ArrayList<>();
 			names.add(uniqueName);
@@ -313,10 +284,8 @@ public class ElementFactory extends AbstractFactory {
 				}
 				names = loops;
 			}
-			if (!list.isEmpty()) {
-				Collections.reverse(list);
-				cache.put(new Element(cacheKey, list));
-			}
+			Collections.reverse(list);
+			CacheManager.put(cacheCategory, cacheKey, list);
 		}
 		return list;
 	}
@@ -452,15 +421,15 @@ public class ElementFactory extends AbstractFactory {
 		return ListTools.trim(ids, true, true);
 	}
 
+	@SuppressWarnings("unchecked")
 	public List<Mapping> listMappingEffectiveWithApplicationAndProcess(String application, String process)
 			throws Exception {
 		final List<Mapping> list = new ArrayList<>();
-		Ehcache cache = ApplicationCache.instance().getCache(Mapping.class);
-		String cacheKey = ApplicationCache.concreteCacheKey(application, process, Application.class.getName(),
-				Process.class.getName());
-		Element element = cache.get(cacheKey);
-		if (null != element) {
-			list.addAll((List<Mapping>) element.getObjectValue());
+		CacheCategory cacheCategory = new CacheCategory(Mapping.class);
+		CacheKey cacheKey = new CacheKey("listMappingEffectiveWithApplicationAndProcess", application, process);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			list.addAll((List<Mapping>) optional.get());
 		} else {
 			EntityManager em = this.entityManagerContainer().get(Mapping.class);
 			CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -476,20 +445,18 @@ public class ElementFactory extends AbstractFactory {
 			})).forEach((k, v) -> {
 				list.add(v.stream().filter(i -> StringUtils.isNotEmpty(i.getProcess())).findFirst().orElse(v.get(0)));
 			});
-			if (!list.isEmpty()) {
-				cache.put(new Element(cacheKey, list));
-			}
+			CacheManager.put(cacheCategory, cacheKey, list);
 		}
 		return list;
 	}
 
 	public CompiledScript getCompiledScript(String applicationId, Activity o, String event) throws Exception {
-		String cacheKey = ApplicationCache.concreteCacheKey(o.getId(), event);
-		Ehcache cache = ApplicationCache.instance().getCache(o.getClass());
-		Element element = cache.get(cacheKey);
+		CacheCategory cacheCategory = new CacheCategory(o.getClass());
+		CacheKey cacheKey = new CacheKey("getCompiledScript", applicationId, o.getId(), event);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		CompiledScript compiledScript = null;
-		if (null != element && null != element.getObjectValue()) {
-			compiledScript = (CompiledScript) element.getObjectValue();
+		if (optional.isPresent()) {
+			compiledScript = (CompiledScript) optional.get();
 		} else {
 			String scriptName = null;
 			String scriptText = null;
@@ -606,7 +573,7 @@ public class ElementFactory extends AbstractFactory {
 			default:
 				break;
 			}
-			StringBuffer sb = new StringBuffer();
+			StringBuilder sb = new StringBuilder();
 			try {
 				sb.append("(function(){").append(System.lineSeparator());
 				if (StringUtils.isNotEmpty(scriptName)) {
@@ -620,7 +587,7 @@ public class ElementFactory extends AbstractFactory {
 				}
 				sb.append("}).apply(bind);");
 				compiledScript = ScriptFactory.compile(sb.toString());
-				cache.put(new Element(cacheKey, compiledScript));
+				CacheManager.put(cacheCategory, cacheKey, compiledScript);
 			} catch (Exception e) {
 				logger.error(e);
 			}
@@ -629,12 +596,12 @@ public class ElementFactory extends AbstractFactory {
 	}
 
 	public CompiledScript getCompiledScript(String applicationId, Route o, String event) throws Exception {
-		String cacheKey = ApplicationCache.concreteCacheKey(o.getId(), event);
-		Ehcache cache = ApplicationCache.instance().getCache(Route.class);
-		Element element = cache.get(cacheKey);
+		CacheCategory cacheCategory = new CacheCategory(Route.class);
+		CacheKey cacheKey = new CacheKey("getCompiledScript", applicationId, o.getId(), event);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		CompiledScript compiledScript = null;
-		if (null != element && null != element.getObjectValue()) {
-			compiledScript = (CompiledScript) element.getObjectValue();
+		if (optional.isPresent()) {
+			compiledScript = (CompiledScript) optional.get();
 		} else {
 			String scriptName = null;
 			String scriptText = null;
@@ -651,7 +618,7 @@ public class ElementFactory extends AbstractFactory {
 			default:
 				break;
 			}
-			StringBuffer sb = new StringBuffer();
+			StringBuilder sb = new StringBuilder();
 			try {
 				sb.append("(function(){").append(System.lineSeparator());
 				if (StringUtils.isNotEmpty(scriptName)) {
@@ -665,7 +632,7 @@ public class ElementFactory extends AbstractFactory {
 				}
 				sb.append("}).apply(bind);");
 				compiledScript = ScriptFactory.compile(sb.toString());
-				cache.put(new Element(cacheKey, compiledScript));
+				CacheManager.put(cacheCategory, cacheKey, compiledScript);
 			} catch (Exception e) {
 				logger.error(e);
 			}
@@ -674,12 +641,12 @@ public class ElementFactory extends AbstractFactory {
 	}
 
 	public CompiledScript getCompiledScript(String applicationId, Process o, String event) throws Exception {
-		String cacheKey = ApplicationCache.concreteCacheKey(o.getId(), event);
-		Ehcache cache = ApplicationCache.instance().getCache(Process.class);
-		Element element = cache.get(cacheKey);
+		CacheCategory cacheCategory = new CacheCategory(Process.class);
+		CacheKey cacheKey = new CacheKey("getCompiledScript", applicationId, o.getId(), event);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		CompiledScript compiledScript = null;
-		if (null != element && null != element.getObjectValue()) {
-			compiledScript = (CompiledScript) element.getObjectValue();
+		if (optional.isPresent()) {
+			compiledScript = (CompiledScript) optional.get();
 		} else {
 			String scriptName = null;
 			String scriptText = null;
@@ -723,7 +690,7 @@ public class ElementFactory extends AbstractFactory {
 			default:
 				break;
 			}
-			StringBuffer sb = new StringBuffer();
+			StringBuilder sb = new StringBuilder();
 			try {
 				sb.append("(function(){").append(System.lineSeparator());
 				if (StringUtils.isNotEmpty(scriptName)) {
@@ -737,7 +704,7 @@ public class ElementFactory extends AbstractFactory {
 				}
 				sb.append("}).apply(bind);");
 				compiledScript = ScriptFactory.compile(sb.toString());
-				cache.put(new Element(cacheKey, compiledScript));
+				CacheManager.put(cacheCategory, cacheKey, compiledScript);
 			} catch (Exception e) {
 				logger.error(e);
 			}
@@ -746,14 +713,14 @@ public class ElementFactory extends AbstractFactory {
 	}
 
 	public CompiledScript getCompiledScript(Activity activity, String event, String name, String code) {
-		String cacheKey = ApplicationCache.concreteCacheKey(activity.getId(), event, name, code);
-		Ehcache cache = ApplicationCache.instance().getCache(activity.getClass());
-		Element element = cache.get(cacheKey);
+		CacheCategory cacheCategory = new CacheCategory(activity.getClass());
+		CacheKey cacheKey = new CacheKey("getCompiledScript", activity.getId(), event, name, code);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
 		CompiledScript compiledScript = null;
-		if (null != element && null != element.getObjectValue()) {
-			compiledScript = (CompiledScript) element.getObjectValue();
+		if (optional.isPresent()) {
+			compiledScript = (CompiledScript) optional.get();
 		} else {
-			StringBuffer sb = new StringBuffer();
+			StringBuilder sb = new StringBuilder();
 			try {
 				sb.append("(function(){").append(System.lineSeparator());
 				if (StringUtils.isNotEmpty(code)) {
@@ -761,7 +728,7 @@ public class ElementFactory extends AbstractFactory {
 				}
 				sb.append("}).apply(bind);");
 				compiledScript = ScriptFactory.compile(sb.toString());
-				cache.put(new Element(cacheKey, compiledScript));
+				CacheManager.put(cacheCategory, cacheKey, compiledScript);
 			} catch (Exception e) {
 				logger.error(e);
 			}

+ 3 - 3
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/applicationdict/ActionUpdate.java

@@ -8,7 +8,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.annotation.FieldDescribe;
-import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.cache.CacheManager;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.executor.ProcessPlatformExecutorFactory;
 import com.x.base.core.project.http.ActionResult;
@@ -38,8 +38,8 @@ class ActionUpdate extends BaseAction {
 					emc.check(dict, CheckPersistType.all);
 					update(business, dict, wi.getData());
 					emc.commit();
-					/* 这个Action是更新ApplicationDict需要刷新缓存 */
-					ApplicationCache.notify(ApplicationDict.class);
+					// 这个Action是更新ApplicationDict需要刷新缓存
+					CacheManager.notify(ApplicationDict.class);
 					Wo wo = new Wo();
 					wo.setId(dict.getId());
 					result.setData(wo);