Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
3d04044f
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
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,发现更多精彩内容 >>
提交
3d04044f
编写于
9月 20, 2022
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加item转文本
上级
dcd4808a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
100 addition
and
39 deletion
+100
-39
o2server/pom.xml
o2server/pom.xml
+9
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/dataitem/DataItemConverter.java
...va/com/x/base/core/entity/dataitem/DataItemConverter.java
+91
-39
未找到文件。
o2server/pom.xml
浏览文件 @
3d04044f
...
...
@@ -424,6 +424,10 @@
<groupId>
org.ldaptive
</groupId>
<artifactId>
ldaptive-jldap
</artifactId>
</dependency>
<dependency>
<groupId>
org.jsoup
</groupId>
<artifactId>
jsoup
</artifactId>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
...
...
@@ -1209,6 +1213,11 @@
<artifactId>
ldaptive-jldap
</artifactId>
<version>
1.3.1
</version>
</dependency>
<dependency>
<groupId>
org.jsoup
</groupId>
<artifactId>
jsoup
</artifactId>
<version>
1.15.3
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/dataitem/DataItemConverter.java
浏览文件 @
3d04044f
...
...
@@ -7,9 +7,15 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.function.UnaryOperator
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.jsoup.Jsoup
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
...
...
@@ -300,49 +306,11 @@ public class DataItemConverter<T extends DataItem> {
return
true
;
}
public
String
text
(
List
<
T
>
items
,
boolean
escapeNumber
,
boolean
escapeBoolean
,
boolean
escapeId
,
boolean
simplifyDistinguishedName
,
boolean
htmlToText
,
String
split
)
{
StringBuilder
builder
=
new
StringBuilder
();
this
.
sort
(
items
);
for
(
T
t
:
items
)
{
if
(
Objects
.
equals
(
t
.
getItemType
(),
ItemType
.
p
))
{
if
(
Objects
.
equals
(
t
.
getItemPrimitiveType
(),
ItemPrimitiveType
.
s
)
&&
StringUtils
.
isNotEmpty
(
t
.
getStringValue
()))
{
if
(
escapeId
&&
StringTools
.
isUUIDFormat
(
t
.
getStringValue
()))
{
continue
;
}
if
(
simplifyDistinguishedName
&&
OrganizationDefinition
.
isDistinguishedName
(
t
.
getStringValue
()))
{
builder
.
append
(
OrganizationDefinition
.
name
(
t
.
getStringValue
()));
builder
.
append
(
split
);
continue
;
}
if
(
htmlToText
)
{
builder
.
append
(
t
.
getStringValue
().
replaceAll
(
"(?s)<[^>]*>(\\s*<[^>]*>)*"
,
""
));
builder
.
append
(
split
);
continue
;
}
builder
.
append
(
t
.
getStringValue
());
}
if
(
Objects
.
equals
(
t
.
getItemPrimitiveType
(),
ItemPrimitiveType
.
b
)
&&
(
null
!=
t
.
getBooleanValue
())
&&
(!
escapeBoolean
))
{
builder
.
append
(
Objects
.
toString
(
t
.
getBooleanValue
()));
builder
.
append
(
split
);
}
if
(
Objects
.
equals
(
t
.
getItemPrimitiveType
(),
ItemPrimitiveType
.
n
)
&&
(
null
!=
t
.
getNumberValue
())
&&
(!
escapeNumber
))
{
builder
.
append
(
Objects
.
toString
(
t
.
getNumberValue
()));
builder
.
append
(
split
);
}
}
}
return
builder
.
toString
();
}
/**
* 此方法在item数据较大(>20000) 时由于双重循环导致运行时间较长( > 5000ms) 改为新的使用hashMap实现.<br>
* Thanks 李舟<lizhou@mochasoft.com.cn>
**/
public
List
<
T
>
subtract
(
List
<
T
>
l1
,
List
<
T
>
l2
)
throws
Exception
{
public
List
<
T
>
subtract
(
List
<
T
>
l1
,
List
<
T
>
l2
)
{
List
<
T
>
result
=
new
ArrayList
<>();
HashMap
<
Wrap
,
T
>
map
=
new
HashMap
<>();
for
(
T
t2
:
l2
)
{
...
...
@@ -428,4 +396,88 @@ public class DataItemConverter<T extends DataItem> {
return
true
;
}
}
public
static
class
ItemText
{
private
static
final
Predicate
<
DataItem
>
NUMBERPREDICATE
=
o
->
Objects
.
equals
(
ItemType
.
p
,
o
.
getItemType
())
&&
Objects
.
equals
(
ItemPrimitiveType
.
n
,
o
.
getItemPrimitiveType
());
public
static
final
Predicate
<
DataItem
>
BOOLEANPREDICATE
=
o
->
Objects
.
equals
(
ItemType
.
p
,
o
.
getItemType
())
&&
Objects
.
equals
(
ItemPrimitiveType
.
b
,
o
.
getItemPrimitiveType
());
public
static
final
Predicate
<
DataItem
>
STRINGPREDICATE
=
o
->
Objects
.
equals
(
ItemType
.
p
,
o
.
getItemType
())
&&
Objects
.
equals
(
ItemPrimitiveType
.
s
,
o
.
getItemPrimitiveType
());
public
static
final
UnaryOperator
<
String
>
ESCAPEIDFUNCTION
=
o
->
(
null
==
o
||
(
StringTools
.
UUID_REGEX
.
matcher
(
o
).
matches
()))
?
""
:
o
;
public
static
final
UnaryOperator
<
String
>
SIMPLIFYDISTINGUISHEDNAMEFUNCTION
=
o
->
OrganizationDefinition
.
isDistinguishedName
(
o
)
?
OrganizationDefinition
.
name
(
o
)
:
o
;
public
static
final
UnaryOperator
<
String
>
HTMLTOTEXTFUNCTION
=
o
->
Jsoup
.
parse
(
o
).
text
();
public
static
final
Function
<
DataItem
,
String
>
DATAITEMTOSTRINGFUNCTION
=
o
->
{
String
value
=
""
;
switch
(
o
.
getItemPrimitiveType
())
{
case
b:
if
(
null
!=
o
.
getBooleanValue
())
{
value
=
BooleanUtils
.
toStringTrueFalse
(
o
.
getBooleanValue
());
}
break
;
case
n:
if
(
null
!=
o
.
getNumberValue
())
{
value
=
Objects
.
toString
(
o
.
getNumberValue
());
}
break
;
default
:
value
=
o
.
getStringValue
();
}
return
value
;
};
public
static
String
text
(
List
<?
extends
DataItem
>
items
,
boolean
escapeNumber
,
boolean
escapeBoolean
,
boolean
escapeId
,
boolean
simplifyDistinguishedName
,
boolean
htmlToText
,
String
split
)
{
Predicate
<
DataItem
>
predicate
=
concretePredicate
(
escapeNumber
,
escapeBoolean
);
Function
<
String
,
String
>
function
=
concreteFunction
(
escapeId
,
simplifyDistinguishedName
,
htmlToText
);
return
items
.
stream
().
filter
(
predicate
).
map
(
DATAITEMTOSTRINGFUNCTION
).
map
(
function
)
.
filter
(
StringUtils:
:
isNotBlank
).
distinct
()
.
collect
(
Collectors
.
joining
(
StringUtils
.
isBlank
(
split
)
?
","
:
split
));
}
private
static
Predicate
<
DataItem
>
concretePredicate
(
boolean
escapeNumber
,
boolean
escapeBoolean
)
{
Predicate
<
DataItem
>
p
=
STRINGPREDICATE
;
if
(!
escapeNumber
)
{
p
.
or
(
NUMBERPREDICATE
);
}
if
(!
escapeBoolean
)
{
p
.
or
(
BOOLEANPREDICATE
);
}
return
p
;
}
private
static
Function
<
String
,
String
>
concreteFunction
(
boolean
escapeId
,
boolean
simplifyDistinguishedName
,
boolean
htmlToText
)
{
Function
<
String
,
String
>
f
=
StringUtils:
:
trim
;
if
(
escapeId
)
{
f
=
f
.
andThen
(
ESCAPEIDFUNCTION
);
}
if
(
simplifyDistinguishedName
)
{
f
=
f
.
andThen
(
SIMPLIFYDISTINGUISHEDNAMEFUNCTION
);
}
if
(
htmlToText
)
{
f
=
f
.
andThen
(
HTMLTOTEXTFUNCTION
);
}
return
f
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录