package foundation.data.meta.template;
|
|
import foundation.data.entity.Entity;
|
import foundation.data.entity.EntitySet;
|
import foundation.data.meta.field.FieldsRuntime;
|
import foundation.data.object.DataObject;
|
import foundation.util.MapList;
|
|
public class TemplateLoader {
|
|
|
public static void reloadTemplateAndIndex(PropertyTemplateBucket templateBucket) throws Exception {
|
//1. 加载Field和Property模板
|
reloadTemplate(templateBucket);
|
|
//2.加载Property Index 设置
|
reloadIndex(templateBucket);
|
}
|
|
public static void reloadTemplate(PropertyTemplateBucket templateBucket) throws Exception {
|
MapList<String, PropertyTemplate> templates = new MapList<String, PropertyTemplate>();
|
|
//1. 加载数据库
|
DataObject propertyObject = DataObject.getInstance("sys_data_field_template");
|
EntitySet entitySet = propertyObject.getTableEntitySet();
|
|
//2. 加载到内存
|
for (Entity entity: entitySet) {
|
PropertyTemplate template = new PropertyTemplate();
|
template.load(entity);
|
|
templates.add(template.getFieldName(), template);
|
}
|
|
//3.
|
templateBucket.setTemplateItems(templates);
|
}
|
|
public static void reloadIndex(PropertyTemplateBucket templateBucket) throws Exception {
|
//1. 清空历史
|
templateBucket.clearIndex();
|
|
//2. 加载数据库
|
DataObject propertyObject = DataObject.getInstance("sys_data_property_memo");
|
EntitySet entitySet = propertyObject.getTableEntitySet();
|
|
//3. 加载到内存
|
String fieldName; boolean list, form, exportable, importable, scene, capacity, user;
|
|
for (Entity entity: entitySet) {
|
fieldName = entity.getString("field_name");
|
list = entity.getBoolean("is_list", false);
|
form = entity.getBoolean("is_form", false);
|
exportable = entity.getBoolean("is_exportable", false);
|
importable = entity.getBoolean("is_importable", false);
|
scene = entity.getBoolean("is_scene", false);
|
capacity = entity.getBoolean("is_capacity", false);
|
user = entity.getBoolean("is_user", false);
|
|
templateBucket.loadOneIndex(fieldName, list, form, exportable, importable, scene, capacity, user);
|
}
|
|
//4. 编译Index
|
DataObject dataObject = DataObject.getInstance("sys_data_property");
|
FieldsRuntime fields = dataObject.getTableFieldMetas();
|
templateBucket.build(fields);
|
}
|
|
}
|