use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.
the class RefactorOperationBuilderFactory method newResourceBasedInstance.
public static <T extends AbstractOperationRequest> RefactorOperationBuilder<T> newResourceBasedInstance(String resourceName, ResourceType type, OperationType operation) {
RefactorOperationBuilder<T> builder = newInstance(operation);
builder.getQueryTerms().add(new ValueReferenceIndexTerm(resourceName, type));
return builder;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.
the class RefactorOperationBuilderFactory method newResourceBasedInstance.
public static <T extends AbstractOperationRequest> RefactorOperationBuilder<T> newResourceBasedInstance(String resourceName, ResourceType type, TermSearchType searchType, OperationType operation) {
RefactorOperationBuilder<T> builder = newInstance(operation);
builder.getQueryTerms().add(new ValueReferenceIndexTerm(resourceName, type, searchType));
return builder;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.
the class FindResourcePartsQueryValidIndexTermsTest method initExpectedValues.
private List<Pair<String, String>> initExpectedValues() {
List<Pair<String, String>> expectedValues = new ArrayList<Pair<String, String>>();
expectedValues.add(new Pair<String, String>(ResourceType.JAVA.toString(), "org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Pojo1"));
// identifying info
String[] fieldNames = new String[] { "o_BigDecimal", "o_BigInteger", "o_Boolean", "o_Byte", "o_Character", "o_Date", "o_Double", "o_Float", "o_Integer", "o_Long", "o_Short", "o_String", "p_boolean", "p_byte", "p_char", "p_double", "p_float", "p_int", "p_long", "p_short" };
for (String className : fieldNames) {
ValuePartIndexTerm partTerm = new ValuePartIndexTerm(className, PartType.FIELD);
expectedValues.add(new Pair<String, String>(partTerm.getTerm(), partTerm.getValue()));
}
// references
String[] referencedClasses = new String[] { "java.util.Date", "java.io.Serializable", "java.math.BigDecimal", "java.lang.Boolean", "java.lang.Byte", "java.lang.Character", "java.lang.Double", "java.lang.Float", "java.lang.Integer", "java.lang.Long", "boolean", "byte", "char", "double", "float", "long", "short" };
for (String className : referencedClasses) {
ValueReferenceIndexTerm refTerm = new ValueReferenceIndexTerm(className, ResourceType.JAVA);
expectedValues.add(new Pair<String, String>(refTerm.getTerm(), refTerm.getValue()));
}
return expectedValues;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.
the class IndexDrlLHSTypeExpressionFieldTypeTest method testIndexDrlLHSTypeExpressionFieldType.
@Test
public void testIndexDrlLHSTypeExpressionFieldType() throws IOException, InterruptedException {
// Add test files
final Path path1 = basePath.resolve("drl6.drl");
final String drl1 = loadText("drl6.drl");
ioService().write(path1, drl1);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 1, path1);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 1, path1);
}
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project kie-wb-common by kiegroup.
the class IndexDrlLHSTypeTest method testIndexDrlLHSType.
@Test
public void testIndexDrlLHSType() throws IOException, InterruptedException {
ioService().startBatch(ioService().getFileSystem(basePath.toUri()));
// Add test files
final Path path1 = basePath.resolve("drl1.drl");
final String drl1 = loadText("drl1.drl");
ioService().write(path1, drl1);
final Path path2 = basePath.resolve("drl2.drl");
final String drl2 = loadText("drl2.drl");
ioService().write(path2, drl2);
final Path path3 = basePath.resolve("drl3.drl");
final String drl3 = loadText("drl3.drl");
ioService().write(path3, drl3);
ioService().endBatch();
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(12000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
// Check type extraction (with wildcards)
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("*.Applicant", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
searchFor(index, query, 3, path1, path2, path3);
}
// Check type extraction (without wildcards)
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 3, path1, path2, path3);
}
// Check type extraction (with wildcards)
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("*.Mortgage", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
searchFor(index, query, 2, path2, path3);
}
// Check type extraction (without wildcards)
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
searchFor(index, query, 2, path2, path3);
}
}
Aggregations