use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameManagerImpl method createRecordName.
@Override
public void createRecordName(String orcid, Name name) {
if (name == null) {
return;
}
if (recordNameDao.exists(orcid)) {
throw new IllegalArgumentException("The name for " + orcid + " already exists");
}
RecordNameEntity entity = jpaJaxbNameAdapter.toRecordNameEntity(name);
if (entity.getProfile() == null || PojoUtil.isEmpty(entity.getProfile().getId())) {
entity.setProfile(new ProfileEntity(orcid));
}
Date now = new Date();
entity.setDateCreated(now);
entity.setLastModified(now);
recordNameDao.createRecordName(entity);
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method setCreditNameDetails.
private void setCreditNameDetails(ProfileEntity profileEntity, CreditName creditName) {
if (creditName != null) {
if (profileEntity.getRecordNameEntity() == null) {
profileEntity.setRecordNameEntity(new RecordNameEntity());
profileEntity.getRecordNameEntity().setProfile(profileEntity);
}
RecordNameEntity recordName = profileEntity.getRecordNameEntity();
// Save the record name entity
if (creditName.getVisibility() != null) {
recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(creditName.getVisibility().value()));
} else {
recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
}
recordName.setCreditName(creditName.getContent());
}
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl 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(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
creditName = recordNameEntity.getCreditName();
if (StringUtils.isBlank(creditName)) {
creditName = recordNameEntity.getGivenNames();
String familyName = recordNameEntity.getFamilyName();
if (StringUtils.isNotBlank(familyName)) {
creditName += " " + familyName;
}
}
}
}
V3WorkToCiteprocTranslator tran = new V3WorkToCiteprocTranslator();
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 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 SelfServiceController method addContactByEmail.
@RequestMapping(value = "/add-contact-by-email.json")
@ResponseBody
public Contact addContactByEmail(@RequestBody Contact contact) {
checkFullAccess(contact.getAccountId());
EmailEntity emailEntity = emailManager.findCaseInsensitive(contact.getEmail());
contact.setOrcid(emailEntity.getProfile().getId());
RecordNameEntity recordNameEntity = emailEntity.getProfile().getRecordNameEntity();
if (Visibility.PUBLIC.equals(recordNameEntity.getVisibility())) {
contact.setFirstName(recordNameEntity.getGivenNames());
contact.setLastName(recordNameEntity.getFamilyName());
} else {
contact.setFirstName(NOT_PUBLIC);
contact.setLastName(NOT_PUBLIC);
}
salesForceManager.createContact(contact);
return contact;
}
Aggregations