Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
e70f400d
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e70f400d
编写于
12月 17, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
全局设计搜索之script脚本搜索3
上级
d49e6b79
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
209 addition
and
40 deletion
+209
-40
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
.../main/java/com/x/base/core/project/tools/StringTools.java
+38
-1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ActionManagerList.java
.../cms/assemble/control/jaxrs/script/ActionManagerList.java
+53
-2
o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ActionManagerList.java
...tal/assemble/designer/jaxrs/script/ActionManagerList.java
+54
-3
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionManagerList.java
...orm/assemble/designer/jaxrs/script/ActionManagerList.java
+54
-3
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java
...x/query/service/processing/jaxrs/design/ActionSearch.java
+8
-3
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java
...m/x/query/service/processing/jaxrs/design/BaseAction.java
+2
-28
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
浏览文件 @
e70f400d
...
...
@@ -27,6 +27,7 @@ import org.apache.commons.collections4.ListUtils;
import
org.apache.commons.collections4.set.ListOrderedSet
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.slf4j.helpers.MessageFormatter
;
...
...
@@ -548,4 +549,40 @@ public class StringTools {
}
return
sb
.
toString
();
}
}
\ No newline at end of file
/**
* 文本搜索
* @param keyword 搜索关键字
* @param content 文本
* @param caseSensitive 大小写敏感
* @param matchWholeWord 是否全字匹配
* @param matchRegExp 正则表达式搜索
* @return
*/
public
static
boolean
matchKeyword
(
String
keyword
,
String
content
,
Boolean
caseSensitive
,
Boolean
matchWholeWord
,
Boolean
matchRegExp
){
if
(
StringUtils
.
isBlank
(
keyword
)
||
StringUtils
.
isBlank
(
content
)){
return
false
;
}
if
(
BooleanUtils
.
isTrue
(
matchRegExp
)){
Pattern
pattern
=
Pattern
.
compile
(
keyword
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
else
if
(
BooleanUtils
.
isTrue
(
matchWholeWord
)){
if
(
BooleanUtils
.
isTrue
(
caseSensitive
))
{
Pattern
pattern
=
Pattern
.
compile
(
"\\b("
+
keyword
+
")\\b"
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
else
{
Pattern
pattern
=
Pattern
.
compile
(
"\\b("
+
keyword
+
")\\b"
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
}
else
{
if
(
BooleanUtils
.
isTrue
(
caseSensitive
))
{
return
(
content
.
indexOf
(
keyword
)
>
-
1
);
}
else
{
return
(
content
.
toLowerCase
().
indexOf
(
keyword
.
toLowerCase
())
>
-
1
);
}
}
}
}
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ActionManagerList.java
浏览文件 @
e70f400d
...
...
@@ -12,8 +12,10 @@ import com.x.base.core.project.gson.GsonPropertyObject;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.cms.core.entity.AppInfo
;
import
com.x.cms.core.entity.element.Script
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -32,6 +34,7 @@ class ActionManagerList extends BaseAction {
}
else
{
wos
=
emc
.
fetchIn
(
Script
.
class
,
Wo
.
copier
,
Script
.
appId_FIELDNAME
,
wi
.
getAppIdList
());
}
final
List
<
Wo
>
resWos
=
new
ArrayList
<>();
wos
.
stream
().
forEach
(
wo
->
{
try
{
AppInfo
appInfo
=
emc
.
find
(
wo
.
getAppId
(),
AppInfo
.
class
);
...
...
@@ -40,17 +43,65 @@ class ActionManagerList extends BaseAction {
}
}
catch
(
Exception
e
)
{
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getKeyword
())){
if
(
StringTools
.
matchKeyword
(
wi
.
getKeyword
(),
wo
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
())){
resWos
.
add
(
wo
);
}
}
else
{
resWos
.
add
(
wo
);
}
});
result
.
setData
(
wos
);
result
.
setCount
((
long
)
wos
.
size
());
wos
.
clear
();
result
.
setData
(
resWos
);
result
.
setCount
((
long
)
resWos
.
size
());
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"搜索关键字."
)
private
String
keyword
;
@FieldDescribe
(
"是否区分大小写."
)
private
Boolean
caseSensitive
;
@FieldDescribe
(
"是否全字匹配."
)
private
Boolean
matchWholeWord
;
@FieldDescribe
(
"是否正则表达式匹配."
)
private
Boolean
matchRegExp
;
@FieldDescribe
(
"应用ID列表."
)
private
List
<
String
>
appIdList
=
new
ArrayList
<>();
public
String
getKeyword
()
{
return
keyword
;
}
public
void
setKeyword
(
String
keyword
)
{
this
.
keyword
=
keyword
;
}
public
Boolean
getCaseSensitive
()
{
return
caseSensitive
;
}
public
void
setCaseSensitive
(
Boolean
caseSensitive
)
{
this
.
caseSensitive
=
caseSensitive
;
}
public
Boolean
getMatchWholeWord
()
{
return
matchWholeWord
;
}
public
void
setMatchWholeWord
(
Boolean
matchWholeWord
)
{
this
.
matchWholeWord
=
matchWholeWord
;
}
public
Boolean
getMatchRegExp
()
{
return
matchRegExp
;
}
public
void
setMatchRegExp
(
Boolean
matchRegExp
)
{
this
.
matchRegExp
=
matchRegExp
;
}
public
List
<
String
>
getAppIdList
()
{
return
appIdList
;
}
...
...
o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ActionManagerList.java
浏览文件 @
e70f400d
...
...
@@ -12,8 +12,10 @@ import com.x.base.core.project.gson.GsonPropertyObject;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.portal.core.entity.Portal
;
import
com.x.portal.core.entity.Script
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -32,6 +34,7 @@ class ActionManagerList extends BaseAction {
}
else
{
wos
=
emc
.
fetchIn
(
Script
.
class
,
Wo
.
copier
,
Script
.
portal_FIELDNAME
,
wi
.
getAppIdList
());
}
final
List
<
Wo
>
resWos
=
new
ArrayList
<>();
wos
.
stream
().
forEach
(
wo
->
{
try
{
Portal
portal
=
emc
.
find
(
wo
.
getPortal
(),
Portal
.
class
);
...
...
@@ -41,17 +44,65 @@ class ActionManagerList extends BaseAction {
}
}
catch
(
Exception
e
)
{
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getKeyword
())){
if
(
StringTools
.
matchKeyword
(
wi
.
getKeyword
(),
wo
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
())){
resWos
.
add
(
wo
);
}
}
else
{
resWos
.
add
(
wo
);
}
});
result
.
setData
(
wos
);
result
.
setCount
((
long
)
wos
.
size
());
wos
.
clear
();
result
.
setData
(
resWos
);
result
.
setCount
((
long
)
resWos
.
size
());
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"搜索关键字."
)
private
String
keyword
;
@FieldDescribe
(
"是否区分大小写."
)
private
Boolean
caseSensitive
;
@FieldDescribe
(
"是否全字匹配."
)
private
Boolean
matchWholeWord
;
@FieldDescribe
(
"是否正则表达式匹配."
)
private
Boolean
matchRegExp
;
@FieldDescribe
(
"应用ID列表."
)
private
List
<
String
>
appIdList
=
new
ArrayList
<>();
public
String
getKeyword
()
{
return
keyword
;
}
public
void
setKeyword
(
String
keyword
)
{
this
.
keyword
=
keyword
;
}
public
Boolean
getCaseSensitive
()
{
return
caseSensitive
;
}
public
void
setCaseSensitive
(
Boolean
caseSensitive
)
{
this
.
caseSensitive
=
caseSensitive
;
}
public
Boolean
getMatchWholeWord
()
{
return
matchWholeWord
;
}
public
void
setMatchWholeWord
(
Boolean
matchWholeWord
)
{
this
.
matchWholeWord
=
matchWholeWord
;
}
public
Boolean
getMatchRegExp
()
{
return
matchRegExp
;
}
public
void
setMatchRegExp
(
Boolean
matchRegExp
)
{
this
.
matchRegExp
=
matchRegExp
;
}
public
List
<
String
>
getAppIdList
()
{
return
appIdList
;
}
...
...
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionManagerList.java
浏览文件 @
e70f400d
...
...
@@ -12,8 +12,10 @@ import com.x.base.core.project.gson.GsonPropertyObject;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.processplatform.core.entity.element.Application
;
import
com.x.processplatform.core.entity.element.Script
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -32,6 +34,7 @@ class ActionManagerList extends BaseAction {
}
else
{
wos
=
emc
.
fetchIn
(
Script
.
class
,
Wo
.
copier
,
Script
.
application_FIELDNAME
,
wi
.
getAppIdList
());
}
final
List
<
Wo
>
resWos
=
new
ArrayList
<>();
wos
.
stream
().
forEach
(
wo
->
{
try
{
Application
app
=
emc
.
find
(
wo
.
getApplication
(),
Application
.
class
);
...
...
@@ -41,17 +44,65 @@ class ActionManagerList extends BaseAction {
}
}
catch
(
Exception
e
)
{
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getKeyword
())){
if
(
StringTools
.
matchKeyword
(
wi
.
getKeyword
(),
wo
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
())){
resWos
.
add
(
wo
);
}
}
else
{
resWos
.
add
(
wo
);
}
});
result
.
setData
(
wos
);
result
.
setCount
((
long
)
wos
.
size
());
wos
.
clear
();
result
.
setData
(
resWos
);
result
.
setCount
((
long
)
resWos
.
size
());
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"搜索关键字."
)
private
String
keyword
;
@FieldDescribe
(
"是否区分大小写."
)
private
Boolean
caseSensitive
;
@FieldDescribe
(
"是否全字匹配."
)
private
Boolean
matchWholeWord
;
@FieldDescribe
(
"是否正则表达式匹配."
)
private
Boolean
matchRegExp
;
@FieldDescribe
(
"应用ID列表."
)
private
List
<
String
>
appIdList
=
new
ArrayList
<>();
public
String
getKeyword
()
{
return
keyword
;
}
public
void
setKeyword
(
String
keyword
)
{
this
.
keyword
=
keyword
;
}
public
Boolean
getCaseSensitive
()
{
return
caseSensitive
;
}
public
void
setCaseSensitive
(
Boolean
caseSensitive
)
{
this
.
caseSensitive
=
caseSensitive
;
}
public
Boolean
getMatchWholeWord
()
{
return
matchWholeWord
;
}
public
void
setMatchWholeWord
(
Boolean
matchWholeWord
)
{
this
.
matchWholeWord
=
matchWholeWord
;
}
public
Boolean
getMatchRegExp
()
{
return
matchRegExp
;
}
public
void
setMatchRegExp
(
Boolean
matchRegExp
)
{
this
.
matchRegExp
=
matchRegExp
;
}
public
List
<
String
>
getAppIdList
()
{
return
appIdList
;
}
...
...
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java
浏览文件 @
e70f400d
...
...
@@ -11,6 +11,7 @@ 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.base.core.project.tools.SortTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.base.core.project.x_cms_assemble_control
;
import
com.x.base.core.project.x_portal_assemble_designer
;
import
com.x.base.core.project.x_processplatform_assemble_designer
;
...
...
@@ -86,11 +87,15 @@ class ActionSearch extends BaseAction {
List
<
ScriptWo
>
swList
=
new
ArrayList
<>();
if
(
moduleMap
.
containsKey
(
moduleType
))
{
try
{
Map
<
String
,
List
<
String
>
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"appIdList"
,
moduleMap
.
get
(
moduleType
));
map
.
put
(
"keyword"
,
wi
.
getKeyword
());
map
.
put
(
"caseSensitive"
,
wi
.
getCaseSensitive
());
map
.
put
(
"matchWholeWord"
,
wi
.
getMatchWholeWord
());
map
.
put
(
"matchRegExp"
,
wi
.
getMatchRegExp
());
List
<
WrapScript
>
scriptList
=
ThisApplication
.
context
().
applications
().
postQuery
(
applicationClass
,
Applications
.
joinQueryUri
(
"script"
,
"list"
,
"manager"
),
map
).
getDataAsList
(
WrapScript
.
class
);
logger
.
print
(
"设计搜索关联{}的脚本个数:{}"
,
moduleType
,
scriptList
.
size
());
logger
.
print
(
"设计搜索关联{}的
匹配
脚本个数:{}"
,
moduleType
,
scriptList
.
size
());
getScriptSearchRes
(
wi
,
moduleType
,
swList
,
scriptList
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
...
...
@@ -110,7 +115,7 @@ class ActionSearch extends BaseAction {
private
void
getScriptSearchRes
(
final
Wi
wi
,
String
moduleType
,
List
<
ScriptWo
>
swList
,
List
<
WrapScript
>
scriptList
){
if
(!
ListTools
.
isEmpty
(
scriptList
)){
for
(
WrapScript
script:
scriptList
)
{
if
(
keywordMatch
(
wi
.
getKeyword
(),
script
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
())){
if
(
StringTools
.
matchKeyword
(
wi
.
getKeyword
(),
script
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
())){
List
<
Integer
>
list
=
patternLines
(
script
.
getId
()+
"-"
+
script
.
getUpdateTime
().
getTime
(),
wi
.
getKeyword
(),
script
.
getText
(),
wi
.
getCaseSensitive
(),
wi
.
getMatchWholeWord
(),
wi
.
getMatchRegExp
());
if
(!
ListTools
.
isEmpty
(
list
)){
...
...
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java
浏览文件 @
e70f400d
...
...
@@ -4,6 +4,7 @@ import com.x.base.core.project.config.Config;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
com.x.base.core.project.tools.FileTools
;
import
com.x.base.core.project.tools.StringTools
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -17,33 +18,6 @@ import java.util.regex.Pattern;
abstract
class
BaseAction
extends
StandardJaxrsAction
{
protected
boolean
keywordMatch
(
String
keyword
,
String
content
,
Boolean
caseSensitive
,
Boolean
matchWholeWord
,
Boolean
matchRegExp
){
if
(
StringUtils
.
isBlank
(
keyword
)
||
StringUtils
.
isBlank
(
content
)){
return
false
;
}
if
(
BooleanUtils
.
isTrue
(
matchRegExp
)){
Pattern
pattern
=
Pattern
.
compile
(
keyword
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
else
if
(
BooleanUtils
.
isTrue
(
matchWholeWord
)){
if
(
BooleanUtils
.
isTrue
(
caseSensitive
))
{
Pattern
pattern
=
Pattern
.
compile
(
"\\b("
+
keyword
+
")\\b"
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
else
{
Pattern
pattern
=
Pattern
.
compile
(
"\\b("
+
keyword
+
")\\b"
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
return
matcher
.
find
();
}
}
else
{
if
(
BooleanUtils
.
isTrue
(
caseSensitive
))
{
return
(
content
.
indexOf
(
keyword
)
>
-
1
);
}
else
{
return
(
content
.
toLowerCase
().
indexOf
(
keyword
.
toLowerCase
())
>
-
1
);
}
}
}
protected
List
<
Integer
>
patternLines
(
String
id
,
String
keyword
,
String
content
,
Boolean
caseSensitive
,
Boolean
matchWholeWord
,
Boolean
matchRegExp
){
List
<
Integer
>
list
=
new
ArrayList
<>();
File
file
=
readFile
(
id
,
content
);
...
...
@@ -56,7 +30,7 @@ abstract class BaseAction extends StandardJaxrsAction {
byte
[]
bytes
=
tmp
.
getBytes
(
"ISO8859-1"
);
String
lineStr
=
new
String
(
bytes
);
if
(
StringUtils
.
isNotBlank
(
lineStr
)
&&
lineStr
.
length
()>=
keyword
.
length
()){
if
(
keywordMatch
(
keyword
,
lineStr
,
caseSensitive
,
matchWholeWord
,
matchRegExp
)){
if
(
StringTools
.
matchKeyword
(
keyword
,
lineStr
,
caseSensitive
,
matchWholeWord
,
matchRegExp
)){
list
.
add
(
curReadLine
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录