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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -46,9 +46,9 @@ import org.dspace.subscriptions.service.DSpaceObjectUpdates;
*
* @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 CommunityService communityService;
@@ -181,7 +181,7 @@ public class ItemsUpdates implements DSpaceObjectUpdates {
return discoverQuery;
}
public ItemsUpdates(CollectionService collectionService, CommunityService communityService, ItemService itemService,
public ItemUpdates(CollectionService collectionService, CommunityService communityService, ItemService itemService,
DiscoveryConfigurationService searchConfigurationService, SearchService searchService) {
this.collectionService = collectionService;
this.communityService = communityService;

View File

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

View File

@@ -40,7 +40,7 @@ public class SubscriptionEPersonLinkRepository extends AbstractDSpaceRestReposit
if (Objects.isNull(subscription)) {
throw new ResourceNotFoundException("No such subscription: " + subscriptionId);
}
return converter.toRest(subscription.getePerson(), projection);
return converter.toRest(subscription.getEPerson(), projection);
} catch (SQLException 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()));
return Objects.nonNull(subscription) ? currentUser.equals(subscription.getePerson()) : true;
return Objects.nonNull(subscription) ? currentUser.equals(subscription.getEPerson()) : true;
} catch (SQLException 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="itemUpdates" name="itemUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.ItemsUpdates" />
<bean id="itemUpdates" name="itemUpdates" class="org.dspace.subscriptions.dSpaceObjectsUpdates.ItemUpdates" />
</beans>