56 lines
2.1 KiB
Java
56 lines
2.1 KiB
Java
package eu.dnetlib.data.mdstore;
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import eu.dnetlib.data.mdstore.model.MetadataRecord;
|
|
import eu.dnetlib.errors.MDStoreManagerException;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
@RestController
|
|
@RequestMapping("/ajax/mdstores")
|
|
@Tag(name = "Metadata Stores")
|
|
public class MDStoreAjaxController extends AbstractMDStoreController {
|
|
|
|
@Value("${dhp.mdstore-manager.hadoop.cluster}")
|
|
private String hadoopCluster;
|
|
|
|
@Value("${dhp.mdstore-manager.hadoop.user}")
|
|
private String hadoopUser;
|
|
|
|
@Value("${dhp.mdstore-manager.hdfs.base-path}")
|
|
private String hdfsBasePath;
|
|
|
|
@Operation(summary = "Show informations")
|
|
@GetMapping("/info")
|
|
public Map<String, Object> info() {
|
|
final Map<String, Object> info = new LinkedHashMap<>();
|
|
info.put("number_of_mdstores", service.countMdStores());
|
|
info.put("hadoop_user", hadoopUser);
|
|
info.put("hadoop_cluster", hadoopCluster);
|
|
info.put("hdfs_base_path", hdfsBasePath);
|
|
info.put("expired_versions", service.listExpiredVersions());
|
|
return info;
|
|
}
|
|
|
|
@Operation(summary = "read the parquet file of a mdstore version")
|
|
@GetMapping("/version/{versionId}/content/{limit}")
|
|
public List<MetadataRecord> listVersionRecords(@PathVariable final String versionId, @PathVariable final long limit) throws MDStoreManagerException {
|
|
return service.listVersionRecords(versionId, limit);
|
|
}
|
|
|
|
@Operation(summary = "read the parquet file of a mdstore (current version)")
|
|
@GetMapping("/mdstore/{mdId}/content/{limit}")
|
|
public List<MetadataRecord> listMdstoreRecords(@PathVariable final String mdId, @PathVariable final long limit) throws MDStoreManagerException {
|
|
return service.listVersionRecords(service.findMdStore(mdId).getCurrentVersion(), limit);
|
|
}
|
|
}
|