提交 4bd3fe79 编写于 作者: O o2null

Merge branch 'fix/内容管理去掉不必要的索引,修改全员权限规则' into 'wrdp'

[内容管理]去掉review表不必要的索引,修改全员权限规则

See merge request o2oa/o2oa!4608
......@@ -445,7 +445,7 @@ public class DocumentFactory extends AbstractFactory {
* @throws NoSuchFieldException
*/
public List<Document> listPagingWithCondition( String personName, String orderField, String orderType, QueryFilter queryFilter, Integer adjustPage,
Integer adjustPageSize, Boolean isAuthor) throws Exception {
Integer adjustPageSize, Boolean isAuthor, Boolean excludeAllRead) throws Exception {
EntityManager em = this.entityManagerContainer().get( Document.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
EntityManager em1 = this.entityManagerContainer().get( Review.class );
......@@ -463,8 +463,12 @@ public class DocumentFactory extends AbstractFactory {
Predicate p_permission = cb1.equal(root2.get(Review_.permissionObj), personName);
p_permission = cb1.and(p_permission, cb1.equal(root2.get(Review_.docId), root.get(Document_.id)));
subquery.where(p_permission);
Predicate orP = cb.or(cb.isTrue(root.get(Document_.isAllRead)), cb.exists(subquery));
p = cb.and(p, orP);
if(BooleanUtils.isTrue(excludeAllRead)){
p = cb.and(p, cb.exists(subquery));
}else {
Predicate orP = cb.or(cb.isTrue(root.get(Document_.isAllRead)), cb.exists(subquery));
p = cb.and(p, orP);
}
}else {
List<String> list = new ArrayList<>();
List<String> unitAllList = this.business().organization().unit().listWithPersonSupNested(personName);
......@@ -551,7 +555,7 @@ public class DocumentFactory extends AbstractFactory {
* @return
* @throws Exception
*/
public Long countWithCondition( String personName, QueryFilter queryFilter, Boolean isAuthor) throws Exception {
public Long countWithCondition( String personName, QueryFilter queryFilter, Boolean isAuthor, Boolean excludeAllRead) throws Exception {
EntityManager em = this.entityManagerContainer().get( Document.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
EntityManager em1 = this.entityManagerContainer().get( Review.class );
......@@ -568,8 +572,12 @@ public class DocumentFactory extends AbstractFactory {
Predicate p_permission = cb1.equal(root2.get(Review_.permissionObj), personName);
p_permission = cb1.and(p_permission, cb1.equal(root2.get(Review_.docId), root.get(Document_.id)));
subquery.where(p_permission);
Predicate orP = cb.or(cb.isTrue(root.get(Document_.isAllRead)), cb.exists(subquery));
p = cb.and(p, orP);
if(BooleanUtils.isTrue(excludeAllRead)){
p = cb.and(p, cb.exists(subquery));
}else {
Predicate orP = cb.or(cb.isTrue(root.get(Document_.isAllRead)), cb.exists(subquery));
p = cb.and(p, orP);
}
}else {
List<String> list = new ArrayList<>();
List<String> unitAllList = this.business().organization().unit().listWithPersonSupNested(personName);
......
......@@ -92,7 +92,7 @@ public class ActionQueryListWithFilterPaging extends BaseAction {
if( isManager ) {
personName = null;
}
total = documentQueryService.countWithCondition( personName, queryFilter, false);
total = documentQueryService.countWithCondition( personName, queryFilter, false, false);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionDocumentInfoProcess(e, "系统在获取用户可查询到的文档数据条目数量时发生异常。");
......@@ -108,7 +108,7 @@ public class ActionQueryListWithFilterPaging extends BaseAction {
if( isManager ) {
personName = null;
}
searchResultList = documentQueryService.listPagingWithCondition( personName, wi.getOrderField(), wi.getOrderType(), queryFilter, page, size, false);
searchResultList = documentQueryService.listPagingWithCondition( personName, wi.getOrderField(), wi.getOrderType(), queryFilter, page, size, false, false);
} catch (Exception e) {
check = false;
Exception exception = new ExceptionDocumentInfoProcess(e, "系统在根据用户可访问的文档ID列表对文档进行分页查询时发生异常。");
......
......@@ -75,9 +75,9 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
}
Long total = 0L;
if (!BooleanUtils.isTrue(wi.getJustData())){
total = documentQueryService.countWithCondition(personName, queryFilter, wi.getAuthor());
total = documentQueryService.countWithCondition(personName, queryFilter, wi.getAuthor(), wi.getExcludeAllRead());
}
List<Document> searchResultList = documentQueryService.listPagingWithCondition( personName, wi.getOrderField(), wi.getOrderType(), queryFilter, page, size, wi.getAuthor());
List<Document> searchResultList = documentQueryService.listPagingWithCondition( personName, wi.getOrderField(), wi.getOrderType(), queryFilter, page, size, wi.getAuthor(), wi.getExcludeAllRead());
Wo wo = null;
for( Document document : searchResultList ) {
try {
......@@ -117,6 +117,9 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
@FieldDescribe( "仅返回数据不查询总数,默认false" )
private Boolean justData;
@FieldDescribe( "是否排除全员可读文档,默认false" )
private Boolean excludeAllRead;
public String getPerson() {
return person;
}
......@@ -140,6 +143,14 @@ public class ActionQueryListWithFilterPagingAdmin extends BaseAction {
public void setJustData(Boolean justData) {
this.justData = justData;
}
public Boolean getExcludeAllRead() {
return excludeAllRead;
}
public void setExcludeAllRead(Boolean excludeAllRead) {
this.excludeAllRead = excludeAllRead;
}
}
public static class Wo extends WrapOutDocumentList {
......
......@@ -311,11 +311,11 @@ public class WrapOutDocumentList extends GsonPropertyObject {
this.isTop = isTop;
}
public Boolean getAllRead() {
public Boolean getIsAllRead() {
return isAllRead;
}
public void setAllRead(Boolean allRead) {
isAllRead = allRead;
public void setIsAllRead(Boolean isAllRead) {
this.isAllRead = isAllRead;
}
}
......@@ -73,7 +73,11 @@ public class ActionRefreshDocumentPermission extends BaseAction {
if ( ListTools.isEmpty(wi.getPermissionList())) {
ReviewService reviewService = new ReviewService();
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
reviewService.refreshDocumentReview(emc, wi.getDocId());
boolean fullRead = reviewService.refreshDocumentReview(emc, wi.getDocId());
Document doc = emc.find( wi.getDocId(), Document.class );
emc.beginTransaction( Document.class );
doc.setIsAllRead(fullRead);
emc.commit();
}
} else {
documentPersistService.refreshDocumentPermission(document.getId(), wi.getPermissionList());
......
......@@ -230,17 +230,13 @@ public class CmsBatchOperationProcessService {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
cmsBatchOperation = emc.find( id, CmsBatchOperation.class );
reviewService.refreshDocumentReview( emc, docId );
boolean fullRead = reviewService.refreshDocumentReview( emc, docId );
Document document = emc.find( docId, Document.class );
if( document != null ) {
emc.beginTransaction( Document.class );
document.setReviewed( true );
if("数据".equals(document.getDocumentType()) || document.getReadPersonList().contains("所有人")){
document.setAllRead(true);
}else{
document.setAllRead(false);
}
document.setIsAllRead(fullRead);
if(StringUtils.isEmpty( document.getAppAlias())) {
document.setAppAlias( document.getAppName() );
......@@ -290,17 +286,13 @@ public class CmsBatchOperationProcessService {
public void refreshDocumentReview(String docId ) throws Exception {
logger.debug( "refreshDocumentReview {}", docId);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
reviewService.refreshDocumentReview( emc, docId );
boolean fullRead = reviewService.refreshDocumentReview( emc, docId );
Document document = emc.find( docId, Document.class );
if( document != null ) {
emc.beginTransaction( Document.class );
document.setReviewed( true );
if("数据".equals(document.getDocumentType()) || document.getReadPersonList().contains("所有人")){
document.setAllRead(true);
}else{
document.setAllRead(false);
}
document.setIsAllRead(fullRead);
if( StringUtils.isEmpty( document.getAppAlias() )) {
document.setAppAlias( document.getAppName() );
}
......
......@@ -342,14 +342,10 @@ public class DocumentPersistService {
if( ListTools.isNotEmpty( documentIds )){
for( String documentId : documentIds ){
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
reviewService.refreshDocumentReview(emc, documentId);
boolean fullRead = reviewService.refreshDocumentReview(emc, documentId);
Document document = emc.find( documentId, Document.class );
emc.beginTransaction( Document.class );
if(document.getReadPersonList().contains("所有人")){
document.setAllRead(true);
}else{
document.setAllRead(false);
}
document.setIsAllRead(fullRead);
emc.commit();
} catch ( Exception e ) {
throw e;
......
......@@ -458,12 +458,12 @@ public class DocumentQueryService {
* @throws Exception
*/
public List<Document> listPagingWithCondition( String personName, String orderField, String orderType, QueryFilter queryFilter, Integer adjustPage,
Integer pageSize, Boolean isAuthor) throws Exception {
Integer pageSize, Boolean isAuthor, Boolean excludeAllRead) throws Exception {
if( pageSize == 0 ) { pageSize = 20; }
//按正常逻辑根据序列进行分页查询
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
Business business = new Business(emc);
return business.getDocumentFactory().listPagingWithCondition(personName, orderField, orderType, queryFilter, adjustPage, pageSize, isAuthor);
return business.getDocumentFactory().listPagingWithCondition(personName, orderField, orderType, queryFilter, adjustPage, pageSize, isAuthor, excludeAllRead);
} catch ( Exception e ) {
throw e;
}
......@@ -476,11 +476,11 @@ public class DocumentQueryService {
* @return
* @throws Exception
*/
public Long countWithCondition( String personName, QueryFilter queryFilter, Boolean isAuthor) throws Exception {
public Long countWithCondition( String personName, QueryFilter queryFilter, Boolean isAuthor, Boolean excludeAllRead) throws Exception {
//按正常逻辑根据序列进行分页查询
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
Business business = new Business(emc);
return business.getDocumentFactory().countWithCondition(personName, queryFilter, isAuthor);
return business.getDocumentFactory().countWithCondition(personName, queryFilter, isAuthor, excludeAllRead);
} catch ( Exception e ) {
throw e;
}
......
......@@ -104,11 +104,11 @@ public class ReviewService {
* @param docId
* @throws Exception
*/
public void refreshDocumentReview( EntityManagerContainer emc, String docId ) throws Exception {
public boolean refreshDocumentReview( EntityManagerContainer emc, String docId ) throws Exception {
boolean fullRead = false;
Document document = emc.find( docId, Document.class );
if( document != null ) {
AppInfo appInfo = emc.find( document.getAppId(), AppInfo.class );
CategoryInfo categoryInfo = emc.find( document.getCategoryId(), CategoryInfo.class );
......@@ -122,6 +122,9 @@ public class ReviewService {
}else if( "published".equalsIgnoreCase( document.getDocStatus() ) ) {
logger.debug( "refreshDocumentReview -> refresh review for published document: " + document.getTitle() );
List<String> persons = listPermissionPersons( appInfo, categoryInfo, document );
if(persons.contains("*")){
fullRead = true;
}
//将文档新的权限与数据库中的权限进行比对,新建或者更新
logger.debug( "refreshDocumentReview -> there are "+ persons.size() +" permission in this document: " + document.getTitle() );
refreshDocumentReview( emc, appInfo, categoryInfo, document, persons );
......@@ -135,12 +138,13 @@ public class ReviewService {
}else {
logger.debug( "refreshDocumentReview -> document not exists: " + docId );
}
return fullRead;
}
private List<String> listPublishAndManagePersons(AppInfo appInfo, CategoryInfo categoryInfo, Document document) throws Exception {
List<String> persons = new ArrayList<>();
persons.add( document.getCreatorPerson() ); //创建者
persons = addListToList( persons, categoryInfo.getPublishablePersonList() );
persons = addListToList( persons, categoryInfo.getPublishablePersonList() );
persons = addPermissionObj( persons, categoryInfo.getPublishableUnitList() );
persons = addPermissionObj( persons, categoryInfo.getPublishableGroupList() );
persons = addListToList( persons, categoryInfo.getManageablePersonList() );
......@@ -251,6 +255,8 @@ public class ReviewService {
if( ListTools.isNotEmpty( document.getReadPersonList() ) ) {
if( !document.getReadPersonList().contains( "所有人" )) {
return true;
}else{
return false;
}
}
if( ListTools.isNotEmpty( document.getReadUnitList() ) ) {
......
......@@ -241,21 +241,18 @@ public class Document extends SliceJpaObject {
public static final String isTop_FIELDNAME = "isTop";
@FieldDescribe("是否置顶")
@Column(name = ColumnNamePrefix + isTop_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + isTop_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Boolean isTop = false;
public static final String isAllRead_FIELDNAME = "isAllRead";
@FieldDescribe("是否全员可读")
@Column(name = ColumnNamePrefix + isAllRead_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + isAllRead_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Boolean isAllRead = false;
public static final String hasIndexPic_FIELDNAME = "hasIndexPic";
@FieldDescribe("是否含有首页图片")
@Column(name = ColumnNamePrefix + hasIndexPic_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + hasIndexPic_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Boolean hasIndexPic = false;
......@@ -263,7 +260,6 @@ public class Document extends SliceJpaObject {
@FieldDescribe("是否已经更新review信息.")
@Column(name = ColumnNamePrefix + reviewed_FIELDNAME)
@CheckPersist(allowEmpty = true)
@Index(name = TABLE + IndexNameMiddle + reviewed_FIELDNAME)
private Boolean reviewed = false;
public static final String sequenceTitle_FIELDNAME = "sequenceTitle";
......@@ -814,12 +810,12 @@ public class Document extends SliceJpaObject {
}
}
public Boolean getAllRead() {
public Boolean getIsAllRead() {
return isAllRead;
}
public void setAllRead(Boolean allRead) {
isAllRead = allRead;
public void setIsAllRead(Boolean isAllRead) {
this.isAllRead = isAllRead;
}
public Boolean getIsTop() {
......
......@@ -60,14 +60,12 @@ public class Review extends SliceJpaObject {
public static final String documentType_FIELDNAME = "documentType";
@FieldDescribe("文档类型:信息|数据.")
@Column(length = JpaObject.length_16B, name = ColumnNamePrefix + documentType_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + documentType_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String documentType;
public static final String appId_FIELDNAME = "appId";
@FieldDescribe("栏目ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + appId_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + appId_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String appId;
......@@ -75,7 +73,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("栏目名称.")
@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
+ appName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + appName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String appName;
......@@ -83,14 +80,12 @@ public class Review extends SliceJpaObject {
@FieldDescribe("栏目别名.")
@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
+ appAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + appAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String appAlias;
public static final String categoryId_FIELDNAME = "categoryId";
@FieldDescribe("分类ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + categoryId_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + categoryId_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String categoryId;
......@@ -98,7 +93,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("分类名称.")
@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
+ categoryName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + categoryName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String categoryName;
......@@ -106,7 +100,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("分类别名.")
@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
+ categoryAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + categoryAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String categoryAlias;
......@@ -119,21 +112,18 @@ public class Review extends SliceJpaObject {
public static final String docSequence_FIELDNAME = "docSequence";
@FieldDescribe("文档Sequence.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + docSequence_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + docSequence_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String docSequence;
public static final String docStatus_FIELDNAME = "docStatus";
@FieldDescribe("文档状态.")
@Column(length = length_32B, name = ColumnNamePrefix + docStatus_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + docStatus_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String docStatus;
public static final String title_FIELDNAME = "title";
@FieldDescribe("文档标题.")
@Column(length = length_255B, name = ColumnNamePrefix + title_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + title_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String title;
......@@ -141,7 +131,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("拟稿人")
@Column(length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix
+ creatorPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + creatorPerson_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String creatorPerson;
......@@ -149,7 +138,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("创建人Identity")
@Column(length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix
+ creatorIdentity_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + creatorIdentity_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String creatorIdentity;
......@@ -157,7 +145,6 @@ public class Review extends SliceJpaObject {
@FieldDescribe("创建人组织")
@Column(length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix
+ creatorUnitName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + creatorUnitName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String creatorUnitName;
......@@ -173,7 +160,6 @@ public class Review extends SliceJpaObject {
@Temporal(TemporalType.TIMESTAMP)
/* 结束时间不能为空,如果为空排序可能出错 */
@Column(name = ColumnNamePrefix + docCreateTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + docCreateTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date docCreateTime;
......@@ -182,7 +168,6 @@ public class Review extends SliceJpaObject {
@Temporal(TemporalType.TIMESTAMP)
/* 结束时间不能为空,如果为空排序可能出错 */
@Column(name = ColumnNamePrefix + publishTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + publishTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date publishTime;
......@@ -215,7 +200,6 @@ public class Review extends SliceJpaObject {
public static final String importBatchName_FIELDNAME = "importBatchName";
@FieldDescribe("文件导入的批次号:一般是分类ID+时间缀")
@Column(length = JpaObject.length_128B, name = ColumnNamePrefix + importBatchName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + importBatchName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String importBatchName;
......@@ -241,42 +225,36 @@ public class Review extends SliceJpaObject {
@FieldDescribe("文档修改时间")
@Temporal(TemporalType.TIMESTAMP)
@Column(name = ColumnNamePrefix + modifyTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + modifyTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date modifyTime;
public static final String sequenceTitle_FIELDNAME = "sequenceTitle";
@FieldDescribe("用于标题排序的sequence")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + sequenceTitle_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + sequenceTitle_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String sequenceTitle = "";
public static final String sequenceAppAlias_FIELDNAME = "sequenceAppAlias";
@FieldDescribe("用于栏目别名排序的sequence")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + sequenceAppAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + sequenceAppAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String sequenceAppAlias = "";
public static final String sequenceCategoryAlias_FIELDNAME = "sequenceCategoryAlias";
@FieldDescribe("用于分类别名排序的sequence")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + sequenceCategoryAlias_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + sequenceCategoryAlias_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String sequenceCategoryAlias = "";
public static final String sequenceCreatorPerson_FIELDNAME = "sequenceCreatorPerson";
@FieldDescribe("用于创建者排序的sequence")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + sequenceCreatorPerson_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + sequenceCreatorPerson_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String sequenceCreatorPerson = "";
public static final String sequenceCreatorUnitName_FIELDNAME = "sequenceCreatorUnitName";
@FieldDescribe("用于创建者组织排序的sequence")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + sequenceCreatorUnitName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + sequenceCreatorUnitName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String sequenceCreatorUnitName = "";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册