Skip to content

Commit

Permalink
Merge branch 'mkouba-WINDUP-952'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsight committed Mar 21, 2016
2 parents 94afabe + 023e5c7 commit 02b9a18
Show file tree
Hide file tree
Showing 24 changed files with 370 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ public interface FileModel extends ResourceModel
String PARSE_ERROR = "parseError";
String ON_PARSE_ERROR = "onParseError";

public static enum OnParseError {
enum OnParseError {
IGNORE, WARN;
OnParseError fromName(String name){
return EnumUtils.getEnum(OnParseError.class, StringUtils.upperCase(name));
//return OnParseError.valueOf(StringUtils.upperCase(name));
}
}



/**
* Contains the File Name (the last component of the path). Eg, a file /tmp/foo/bar/file.txt would have fileName set to "file.txt"
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
public interface HibernateConfigurationFileModel extends XmlFileModel
{

public static final String HIBERNATE_SESSION_FACTORY = "hibernateSessionFactory";
public static final String SPECIFICATION_VERSION = "specificationVersion";
public static final String TYPE = "HibernateConfigurationFileModel";
String HIBERNATE_SESSION_FACTORY = "hibernateSessionFactory";
String SPECIFICATION_VERSION = "specificationVersion";
String TYPE = "HibernateConfigurationFileModel";

@Property(SPECIFICATION_VERSION)
public String getSpecificationVersion();
String getSpecificationVersion();

@Property(SPECIFICATION_VERSION)
public void setSpecificationVersion(String version);
void setSpecificationVersion(String version);

@Adjacency(label = HIBERNATE_SESSION_FACTORY, direction = Direction.OUT)
public Iterable<HibernateSessionFactoryModel> getHibernateSessionFactories();
Iterable<HibernateSessionFactoryModel> getHibernateSessionFactories();

@Adjacency(label = HIBERNATE_SESSION_FACTORY, direction = Direction.OUT)
public void addHibernateSessionFactory(HibernateSessionFactoryModel hibernateSessionFactor);
void addHibernateSessionFactory(HibernateSessionFactoryModel hibernateSessionFactor);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.windup.rules.apps.javaee.model;

import org.jboss.windup.graph.model.ProjectModel;
import org.jboss.windup.graph.model.WindupVertexFrame;
import org.jboss.windup.rules.apps.java.model.JavaClassModel;

Expand All @@ -17,70 +18,83 @@
@TypeValue(HibernateEntityModel.TYPE)
public interface HibernateEntityModel extends WindupVertexFrame
{
public static final String CATALOG_NAME = "catalogName";
public static final String SCHEMA_NAME = "schemaName";
public static final String TABLE_NAME = "tableName";
public static final String SPECIFICATION_VERSION = "specificationVersion";
public static final String HIBERNATE_ENTITY_CLASS = "hibernateEntityClass";
public static final String TYPE = "HibernateEntityModel";
String CATALOG_NAME = "catalogName";
String SCHEMA_NAME = "schemaName";
String TABLE_NAME = "tableName";
String SPECIFICATION_VERSION = "specificationVersion";
String HIBERNATE_ENTITY_CLASS = "hibernateEntityClass";
String TYPE = "HibernateEntityModel";
String APPLICATION = "application";

/**
* Contains the application in which this Spring Bean was discovered.
*/
@Adjacency(label = APPLICATION, direction = Direction.OUT)
ProjectModel getApplication();

/**
* Contains the application in which this Spring Bean was discovered.
*/
@Adjacency(label = APPLICATION, direction = Direction.OUT)
void setApplication(ProjectModel projectModel);

/**
* Contains the specification version
*/
@Property(SPECIFICATION_VERSION)
public String getSpecificationVersion();
String getSpecificationVersion();

/**
* Contains the specification version
*/
@Property(SPECIFICATION_VERSION)
public void setSpecificationVersion(String version);
void setSpecificationVersion(String version);

/**
* Contains the table name
*/
@Property(TABLE_NAME)
public String getTableName();
String getTableName();

/**
* Contains the table name
*/
@Property(TABLE_NAME)
public void setTableName(String tableName);
void setTableName(String tableName);

/**
* Contains the schema name
*/
@Property(SCHEMA_NAME)
public String getSchemaName();
String getSchemaName();

/**
* Contains the schema name
*/
@Property(SCHEMA_NAME)
public void setSchemaName(String schemaName);
void setSchemaName(String schemaName);

/**
* Contains the catalog name
*/
@Property(CATALOG_NAME)
public String getCatalogName();
String getCatalogName();

/**
* Contains the catalog name
*/
@Property(CATALOG_NAME)
public void setCatalogName(String catalogName);
void setCatalogName(String catalogName);

/**
* Contains the entity class
*/
@Adjacency(label = HIBERNATE_ENTITY_CLASS, direction = Direction.OUT)
public void setJavaClass(JavaClassModel ejbHome);
void setJavaClass(JavaClassModel entityClass);

/**
* Contains the entity class
*/
@Adjacency(label = HIBERNATE_ENTITY_CLASS, direction = Direction.OUT)
public JavaClassModel getJavaClass();
JavaClassModel getJavaClass();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.windup.rules.apps.javaee.model;

import org.jboss.windup.graph.Indexed;
import org.jboss.windup.graph.model.ProjectModel;
import org.jboss.windup.graph.model.WindupVertexFrame;
import org.jboss.windup.rules.apps.java.model.JavaClassModel;

Expand All @@ -11,52 +12,65 @@

/**
* Contains metadata associated with a Spring Bean.
*
*
* @author <a href="mailto:jesse.sightler@gmail.com">Jesse Sightler</a>
*
*
*/
@TypeValue(SpringBeanModel.TYPE)
public interface SpringBeanModel extends WindupVertexFrame
{
public static final String TYPE = "SpringBeanModel";
public static final String SPRING_BEAN_TO_JAVA_CLASS = "springBeanToJavaClass";
public static final String SPRING_CONFIGURATION = "springConfiguration";
public static final String SPRING_BEAN_NAME = "springBeanName";
String TYPE = "SpringBeanModel";
String SPRING_BEAN_TO_JAVA_CLASS = "springBeanToJavaClass";
String SPRING_CONFIGURATION = "springConfiguration";
String SPRING_BEAN_NAME = "springBeanName";
String APPLICATION = "application";

/**
* The name of this spring bean
*/
@Indexed
@Property(SPRING_BEAN_NAME)
public String getSpringBeanName();
String getSpringBeanName();

/**
* The name of this spring bean
*/
@Property(SPRING_BEAN_NAME)
public String setSpringBeanName(String springBeanName);
String setSpringBeanName(String springBeanName);

/**
* The Spring configuration file in which this Spring Bean was defined.
*/
@Adjacency(label = SPRING_CONFIGURATION, direction = Direction.IN)
public SpringConfigurationFileModel getSpringConfiguration();
SpringConfigurationFileModel getSpringConfiguration();

/**
* The Spring configuration file in which this Spring Bean was defined.
*/
@Adjacency(label = SPRING_CONFIGURATION, direction = Direction.IN)
public void setSpringConfiguration(SpringConfigurationFileModel springConfiguration);
void setSpringConfiguration(SpringConfigurationFileModel springConfiguration);

/**
* This points to the @{link JavaClassModel} referenced by this Spring Bean
*/
@Adjacency(label = SPRING_BEAN_TO_JAVA_CLASS, direction = Direction.OUT)
public JavaClassModel getJavaClass();
JavaClassModel getJavaClass();

/**
* This points to the @{link JavaClassModel} referenced by this Spring Bean
*/
@Adjacency(label = SPRING_BEAN_TO_JAVA_CLASS, direction = Direction.OUT)
public void setJavaClass(JavaClassModel m);
void setJavaClass(JavaClassModel m);

/**
* Contains the application in which this Spring Bean was discovered.
*/
@Adjacency(label = APPLICATION, direction = Direction.OUT)
ProjectModel getApplication();

/**
* Contains the application in which this Spring Bean was discovered.
*/
@Adjacency(label = APPLICATION, direction = Direction.OUT)
void setApplication(ProjectModel projectModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ private void createHibernateReport(GraphContext context, ProjectModel projectMod
HibernateEntityService hibernateEntityService = new HibernateEntityService(context);
GraphService<WindupVertexListModel> listService = new GraphService<>(context, WindupVertexListModel.class);

WindupVertexListModel hibernateConfigList = listService.create();
for (HibernateConfigurationFileModel hibernateConfig : hibernateConfigurationFileService.findAll())
@SuppressWarnings("unchecked")
WindupVertexListModel<HibernateConfigurationFileModel> hibernateConfigList = listService.create();
for (HibernateConfigurationFileModel hibernateConfig : hibernateConfigurationFileService.findAllByApplication(projectModel))
{
hibernateConfigList.addItem(hibernateConfig);
}

WindupVertexListModel entityList = listService.create();
for (HibernateEntityModel entityModel : hibernateEntityService.findAll())
@SuppressWarnings("unchecked")
WindupVertexListModel<HibernateEntityModel> entityList = listService.create();
for (HibernateEntityModel entityModel : hibernateEntityService.findAllByApplication(projectModel))
{
entityList.addItem(entityModel);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.windup.rules.apps.javaee.rules;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jboss.forge.furnace.versions.EmptyVersionRange;
Expand Down Expand Up @@ -43,7 +44,8 @@ public class CreateSpringBeanReportRuleProvider extends AbstractRuleProvider
public CreateSpringBeanReportRuleProvider()
{
super(MetadataBuilder.forProvider(CreateSpringBeanReportRuleProvider.class, "Create Spring Bean Report")
.setPhase(ReportGenerationPhase.class).addSourceTechnology(new TechnologyReference("spring", new EmptyVersionRange())));
.setPhase(ReportGenerationPhase.class)
.addSourceTechnology(new TechnologyReference("spring", new EmptyVersionRange())));
}

@Override
Expand All @@ -57,7 +59,8 @@ public Configuration getConfiguration(GraphContext context)
@Override
public void perform(GraphRewrite event, EvaluationContext context)
{
WindupConfigurationModel windupConfiguration = WindupConfigurationService.getConfigurationModel(event.getGraphContext());
WindupConfigurationModel windupConfiguration = WindupConfigurationService
.getConfigurationModel(event.getGraphContext());
for (FileModel inputPath : windupConfiguration.getInputPaths())
{
ProjectModel projectModel = inputPath.getProjectModel();
Expand All @@ -84,6 +87,12 @@ public String toString()

private void createSpringBeanReport(GraphContext context, ProjectModel projectModel)
{
SpringBeanService springBeanService = new SpringBeanService(context);
Iterable<SpringBeanModel> models = springBeanService.findAllByApplication(projectModel);
if (!models.iterator().hasNext())
{
return;
}
ApplicationReportService applicationReportService = new ApplicationReportService(context);
ApplicationReportModel applicationReportModel = applicationReportService.create();
applicationReportModel.setReportPriority(500);
Expand All @@ -96,14 +105,11 @@ private void createSpringBeanReport(GraphContext context, ProjectModel projectMo
applicationReportModel.setTemplatePath(TEMPLATE_SPRING_REPORT);
applicationReportModel.setTemplateType(TemplateType.FREEMARKER);

SpringBeanService springBeanService = new SpringBeanService(context);
GraphService<WindupVertexListModel> listService = new GraphService<>(context, WindupVertexListModel.class);

WindupVertexListModel springBeanList = listService.create();
for (SpringBeanModel springBeanModel : springBeanService.findAll())
{
springBeanList.addItem(springBeanModel);
}
@SuppressWarnings("unchecked")
WindupVertexListModel<SpringBeanModel> springBeanList = listService.create();
springBeanList.addAll(models);

Map<String, WindupVertexFrame> additionalData = new HashMap<>(2);
additionalData.put("springBeans", springBeanList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public void perform(GraphRewrite event, EvaluationContext context, DoctypeMetaMo
// create the hibernate facet.
HibernateEntityModel hibernateEntity = hibernateEntityService.create();
hibernateEntity.setSpecificationVersion(versionInformation);
hibernateEntity.setApplication(xml.getApplication());
hibernateEntity.setJavaClass(clz);
hibernateEntity.setTableName(tableName);
hibernateEntity.setSchemaName(schemaName);
Expand Down
Loading

0 comments on commit 02b9a18

Please sign in to comment.