26 lines
578 B
Java
26 lines
578 B
Java
package org.opencdmp.filetransformer.rda.model.rda.mapper;
|
|
|
|
import org.opencdmp.filetransformer.rda.model.rda.DmpId;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.UUID;
|
|
@Component
|
|
public class DmpIdRDAMapper{
|
|
|
|
public DmpId toRDA(Object id) {
|
|
if (id == null) return null;
|
|
DmpId rda = new DmpId();
|
|
rda.setIdentifier(id.toString());
|
|
if (id instanceof UUID) {
|
|
rda.setType(DmpId.Type.OTHER);
|
|
} else {
|
|
rda.setType(DmpId.Type.DOI);
|
|
}
|
|
return rda;
|
|
}
|
|
|
|
public Object toEntity(DmpId rda) {
|
|
return rda == null ? null : rda.getIdentifier();
|
|
}
|
|
}
|