@@ -42,14 +42,14 @@ private fun cleanProperties(type: PatternConfigurationType, properties: List<Str
4242interface PatternConfiguration
4343
4444data class NodePatternConfiguration (val keys : Set <String >, val type : PatternConfigurationType ,
45- val labels : List <String >, val properties : List <String >): PatternConfiguration {
45+ val labels : List <String >, val properties : List <String >, val mergeProperties : Boolean ): PatternConfiguration {
4646 companion object {
4747
4848 // (:LabelA{!id,foo,bar})
4949 @JvmStatic private val cypherNodePatternConfigured = """ \((:\w+\s*(?::\s*(?:\w+)\s*)*)\s*(?:\{\s*(-?[\w!\.]+\s*(?:,\s*-?[!\w\*\.]+\s*)*)\})?\)$""" .toRegex()
5050 // LabelA{!id,foo,bar}
5151 @JvmStatic private val simpleNodePatternConfigured = """ ^(\w+\s*(?::\s*(?:\w+)\s*)*)\s*(?:\{\s*(-?[\w!\.]+\s*(?:,\s*-?[!\w\*\.]+\s*)*)\})?$""" .toRegex()
52- fun parse (pattern : String ): NodePatternConfiguration {
52+ fun parse (pattern : String , mergeProperties : Boolean ): NodePatternConfiguration {
5353 val isCypherPattern = pattern.startsWith(" (" )
5454 val regex = if (isCypherPattern) cypherNodePatternConfigured else simpleNodePatternConfigured
5555 val matcher = regex.matchEntire(pattern)
@@ -75,25 +75,26 @@ data class NodePatternConfiguration(val keys: Set<String>, val type: PatternConf
7575 val cleanedProperties = cleanProperties(type, properties)
7676
7777 return NodePatternConfiguration (keys = keys, type = type,
78- labels = labels, properties = cleanedProperties)
78+ labels = labels, properties = cleanedProperties, mergeProperties )
7979 }
8080 }
8181 }
82+
8283}
8384
8485
8586data class RelationshipPatternConfiguration (val start : NodePatternConfiguration , val end : NodePatternConfiguration ,
8687 val relType : String , val type : PatternConfigurationType ,
87- val properties : List <String >): PatternConfiguration {
88+ val properties : List <String >, val mergeProperties : Boolean ): PatternConfiguration {
8889 companion object {
8990
9091 // we don't allow ALL for start/end nodes in rels
9192 // it's public for testing purpose
92- fun getNodeConf (pattern : String ): NodePatternConfiguration {
93- val start = NodePatternConfiguration .parse(pattern)
93+ fun getNodeConf (pattern : String , mergeProperties : Boolean ): NodePatternConfiguration {
94+ val start = NodePatternConfiguration .parse(pattern, mergeProperties )
9495 return if (start.type == PatternConfigurationType .ALL ) {
9596 NodePatternConfiguration (keys = start.keys, type = PatternConfigurationType .INCLUDE ,
96- labels = start.labels, properties = start.properties)
97+ labels = start.labels, properties = start.properties, mergeProperties )
9798 } else {
9899 start
99100 }
@@ -148,7 +149,7 @@ data class RelationshipPatternConfiguration(val start: NodePatternConfiguration,
148149 }
149150 }
150151
151- fun parse (pattern : String ): RelationshipPatternConfiguration {
152+ fun parse (pattern : String , mergeNodeProps : Boolean , mergeRelProps : Boolean ): RelationshipPatternConfiguration {
152153 val isCypherPattern = pattern.startsWith(" (" )
153154 val regex = if (isCypherPattern) {
154155 cypherRelationshipPatternConfigured
@@ -169,20 +170,20 @@ data class RelationshipPatternConfiguration(val start: NodePatternConfiguration,
169170 val metadata = RelationshipPatternMetaData .create(isCypherPattern, isLeftToRight, matcher.groupValues)
170171
171172 val start = try {
172- getNodeConf(metadata.startPattern)
173+ getNodeConf(metadata.startPattern, mergeNodeProps )
173174 } catch (e: Exception ) {
174175 throw IllegalArgumentException (" The Relationship pattern $pattern is invalid" )
175176 }
176177 val end = try {
177- getNodeConf(metadata.endPattern)
178+ getNodeConf(metadata.endPattern, mergeNodeProps )
178179 } catch (e: Exception ) {
179180 throw IllegalArgumentException (" The Relationship pattern $pattern is invalid" )
180181 }
181182 val type = getPatternConfiguredType(metadata.properties)
182183 isHomogeneousPattern(type, metadata.properties, pattern, " Relationship" )
183184 val cleanedProperties = cleanProperties(type, metadata.properties)
184185 return RelationshipPatternConfiguration (start = start, end = end, relType = metadata.relType,
185- properties = cleanedProperties, type = type)
186+ properties = cleanedProperties, type = type, mergeProperties = mergeRelProps )
186187 }
187188 }
188189
0 commit comments