Search in sources :

Example 1 with ResourceConversionResult

use of org.drools.compiler.compiler.ResourceConversionResult in project drools by kiegroup.

the class GuidedRuleTemplateProviderImpl method loadFromInputStream.

@Override
public ResourceConversionResult loadFromInputStream(InputStream is) throws IOException {
    String xml = new String(IoUtils.readBytesFromInputStream(is), IoUtils.UTF8_CHARSET);
    TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(xml);
    String content = RuleTemplateModelDRLPersistenceImpl.getInstance().marshal(model);
    if (model.hasDSLSentences()) {
        return new ResourceConversionResult(content, ResourceType.DSLR);
    } else {
        return new ResourceConversionResult(content, ResourceType.DRL);
    }
}
Also used : TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) ResourceConversionResult(org.drools.compiler.compiler.ResourceConversionResult)

Example 2 with ResourceConversionResult

use of org.drools.compiler.compiler.ResourceConversionResult in project drools by kiegroup.

the class KnowledgeBuilderImpl method guidedDecisionTableToPackageDescr.

PackageDescr guidedDecisionTableToPackageDescr(Resource resource) throws DroolsParserException, IOException {
    GuidedDecisionTableProvider guidedDecisionTableProvider = GuidedDecisionTableFactory.getGuidedDecisionTableProvider();
    ResourceConversionResult conversionResult = guidedDecisionTableProvider.loadFromInputStream(resource.getInputStream());
    return conversionResultToPackageDescr(resource, conversionResult);
}
Also used : GuidedDecisionTableProvider(org.drools.compiler.compiler.GuidedDecisionTableProvider) ResourceConversionResult(org.drools.compiler.compiler.ResourceConversionResult)

Example 3 with ResourceConversionResult

use of org.drools.compiler.compiler.ResourceConversionResult in project drools by kiegroup.

the class KnowledgeBuilderImpl method templateToPackageDescr.

PackageDescr templateToPackageDescr(Resource resource) throws DroolsParserException, IOException {
    GuidedRuleTemplateProvider guidedRuleTemplateProvider = GuidedRuleTemplateFactory.getGuidedRuleTemplateProvider();
    ResourceConversionResult conversionResult = guidedRuleTemplateProvider.loadFromInputStream(resource.getInputStream());
    return conversionResultToPackageDescr(resource, conversionResult);
}
Also used : ResourceConversionResult(org.drools.compiler.compiler.ResourceConversionResult) GuidedRuleTemplateProvider(org.drools.compiler.compiler.GuidedRuleTemplateProvider)

Example 4 with ResourceConversionResult

use of org.drools.compiler.compiler.ResourceConversionResult in project drools by kiegroup.

the class GuidedDecisionTableProviderImpl method loadFromInputStream.

@Override
public ResourceConversionResult loadFromInputStream(InputStream is) throws IOException {
    String xml = new String(IoUtils.readBytesFromInputStream(is), IoUtils.UTF8_CHARSET);
    GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(xml);
    String content = GuidedDTDRLPersistence.getInstance().marshal(model);
    if (hasDSLSentences(model)) {
        return new ResourceConversionResult(content, ResourceType.DSLR);
    } else {
        return new ResourceConversionResult(content, ResourceType.DRL);
    }
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ResourceConversionResult(org.drools.compiler.compiler.ResourceConversionResult)

Aggregations

ResourceConversionResult (org.drools.compiler.compiler.ResourceConversionResult)4 GuidedDecisionTableProvider (org.drools.compiler.compiler.GuidedDecisionTableProvider)1 GuidedRuleTemplateProvider (org.drools.compiler.compiler.GuidedRuleTemplateProvider)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)1