Search in sources :

Example 1 with MetaSchemaGenerator

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;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) MetaSchemaGenerator(com.rebuild.core.rbstore.MetaSchemaGenerator) ID(cn.devezhao.persist4j.engine.ID) MetaschemaImporter(com.rebuild.core.rbstore.MetaschemaImporter)

Example 2 with MetaSchemaGenerator

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);
    }
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) CopyEntity(com.rebuild.core.metadata.impl.CopyEntity) Entity(cn.devezhao.persist4j.Entity) MetaSchemaGenerator(com.rebuild.core.rbstore.MetaSchemaGenerator) File(java.io.File)

Aggregations

MetaSchemaGenerator (com.rebuild.core.rbstore.MetaSchemaGenerator)2 Entity (cn.devezhao.persist4j.Entity)1 ID (cn.devezhao.persist4j.engine.ID)1 JSONObject (com.alibaba.fastjson.JSONObject)1 EasyEntity (com.rebuild.core.metadata.easymeta.EasyEntity)1 CopyEntity (com.rebuild.core.metadata.impl.CopyEntity)1 MetaschemaImporter (com.rebuild.core.rbstore.MetaschemaImporter)1 File (java.io.File)1