Commit ea650159 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '208-emptymodel-with-initializeentity' into 'main'

Resolve "EmptyModel with initializeEntity"

Closes #208

See merge request grin-global/grin-global-server!258
parents 5631a1d9 b0990501
......@@ -34,7 +34,7 @@ run tests:
image: maven:3-openjdk-11
script:
# First do coverage testing
- mvn $MAVEN_CLI_OPTS --activate-profiles quality verify -U
- mvn $MAVEN_CLI_OPTS --activate-profiles quality clean verify -U
- cat coverage/target/site/jacoco-aggregate/index.html | grep -o 'Total[^%]*%'
coverage: '/Total.*?([0-9]{1,3})%/'
artifacts:
......@@ -55,7 +55,7 @@ package server:
- run tests
script:
# Then package the clean app
- mvn $MAVEN_CLI_OPTS -Ppackage package
- mvn $MAVEN_CLI_OPTS -Ppackage clean package
artifacts:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}"
expire_in: 1 day
......
......@@ -62,7 +62,7 @@
<jackson.version>2.11.4</jackson.version>
<liquibase.version>3.10.3</liquibase.version>
<application.blocks.version>3.0-SNAPSHOT</application.blocks.version>
<application.blocks.version>3.1-SNAPSHOT</application.blocks.version>
<!--Container -->
<jetty.version>9.4.40.v20210413</jetty.version>
......
......@@ -147,9 +147,7 @@ public abstract class AbstractAction<T extends AbstractAction<T>> extends Cooper
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.cooperator != null) {
this.cooperator.getId();
}
lazyLoad(this.cooperator);
}
}
\ No newline at end of file
......@@ -467,14 +467,10 @@ public class Accession extends CooperatorOwnedModel implements IWebVisible, Copy
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.site != null) {
this.site.getId();
}
if (this.taxonomySpecies != null) {
this.taxonomySpecies.getId();
}
Hibernate.initialize(this.backupLocation1Site);
Hibernate.initialize(this.backupLocation2Site);
lazyLoad(this.site);
lazyLoad(this.taxonomySpecies);
lazyLoad(this.backupLocation1Site);
lazyLoad(this.backupLocation2Site);
}
@Override
......
......@@ -122,11 +122,7 @@ public class AccessionAction extends AbstractAction<AccessionAction> implements
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.accession != null) {
this.accession.getId();
}
if (this.method != null) {
this.method.getId();
}
lazyLoad(this.accession);
lazyLoad(this.method);
}
}
\ No newline at end of file
......@@ -173,10 +173,8 @@ public class AccessionInvAttach extends CooperatorAttachment implements Copyable
public void lazyLoad() {
super.lazyLoad();
if (this.inventory != null) {
this.inventory.getId();
if (this.inventory.getSite() != null) {
this.inventory.getSite().getId();
}
lazyLoad(this.inventory);
lazyLoad(this.inventory.getSite());
}
}
}
......@@ -201,9 +201,6 @@ public class AccessionIpr extends CooperatorOwnedModel implements Copyable<Acces
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.accession != null) {
this.accession.getId();
this.accession.lazyLoad();
}
lazyLoad(this.accession, true);
}
}
\ No newline at end of file
......@@ -172,6 +172,6 @@ public class AccessionPedigree extends CooperatorOwnedModel implements Copyable<
@Override
public void lazyLoad() {
this.getAccession().lazyLoad();
lazyLoad(this.accession, true);
}
}
\ No newline at end of file
......@@ -175,12 +175,7 @@ public class AccessionQuarantine extends CooperatorOwnedModel implements Copyabl
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.accession != null) {
this.accession.getId();
this.accession.lazyLoad();
}
if (this.custodialCooperator != null) {
this.custodialCooperator.getId();
}
lazyLoad(this.custodialCooperator);
lazyLoad(this.accession, true);
}
}
\ No newline at end of file
......@@ -392,12 +392,7 @@ public class AccessionSource extends CooperatorOwnedModel implements IWebVisible
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.accession != null) {
this.accession.getId();
this.accession.lazyLoad();
}
if (this.geography != null) {
this.geography.getId();
}
lazyLoad(this.accession, true);
lazyLoad(this.geography);
}
}
\ No newline at end of file
......@@ -194,8 +194,6 @@ public class AppResource extends CooperatorOwnedModel implements Copyable<AppRes
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.sysLang != null) {
this.sysLang.getId();
}
lazyLoad(this.sysLang);
}
}
\ No newline at end of file
......@@ -24,6 +24,7 @@ import javax.persistence.MappedSuperclass;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.genesys.blocks.auditlog.annotations.NotAudited;
import org.genesys.blocks.model.EmptyModel;
import org.genesys.blocks.model.EntityId;
import org.genesys.blocks.util.JsonSidConverter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
......@@ -132,4 +133,17 @@ public abstract class AuditedModel extends EmptyModel {
public String toString() {
return this.getClass() + "#id=" + getId();
}
protected final void lazyLoad(EntityId entity) {
lazyLoad(entity, false);
}
protected final void lazyLoad(EntityId entity, boolean deepLazyLoad) {
if (entity != null) {
entity.getId();
if (deepLazyLoad && entity instanceof LazyLoading<?>) {
((LazyLoading<?>) entity).lazyLoad();
}
}
}
}
\ No newline at end of file
......@@ -532,24 +532,12 @@ public class Cooperator extends CooperatorOwnedModel implements Copyable<Coopera
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.currentCooperator != null) {
this.currentCooperator.getId();
}
if (this.geography != null) {
this.geography.getId();
}
if (this.secondaryGeography != null) {
this.secondaryGeography.getId();
}
if (this.site != null) {
this.site.getId();
}
if (this.sysLang != null) {
this.sysLang.getId();
}
if (this.webCooperator != null) {
this.webCooperator.getId();
}
lazyLoad(this.currentCooperator);
lazyLoad(this.geography);
lazyLoad(this.secondaryGeography);
lazyLoad(this.site);
lazyLoad(this.sysLang);
lazyLoad(this.webCooperator);
}
......
......@@ -150,8 +150,6 @@ public abstract class CooperatorAttachment extends CooperatorOwnedModel implemen
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.repositoryFile != null) {
this.repositoryFile.getId();
}
lazyLoad(this.repositoryFile);
}
}
\ No newline at end of file
......@@ -133,8 +133,6 @@ public class CropAttach extends CooperatorAttachment implements Copyable<CropAtt
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.crop != null) {
this.crop.getId();
}
lazyLoad(this.crop);
}
}
......@@ -283,8 +283,6 @@ public class CropTrait extends TranslatedCooperatorOwnedModel<CropTraitLang, Cro
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.crop != null) {
this.crop.getId();
}
lazyLoad(this.crop);
}
}
\ No newline at end of file
......@@ -133,8 +133,6 @@ public class CropTraitAttach extends CooperatorAttachment implements Copyable<Cr
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.cropTrait != null) {
this.cropTrait.getId();
}
lazyLoad(this.cropTrait);
}
}
......@@ -133,8 +133,6 @@ public class CropTraitCodeAttach extends CooperatorAttachment implements Copyabl
@Override
public void lazyLoad() {
super.lazyLoad();
if (this.cropTraitCode != null) {
this.cropTraitCode.getId();
}
lazyLoad(this.cropTraitCode);
}
}
......@@ -294,8 +294,6 @@ public class Geography extends CooperatorOwnedModel implements Copyable<Geograph
@Override
public void lazyLoad() {
super.lazyLoad();
if (currentGeography != null) {
currentGeography.getId();
}
lazyLoad(this.currentGeography);
}
}
\ No newline at end of file
......@@ -745,10 +745,8 @@ public class Inventory extends CooperatorOwnedModel implements Copyable<Inventor
@Override
public void lazyLoad() {
super.lazyLoad();
if (site != null) {
site.getId();
}
accession.lazyLoad();
lazyLoad(this.site);
lazyLoad(this.accession, true);
}
@Override
......
Supports Markdown
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