/** * @param other * @return * @see * edu.utah.further.mdr.api.domain.asset.Asset#copyFrom(edu.utah.further.mdr.api.domain.asset.Asset) */ @Override public AssetToImpl copyFrom(final Asset other) { if (other == null) { return this; } // Deep-copy primitive fields and IDs, but do not deep-copy entity references this.id = other.getId(); final Asset otherNamespace = other.getNamespace(); if (otherNamespace != null) { this.namespaceId = otherNamespace.getId(); } final Asset otherType = other.getType(); if (otherType != null) { this.typeId = otherType.getId(); } this.label = other.getLabel(); this.description = other.getDescription(); this.activationInfo = new ActivationInfoToImpl().copyFrom(other.getActivationInfo()); // Deep-copy collection references (IDs) but do not deep-copy their elements // unless it's easy to deep-copy them too. Note: the hibernate entity (other) 's // version set must be eagerly fetched so that copying it here, outside the // Hibernate session, does not throw a lazy init exception. this.versionSet = newSortedSet(); this.versionIdSet = newSortedSet(); for (final Version version : other.getVersionSet()) { // TODO: add version TOs here in the future // addVersion(new VersionEntity().copyFrom(version)); versionIdSet.add(version.getId()); } return this; }
/** * @param version * @return * @see * edu.utah.further.mdr.api.domain.asset.Asset#addVersion(edu.utah.further.mdr.api.domain.asset.Version) */ @Override public void addVersion(final Version version) { final Long versionId = (version == null) ? null : version.getId(); if (versionId != null) { versionIdSet.add(versionId); } versionSet.add(version); }
/** * @param version * @return * @see * edu.utah.further.mdr.api.domain.asset.Asset#removeVersion(edu.utah.further.mdr.api.domain.asset.Version) */ @Override public void removeVersion(final Version version) { final Long versionId = (version == null) ? null : version.getId(); versionSet.remove(versionId); versionSet.remove(version); }