MetadatumSearcher.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:WhiteLab2.0-Neo4J-Plugin 作者:
protected Response updateMetadataLabel(final String label, final String property, final String value) {
    StreamingOutput stream = new StreamingOutput()
    {
        @Override
        public void write( OutputStream os ) throws IOException, WebApplicationException
        {
            try ( Transaction tx = database.beginTx() ) {
                JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
                IndexManager index = database.index();
                Index<Node> metadata = index.forNodes("Metadatum");
                for ( Node metadatum : metadata.query( "label:"+label ) ) {
                    if (property.equals("explorable") || property.equals("searchable"))
                        metadatum.setProperty(property, Boolean.valueOf(value));
                    else
                        metadatum.setProperty(property, value);
                }
                jg.writeString("Updated "+label);
                jg.flush();
                tx.success();
            }
        }
    };

    return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号