use of org.orcid.persistence.jpa.entities.BiographyEntity in project ORCID-Source by ORCID.
the class BiographyManagerReadOnlyImpl method getBiography.
@Override
@Cacheable(value = "biography", key = "#orcid.concat('-').concat(#lastModified)")
public Biography getBiography(String orcid, long lastModified) {
BiographyEntity biographyEntity = null;
try {
biographyEntity = biographyDao.getBiography(orcid);
} catch (Exception e) {
LOGGER.warn("Couldn't find biography for " + orcid);
}
if (biographyEntity != null) {
Biography bio = new Biography();
bio.setContent(biographyEntity.getBiography());
bio.setVisibility(biographyEntity.getVisibility());
bio.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getLastModified())));
bio.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getDateCreated())));
return bio;
}
return null;
}
use of org.orcid.persistence.jpa.entities.BiographyEntity in project ORCID-Source by ORCID.
the class BiographyDaoTest method testfindByOrcid.
@Test
public void testfindByOrcid() {
BiographyEntity bio = biographyDao.getBiography("4444-4444-4444-4447");
assertNotNull(bio);
assertEquals("Biography for 4444-4444-4444-4447", bio.getBiography());
assertEquals(Visibility.LIMITED, bio.getVisibility());
}
use of org.orcid.persistence.jpa.entities.BiographyEntity in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method deactivateRecord.
@Override
@Transactional
public boolean deactivateRecord(String orcid) {
//Clear the record
ProfileEntity toClear = profileDao.find(orcid);
toClear.setLastModified(new Date());
toClear.setDeactivationDate(new Date());
toClear.setActivitiesVisibilityDefault(Visibility.PRIVATE);
toClear.setIndexingStatus(IndexingStatus.REINDEX);
// Remove works
workManager.removeAllWorks(orcid);
// Remove funding
if (toClear.getProfileFunding() != null) {
toClear.getProfileFunding().clear();
}
// Remove affiliations
if (toClear.getOrgAffiliationRelations() != null) {
toClear.getOrgAffiliationRelations().clear();
}
// Remove external identifiers
if (toClear.getExternalIdentifiers() != null) {
toClear.getExternalIdentifiers().clear();
}
// Remove researcher urls
if (toClear.getResearcherUrls() != null) {
toClear.getResearcherUrls().clear();
}
// Remove other names
if (toClear.getOtherNames() != null) {
toClear.getOtherNames().clear();
}
// Remove keywords
if (toClear.getKeywords() != null) {
toClear.getKeywords().clear();
}
// Remove address
if (toClear.getAddresses() != null) {
toClear.getAddresses().clear();
}
BiographyEntity bioEntity = toClear.getBiographyEntity();
if (bioEntity != null) {
bioEntity.setBiography("");
bioEntity.setVisibility(Visibility.PRIVATE);
}
//Set the deactivated names
RecordNameEntity recordName = toClear.getRecordNameEntity();
if (recordName != null) {
recordName.setCreditName(null);
recordName.setGivenNames("Given Names Deactivated");
recordName.setFamilyName("Family Name Deactivated");
recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
}
Set<EmailEntity> emails = toClear.getEmails();
if (emails != null) {
// For each email in the deprecated profile
for (EmailEntity email : emails) {
email.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
}
profileDao.merge(toClear);
profileDao.flush();
//Delete all connections
userConnectionDao.deleteByOrcid(orcid);
notificationManager.sendAmendEmail(orcid, AmendedSection.UNKNOWN, null);
return true;
}
use of org.orcid.persistence.jpa.entities.BiographyEntity in project ORCID-Source by ORCID.
the class BiographyDaoTest method testUpdate.
@Test
public void testUpdate() {
BiographyEntity bio = biographyDao.getBiography("4444-4444-4444-4442");
assertNotNull(bio);
assertEquals("Biography for 4444-4444-4444-4442", bio.getBiography());
assertEquals(Visibility.PUBLIC, bio.getVisibility());
bio.setBiography("Updated biography");
bio.setVisibility(Visibility.LIMITED);
assertTrue(biographyDao.updateBiography("4444-4444-4444-4442", bio.getBiography(), bio.getVisibility()));
BiographyEntity updatedBio = biographyDao.getBiography("4444-4444-4444-4442");
assertNotNull(updatedBio);
assertEquals("Updated biography", bio.getBiography());
assertEquals(Visibility.LIMITED, bio.getVisibility());
}
use of org.orcid.persistence.jpa.entities.BiographyEntity in project ORCID-Source by ORCID.
the class BiographyDaoImpl method persistBiography.
@Override
@Transactional
public void persistBiography(String orcid, String biography, Visibility visibility) {
BiographyEntity bio = new BiographyEntity();
bio.setVisibility(visibility);
bio.setBiography(biography);
bio.setProfile(new ProfileEntity(orcid));
bio.setDateCreated(new Date());
bio.setLastModified(new Date());
entityManager.persist(bio);
}
Aggregations