@Override public String toSource( Path path, final RuleModel model ) { return sourceServices.getServiceFor( paths.convert( path ) ).getSource( paths.convert( path ), model ); }
@Override public boolean accepts( final Path path ) { final String pattern = getPattern(); final String suffix = "." + pattern; final String uri = path.toUri().toString(); return uri.substring( uri.length() - suffix.length() ).equals( suffix ); }
private SourceService getMatchingSourceService( final Path path ) { //Find all matching services final List<SourceService> matchingServices = new ArrayList<SourceService>(); for ( final SourceService service : sourceServices ) { if ( service.accepts( path ) ) { matchingServices.add( service ); } } if ( matchingServices.isEmpty() ) { return null; } //Find the service that matches the longest pattern. This will be the more specific service SourceService specificMatchingService = null; for ( final SourceService service : matchingServices ) { if ( specificMatchingService == null ) { specificMatchingService = service; } else { if ( service.getPattern().length() > specificMatchingService.getPattern().length() ) { specificMatchingService = service; } } } return specificMatchingService; }
private String toDRL( Path path, final ScoreCardModel model ) { return sourceServices.getServiceFor( paths.convert( path ) ).getSource( paths.convert( path ), model ); }
@Override public String toSource( final Path path, final FactModels model ) { return sourceServices.getServiceFor( paths.convert( path ) ).getSource( paths.convert( path ), FactModelPersistence.marshal( model ) ); }