Skip to content

Commit

Permalink
Merge pull request #675 from mbriskar/WINDUP-751
Browse files Browse the repository at this point in the history
WINDUP-751: Windup report path to a file contains About instead of Ap…
  • Loading branch information
jsight committed Sep 9, 2015
2 parents c7caf18 + e1eb6e5 commit 4b2fef0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
Expand Up @@ -79,13 +79,15 @@ public interface ApplicationReportModel extends ReportModel
public void setDisplayInApplicationReportIndex(Boolean displayInIndex);

/**
* Indicates whether or not this is the main report for the application.
* Indicates whether or not this is the main report for the application. This boolean flag means this report will be referenced from all the filemodels within application.
* Only one report per application must have this set to true.
*/
@Property(MAIN_APPLICATION_REPORT)
public Boolean isMainApplicationReport();

/**
* Indicates whether or not this is the main report for the application.
* Indicates whether or not this is the main report for the application. This boolean flag means this report will be referenced from all the filemodels within application.
* Only one report per application must have this set to true.
*/
@Property(MAIN_APPLICATION_REPORT)
public void setMainApplicationReport(Boolean mainApplicationReport);
Expand Down
Expand Up @@ -9,15 +9,21 @@

import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.gremlin.java.GremlinPipeline;
import org.jboss.windup.util.Logging;

import java.util.logging.Logger;

/**
* This class provides helpful utility methods for creating and finding {@link ApplicationReportModel} vertices.
*
* @author <a href="mailto:jesse.sightler@gmail.com">Jesse Sightler</a>
* @author <a href="mailto:mbriskar@gmail.com">Matej Briskar</a>
*
*/
public class ApplicationReportService extends GraphService<ApplicationReportModel>
{
private static final Logger LOG = Logging.get(ApplicationReportService.class);

public ApplicationReportService(GraphContext context)
{
super(context, ApplicationReportModel.class);
Expand All @@ -36,6 +42,12 @@ public ApplicationReportModel create()
return applicationReportModel;
}

/**
* Takes the first {@link ApplicationReportModel} that has set boolean value {@link ApplicationReportModel.MAIN_APPLICATION_REPORT} to true and whose
* projectModel is the same as the rootProjectModel of the given file
* @param fileModel A FileModel for which we are looking for the main application report to link to.
* @return
*/
public ApplicationReportModel getMainApplicationReportForFile(FileModel fileModel)
{
GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<>(getGraphContext().getGraph());
Expand All @@ -50,9 +62,9 @@ public ApplicationReportModel getMainApplicationReportForFile(FileModel fileMode
{
return null;
}
while (rootProjectModel.getParentProject() != null)
else
{
rootProjectModel = rootProjectModel.getParentProject();
rootProjectModel = rootProjectModel.getRootProjectModel();
}
String rootFilePath = rootProjectModel.getRootFileModel().getFilePath();
pipe.out(ProjectModel.ROOT_FILE_MODEL);
Expand All @@ -64,6 +76,10 @@ public ApplicationReportModel getMainApplicationReportForFile(FileModel fileMode
{
Vertex v = pipe.iterator().next();
ApplicationReportModel mainAppReport = frame(v);
if(pipe.iterator().hasNext()) {
LOG.warning("There are multiple ApplicationReportModels for a single file " + fileModel.getFilePath() +". This may cause some broken"
+ "links in the report file");
}
return mainAppReport;
}
return null;
Expand Down
Expand Up @@ -85,7 +85,7 @@ private ApplicationReportModel createApplicationReport(GraphContext context, Pro
applicationReportModel.setDisplayInApplicationReportIndex(true);
applicationReportModel.setReportName(REPORT_NAME);
applicationReportModel.setReportIconClass("glyphicon glyphicon-info-sign");
applicationReportModel.setMainApplicationReport(true);
applicationReportModel.setMainApplicationReport(false);
applicationReportModel.setProjectModel(projectModel);
applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT);
applicationReportModel.setTemplateType(TemplateType.FREEMARKER);
Expand Down
Expand Up @@ -4,6 +4,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
Expand All @@ -15,7 +16,9 @@
import org.jboss.windup.graph.service.GraphService;
import org.jboss.windup.graph.service.Service;
import org.jboss.windup.reporting.model.ReportModel;
import org.jboss.windup.reporting.model.source.SourceReportModel;
import org.jboss.windup.reporting.service.ReportService;
import org.jboss.windup.reporting.service.SourceReportService;
import org.jboss.windup.rules.apps.java.reporting.rules.CreateJavaApplicationOverviewReportRuleProvider;
import org.jboss.windup.rules.apps.javaee.model.EjbDeploymentDescriptorModel;
import org.jboss.windup.rules.apps.javaee.model.EjbMessageDrivenModel;
Expand Down Expand Up @@ -61,6 +64,7 @@ public void testRunWindupJEEExampleMode() throws Exception

validateEjbXmlReferences(context);
validateReports(context);
validateParentOfSourceReports(context);
}
}

Expand Down Expand Up @@ -166,4 +170,16 @@ private void validateReports(GraphContext context)

validateEJBBeanReport(context);
}

private void validateParentOfSourceReports(GraphContext context)
{
SourceReportService reportService = new SourceReportService(context);
for (SourceReportModel sourceReportModel : reportService.findAll())
{
List<ReportModel> parents = sourceReportModel.getAllParentsInReversedOrder();
Assert.assertTrue(parents.size() == 2);
Assert.assertTrue(parents.get(0).getReportName().equals("Overview"));
Assert.assertTrue(parents.get(0).getReportFilename().contains("JEE_Example_App__"));
}
}
}

0 comments on commit 4b2fef0

Please sign in to comment.