2023-06-28 15:28:12 +02:00
|
|
|
package eu.dnetlib.openaire.community.utils;
|
2023-06-14 11:14:24 +02:00
|
|
|
|
|
|
|
import javax.persistence.AttributeConverter;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2023-06-15 11:37:01 +02:00
|
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType;
|
|
|
|
|
2023-06-14 11:14:24 +02:00
|
|
|
public class CommunityMembershipTypeConverter implements AttributeConverter<CommunityMembershipType, String> {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String convertToDatabaseColumn(final CommunityMembershipType attribute) {
|
|
|
|
if (attribute == null) {
|
|
|
|
return null;
|
|
|
|
} else {
|
2023-06-15 11:27:59 +02:00
|
|
|
return attribute.getDescription();
|
2023-06-14 11:14:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public CommunityMembershipType convertToEntityAttribute(final String dbData) {
|
|
|
|
if (StringUtils.isBlank(dbData)) {
|
|
|
|
return null;
|
|
|
|
} else {
|
2023-06-15 11:27:59 +02:00
|
|
|
return CommunityMembershipType.fromDescription(dbData);
|
2023-06-14 11:14:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|