Beispiel #1
0
 private void mergeWork(WorkEntity workToUpdate, WorkEntity workWithNewData) {
   workToUpdate.setTitle(workWithNewData.getTitle());
   workToUpdate.setTranslatedTitle(workWithNewData.getTranslatedTitle());
   workToUpdate.setSubtitle(workWithNewData.getSubtitle());
   workToUpdate.setDescription(workWithNewData.getDescription());
   workToUpdate.setWorkUrl(workWithNewData.getWorkUrl());
   workToUpdate.setCitation(workWithNewData.getCitation());
   workToUpdate.setJournalTitle(workWithNewData.getJournalTitle());
   workToUpdate.setLanguageCode(workWithNewData.getLanguageCode());
   workToUpdate.setTranslatedTitleLanguageCode(workWithNewData.getTranslatedTitleLanguageCode());
   workToUpdate.setIso2Country(workWithNewData.getIso2Country());
   workToUpdate.setCitationType(workWithNewData.getCitationType());
   workToUpdate.setWorkType(workWithNewData.getWorkType());
   workToUpdate.setPublicationDate(workWithNewData.getPublicationDate());
   workToUpdate.setContributorsJson(workWithNewData.getContributorsJson());
   workToUpdate.setExternalIdentifiersJson(workWithNewData.getExternalIdentifiersJson());
   workToUpdate.setVisibility(workWithNewData.getVisibility());
   workToUpdate.setDisplayIndex(workWithNewData.getDisplayIndex());
   workToUpdate.setSource(workWithNewData.getSource());
   workToUpdate.setLastModified(new Date());
   if (workWithNewData.getAddedToProfileDate() != null) {
     workToUpdate.setAddedToProfileDate(workWithNewData.getAddedToProfileDate());
   }
   workToUpdate.setProfile(workWithNewData.getProfile());
 }
Beispiel #2
0
  @Test
  @Rollback(true)
  @Transactional(propagation = Propagation.REQUIRES_NEW)
  public void testAddWork() {
    String title = "New Work";
    String subtitle = "Subtitle";
    String citation = "Test citation";
    String description = "Description for new work";
    String url = "http://work.com";

    WorkEntity work = new WorkEntity();
    work.setCitation(citation);
    work.setCitationType(CitationType.FORMATTED_UNSPECIFIED);
    work.setDescription(description);
    work.setTitle(title);
    work.setSubtitle(subtitle);
    work.setWorkType(WorkType.BOOK);
    work.setWorkUrl(url);
    ProfileEntity profile = new ProfileEntity(USER_ORCID);
    work.setProfile(profile);
    work.setSourceId(USER_ORCID);
    work.setAddedToProfileDate(new Date());

    assertNull(work.getId());

    try {
      work = workDao.addWork(work);
    } catch (Exception e) {
      fail();
    }

    assertNotNull(work.getId());
  }