Commit 1896e3d0 authored by Matija Obreza's avatar Matija Obreza
Browse files

Avoid NPE in @PrePersist on Accession

parent e049ca95
......@@ -18,6 +18,7 @@ package org.genesys2.server.model.genesys;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.persistence.CollectionTable;
......@@ -43,6 +44,8 @@ import org.genesys2.util.MCPDUtil;
public class Accession extends VersionedAuditedModel {
private static final long serialVersionUID = -7630113633534038876L;
public static final List<Accession> EMPTY_LIST = Collections.unmodifiableList(new ArrayList<Accession>());
@Column(length = 36)
private String uuid;
......@@ -113,7 +116,11 @@ public class Accession extends VersionedAuditedModel {
@PrePersist
@PreUpdate
private void prePersist() {
this.origin = getCountryOfOrigin().getCode3();
if (this.countryOfOrigin != null)
this.origin = this.countryOfOrigin.getCode3();
else
this.origin = null;
this.taxGenus = getTaxonomy().getTaxGenus();
this.instituteCode = getInstitute().getCode();
this.storage = MCPDUtil.toMcpdArray(this.stoRage);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment