Search in sources :

Example 6 with Entity2Schema

use of com.rebuild.core.metadata.impl.Entity2Schema in project rebuild by getrebuild.

the class MetaschemaImporterTest method testImport.

@Test
void testImport() throws Exception {
    File file = ResourceUtils.getFile("classpath:metaschema-test.json");
    String text = FileUtils.readFileToString(file, "utf-8");
    JSONObject data = JSON.parseObject(text);
    String entityName = data.getString("entity");
    if (MetadataHelper.containsEntity(entityName)) {
        new Entity2Schema(UserService.ADMIN_USER).dropEntity(MetadataHelper.getEntity(entityName), true);
    }
    MetaschemaImporter importer = new MetaschemaImporter(data);
    TaskExecutors.run((HeavyTask<?>) importer.setUser(UserService.ADMIN_USER));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Entity2Schema(com.rebuild.core.metadata.impl.Entity2Schema) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Entity2Schema (com.rebuild.core.metadata.impl.Entity2Schema)6 Entity (cn.devezhao.persist4j.Entity)5 JSONObject (com.alibaba.fastjson.JSONObject)4 Field (cn.devezhao.persist4j.Field)2 EasyEntity (com.rebuild.core.metadata.easymeta.EasyEntity)2 CopyEntity (com.rebuild.core.metadata.impl.CopyEntity)2 Field2Schema (com.rebuild.core.metadata.impl.Field2Schema)2 MetadataModificationException (com.rebuild.core.metadata.impl.MetadataModificationException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Record (cn.devezhao.persist4j.Record)1 ID (cn.devezhao.persist4j.engine.ID)1 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 DisplayType (com.rebuild.core.metadata.easymeta.DisplayType)1 MetaschemaImporter (com.rebuild.core.rbstore.MetaschemaImporter)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1