コード例 #1
0
ファイル: WorkDaoTest.java プロジェクト: ORCID/ORCID-Source
  @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());
  }
コード例 #2
0
ファイル: WorkDaoImpl.java プロジェクト: stain/ORCID-Source
 @Override
 @Transactional
 public WorkEntity editWork(WorkEntity updatedWork) {
   WorkEntity workToUpdate = this.find(updatedWork.getId());
   mergeWork(workToUpdate, updatedWork);
   workToUpdate = this.merge(workToUpdate);
   return workToUpdate;
 }
コード例 #3
0
ファイル: WorkEntity.java プロジェクト: nabeta/ORCID-Source
 private int compareIds(WorkEntity other) {
   if (other.getId() == null) {
     if (id == null) {
       if (equals(other)) {
         return 0;
       } else {
         // If can't determine preferred order, then be polite and
         // say 'after you!'
         return -1;
       }
     } else {
       return 1;
     }
   }
   if (id == null) {
     return -1;
   }
   return id.compareTo(other.getId());
 }