Skip to content
Snippets Groups Projects
Commit e59dd18f authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

Model -> Chart -> SVG works

parent 9e1d91a3
No related branches found
No related tags found
No related merge requests found
...@@ -91,6 +91,21 @@ public class ModelsApi { ...@@ -91,6 +91,21 @@ public class ModelsApi {
return new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Get SVG", notes = "", response = Model.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Found"),
@ApiResponse(code = 404, message = "Not found")})
@RequestMapping(value = "/{slug}.svg", produces = {"image/svg+xml"}, method = RequestMethod.GET)
public ResponseEntity<String> getSVG(
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug) throws NotFoundException {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
org.hibernate.Query query = session.createQuery("from Model where slug= :slug");
query.setString("slug", slug);
Model model = (Model) query.uniqueResult();
session.getTransaction().commit();
return new ResponseEntity<String>(HttpStatus.OK).ok(model.getChart().getSvg());
}
@ApiOperation(value = "Get a model", notes = "", response = Model.class) @ApiOperation(value = "Get a model", notes = "", response = Model.class)
@ApiResponses(value = { @ApiResponses(value = {
......
...@@ -25,6 +25,7 @@ public class Article { ...@@ -25,6 +25,7 @@ public class Article {
private String title = null; private String title = null;
private String status = null; private String status = null;
private String _abstract = null; private String _abstract = null;
@Column(columnDefinition = "text")
private String content = null; private String content = null;
private Date publishedAt = null; private Date publishedAt = null;
private Date createdAt = null; private Date createdAt = null;
......
...@@ -26,6 +26,9 @@ public class Chart { ...@@ -26,6 +26,9 @@ public class Chart {
private Long id = null; private Long id = null;
private String chartType = null; private String chartType = null;
private String xAxis = null; private String xAxis = null;
// TODO: Should I use @Lob ?
@Column(columnDefinition = "text")
private String svg = null;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<ChartConfigSet> chartConfigSets = new LinkedList<ChartConfigSet>(); private List<ChartConfigSet> chartConfigSets = new LinkedList<ChartConfigSet>();
...@@ -71,6 +74,14 @@ public class Chart { ...@@ -71,6 +74,14 @@ public class Chart {
this.xAxis = xAxis; this.xAxis = xAxis;
} }
public String getSvg() {
return svg;
}
public void setSvg(String svg) {
this.svg = svg;
}
/** /**
* Chart configuration * Chart configuration
**/ **/
...@@ -92,6 +103,7 @@ public class Chart { ...@@ -92,6 +103,7 @@ public class Chart {
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(id).append("\n");
sb.append(" chartType: ").append(chartType).append("\n"); sb.append(" chartType: ").append(chartType).append("\n");
sb.append(" xAxis: ").append(xAxis).append("\n"); sb.append(" xAxis: ").append(xAxis).append("\n");
sb.append(" svg: ").append(svg).append("\n");
sb.append(" chartConfigSets: ").append(chartConfigSets).append("\n"); sb.append(" chartConfigSets: ").append(chartConfigSets).append("\n");
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL82Dialect</property> <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL82Dialect</property>
<property name="current_session_context_class">thread</property> <property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hibernate.show_sql">true</property> <property name="hibernate.show_sql">false</property>
<property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="org.hbp.mip.model.Article"/> <mapping class="org.hbp.mip.model.Article"/>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment