@@ -215,21 +215,42 @@ public Stream<RelAndNodeResult> getRels(@Name("node") Node node, @Name("rel") St
215
215
public Stream <LabelNameResult > labels (@ Name (value = "params" , defaultValue = "{}" ) Map <String , Object > props ) throws MicroReasonerException {
216
216
final GraphConfig gc = getGraphConfig ();
217
217
218
- if (gc == null && missingParams (props , "catLabel" , "catNameProp" , "subCatRel" )) {
219
- throw new MicroReasonerException ("No GraphConfig or in-procedure params (catLabel, catNameProp, subCatRel). Method cannot be run." );
218
+ if (gc == null && missingParams (props , "catLabel" , "catNameProp" , "subCatRel" , "relLabel" , "propLabel" )) {
219
+ throw new MicroReasonerException ("No GraphConfig or in-procedure params (catLabel, catNameProp, subCatRel, relLabel, propLabel ). Method cannot be run." );
220
220
}
221
221
222
- String cypher = getInferredLabelsQuery ((String ) props .getOrDefault ("catLabel" ,gc .getClassLabelName ()),
223
- (String ) props .getOrDefault ("subCatRel" ,gc .getSubClassOfRelName ()),
224
- (String ) props .getOrDefault ("catNameProp" ,gc .getClassNamePropName ()));
222
+ String cypher ;
225
223
224
+ if (gc == null ){
225
+ cypher = getInferredLabelsQuery ((String ) props .get ("catLabel" ),
226
+ (String ) props .get ("subCatRel" ),
227
+ (String ) props .get ("catNameProp" ),
228
+ (String ) props .get ("relLabel" ),
229
+ (String ) props .get ("propLabel" ));
230
+ } else {
231
+ cypher = getInferredLabelsQuery ((String ) props .getOrDefault ("catLabel" , gc .getClassLabelName ()),
232
+ (String ) props .getOrDefault ("subCatRel" , gc .getSubClassOfRelName ()),
233
+ (String ) props .getOrDefault ("catNameProp" , gc .getClassNamePropName ()),
234
+ (String ) props .getOrDefault ("relLabel" , gc .getObjectPropertyLabelName ()),
235
+ (String ) props .getOrDefault ("propLabel" , gc .getDataTypePropertyLabelName ()));
236
+ }
226
237
return tx .execute (cypher ).stream ().map (n -> (String ) n .get ("inferredlabel" )).map (LabelNameResult ::new );
227
238
}
228
239
229
- private static final String getInferredLabelsQuery (String catLabel , String subCatRel , String catNameProp ) {
230
- return "call db.labels() yield label\n " +
231
- " match hierarchy = (:`" + catLabel + "` { `" + catNameProp + "`: label })-[:`" + subCatRel + "`*0..]->(p) where size([(p)-[s:`" + subCatRel + "`]->() | s]) = 0\n " +
232
- " unwind [n in nodes(hierarchy) | n.`" + catNameProp + "` ] as inferredlabel return distinct inferredlabel" ;
240
+ private static final String getInferredLabelsQuery (String catLabel , String subCatRel , String catNameProp ,
241
+ String relLabel , String propLabel ) {
242
+ return "call db.labels() yield label " +
243
+ " where not label in ['_GraphConfig', 'Resource', '_NsPrefDef', '" + relLabel + "', '" + propLabel + "', '" + catLabel + "', '_MapNs', '_MapDef'] " +
244
+ " call { " +
245
+ " with label " +
246
+ " return label as inferredlabel " +
247
+ " union " +
248
+ " with label " +
249
+ " match hierarchy = (:`" + catLabel + "` { `" + catNameProp + "`: label })-[:`" + subCatRel + "`*0..]->(p) where size([(p)-[s:`" + subCatRel + "`]->() | s]) = 0 " +
250
+ " unwind [n in nodes(hierarchy) | n.`" + catNameProp + "` ] as inferredlabel " +
251
+ " return distinct inferredlabel " +
252
+ " } " +
253
+ " return distinct inferredlabel " ;
233
254
}
234
255
235
256
private static final String getClassRelsFromOntoQuery (boolean outgoing , boolean includeAll , String catLabel ,
0 commit comments