Skip to content

Commit

Permalink
Fix 3.4.6 (#675)
Browse files Browse the repository at this point in the history
* fix: auto-fillin

* fix: default-value for tag

* fix: 多引用高级查询

* v3.4.6
  • Loading branch information
getrebuild authored Nov 3, 2023
1 parent bc57779 commit dba501d
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 32 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e59cdd to 0f5ad7
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.4.5</version>
<version>3.4.6</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<!-- UNCOMMENT USE TOMCAT -->
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/rebuild/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.rebuild.core.support.License;
import com.rebuild.core.support.RebuildConfiguration;
import com.rebuild.core.support.i18n.Language;
import com.rebuild.core.support.setup.DataMigrator;
import com.rebuild.core.support.setup.DatabaseFixer;
import com.rebuild.core.support.setup.Installer;
import com.rebuild.core.support.setup.UpgradeDatabase;
import com.rebuild.utils.JSONable;
Expand Down Expand Up @@ -73,11 +73,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.4.5";
public static final String VER = "3.4.6";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3040510;
public static final int BUILD = 3040611;

static {
// Driver for DB
Expand Down Expand Up @@ -249,7 +249,7 @@ public static boolean init() throws Exception {

License.isRbvAttached();

DataMigrator.dataMigrateIfNeed();
DatabaseFixer.fixIfNeed();

return true;
}
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/rebuild/core/metadata/easymeta/EasyTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import cn.devezhao.persist4j.Field;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.support.general.TagSupport;
import com.rebuild.core.metadata.impl.EasyFieldConfigProps;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;

/**
* @author Zixin
* @since 2022/12/12
Expand Down Expand Up @@ -45,7 +49,15 @@ public Object convertCompatibleValue(Object value, EasyField targetField) {

@Override
public Object exprDefaultValue() {
return TagSupport.getDefaultValue(this);
JSONArray tagList = getExtraAttrs(true).getJSONArray(EasyFieldConfigProps.TAG_LIST);
if (tagList == null || tagList.isEmpty()) return null;

List<String> dv = new ArrayList<>();
for (Object o : tagList) {
JSONObject tag = (JSONObject) o;
if (tag.getBooleanValue("default")) dv.add(tag.getString("name"));
}
return dv.isEmpty() ? null : dv.toArray(new String[0]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,52 @@
import org.apache.commons.lang.BooleanUtils;

/**
* 数据库修订
*
* @author devezhao
* @since 2021/11/18
*/
@Slf4j
public class DataMigrator {
public class DatabaseFixer {

private static final String KEY_41 = "DataMigratorV41";
private static final String KEY_346 = "DatabaseFixerV346";

/**
* 辅助数据库升级
*/
public static void dataMigrateIfNeed() {
if (RebuildConfiguration.getInt(ConfigurationItem.DBVer) == 41
&& !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_41))) {
log.info("Data migrating #41 ...");
public static void fixIfNeed() {
final int dbVer = RebuildConfiguration.getInt(ConfigurationItem.DBVer);

if (dbVer == 41 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_41))) {
log.info("Database fixing `#41` ...");
ThreadPool.exec(() -> {
try {
v41();
fixV41();
KVStorage.setCustomValue(KEY_41, "true");
log.info("Data migrated #41 all succeeded");
log.info("Database fixed `#41` all succeeded");
} catch (Exception ex) {
log.error("Database fixing `#41` failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
}
});
}

if (dbVer <= 52 && !BooleanUtils.toBoolean(KVStorage.getCustomValue(KEY_346))) {
log.info("Database fixing `V346` ...");
ThreadPool.exec(() -> {
try {
fixV346();
KVStorage.setCustomValue(KEY_346, "true");
log.info("Database fixed `V346` all succeeded");
} catch (Exception ex) {
log.error("Data migrating #41 failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
log.error("Database fixing `V346` failed : {}", ThrowableUtils.getRootCause(ex).getLocalizedMessage());
}
});
}
}

// #41 多引用字段改为三方表
private static void v41() {
// #41:多引用字段改为三方表
private static void fixV41() {
for (Entity entity : MetadataHelper.getEntities()) {
if (EasyMetaFactory.valueOf(entity).isBuiltin()) continue;

Expand Down Expand Up @@ -87,7 +104,29 @@ private static void v41() {
}

if (count > 0) {
log.info("Data migrated #41 : {} > {}", entity.getName(), count);
log.info("Database fixed `#41` : {} > {}", entity.getName(), count);
}
}
}

// V346:标签无效值问题
private static void fixV346() {
for (Entity entity : MetadataHelper.getEntities()) {
if (EasyMetaFactory.valueOf(entity).isBuiltin()) continue;

Field[] tagFields = MetadataSorter.sortFields(entity, DisplayType.TAG);
if (tagFields.length == 0) continue;

int count = 0;
for (Field field : tagFields) {
String usql = String.format(
"update `%s` set `%s` = NULL where `%s` like '[Ljava.lang.String;@%%'",
entity.getPhysicalName(), field.getPhysicalName(), field.getPhysicalName());
count += Application.getSqlExecutor().execute(usql, 120);
}

if (count > 0) {
log.info("Database fixed `V346` : {} > {}", entity.getName(), count);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/web/assets/js/metadata/auto-fillin.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ class DlgRuleEdit extends RbFormHandler {
}
})
this.setState({ targetFields: targetFields }, () => {
if (targetFields.length > 0) this.__select2[0].val(targetFields[0].name)
if (targetFields.length > 0) {
this.__select2[0].val(targetFields[0].name).trigger('change')
}
})
}

Expand Down
27 changes: 16 additions & 11 deletions src/main/resources/web/assets/js/rb-advfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ class AdvFilter extends React.Component {
// 例如原名称字段为日期,其设置的过滤条件也是日期相关的,修改成文本后可能出错

if (['REFERENCE', 'N2NREFERENCE'].includes(item.type)) {
REFENTITY_CACHE[`${this.props.entity}.${item.name}`] = item.ref
REFENTITY_CACHE[item.name] = item.ref
if ('N2NREFERENCE' === item.type) REFENTITY_CACHE[item.name]._n2n = true

// NOTE: Use `NameField` field-type
if (!BIZZ_ENTITIES.includes(item.ref[0])) {
Expand All @@ -157,13 +158,15 @@ class AdvFilter extends React.Component {
if (item.type === 'REFERENCE' && item.name === 'approvalLastUser') {
const item2 = { ...item, name: VF_ACU, label: $L('当前审批人') }
validFs.push(item2.name)
REFENTITY_CACHE[`${this.props.entity}.${item2.name}`] = item2.ref
REFENTITY_CACHE[item2.name] = item2.ref
fields.push(item2)
}
}
})
this._fields = fields

console.log(REFENTITY_CACHE)

// init
if (this.__initItems) {
this.__initItems.forEach((item) => {
Expand Down Expand Up @@ -551,9 +554,9 @@ class FilterItem extends React.Component {
// 引用 User/Department/Role/Team
isBizzField(entity) {
if (this.state.type === 'REFERENCE') {
const ref = REFENTITY_CACHE[`${this._searchEntity}.${this.state.field}`]
if (entity) return ref[0] === entity
else return BIZZ_ENTITIES.includes(ref[0])
const ifRefField = REFENTITY_CACHE[this.state.field]
if (entity) return ifRefField[0] === entity
else return BIZZ_ENTITIES.includes(ifRefField[0])
}
return false
}
Expand Down Expand Up @@ -635,9 +638,9 @@ class FilterItem extends React.Component {
}

if (this.isBizzField()) {
let ref = REFENTITY_CACHE[`${this._searchEntity}.${state.field}`]
ref = state.op === 'SFT' ? 'Team' : ref[0]
this.renderBizzSearch(ref)
let ifRefField = REFENTITY_CACHE[state.field]
ifRefField = state.op === 'SFT' ? 'Team' : ifRefField[0]
this.renderBizzSearch(ifRefField)
} else if (lastType === 'REFERENCE') {
this.removeBizzSearch()
}
Expand Down Expand Up @@ -902,9 +905,11 @@ class FilterItem extends React.Component {
if (s.value2) item.value2 = s.value2

// 引用字段查询名称字段
const isRefField = REFENTITY_CACHE[`${this._searchEntity}.${s.field}`]
if (isRefField && !BIZZ_ENTITIES.includes(isRefField[0])) {
if (!(s.op === 'NL' || s.op === 'NT')) {
const ifRefField = REFENTITY_CACHE[s.field]
if (ifRefField && !(s.op === 'NL' || s.op === 'NT')) {
if (BIZZ_ENTITIES.includes(ifRefField[0])) {
if (ifRefField._n2n) item.field = NAME_FLAG + item.field
} else {
item.field = NAME_FLAG + item.field
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/rb-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ class RbFormTextarea extends RbFormElement {

setValue(val) {
super.setValue(val)
if (this.props.useMdedit) this._SimpleMDE.value(val)
if (this.props.useMdedit) this._SimpleMDE.value(val || '')
}

_initMde() {
Expand Down

0 comments on commit dba501d

Please sign in to comment.