• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSONMetadataParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.redhat.lightblue.metadata.parser.JSONMetadataParser的典型用法代码示例。如果您正苦于以下问题:Java JSONMetadataParser类的具体用法?Java JSONMetadataParser怎么用?Java JSONMetadataParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONMetadataParser类属于com.redhat.lightblue.metadata.parser包,在下文中一共展示了JSONMetadataParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getMd

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
public EntityMetadata getMd(String fname)  {
    //runValidJsonTest("json-schema/metadata/metadata.json", fname);
    try {
        JsonNode node = loadJsonNode(fname);
        Extensions<JsonNode> extensions = new Extensions<>();
        extensions.addDefaultExtensions();
        extensions.registerDataStoreParser("mongo", new MongoDataStoreParser<JsonNode>());
        TypeResolver resolver = new DefaultTypes();
        JSONMetadataParser parser = new JSONMetadataParser(extensions, resolver, nodeFactory);
        EntityMetadata md = parser.parseEntityMetadata(node);
        PredefinedFields.ensurePredefinedFields(md);
        return md;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:AbstractMongoCrudTest.java


示例2: createMetadataWithPartialFilterExpression_CanPersistFieldNamesWithDots

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void createMetadataWithPartialFilterExpression_CanPersistFieldNamesWithDots() throws Exception {
    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.addDefaultExtensions();
    extensions.registerDataStoreParser("mongo", new MongoDataStoreParser<JsonNode>());
    JSONMetadataParser parser = new JSONMetadataParser(extensions, new DefaultTypes(), new JsonNodeFactory(true));

    EntityMetadata m = parser.parseEntityMetadata(AbstractJsonNodeTest.loadJsonNode("./testMetadata_partialIndex.json"));

    Index partialIndex = m.getEntityInfo().getIndexes().getIndexes().get(0);
    Assert.assertEquals("{$and=[{field6.nf7.nnf2={$gt=5}}, {field6.nf7.nnf2={$lt=100}}]}", partialIndex.getProperties().get("partialFilterExpression").toString());

    // persist
    md.createNewMetadata(m);
    // read
    m = md.getEntityMetadata("test", "1.0.0");

    Assert.assertNotNull(m);
    partialIndex = m.getEntityInfo().getIndexes().getIndexes().get(0);
    Assert.assertEquals("{ \"$and\" : [ { \"field6.nf7.nnf2\" : { \"$gt\" : 5}} , { \"field6.nf7.nnf2\" : { \"$lt\" : 100}}]}", partialIndex.getProperties().get("partialFilterExpression").toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:22,代码来源:MongoMetadataTest.java


示例3: createMdWithAndRefTest

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void createMdWithAndRefTest() throws Exception {
    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.addDefaultExtensions();
    extensions.registerDataStoreParser("mongo", new MongoDataStoreParser<JsonNode>());
    JSONMetadataParser parser = new JSONMetadataParser(extensions, new DefaultTypes(), new JsonNodeFactory(true));

    // get JsonNode representing metadata
    JsonNode jsonMetadata = AbstractJsonNodeTest.loadJsonNode(getClass().getSimpleName() + "-qps-andquery.json");

    // parser into EntityMetadata
    EntityMetadata e = parser.parseEntityMetadata(jsonMetadata);

    // persist
    md.createNewMetadata(e);
    EntityMetadata g = md.getEntityMetadata("test", "1.0.0");
    // No exception=OK
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:19,代码来源:MongoMetadataTest.java


示例4: testConvert

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testConvert() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-fetch.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    MetadataParser<JsonNode> p2 = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    new RDBMSPropertyParserImpl<JsonNode>().convert(p2, node, rdbms);

    assertNotNull(p2.getObjectProperty(node, "rdbms"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:21,代码来源:RDBMSPropertyParserImplTest.java


示例5: testParse_NoDialect

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_NoDialect() throws IOException{
    expectedEx.expect(com.redhat.lightblue.util.Error.class);
    expectedEx.expectMessage("{\"objectType\":\"error\",\"errorCode\":\""
            + RDBMSConstants.ERR_FIELD_REQUIRED
            + "\",\"msg\":\"No field informed\"}");

    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode emptyNode = JsonUtils.json("{}");

    new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, emptyNode);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:17,代码来源:RDBMSPropertyParserImplTest.java


示例6: testParse_EmptyDialect

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_EmptyDialect() throws IOException{
    expectedEx.expect(com.redhat.lightblue.util.Error.class);
    expectedEx.expectMessage("{\"objectType\":\"error\",\"errorCode\":\""
            + RDBMSConstants.ERR_FIELD_REQUIRED
            + "\",\"msg\":\"No field informed\"}");

    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode emptyNode = JsonUtils.json("{\"dialect\":\"\"}");

    new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, emptyNode);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:17,代码来源:RDBMSPropertyParserImplTest.java


示例7: testParse_NoOperation

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_NoOperation() throws IOException{
    expectedEx.expect(com.redhat.lightblue.util.Error.class);
    expectedEx.expectMessage("{\"objectType\":\"error\",\"errorCode\":\""
            + RDBMSConstants.ERR_FIELD_REQUIRED
            + "\",\"msg\":\"No Operation informed\"}");

    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode emptyNode = JsonUtils.json("{\"dialect\":\""+ DialectOperators.ORACLE + "\"}");

    new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, emptyNode);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:17,代码来源:RDBMSPropertyParserImplTest.java


示例8: testParse_Delete

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_Delete() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-delete.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    assertEquals(DialectOperators.ORACLE, rdbms.getDialect());
    assertNotNull(rdbms.getDelete());
    assertNull(rdbms.getFetch());
    assertNull(rdbms.getInsert());
    assertNull(rdbms.getSave());
    assertNull(rdbms.getUpdate());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:RDBMSPropertyParserImplTest.java


示例9: testParse_Fetch

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_Fetch() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-fetch.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    assertEquals(DialectOperators.ORACLE, rdbms.getDialect());
    assertNull(rdbms.getDelete());
    assertNotNull(rdbms.getFetch());
    assertNull(rdbms.getInsert());
    assertNull(rdbms.getSave());
    assertNull(rdbms.getUpdate());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:RDBMSPropertyParserImplTest.java


示例10: testParse_Insert

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_Insert() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-insert.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    assertEquals(DialectOperators.ORACLE, rdbms.getDialect());
    assertNull(rdbms.getDelete());
    assertNull(rdbms.getFetch());
    assertNotNull(rdbms.getInsert());
    assertNull(rdbms.getSave());
    assertNull(rdbms.getUpdate());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:RDBMSPropertyParserImplTest.java


示例11: testParse_Save

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_Save() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-save.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    assertEquals(DialectOperators.ORACLE, rdbms.getDialect());
    assertNull(rdbms.getDelete());
    assertNull(rdbms.getFetch());
    assertNull(rdbms.getInsert());
    assertNotNull(rdbms.getSave());
    assertNull(rdbms.getUpdate());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:RDBMSPropertyParserImplTest.java


示例12: testParse_Update

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse_Update() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = loadJsonNode("RdbmsMetadataTest-update.json");

    RDBMS rdbms = new RDBMSPropertyParserImpl<JsonNode>().parse(RDBMSPropertyParserImpl.NAME, p, node.get("rdbms"));

    assertEquals(DialectOperators.ORACLE, rdbms.getDialect());
    assertNull(rdbms.getDelete());
    assertNull(rdbms.getFetch());
    assertNull(rdbms.getInsert());
    assertNull(rdbms.getSave());
    assertNotNull(rdbms.getUpdate());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:19,代码来源:RDBMSPropertyParserImplTest.java


示例13: testParse

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testParse() throws IOException{
    String databaseName = "fakeDatabase";
    String datasourceName = "fakeDatasource";

    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode node = JsonUtils.json("{\"database\":\"" + databaseName + "\",\"datasource\":\"" + datasourceName + "\"}");
    RDBMSDataStore ds = new RDBMSDataStoreParser<JsonNode>().parse(RDBMSDataStoreParser.NAME, p, node);

    assertNotNull(ds);
    assertEquals(databaseName, ds.getDatabaseName());
    assertEquals(datasourceName, ds.getDatasourceName());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:18,代码来源:RDBMSDataStoreParserTest.java


示例14: testConvert

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testConvert() throws IOException{
    String databaseName = "fakeDatabase";
    String datasourceName = "fakeDatasource";

    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode emptyNode = JsonUtils.json("{}");

    RDBMSDataStore ds = new RDBMSDataStore(databaseName, datasourceName);

    new RDBMSDataStoreParser<JsonNode>().convert(p, emptyNode, ds);

    assertEquals(databaseName, p.getStringProperty(emptyNode, "database"));
    assertEquals(datasourceName, p.getStringProperty(emptyNode, "datasource"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:20,代码来源:RDBMSDataStoreParserTest.java


示例15: testConvert_WithNullValues

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
@Test
public void testConvert_WithNullValues() throws IOException{
    MetadataParser<JsonNode> p = new JSONMetadataParser(
            new Extensions<JsonNode>(),
            new DefaultTypes(),
            new JsonNodeFactory(true));

    JsonNode emptyNode = JsonUtils.json("{}");

    RDBMSDataStore ds = new RDBMSDataStore(null, null);

    new RDBMSDataStoreParser<JsonNode>().convert(p, emptyNode, ds);

    assertNull(p.getStringProperty(emptyNode, "database"));
    assertNull(p.getStringProperty(emptyNode, "datasource"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:17,代码来源:RDBMSDataStoreParserTest.java


示例16: createJSONMetadataParser

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
/**
 * Creates an instance of {@link JSONMetadataParser}.
 *
 * @param backend - Name of backend to use.
 * @param fieldConstraintParsers - <i>(optional)</i>
 * {@link FieldConstraintParser}s to register on the {@link Extensions} used
 * to parse the {@link EntityMetadata}. If <code>null</code> then nothing
 * will be set.
 * @return An instance of {@link JSONMetadataParser}.
 */
public static JSONMetadataParser createJSONMetadataParser(
        String backend,
        Map<String, ? extends FieldConstraintParser<JsonNode>> fieldConstraintParsers) {
    FakeDataStoreParser<JsonNode> dsParser = new FakeDataStoreParser<>(backend);

    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.registerDataStoreParser(dsParser.getDefaultName(), dsParser);
    extensions.addDefaultExtensions();
    if (fieldConstraintParsers != null) {
        for (Entry<String, ? extends FieldConstraintParser<JsonNode>> checker : fieldConstraintParsers.entrySet()) {
            extensions.registerFieldConstraintParser(checker.getKey(), checker.getValue());
        }
    }

    return new JSONMetadataParser(
            extensions,
            new DefaultTypes(),
            JsonNodeFactory.withExactBigDecimals(false));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:30,代码来源:MetadataUtil.java


示例17: createEntityMetadata

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
/**
 * Creates an instance of {@link EntityMetadata} for testing purposes.
 *
 * @param backend - Name of backend to use.
 * @param node - Json node to parse metadata from.
 * @param entityConstraints - <i>(optional)</i> {@link EntityConstraint}s to
 * set on the {@link EntityMetadata}. If <code>null</code> then nothing will
 * be set.
 * @param fieldConstraintParsers - <i>(optional)</i>
 * {@link FieldConstraintParser}s to register on the {@link Extensions} used
 * to parse the {@link EntityMetadata}. If <code>null</code> then nothing
 * will be set.
 * @return An instance of {@link EntityMetadata} for testing purposes.
 */
public static EntityMetadata createEntityMetadata(
        String backend,
        JsonNode node,
        List<? extends EntityConstraint> entityConstraints,
        Map<String, ? extends FieldConstraintParser<JsonNode>> fieldConstraintParsers) {

    JSONMetadataParser jsonParser = createJSONMetadataParser(backend, fieldConstraintParsers);

    EntityMetadata entityMetadata = jsonParser.parseEntityMetadata(node);
    if ((entityConstraints != null) && !entityConstraints.isEmpty()) {
        entityMetadata.setConstraints(new ArrayList<>(entityConstraints));
    }

    return entityMetadata;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:30,代码来源:MetadataUtil.java


示例18: Main

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
public Main(JSONMetadataParser parser, ObjectWriter jsonWriter, JsonNodeFactory jsonNodeFactory,
        EntityNotificationHookConfigurationReader hookConfigReader) {
    this.parser = parser;
    this.jsonWriter = jsonWriter;
    this.jsonNodeFactory = jsonNodeFactory;
    this.hookConfigReader = hookConfigReader;
}
 
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:8,代码来源:Main.java


示例19: usingLightblueDefaults

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
public static Main usingLightblueDefaults() {
    EntityNotificationHookConfigurationReader generator = new EntityNotificationHookConfigurationReader();
    JsonNodeFactory factory = JsonNodeFactory.withExactBigDecimals(true);
    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.addDefaultExtensions();
    JSONMetadataParser parser = new JSONMetadataParser(extensions, new DefaultTypes(), factory);

    return new Main(parser, prettyWriter, factory, generator);
}
 
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:10,代码来源:Main.java


示例20: getMd

import com.redhat.lightblue.metadata.parser.JSONMetadataParser; //导入依赖的package包/类
public EntityMetadata getMd(String fname) throws Exception {
    JsonNode node = loadJsonNode(fname);
    Extensions<JsonNode> extensions = new Extensions<>();
    extensions.addDefaultExtensions();
    extensions.registerDataStoreParser("mongo", new FakeMongoDataStoreParser<JsonNode>());
    TypeResolver resolver = new DefaultTypes();
    JSONMetadataParser parser = new JSONMetadataParser(extensions, resolver, JsonNodeFactory.instance);
    EntityMetadata md = parser.parseEntityMetadata(node);
    PredefinedFields.ensurePredefinedFields(md);
    return md;
}
 
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:12,代码来源:NotificationHookTest.java



注:本文中的com.redhat.lightblue.metadata.parser.JSONMetadataParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Parameter类代码示例发布时间:2022-05-23
下一篇:
Java EditProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap