readded deprecated field (typology) in /ds/update

This commit is contained in:
Michele Artini 2022-05-13 11:47:11 +02:00
parent f113bcbfdd
commit b1f115dfc1
2 changed files with 29 additions and 12 deletions

View File

@ -97,31 +97,32 @@ public class DsmMappingUtils {
});
}
_fix_typology(dbe, d);
_fix_typology(dbe, d.getTypology(), d.getEoscDatasourceType());
return dbe;
}
@Deprecated
private static void _fix_typology(final DatasourceDbEntry dbe, final DatasourceDetails d) {
if (StringUtils.isNotBlank(d.getTypology()) && StringUtils.isBlank(d.getEoscDatasourceType())) {
private static void _fix_typology(final DatasourceDbEntry dbe, final String oldTypology, final String eoscTypology) {
if (StringUtils.isNotBlank(oldTypology) && StringUtils.isBlank(eoscTypology)) {
// THE ORDER IS IMPORTANT: DO NOT CHANGE IT
if (d.getTypology().startsWith("crissystem")) {
if (oldTypology.startsWith("crissystem")) {
dbe.setEoscDatasourceType("CRIS system");
} else if (d.getTypology().startsWith("entityregistry")) {
} else if (oldTypology.startsWith("entityregistry")) {
dbe.setEoscDatasourceType("Registry");
} else if (d.getTypology().startsWith("pubscatalogue") || d.getTypology().equals("websource")) {
} else if (oldTypology.startsWith("pubscatalogue") || oldTypology.equals("websource")) {
dbe.setEoscDatasourceType("Catalogue");
} else if (d.getTypology().contains("journal")) {
} else if (oldTypology.contains("journal")) {
dbe.setEoscDatasourceType("Journal archive");
} else if (d.getTypology().startsWith("aggregator")) {
} else if (oldTypology.startsWith("aggregator")) {
dbe.setEoscDatasourceType("Aggregator");
} else if (d.getTypology().contains("repository")) {
} else if (oldTypology.contains("repository")) {
dbe.setEoscDatasourceType("Repository");
} else {
dbe.setEoscDatasourceType("Aggregator");
}
} else if (StringUtils.isBlank(d.getTypology()) && StringUtils.isNotBlank(d.getEoscDatasourceType())) {
} else if (StringUtils.isBlank(oldTypology) && StringUtils.isNotBlank(eoscTypology)) {
if (dbe.getEoscDatasourceType().equals("CRIS system")) {
dbe.setTypology("crissystem");
} else if (dbe.getEoscDatasourceType().equals("Registry")) {
@ -141,7 +142,9 @@ public class DsmMappingUtils {
}
public static DatasourceDbEntry asDbEntry(final DatasourceDetailsUpdate d) {
return _convert(d, DatasourceDbEntry.class);
final DatasourceDbEntry dbe = _convert(d, DatasourceDbEntry.class);
_fix_typology(dbe, d.getTypology(), d.getEoscDatasourceType());
return dbe;
}
// HELPERS

View File

@ -49,7 +49,10 @@ public class DatasourceDetailsUpdate {
@ApiModelProperty(position = 9)
private String timezone;
@NotBlank
@Deprecated
@ApiModelProperty(position = 12)
private String typology;
@ApiModelProperty(position = 13)
private String eoscDatasourceType;
@ -252,4 +255,15 @@ public class DatasourceDetailsUpdate {
return this;
}
@Deprecated
public String getTypology() {
return typology;
}
@Deprecated
public DatasourceDetailsUpdate setTypology(final String typology) {
this.typology = typology;
return this;
}
}