use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class MemberV2ApiServiceImplV2_0_rc1 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_rc4.Visibility in project ORCID-Source by ORCID.
the class MemberV2ApiServiceImplV2_0_rc2 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_rc4.Visibility in project ORCID-Source by ORCID.
the class MemberV2ApiServiceImplV2_0_rc3 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_rc4.Visibility in project ORCID-Source by ORCID.
the class MigrateNamesAndBioToTheirOwnTables method migrateData.
private void migrateData() {
LOG.debug("Starting migration process");
List<Object[]> profileElements = Collections.emptyList();
int counter = 0;
int batchCount = 0;
do {
LOG.debug("About to fetch a batch from DB");
profileElements = profileDao.findProfilesWhereNamesAreNotMigrated(batchSize);
LOG.debug("Procesing batch, profiles processed so far: " + counter);
for (final Object[] profileElement : profileElements) {
String orcid = (String) profileElement[0];
String givenNames = (String) profileElement[1];
String familyName = (String) profileElement[2];
String creditName = (String) profileElement[3];
String namesVisibility = (String) profileElement[4];
String biography = (String) profileElement[5];
String biographyVisibility = (String) profileElement[6];
String defaultVisibility = (String) profileElement[7];
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
LOG.info("Migrating names for profile: {}", orcid);
if (!recordNameDao.exists(orcid)) {
ProfileEntity profile = new ProfileEntity(orcid);
RecordNameEntity recordName = new RecordNameEntity();
recordName.setProfile(profile);
recordName.setCreditName(creditName);
recordName.setFamilyName(familyName);
recordName.setGivenNames(givenNames);
if (PojoUtil.isEmpty(namesVisibility)) {
recordName.setVisibility(Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
} else {
recordName.setVisibility(Visibility.fromValue(namesVisibility));
}
recordNameDao.createRecordName(recordName);
}
LOG.info("Migrating biography for profile: {}", orcid);
if (!biographyDao.exists(orcid)) {
Visibility visibility = Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value());
if (!PojoUtil.isEmpty(biographyVisibility)) {
visibility = Visibility.fromValue(biographyVisibility);
} else if (!PojoUtil.isEmpty(defaultVisibility)) {
visibility = Visibility.fromValue(defaultVisibility);
}
biographyDao.persistBiography(orcid, biography, visibility);
}
}
});
counter += 1;
}
batchCount += 1;
LOG.info("Batches processed so far: {}", String.valueOf(batchCount));
//Stop if we ran the number of batches
if (numberOfBatches > 0) {
if (batchCount >= numberOfBatches) {
profileElements = null;
}
}
} while (profileElements != null && !profileElements.isEmpty());
LOG.debug("Finished migration process");
}
use of org.orcid.jaxb.model.common_rc4.Visibility in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method retrivePublicDisplayName.
@Override
public String retrivePublicDisplayName(String orcid) {
String publicName = "";
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
if (profile != null) {
RecordNameEntity recordName = profile.getRecordNameEntity();
if (recordName != null) {
Visibility namesVisibility = (recordName.getVisibility() != null) ? Visibility.fromValue(recordName.getVisibility().value()) : Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value());
if (Visibility.PUBLIC.equals(namesVisibility)) {
if (!PojoUtil.isEmpty(recordName.getCreditName())) {
publicName = recordName.getCreditName();
} else {
publicName = PojoUtil.isEmpty(recordName.getGivenNames()) ? "" : recordName.getGivenNames();
publicName += PojoUtil.isEmpty(recordName.getFamilyName()) ? "" : " " + recordName.getFamilyName();
}
}
}
}
return publicName;
}
Aggregations