Skip to content

Commit 6bda78d

Browse files
authored
Merge pull request #6715 from ORCID/qa-fix-null-in-anoymize-script
Fixed null for anonymizing top contributors
2 parents 4ab2871 + 98d9df3 commit 6bda78d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromCSV.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ private void init() {
9494
ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
9595
workDao = (WorkDao) context.getBean("workDao");
9696
jpaJaxbWorkAdapter = (JpaJaxbWorkAdapter) context.getBean("jpaJaxbWorkAdapterV3");
97+
contributorUtils = (ContributorUtils) context.getBean("contributorUtilsV3");
98+
contributorsRolesAndSequencesConverter=context.getBean(ContributorsRolesAndSequencesConverter.class);
9799
bootstrapTogglz(context.getBean(OrcidTogglzConfiguration.class));
98100
}
99101

@@ -131,7 +133,6 @@ private static void bootstrapTogglz(OrcidTogglzConfiguration togglzConfig) {
131133
private void anonymizeWorks() throws Exception {
132134
ArrayList<WorkPojoFromCsv> worksFromCsv = getAllWorks();
133135
Work work;
134-
135136
// delete all existent works for orcid provided
136137
workDao.removeWorks(orcid);
137138

@@ -151,6 +152,9 @@ private void anonymizeWorks() throws Exception {
151152
}
152153
workEntity.setVisibility(work.getVisibility().name());
153154
if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null && work.getWorkContributors().getContributor().size() > 0) {
155+
if(maxContributorsForUI == 0) {
156+
maxContributorsForUI = 50;
157+
}
154158
List<ContributorsRolesAndSequences> topContributors = contributorUtils.getContributorsGroupedByOrcid(work.getWorkContributors().getContributor(), maxContributorsForUI);
155159
if (topContributors.size() > 0) {
156160
workEntity.setTopContributorsJson(contributorsRolesAndSequencesConverter.convertTo(topContributors, null));

orcid-core/src/main/java/org/orcid/core/cli/AnonymizeWorksFromGetMyData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ private void init() {
106106
ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
107107
workDao = (WorkDao) context.getBean("workDao");
108108
jpaJaxbWorkAdapter = (JpaJaxbWorkAdapter) context.getBean("jpaJaxbWorkAdapterV3");
109+
contributorUtils = (ContributorUtils) context.getBean("contributorUtilsV3");
110+
contributorsRolesAndSequencesConverter=context.getBean(ContributorsRolesAndSequencesConverter.class);
109111
bootstrapTogglz(context.getBean(OrcidTogglzConfiguration.class));
110112
}
111113

@@ -284,6 +286,9 @@ private void anonymizeWorks() throws Exception {
284286
workEntity.setSourceId(orcid);
285287
}
286288
if (anonymizedWork.getWorkContributors() != null && anonymizedWork.getWorkContributors().getContributor() != null && anonymizedWork.getWorkContributors().getContributor().size() > 0) {
289+
if(maxContributorsForUI == 0) {
290+
maxContributorsForUI = 50;
291+
}
287292
List<ContributorsRolesAndSequences> topContributors = contributorUtils.getContributorsGroupedByOrcid(anonymizedWork.getWorkContributors().getContributor(), maxContributorsForUI);
288293
if (topContributors.size() > 0) {
289294
workEntity.setTopContributorsJson(contributorsRolesAndSequencesConverter.convertTo(topContributors, null));

0 commit comments

Comments
 (0)