This commit is contained in:
Michele Artini 2019-03-22 10:16:47 +01:00
parent 042d477878
commit 55aa7e1f26
4 changed files with 43 additions and 13 deletions

View File

@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import eu.dnetlib.data.mdstore.manager.exceptions.MDStoreManagerException;
import eu.dnetlib.data.mdstore.manager.exceptions.NoContentException;
import eu.dnetlib.data.mdstore.manager.model.MDStore;
@ -101,6 +103,12 @@ public class MDStoreController {
mdstoreRepository.deleteById(mdId);
}
@Transactional
@RequestMapping(value = "/mdstore/{mdId}/versions", method = RequestMethod.GET)
public List<MDStoreVersion> listVersions(@PathVariable final String mdId) throws MDStoreManagerException {
return Lists.newArrayList(mdstoreVersionRepository.findByMdstore(mdId));
}
@Transactional
@RequestMapping(value = "/mdstore/{mdId}/newVersion", method = RequestMethod.GET)
public MDStoreVersion prepareNewVersion1(@PathVariable final String mdId) {

View File

@ -36,7 +36,7 @@ public class MDStoreWithInfo implements Serializable {
private String datasourceId;
@Column(name = "api_id")
private String apiId ;
private String apiId;
@Column(name = "current_version")
private String currentVersion;
@ -48,11 +48,14 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "size")
private int size;
@Column(name = "n_versions")
private long numberOfVersions;
public String getId() {
return id;
}
public void setId(String id) {
public void setId(final String id) {
this.id = id;
}
@ -60,7 +63,7 @@ public class MDStoreWithInfo implements Serializable {
return format;
}
public void setFormat(String format) {
public void setFormat(final String format) {
this.format = format;
}
@ -68,7 +71,7 @@ public class MDStoreWithInfo implements Serializable {
return layout;
}
public void setLayout(String layout) {
public void setLayout(final String layout) {
this.layout = layout;
}
@ -76,7 +79,7 @@ public class MDStoreWithInfo implements Serializable {
return interpretation;
}
public void setInterpretation(String interpretation) {
public void setInterpretation(final String interpretation) {
this.interpretation = interpretation;
}
@ -84,7 +87,7 @@ public class MDStoreWithInfo implements Serializable {
return datasourceId;
}
public void setDatasourceId(String datasourceId) {
public void setDatasourceId(final String datasourceId) {
this.datasourceId = datasourceId;
}
@ -92,7 +95,7 @@ public class MDStoreWithInfo implements Serializable {
return apiId;
}
public void setApiId(String apiId) {
public void setApiId(final String apiId) {
this.apiId = apiId;
}
@ -100,7 +103,7 @@ public class MDStoreWithInfo implements Serializable {
return currentVersion;
}
public void setCurrentVersion(String currentVersion) {
public void setCurrentVersion(final String currentVersion) {
this.currentVersion = currentVersion;
}
@ -108,7 +111,7 @@ public class MDStoreWithInfo implements Serializable {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
public void setLastUpdate(final Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
@ -116,9 +119,15 @@ public class MDStoreWithInfo implements Serializable {
return size;
}
public void setSize(int size) {
public void setSize(final int size) {
this.size = size;
}
public long getNumberOfVersions() {
return numberOfVersions;
}
public void setNumberOfVersions(final long numberOfVersions) {
this.numberOfVersions = numberOfVersions;
}
}

View File

@ -14,4 +14,6 @@ public interface MDStoreVersionRepository extends JpaRepository<MDStoreVersion,
int countByMdstoreAndReadCountGreaterThan(String id, int count);
Iterable<MDStoreVersion> findByMdstore(String mdId);
}

View File

@ -34,9 +34,20 @@ CREATE VIEW mdstores_with_info AS SELECT
md.datasource_id AS datasource_id,
md.api_id AS api_id,
cv.current_version AS current_version,
v.lastupdate AS lastupdate,
v.size AS size
v1.lastupdate AS lastupdate,
v1.size AS size,
count(v2.id) AS n_versions
FROM
mdstores md
LEFT OUTER JOIN mdstore_current_versions cv ON (md.id = cv.mdstore)
LEFT OUTER JOIN mdstore_versions v ON (cv.current_version = v.id);
LEFT OUTER JOIN mdstore_versions v1 ON (cv.current_version = v1.id)
LEFT OUTER JOIN mdstore_versions v2 ON (md.id = v2.id)
GROUP BY md.id,
md.format,
md.layout,
md.interpretation,
md.datasource_id,
md.api_id,
cv.current_version,
v1.lastupdate,
v1.size;