private Resource generatePreviewResource(Resource resource,Eml eml,BigDecimal nextVersion){
  Resource copy=new Resource();
  copy.setShortname(resource.getShortname());
  copy.setTitle(resource.getTitle());
  copy.setLastPublished(resource.getLastPublished());
  copy.setStatus(resource.getStatus());
  copy.setOrganisation(resource.getOrganisation());
  copy.setKey(resource.getKey());
  copy.setEmlVersion(nextVersion);
  if (resource.isCitationAutoGenerated()) {
    Citation citation=new Citation();
    URI homepage=cfg.getResourceVersionUri(resource.getShortname(),nextVersion);
    citation.setCitation(resource.generateResourceCitation(nextVersion,homepage));
    eml.setCitation(citation);
  }
  Date releaseDate=new Date();
  copy.setLastPublished(releaseDate);
  eml.setPubDate(releaseDate);
  copy.setEml(eml);
  List<VersionHistory> histories=Lists.newArrayList();
  histories.addAll(resource.getVersionHistory());
  copy.setVersionHistory(histories);
  VersionHistory history=new VersionHistory(nextVersion,releaseDate,PublicationStatus.PUBLIC);
  User modifiedBy=getCurrentUser();
  if (modifiedBy != null) {
    history.setModifiedBy(modifiedBy);
  }
  if (resource.getDoi() != null && (resource.getIdentifierStatus() == IdentifierStatus.PUBLIC_PENDING_PUBLICATION || resource.getIdentifierStatus() == IdentifierStatus.PUBLIC)) {
    copy.setDoi(resource.getDoi());
    copy.setIdentifierStatus(IdentifierStatus.PUBLIC);
    history.setDoi(resource.getDoi());
    history.setStatus(IdentifierStatus.PUBLIC);
  }
  copy.addVersionHistory(history);
  return copy;
}

private Resource generatePreviewResource ( Resource resource , Eml eml , BigDecimal nextVersion ) { Resource copy = new Resource ( ) ; copy . setShortname ( resource . getShortname ( ) ) ; copy . setTitle ( resource . getTitle ( ) ) ; copy . setLastPublished ( resource . getLastPublished ( ) ) ; copy . setStatus ( resource . getStatus ( ) ) ; copy . setOrganisation ( resource . getOrganisation ( ) ) ; copy . setKey ( resource . getKey ( ) ) ; copy . setEmlVersion ( nextVersion ) ; if ( resource . isCitationAutoGenerated ( ) ) { Citation citation = new Citation ( ) ; URI homepage = cfg . getResourceVersionUri ( resource . getShortname ( ) , nextVersion ) ; citation . setCitation ( resource . generateResourceCitation ( nextVersion , homepage ) ) ; eml . setCitation ( citation ) ; } Date releaseDate = new Date ( ) ; copy . setLastPublished ( releaseDate ) ; eml . setPubDate ( releaseDate ) ; copy . setEml ( eml ) ; List < VersionHistory > histories = Lists . newArrayList ( ) ; histories . addAll ( resource . getVersionHistory ( ) ) ; copy . setVersionHistory ( histories ) ; VersionHistory history = new VersionHistory ( nextVersion , releaseDate , PublicationStatus . PUBLIC ) ; User modifiedBy = getCurrentUser ( ) ; if ( modifiedBy != null ) { history . setModifiedBy ( modifiedBy ) ; } if ( resource . getDoi ( ) != null && ( resource . getIdentifierStatus ( ) == IdentifierStatus . PUBLIC_PENDING_PUBLICATION || resource . getIdentifierStatus ( ) == IdentifierStatus . PUBLIC ) ) { copy . setDoi ( resource . getDoi ( ) ) ; copy . setIdentifierStatus ( IdentifierStatus . PUBLIC ) ; history . setDoi ( resource . getDoi ( ) ) ; history . setStatus ( IdentifierStatus . PUBLIC ) ; } copy . addVersionHistory ( history ) ; return copy ; }
generate a copy of the resource , previewing what the next publication of the resource will look like . this involves copying over certain fields not in eml , and then setting the version equal to next published version , and setting a new pubdate .
