use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method checkAndUpdateDisambiguatedOrganization.
private void checkAndUpdateDisambiguatedOrganization(List<Affiliation> affiliations) {
if (affiliations != null && !affiliations.isEmpty()) {
for (Affiliation affiliation : affiliations) {
Organization org = affiliation.getOrganization();
OrgEntity orgEntity = orgManager.getOrgEntity(org);
// If the org exists
if (orgEntity != null) {
// And it have a disambiguated org
if (orgEntity.getOrgDisambiguated() != null) {
// Update the desambiguated org
org.setDisambiguatedOrganization(adapter.getDisambiguatedOrganization(orgEntity.getOrgDisambiguated()));
} else {
// Null the disambiguated organization
org.setDisambiguatedOrganization(null);
}
}
}
}
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class JpaJaxbPeerReviewAdapterTest method getPeerReviewEntity.
private PeerReviewEntity getPeerReviewEntity() {
OrgEntity orgEntity = new OrgEntity();
orgEntity.setCity("org:city");
orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
orgEntity.setName("org:name");
orgEntity.setRegion("org:region");
orgEntity.setUrl("org:url");
orgEntity.setSource(new SourceEntity("APP-000000001"));
PeerReviewEntity result = new PeerReviewEntity();
result.setOrg(orgEntity);
result.setCompletionDate(new CompletionDateEntity(2015, 1, 1));
result.setExternalIdentifiersJson("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"peer-review:external-identifier-id\"}}]}");
result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
result.setRole(Role.MEMBER);
result.setType(PeerReviewType.EVALUATION);
result.setUrl("peer-review:url");
result.setSubjectExternalIdentifiersJson("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}");
result.setSubjectContainerName("peer-review:subject-container-name");
result.setSubjectName("peer-review:subject-name");
result.setSubjectTranslatedName("peer-review:subject-translated-name");
result.setSubjectTranslatedNameLanguageCode("en");
result.setSubjectUrl("peer-review:subject-url");
result.setSubjectType(WorkType.BOOK_REVIEW);
result.setVisibility(Visibility.PRIVATE);
result.setClientSourceId("APP-000000001");
result.setGroupId("orcid-generated:12345");
result.setId(12345L);
return result;
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testOrgReuse.
@Test
@Transactional
@Rollback(true)
public void testOrgReuse() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
OrcidActivities orcidActivities = profile1.getOrcidActivities();
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation = new Affiliation();
affiliations.getAffiliation().add(affiliation);
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName("New College");
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
organizationAddress.setCity("Edinburgh");
organizationAddress.setCountry(Iso3166Country.GB);
orcidProfileManager.createOrcidProfile(profile1, false, false);
ProfileEntity profileEntity = profileDao.find(TEST_ORCID);
assertEquals(1, profileEntity.getOrgAffiliationRelations().size());
OrgEntity orgEntity = profileEntity.getOrgAffiliationRelations().iterator().next().getOrg();
assertNotNull(orgEntity);
// Now create another profile with the same affiliation and check that
// the org is reused;
String otherOrcid = "4444-4444-4444-4448";
OrcidProfile profile2 = createBasicProfile();
profile2.setOrcidIdentifier(otherOrcid);
List<Email> emailList2 = profile2.getOrcidBio().getContactDetails().getEmail();
emailList2.clear();
emailList2.add(new Email("another@semantico.com"));
profile2.getOrcidActivities().setAffiliations(affiliations);
orcidProfileManager.createOrcidProfile(profile2, false, false);
ProfileEntity profileEntity2 = profileDao.find(otherOrcid);
assertEquals(1, profileEntity2.getOrgAffiliationRelations().size());
OrgEntity orgEntity2 = profileEntity2.getOrgAffiliationRelations().iterator().next().getOrg();
assertNotNull(orgEntity);
assertEquals(orgEntity.getId(), orgEntity2.getId());
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createEmploymentAffiliation.
/**
* Add a new employment to the given user
*
* @param orcid
* The user to add the employment
* @param employment
* The employment to add
* @return the added employment
*/
@Override
public Employment createEmploymentAffiliation(String orcid, Employment employment, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
activityValidator.validateEmployment(employment, sourceEntity, true, isApiRequest, null);
OrgAffiliationRelationEntity employmentEntity = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(employment);
// Updates the give organization with the latest organization from
// database
OrgEntity updatedOrganization = orgManager.getOrgEntity(employment);
employmentEntity.setOrg(updatedOrganization);
// Set source id
if (sourceEntity.getSourceProfile() != null) {
employmentEntity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
employmentEntity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
employmentEntity.setProfile(profile);
setIncomingWorkPrivacy(employmentEntity, profile);
employmentEntity.setAffiliationType(AffiliationType.EMPLOYMENT);
orgAffiliationRelationDao.persist(employmentEntity);
orgAffiliationRelationDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItemList(employmentEntity));
return jpaJaxbEmploymentAdapter.toEmployment(employmentEntity);
}
use of org.orcid.persistence.jpa.entities.OrgEntity in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createEducationAffiliation.
/**
* Add a new education to the given user
*
* @param orcid
* The user to add the education
* @param education
* The education to add
* @return the added education
*/
@Override
public Education createEducationAffiliation(String orcid, Education education, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
activityValidator.validateEducation(education, sourceEntity, true, isApiRequest, null);
OrgAffiliationRelationEntity educationEntity = jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity(education);
// Updates the give organization with the latest organization from
// database
OrgEntity updatedOrganization = orgManager.getOrgEntity(education);
educationEntity.setOrg(updatedOrganization);
// Set source id
if (sourceEntity.getSourceProfile() != null) {
educationEntity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
educationEntity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
educationEntity.setProfile(profile);
setIncomingWorkPrivacy(educationEntity, profile);
educationEntity.setAffiliationType(AffiliationType.EDUCATION);
orgAffiliationRelationDao.persist(educationEntity);
orgAffiliationRelationDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItemList(educationEntity));
return jpaJaxbEducationAdapter.toEducation(educationEntity);
}
Aggregations