Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP WINDUP-2360 Rule add tag to projects with EJB #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions rules-reviewed/technology-usage/ejb-technology-usage.windup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import org.jboss.windup.config.GraphRewrite
import org.jboss.windup.config.operation.iteration.AbstractIterationOperation
import org.jboss.windup.config.phase.DependentPhase
import org.jboss.windup.config.phase.PostMigrationRulesPhase
import org.jboss.windup.config.phase.PreReportGenerationPhase
import org.jboss.windup.config.query.Query
import org.jboss.windup.graph.model.ProjectModel
import org.jboss.windup.reporting.model.TechnologyTagLevel
import org.jboss.windup.reporting.service.TechnologyTagService
import org.jboss.windup.rules.apps.javaee.model.EjbBeanBaseModel
import org.ocpsoft.rewrite.context.EvaluationContext

ruleSet("ejb-technology-usage-groovy")
/* if we need to query for TechnologyUsageStatisticsModel models
added during PostMigrationRulesPhase phase
.setPhase(DependentPhase.class)
.addExecuteAfter(PostMigrationRulesPhase.class)
.addExecuteBefore(PreReportGenerationPhase.class)
*/
.setPhase(PostMigrationRulesPhase.class)
.addRule()
.when(
Query.fromType(EjbBeanBaseModel.class)
)
.perform(
new AbstractIterationOperation<EjbBeanBaseModel>()
{
void perform(GraphRewrite event, EvaluationContext context, EjbBeanBaseModel payload)
{
List<ProjectModel> projectModels = payload.getApplications()
for (ProjectModel projectModel : projectModels)
{
TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext())
technologyTagService.addTagToFileModel(projectModel.getRootFileModel(), "Enterprise Java Bean", TechnologyTagLevel.INFORMATIONAL)
}
}

}
)
.withId("ejb-technology-usage-groovy-00000")
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ruletest id="technology-usage-ejb-test" xmlns="http://windup.jboss.org/schema/jboss-ruleset">
<testDataPath>data/ejb/</testDataPath>
<rulePath>../ejb-technology-usage.windup.xml</rulePath>
<rulePath>../ejb-technology-usage.windup.groovy</rulePath>
<ruleset>
<rules>
<rule id="technology-usage-ejb-01000-test">
Expand Down Expand Up @@ -60,6 +61,18 @@
<fail message="Entity Bean Technology Statistic Not Found" />
</perform>
</rule>
<rule id="ejb-technology-usage-groovy-00000-test">
<when>
<not>
<iterable-filter size="1">
<technology-tag-exists technology-tag="Enterprise Java Bean"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="'Enterprise Java Bean' Technology Tag Not Found" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>