package foundation.data.meta.template;
|
|
import foundation.data.meta.MetaMonitor;
|
import foundation.data.meta.field.FieldsRuntime;
|
import foundation.persist.source.NamedDataSource;
|
import foundation.util.MapList;
|
|
public class PropertyTemplateBucket {
|
|
private static PropertyTemplateBucket instance;
|
private MapList<String, PropertyTemplate> templates;
|
private Indexes defaultIndexes;
|
private Indexes sceneIndexes;
|
private Indexes capacityIndexes;
|
private Indexes userIndexes;
|
private MetaMonitor indexMonitor;
|
private MetaMonitor templateAndIndexMonitor;
|
|
|
private PropertyTemplateBucket() {
|
try {
|
templates = new MapList<String, PropertyTemplate>();
|
|
defaultIndexes = new Indexes();
|
sceneIndexes = new Indexes();
|
capacityIndexes = new Indexes();
|
userIndexes = new Indexes();
|
|
NamedDataSource datasource = NamedDataSource.getInstance();
|
indexMonitor = new MetaMonitor(datasource, "getPropertyIndexLastUpdateTime");
|
templateAndIndexMonitor = new MetaMonitor(datasource, "getTemplateAndIndexLastUpdateTime");
|
}
|
catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
public static synchronized PropertyTemplateBucket getInstance() {
|
if (instance == null) {
|
instance = new PropertyTemplateBucket();
|
}
|
|
return instance;
|
}
|
|
public void loadTemplateAndIndex() throws Exception {
|
//1. 加载Field和Property模板
|
TemplateLoader.reloadTemplate(this);
|
|
//2.加载Property Index 设置
|
TemplateLoader.reloadIndex(this);
|
}
|
|
public void reloadIndex() throws Exception {
|
TemplateLoader.reloadIndex(this);
|
}
|
|
public void build(FieldsRuntime fields) {
|
defaultIndexes.build(fields);
|
sceneIndexes.build(fields);
|
capacityIndexes.build(fields);
|
userIndexes.build(fields);
|
}
|
|
public void loadOneIndex(String fieldName, boolean list, boolean form, boolean exportable, boolean importable, boolean scene, boolean capacity, boolean user) {
|
defaultIndexes.loadOne(fieldName, list, form, exportable, importable);
|
|
if (scene) {
|
sceneIndexes.loadOne(fieldName, list, form, exportable, importable);
|
}
|
|
if (capacity) {
|
capacityIndexes.loadOne(fieldName, list, form, exportable, importable);
|
}
|
|
if (user) {
|
userIndexes.loadOne(fieldName, list, form, exportable, importable);
|
}
|
}
|
|
public Indexes getDefaultIndexes() {
|
return defaultIndexes;
|
}
|
|
public Indexes getSceneIndexes() {
|
return sceneIndexes;
|
}
|
|
public Indexes getCapacityIndexes() {
|
return capacityIndexes;
|
}
|
|
public Indexes getUserIndexes() {
|
return userIndexes;
|
}
|
|
public PropertyTemplate getOneTemplate(String fieldName) {
|
return templates.get(fieldName);
|
}
|
|
public void setTemplateItems(MapList<String, PropertyTemplate> templates) {
|
this.templates = templates;
|
}
|
|
public void clearIndex() {
|
defaultIndexes.clear();
|
sceneIndexes.clear();
|
capacityIndexes.clear();
|
userIndexes.clear();
|
}
|
|
public MetaMonitor getIndexMonitor() {
|
return indexMonitor;
|
}
|
|
public MetaMonitor getTemplateAndIndexMonitor() {
|
return templateAndIndexMonitor;
|
}
|
}
|