@Override public String getSource(final Path path, final RuleModel model) throws SourceGenerationFailedException { try { return new StringBuilder().append(RuleModelDRLPersistenceImpl.getInstance().marshal(model)).toString(); } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
final RuleModel rm = RuleModelDRLPersistenceImpl.getInstance().unmarshal(rule.toString(), Collections.emptyList(), dmo);
String ruleName = null; if (drlResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, dataModelService.getDataModel(destination), drlResourceType); } else if (dslrResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, dataModelService.getDataModel(destination), RuleModelDRLPersistenceImpl.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] copied to [" + destination.toURI() + "]."));
@Override public RuleModel load(final Path path) { try { final String drl = ioService.readAllString(Paths.convert(path)); final List<String> globals = utilities.loadGlobalsForPackage(path); final PackageDataModelOracle oracle = dataModelService.getDataModel(path); RuleModel ruleModel = null; if (dslrResourceType.accept(path)) { final String[] dsls = utilities.loadDslsForPackage(path); ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, oracle, persistenceExtensions, dsls); } else { ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, oracle, persistenceExtensions); } return ruleModel; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
String ruleName = null; if (drlResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, dataModelService.getDataModel(destination), drlResourceType); } else if (dslrResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, dataModelService.getDataModel(destination), RuleModelDRLPersistenceImpl.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]."));
@Override public RuleModel load(final Path path) { try { final String drl = ioService.readAllString(Paths.convert(path)); final List<String> globals = utilities.loadGlobalsForPackage(path); final PackageDataModelOracle oracle = dataModelService.getDataModel(path); RuleModel ruleModel = null; if (dslrResourceType.accept(path)) { final String[] dsls = utilities.loadDslsForPackage(path); ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, oracle, persistenceExtensions, dsls); } else { ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, oracle, persistenceExtensions); } return ruleModel; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public String getSource(final Path path, final RuleModel model) throws SourceGenerationFailedException { try { return new StringBuilder().append(RuleModelDRLPersistenceImpl.getInstance().marshal(model)).toString(); } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
String ruleName = null; if (drlResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, dataModelService.getDataModel(destination), drlResourceType); } else if (dslrResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, dataModelService.getDataModel(destination), RuleModelDRLPersistenceImpl.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] copied to [" + destination.toURI() + "]."));
final RuleModel rm = RuleModelDRLPersistenceImpl.getInstance().unmarshal(rule, globals, dmo);
@Override public String getSource(final Path path, final RuleModel model) throws SourceGenerationFailedException { try { final String dslr = RuleModelDRLPersistenceImpl.getInstance().marshal(model); final Expander expander = getDSLExpander(path); final String drl = expander.expand(dslr); return drl; } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
String ruleName = null; if (drlResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, globals, dataModelService.getDataModel(destination), drlResourceType); } else if (dslrResourceType.accept(destination)) { model = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(drl, globals, dataModelService.getDataModel(destination), RuleModelDRLPersistenceImpl.getInstance().marshal(model), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]."));
@Override public String getSource(final Path path, final RuleModel model) throws SourceGenerationFailedException { try { final String dslr = RuleModelDRLPersistenceImpl.getInstance().marshal(model); final Expander expander = getDSLExpander(path); final String drl = expander.expand(dslr); return drl; } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
private String toSourceUnexpanded(final Path path, final RuleModel content) { //Wrap RuleModel as we need to control whether the DSLs are expanded. Both DRL and DSLR files should not have //DSLs expanded. In the case of DSLRs we need to explicitly control escaping plain-DRL to prevent attempts //by drools to expand it, by forcing the Model->DRL persistence into believing the model has DSLs. final RuleModelWrapper model = new RuleModelWrapper(content, dslrResourceType.accept(path)); final String source = RuleModelDRLPersistenceImpl.getInstance().marshal(model); return source; }
private String toSourceUnexpanded(final Path path, final RuleModel content) { //Wrap RuleModel as we need to control whether the DSLs are expanded. Both DRL and DSLR files should not have //DSLs expanded. In the case of DSLRs we need to explicitly control escaping plain-DRL to prevent attempts //by drools to expand it, by forcing the Model->DRL persistence into believing the model has DSLs. final RuleModelWrapper model = new RuleModelWrapper(content, dslrResourceType.accept(path)); final String source = RuleModelDRLPersistenceImpl.getInstance().marshal(model); return source; }
@Override public String getSource(final Path path, final TemplateModel model) throws SourceGenerationFailedException { try { if (model == null) { return ""; } else { final String dslr = RuleTemplateModelDRLPersistenceImpl.getInstance().marshal(model); final Expander expander = getDSLExpander(path); final String drl = expander.expand(dslr); return drl; } } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
@Override public String getSource(final Path path, final TemplateModel model) throws SourceGenerationFailedException { try { if (model == null) { return ""; } else { final String dslr = RuleTemplateModelDRLPersistenceImpl.getInstance().marshal(model); final Expander expander = getDSLExpander(path); final String drl = expander.expand(dslr); return drl; } } catch (Exception e) { throw new SourceGenerationFailedException(e.getMessage()); } }
@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); } }
private void checkMarshall(String expected, RuleModel m) { String drl = ruleModelPersistence.marshal(m); assertNotNull(drl); if (expected != null) { assertEqualsIgnoreWhitespace(expected, drl); } }
rm); String drl = RuleModelDRLPersistenceImpl.getInstance().marshal(rm); assertTrue(drl.indexOf("age > \"42\"") > 0);
rm); final String actualRuleModelDrl = RuleModelDRLPersistenceImpl.getInstance().marshal(rm);