Skip to content

Commit

Permalink
Merge pull request #1 from WeBankPartners/master
Browse files Browse the repository at this point in the history
test
  • Loading branch information
xuxuzhesi authored Oct 9, 2019
2 parents d367382 + df80b0e commit eaf1492
Show file tree
Hide file tree
Showing 16 changed files with 2,435 additions and 1,359 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Java CI

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn --file cmdb-core/pom.xml clean package
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ WeCMDB具备以下特点:
包括权限管理(角色管理,用户角色管理, 数据权限, 菜单管理)。

## 快速入门
WeCMDB采用容器化部署
WeCMDB常规容器化部署

如何编译WeCMDB,请查看以下文档
[WeCMDB编译文档](cmdb-wiki/docs/install/wecmdb_compile_guide.md)
Expand All @@ -84,6 +84,10 @@ WeCMDB采用容器化部署。
[WeCMDB用户手册](cmdb-wiki/docs/manual/wecmdb_user_guide.md)

## 开发者文档
#### WeCMDB快速本地启动
[WeCMDB快速本地启动环境配置](cmdb-wiki/docs/developer/wecmdb_local_standalone_guide.md)

#### WeCMDB常规环境搭建
WeCMDB使用Java和React JS进行开发,数据存储于MySQL,并依赖Tomcat Web容器运行。

请参考以下文档进行开发环境配置[WeCMDB开发环境配置](cmdb-wiki/docs/developer/wecmdb_developer_guide.md)
Expand Down
2 changes: 1 addition & 1 deletion build/db/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cd `dirname $0`

rm -rf database

cp -r ../../cmdb-core/database database
cp -r ../../cmdb-core/src/main/resources/database database

cd database
for i in `ls -1 ./*.sql`; do
Expand Down
14 changes: 12 additions & 2 deletions cmdb-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
Expand Down Expand Up @@ -85,7 +86,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
<version>1.4.199</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
Expand Down Expand Up @@ -133,6 +134,10 @@
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -144,9 +149,14 @@
<groupId>org.easetech</groupId>
<artifactId>easytest</artifactId>
<version>0.6.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,13 @@ public List<Map<String, Object>> update(int ciTypeId, List<Map<String, Object>>

private Map<String, Object> doUpdate(EntityManager entityManager, int ciTypeId, Map<String, Object> ci, boolean enableStateTransition) {
DynamicEntityMeta entityMeta = getDynamicEntityMetaMap().get(ciTypeId);
Map<String, Object> convertedCi = MultiValueFeildOperationUtils.convertMultiValueFieldsForCICreation(entityManager, ciTypeId, ci, (String) ci.get(CmdbConstants.DEFAULT_FIELD_GUID), ciTypeAttrRepository, this);

String guid = convertedCi.get(GUID).toString();
String guid = ci.get(GUID).toString();
Object entityBean = validateCi(ciTypeId, guid, entityMeta, entityManager, ACTION_MODIFICATION);
DynamicEntityHolder entityHolder = new DynamicEntityHolder(entityMeta, entityBean);

ciDataInterceptorService.preUpdate(entityHolder, convertedCi);
ciDataInterceptorService.preUpdate(entityHolder, ci);
Map<String, Object> convertedCi = MultiValueFeildOperationUtils.convertMultiValueFieldsForCICreation(entityManager, ciTypeId, ci, (String) ci.get(CmdbConstants.DEFAULT_FIELD_GUID), ciTypeAttrRepository, this);
Map<String, Object> updatedMap = null;
if (onlyIncludeRefreshableFields(ciTypeId, convertedCi.keySet()) || !enableStateTransition) {
entityHolder.update(convertedCi, CmdbThreadLocal.getIntance().getCurrentUser(), entityManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -556,6 +557,23 @@ public void preUpdate(DynamicEntityHolder entityHolder, Map<String, Object> ci)
validateNotNullable(entityHolder, cloneCi);
validateUniqueFieldForUpdate(entityHolder.getEntityMeta().getCiTypeId(), ci);
validateRegularExpressionRule(entityHolder, cloneCi);
validateValueType(entityHolder, cloneCi);
}

private void validateValueType(DynamicEntityHolder entityHolder, Map cloneCi) {
List<AdmCiTypeAttr> attrs = ciTypeAttrRepository.findAllByCiTypeId(entityHolder.getEntityMeta().getCiTypeId());
attrs.forEach(attr -> {
String inputType = attr.getInputType();
String name = attr.getPropertyName();
Object value = cloneCi.get(name);
if(value != null) {
if(value instanceof Collection) {
if(!(InputType.MultRef.getCode().equals(inputType) || InputType.MultSelDroplist.getCode().equals(inputType))) {
throw new InvalidArgumentException(String.format("Field [%s] shold not be list.",name));
}
}
}
});
}

// can not update not editable field
Expand Down
31 changes: 31 additions & 0 deletions cmdb-core/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
server:
port: 9080
address: localhost

spring:
datasource:
platform: H2
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:cmdb;MODE=MYSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=true;MV_STORE=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS wecmdb_dev\;SET SCHEMA wecmdb_dev
username: sa
password:
schema: classpath:/database/01.cmdb.schema.sql
data:
- classpath:/database/02.cmdb.system.data.sql
- classpath:/local/03.cmdb.system.data.files.h2.sql
- classpath:/database/04.cmdb.experience.data.sql
sql-script-encoding: utf-8

jpa:
database: MySQL
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
show-sql: false
hibernate:
ddl-auto: none

cmdb:
datasource:
schema: wecmdb_dev
security:
enabled: false
whitelist-ip-address: localhost
Loading

0 comments on commit eaf1492

Please sign in to comment.