VIVO-672 Preserve the lazy initialization of the VClassJena.

Instead of a copy constructor on VClass, use a copy() method, which can be overridden.
This commit is contained in:
j2blake 2014-01-15 15:16:17 -05:00
parent 0280cda8e3
commit 2f68ddb8ee
3 changed files with 37 additions and 21 deletions

View file

@ -137,26 +137,32 @@ public class VClass extends BaseResourceBean implements Comparable<VClass>
/** /**
* Constructs the VClass as a deep copy of an existing VClass. * Constructs the VClass as a deep copy of an existing VClass.
*/ */
public VClass( VClass vc) { public VClass copy() {
this.URI = vc.URI; VClass that = new VClass();
this.namespace = vc.namespace; copyFields(that);
this.localName = vc.localName; return that;
this.myName = vc.myName;
this.myExample = vc.myExample;
this.myDescription = vc.myDescription;
this.myShortDefinition = vc.myShortDefinition;
this.myEntityCount = vc.myEntityCount;
this.displayLimit = vc.displayLimit;
this.displayRank = vc.displayRank;
this.quickEditJsp = vc.quickEditJsp;
this.groupURI = vc.groupURI;
this.group = (vc.group == null) ? null : new VClassGroup(vc.group);
this.customEntryForm = vc.customEntryForm;
this.customDisplayView = vc.customDisplayView;
this.customShortView = vc.customShortView;
this.customSearchView = vc.customSearchView;
} }
protected void copyFields(VClass that) {
that.myName = this.myName;
that.namespace = this.namespace;
that.localName = this.localName;
that.URI = this.URI;
that.myExample = this.myExample;
that.myDescription = this.myDescription;
that.myShortDefinition = this.myShortDefinition;
that.myEntityCount = this.myEntityCount;
that.displayLimit = this.displayLimit;
that.displayRank = this.displayRank;
that.quickEditJsp = this.quickEditJsp;
that.groupURI = this.groupURI;
that.group = this.group;
that.customEntryForm = this.customEntryForm;
that.customDisplayView = this.customDisplayView;
that.customShortView = this.customShortView;
that.customSearchView = this.customSearchView;
}
/** /**
* Sorts alphabetically by name * Sorts alphabetically by name
*/ */

View file

@ -37,8 +37,8 @@ public class VClassGroupsForRequest {
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("groups: " + groupMap); log.debug("groups: " + groupMap.values());
log.debug("classes: " + classMap); log.debug("classes: " + classMap.values());
} }
} }
@ -59,7 +59,7 @@ public class VClassGroupsForRequest {
} }
private void loadClass(VClass vc, VClassGroup newVcg) { private void loadClass(VClass vc, VClassGroup newVcg) {
VClass newVc = new VClass(vc); VClass newVc = vc.copy();
newVc.setName(getNameForVClass(vc)); newVc.setName(getNameForVClass(vc));
newVc.setGroup(newVcg); newVc.setGroup(newVcg);
newVcg.add(newVc); newVcg.add(newVc);

View file

@ -47,6 +47,16 @@ public class VClassJena extends VClass {
this.webappDaoFactory = wadf; this.webappDaoFactory = wadf;
} }
/**
* Constructs the VClassJena as a deep copy of an existing VClassJena.
*/
@Override
public VClassJena copy() {
VClassJena that = new VClassJena(this.cls, this.webappDaoFactory);
copyFields(that);
return that;
}
/** /**
* What this VClass is called * What this VClass is called
*/ */