logs and ui

This commit is contained in:
Michele Artini 2019-03-22 11:41:00 +01:00
parent 405f418dfc
commit e2f1013b3d
8 changed files with 81 additions and 45 deletions

View File

@ -77,15 +77,21 @@ public class MDStoreController {
@ApiParam("mdstore format") @PathVariable final String format, @ApiParam("mdstore format") @PathVariable final String format,
@ApiParam("mdstore layout") @PathVariable final String layout, @ApiParam("mdstore layout") @PathVariable final String layout,
@ApiParam("mdstore interpretation") @PathVariable final String interpretation, @ApiParam("mdstore interpretation") @PathVariable final String interpretation,
@ApiParam("datasource name") @RequestParam(required = false) final String dsName,
@ApiParam("datasource id") @RequestParam(required = false) final String dsId, @ApiParam("datasource id") @RequestParam(required = false) final String dsId,
@ApiParam("api id") @RequestParam(required = false) final String apiId) throws MDStoreManagerException { @ApiParam("api id") @RequestParam(required = false) final String apiId) throws MDStoreManagerException {
final String id = _createMDStore(format, layout, interpretation, dsId, apiId); final String id = _createMDStore(format, layout, interpretation, dsName, dsId, apiId);
return mdstoreWithInfoRepository.findById(id).orElseThrow(() -> new MDStoreManagerException("MDStore not found")); return mdstoreWithInfoRepository.findById(id).orElseThrow(() -> new MDStoreManagerException("MDStore not found"));
} }
@Transactional @Transactional
private String _createMDStore(final String format, final String layout, final String interpretation, final String dsId, final String apiId) { private String _createMDStore(final String format,
final MDStore md = MDStore.newInstance(dsId, apiId, format, layout, interpretation); final String layout,
final String interpretation,
final String dsName,
final String dsId,
final String apiId) {
final MDStore md = MDStore.newInstance(format, layout, interpretation, dsName, dsId, apiId);
mdstoreRepository.save(md); mdstoreRepository.save(md);
final MDStoreVersion v = MDStoreVersion.newInstance(md.getId(), false); final MDStoreVersion v = MDStoreVersion.newInstance(md.getId(), false);
@ -133,7 +139,7 @@ public class MDStoreController {
@ApiOperation(value = "Promote a preliminary version to current") @ApiOperation(value = "Promote a preliminary version to current")
@RequestMapping(value = "/version/{versionId}/commit/{size}", method = RequestMethod.GET) @RequestMapping(value = "/version/{versionId}/commit/{size}", method = RequestMethod.GET)
public void commitVersion(@ApiParam("the id of the version that will be promoted to the current version") @PathVariable final String versionId, public void commitVersion(@ApiParam("the id of the version that will be promoted to the current version") @PathVariable final String versionId,
@ApiParam("the size of the new current mdstore") @PathVariable final int size) throws NoContentException { @ApiParam(value = "the size of the new current mdstore") @PathVariable final long size) throws NoContentException {
final MDStoreVersion v = mdstoreVersionRepository.findById(versionId).orElseThrow(() -> new NoContentException("Invalid version: " + versionId)); final MDStoreVersion v = mdstoreVersionRepository.findById(versionId).orElseThrow(() -> new NoContentException("Invalid version: " + versionId));
mdstoreCurrentVersionRepository.save(MDStoreCurrentVersion.newInstance(v)); mdstoreCurrentVersionRepository.save(MDStoreCurrentVersion.newInstance(v));
v.setWriting(false); v.setWriting(false);

View File

@ -27,22 +27,23 @@ public class MDStore implements Serializable {
@Column(name = "layout") @Column(name = "layout")
private String layout; private String layout;
@Column(name = "interpretation") @Column(name = "interpretation")
private String interpretation; private String interpretation;
@Column(name = "datasource_name")
private String datasourceName;
@Column(name = "datasource_id") @Column(name = "datasource_id")
private String datasourceId; private String datasourceId;
@Column(name = "api_id") @Column(name = "api_id")
private String apiId ; private String apiId;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(final String id) {
this.id = id; this.id = id;
} }
@ -50,7 +51,7 @@ public class MDStore implements Serializable {
return format; return format;
} }
public void setFormat(String format) { public void setFormat(final String format) {
this.format = format; this.format = format;
} }
@ -58,7 +59,7 @@ public class MDStore implements Serializable {
return layout; return layout;
} }
public void setLayout(String layout) { public void setLayout(final String layout) {
this.layout = layout; this.layout = layout;
} }
@ -66,15 +67,23 @@ public class MDStore implements Serializable {
return interpretation; return interpretation;
} }
public void setInterpretation(String interpretation) { public void setInterpretation(final String interpretation) {
this.interpretation = interpretation; this.interpretation = interpretation;
} }
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(final String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceId() { public String getDatasourceId() {
return datasourceId; return datasourceId;
} }
public void setDatasourceId(String datasourceId) { public void setDatasourceId(final String datasourceId) {
this.datasourceId = datasourceId; this.datasourceId = datasourceId;
} }
@ -82,27 +91,29 @@ public class MDStore implements Serializable {
return apiId; return apiId;
} }
public void setApiId(String apiId) { public void setApiId(final String apiId) {
this.apiId = apiId; this.apiId = apiId;
} }
public static MDStore newInstance(final String format, final String layout, final String interpretation) { public static MDStore newInstance(final String format, final String layout, final String interpretation) {
return newInstance(null, null, format, layout, interpretation); return newInstance(format, layout, interpretation, null, null, null);
} }
public static MDStore newInstance(final String dsId, final String apiId, final String format, final String layout, final String interpretation) { public static MDStore newInstance(final String format,
final String layout,
final String interpretation,
final String dsName,
final String dsId,
final String apiId) {
final MDStore md = new MDStore(); final MDStore md = new MDStore();
md.setId("md-" + UUID.randomUUID()); md.setId("md-" + UUID.randomUUID());
md.setDatasourceId(dsId);
md.setApiId(apiId);
md.setFormat(format); md.setFormat(format);
md.setLayout(layout); md.setLayout(layout);
md.setInterpretation(interpretation); md.setInterpretation(interpretation);
md.setDatasourceName(dsName);
md.setDatasourceId(dsId);
md.setApiId(apiId);
return md; return md;
} }
} }

View File

@ -27,7 +27,7 @@ public class MDStoreCurrentVersion implements Serializable {
return mdstore; return mdstore;
} }
public void setMdstore(String mdstore) { public void setMdstore(final String mdstore) {
this.mdstore = mdstore; this.mdstore = mdstore;
} }
@ -35,14 +35,10 @@ public class MDStoreCurrentVersion implements Serializable {
return currentVersion; return currentVersion;
} }
public void setCurrentVersion(String currentVersion) { public void setCurrentVersion(final String currentVersion) {
this.currentVersion = currentVersion; this.currentVersion = currentVersion;
} }
public static long getSerialversionuid() {
return serialVersionUID;
}
public static MDStoreCurrentVersion newInstance(final String mdId, final String versionId) { public static MDStoreCurrentVersion newInstance(final String mdId, final String versionId) {
final MDStoreCurrentVersion cv = new MDStoreCurrentVersion(); final MDStoreCurrentVersion cv = new MDStoreCurrentVersion();
cv.setMdstore(mdId); cv.setMdstore(mdId);

View File

@ -30,14 +30,14 @@ public class MDStoreVersion implements Serializable {
private boolean writing; private boolean writing;
@Column(name = "readcount") @Column(name = "readcount")
private int readCount; private int readCount = 0;
@Column(name = "lastupdate") @Column(name = "lastupdate")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date lastUpdate; private Date lastUpdate;
@Column(name = "size") @Column(name = "size")
private long size; private long size = 0;
public static MDStoreVersion newInstance(final String mdId, final boolean writing) { public static MDStoreVersion newInstance(final String mdId, final boolean writing) {
final MDStoreVersion t = new MDStoreVersion(); final MDStoreVersion t = new MDStoreVersion();

View File

@ -32,6 +32,9 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "interpretation") @Column(name = "interpretation")
private String interpretation; private String interpretation;
@Column(name = "datasource_name")
private String datasourceName;
@Column(name = "datasource_id") @Column(name = "datasource_id")
private String datasourceId; private String datasourceId;
@ -46,10 +49,10 @@ public class MDStoreWithInfo implements Serializable {
private Date lastUpdate; private Date lastUpdate;
@Column(name = "size") @Column(name = "size")
private long size; private long size = 0;
@Column(name = "n_versions") @Column(name = "n_versions")
private long numberOfVersions; private long numberOfVersions = 0;
public String getId() { public String getId() {
return id; return id;
@ -83,6 +86,14 @@ public class MDStoreWithInfo implements Serializable {
this.interpretation = interpretation; this.interpretation = interpretation;
} }
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(final String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceId() { public String getDatasourceId() {
return datasourceId; return datasourceId;
} }
@ -130,4 +141,5 @@ public class MDStoreWithInfo implements Serializable {
public void setNumberOfVersions(final long numberOfVersions) { public void setNumberOfVersions(final long numberOfVersions) {
this.numberOfVersions = numberOfVersions; this.numberOfVersions = numberOfVersions;
} }
} }

View File

@ -12,3 +12,6 @@ spring.jpa.hibernate.ddl-auto = validate
spring.jpa.properties.hibernate.hbm2dll.extra_physical_table_types = MATERIALIZED VIEW spring.jpa.properties.hibernate.hbm2dll.extra_physical_table_types = MATERIALIZED VIEW
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.open-in-view=true spring.jpa.open-in-view=true
# logs
logging.level.io.swagger.models.parameters.AbstractSerializableParameter = error

View File

@ -8,6 +8,7 @@ CREATE TABLE mdstores (
format text, format text,
layout text, layout text,
interpretation text, interpretation text,
datasource_name text,
datasource_id text, datasource_id text,
api_id text api_id text
); );
@ -31,6 +32,7 @@ CREATE VIEW mdstores_with_info AS SELECT
md.format AS format, md.format AS format,
md.layout AS layout, md.layout AS layout,
md.interpretation AS interpretation, md.interpretation AS interpretation,
md.datasource_name AS datasource_name,
md.datasource_id AS datasource_id, md.datasource_id AS datasource_id,
md.api_id AS api_id, md.api_id AS api_id,
cv.current_version AS current_version, cv.current_version AS current_version,
@ -46,6 +48,7 @@ GROUP BY md.id,
md.format, md.format,
md.layout, md.layout,
md.interpretation, md.interpretation,
md.datasource_name,
md.datasource_id, md.datasource_id,
md.api_id, md.api_id,
cv.current_version, cv.current_version,

View File

@ -17,27 +17,32 @@
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Format</th> <th>Format / Layout / Interpretation</th>
<th>Layout</th> <th>Datasource</th>
<th>Interpretation</th> <th>Current Version</th>
<th>Datasource ID</th> <th class="text-right">All versions</th>
<th>Api ID</th> <th class="text-center">Last Update</th>
<th>Current Version ID</th> <th class="text-right">Size</th>
<th>Last Update</th>
<th>Size</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="md in mdstores"> <tr ng-repeat="md in mdstores">
<td>{{md.id}}</td> <td>{{md.id}}</td>
<td>{{md.format}}</td> <td>{{md.format}} / {{md.layout}} / {{md.interpretation}}</td>
<td>{{md.layout}}</td> <td>
<td>{{md.interpretation}}</td> <span ng-if="md.datasourceName">
<td>{{md.datasourceId}}</td> {{md.datasourceName}}<br />
<small>
<b>id: </b>{{md.datasourceId}}
<b>api: </b>{{md.apiId}}
</small>
</span>
</td>
<td>{{md.apiId}}</td> <td>{{md.apiId}}</td>
<td>{{md.currentVersion}}</td> <td>{{md.currentVersion}}</td>
<td>{{md.lastUpdate}}</td> <td class="text-right">{{md.numberOfVersions}}</td>
<td>{{md.size}}</td> <td class="text-center">{{md.lastUpdate}}</td>
<td class="text-right">{{md.size}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>