[CST-7756] renamed some methods & class

This commit is contained in:
Mykhaylo
2023-01-27 14:53:53 +01:00
parent c59438b936
commit f5c1690e0b
11 changed files with 37 additions and 37 deletions

View File

@@ -104,12 +104,12 @@ public class SubscribeCLITool {
// Go through the list collating subscriptions for each e-person // Go through the list collating subscriptions for each e-person
for (Subscription subscription : subscriptions) { for (Subscription subscription : subscriptions) {
if (!(subscription.getdSpaceObject() != null && subscription.getdSpaceObject() instanceof Collection)) { if (!(subscription.getDSpaceObject() != null && subscription.getDSpaceObject() instanceof Collection)) {
continue; continue;
} }
// Does this row relate to the same e-person as the last? // Does this row relate to the same e-person as the last?
if ((currentEPerson == null) if ((currentEPerson == null)
|| (!subscription.getePerson().getID().equals(currentEPerson || (!subscription.getEPerson().getID().equals(currentEPerson
.getID()))) { .getID()))) {
// New e-person. Send mail for previous e-person // New e-person. Send mail for previous e-person
if (currentEPerson != null) { if (currentEPerson != null) {
@@ -123,11 +123,11 @@ public class SubscribeCLITool {
} }
} }
currentEPerson = subscription.getePerson(); currentEPerson = subscription.getEPerson();
collections = new ArrayList<>(); collections = new ArrayList<>();
} }
collections.add((Collection) subscription.getdSpaceObject()); collections.add((Collection) subscription.getDSpaceObject());
} }
// Process the last person // Process the last person

View File

@@ -70,7 +70,7 @@ public class SubscribeServiceImpl implements SubscribeService {
Subscription newSubscription = subscriptionDAO.create(context, new Subscription()); Subscription newSubscription = subscriptionDAO.create(context, new Subscription());
subscriptionParameterList.forEach(subscriptionParameter -> subscriptionParameterList.forEach(subscriptionParameter ->
newSubscription.addParameter(subscriptionParameter)); newSubscription.addParameter(subscriptionParameter));
newSubscription.setePerson(eperson); newSubscription.setEPerson(eperson);
newSubscription.setdSpaceObject(dSpaceObject); newSubscription.setdSpaceObject(dSpaceObject);
newSubscription.setSubscriptionType(type); newSubscription.setSubscriptionType(type);
return newSubscription; return newSubscription;
@@ -156,7 +156,7 @@ public class SubscribeServiceImpl implements SubscribeService {
subscriptionDB.setSubscriptionType(type); subscriptionDB.setSubscriptionType(type);
subscriptionDB.setdSpaceObject(dSpaceObject); subscriptionDB.setdSpaceObject(dSpaceObject);
subscriptionParameterList.forEach(x -> subscriptionDB.addParameter(x)); subscriptionParameterList.forEach(x -> subscriptionDB.addParameter(x));
subscriptionDB.setePerson(eperson); subscriptionDB.setEPerson(eperson);
subscriptionDAO.save(context, subscriptionDB); subscriptionDAO.save(context, subscriptionDB);
return subscriptionDB; return subscriptionDB;
} }

View File

@@ -71,7 +71,7 @@ public class Subscription implements ReloadableEntity<Integer> {
return id; return id;
} }
public DSpaceObject getdSpaceObject() { public DSpaceObject getDSpaceObject() {
return this.dSpaceObject; return this.dSpaceObject;
} }
@@ -79,11 +79,11 @@ public class Subscription implements ReloadableEntity<Integer> {
this.dSpaceObject = dSpaceObject; this.dSpaceObject = dSpaceObject;
} }
public EPerson getePerson() { public EPerson getEPerson() {
return ePerson; return ePerson;
} }
public void setePerson(EPerson ePerson) { public void setEPerson(EPerson ePerson) {
this.ePerson = ePerson; this.ePerson = ePerson;
} }

View File

@@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
/** /**
* Implementation class of SubscriptionGenerator * Implementation class of SubscriptionGenerator
* which will handle the logic of sending the emails * which will handle the logic of sending the emails
* in case of content subscriptions * in case of 'content' subscriptionType
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class ContentGenerator implements SubscriptionGenerator<IndexableObject> { public class ContentGenerator implements SubscriptionGenerator<IndexableObject> {

View File

@@ -41,7 +41,7 @@ public class SubscriptionEmailNotification
@Override @Override
public void setup() throws ParseException { public void setup() throws ParseException {
this.subscriptionEmailNotificationService = new DSpace().getServiceManager().getServiceByName( this.subscriptionEmailNotificationService = new DSpace().getServiceManager().getServiceByName(
SubscriptionEmailNotificationService.class.getName(), SubscriptionEmailNotificationService.class); SubscriptionEmailNotificationServiceImpl.class.getName(), SubscriptionEmailNotificationServiceImpl.class);
} }
@Override @Override

View File

@@ -77,12 +77,12 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void perform(Context context, DSpaceRunnableHandler handler, String type, String frequency) { public void perform(Context context, DSpaceRunnableHandler handler, String subscriptionType, String frequency) {
try { try {
List<Subscription> subscriptions = findAllSubscriptionsBySubscriptionTypeAndFrequency(context, type, List<Subscription> subscriptions =
frequency); findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, frequency);
// Here is verified if type is "content" Or "statistics" as them are configured // Here is verified if SubscriptionType is "content" Or "statistics" as them are configured
if (subscriptionType2generators.keySet().contains(type)) { if (subscriptionType2generators.keySet().contains(subscriptionType)) {
// the list of the person who has subscribed // the list of the person who has subscribed
int iterator = 0; int iterator = 0;
for (Subscription subscription : subscriptions) { for (Subscription subscription : subscriptions) {
@@ -97,13 +97,13 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
items.addAll(contentUpdates.get(Item.class.getSimpleName().toLowerCase(Locale.ROOT)) items.addAll(contentUpdates.get(Item.class.getSimpleName().toLowerCase(Locale.ROOT))
.findUpdates(context, dSpaceObject, frequency)); .findUpdates(context, dSpaceObject, frequency));
} }
var ePerson = subscription.getePerson(); var ePerson = subscription.getEPerson();
if (iterator < subscriptions.size() - 1) { if (iterator < subscriptions.size() - 1) {
if (ePerson.equals(subscriptions.get(iterator + 1).getePerson())) { if (ePerson.equals(subscriptions.get(iterator + 1).getEPerson())) {
iterator++; iterator++;
continue; continue;
} else { } else {
subscriptionType2generators.get(type) subscriptionType2generators.get(subscriptionType)
.notifyForSubscriptions(context, ePerson, communities, collections, items); .notifyForSubscriptions(context, ePerson, communities, collections, items);
communities.clear(); communities.clear();
collections.clear(); collections.clear();
@@ -111,14 +111,14 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
} }
} else { } else {
//in the end of the iteration //in the end of the iteration
subscriptionType2generators.get(type) subscriptionType2generators.get(subscriptionType)
.notifyForSubscriptions(context, ePerson, communities, collections, items); .notifyForSubscriptions(context, ePerson, communities, collections, items);
} }
iterator++; iterator++;
} }
} else { } else {
throw new IllegalArgumentException("Currently this type:" + type + throw new IllegalArgumentException("Currently this SubscriptionType:" + subscriptionType +
" of subscription is not supported!"); " is not supported!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@@ -128,9 +128,9 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
} }
private DSpaceObject getdSpaceObject(Subscription subscription) { private DSpaceObject getdSpaceObject(Subscription subscription) {
DSpaceObject dSpaceObject = subscription.getdSpaceObject(); DSpaceObject dSpaceObject = subscription.getDSpaceObject();
if (subscription.getdSpaceObject() instanceof HibernateProxy) { if (subscription.getDSpaceObject() instanceof HibernateProxy) {
HibernateProxy hibernateProxy = (HibernateProxy) subscription.getdSpaceObject(); HibernateProxy hibernateProxy = (HibernateProxy) subscription.getDSpaceObject();
LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer(); LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer();
dSpaceObject = (DSpaceObject) initializer.getImplementation(); dSpaceObject = (DSpaceObject) initializer.getImplementation();
} }
@@ -143,7 +143,7 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
return subscribeService.findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, return subscribeService.findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType,
frequency) frequency)
.stream() .stream()
.sorted(Comparator.comparing(s -> s.getePerson().getID())) .sorted(Comparator.comparing(s -> s.getEPerson().getID()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (SQLException e) { } catch (SQLException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

View File

@@ -46,9 +46,9 @@ import org.dspace.subscriptions.service.DSpaceObjectUpdates;
* *
* @author Alba Aliu * @author Alba Aliu
*/ */
public class ItemsUpdates implements DSpaceObjectUpdates { public class ItemUpdates implements DSpaceObjectUpdates {
private final Logger log = LogManager.getLogger(ItemsUpdates.class); private final Logger log = LogManager.getLogger(ItemUpdates.class);
private final CollectionService collectionService; private final CollectionService collectionService;
private final CommunityService communityService; private final CommunityService communityService;
@@ -181,7 +181,7 @@ public class ItemsUpdates implements DSpaceObjectUpdates {
return discoverQuery; return discoverQuery;
} }
public ItemsUpdates(CollectionService collectionService, CommunityService communityService, ItemService itemService, public ItemUpdates(CollectionService collectionService, CommunityService communityService, ItemService itemService,
DiscoveryConfigurationService searchConfigurationService, SearchService searchService) { DiscoveryConfigurationService searchConfigurationService, SearchService searchService) {
this.collectionService = collectionService; this.collectionService = collectionService;
this.communityService = communityService; this.communityService = communityService;

View File

@@ -45,12 +45,12 @@ public class SubscriptionDSpaceObjectLinkRepository extends AbstractDSpaceRestRe
if (Objects.isNull(subscription)) { if (Objects.isNull(subscription)) {
throw new ResourceNotFoundException("No such subscription: " + subscriptionId); throw new ResourceNotFoundException("No such subscription: " + subscriptionId);
} }
if (subscription.getdSpaceObject() instanceof Item || if (subscription.getDSpaceObject() instanceof Item ||
subscription.getdSpaceObject() instanceof Community || subscription.getDSpaceObject() instanceof Community ||
subscription.getdSpaceObject() instanceof Collection) { subscription.getDSpaceObject() instanceof Collection) {
return converter.toRest(subscription.getdSpaceObject(), projection); return converter.toRest(subscription.getDSpaceObject(), projection);
} else { } else {
HibernateProxy hibernateProxy = (HibernateProxy) subscription.getdSpaceObject(); HibernateProxy hibernateProxy = (HibernateProxy) subscription.getDSpaceObject();
LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer(); LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer();
return converter.toRest(initializer.getImplementation(), projection); return converter.toRest(initializer.getImplementation(), projection);
} }

View File

@@ -40,7 +40,7 @@ public class SubscriptionEPersonLinkRepository extends AbstractDSpaceRestReposit
if (Objects.isNull(subscription)) { if (Objects.isNull(subscription)) {
throw new ResourceNotFoundException("No such subscription: " + subscriptionId); throw new ResourceNotFoundException("No such subscription: " + subscriptionId);
} }
return converter.toRest(subscription.getePerson(), projection); return converter.toRest(subscription.getEPerson(), projection);
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} }

View File

@@ -74,7 +74,7 @@ public class SubscriptionRestPermissionEvaluatorPlugin extends RestObjectPermiss
} }
Subscription subscription = subscribeService.findById(context, Integer.parseInt(targetId.toString())); Subscription subscription = subscribeService.findById(context, Integer.parseInt(targetId.toString()));
return Objects.nonNull(subscription) ? currentUser.equals(subscription.getePerson()) : true; return Objects.nonNull(subscription) ? currentUser.equals(subscription.getEPerson()) : true;
} catch (SQLException e) { } catch (SQLException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }

View File

@@ -82,6 +82,6 @@
<bean id="collectionUpdates" name="collectionUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.CollectionsUpdates" /> <bean id="collectionUpdates" name="collectionUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.CollectionsUpdates" />
<bean id="itemUpdates" name="itemUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.ItemsUpdates" /> <bean id="itemUpdates" name="itemUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.ItemUpdates" />
</beans> </beans>