use of org.orcid.jaxb.model.common_v2.Organization in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method updateEmploymentAffiliation.
/**
* Updates a employment that belongs to the given user
*
* @param orcid
* The user
* @param employment
* The employment to update
* @return the updated employment
* */
@Override
public Employment updateEmploymentAffiliation(String orcid, Employment employment, boolean isApiRequest) {
OrgAffiliationRelationEntity employmentEntity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, employment.getPutCode());
Visibility originalVisibility = employmentEntity.getVisibility();
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
//Save the original source
String existingSourceId = employmentEntity.getSourceId();
String existingClientSourceId = employmentEntity.getClientSourceId();
orcidSecurityManager.checkSource(employmentEntity);
activityValidator.validateEmployment(employment, sourceEntity, false, isApiRequest, originalVisibility);
jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(employment, employmentEntity);
employmentEntity.setVisibility(originalVisibility);
//Be sure it doesn't overwrite the source
employmentEntity.setSourceId(existingSourceId);
employmentEntity.setClientSourceId(existingClientSourceId);
// Updates the give organization with the latest organization from
// database, or, create a new one
OrgEntity updatedOrganization = orgManager.getOrgEntity(employment);
employmentEntity.setOrg(updatedOrganization);
employmentEntity.setAffiliationType(AffiliationType.EMPLOYMENT);
employmentEntity = orgAffiliationRelationDao.merge(employmentEntity);
orgAffiliationRelationDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItem(employmentEntity));
return jpaJaxbEmploymentAdapter.toEmployment(employmentEntity);
}
use of org.orcid.jaxb.model.common_v2.Organization in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method updateEducationAffiliation.
/**
* Updates a education that belongs to the given user
*
* @param orcid
* The user
* @param education
* The education to update
* @return the updated education
* */
@Override
public Education updateEducationAffiliation(String orcid, Education education, boolean isApiRequest) {
OrgAffiliationRelationEntity educationEntity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, education.getPutCode());
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
//Save the original source
String existingSourceId = educationEntity.getSourceId();
String existingClientSourceId = educationEntity.getClientSourceId();
Visibility originalVisibility = educationEntity.getVisibility();
orcidSecurityManager.checkSource(educationEntity);
activityValidator.validateEducation(education, sourceEntity, false, isApiRequest, originalVisibility);
jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity(education, educationEntity);
educationEntity.setVisibility(originalVisibility);
//Be sure it doesn't overwrite the source
educationEntity.setSourceId(existingSourceId);
educationEntity.setClientSourceId(existingClientSourceId);
// Updates the give organization with the latest organization from
// database, or, create a new one
OrgEntity updatedOrganization = orgManager.getOrgEntity(education);
educationEntity.setOrg(updatedOrganization);
educationEntity.setAffiliationType(AffiliationType.EDUCATION);
educationEntity = orgAffiliationRelationDao.merge(educationEntity);
orgAffiliationRelationDao.flush();
notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItem(educationEntity));
return jpaJaxbEducationAdapter.toEducation(educationEntity);
}
use of org.orcid.jaxb.model.common_v2.Organization in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method getEducation.
private Education getEducation() {
Education education = new Education();
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
education.setOrganization(org);
education.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
education.setVisibility(Visibility.PUBLIC);
return education;
}
use of org.orcid.jaxb.model.common_v2.Organization in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method getEmployment.
private Employment getEmployment() {
Employment employment = new Employment();
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
employment.setOrganization(org);
employment.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
employment.setVisibility(Visibility.PUBLIC);
return employment;
}
use of org.orcid.jaxb.model.common_v2.Organization in project ORCID-Source by ORCID.
the class ProfileFundingManagerImpl method updateFunding.
/**
* Updates a funding that belongs to the given user
* @param orcid
* The user
* @param funding
* The funding to update
* @return the updated funding
* */
@Override
public Funding updateFunding(String orcid, Funding funding, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
ProfileFundingEntity pfe = profileFundingDao.getProfileFunding(orcid, funding.getPutCode());
Visibility originalVisibility = pfe.getVisibility();
//Save the original source
String existingSourceId = pfe.getSourceId();
String existingClientSourceId = pfe.getClientSourceId();
activityValidator.validateFunding(funding, sourceEntity, false, isApiRequest, originalVisibility);
if (!isApiRequest) {
List<ProfileFundingEntity> existingFundings = profileFundingDao.getByUser(orcid);
for (ProfileFundingEntity existingFunding : existingFundings) {
Funding existing = jpaJaxbFundingAdapter.toFunding(existingFunding);
if (!existing.getPutCode().equals(funding.getPutCode())) {
activityValidator.checkFundingExternalIdentifiersForDuplicates(funding.getExternalIdentifiers(), existing.getExternalIdentifiers(), existing.getSource(), sourceEntity);
}
}
}
orcidSecurityManager.checkSource(pfe);
jpaJaxbFundingAdapter.toProfileFundingEntity(funding, pfe);
pfe.setVisibility(originalVisibility);
//Be sure it doesn't overwrite the source
pfe.setSourceId(existingSourceId);
pfe.setClientSourceId(existingClientSourceId);
//Updates the give organization with the latest organization from database, or, create a new one
OrgEntity updatedOrganization = orgManager.getOrgEntity(funding);
pfe.setOrg(updatedOrganization);
pfe = profileFundingDao.merge(pfe);
profileFundingDao.flush();
if (!isApiRequest) {
notificationManager.sendAmendEmail(orcid, AmendedSection.FUNDING, createItem(pfe));
}
return jpaJaxbFundingAdapter.toFunding(pfe);
}
Aggregations