public void updateReportContainer(Project project)
{
if( project == null ) return;
ReportContainer container = null;
List<EObject> helper = accessLayer.getElements(project, "ReportContainer");
if( helper.isEmpty() )
{
container = ReportModelFactory.eINSTANCE.createReportContainer();
accessLayer.addElement(project, container);
}
else
{
// merge containers:
container = (ReportContainer)helper.get(0);
for(int i = 0; i < helper.size(); i++)
{
if( i == 0 ) continue;
container.getReports().addAll(((ReportContainer)helper.get(i)).getReports());
((ReportContainer)helper.get(i)).getReports().clear();
accessLayer.removeElement(project, helper.get(i));
helper.remove(i);
i--;
}
}
// move all reports into the container:
List<EObject> reports = accessLayer.getElements(project, "ImpactReport");
reports.addAll(accessLayer.getElements(project, "ConsistenceReport"));
int violations = 0;
int badSmells = 0;
int impacts = 0;
if( container.getReports().size() != reports.size() )
for(int i = 0; i < reports.size(); i++)
if( !container.getReports().contains(reports.get(i)))
container.getReports().add((Report)reports.get(i));
for(int i = 0; i < container.getReports().size(); i++)
{
if( container.getReports().get(i).getType() == org.emftrace.metamodel.ReportModel.ReportType.VIOLATION ) violations++;
if( container.getReports().get(i).getType() == org.emftrace.metamodel.ReportModel.ReportType.BAD_SMELL ) badSmells++;
if( container.getReports().get(i).getType() == org.emftrace.metamodel.ReportModel.ReportType.IMPACT ) impacts++;
}
String impactText = " impact";
if( impacts > 1 ) impactText += "s";
String violationText = " violation";
if( violations > 1 ) violationText += "s";
String badsmellText = " bad smell";
if( badSmells > 1 ) badsmellText += "s";
container.setName("[" + impacts + impactText + ", " + violations + violationText + ", " + badSmells + badsmellText + "]");
if( isLoggingEnabled ) printToLog("updateReportContainer", "10. report container has been updated");
}