Skip to content

Commit

Permalink
Merge pull request #908 from OndraZizka/trimHintAndClassf-WINDUP-1009
Browse files Browse the repository at this point in the history
    WINDUP-987 Trim the text of titles, hints and classifications
  • Loading branch information
jsight committed May 2, 2016
2 parents 3808cb0 + 4671799 commit 73c9f53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.jboss.forge.furnace.util.Assert;
import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.config.parameters.ParameterizedIterationOperation;
Expand Down Expand Up @@ -116,12 +115,12 @@ public void performParameterized(final GraphRewrite event, final EvaluationConte
{
try
{
hintModel.setTitle(hintTitlePattern.getBuilder().build(event, context));
hintModel.setTitle(StringUtils.trim(hintTitlePattern.getBuilder().build(event, context)));
}
catch (Throwable t)
{
LOG.log(Level.WARNING, "Failed to generate parameterized Hint title due to: " + t.getMessage(), t);
hintModel.setTitle(hintTitlePattern.toString());
hintModel.setTitle(hintTitlePattern.toString().trim());
}
}
else
Expand All @@ -141,14 +140,14 @@ public void performParameterized(final GraphRewrite event, final EvaluationConte
LOG.log(Level.WARNING, "Failed to generate parameterized Hint body due to: " + t.getMessage(), t);
hintText = hintTextPattern.toString();
}
hintModel.setHint(hintText);
hintModel.setHint(StringUtils.trim(hintText));

GraphService<LinkModel> linkService = new GraphService<>(event.getGraphContext(), LinkModel.class);
for (Link link : links)
{
LinkModel linkModel = linkService.create();
linkModel.setDescription(link.getTitle());
linkModel.setLink(link.getLink());
linkModel.setDescription(StringUtils.trim(link.getTitle()));
linkModel.setLink(StringUtils.trim(link.getLink()));
hintModel.addLink(linkModel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.jboss.forge.furnace.util.Assert;
import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.config.operation.Iteration;
Expand Down Expand Up @@ -201,8 +201,8 @@ public void performParameterized(GraphRewrite event, EvaluationContext context,
classification = classificationService.create();
classification.setEffort(effort);
classification.setSeverity(severity);
classification.setDescription(description);
classification.setClassification(text);
classification.setDescription(StringUtils.trim(description));
classification.setClassification(StringUtils.trim(text));

Set<String> tags = new HashSet<>(this.getTags());
TagSetService tagSetService = new TagSetService(event.getGraphContext());
Expand All @@ -213,7 +213,9 @@ public void performParameterized(GraphRewrite event, EvaluationContext context,
LinkService linkService = new LinkService(graphContext);
for (Link link : links)
{
LinkModel linkModel = linkService.getOrCreate(link.getTitle(), link.getLink());
LinkModel linkModel = linkService.getOrCreate(
StringUtils.trim(link.getTitle()),
StringUtils.trim(link.getLink()));
classification.addLink(linkModel);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package org.jboss.windup.reporting.model;

import java.util.Set;

import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
import org.jboss.windup.graph.Indexed;
import org.jboss.windup.graph.model.resource.FileModel;
import org.jboss.windup.reporting.model.association.LinkableModel;
import org.jboss.windup.rules.files.condition.ToFileModelTransformable;
import org.ocpsoft.rewrite.config.Rule;

import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;

/**
* This classifies files and provides general background information about a specific {@link FileModel}. (For instance,
* an XML file may be classified as a "XYZ Configuration File".) A {@link ClassificationModel} may also contain links to
Expand Down Expand Up @@ -61,7 +58,7 @@ public interface ClassificationModel extends EffortReportModel, LinkableModel, T
* Set the description text of this {@link ClassificationModel}.
*/
@Property(DESCRIPTION)
void setDescription(String ruleID);
void setDescription(String description);

/**
* Get the description text of this {@link ClassificationModel}.
Expand Down

0 comments on commit 73c9f53

Please sign in to comment.