31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package eu.eudat.file.transformer.rda.mapper;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class KeywordRDAMapper {
|
|
private static final Logger logger = LoggerFactory.getLogger(KeywordRDAMapper.class);
|
|
private static final ObjectMapper mapper = new ObjectMapper();
|
|
|
|
public static List<String> toRDA(String value) {
|
|
if (!value.isEmpty() && !value.equals("null")) {
|
|
try {
|
|
TagFileTransformerModel tag = mapper.readValue(value, TagFileTransformerModel.class);
|
|
return new ArrayList<>(Collections.singletonList(tag.getLabel()));
|
|
} catch (JsonProcessingException e) {
|
|
logger.warn(e.getMessage() + ". Attempting to parse it as a String since its a new tag.");
|
|
return new ArrayList<>(Collections.singletonList(value));
|
|
}
|
|
}
|
|
|
|
return new ArrayList<>();
|
|
}
|
|
}
|