Skip to content

Commit

Permalink
Fixed some API issues for Windup web
Browse files Browse the repository at this point in the history
  • Loading branch information
jsight committed Nov 10, 2016
1 parent 9966b9b commit a338a99
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
Expand Up @@ -2,6 +2,7 @@

import org.jboss.windup.config.loader.RuleLoaderContext;
import org.jboss.windup.config.metadata.RuleProviderMetadata;
import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationProvider;
import org.ocpsoft.rewrite.config.Rule;

Expand All @@ -17,4 +18,12 @@ public interface RuleProvider extends ConfigurationProvider<RuleLoaderContext>
* Get the {@link RuleProviderMetadata} for this {@link RuleProvider}.
*/
RuleProviderMetadata getMetadata();

/**
* KEEP - The purpose of this override is to make sure that reflection (interface.getClass().getMethods())
* keeps a method with the specific type. Otherwise, type erasure will get rid of it and callers will get
* ClassCastExceptions in some obscure cases.
*/
@Override
Configuration getConfiguration(RuleLoaderContext context);
}
Expand Up @@ -19,14 +19,14 @@ public class RuleLoaderContext

public RuleLoaderContext()
{
this.context = new ContextBase() {};
rulePaths = Collections.emptyList();
ruleProviderFilter = (provider) -> true;
this.context = new ContextBase() { };
this.rulePaths = Collections.emptyList();
this.ruleProviderFilter = (provider) -> true;
}

public RuleLoaderContext(Iterable<Path> rulePaths, Predicate<RuleProvider> ruleProviderFilter)
{
this.context = new ContextBase() {};
this.context = new ContextBase() { };
this.rulePaths = rulePaths;
this.ruleProviderFilter = ruleProviderFilter;
}
Expand Down
Expand Up @@ -66,7 +66,7 @@ public Object exec(List arguments) throws TemplateModelException
Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3));

Set<ProjectModel> projectModels = getProjects(projectModel);
Map<IssueCategoryModel, List<ProblemSummary>> problemSummariesOriginal = ProblemSummaryService.getProblemSummaries(event, projectModels, includeTags,
Map<IssueCategoryModel, List<ProblemSummary>> problemSummariesOriginal = ProblemSummaryService.getProblemSummaries(event.getGraphContext(), projectModels, includeTags,
excludeTags);

// Convert the keys to String to make Freemarker happy
Expand Down
Expand Up @@ -8,7 +8,7 @@
import java.util.TreeMap;
import java.util.UUID;

import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.graph.GraphContext;
import org.jboss.windup.graph.model.LinkModel;
import org.jboss.windup.graph.model.ProjectModel;
import org.jboss.windup.graph.model.resource.FileModel;
Expand All @@ -31,14 +31,14 @@ public class ProblemSummaryService
/**
* Gets lists of {@link ProblemSummary} objects organized by {@link IssueCategoryModel}.
*/
public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries(GraphRewrite event, Set<ProjectModel> projectModels, Set<String> includeTags,
Set<String> excludeTags)
public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries(GraphContext graphContext, Set<ProjectModel> projectModels, Set<String> includeTags,
Set<String> excludeTags)
{
// The key is the severity as a String
Map<IssueCategoryModel, List<ProblemSummary>> results = new TreeMap<>(new IssueCategoryModel.IssueSummaryPriorityComparator());
Map<RuleSummaryKey, ProblemSummary> ruleToSummary = new HashMap<>();

InlineHintService hintService = new InlineHintService(event.getGraphContext());
InlineHintService hintService = new InlineHintService(graphContext);
final Iterable<InlineHintModel> hints = projectModels == null ? hintService.findAll() : hintService.getHintsForProjects(projectModels);
for (InlineHintModel hint : hints)
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries(
summary.addFile(hint.getHint(), hint.getFile());
}

ClassificationService classificationService = new ClassificationService(event.getGraphContext());
ClassificationService classificationService = new ClassificationService(graphContext);
for (ClassificationModel classification : classificationService.findAll())
{
Set<String> tags = classification.getTags();
Expand Down
Expand Up @@ -86,7 +86,7 @@ private void generateDataSummary(GraphRewrite event)
ObjectMapper objectMapper = new ObjectMapper(jsonFactory);
Map<String, List<ProblemSummary>> summariesBySeverity =
ProblemSummaryService.getProblemSummaries(
event, projectModelTraversal.getAllProjects(true), Collections.emptySet(), Collections.emptySet())
event.getGraphContext(), projectModelTraversal.getAllProjects(true), Collections.emptySet(), Collections.emptySet())
.entrySet().stream().collect(Collectors.toMap((e) -> e.getKey().getName(), Map.Entry::getValue));

issueSummaryWriter.write("WINDUP_ISSUE_SUMMARIES['" + inputApplication.asVertex().getId() + "'] = ");
Expand Down
Expand Up @@ -79,8 +79,6 @@
@RuleMetadata(phase = InitialAnalysisPhase.class, haltOnException = true)
public class AnalyzeJavaFilesRuleProvider extends AbstractRuleProvider
{
private static final Object LOCK_OBJECT = new Object();

static final String UNPARSEABLE_JAVA_CLASSIFICATION = "Unparseable Java File";
static final String UNPARSEABLE_JAVA_DESCRIPTION = "This Java file could not be parsed";

Expand Down

0 comments on commit a338a99

Please sign in to comment.