-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#258) This change will add some event listeners to handle category management and objects link to categories, such as spaces. In addition, this change will implement some UI extensions to well display the category names in Analytics Table and Analytics Charts.
- Loading branch information
Showing
18 changed files
with
590 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...eners/src/main/java/io/meeds/analytics/listener/social/AnalyticsCategoryLinkListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2025 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.analytics.listener.social; | ||
|
||
import static io.meeds.social.category.service.CategoryService.EVENT_SOCIAL_CATEGORY_ITEM_LINKED; | ||
import static io.meeds.social.category.service.CategoryService.EVENT_SOCIAL_CATEGORY_ITEM_UNLINKED; | ||
|
||
import java.util.Date; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import org.exoplatform.services.listener.Event; | ||
import org.exoplatform.services.listener.Listener; | ||
import org.exoplatform.services.listener.ListenerService; | ||
|
||
import io.meeds.analytics.model.StatisticData; | ||
import io.meeds.analytics.utils.AnalyticsUtils; | ||
import io.meeds.social.category.model.CategoryObject; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
|
||
@Component | ||
public class AnalyticsCategoryLinkListener extends Listener<CategoryObject, Long> { | ||
|
||
@Autowired | ||
private ListenerService listenerService; | ||
|
||
@PostConstruct | ||
public void init() { | ||
listenerService.addListener(EVENT_SOCIAL_CATEGORY_ITEM_LINKED, this); | ||
listenerService.addListener(EVENT_SOCIAL_CATEGORY_ITEM_UNLINKED, this); | ||
} | ||
|
||
@Override | ||
public void onEvent(Event<CategoryObject, Long> event) throws Exception { | ||
StatisticData statisticData = new StatisticData(); | ||
statisticData.setTimestamp(new Date().getTime()); | ||
statisticData.setModule("social"); | ||
statisticData.setSubModule("category"); | ||
switch (event.getEventName()) { | ||
case EVENT_SOCIAL_CATEGORY_ITEM_LINKED: | ||
statisticData.setOperation("categoryObjectLinked"); | ||
break; | ||
case EVENT_SOCIAL_CATEGORY_ITEM_UNLINKED: | ||
statisticData.setOperation("categoryObjectUnlinked"); | ||
break; | ||
default: | ||
break; | ||
} | ||
AnalyticsUtils.addCategoryStatistics(statisticData, event.getData()); | ||
AnalyticsUtils.addCategoryLinkStatistics(statisticData, event.getSource()); | ||
AnalyticsUtils.addStatisticData(statisticData); | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
...listeners/src/main/java/io/meeds/analytics/listener/social/AnalyticsCategoryListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2025 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.analytics.listener.social; | ||
|
||
import static io.meeds.social.category.service.CategoryService.EVENT_SOCIAL_CATEGORY_CREATED; | ||
import static io.meeds.social.category.service.CategoryService.EVENT_SOCIAL_CATEGORY_DELETED; | ||
import static io.meeds.social.category.service.CategoryService.EVENT_SOCIAL_CATEGORY_UPDATED; | ||
|
||
import java.util.Date; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import org.exoplatform.services.listener.Event; | ||
import org.exoplatform.services.listener.Listener; | ||
import org.exoplatform.services.listener.ListenerService; | ||
|
||
import io.meeds.analytics.model.StatisticData; | ||
import io.meeds.analytics.utils.AnalyticsUtils; | ||
import io.meeds.social.category.model.Category; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
|
||
@Component | ||
public class AnalyticsCategoryListener extends Listener<Category, Long> { | ||
|
||
@Autowired | ||
private ListenerService listenerService; | ||
|
||
@PostConstruct | ||
public void init() { | ||
listenerService.addListener(EVENT_SOCIAL_CATEGORY_CREATED, this); | ||
listenerService.addListener(EVENT_SOCIAL_CATEGORY_UPDATED, this); | ||
listenerService.addListener(EVENT_SOCIAL_CATEGORY_DELETED, this); | ||
} | ||
|
||
@Override | ||
public void onEvent(Event<Category, Long> event) throws Exception { | ||
StatisticData statisticData = new StatisticData(); | ||
statisticData.setTimestamp(new Date().getTime()); | ||
statisticData.setModule("social"); | ||
statisticData.setSubModule("category"); | ||
switch (event.getEventName()) { | ||
case EVENT_SOCIAL_CATEGORY_CREATED: | ||
statisticData.setOperation("categoryCreated"); | ||
break; | ||
case EVENT_SOCIAL_CATEGORY_UPDATED: | ||
statisticData.setOperation("categoryUpdated"); | ||
break; | ||
case EVENT_SOCIAL_CATEGORY_DELETED: | ||
statisticData.setOperation("categoryDeleted"); | ||
break; | ||
default: | ||
break; | ||
} | ||
AnalyticsUtils.addCategoryStatistics(statisticData, event.getSource()); | ||
AnalyticsUtils.addStatisticData(statisticData); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.