fix freetext-format bug in prefilling temporarily
This commit is contained in:
parent
26e10b1299
commit
eedcf0dfb0
|
@ -390,6 +390,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
}
|
}
|
||||||
formats = formats.stream().distinct().collect(Collectors.toList());
|
formats = formats.stream().distinct().collect(Collectors.toList());
|
||||||
List<Object> standardFormats = new ArrayList<>();
|
List<Object> standardFormats = new ArrayList<>();
|
||||||
|
StringBuilder freeTextFormat = new StringBuilder();
|
||||||
for(String format: formats) {
|
for(String format: formats) {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String parsedUrl = "https://eestore.paas2.uninett.no/api/fileformat/?search=" + format;
|
String parsedUrl = "https://eestore.paas2.uninett.no/api/fileformat/?search=" + format;
|
||||||
|
@ -398,28 +399,42 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
HttpEntity<String> entity = new HttpEntity("", headers);
|
HttpEntity<String> entity = new HttpEntity("", headers);
|
||||||
Map<String, Object> data = restTemplate.exchange(parsedUrl, HttpMethod.GET, entity, LinkedHashMap.class).getBody();
|
Map<String, Object> data = restTemplate.exchange(parsedUrl, HttpMethod.GET, entity, LinkedHashMap.class).getBody();
|
||||||
jsonArr = new JSONArray(new ObjectMapper().writeValueAsString(data.get("data")));
|
jsonArr = new JSONArray(new ObjectMapper().writeValueAsString(data.get("data")));
|
||||||
for(int i = 0; i < jsonArr.length(); i++){
|
if(jsonArr.length() > 0) {
|
||||||
JSONObject jsonObj = jsonArr.getJSONObject(i);
|
for (int i = 0; i < jsonArr.length(); i++) {
|
||||||
jsonObj = jsonObj.getJSONObject("attributes");
|
JSONObject jsonObj = jsonArr.getJSONObject(i);
|
||||||
JSONArray extensions = jsonObj.getJSONArray("extensions");
|
jsonObj = jsonObj.getJSONObject("attributes");
|
||||||
Object formatName = jsonObj.get("name");
|
JSONArray extensions = jsonObj.getJSONArray("extensions");
|
||||||
boolean found = false;
|
Object formatName = jsonObj.get("name");
|
||||||
for(int j = 0; j < extensions.length(); j++){
|
boolean found = false;
|
||||||
if(extensions.getString(j).equals(format)){
|
for (int j = 0; j < extensions.length(); j++) {
|
||||||
JSONObject cur = new JSONObject();
|
if (extensions.getString(j).equals(format)) {
|
||||||
cur.put("label", formatName.toString());
|
JSONObject cur = new JSONObject();
|
||||||
standardFormats.add(cur.toString());
|
cur.put("label", formatName.toString());
|
||||||
found = true;
|
standardFormats.add(cur.toString());
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(found){
|
}
|
||||||
break;
|
else{
|
||||||
}
|
freeTextFormat.append(format).append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
properties.put(id, standardFormats);
|
String renderStyle = node.get(0) != null ? node.get(0).get("viewStyle").get("renderStyle").asText() : node.get("viewStyle").get("renderStyle").asText();
|
||||||
|
if(renderStyle.equals("freetext")){
|
||||||
|
if (freeTextFormat.length() > 0) {
|
||||||
|
freeTextFormat.setLength(freeTextFormat.length() - 2);
|
||||||
|
}
|
||||||
|
properties.put(id, freeTextFormat.toString());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
properties.put(id, standardFormats);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
|
else if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
|
||||||
value = value.replace("\"", "");
|
value = value.replace("\"", "");
|
||||||
|
|
Loading…
Reference in New Issue