use of org.orcid.jaxb.model.common_rc1.Visibility 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, createItemList(employmentEntity));
return jpaJaxbEmploymentAdapter.toEmployment(employmentEntity);
}
use of org.orcid.jaxb.model.common_rc1.Visibility 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, createItemList(educationEntity));
return jpaJaxbEducationAdapter.toEducation(educationEntity);
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class MemberV2ApiServiceImplV2_0_rc2 method compareWorkAndCreditNameVisibility.
private void compareWorkAndCreditNameVisibility(Work work) {
Visibility workVisibility = work.getVisibility();
if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
for (Contributor contributor : work.getWorkContributors().getContributor()) {
if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(workVisibility)) {
String title = (work.getWorkTitle() == null || work.getWorkTitle().getTitle() == null) ? null : work.getWorkTitle().getTitle().getContent();
LOGGER.error("Client posting work '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, workVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
}
}
}
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class MemberV2ApiServiceImplV2_0_rc3 method compareFundingAndCreditNameVisibility.
private void compareFundingAndCreditNameVisibility(Funding funding) {
Visibility fundingVisibility = funding.getVisibility();
if (funding.getContributors() != null && funding.getContributors().getContributor() != null) {
for (FundingContributor contributor : funding.getContributors().getContributor()) {
if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(fundingVisibility)) {
String title = (funding.getTitle() == null || funding.getTitle().getTitle() == null) ? null : funding.getTitle().getTitle().getContent();
LOGGER.error("Client posting funding '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, fundingVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
}
}
}
}
use of org.orcid.jaxb.model.common_rc1.Visibility in project ORCID-Source by ORCID.
the class MigrateAddressData method migrateAddress.
private void migrateAddress() {
LOG.debug("Starting migration process");
List<Object[]> addressElements = Collections.emptyList();
do {
addressElements = addressDao.findAddressesToMigrate();
for (final Object[] addressElement : addressElements) {
String orcid = (String) addressElement[0];
String countryCode = (String) addressElement[1];
String visibilityValue = (String) addressElement[2];
LOG.info("Migrating address for profile: {}", orcid);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
Visibility visibility = null;
try {
visibility = Visibility.fromValue(visibilityValue);
} catch (Exception e) {
visibility = Visibility.fromValue(OrcidVisibilityDefaults.COUNTRY_DEFAULT.getVisibility().value());
}
AddressEntity address = new AddressEntity();
address.setDateCreated(new Date());
address.setLastModified(new Date());
address.setUser(new ProfileEntity(orcid));
address.setIso2Country(Iso3166Country.fromValue(countryCode));
address.setSourceId(orcid);
address.setVisibility(visibility);
addressDao.persist(address);
}
});
}
} while (addressElements != null && !addressElements.isEmpty());
LOG.debug("Finished migration process");
}
Aggregations