コード例 #1
0
  @Override
  public KObject toKObject(final Path path) {
    KObject index = null;

    try {
      final String drl = ioService.readAllString(path);
      final DrlParser drlParser = new DrlParser();
      final PackageDescr packageDescr = drlParser.parse(true, drl);

      if (drlParser.hasErrors()) {
        final List<DroolsError> errors = drlParser.getErrors();
        logger.warn(
            ErrorMessageUtilities.makeErrorMessage(
                path, errors.toArray(new DroolsError[errors.size()])));
        return index;
      }
      if (packageDescr == null) {
        logger.warn(ErrorMessageUtilities.makeErrorMessage(path));
        return index;
      }

      final ProjectDataModelOracle dmo = getProjectDataModelOracle(path);
      final Project project = projectService.resolveProject(Paths.convert(path));
      final Package pkg = projectService.resolvePackage(Paths.convert(path));

      final DefaultIndexBuilder builder = new DefaultIndexBuilder(project, pkg);
      final PackageDescrIndexVisitor visitor =
          new PackageDescrIndexVisitor(dmo, builder, packageDescr);
      visitor.visit();

      index = KObjectUtil.toKObject(path, builder.build());

    } catch (Exception e) {
      logger.error("Unable to index '" + path.toUri().toString() + "'.", e);
    }

    return index;
  }
コード例 #2
0
 @Override
 public KObjectKey toKObjectKey(final Path path) {
   return KObjectUtil.toKObjectKey(path);
 }