TODO verification

This commit is contained in:
Michele Artini 2023-10-13 12:09:05 +02:00
parent 04d08abbc5
commit bc98bd79b9
29 changed files with 120 additions and 107 deletions

View File

@ -186,7 +186,7 @@ public class DsmApiControllerV1 extends AbstractDsmController {
@PostMapping("/ds/add")
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException {
if (dsmService.existDs(datasource.getId())) { // TODO further check that the DS doesn't have any API
if (dsmService.existDs(datasource.getId())) {
throw new DsmException(String.format("cannot register, datasource already defined '%s'", datasource.getId()));
}
dsmService.saveDs(DsmMappingUtils.asDbEntry(datasource));
@ -196,7 +196,7 @@ public class DsmApiControllerV1 extends AbstractDsmController {
@PostMapping("/ds/addWithApis")
public void saveDsWithApis(@Valid @RequestBody final DatasourceDetailsWithApis d) throws DsmException {
if (d.getDatasource() == null) { throw new DsmException("Datasource field is null"); }
if (dsmService.existDs(d.getDatasource().getId())) { // TODO further check that the DS doesn't have any API
if (dsmService.existDs(d.getDatasource().getId())) {
throw new DsmException(String.format("cannot register, datasource already defined '%s'", d.getDatasource().getId()));
}
dsmService.addDsAndApis(DsmMappingUtils.asDbEntry(d.getDatasource()), d.getApis());

View File

@ -46,7 +46,7 @@ import eu.dnetlib.domain.dsm.info.SimpleDatasourceInfo;
import eu.dnetlib.domain.dsm.info.SimpleResponse;
import eu.dnetlib.domain.dsm.readonly.ApiWithAdditionalInfo;
import eu.dnetlib.domain.dsm.readonly.SimpleDsWithApis;
import eu.dnetlib.domain.vocabulary.Vocabulary;
import eu.dnetlib.errors.DnetRuntimeException;
import eu.dnetlib.errors.DsmException;
import eu.dnetlib.errors.DsmForbiddenException;
import eu.dnetlib.errors.DsmNotFoundException;
@ -89,21 +89,11 @@ public class DsmService {
public Object setApiActive;
public List<Country> listCountries() throws DsmException {
final List<Country> countries = new ArrayList<>();
// TODO Usare solo vocabolari???
final VocabularyClient vocabularyClient = clientFactory.getClient(VocabularyClient.class);
final Vocabulary v = vocabularyClient.getCountries();
countries.addAll(browseTerm(DsmBrowsableFields.country)
return browseTerm(DsmBrowsableFields.country)
.stream()
.filter(Objects::nonNull)
.map(t -> new Country(t.getTerm(), t.getName()))
.collect(Collectors.toList()));
return countries;
.collect(Collectors.toList());
}
@Transactional
@ -214,8 +204,15 @@ public class DsmService {
}
public void updateName(final String dsId, final String officialname, final String englishname) {
// TODO what if one of the two names is null or empty?
dsRepository.setDatasourcename(dsId, officialname, englishname);
if (StringUtils.isNoneBlank(officialname, englishname)) {
dsRepository.setDatasourcename(dsId, officialname, englishname);
} else if (StringUtils.isNotBlank(officialname)) {
dsRepository.setDatasourcename(dsId, officialname, officialname);
} else if (StringUtils.isNotBlank(englishname)) {
dsRepository.setDatasourcename(dsId, englishname, englishname);
} else {
throw new DnetRuntimeException("Both datasource names are empty");
}
}
public void updateLogoUrl(final String dsId, final String logourl) throws DsmException {

View File

@ -62,8 +62,8 @@ public class MDStoreService {
public List<MDStoreWithInfo> listMdStores() {
return StreamSupport.stream(mdstoreWithInfoRepository.findAll().spliterator(), false)
.sorted(Comparator.comparing((Function<MDStoreWithInfo, String>) md -> md.getDatasourceName()).thenComparing(md -> md.getId()))
.collect(Collectors.toList());
.sorted(Comparator.comparing((Function<MDStoreWithInfo, String>) MDStoreWithInfo::getDatasourceName).thenComparing(MDStoreWithInfo::getId))
.collect(Collectors.toList());
}
public List<String> listMdStoreIDs() {
@ -80,7 +80,7 @@ public class MDStoreService {
public List<String> listExpiredVersions() {
return jdbcTemplate
.queryForList("select v.id from mdstore_versions v left outer join mdstore_current_versions cv on (v.id = cv.current_version) where v.writing = false and v.readcount = 0 and cv.mdstore is null;", String.class);
.queryForList("select v.id from mdstore_versions v left outer join mdstore_current_versions cv on (v.id = cv.current_version) where v.writing = false and v.readcount = 0 and cv.mdstore is null;", String.class);
}
public MDStoreWithInfo findMdStore(final String mdId) throws MDStoreManagerException {
@ -93,12 +93,12 @@ public class MDStoreService {
@Transactional
public String createMDStore(final String format,
final String layout,
final String interpretation,
final MDStoreType type,
final String dsName,
final String dsId,
final String apiId) {
final String layout,
final String interpretation,
final MDStoreType type,
final String dsName,
final String dsId,
final String apiId) {
final MDStore md = newMDStore(format, layout, interpretation, type, dsName, dsId, apiId, apiId);
mdstoreRepository.save(md);
@ -154,9 +154,9 @@ public class MDStoreService {
@Transactional
public MDStoreVersion startReading(final String mdId) throws MDStoreManagerException {
final MDStoreCurrentVersion cv =
mdstoreCurrentVersionRepository.findById(mdId).orElseThrow(() -> new MDStoreManagerException("Missing mdstore: " + mdId));
mdstoreCurrentVersionRepository.findById(mdId).orElseThrow(() -> new MDStoreManagerException("Missing mdstore: " + mdId));
final MDStoreVersion v = mdstoreVersionRepository.findById(cv.getCurrentVersion())
.orElseThrow(() -> new MDStoreManagerException("Missing version: " + cv.getCurrentVersion()));
.orElseThrow(() -> new MDStoreManagerException("Missing version: " + cv.getCurrentVersion()));
v.setReadCount(v.getReadCount() + 1);
mdstoreVersionRepository.save(v);
return v;
@ -203,7 +203,7 @@ public class MDStoreService {
final MDStore md = mdstoreRepository.findById(v.getMdstore()).orElseThrow(() -> new MDStoreManagerException("Version not found"));
if (mdstoreCurrentVersionRepository
.countByCurrentVersion(versionId) > 0) {
.countByCurrentVersion(versionId) > 0) {
throw new MDStoreManagerException("I cannot delete this version because it is the current version");
}
@ -236,14 +236,14 @@ public class MDStoreService {
}
public MDStore newMDStore(
final String format,
final String layout,
final String interpretation,
final MDStoreType type,
final String dsName,
final String dsId,
final String apiId,
final String hdfsBasePath) {
final String format,
final String layout,
final String interpretation,
final MDStoreType type,
final String dsName,
final String dsId,
final String apiId,
final String hdfsBasePath) {
final String mdId = "md-" + UUID.randomUUID();
@ -268,18 +268,16 @@ public class MDStoreService {
// res.put(MDStoreType.HDFS, hdfsBackend.fixInconsistencies(delete));
res.put(MDStoreType.MOCK, mockBackend.fixInconsistencies(delete));
// TODO: ADD HERE THE INVOCATION FOR OTHER MDSTORE TYPE
// TODO (LOW PRIORITY): ADD HERE THE INVOCATION FOR OTHER MDSTORE TYPE
return res;
}
private MDStoreBackend selectBackend(final MDStoreType type) {
switch (type) {
case MOCK:
return mockBackend;
default:
return defaultBackend;
}
return switch (type) {
case MOCK -> mockBackend;
default -> defaultBackend;
};
}
public void addRecord(final String newVersion, final MDStoreType type, final MetadataRecord record) {

View File

@ -61,7 +61,7 @@ public class MdTransformJobNode extends AbstractJobNode {
final Predicate<Document> filter = XpathFilterFactory.createFilter(filterXpath);
final Map<String, String> params = new HashMap<>();
// TODO: which params ?
// TODO (LOW PRIORITY): which params ?
final RecordTransformer<String, String> xslt = xsltTransformFactory.getTransformer(ruleId, params);
mdstoreService.clearRecords(outputMdId);

View File

@ -5,7 +5,7 @@ import eu.dnetlib.domain.index.IndexConfiguration;
public class SolrIndexRecordFactory {
public static String createSolrDocument(final String xml, final IndexConfiguration conf) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
return null;
}

View File

@ -8,21 +8,21 @@ import eu.dnetlib.domain.index.IndexConfiguration;
public class SolrIndexService {
public boolean exists(final String id) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
return false;
}
public void createIndex(final IndexConfiguration conf) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}
public void addRecord(final String indexConfId, final String record) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}
public void deleteOldRecords(final long time) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}

View File

@ -6,21 +6,21 @@ import eu.dnetlib.domain.oai.OaiConfiguration;
public class OaiService {
public boolean exists(final String oaiConfId) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
return false;
}
public void createOaiCollection(final OaiConfiguration conf) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}
public void addRecord(final MetadataRecord record, final OaiConfiguration conf) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}
public void deleteOldRecords(final long start) {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
}

View File

@ -10,20 +10,20 @@ import eu.dnetlib.domain.mdstore.records.MetadataRecord;
public class DbMdStoreService {
public void clearRecords(final String mdId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public void addRecord(final String mdId, final MetadataRecord record) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public long getSize(final String mdId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return 0;
}
public Stream<MetadataRecord> listRecords(final String inputMdId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -32,7 +32,6 @@ public class WorkflowManagerService {
}
@Transactional
public List<WorkflowSection> listSections() {
return workflowSectionRepository.findAll();
}
@ -55,7 +54,8 @@ public class WorkflowManagerService {
}
private void checkConfiguration(final WorkflowConfiguration conf) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
// PS: THERE ARE OTHER FUNCTIONS WITH SAME NAME
}
@Transactional

View File

@ -15,13 +15,13 @@ public class BaseMDStoreClient extends DnetServiceClient {
final String officialname,
final String dsId,
final String apiId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public void deleteMdStore(final String mdId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}

View File

@ -10,42 +10,42 @@ public class DsmClient extends DnetServiceClient {
}
public Iterable<?> listProtocols() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Api updateUpdateApiCollectionInfo(final String apiId, final String mdId, final long size) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Api updateUpdateApiAggregationInfo(final String apiId, final String mdId, final long size) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Api updateUpdateApiDownloadInfo(final String apiId, final String objId, final long size) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Datasource findDs(final String dsId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Api findApi(final String apiId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public void setManaged(final Datasource ds, final boolean b) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public void setApiActive(final Api api, final boolean b) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}

View File

@ -9,10 +9,10 @@ public class EmailClient extends DnetServiceClient {
}
public void sendStoredMail(final String email, final String messageId, final Map<String, Object> params) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
// TODO portare qui la logica del template
// TODO (HIGH PRIORITY) portare qui la logica del template
}

View File

@ -9,7 +9,7 @@ public class IndexManagerClient extends DnetServiceClient {
}
public IndexConfiguration getIndexConfiguration(final String indexConfId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -9,7 +9,7 @@ public class OaiManagerClient extends DnetServiceClient {
}
public OaiConfiguration getOaiConfiguration(final String oaiConfId) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -11,37 +11,37 @@ public class SimpleResourceClient extends DnetServiceClient {
}
public List<String> listResources(final String type) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public String getResourceContent(final String id, final String type) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public SimpleResource findResource(final String id) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public <T> T findResourceContent(final String id, final Class<T> clazz) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public void deleteResource(final String id) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public void updateResource(final SimpleResource simpleResource, final Object content) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public SimpleResource prepareNewResource(final String name, final String desc, final String type, final Object content) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -7,45 +7,45 @@ public class VocabularyClient extends DnetServiceClient {
public VocabularyClient(final String baseUrl) {
super(baseUrl);
// TODO Auto-generated constructor stub
// TODO (HIGH PRIORITY) Auto-generated constructor stub
}
// TODO
// TODO (HIGH PRIORITY)
// Forse inutile,
// se serve solo per la UI conviene fare le chiamate direttamente al servizio dei vocabolari
public void dropCache() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public Vocabulary getCountries() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Vocabulary getDatasourceTypologies() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public boolean isValidTerm(final String string, final String type) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return false;
}
public Iterable<?> findTermsByVocabulary(final String vocabulary) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Iterable<Vocabulary> listVocs() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public Iterable<VocabularyTerm> listTerms(final String id) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -11,19 +11,19 @@ public class WfExecutorClient extends DnetServiceClient {
// Use a QUEUE or a DB table ?
public <T> String startWorkflow(final String wfId, final WorkflowConfiguration conf, final DnetCallback<T> processCallback) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
// return the processId ?
return null;
}
public void startWorkflowConfiguration(final WorkflowConfiguration conf) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
public String startWorkflowConfiguration(final String id) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
// return the processId ???
return null;
}

View File

@ -19,12 +19,12 @@ public class WfManagerClient extends DnetServiceClient {
private final static String LOADTIME = "loadtime";
public List<AggregationInfo> getAggregationHistory(final String dsId) throws DsmException {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}
public void dropCache() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
}

View File

@ -2,9 +2,9 @@ package eu.dnetlib.domain.index;
public class IndexConfiguration {
// TODO (MEDIUM PRIORITY)
public String getId() {
// TODO Auto-generated method stub
return null;
}
// TODO
}

View File

@ -1,5 +1,6 @@
package eu.dnetlib.domain.oai;
public class OaiConfiguration {
// TODO
// TODO (MEDIUM PRIORITY)
}

View File

@ -86,7 +86,7 @@ public class RegisterWfConfigurationNode extends AbstractJobNode {
}
private boolean verifyConfiguration() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return false;
}

View File

@ -1,5 +1,5 @@
package eu.dnetlib.wfs.nodes.index;
public class CreateIndexConfigurationJobNode {
// TODO
// TODO (MEDIUM PRIORITY)
}

View File

@ -1,5 +1,5 @@
package eu.dnetlib.wfs.nodes.oai;
public class PrepareOaiExportJobNode {
// TODO
// TODO (MEDIUM PRIORITY)
}

View File

@ -11,6 +11,7 @@ import java.lang.annotation.Target;
@Documented
public @interface WfInputParam {
// TODO manage the parameter assignment
// TODO (HIGH PRIORITY) manage the parameter assignment
String value() default "";
}

View File

@ -11,6 +11,6 @@ import java.lang.annotation.Target;
@Documented
public @interface WfOutputParam {
// TODO manage the parameter assignment
// TODO (HIGH PRIORITY) manage the parameter assignment
String value() default "";
}

View File

@ -13,7 +13,7 @@ public class OaiCollectorPlugin implements DnetCollectorPlugin {
@Override
public Stream<String> collect(final String baseUrl, final Map<String, String> apiParams, final LocalDateTime from, final LocalDateTime until)
throws Exception {
// TODO Auto-generated method stub
// TODO (MEDIUM PRIORITY) Auto-generated method stub
return null;
}

View File

@ -259,7 +259,7 @@ public class WorkflowProcess implements Comparable<WorkflowProcess> {
}
public ExecutionStatus getExecutionStatus() {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
return null;
}

View File

@ -196,7 +196,7 @@ public class WfExecutorService implements Stoppable {
}
private void checkConfiguration(final WorkflowConfiguration conf) {
// TODO Auto-generated method stub
// TODO (HIGH PRIORITY) Auto-generated method stub
}
@Transactional

View File

@ -28,9 +28,25 @@ public class MdBuilderFactory {
final String origId = doc.valueOf(xpath);
// TODO populate the xml record with missing oaf fields, see:
// TODO (LOW PRIORITY) populate the xml record with missing oaf fields, see:
// https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/workflows/repo-hi/xslt/openaireMdBuilder.xslt.st
/*
* <xsl:template name="about"> <about> <provenance xmlns="http://www.openarchives.org/OAI/2.0/provenance"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/provenance http://www.openarchives.org/OAI/2.0/provenance.xsd">
* <originDescription harvestDate="{\$datestamp}" altered="true"> <baseURL>$baseurl$</baseURL> <identifier><xsl:value-of
* select="//*[local-name()='header']/*[local-name()='identifier']"/></identifier> <datestamp><xsl:value-of
* select="//*[local-name()='header']/*[local-name()='datestamp']"/></datestamp>
* <metadataNamespace>$metadatanamespace$</metadataNamespace> <xsl:copy-of
* select="//*[local-name()='provenance']/*[local-name() = 'originDescription']"/> </originDescription> </provenance>
* <oaf:datainfo> <oaf:inferred>$inferred$</oaf:inferred> <oaf:deletedbyinference>$deletedbyinference$</oaf:deletedbyinference>
* <oaf:trust>$trust$</oaf:trust> <oaf:inferenceprovenance>$inferenceprovenance$</oaf:inferenceprovenance> <oaf:provenanceaction
* schemename="dnet:provenanceActions" schemeid="dnet:provenanceActions" classname="$provenanceactionclassname$"
* classid="$provenanceactionclassid$"/> </oaf:datainfo> </about> </xsl:template>
*/
final MetadataRecord md = new MetadataRecordImpl();
md.setId(MetadataRecord.generateIdentifier(origId, nsPrefix));