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 layout") @PathVariable final String layout,
@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("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"));
}
@Transactional
private String _createMDStore(final String format, final String layout, final String interpretation, final String dsId, final String apiId) {
final MDStore md = MDStore.newInstance(dsId, apiId, format, layout, interpretation);
private String _createMDStore(final String format,
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);
final MDStoreVersion v = MDStoreVersion.newInstance(md.getId(), false);
@ -133,7 +139,7 @@ public class MDStoreController {
@ApiOperation(value = "Promote a preliminary version to current")
@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,
@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));
mdstoreCurrentVersionRepository.save(MDStoreCurrentVersion.newInstance(v));
v.setWriting(false);

View File

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

View File

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

View File

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

View File

@ -32,6 +32,9 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "interpretation")
private String interpretation;
@Column(name = "datasource_name")
private String datasourceName;
@Column(name = "datasource_id")
private String datasourceId;
@ -46,10 +49,10 @@ public class MDStoreWithInfo implements Serializable {
private Date lastUpdate;
@Column(name = "size")
private long size;
private long size = 0;
@Column(name = "n_versions")
private long numberOfVersions;
private long numberOfVersions = 0;
public String getId() {
return id;
@ -83,6 +86,14 @@ public class MDStoreWithInfo implements Serializable {
this.interpretation = interpretation;
}
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(final String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceId() {
return datasourceId;
}
@ -130,4 +141,5 @@ public class MDStoreWithInfo implements Serializable {
public void setNumberOfVersions(final long 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.jdbc.lob.non_contextual_creation=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,
layout text,
interpretation text,
datasource_name text,
datasource_id text,
api_id text
);
@ -31,6 +32,7 @@ CREATE VIEW mdstores_with_info AS SELECT
md.format AS format,
md.layout AS layout,
md.interpretation AS interpretation,
md.datasource_name AS datasource_name,
md.datasource_id AS datasource_id,
md.api_id AS api_id,
cv.current_version AS current_version,
@ -46,6 +48,7 @@ GROUP BY md.id,
md.format,
md.layout,
md.interpretation,
md.datasource_name,
md.datasource_id,
md.api_id,
cv.current_version,

View File

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