use of com.rebuild.core.rbstore.MetaSchemaGenerator in project rebuild by getrebuild.
the class CopyEntity method copy.
/**
* @param entityName
* @param detailName
* @return
*/
public String copy(String entityName, String detailName) {
final ID user = getUser();
RbAssert.isAllow(UserHelper.isSuperAdmin(user), Language.L("仅超级管理员可操作"));
// 导出
JSONObject schemadata = (JSONObject) new MetaSchemaGenerator(sourceEntity).generate();
String uniqueEntityName = clearConfig(schemadata, entityName);
JSONObject detailSchema = schemadata.getJSONObject("detail");
if (StringUtils.isBlank(detailName)) {
schemadata.remove("detail");
} else if (detailSchema != null) {
clearConfig(detailSchema, detailName);
}
// 导入
MetaschemaImporter importer = new MetaschemaImporter(schemadata);
importer.setUser(user);
TaskExecutors.run(importer);
return uniqueEntityName;
}
use of com.rebuild.core.rbstore.MetaSchemaGenerator in project rebuild by getrebuild.
the class MetaEntityController method entityExport.
@GetMapping("entity/entity-export")
public void entityExport(HttpServletRequest request, HttpServletResponse response) throws IOException {
final Entity entity = getEntityById(getIdParameterNotNull(request, "id"));
File dest = RebuildConfiguration.getFileOfTemp("schema-" + entity.getName() + ".json");
if (dest.exists())
FileUtils.deleteQuietly(dest);
new MetaSchemaGenerator(entity).generate(dest);
if (ServletUtils.isAjaxRequest(request)) {
writeSuccess(response, JSONUtils.toJSONObject("file", dest.getName()));
} else {
FileDownloader.downloadTempFile(response, dest, null);
}
}
Aggregations