Search in sources :

Example 1 with RefactoringRuleNamePageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow in project kie-wb-common by kiegroup.

the class RuleNameResponseBuilder method buildResponse.

@Override
public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) {
    // Both "child" rule and "parent" rule (when one extends another) are stored
    // in the index. We therefore need to build a set of unique Rule Names
    final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size());
    final Set<RuleName> uniqueRuleNames = new HashSet<>();
    for (final KObject kObject : kObjects) {
        final Set<RuleName> ruleNames = getRuleNamesFromKObject(kObject);
        uniqueRuleNames.addAll(ruleNames);
    }
    for (RuleName ruleName : uniqueRuleNames) {
        final RefactoringRuleNamePageRow row = new RefactoringRuleNamePageRow();
        row.setValue(ruleName);
        result.add(row);
    }
    return result;
}
Also used : KObject(org.uberfire.ext.metadata.model.KObject) ArrayList(java.util.ArrayList) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) RuleName(org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow.RuleName) HashSet(java.util.HashSet) RefactoringRuleNamePageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow)

Example 2 with RefactoringRuleNamePageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow in project kie-wb-common by kiegroup.

the class RuleNameServiceImplTest method getResults.

private List<RefactoringPageRow> getResults() {
    final List<RefactoringPageRow> results = new ArrayList<>();
    results.add(new RefactoringRuleNamePageRow() {

        {
            setValue(new RuleName("rule1", "org.kie.test.package"));
        }
    });
    results.add(new RefactoringRuleNamePageRow() {

        {
            setValue(new RuleName("rule2", "org.kie.test.package"));
        }
    });
    return results;
}
Also used : ArrayList(java.util.ArrayList) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) RefactoringRuleNamePageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow)

Aggregations

ArrayList (java.util.ArrayList)2 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)2 RefactoringRuleNamePageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow)2 HashSet (java.util.HashSet)1 RuleName (org.kie.workbench.common.services.refactoring.model.query.RefactoringRuleNamePageRow.RuleName)1 KObject (org.uberfire.ext.metadata.model.KObject)1