@Override public ModuleService getModule(Serializable moduleID) { Module module; if (moduleID instanceof Long) module = (Module) moduleEngine.getModule((Long) moduleID); else module = (Module) moduleEngine.getModule(moduleID.toString()); if (module == null) return null; SFTSystem mainSystem = (SFTSystem) moduleEngine.getSystem(module); // TableService mainDataTable = this.makeBizTable(mainSystem); DemsyModuleService ret = new DemsyModuleService(module, mainDataTable); // List<TableService> childrenDataTables = new ArrayList(); List<IBizField> fkFields = bizEngine.getFieldsOfSlave(mainSystem); for (IBizField fkField : fkFields) { SFTSystem fkSystem = (SFTSystem) fkField.getSystem(); DemsyEntityTableService bizTable = this.makeBizTable(fkSystem); childrenDataTables.add(bizTable); // 设置该子表通过哪个字段引用了主表? bizTable.set("fkfield", fkField.getPropName()); // TODO:应通过模块表达式来解析数据表对象,目前暂时不支持模块对数据表的引用表达式。 } ret.setChildrenDataTables(childrenDataTables); return ret; }
DemsyEntityManager(ModuleService m, TableService t) { moduleService = (DemsyModuleService) m; tableService = (DemsyEntityTableService) t; Module module = null; if (moduleService != null) { module = moduleService.getEntity(); if (tableService == null) tableService = (DemsyEntityTableService) moduleService.getTable(); } SFTSystem system = null; if (tableService != null) system = tableService.getEntity(); if (system == null && module != null) system = (SFTSystem) Demsy.moduleEngine.getSystem(module); bizManager = Demsy.bizManagerFactory.getManager(module, system); }
@Override public int save(Object entity, String opMode) { tableService.validateEntityData(opMode, entity); return bizManager.save(entity, opMode); }