use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameUtilsTest method testGetPublicNamePublicVisibilityNoCreditName.
@Test
public void testGetPublicNamePublicVisibilityNoCreditName() {
RecordNameEntity recordName = new RecordNameEntity();
recordName.setVisibility(Visibility.PUBLIC);
recordName.setGivenNames("given name");
recordName.setFamilyName("family name");
String publicName = RecordNameUtils.getPublicName(recordName);
assertNotNull(recordName);
assertEquals(recordName.getGivenNames() + " " + recordName.getFamilyName(), publicName);
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameUtilsTest method testGetPublicNamePrivateVisibility.
@Test
public void testGetPublicNamePrivateVisibility() {
RecordNameEntity recordName = new RecordNameEntity();
recordName.setVisibility(Visibility.PRIVATE);
recordName.setCreditName("credit name");
recordName.setGivenNames("given name");
recordName.setFamilyName("family name");
String publicName = RecordNameUtils.getPublicName(recordName);
assertNotNull(recordName);
assertNull(publicName);
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class BibtexManagerImpl method getCreditName.
/**
* Extract a credit name from the profile
* @param orcid
* @return
*/
private String getCreditName(String orcid) {
ProfileEntity entity = profileEntityManager.findByOrcid(orcid);
String creditName = null;
RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
if (recordNameEntity != null) {
creditName = recordNameEntity.getCreditName();
if (StringUtils.isBlank(creditName)) {
creditName = recordNameEntity.getGivenNames();
String familyName = recordNameEntity.getFamilyName();
if (StringUtils.isNotBlank(familyName)) {
creditName += " " + familyName;
}
}
}
return creditName;
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorImpl method viewWorkCitation.
@Override
public Response viewWorkCitation(String orcid, Long putCode) {
Work w = (Work) this.viewWork(orcid, putCode).getEntity();
ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
String creditName = null;
RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
if (recordNameEntity != null) {
if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(Visibility.PUBLIC)) {
creditName = recordNameEntity.getCreditName();
if (StringUtils.isBlank(creditName)) {
creditName = recordNameEntity.getGivenNames();
String familyName = recordNameEntity.getFamilyName();
if (StringUtils.isNotBlank(familyName)) {
creditName += " " + familyName;
}
}
}
}
WorkToCiteprocTranslator tran = new WorkToCiteprocTranslator();
CSLItemData item = tran.toCiteproc(w, creditName, true);
return Response.ok(item).build();
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameDaoTest method testUpdate.
@Test
public void testUpdate() {
RecordNameEntity recordName = recordNameDao.getRecordName("4444-4444-4444-4447");
assertNotNull(recordName);
assertEquals("Credit Name", recordName.getCreditName());
assertEquals("Given Names", recordName.getGivenNames());
assertEquals("Family Name", recordName.getFamilyName());
assertEquals(Visibility.LIMITED, recordName.getVisibility());
recordName.setCreditName("Updated Credit Name");
recordName.setGivenNames("Updated Given Names");
recordName.setFamilyName("Updated Family Name");
recordName.setVisibility(Visibility.PUBLIC);
assertTrue(recordNameDao.updateRecordName(recordName));
RecordNameEntity updatedRecordName = recordNameDao.getRecordName("4444-4444-4444-4447");
assertEquals("Updated Credit Name", updatedRecordName.getCreditName());
assertEquals("Updated Given Names", updatedRecordName.getGivenNames());
assertEquals("Updated Family Name", updatedRecordName.getFamilyName());
assertEquals(Visibility.PUBLIC, updatedRecordName.getVisibility());
}
Aggregations