提交 20a422ec 编写于 作者: O o2null

Merge branch 'feature/应用缓存优化' into 'develop'

【平台】应用缓存优化

See merge request o2oa/o2oa!1451
......@@ -2,10 +2,10 @@ package com.x.organization.assemble.authentication.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
......@@ -13,24 +13,22 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.organization.assemble.authentication.AbstractFactory;
import com.x.organization.assemble.authentication.Business;
import com.x.organization.assemble.authentication.CacheFactory;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
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;
public class PersonFactory extends AbstractFactory {
private Ehcache cache;
private CacheCategory cache;
public PersonFactory(Business business) throws Exception {
super(business);
this.cache = CacheFactory.getPersonCache();
this.cache = new CacheCategory(Person.class);
}
public Person pick(String flag) throws Exception {
......@@ -38,14 +36,13 @@ public class PersonFactory extends AbstractFactory {
return null;
}
Person o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Person) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Person) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -84,14 +81,13 @@ public class PersonFactory extends AbstractFactory {
public List<Person> pick(List<String> flags) throws Exception {
List<Person> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Person) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Person) optional.get());
} else {
Person o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.authentication.jaxrs.oauth;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -17,7 +18,6 @@ import org.apache.commons.text.StringEscapeUtils;
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.config.Config;
import com.x.base.core.project.config.Token.InitialManager;
import com.x.base.core.project.config.Token.Oauth;
......@@ -30,9 +30,9 @@ import com.x.base.core.project.script.ScriptFactory;
import com.x.organization.assemble.authentication.Business;
import com.x.organization.core.entity.OauthCode;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
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;
class ActionInfo extends BaseAction {
......@@ -40,7 +40,7 @@ class ActionInfo extends BaseAction {
public static final Pattern SCRIPT_PATTERN = Pattern.compile("^\\((.+?)\\)$");
private static Ehcache cache = ApplicationCache.instance().getCache(Person.class);
private static CacheCategory cache = new CacheCategory(Person.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String accessToken) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -80,14 +80,13 @@ class ActionInfo extends BaseAction {
private CompiledScript compliedScript(String clientId, String scope, String text) throws Exception {
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), clientId, scope);
Element element = cache.get(cacheKey);
if ((null != element) && (null != element.getObjectValue())) {
return (CompiledScript) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), clientId, scope);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
return (CompiledScript) optional.get();
} else {
CompiledScript compiledScript = ScriptFactory.compile(ScriptFactory.functionalization(text));
cache.put(new Element(cacheKey, compiledScript));
CacheManager.put(cache, cacheKey, compiledScript);
return compiledScript;
}
}
......
......@@ -2,7 +2,7 @@ package com.x.organization.assemble.control;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.persistence.EntityManager;
......@@ -10,16 +10,15 @@ 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.project.cache.ApplicationCache;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
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;
public abstract class AbstractFactory {
protected Business business;
protected Ehcache cache;
protected CacheCategory cache;
public AbstractFactory(Business business) throws Exception {
try {
......@@ -41,19 +40,18 @@ public abstract class AbstractFactory {
if (StringUtils.isEmpty(flag)) {
return null;
}
Ehcache cache = ApplicationCache.instance().getCache(clz);
CacheCategory cacheCategory = new CacheCategory(clz);
T t = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
t = (T) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
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);
}
cache.put(new Element(flag, t));
CacheManager.put(cacheCategory, cacheKey, t);
}
return t;
}
......@@ -64,19 +62,28 @@ public abstract class AbstractFactory {
if (null == flags || flags.isEmpty()) {
return list;
}
Ehcache cache = ApplicationCache.instance().getCache(clz);
Map<Object, Element> map = cache.getAll(flags);
if (map.size() == flags.size()) {
map.values().stream().forEach(o -> {
list.add((T) o.getObjectValue());
});
CacheCategory cacheCategory = new CacheCategory(clz);
boolean hasCache = true;
for(String flag : flags){
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
list.add ((T) optional.get());
}else{
hasCache = false;
break;
}
}
if(hasCache){
return list;
} else {
List<T> os = this.entityManagerContainer().flag(flags, clz);
EntityManager em = this.entityManagerContainer().get(clz);
os.stream().forEach(o -> {
em.detach(o);
list.add(o);
cache.put(new Element(o.getId(), o));
CacheKey cacheKey = new CacheKey(o.getId());
CacheManager.put(cacheCategory, cacheKey, o);
});
}
return list;
......
......@@ -14,7 +14,7 @@ import javax.persistence.criteria.Root;
import com.x.base.core.container.EntityManagerContainer;
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.http.EffectivePerson;
import com.x.base.core.project.instrument.Instrument;
import com.x.base.core.project.organization.OrganizationDefinition;
......@@ -43,19 +43,17 @@ import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitDuty;
import org.apache.commons.collections4.CollectionUtils;
import net.sf.ehcache.Ehcache;
import org.apache.commons.collections4.set.ListOrderedSet;
public class Business {
private EntityManagerContainer emc;
private Ehcache cache;
private CacheCategory cacheCategory;
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
this.cache = ApplicationCache.instance().getCache(Group.class, Role.class, Person.class, PersonAttribute.class,
this.cacheCategory = new CacheCategory(Group.class, Role.class, Person.class, PersonAttribute.class,
Unit.class, UnitDuty.class, UnitAttribute.class, Identity.class);
}
......@@ -492,8 +490,8 @@ public class Business {
return set.asList();
}
public Ehcache cache() {
return cache;
public CacheCategory cache() {
return cacheCategory;
}
public List<Person> listPersonWithUnit(String unitFlag) throws Exception {
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -16,7 +17,6 @@ import com.x.base.core.project.tools.ListTools;
import org.apache.commons.collections4.set.ListOrderedSet;
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.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
......@@ -24,14 +24,15 @@ import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
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;
public class GroupFactory extends AbstractFactory {
public GroupFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(Group.class);
cache = new CacheCategory(Group.class);
}
public Group pick(String flag) throws Exception {
......@@ -40,14 +41,13 @@ public class GroupFactory extends AbstractFactory {
}
Group o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Group) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Group) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -55,14 +55,13 @@ public class GroupFactory extends AbstractFactory {
public List<Group> pick(List<String> flags) throws Exception {
List<Group> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Group) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Group) optional.get());
} else {
Group o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -15,20 +16,20 @@ import javax.persistence.criteria.Root;
import com.x.base.core.project.config.Config;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.PersistenceProperties;
import net.sf.ehcache.Element;
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;
public class IdentityFactory extends AbstractFactory {
public IdentityFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(Identity.class);
cache = new CacheCategory(Identity.class);
}
public Identity pick(String flag) throws Exception {
......@@ -36,14 +37,13 @@ public class IdentityFactory extends AbstractFactory {
return null;
}
Identity o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Identity) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Identity) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -82,14 +82,13 @@ public class IdentityFactory extends AbstractFactory {
public List<Identity> pick(List<String> flags) throws Exception {
List<Identity> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Identity) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Identity) optional.get());
} else {
Identity o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
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.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.PermissionSetting;
import com.x.organization.core.entity.PermissionSetting_;
import com.x.organization.core.entity.PersistenceProperties;
import net.sf.ehcache.Element;
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;
public class PermissionSettingFactory extends AbstractFactory {
public PermissionSettingFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(PermissionSetting.class);
cache = new CacheCategory(PermissionSetting.class);
}
public PermissionSetting pick(String flag) throws Exception {
......@@ -37,28 +34,26 @@ public class PermissionSettingFactory extends AbstractFactory {
return null;
}
PermissionSetting o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (PermissionSetting) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (PermissionSetting) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
public List<PermissionSetting> pick(List<String> flags) throws Exception {
List<PermissionSetting> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((PermissionSetting) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((PermissionSetting) optional.get());
} else {
PermissionSetting o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -14,20 +15,20 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.PersonAttribute_;
import net.sf.ehcache.Element;
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;
public class PersonAttributeFactory extends AbstractFactory {
public PersonAttributeFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(PersonAttribute.class);
cache = new CacheCategory(PersonAttribute.class);
}
public PersonAttribute pick(String flag) throws Exception {
......@@ -35,14 +36,13 @@ public class PersonAttributeFactory extends AbstractFactory {
return null;
}
PersonAttribute o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (PersonAttribute) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (PersonAttribute) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -81,14 +81,13 @@ public class PersonAttributeFactory extends AbstractFactory {
public List<PersonAttribute> pick(List<String> flags) throws Exception {
List<PersonAttribute> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((PersonAttribute) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((PersonAttribute) optional.get());
} else {
PersonAttribute o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
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.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.PersonCard;
import com.x.organization.core.entity.PersonCard_;
import net.sf.ehcache.Element;
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;
public class PersonCardFactory extends AbstractFactory {
public PersonCardFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(PersonCard.class);
cache = new CacheCategory(PersonCard.class);
}
public PersonCard pick(String flag) throws Exception {
......@@ -36,14 +33,13 @@ public class PersonCardFactory extends AbstractFactory {
return null;
}
PersonCard o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (PersonCard) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (PersonCard) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......
package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -17,7 +13,6 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.entity.tools.JpaObjectTools;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.tools.Crypto;
import com.x.organization.assemble.control.AbstractFactory;
......@@ -25,14 +20,15 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import net.sf.ehcache.Element;
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;
public class PersonFactory extends AbstractFactory {
public PersonFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(Person.class);
cache = new CacheCategory(Person.class);
}
public Person pick(String flag) throws Exception {
......@@ -40,14 +36,13 @@ public class PersonFactory extends AbstractFactory {
return null;
}
Person o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Person) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Person) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -86,14 +81,13 @@ public class PersonFactory extends AbstractFactory {
public List<Person> pick(List<String> flags) throws Exception {
List<Person> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Person) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Person) optional.get());
} else {
Person o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -14,20 +15,20 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
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;
public class RoleFactory extends AbstractFactory {
public RoleFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(Role.class);
cache = new CacheCategory(Role.class);
}
public Role pick(String flag) throws Exception {
......@@ -35,14 +36,13 @@ public class RoleFactory extends AbstractFactory {
return null;
}
Role o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Role) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Role) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -81,14 +81,13 @@ public class RoleFactory extends AbstractFactory {
public List<Role> pick(List<String> flags) throws Exception {
List<Role> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Role) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Role) optional.get());
} else {
Role o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -14,20 +15,20 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitAttribute_;
import net.sf.ehcache.Element;
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;
public class UnitAttributeFactory extends AbstractFactory {
public UnitAttributeFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(UnitAttribute.class);
cache = new CacheCategory(UnitAttribute.class);
}
public UnitAttribute pick(String flag) throws Exception {
......@@ -35,14 +36,13 @@ public class UnitAttributeFactory extends AbstractFactory {
return null;
}
UnitAttribute o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (UnitAttribute) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (UnitAttribute) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -81,14 +81,13 @@ public class UnitAttributeFactory extends AbstractFactory {
public List<UnitAttribute> pick(List<String> flags) throws Exception {
List<UnitAttribute> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((UnitAttribute) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((UnitAttribute) optional.get());
} else {
UnitAttribute o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -3,6 +3,7 @@ package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -14,20 +15,20 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
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;
public class UnitDutyFactory extends AbstractFactory {
public UnitDutyFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(UnitDuty.class);
cache = new CacheCategory(UnitDuty.class);
}
public UnitDuty pick(String flag) throws Exception {
......@@ -35,14 +36,13 @@ public class UnitDutyFactory extends AbstractFactory {
return null;
}
UnitDuty o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (UnitDuty) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (UnitDuty) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -81,14 +81,13 @@ public class UnitDutyFactory extends AbstractFactory {
public List<UnitDuty> pick(List<String> flags) throws Exception {
List<UnitDuty> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((UnitDuty) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((UnitDuty) optional.get());
} else {
UnitDuty o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
package com.x.organization.assemble.control.factory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
......@@ -17,21 +13,21 @@ import javax.persistence.criteria.Root;
import com.x.base.core.project.config.Config;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.AbstractFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersistenceProperties;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.Unit_;
import net.sf.ehcache.Element;
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;
public class UnitFactory extends AbstractFactory {
public UnitFactory(Business business) throws Exception {
super(business);
cache = ApplicationCache.instance().getCache(Unit.class);
cache = new CacheCategory(Unit.class);
}
public Unit pick(String flag) throws Exception {
......@@ -39,14 +35,13 @@ public class UnitFactory extends AbstractFactory {
return null;
}
Unit o = null;
Element element = cache.get(flag);
if (null != element) {
if (null != element.getObjectValue()) {
o = (Unit) element.getObjectValue();
}
CacheKey cacheKey = new CacheKey(flag);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
o = (Unit) optional.get();
} else {
o = this.pickObject(flag);
cache.put(new Element(flag, o));
CacheManager.put(cache, cacheKey, o);
}
return o;
}
......@@ -102,14 +97,13 @@ public class UnitFactory extends AbstractFactory {
public List<Unit> pick(List<String> flags) throws Exception {
List<Unit> list = new ArrayList<>();
for (String str : flags) {
Element element = cache.get(str);
if (null != element) {
if (null != element.getObjectValue()) {
list.add((Unit) element.getObjectValue());
}
CacheKey cacheKey = new CacheKey(str);
Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) {
list.add((Unit) optional.get());
} else {
Unit o = this.pickObject(str);
cache.put(new Element(str, o));
CacheManager.put(cache, cacheKey, o);
if (null != o) {
list.add(o);
}
......
......@@ -5,8 +5,10 @@ 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 com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import net.sf.ehcache.Element;
import java.util.Optional;
class ActionGetResult extends BaseAction {
......@@ -15,11 +17,12 @@ class ActionGetResult extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
logger.debug(effectivePerson, "flag:{}.", flag);
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()) {
throw new ExceptionResultNotFound(flag);
}
CacheFileResult o = (CacheFileResult) element.getObjectValue();
CacheFileResult o = (CacheFileResult) optional.get();
Wo wo = new Wo(o.getBytes(), this.contentType(true, o.getName()), this.contentDisposition(true, o.getName()));
result.setData(wo);
return result;
......
......@@ -30,8 +30,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionZhengwuDingdingPerson extends BaseAction {
......@@ -88,7 +88,8 @@ class ActionZhengwuDingdingPerson extends BaseAction {
cacheFileResult.setName("政务钉钉人员.xlsx");
Wo wo = new Wo();
wo.setFlag(StringTools.uniqueToken());
this.cache.put(new Element(wo.getFlag(), cacheFileResult));
CacheKey cacheKey = new CacheKey(wo.getFlag());
CacheManager.put(this.cacheCategory, cacheKey, cacheFileResult);
result.setData(wo);
return result;
}
......
package com.x.organization.assemble.control.jaxrs.export;
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 net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
protected Ehcache cache = ApplicationCache.instance().getCache(CacheFileResult.class);
protected CacheCategory cacheCategory = new CacheCategory(CacheFileResult.class);
public static class CacheFileResult {
......
package com.x.organization.assemble.control.jaxrs.function;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
......@@ -30,7 +31,7 @@ public class ActionSetPassword {
business.person().setPassword(person, wrapIn.getValue(),false);
emc.check(person, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
WrapOutId wrap = new WrapOutId(person.getId());
return wrap;
}
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.List;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.collections4.ListUtils;
import com.google.gson.JsonElement;
......@@ -11,7 +12,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -62,7 +62,7 @@ class ActionAddMember extends BaseAction {
}
emc.check(group, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Group.class);
CacheManager.notify(Group.class);
Wo wo = new Wo();
wo.setId(group.getId());
result.setData(wo);
......
package com.x.organization.assemble.control.jaxrs.group;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -20,9 +17,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Group;
......@@ -56,7 +50,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(Group.class);
emc.persist(group, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Group.class);
CacheManager.notify(Group.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -8,22 +8,16 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.google.gson.Gson;
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.x_message_assemble_communicate;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.connection.ActionResponse;
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;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
......@@ -53,7 +47,7 @@ class ActionDelete extends BaseAction {
this.removeRoleMember(business, group);
emc.remove(group, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Group.class);
CacheManager.notify(Group.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.List;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.collections4.ListUtils;
import com.google.gson.JsonElement;
......@@ -11,7 +12,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -61,7 +61,7 @@ class ActionDeleteMember extends BaseAction {
}
emc.check(group, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Group.class);
CacheManager.notify(Group.class);
Wo wo = new Wo();
wo.setId(group.getId());
result.setData(wo);
......
package com.x.organization.assemble.control.jaxrs.group;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
......@@ -8,11 +9,8 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -20,9 +18,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Group;
......@@ -65,7 +60,7 @@ class ActionEdit extends BaseAction {
JpaObject.id_FIELDNAME, String.class, true, true));
emc.check(group, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Group.class);
CacheManager.notify(Group.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
package com.x.organization.assemble.control.jaxrs.group;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Optional;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
......@@ -11,7 +10,6 @@ import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
......@@ -20,8 +18,8 @@ import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionGet extends BaseAction {
......@@ -29,13 +27,13 @@ class ActionGet extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLike extends BaseAction {
......@@ -37,14 +37,14 @@ class ActionListLike extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLikePinyin extends BaseAction {
......@@ -37,14 +37,14 @@ class ActionListLikePinyin extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.group;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListNext extends BaseAction {
......@@ -25,10 +25,10 @@ class ActionListNext extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +44,7 @@ class ActionListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPinyinInitial extends BaseAction {
......@@ -37,14 +37,14 @@ class ActionListPinyinInitial extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.group;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPrev extends BaseAction {
......@@ -25,10 +25,10 @@ class ActionListPrev extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +44,7 @@ class ActionListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,13 +10,12 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSubDirect extends BaseAction {
......@@ -23,13 +23,13 @@ class ActionListSubDirect extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,13 +10,12 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSubNested extends BaseAction {
......@@ -23,13 +23,13 @@ class ActionListSubNested extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,13 +10,12 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSupDirect extends BaseAction {
......@@ -23,13 +23,13 @@ class ActionListSupDirect extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,14 +10,13 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSupDirectWithPerson extends BaseAction {
......@@ -24,13 +24,13 @@ class ActionListSupDirectWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,13 +10,12 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSupNested extends BaseAction {
......@@ -23,13 +23,13 @@ class ActionListSupNested extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,14 +10,13 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSupNestedWithPerson extends BaseAction {
......@@ -24,13 +24,13 @@ class ActionListSupNestedWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), key);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), key);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, key);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.group;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,15 +10,14 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithRole extends BaseAction {
......@@ -25,13 +25,13 @@ class ActionListWithRole extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), roleFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), roleFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, roleFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -8,6 +8,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -18,7 +19,6 @@ 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.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -101,8 +101,8 @@ class ActionCreate extends BaseAction {
orgMessageFactory.createMessageCommunicate("add", "identity", identity, effectivePerson);
}
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(Person.class);
CacheManager.notify(Identity.class);
CacheManager.notify(Person.class);
......
......@@ -11,13 +11,13 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import com.x.organization.core.entity.*;
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.annotation.CheckRemoveType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -76,7 +76,7 @@ public class ActionDelete extends BaseAction {
emc.beginTransaction(Identity.class);
emc.remove(identity, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Identity.class);
CacheManager.notify(Identity.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.identity;
import java.util.List;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -13,7 +14,6 @@ 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.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -81,8 +81,8 @@ class ActionEdit extends BaseAction {
person.setTopUnitList(ListTools.extractField(topUnits, Unit.id_FIELDNAME, String.class, true, true));
emc.check(person, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(Person.class);
CacheManager.notify(Identity.class);
CacheManager.notify(Person.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -14,7 +14,6 @@ import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
......@@ -24,8 +23,10 @@ import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.Unit_;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import net.sf.ehcache.Element;
import java.util.Optional;
class ActionGet extends BaseAction {
......@@ -33,13 +34,13 @@ class ActionGet extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.identity;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -9,7 +10,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections4.set.ListOrderedSet;
import org.apache.commons.lang3.StringUtils;
......@@ -20,7 +20,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -30,8 +29,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.UnitDuty;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLike extends BaseAction {
......@@ -40,16 +39,16 @@ class ActionListLike extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getUnitList(), ","),
StringUtils.join(wi.getUnitDutyList(), ","),
StringUtils.join(wi.getGroupList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.listLike(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.identity;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -9,7 +10,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections4.set.ListOrderedSet;
import org.apache.commons.lang3.StringUtils;
......@@ -20,7 +20,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -30,8 +29,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.UnitDuty;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLikePinyin extends BaseAction {
......@@ -40,16 +39,16 @@ class ActionListLikePinyin extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getUnitList(), ","),
StringUtils.join(wi.getUnitDutyList(), ","),
StringUtils.join(wi.getGroupList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
package com.x.organization.assemble.control.jaxrs.identity;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
......@@ -10,14 +10,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListNext extends BaseAction {
......@@ -25,10 +24,10 @@ class ActionListNext extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +43,7 @@ class ActionListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
}
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.identity;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -19,7 +20,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -29,8 +29,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.UnitDuty;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
public class ActionListPinyinInitial extends BaseAction {
......@@ -39,16 +39,16 @@ public class ActionListPinyinInitial extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getUnitList(), ","),
StringUtils.join(wi.getUnitDutyList(), ","),
StringUtils.join(wi.getGroupList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
package com.x.organization.assemble.control.jaxrs.identity;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPrev extends BaseAction {
......@@ -25,10 +25,10 @@ class ActionListPrev extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +44,7 @@ class ActionListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
return result;
}
......
package com.x.organization.assemble.control.jaxrs.identity;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -13,15 +14,14 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithPerson extends BaseAction {
......@@ -29,13 +29,13 @@ class ActionListWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), personFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), personFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, personFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
package com.x.organization.assemble.control.jaxrs.identity;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -13,15 +14,14 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.Unit;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithUnit extends BaseAction {
......@@ -29,13 +29,13 @@ class ActionListWithUnit extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), unitFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), unitFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, unitFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -2,28 +2,21 @@ package com.x.organization.assemble.control.jaxrs.identity;
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 java.util.Optional;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithUnitDutyName extends BaseAction {
......@@ -31,13 +24,13 @@ class ActionListWithUnitDutyName extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), unitDutyName);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), unitDutyName);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, unitDutyName);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.identity;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -14,7 +15,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
......@@ -25,8 +25,8 @@ import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithUnitWithUnitDutyName extends BaseAction {
......@@ -35,13 +35,13 @@ class ActionListWithUnitWithUnitDutyName extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), unitFlag, unitDutyName);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), unitFlag, unitDutyName);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, unitFlag, unitDutyName);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -9,6 +9,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -83,8 +84,8 @@ class ActionOrder extends BaseAction {
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(Unit.class);
CacheManager.notify(Identity.class);
CacheManager.notify(Unit.class);
return result;
}
}
......
......@@ -5,8 +5,10 @@ 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 com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import net.sf.ehcache.Element;
import java.util.Optional;
public class ActionGetResult extends BaseAction {
......@@ -15,11 +17,12 @@ public class ActionGetResult extends BaseAction {
protected ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
logger.debug(effectivePerson, "flag:{}.", flag);
ActionResult<Wo> result = new ActionResult<>();
Element element = cache.get(flag);
if (null == element || (null == element.getObjectValue())) {
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(this.cache, cacheKey);
if (!optional.isPresent()) {
throw new ExceptionResultNotFound(flag);
}
CacheInputResult o = (CacheInputResult) element.getObjectValue();
CacheInputResult o = (CacheInputResult) optional.get();
Wo wo = new Wo(o.getBytes(), this.contentType(true, o.getName()), this.contentDisposition(true, o.getName()));
result.setData(wo);
return result;
......
......@@ -14,6 +14,7 @@ import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.SimpleScriptContext;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.poi.ss.usermodel.Cell;
......@@ -28,7 +29,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.type.GenderType;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
......@@ -46,8 +46,7 @@ import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
class ActionInput extends BaseAction {
......@@ -68,12 +67,13 @@ class ActionInput extends BaseAction {
cacheInputResult.setName(name);
cacheInputResult.setBytes(os.toByteArray());
String flag = StringTools.uniqueToken();
cache.put(new Element(flag, cacheInputResult));
ApplicationCache.notify(Person.class);
ApplicationCache.notify(Group.class);
ApplicationCache.notify(Role.class);
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(PersonAttribute.class);
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
CacheManager.put(business.cache(), cacheKey, cacheInputResult);
CacheManager.notify(Person.class);
CacheManager.notify(Group.class);
CacheManager.notify(Role.class);
CacheManager.notify(Identity.class);
CacheManager.notify(PersonAttribute.class);
Wo wo = new Wo();
wo.setFlag(flag);
result.setData(wo);
......
......@@ -22,6 +22,7 @@ import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.SimpleScriptContext;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
......@@ -37,7 +38,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.type.GenderType;
import com.x.base.core.project.x_organization_assemble_control;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.connection.ActionResponse;
import com.x.base.core.project.gson.GsonPropertyObject;
......@@ -61,8 +61,7 @@ import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitDuty;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
class ActionInputAll extends BaseAction {
......@@ -102,14 +101,15 @@ class ActionInputAll extends BaseAction {
cacheInputResult.setName(name);
cacheInputResult.setBytes(os.toByteArray());
String flag = StringTools.uniqueToken();
cache.put(new Element(flag, cacheInputResult));
ApplicationCache.notify(Person.class);
ApplicationCache.notify(Group.class);
ApplicationCache.notify(Role.class);
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(PersonAttribute.class);
ApplicationCache.notify(Unit.class);
ApplicationCache.notify(UnitDuty.class);
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
CacheManager.put(business.cache(), cacheKey, cacheInputResult);
CacheManager.notify(Person.class);
CacheManager.notify(Group.class);
CacheManager.notify(Role.class);
CacheManager.notify(Identity.class);
CacheManager.notify(PersonAttribute.class);
CacheManager.notify(Unit.class);
CacheManager.notify(UnitDuty.class);
Wo wo = new Wo();
wo.setFlag(flag);
result.setData(wo);
......
......@@ -11,6 +11,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
......@@ -26,11 +27,9 @@ import com.x.organization.core.entity.UnitDuty_;
import com.x.organization.core.entity.Unit_;
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.entity.annotation.CheckRemoveType;
import com.x.base.core.project.x_organization_assemble_control;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.connection.ActionResponse;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
......@@ -81,12 +80,12 @@ public class ActionWipeAll extends BaseAction {
System.out.println("开始删除组织--------");
this.deleteUnits(emc,business);
emc.commit();
ApplicationCache.notify(UnitDuty.class);
ApplicationCache.notify(Group.class);
ApplicationCache.notify(Identity.class);
ApplicationCache.notify(Person.class);
ApplicationCache.notify(Unit.class);
CacheManager.notify(UnitDuty.class);
CacheManager.notify(Group.class);
CacheManager.notify(Identity.class);
CacheManager.notify(Person.class);
CacheManager.notify(Unit.class);
wo.setFlag("清空人员数据成功");
System.out.println("开始删除人员组织所有数据--------end");
......
......@@ -3,21 +3,18 @@ package com.x.organization.assemble.control.jaxrs.inputperson;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.organization.assemble.control.Business;
import net.sf.ehcache.Ehcache;
abstract class BaseAction extends StandardJaxrsAction {
protected static List<String> genderTypeFemaleItems = Arrays.asList(new String[] { "f","F" ,"女", "female" });
protected static List<String> genderTypeMaleItems = Arrays.asList(new String[] { "m", "M", "男", "male" });
protected Ehcache cache = ApplicationCache.instance().getCache(CacheInputResult.class);
protected CacheCategory cache = new CacheCategory(CacheInputResult.class);
protected boolean checkMobile(Business business, String mobile) throws Exception {
if (!Config.person().isMobile(mobile)) {
......
package com.x.organization.assemble.control.jaxrs.permissionsetting;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
import com.x.base.core.project.cache.CacheManager;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.DateTools;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.PermissionSetting;
......@@ -43,7 +32,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(PermissionSetting.class);
emc.persist(permission, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(PermissionSetting.class);
CacheManager.notify(PermissionSetting.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -3,7 +3,7 @@ package com.x.organization.assemble.control.jaxrs.permissionsetting;
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;
......@@ -29,7 +29,7 @@ class ActionDelete extends BaseAction {
permission = emc.find(permission.getId(), PermissionSetting.class);
emc.remove(permission, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(PermissionSetting.class);
CacheManager.notify(PermissionSetting.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
package com.x.organization.assemble.control.jaxrs.permissionsetting;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
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.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PermissionSetting;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
......
......@@ -2,7 +2,6 @@ package com.x.organization.assemble.control.jaxrs.permissionsetting;
import java.util.List;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
......@@ -14,8 +13,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PermissionSetting;
import com.x.organization.core.entity.PersonCard;
class ActionList extends BaseAction {
......
package com.x.organization.assemble.control.jaxrs.permissionsetting;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.Field;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
......@@ -16,7 +10,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
......@@ -25,9 +18,6 @@ import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.PermissionSetting;
import com.x.organization.core.entity.PersonCard;
public class ActionUpdate extends BaseAction{
private static Logger logger = LoggerFactory.getLogger(ActionUpdate.class);
......@@ -55,7 +45,7 @@ public class ActionUpdate extends BaseAction{
emc.check(entityPerson, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(PermissionSetting.class);
CacheManager.notify(PermissionSetting.class);
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
orgMessageFactory.createMessageCommunicate("modfiy", "PermissionSetting", permission, effectivePerson);
......
......@@ -9,6 +9,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.x_message_assemble_communicate;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
......@@ -87,7 +88,7 @@ class ActionCreate extends BaseAction {
emc.persist(person, CheckPersistType.all);
emc.commit();
/** 刷新缓存 */
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
/** 通知x_collect_service_transmit同步数据到collect */
business.instrument().collect().person();
......
......@@ -14,6 +14,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.Applications;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.x_message_assemble_communicate;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
......@@ -97,7 +98,7 @@ class ActionDelete extends BaseAction {
emc.beginTransaction(Person.class);
emc.remove(person, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
/** 通知x_collect_service_transmit同步数据到collect */
business.instrument().collect().person();
......
......@@ -9,10 +9,10 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.x_message_assemble_communicate;
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.config.Config;
import com.x.base.core.project.connection.ActionResponse;
import com.x.base.core.project.exception.ExceptionAccessDenied;
......@@ -96,9 +96,9 @@ class ActionEdit extends BaseAction {
emc.commit();
/** 刷新缓存 */
if (isNameUpdate) {
ApplicationCache.notify(Identity.class);
CacheManager.notify(Identity.class);
}
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
/** 通知x_collect_service_transmit同步数据到collect */
business.instrument().collect().person();
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -8,6 +9,9 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.collections4.set.ListOrderedSet;
import org.apache.commons.lang3.StringUtils;
......@@ -17,7 +21,6 @@ import com.x.base.core.entity.JpaObject;
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.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -36,18 +39,16 @@ import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitDuty;
import com.x.organization.core.entity.UnitDuty_;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
if (Config.token().isInitialManager(flag)) {
/** 如果是xadmin单独处理 */
......@@ -64,7 +65,7 @@ class ActionGet extends BaseAction {
this.referenceIdentity(business, wo);
this.referenceRole(business, wo);
this.referenceGroup(business, wo);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
}
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.Objects;
import java.util.Optional;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
......@@ -8,15 +9,14 @@ 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.type.GenderType;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.config.Config;
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.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionGetIconWithPerson extends BaseAction {
......@@ -24,13 +24,13 @@ class ActionGetIconWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -17,7 +18,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -26,8 +26,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLike extends BaseAction {
......@@ -36,14 +36,14 @@ class ActionListLike extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
wi.getKey(), StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, effectivePerson, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -17,7 +18,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -26,8 +26,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLikePinyin extends BaseAction {
......@@ -36,14 +36,14 @@ class ActionListLikePinyin extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
wi.getKey(), StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, effectivePerson, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -9,14 +10,13 @@ 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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListNext extends BaseAction {
......@@ -24,11 +24,11 @@ class ActionListNext extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -46,7 +46,7 @@ class ActionListNext extends BaseAction {
business.personPredicateWithTopUnit(effectivePerson));
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
this.hide(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -17,7 +18,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -26,8 +26,8 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPinyinInitial extends BaseAction {
......@@ -36,14 +36,14 @@ class ActionListPinyinInitial extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
wi.getKey(), StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, effectivePerson, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -9,15 +10,13 @@ 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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.jaxrs.person.ActionListNext.Wo;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPrev extends BaseAction {
......@@ -25,11 +24,11 @@ class ActionListPrev extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
CacheKey cacheKey = new CacheKey(this.getClass(), effectivePerson.getDistinguishedName(),
flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -46,7 +45,7 @@ class ActionListPrev extends BaseAction {
business.personPredicateWithTopUnit(effectivePerson));
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
this.hide(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.List;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSubDirectWithGroup extends BaseAction {
......@@ -21,13 +21,13 @@ class ActionListSubDirectWithGroup extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), groupFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), groupFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, groupFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,12 +2,12 @@ package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.List;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
......@@ -15,8 +15,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Person;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListSubNestedWithGroup extends BaseAction {
......@@ -24,13 +24,13 @@ class ActionListSubNestedWithGroup extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), groupFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), groupFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, groupFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.List;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithRole extends BaseAction {
......@@ -21,13 +21,13 @@ class ActionListWithRole extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), roleFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), roleFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, roleFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -3,7 +3,7 @@ package com.x.organization.assemble.control.jaxrs.person;
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.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -33,7 +33,7 @@ class ActionResetPassword extends BaseAction {
emc.beginTransaction(Person.class);
emc.check(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
......@@ -6,13 +6,13 @@ import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.codec.binary.Base64;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
......@@ -59,7 +59,7 @@ class ActionSetIcon extends BaseAction {
person.setIconLdpi(icon_l);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
package com.x.organization.assemble.control.jaxrs.person;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
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.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -41,7 +41,7 @@ class ActionSetPassword extends BaseAction {
business.person().setPassword(o, wi.getValue(),false);
emc.check(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Person.class);
CacheManager.notify(Person.class);
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
......
package com.x.organization.assemble.control.jaxrs.personattribute;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -9,7 +10,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -47,7 +47,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(PersonAttribute.class);
emc.persist(o, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(PersonAttribute.class);
CacheManager.notify(PersonAttribute.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
......
......@@ -3,7 +3,7 @@ package com.x.organization.assemble.control.jaxrs.personattribute;
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;
......@@ -33,7 +33,7 @@ class ActionDelete extends BaseAction {
o = emc.find(o.getId(), PersonAttribute.class);
emc.remove(o, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(PersonAttribute.class);
CacheManager.notify(PersonAttribute.class);
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
......
package com.x.organization.assemble.control.jaxrs.personattribute;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -9,7 +10,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -56,7 +56,7 @@ class ActionEdit extends BaseAction {
Wo wo = new Wo();
wo.setId(o.getId());
result.setData(wo);
ApplicationCache.notify(PersonAttribute.class);
CacheManager.notify(PersonAttribute.class);
return result;
}
}
......
......@@ -6,15 +6,16 @@ import com.x.base.core.entity.JpaObject;
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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.PersonAttribute;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import net.sf.ehcache.Element;
import java.util.Optional;
class ActionGet extends BaseAction {
......@@ -22,13 +23,13 @@ class ActionGet extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
return result;
......
package com.x.organization.assemble.control.jaxrs.personattribute;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersonAttribute;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListNext extends BaseAction {
......@@ -25,10 +25,10 @@ class ActionListNext extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +44,7 @@ class ActionListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
return result;
}
......
package com.x.organization.assemble.control.jaxrs.personattribute;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,13 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersonAttribute;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPrev extends BaseAction {
......@@ -25,10 +25,10 @@ class ActionListPrev extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -45,7 +45,7 @@ class ActionListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
return result;
}
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.personattribute;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
......@@ -15,15 +16,14 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.PersonAttribute;
import com.x.organization.core.entity.PersonAttribute_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithPerson extends BaseAction {
......@@ -31,13 +31,13 @@ class ActionListWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), personFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), personFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, personFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
......
......@@ -2,19 +2,16 @@ package com.x.organization.assemble.control.jaxrs.personcard;
import java.util.Date;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
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,9 +20,6 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.DateTools;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.PersonCard;
......@@ -54,7 +48,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(PersonCard.class);
emc.persist(personCard, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(PersonCard.class);
CacheManager.notify(PersonCard.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -3,7 +3,7 @@ package com.x.organization.assemble.control.jaxrs.personcard;
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 {
personCard = emc.find(personCard.getId(), PersonCard.class);
emc.remove(personCard, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(PersonCard.class);
CacheManager.notify(PersonCard.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -9,16 +9,11 @@ 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.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.PersonCard;
import net.sf.ehcache.Element;
class ActionGet extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
......
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.beanutils.PropertyUtils;
......@@ -57,7 +58,7 @@ public class ActionUpdate extends BaseAction{
emc.check(entityPerson, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(PersonCard.class);
CacheManager.notify(PersonCard.class);
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
orgMessageFactory.createMessageCommunicate("modfiy", "personCard", personCard, effectivePerson);
......
package com.x.organization.assemble.control.jaxrs.role;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -20,9 +17,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Role;
......@@ -54,7 +48,7 @@ class ActionCreate extends BaseAction {
emc.beginTransaction(Role.class);
emc.persist(role, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Role.class);
CacheManager.notify(Role.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
package com.x.organization.assemble.control.jaxrs.role;
import com.google.gson.Gson;
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.Applications;
import com.x.base.core.project.x_message_assemble_communicate;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.connection.ActionResponse;
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;
......@@ -15,9 +11,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Role;
......@@ -43,7 +36,7 @@ class ActionDelete extends BaseAction {
role = emc.find(role.getId(), Role.class);
emc.remove(role, CheckRemoveType.all);
emc.commit();
ApplicationCache.notify(Role.class);
CacheManager.notify(Role.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
package com.x.organization.assemble.control.jaxrs.role;
import com.x.base.core.project.cache.CacheManager;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
......@@ -8,11 +9,8 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.x_message_assemble_communicate;
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.connection.ActionResponse;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -20,9 +18,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Role;
......@@ -63,7 +58,7 @@ class ActionEdit extends BaseAction {
emc.beginTransaction(Role.class);
emc.check(role, CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Role.class);
CacheManager.notify(Role.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
......@@ -9,7 +10,6 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.ListTools;
......@@ -17,8 +17,8 @@ import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionGet extends BaseAction {
......@@ -26,13 +26,13 @@ class ActionGet extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<Wo> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((Wo) element.getObjectValue());
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = this.get(business, flag);
business.cache().put(new Element(cacheKey, wo));
CacheManager.put(business.cache(), cacheKey, wo);
result.setData(wo);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,9 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLike extends BaseAction {
......@@ -37,15 +38,15 @@ class ActionListLike extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
result.setData(wos);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,9 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListLikePinyin extends BaseAction {
......@@ -37,14 +38,14 @@ class ActionListLikePinyin extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.role;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,14 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListNext extends BaseAction {
......@@ -25,10 +26,10 @@ class ActionListNext extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +45,7 @@ class ActionListNext extends BaseAction {
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null,
null, null, null, null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -18,7 +19,6 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -27,8 +27,9 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPinyinInitial extends BaseAction {
......@@ -37,14 +38,14 @@ class ActionListPinyinInitial extends BaseAction {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), wi.getKey(),
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), wi.getKey(),
StringUtils.join(wi.getGroupList(), ","), StringUtils.join(wi.getRoleList(), ","));
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
package com.x.organization.assemble.control.jaxrs.role;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
......@@ -10,14 +11,14 @@ import com.x.base.core.entity.JpaObject;
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.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Role;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPrev extends BaseAction {
......@@ -25,10 +26,10 @@ class ActionListPrev extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
ActionResult<List<Wo>> result = new ActionResult<>();
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), flag, count);
Element element = business.cache().get(cacheKey);
if (null != element && null != element.getObjectValue()) {
Co co = (Co) element.getObjectValue();
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), flag, count);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
Co co = (Co) optional.get();
result.setData(co.getWos());
result.setCount(co.getCount());
} else {
......@@ -44,7 +45,7 @@ class ActionListPrev extends BaseAction {
result = this.standardListPrev(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null,
null, null, true, DESC);
Co co = new Co(result.getData(), result.getCount());
business.cache().put(new Element(cacheKey, co));
CacheManager.put(business.cache(), cacheKey, co);
}
this.updateControl(effectivePerson, business, result.getData());
return result;
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -14,15 +15,15 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithGroup extends BaseAction {
......@@ -30,13 +31,13 @@ class ActionListWithGroup extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), groupFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), groupFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, groupFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -2,6 +2,7 @@ package com.x.organization.assemble.control.jaxrs.role;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
......@@ -15,15 +16,15 @@ 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.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Role;
import com.x.organization.core.entity.Role_;
import net.sf.ehcache.Element;
import com.x.base.core.project.cache.Cache;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListWithPerson extends BaseAction {
......@@ -31,13 +32,13 @@ class ActionListWithPerson extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
String cacheKey = ApplicationCache.concreteCacheKey(this.getClass(), personFlag);
Element element = business.cache().get(cacheKey);
if (null != element && (null != element.getObjectValue())) {
result.setData((List<Wo>) element.getObjectValue());
CacheKey cacheKey = new Cache.CacheKey(this.getClass(), personFlag);
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, personFlag);
business.cache().put(new Element(cacheKey, wos));
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
this.updateControl(effectivePerson, business, result.getData());
......
......@@ -7,7 +7,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;
......@@ -66,7 +66,7 @@ class ActionCreate extends BaseAction {
business.unit().adjustInherit(unit);
emc.persist(unit,CheckPersistType.all);
emc.commit();
ApplicationCache.notify(Unit.class);
CacheManager.notify(Unit.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
......@@ -11,15 +11,11 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.google.gson.Gson;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.Applications;
import com.x.base.core.project.x_message_assemble_communicate;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.connection.ActionResponse;
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;
......@@ -27,15 +23,11 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.assemble.control.ThisApplication;
import com.x.organization.assemble.control.message.OrgBodyMessage;
import com.x.organization.assemble.control.message.OrgMessage;
import com.x.organization.assemble.control.message.OrgMessageFactory;
import com.x.organization.core.entity.Group;
import com.x.organization.core.entity.Group_;
import com.x.organization.core.entity.Identity;
import com.x.organization.core.entity.Identity_;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.UnitAttribute;
import com.x.organization.core.entity.UnitAttribute_;
......@@ -64,8 +56,8 @@ class ActionDelete extends BaseAction {
for (Unit o : list) {
this.remove(business, o);
}
ApplicationCache.notify(Unit.class);
CacheManager.notify(Unit.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册