Commit d316eacf authored by Matija Obreza's avatar Matija Obreza

BasicModel#isPersisted() from app-blocks:1.2-SNAPSHOT is a better test than getId() == null

parent e745ea62
......@@ -58,7 +58,7 @@
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<junit.version>4.12</junit.version>
<application.blocks.version>1.1-SNAPSHOT</application.blocks.version>
<application.blocks.version>1.2-SNAPSHOT</application.blocks.version>
<commons.beanutils.version>1.9.2</commons.beanutils.version>
<commons.collections.version>3.2.1</commons.collections.version>
<commons.fileupload.version>1.3.1</commons.fileupload.version>
......
......@@ -96,7 +96,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
@Autowired
private TaxonomyManager taxonomyManager;
@Override
// Read-only, everything happens in manager
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#institute, 'WRITE') or hasPermission(#institute, 'CREATE')")
......@@ -256,7 +256,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
upsertResult.setUUID(accession.getUuid());
}
if (accession.getAccessionId().getId() == null || useUniqueAcceNumbs && accnJson.get(Api1Constants.Accession.GENUS) != null
if (accession.getAccessionId().isPersisted() || useUniqueAcceNumbs && accnJson.get(Api1Constants.Accession.GENUS) != null
|| accnJson.get(Api1Constants.Accession.GENUS_NEW) != null || accnJson.get(Api1Constants.Accession.SPECIES) != null
|| accnJson.get(Api1Constants.Accession.SPAUTHOR) != null || accnJson.get(Api1Constants.Accession.SUBTAXA) != null
|| accnJson.get(Api1Constants.Accession.SUBTAUTHOR) != null) {
......@@ -728,7 +728,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
private boolean updateAcceNumb(AccessionData accession, JsonNode value) throws RESTApiDataTypeException, RESTApiException {
if (value != null) {
// Rename is possible only if accession exists
if (accession.getAccessionId().getId() == null) {
if (! accession.getAccessionId().isPersisted()) {
throw new RESTApiException("Cannot rename a new accession entry");
}
......
......@@ -400,7 +400,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionBreeding listAccessionBreeding(AccessionId accession) {
if (accession == null || accession.getId() == null) {
if (accession == null || ! accession.isPersisted()) {
return null;
}
return accessionBreedingRepository.findByAccession(accession);
......@@ -408,7 +408,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionGeo listAccessionGeo(AccessionId accession) {
if (accession == null || accession.getId() == null) {
if (accession == null || ! accession.isPersisted()) {
return null;
}
return accessionGeoRepository.findByAccession(accession);
......@@ -432,7 +432,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionCollect listAccessionCollect(AccessionId accession) {
if (accession == null || accession.getId() == null) {
if (accession == null || ! accession.isPersisted()) {
return null;
}
return accessionCollectRepository.findByAccession(accession);
......@@ -440,7 +440,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public AccessionExchange listAccessionExchange(AccessionId accession) {
if (accession == null || accession.getId() == null) {
if (accession == null || ! accession.isPersisted()) {
return null;
}
return accessionExchangeRepository.findByAccession(accession);
......@@ -448,7 +448,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public List<AccessionRemark> listAccessionRemarks(AccessionId accession) {
if (accession == null || accession.getId() == null) {
if (accession == null || ! accession.isPersisted()) {
return null;
}
return accessionRemarkRepository.findByAccession(accession);
......@@ -630,7 +630,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
private AccessionData getAccessionData(AccessionId accessionId) {
if (accessionId == null)
if (accessionId == null || ! accessionId.isPersisted())
return null;
return getAccessionData(accessionId.getId());
}
......
......@@ -128,7 +128,7 @@ public class OAuthManagementController extends RequestsController {
OAuthClientDetails clientDetails;
if (requestClient.getId() == null) {
if (! requestClient.isPersisted()) {
clientDetails = clientDetailsService.addClientDetails(
requestClient.getTitle(),
requestClient.getDescription(),
......
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