001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.extraction.component; 017 018import java.util.ArrayList; 019import java.util.Arrays; 020import java.util.Collection; 021import java.util.Collections; 022import java.util.HashSet; 023import java.util.LinkedHashSet; 024import java.util.List; 025import java.util.Locale; 026import java.util.Map; 027import java.util.Set; 028import java.util.regex.Matcher; 029import java.util.regex.Pattern; 030import java.util.stream.Collectors; 031 032import org.apache.avalon.framework.configuration.Configuration; 033import org.apache.avalon.framework.configuration.ConfigurationException; 034import org.apache.avalon.framework.service.ServiceException; 035import org.apache.avalon.framework.service.ServiceManager; 036import org.xml.sax.ContentHandler; 037 038import org.ametys.cms.content.ContentHelper; 039import org.ametys.cms.contenttype.ContentType; 040import org.ametys.cms.data.type.ModelItemTypeConstants; 041import org.ametys.cms.repository.Content; 042import org.ametys.cms.search.GetQueryFromJSONHelper; 043import org.ametys.cms.search.QueryBuilder; 044import org.ametys.cms.search.content.ContentSearcherFactory; 045import org.ametys.cms.search.content.ContentSearcherFactory.SimpleContentSearcher; 046import org.ametys.cms.search.model.SystemProperty; 047import org.ametys.cms.search.model.SystemPropertyExtensionPoint; 048import org.ametys.cms.search.query.AbstractTextQuery; 049import org.ametys.cms.search.query.Query.Operator; 050import org.ametys.cms.search.query.QuerySyntaxException; 051import org.ametys.cms.search.query.StringQuery; 052import org.ametys.cms.search.solr.SolrContentQueryHelper; 053import org.ametys.cms.search.ui.model.SearchUIModel; 054import org.ametys.core.util.JSONUtils; 055import org.ametys.core.util.LambdaUtils; 056import org.ametys.core.util.StringUtils; 057import org.ametys.plugins.extraction.execution.ExtractionExecutionContext; 058import org.ametys.plugins.extraction.execution.ExtractionExecutionContextHierarchyElement; 059import org.ametys.plugins.queriesdirectory.Query; 060import org.ametys.plugins.repository.AmetysObjectIterable; 061import org.ametys.plugins.repository.AmetysObjectResolver; 062import org.ametys.plugins.repository.EmptyIterable; 063import org.ametys.plugins.thesaurus.ThesaurusDAO; 064import org.ametys.runtime.model.ModelHelper; 065import org.ametys.runtime.model.ModelItem; 066 067/** 068 * This class represents an extraction component with a solr query 069 */ 070public abstract class AbstractSolrExtractionComponent extends AbstractExtractionComponent 071{ 072 /** 073 * Regex used to extract variables from a join expression: \$\{(\.\.(?:\/\.\.)*(?:\/[^\/}]+)?)\} 074 * a variable is inside a ${} 075 * variable starts with .. (to get the direct parent), 076 * has several /.. (to get parent of parent of (...)) 077 * and can have a /metadataName (to specify the metadata to join on) 078 */ 079 private static final String EXTRACT_JOIN_VARIABLES_REGEX = "\\$\\{(\\.\\.(?:\\/\\.\\.)*(?:\\/[^\\/}]+)?)\\}"; 080 081 /** Content types concerned by the solr search */ 082 protected Set<String> _contentTypes = new HashSet<>(); 083 084 /** Reference id of a recorded query */ 085 protected String _queryReferenceId; 086 087 /** The list of clauses */ 088 protected List<ExtractionClause> _clauses = new ArrayList<>(); 089 090 /** Helper to resolve referenced query infos */ 091 protected GetQueryFromJSONHelper _getQueryFromJSONHelper; 092 093 /** Util class to manipulate JSON String */ 094 protected JSONUtils _jsonUtils; 095 096 private AmetysObjectResolver _resolver; 097 private SystemPropertyExtensionPoint _systemPropertyExtensionPoint; 098 private ContentHelper _contentHelper; 099 private ContentSearcherFactory _contentSearcherFactory; 100 private QueryBuilder _queryBuilder; 101 102 @Override 103 public void service(ServiceManager serviceManager) throws ServiceException 104 { 105 super.service(serviceManager); 106 _jsonUtils = (JSONUtils) serviceManager.lookup(JSONUtils.ROLE); 107 _getQueryFromJSONHelper = (GetQueryFromJSONHelper) serviceManager.lookup(GetQueryFromJSONHelper.ROLE); 108 _resolver = (AmetysObjectResolver) serviceManager.lookup(AmetysObjectResolver.ROLE); 109 _systemPropertyExtensionPoint = (SystemPropertyExtensionPoint) serviceManager.lookup(SystemPropertyExtensionPoint.ROLE); 110 _contentHelper = (ContentHelper) serviceManager.lookup(ContentHelper.ROLE); 111 _contentSearcherFactory = (ContentSearcherFactory) serviceManager.lookup(ContentSearcherFactory.ROLE); 112 _queryBuilder = (QueryBuilder) serviceManager.lookup(QueryBuilder.ROLE); 113 } 114 115 @Override 116 public void configure(Configuration configuration) throws ConfigurationException 117 { 118 super.configure(configuration); 119 120 Configuration clauses = configuration.getChild("clauses"); 121 for (Configuration clause : clauses.getChildren("clause")) 122 { 123 addClauses(clause.getValue()); 124 } 125 126 _contentTypes = new HashSet<>(); 127 if (Arrays.asList(configuration.getAttributeNames()).contains("ref")) 128 { 129 if (Arrays.asList(configuration.getAttributeNames()).contains("contentTypes")) 130 { 131 throw new IllegalArgumentException(getLogsPrefix() + "a component with a query reference should not specify a content type"); 132 } 133 134 _queryReferenceId = configuration.getAttribute("ref"); 135 } 136 else 137 { 138 String contentTypesString = configuration.getAttribute("contentTypes"); 139 _contentTypes.addAll(StringUtils.stringToCollection(contentTypesString)); 140 } 141 } 142 143 @Override 144 public void prepareComponentExecution(ExtractionExecutionContext context) throws Exception 145 { 146 super.prepareComponentExecution(context); 147 148 if (_queryReferenceId != null && !_queryReferenceId.isEmpty()) 149 { 150 Query referencedQuery = _resolver.resolveById(_queryReferenceId); 151 computeReferencedQueryInfos(referencedQuery.getContent()); 152 } 153 154 _computeClausesInfos(context); 155 } 156 157 /** 158 * Manages the stored query referenced by the component 159 * @param refQueryContent referenced query content 160 * @throws QuerySyntaxException if there is a syntax error in the referenced query 161 */ 162 @SuppressWarnings("unchecked") 163 protected void computeReferencedQueryInfos(String refQueryContent) throws QuerySyntaxException 164 { 165 Map<String, Object> contentMap = _jsonUtils.convertJsonToMap(refQueryContent); 166 Map<String, Object> exportParams = (Map<String, Object>) contentMap.get("exportParams"); 167 String modelId = (String) exportParams.get("model"); 168 169 String q; 170 if (modelId.contains("solr")) 171 { 172 Map<String, Object> values = (Map<String, Object>) exportParams.get("values"); 173 String baseQuery = (String) values.get("query"); 174 175 _contentTypes = new HashSet<>((List<String>) values.get("contentTypes")); 176 177 q = SolrContentQueryHelper.buildQuery(_queryBuilder, baseQuery, _contentTypes, Collections.emptySet()); 178 } 179 else 180 { 181 SearchUIModel model = _getQueryFromJSONHelper.getSearchUIModel(exportParams); 182 List<String> contentTypesToFill = new ArrayList<>(); 183 org.ametys.cms.search.query.Query query = _getQueryFromJSONHelper.getQueryFromModel(model, exportParams, contentTypesToFill); 184 185 q = query.build(); 186 _contentTypes = new HashSet<>(contentTypesToFill); 187 } 188 189 ExtractionClause clause = new ExtractionClause(); 190 clause.setExpression(q); 191 _clauses.add(0, clause); 192 } 193 194 private void _computeClausesInfos(ExtractionExecutionContext context) 195 { 196 for (ExtractionClause clause : _clauses) 197 { 198 String clauseExpression = clause.getExpression(); 199 clause.setExpression(_resolveExpression(clauseExpression, context.getClauseVariables())); 200 201 List<ExtractionClauseGroup> groups = _extractGroupExpressionsFromClause(clauseExpression); 202 if (!groups.isEmpty()) 203 { 204 Collection<String> groupExpressions = groups.stream() 205 .map(ExtractionClauseGroup::getCompleteExpression) 206 .collect(Collectors.toList()); 207 if (_hasVariablesOutsideGroups(clauseExpression, groupExpressions)) 208 { 209 throw new IllegalArgumentException(getLogsPrefix() + "if there's at least one group, every variable should be in a group."); 210 } 211 } 212 else 213 { 214 // The only group is the entire expression 215 // The complete expression is the same as the classic one (there is no characters used to identify the group) 216 ExtractionClauseGroup group = new ExtractionClauseGroup(); 217 group.setCompleteExpression(clauseExpression); 218 group.setExpression(clauseExpression); 219 groups.add(group); 220 } 221 222 for (ExtractionClauseGroup group : groups) 223 { 224 Set<String> variables = new HashSet<>(_extractVariableFromClauseExpression(group.getExpression())); 225 if (!variables.isEmpty()) 226 { 227 if (variables.size() > 1) 228 { 229 throw new IllegalArgumentException(getLogsPrefix() + "only variables with same name are allowed within a single group"); 230 } 231 232 for (String variable : variables) 233 { 234 String[] pathSegments = variable.split(JOIN_HIERARCHY_SEPARATOR); 235 String fieldPath = pathSegments[pathSegments.length - 1]; 236 237 group.setVariable(variable); 238 group.setFieldPath(fieldPath); 239 } 240 } 241 242 clause.addGroup(group); 243 } 244 } 245 } 246 247 private String _resolveExpression(String expression, Map<String, String> queryVariables) 248 { 249 String resolvedExpression = expression; 250 for (Map.Entry<String, String> entry : queryVariables.entrySet()) 251 { 252 String variableName = entry.getKey(); 253 String contentId = entry.getValue(); 254 String escapedContentId = AbstractTextQuery.escapeStringValue(contentId, Operator.EQ); 255 resolvedExpression = resolvedExpression.replace("${" + variableName + "}", escapedContentId); 256 } 257 258 return resolvedExpression; 259 } 260 261 private boolean _hasVariablesOutsideGroups(String clauseExpression, Collection<String> groupExpressions) 262 { 263 List<String> variablesInClause = _extractVariableFromClauseExpression(clauseExpression); 264 List<String> variablesInGroups = new ArrayList<>(); 265 for (String groupExpression : groupExpressions) 266 { 267 variablesInGroups.addAll(_extractVariableFromClauseExpression(groupExpression)); 268 } 269 return variablesInClause.size() > variablesInGroups.size(); 270 } 271 272 List<ExtractionClauseGroup> _extractGroupExpressionsFromClause(String expression) 273 { 274 List<ExtractionClauseGroup> groupExpressions = new ArrayList<>(); 275 int indexOfGroup = expression.indexOf("#{"); 276 while (indexOfGroup != -1) 277 { 278 StringBuilder currentGroupSb = new StringBuilder(); 279 int endIndex = indexOfGroup; 280 int braceLevel = 0; 281 for (int i = indexOfGroup + 2; i < expression.length(); i++) 282 { 283 endIndex = i; 284 char currentChar = expression.charAt(i); 285 if ('{' == currentChar) 286 { 287 braceLevel++; 288 } 289 else if ('}' == currentChar) 290 { 291 if (0 == braceLevel) 292 { 293 ExtractionClauseGroup group = new ExtractionClauseGroup(); 294 String currentGroup = currentGroupSb.toString(); 295 group.setCompleteExpression("#{" + currentGroup + "}"); 296 group.setExpression(currentGroup); 297 groupExpressions.add(group); 298 break; 299 } 300 braceLevel--; 301 } 302 currentGroupSb.append(currentChar); 303 } 304 305 indexOfGroup = expression.indexOf("#{", endIndex); 306 } 307 return groupExpressions; 308 } 309 310 List<String> _extractVariableFromClauseExpression(String expression) 311 { 312 List<String> variables = new ArrayList<>(); 313 314 Pattern pattern = Pattern.compile(EXTRACT_JOIN_VARIABLES_REGEX); 315 Matcher matcher = pattern.matcher(expression); 316 317 while (matcher.find()) 318 { 319 variables.add(matcher.group(1)); 320 } 321 322 return variables; 323 } 324 325 @Override 326 public void executeComponent(ContentHandler contentHandler, ExtractionExecutionContext context) throws Exception 327 { 328 Iterable<Content> contents = getContents(context); 329 if (contents.iterator().hasNext()) 330 { 331 processContents(contents, contentHandler, context); 332 } 333 } 334 335 List<String> _getClauseQueries(ExtractionExecutionContext context) 336 { 337 List<String> clauseQueries = new ArrayList<>(); 338 339 for (ExtractionClause clause : _clauses) 340 { 341 String expression = clause.getExpression(); 342 343 for (ExtractionClauseGroup group : clause.getGroups()) 344 { 345 String variable = group.getVariable(); 346 347 if (variable != null && !variable.isEmpty()) 348 { 349 ExtractionExecutionContextHierarchyElement currentContextHierarchyElement = _getCurrentContextElementFromVariable(variable, context.getHierarchyElements()); 350 351 String fieldPath = group.getFieldPath(); 352 353 ExtractionComponent contextComponent = currentContextHierarchyElement.getComponent(); 354 String attributeTypeId = _getAttributeTypeId(fieldPath, contextComponent.getContentTypes()); 355 Collection<Object> values = _getValuesFromVariable(fieldPath, attributeTypeId, currentContextHierarchyElement, context.getDefaultLocale()); 356 357 if (values.isEmpty()) 358 { 359 getLogger().warn(getLogsPrefix() + "no value found for field '" + fieldPath + "'. The query of this component can't be achieved"); 360 return null; 361 } 362 363 Collection<String> groupExpressions = new ArrayList<>(); 364 for (Object value : values) 365 { 366 String valueAsString = _getValueAsString(value, attributeTypeId, fieldPath); 367 groupExpressions.add(group.getExpression().replace("${" + variable + "}", valueAsString)); 368 } 369 370 String groupReplacement = org.apache.commons.lang3.StringUtils.join(groupExpressions, " OR "); 371 expression = expression.replace(group.getCompleteExpression(), "(" + groupReplacement + ")"); 372 } 373 } 374 375 clauseQueries.add(expression); 376 } 377 378 return clauseQueries; 379 } 380 381 private ExtractionExecutionContextHierarchyElement _getCurrentContextElementFromVariable(String variable, List<ExtractionExecutionContextHierarchyElement> context) 382 { 383 int lastIndexOfSlash = variable.lastIndexOf(JOIN_HIERARCHY_SEPARATOR); 384 int indexOfCurrentContext = -1; 385 if (lastIndexOfSlash == -1) 386 { 387 indexOfCurrentContext = context.size() - 1; 388 } 389 else 390 { 391 int hierarchicalLevel = (lastIndexOfSlash + 1) / 3; 392 indexOfCurrentContext = context.size() - hierarchicalLevel; 393 if (variable.endsWith(JOIN_HIERARCHY_ELEMENT)) 394 { 395 indexOfCurrentContext--; 396 } 397 } 398 if (indexOfCurrentContext < 0 || indexOfCurrentContext >= context.size()) 399 { 400 throw new IllegalArgumentException(getLogsPrefix() + "join on '" + variable + "' does not refer to an existing parent"); 401 } 402 return context.get(indexOfCurrentContext); 403 } 404 405 /** 406 * Retrieves the field path's attribute type identifier from content types 407 * @param fieldPath the field path 408 * @param contentTypeIds the content types identifiers 409 * @return the attribute type identifier 410 */ 411 protected String _getAttributeTypeId(String fieldPath, Collection<String> contentTypeIds) 412 { 413 // Manage direct content references 414 if (JOIN_HIERARCHY_ELEMENT.equals(fieldPath)) 415 { 416 return ModelItemTypeConstants.CONTENT_ELEMENT_TYPE_ID; 417 } 418 419 // Manage System Properties 420 String[] pathSegments = fieldPath.split(EXTRACTION_ITEM_PATH_SEPARATOR); 421 String propertyName = pathSegments[pathSegments.length - 1]; 422 if (_systemPropertyExtensionPoint.hasExtension(propertyName)) 423 { 424 SystemProperty systemProperty = _systemPropertyExtensionPoint.getExtension(propertyName); 425 return systemProperty.getType().name().toLowerCase().replaceAll("_", "-"); 426 } 427 428 String fieldPathWthClassicSeparator = fieldPath.replaceAll(EXTRACTION_ITEM_PATH_SEPARATOR, ModelItem.ITEM_PATH_SEPARATOR); 429 Collection<ContentType> contentTypes = contentTypeIds.stream() 430 .map(_contentTypeExtensionPoint::getExtension) 431 .collect(Collectors.toList()); 432 433 if (ModelHelper.hasModelItem(fieldPathWthClassicSeparator, contentTypes)) 434 { 435 ModelItem modelItem = ModelHelper.getModelItem(fieldPathWthClassicSeparator, contentTypes); 436 return modelItem.getType().getId(); 437 } 438 439 throw new IllegalArgumentException(getLogsPrefix() + "join on '" + fieldPath + "'. This attribute is not available"); 440 } 441 442 private Collection<Object> _getValuesFromVariable(String fieldPath, String attributeTypeId, ExtractionExecutionContextHierarchyElement contextHierarchyElement, Locale defaultLocale) 443 { 444 Collection<Object> values = new LinkedHashSet<>(); 445 446 Iterable<Content> contents = contextHierarchyElement.getContents(); 447 for (Content content: contents) 448 { 449 boolean isAutoposting = contextHierarchyElement.isAutoposting(); 450 Collection<Object> contentValues = _getContentValuesFromVariable(content, fieldPath, attributeTypeId, isAutoposting, defaultLocale); 451 values.addAll(contentValues); 452 } 453 454 return values; 455 } 456 457 private Collection<Object> _getContentValuesFromVariable(Content content, String fieldPath, String attributeTypeId, boolean isAutoposting, Locale defaultLocale) 458 { 459 Collection<Object> values = new LinkedHashSet<>(); 460 461 Object value = _getContentValue(content, fieldPath, defaultLocale); 462 if (value == null) 463 { 464 return Collections.emptyList(); 465 } 466 467 if (value instanceof Collection<?>) 468 { 469 values.addAll((Collection<?>) value); 470 } 471 else 472 { 473 values.add(value); 474 } 475 476 Collection<Object> result = new LinkedHashSet<>(values); 477 478 if (isAutoposting && ModelItemTypeConstants.CONTENT_ELEMENT_TYPE_ID.equals(attributeTypeId)) 479 { 480 for (Object object : values) 481 { 482 Content parent = (Content) object; 483 ContentType contentType = _contentTypesHelper.getFirstContentType(parent); 484 485 // Manage autoposting only if the current value is a thesaurus term 486 if (Arrays.asList(_contentTypesHelper.getSupertypeIds(contentType.getId()).getLeft()).contains(ThesaurusDAO.MICROTHESAURUS_ABSTRACT_CONTENT_TYPE)) 487 { 488 AmetysObjectIterable<Content> chidren = _thesaurusDAO.getChildTerms(contentType.getId(), parent.getId()); 489 for (Content child : chidren) 490 { 491 Collection<Object> childValues = _getContentValuesFromVariable(child, JOIN_HIERARCHY_ELEMENT, attributeTypeId, isAutoposting, defaultLocale); 492 result.addAll(childValues); 493 } 494 } 495 } 496 } 497 498 return result; 499 } 500 501 private Object _getContentValue(Content content, String fieldPath, Locale defaultLocale) 502 { 503 if (JOIN_HIERARCHY_ELEMENT.equals(fieldPath)) 504 { 505 return content; 506 } 507 else 508 { 509 String fieldPathWthClassicSeparator = fieldPath.replaceAll(EXTRACTION_ITEM_PATH_SEPARATOR, ModelItem.ITEM_PATH_SEPARATOR); 510 return _contentHelper.getValue(content, fieldPathWthClassicSeparator, defaultLocale, true); 511 } 512 } 513 514 @SuppressWarnings("static-access") 515 private String _getValueAsString(Object value, String attributeTypeId, String fieldPath) 516 { 517 String valueAsString; 518 switch (attributeTypeId) 519 { 520 case ModelItemTypeConstants.STRING_TYPE_ID: 521 case ModelItemTypeConstants.LONG_TYPE_ID: 522 case ModelItemTypeConstants.DOUBLE_TYPE_ID: 523 case ModelItemTypeConstants.BOOLEAN_TYPE_ID: 524 valueAsString = value.toString(); 525 break; 526 case ModelItemTypeConstants.CONTENT_ELEMENT_TYPE_ID: 527 valueAsString = ((Content) value).getId(); 528 break; 529 default: 530 throw new IllegalArgumentException(getLogsPrefix() + "join on '" + fieldPath + "'. Metadata type '" + attributeTypeId + "' is not supported by extraction module"); 531 } 532 533 return StringQuery.escapeStringValue(valueAsString, Operator.EQ); 534 } 535 536 /** 537 * Retrieves the content searcher to use for solr search 538 * @return the content searcher 539 */ 540 protected SimpleContentSearcher getContentSearcher() 541 { 542 return _contentSearcherFactory.create(_contentTypes); 543 } 544 545 /** 546 * Gets the content results from Solr 547 * @param context component execution context 548 * @return the content results from Solr 549 * @throws Exception if an error occurs 550 */ 551 protected Iterable<Content> getContents(ExtractionExecutionContext context) throws Exception 552 { 553 List<String> clauseQueries = _getClauseQueries(context); 554 if (clauseQueries == null) 555 { 556 return new EmptyIterable<>(); 557 } 558 else 559 { 560 List<String> filterQueryStrings = clauseQueries 561 .stream() 562 .map(LambdaUtils.wrap(clauseQuery -> SolrContentQueryHelper.buildQuery(_queryBuilder, clauseQuery, Collections.emptySet(), Collections.emptySet()))) 563 .collect(Collectors.toList()); 564 return getContentSearcher() 565 .withFilterQueryStrings(filterQueryStrings) 566 .setCheckRights(false) 567 .search("*:*"); 568 } 569 } 570 571 /** 572 * Process result contents to format the result document 573 * @param contents search results 574 * @param contentHandler result document 575 * @param context component execution context 576 * @throws Exception if an error occurs 577 */ 578 protected abstract void processContents(Iterable<Content> contents, ContentHandler contentHandler, ExtractionExecutionContext context) throws Exception; 579 580 @Override 581 public Map<String, Object> getComponentDetailsForTree() 582 { 583 Map<String, Object> details = super.getComponentDetailsForTree(); 584 585 @SuppressWarnings("unchecked") 586 Map<String, Object> data = (Map<String, Object>) details.get("data"); 587 588 List<String> clauses = new ArrayList<>(); 589 for (ExtractionClause clause : this.getClauses()) 590 { 591 clauses.add(clause.getExpression()); 592 } 593 data.put("clauses", clauses); 594 595 data.put("useQueryRef", org.apache.commons.lang.StringUtils.isNotEmpty(_queryReferenceId)); 596 data.put("contentTypes", this.getContentTypes()); 597 data.put("queryReferenceId", this.getQueryReferenceId()); 598 599 return details; 600 } 601 602 public Set<String> getContentTypes() 603 { 604 return _contentTypes; 605 } 606 607 /** 608 * Add content types to component 609 * @param contentTypes Array of content types to add 610 */ 611 public void addContentTypes(String... contentTypes) 612 { 613 _contentTypes.addAll(Arrays.asList(contentTypes)); 614 } 615 616 /** 617 * Retrieves the id of the referenced query 618 * @return the id of the referenced query 619 */ 620 public String getQueryReferenceId() 621 { 622 return _queryReferenceId; 623 } 624 625 /** 626 * Sets the id of the referenced query 627 * @param queryReferenceId The id of the referenced query to set 628 */ 629 public void setQueryReferenceId(String queryReferenceId) 630 { 631 _queryReferenceId = queryReferenceId; 632 } 633 634 /** 635 * Retrieves the component clauses 636 * @return the component clauses 637 */ 638 public List<ExtractionClause> getClauses() 639 { 640 return _clauses; 641 } 642 643 /** 644 * Add clauses to the component. Do not manage clauses' groups 645 * @param expressions Array clauses expressions to add 646 */ 647 public void addClauses(String... expressions) 648 { 649 for (String expression : expressions) 650 { 651 ExtractionClause clause = new ExtractionClause(); 652 clause.setExpression(expression); 653 _clauses.add(clause); 654 } 655 } 656}