Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
36744792
提交
36744792
编写于
9月 03, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tableschema 接口,模型刷新
上级
5ad47856
变更
11
展开全部
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
672 行增加
和
238 行删除
+672
-238
pom.xml
ibzdata-core/pom.xml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+2
-2
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+50
-27
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+1
-1
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+1
-1
DataResource.java
...src/main/java/cn/ibizlab/core/data/rest/DataResource.java
+11
-4
PersistentResource.java
...in/java/cn/ibizlab/core/data/rest/PersistentResource.java
+354
-0
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+243
-157
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+1
-43
DbPersistentServiceImpl.java
...izlab/core/data/service/impl/DbPersistentServiceImpl.java
+4
-1
MongoPersistentServiceImpl.java
...ab/core/data/service/impl/MongoPersistentServiceImpl.java
+4
-1
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
36744792
...
...
@@ -175,7 +175,7 @@
<dependency>
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.2.
7
</version>
<version>
1.2.
9
</version>
<exclusions>
<exclusion>
<artifactId>
slf4j-simple
</artifactId>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
36744792
...
...
@@ -216,8 +216,8 @@ public class DOModel implements Serializable {
{
return
poSchemas
.
get
(
name
);
}
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
);
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equals
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
.
toLowerCase
()
);
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equals
IgnoreCase
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
return
poSchemas
.
get
(
vendorProvider
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
36744792
...
...
@@ -88,6 +88,7 @@ public class DynamicModelService {
psModelService
.
setPSModelFolderPath
(
strPSModelFolderPath
);
try
{
iPSSystem
=
psModelService
.
getPSSystem
();
if
(
iPSSystem
==
null
)
throw
new
BadRequestAlertException
(
"加载系统模型错误"
,
"DynamicSystem"
,
system
);
dynamicSystems
.
put
(
system
,
iPSSystem
);
...
...
@@ -252,10 +253,13 @@ public class DynamicModelService {
if
(
defield
.
isLinkDEField
()
&&
defield
instanceof
IPSLinkDEField
)
{
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
metaFieldModel
.
setRefFieldId
(
linkDEField
.
getRelatedPSDEField
().
getId
())
.
setRefFieldName
(
linkDEField
.
getRelatedPSDEField
().
getName
()).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
String
relfieldname
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
relfieldcodename
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
linkDEField
.
getRelatedPSDEField
();
metaFieldModel
.
setRefFieldId
(
relfieldcodename
)
.
setRefFieldName
(
relfieldname
).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
.
setRelationName
(
linkDEField
.
getPSDER
().
getName
()).
setRelationCodeName
(
linkDEField
.
getPSDER
().
getCodeName
()).
setRefEntityName
(
linkDEField
.
getPSDER
().
getMajorPSDataEntity
().
getName
())
.
setRefFieldCodeName
(
linkDEField
.
getRelatedPSDEField
().
getCodeName
()
);
.
setRefFieldCodeName
(
relfieldcodename
);
}
if
(!
ObjectUtils
.
isEmpty
(
defield
.
getAllPSDEFSearchModes
()))
...
...
@@ -309,8 +313,10 @@ public class DynamicModelService {
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
relfieldname
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
()
);
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
relfieldname
);
metaRel
.
addLookup
(
lookupModel
);
}
...
...
@@ -340,8 +346,10 @@ public class DynamicModelService {
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
relfieldname
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
()
);
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
relfieldname
);
metaRel
.
addLookup
(
lookupModel
);
}
...
...
@@ -671,34 +679,49 @@ public class DynamicModelService {
return
initDynamicSystem
(
system
.
getPssystemid
(),
system
.
getDynamicModelPath
());
}
public
Map
<
String
,
Map
<
String
,
Long
>
>
getAllDynamicModelVersion
()
public
synchronized
Map
<
String
,
Long
>
getAllDynamicModelVersion
()
{
Map
<
String
,
Map
<
String
,
Long
>>
ret
=
new
LinkedHashMap
<>();
Set
<
String
>
set
=
new
HashSet
<>();
Map
<
String
,
Long
>
ret
=
new
LinkedHashMap
<>();
this
.
findAllDynamicModel
().
values
().
forEach
(
dstSystemModel
->
{
if
(
ret
.
containsKey
(
dstSystemModel
.
getPssystemid
()))
if
(
set
.
contains
(
dstSystemModel
.
getPssystemid
()))
return
;
ret
.
putAll
(
getDynamicModelVersion
(
dstSystemModel
));
});
return
ret
;
}
public
synchronized
Map
<
String
,
Long
>
getDynamicModelVersion
(
String
system
)
{
DstSystemModel
dstSystemModel
=
this
.
findAllDynamicModel
().
get
(
system
);
if
(
dstSystemModel
==
null
)
return
getDynamicModelVersion
(
dstSystemModel
);
return
new
LinkedHashMap
<>();
}
public
synchronized
Map
<
String
,
Long
>
getDynamicModelVersion
(
DstSystemModel
dstSystemModel
)
{
if
((!
systemModifyMap
.
containsKey
(
dstSystemModel
.
getPssystemid
()))||
systemModifyMap
.
get
(
dstSystemModel
.
getPssystemid
())<
dstSystemModel
.
getLastModify
())
{
reloadDynamicSystem
(
dstSystemModel
);
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
());
if
(!
dstSystemModel
.
getPssystemid
().
equals
(
dstSystemModel
.
getPssystemid
().
toLowerCase
()))
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
().
toLowerCase
());
reloadDynamicSystem
(
dstSystemModel
);
}
systemModifyMap
.
put
(
dstSystemModel
.
getPssystemid
(),
dstSystemModel
.
getLastModify
());
Map
<
String
,
Long
>
entities
=
new
LinkedHashMap
<>();
ret
.
put
(
dstSystemModel
.
getPssystemid
(),
entities
);
try
{
this
.
getEntities
(
dstSystemModel
.
getPssystemid
()).
values
().
forEach
(
metaEntityModel
->
{
if
(
entities
.
containsKey
(
metaEntityModel
.
getEntityName
()))
String
key
=
dstSystemModel
.
getPssystemid
().
concat
(
"."
).
concat
(
metaEntityModel
.
getEntityName
());
if
(
entities
.
containsKey
(
key
))
return
;
entities
.
put
(
metaEntityModel
.
getEntityName
()
,
dstSystemModel
.
getLastModify
());
entities
.
put
(
key
,
dstSystemModel
.
getLastModify
());
});
}
catch
(
Exception
exception
)
{
}
});
return
ret
;
return
entities
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
36744792
...
...
@@ -846,7 +846,7 @@ public class POSchema {
File
dir
=
path
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
)
,
StandardOpenOption
.
CREATE
);
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchema"
,
path
.
toString
());
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
36744792
...
...
@@ -514,7 +514,7 @@ public class PojoSchema {
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
)
,
StandardOpenOption
.
CREATE
);
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"PojoSchema"
,
path
.
toString
());
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/DataResource.java
浏览文件 @
36744792
...
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.FilterData;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -35,6 +36,10 @@ public class DataResource
@Autowired
public
IDataService
dataService
;
@Autowired
public
ModelService
modelService
;
@ApiOperation
(
value
=
"callMethod数据"
,
tags
=
{
"数据"
},
notes
=
"callMethod数据"
)
@RequestMapping
(
method
=
{
RequestMethod
.
GET
},
value
=
{
"/{entity}/call{method}"
,
"/{entity}/{key}/call{method}"
})
public
ResponseEntity
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
...
...
@@ -423,10 +428,9 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestParam
Map
map
)
{
FilterData
context
=
FilterData
.
fromContext
(
map
);
return
doSelect
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
dataquery
,
context
);
return
doSelect
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
context
);
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,POST,返回body<list>+header<page,total>"
)
...
...
@@ -439,7 +443,6 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
context
.
addParent
(
parentEntity
,
parentKey
).
addParent
(
parentEntity2
,
parentKey2
);
...
...
@@ -601,7 +604,11 @@ public class DataResource
.
body
(
new
PageImpl
(
baseDatas
.
getContent
(),
context
.
getPageable
(),
baseDatas
.
getTotalElements
()));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/reload"
})
public
ResponseEntity
<
Boolean
>
reload
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
systemId
)
{
modelService
.
refreshDynamicModel
(
systemId
);
return
ResponseEntity
.
ok
(
true
);
}
@Value
(
"${ibiz.enablePermissionValid:false}"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/PersistentResource.java
0 → 100644
浏览文件 @
36744792
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
36744792
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
36744792
...
...
@@ -74,49 +74,9 @@ public class DOModelServiceImpl implements IDOModelService {
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
entity
=
args
[
2
];
Path
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
try
{
String
entityId
=
modelService
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
if
(
StringUtils
.
isEmpty
(
entityId
))
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
if
(!
key
.
equals
(
entityId
))
{
args
=
entityId
.
split
(
"[.]"
);
system
=
args
[
0
];
entity
=
args
[
2
];
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
}
}
catch
(
Exception
exception
)
{
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
}
}
if
(!
Files
.
exists
(
storePath
))
if
(
Files
.
exists
(
storePath
))
{
doModel
=
modelService
.
loadDOModel
(
system
,
entity
);
schema
=
doModel
.
getSchema
();
if
(
schema
!=
null
)
{
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"repository"
,
doModel
.
getName
()+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
}
}
else
{
doModel
=
new
DOModel
();
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
{
...
...
@@ -132,8 +92,6 @@ public class DOModelServiceImpl implements IDOModelService {
}
}
}
if
(
schema
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbPersistentServiceImpl.java
浏览文件 @
36744792
...
...
@@ -7,6 +7,7 @@ import cn.ibizlab.core.data.model.DSLink;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IPersistentService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -34,6 +35,8 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Autowired
private
DbDataMapper
repository
;
@Autowired
private
ModelService
modelService
;
@Override
public
BaseData
create
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
,
boolean
bGet
)
{
...
...
@@ -345,6 +348,6 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Override
public
POSchema
getSchema
(
DSLink
link
,
String
system
,
String
table
)
{
return
null
;
return
modelService
.
getPOSchema
(
system
,
table
,
link
.
getType
())
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoPersistentServiceImpl.java
浏览文件 @
36744792
...
...
@@ -7,6 +7,7 @@ import cn.ibizlab.core.data.model.POSchema;
import
cn.ibizlab.core.data.repository.MongoDataRepository
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IPersistentService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +29,8 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Autowired
private
MongoDataRepository
repository
;
@Autowired
private
ModelService
modelService
;
@Override
public
BaseData
create
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
,
boolean
bGet
)
{
...
...
@@ -251,6 +254,6 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Override
public
POSchema
getSchema
(
DSLink
link
,
String
system
,
String
table
)
{
return
null
;
return
modelService
.
getPOSchema
(
system
,
table
,
link
.
getType
())
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录