P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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);
    }
 
}