首页 \ 问答 \ 来自groovy.config的groovy打印环境(groovy print environments from groovy.config)

来自groovy.config的groovy打印环境(groovy print environments from groovy.config)

如何从配置文件中打印可用的环境? ojbect ConfigSlurper创建什么形式?

我试过了

def config2 = new ConfigSlurper().parse(new File('obieeadmincfg.groovy').toURL())

config2.config.environments.each { println ${it} }
        and 
println prettyPrint(toJson(config2))
        and
for ( i in 0 ..config2.config.environments.size()-1)
    println config2.config.environments[i]

groovy.config

//Config3.groovy
obieadmin {
    //default values
    serverurl = "http://default.mycompany.com"

}

environments {
    pldev01 {
        obieeadmin {
            serverurl = 'devgdwobi03.x.com'

        }
    }
    plsbx02 {
        obieeadmin {
            serverurl = 'devgdwobi03.x.com'

        }
    }
}

how do I print available environments from a config file? What is the form of the ojbect ConfigSlurper creates?

I tried

def config2 = new ConfigSlurper().parse(new File('obieeadmincfg.groovy').toURL())

config2.config.environments.each { println ${it} }
        and 
println prettyPrint(toJson(config2))
        and
for ( i in 0 ..config2.config.environments.size()-1)
    println config2.config.environments[i]

groovy.config

//Config3.groovy
obieadmin {
    //default values
    serverurl = "http://default.mycompany.com"

}

environments {
    pldev01 {
        obieeadmin {
            serverurl = 'devgdwobi03.x.com'

        }
    }
    plsbx02 {
        obieeadmin {
            serverurl = 'devgdwobi03.x.com'

        }
    }
}

原文:https://stackoverflow.com/questions/33394245
更新时间:2024-02-14 13:02

最满意答案

考虑为什么您的查询不起作用:

没有不同的,你有每行配对u和p的行。 当你使用DISTINCT时,如果同一个u有多行,匹配多个p,它应该如何排序? 那是一项不可能完成的任务。

如果你把它改成u.id的顺序,那么它就可以了。

顺便说一下,我鼓励您使用标签将查询限制为仅限于相关节点。 您还可以重新编写查询,以防止它发出重复项,并完全避免使用DISTINCT。

如果我们假设您感兴趣的节点标有:Person,您的查询可能是:

MATCH (p:Person)
WHERE EXISTS( (p)-[:likes]-() )
RETURN p ORDER BY p.id DESC

Consider why your query isn't working:

Without the distinct, you have rows with each pairing of u and p. When you use DISTINCT, how is it supposed to order when there are multiple lines for the same u, matching to multiple p's? That's an impossible task.

If you change it to order by u.id instead, then it works just fine.

I do encourage you to use labels, by the way, to restrict your query only to relevant nodes. You can also rework your query to prevent it from emitting duplicates and avoid the need for DISTINCT completely.

If we assume the nodes you're interested in are labeled with :Person, your query might be:

MATCH (p:Person)
WHERE EXISTS( (p)-[:likes]-() )
RETURN p ORDER BY p.id DESC

相关问答

更多
  • 因为节点可以有多个标签和labels (n)返回代表这些标签的字符串集合,所以每个标签获得一个计数是非常复杂的。 在由三个节点和两个标签组成的图上,如{:A} , {:B}和{:A:B} , labels (n)返回三个不同的字符串集合。 而不是用两个节点计数:A和两个节点:B ,结果将是三个标签组合中的每一个的结果。 见控制台 。 要按每个标签进行汇总,而不是按标签集合进行汇总,则必须按集合中的值进行分组,这非常麻烦。 我有一个丑陋的方式来做到这一点,也许有人可以建议一个更好的方法:首先找出任何节点有最大 ...
  • 对于一般查询,Cypher是足够的,可能更快。 Gremlin与Cypher的优势在于您进入高级别的运行 - 在Gremlin中,您可以更好地定义精确的遍历模式(或您自己的算法),而在Cypher中,引擎会尝试找到最佳的运行解决方案。 我个人使用Cypher,因为它的简单,迄今为止,我还没有任何情况下,我不得不使用Gremlin(除了使用Gremlin graphML导入/导出功能)。 然而,我期望即使我需要使用Gremlin,我会这样做一个具体的查询,我会发现在网上,永远不会再回来。 您可以随时了解Cyp ...
  • 在设置索引时我不确定这是否是Spring Data中的错误,但是使用REST索引手动创建索引: :POST /db/data/index/node { "name" : "location", "config" : { "provider" : "spatial", "geometry_type" : "point", "wkt" : "wkt" } } 我现在可以使用@Query注释中的cypher以最小的努力执行查询(显然会有更多参数): @Query(value ...
  • 如果我理解正确,那么你需要计算节点的相互依赖性: MATCH (v1)-[:DEPENDS_ON]->(v2 {gav: 'A'}) WHERE EXISTS(v1.gav) OPTIONAL MATCH (v1)<-[:DEPENDS_ON]-(v3)-[:DEPENDS_ON]->(v2) WHERE EXISTS(v3.gav) WITH DISTINCT v1.gav AS gav, COUNT(v3) AS sortValue RETURN gav ORDER BY sortValu ...
  • 使用定期收集 在Cypher中,您可以使用WITH将查询分解为步骤,并且可以通过将它们连接在一起来连接两个列表。 MATCH (e:Enzyme)-[:activated]->(compA:Compound), (e)-[:inhibited_by]->(compB:Compund) WITH e, COLLECT(compA)+COLLECT(compB) as compList UNWIND compList as comp WITH DISTINCT e, comp // if a comp can ...
  • 考虑为什么您的查询不起作用: 没有不同的,你有每行配对u和p的行。 当你使用DISTINCT时,如果同一个u有多行,匹配多个p,它应该如何排序? 那是一项不可能完成的任务。 如果你把它改成u.id的顺序,那么它就可以了。 顺便说一下,我鼓励您使用标签将查询限制为仅限于相关节点。 您还可以重新编写查询,以防止它发出重复项,并完全避免使用DISTINCT。 如果我们假设您感兴趣的节点标有:Person,您的查询可能是: MATCH (p:Person) WHERE EXISTS( (p)-[:likes]-() ...
  • 就像@chrylis指出的那样,你的错误似乎是你没有所需的罐子,因而也就是错误的问题。 现在从您的评论中,我发现您在理解maven和依赖关系时遇到了困难。 所以这是我为您制作的简单指南。 [了解这不是一站式指南,这个程序可能不会开箱即用。 它目前正在为我运行,但它取决于许多事情,包括你正在运行的neo4j版本和其他一些配置因素。 尽管如此,这应该足以让你入门。 ] 您需要在系统上安装maven。 maven上很少有很酷的教程。 一个在这里。 https://www.youtube.com/watch?v=a ...
  • 您正在执行的查询以及Neo4j文档中针对Expand Into提供的示例不同。 示例查询在同一节点上开始和结束。 如果您希望计划程序首先找到两个节点并查看是否存在关系,那么您可以使用长度为1的shortestPath来最小化数据库命中。 PROFILE MATCH (n:Consumer {mobileNumber: "yyyyyyyyy"}), (m:Consumer {mobileNumber: "xxxxxxxxxxx"}) WITH n,m MATCH Path=shortestPath( ...
  • 您要求的是不同的节点,这表明该节点可能可以通过多个路径到达,因此可能存在于距起始节点多个距离处。 您应该在每个n的路径长度上使用min() (或max() ,具体取决于您的要求),而不是使用DISTINCT。 由于这些是聚合函数,因此每个n只能获得一行。 MATCH p=((:Start)-[:NEXT*..100]->(n:RELEVANT)) WHERE ALL(node IN nodes(p) WHERE ...) WITH n, min(length(p)) as distance WITH n ...
  • 如果我理解查询,我认为Cypher让这比你期望的要容易得多。 尝试这个: MATCH (start:Col {schema:"${DWMDATA}",table:"CHK_P_T80_ASSET_ACCT_AMT_DD"})-->(node:Col) WHERE start.schema <> node.schema RETURN start, node 虽然我不确定为什么要比较节点上的schema属性。 是否由传入的值修复了起始节点的schema ? 我可能不理解查询。 如果您正在寻找的不仅仅是连接到起 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。