This commit is contained in:
devezhao-mbp 2020-05-15 01:45:09 +08:00
parent 5055d5ee98
commit b58220c0c9
4 changed files with 29 additions and 49 deletions

View file

@ -1,19 +1,8 @@
/*
rebuild - Building your business-systems freely.
Copyright (C) 2018 devezhao <zhaofang123@gmail.com>
Copyright (c) REBUILD <https://getrebuild.com/> and its owners. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
package com.rebuild.server;
@ -49,6 +38,7 @@ import java.util.List;
*/
public final class ServerStatus {
private static long LastCheckTime = 0;
private static final List<Status> LAST_STATUS = new ArrayList<>();
/**
@ -57,6 +47,11 @@ public final class ServerStatus {
* @return
*/
public static List<Status> getLastStatus() {
// 60 秒缓存
if (System.currentTimeMillis() - LastCheckTime > 60 * 1000) {
checkAll();
}
synchronized (LAST_STATUS) {
return Collections.unmodifiableList(LAST_STATUS);
}
@ -92,7 +87,8 @@ public final class ServerStatus {
LAST_STATUS.clear();
LAST_STATUS.addAll(last);
}
return isStatusOK();
LastCheckTime = System.currentTimeMillis();
return isStatusOK();
}
/**

View file

@ -93,16 +93,22 @@ public class TestSupport {
}
String fieldName = dt.name().toUpperCase();
if (dt == DisplayType.DATE) fieldName = "DATE1"; // Black
if (dt == DisplayType.REFERENCE) {
new Field2Schema(UserService.ADMIN_USER).createField(testEntity, fieldName, dt, null, entityName, null);
new Field2Schema(UserService.ADMIN_USER)
.createField(testEntity, fieldName, dt, null, entityName, null);
} else if (dt == DisplayType.CLASSIFICATION) {
JSON area = JSON.parseObject("{classification:'018-0000000000000001'}");
new Field2Schema(UserService.ADMIN_USER).createField(testEntity, fieldName, dt, null, entityName, area);
new Field2Schema(UserService.ADMIN_USER)
.createField(testEntity, fieldName, dt, null, entityName, area);
} else if (dt == DisplayType.STATE) {
JSON area = JSON.parseObject("{stateClass:'com.rebuild.server.helper.state.HowtoState'}");
new Field2Schema(UserService.ADMIN_USER).createField(testEntity, fieldName, dt, null, entityName, area);
new Field2Schema(UserService.ADMIN_USER)
.createField(testEntity, fieldName, dt, null, entityName, area);
} else {
new Field2Schema(UserService.ADMIN_USER).createField(testEntity, fieldName, dt, null, null, null);
new Field2Schema(UserService.ADMIN_USER)
.createField(testEntity, fieldName, dt, null, null, null);
}
}
}

View file

@ -1,19 +1,8 @@
/*
rebuild - Building your business-systems freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
Copyright (c) REBUILD <https://getrebuild.com/> and its owners. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
package com.rebuild.server.configuration;
@ -51,7 +40,7 @@ public class AutoFillinManagerTest extends TestSupportWithUser {
System.out.println(
AutoFillinManager.instance.conversionCompatibleValue(test.getField("datetime"), textField, CalendarUtils.now()));
System.out.println(
AutoFillinManager.instance.conversionCompatibleValue(test.getField("datetime"), test.getField("date"), CalendarUtils.now()));
AutoFillinManager.instance.conversionCompatibleValue(test.getField("datetime"), test.getField("date1"), CalendarUtils.now()));
}
@Test

View file

@ -1,19 +1,8 @@
/*
rebuild - Building your business-systems freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
Copyright (c) REBUILD <https://getrebuild.com/> and its owners. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
rebuild is dual-licensed under commercial and open source licenses (GPLv3).
See LICENSE and COMMERCIAL in the project root for license information.
*/
package com.rebuild.server.metadata;
@ -30,7 +19,7 @@ public class DefaultValueHelperTest extends TestSupport {
@Test
public void testExprDefaultValue() throws Exception {
Field dateField = MetadataHelper.getField(TEST_ENTITY, "date");
Field dateField = MetadataHelper.getField(TEST_ENTITY, "DATE1");
System.out.println(DefaultValueHelper.exprDefaultValue(dateField, "{NOW}"));
System.out.println(DefaultValueHelper.exprDefaultValue(dateField, "{NOW - 1H}"));
System.out.println(DefaultValueHelper.exprDefaultValue(dateField, "{NOW + 1M}"));