Search in sources :

Example 16 with ScoreCardModel

use of org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel in project drools by kiegroup.

the class Helper method createEmptyGuidedScoreCard.

public static ScoreCardModel createEmptyGuidedScoreCard() {
    final ScoreCardModel model = new ScoreCardModel();
    model.setName("test");
    return model;
}
Also used : ScoreCardModel(org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)

Example 17 with ScoreCardModel

use of org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel in project drools by kiegroup.

the class GuidedScoreCardProviderImpl method loadFromInputStream.

@Override
public String loadFromInputStream(InputStream is) throws IOException {
    String xml = new String(IoUtils.readBytesFromInputStream(is), IoUtils.UTF8_CHARSET);
    ScoreCardModel model = GuidedScoreCardXMLPersistence.getInstance().unmarshall(xml);
    return GuidedScoreCardDRLPersistence.marshal(model);
}
Also used : ScoreCardModel(org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)

Example 18 with ScoreCardModel

use of org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel in project drools-wb by kiegroup.

the class GuidedScoreCardFileIndexer method fillIndexBuilder.

@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
    final String content = ioService.readAllString(path);
    final ScoreCardModel model = GuidedScoreCardXMLPersistence.getInstance().unmarshall(content);
    final ModuleDataModelOracle dmo = getModuleDataModelOracle(path);
    final DefaultIndexBuilder builder = getIndexBuilder(path);
    if (builder == null) {
        return null;
    }
    final GuidedScoreCardIndexVisitor visitor = new GuidedScoreCardIndexVisitor(dmo, model);
    visitor.visit();
    addReferencedResourcesToIndexBuilder(builder, visitor);
    return builder;
}
Also used : ScoreCardModel(org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) DefaultIndexBuilder(org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder)

Example 19 with ScoreCardModel

use of org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel in project drools-wb by kiegroup.

the class IndexGuidedScoreCardTest method testIndexGuidedScoreCard.

@Test
public void testIndexGuidedScoreCard() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("scorecard1.scgd");
    final ScoreCardModel model1 = GuidedScoreCardFactory.makeScoreCardWithCharacteristics("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", new ArrayList<Import>() {

        {
            add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant"));
            add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage"));
        }
    }, "scorecard1");
    final String xml1 = GuidedScoreCardXMLPersistence.getInstance().marshal(model1);
    ioService().write(path1, xml1);
    final Path path2 = basePath.resolve("scorecard2.scgd");
    final ScoreCardModel model2 = GuidedScoreCardFactory.makeScoreCardWithoutCharacteristics("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", new ArrayList<Import>() {

        {
            add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant"));
            add(new Import("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage"));
        }
    }, "scorecard2");
    final String xml2 = GuidedScoreCardXMLPersistence.getInstance().marshal(model2);
    ioService().write(path2, xml2);
    final Path path3 = basePath.resolve("scorecard3.scgd");
    final ScoreCardModel model3 = GuidedScoreCardFactory.makeEmptyScoreCard("org.drools.workbench.screens.guided.scorecard.backend.server.indexing", "scorecard3");
    final String xml3 = GuidedScoreCardXMLPersistence.getInstance().marshal(model3);
    ioService().write(path3, xml3);
    // 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.getFileSystem()).getClusterId());
    // Score Cards using org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1, path2);
    }
    // Score Cards referring to org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1);
    }
    // Score Cards using org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage#amount
    {
        final Query query = new SingleTermQueryBuilder(new ValuePartReferenceIndexTerm("org.drools.workbench.screens.guided.scorecard.backend.server.indexing.classes.Mortgage", "amount", PartType.FIELD)).build();
        searchFor(index, query, 1, path1);
    }
    // Score Cards using java.lang.Integer
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.lang.Integer", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1, path2);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValuePartReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) ScoreCardModel(org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

ScoreCardModel (org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)19 Test (org.junit.Test)10 Import (org.kie.soup.project.datamodel.imports.Import)5 Characteristic (org.drools.workbench.models.guided.scorecard.shared.Characteristic)3 Attribute (org.drools.workbench.models.guided.scorecard.shared.Attribute)2 Query (org.apache.lucene.search.Query)1 ScoreCardModelContent (org.drools.workbench.screens.guided.scorecard.model.ScoreCardModelContent)1 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)1 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)1 DefaultIndexBuilder (org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder)1 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)1 ValuePartReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm)1 ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)1 Path (org.uberfire.backend.vfs.Path)1 HasBusyIndicatorDefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)1 Path (org.uberfire.java.nio.file.Path)1 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)1