Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,41 @@ files: [
"update_option" : "update_as_unapproved",
"escape_special_characters": 0,
"escape_quotes" : 0,
},
{
"source": "/ide-webapp/src/main/resources/locale/portlet/SiteManagement_en.properties",

"translation": "%original_path%/%file_name%!_%locale_with_underscore%.%file_extension%",
"translation_replace": {
"_en!": "","ar_SA": "ar","ar_OM": "aro","az_AZ": "az","ca_ES": "ca","ceb_PH": "ceb",
"co_FR": "co","cs_CZ": "cs","de_DE": "de","el_GR": "el","en_US": "en","es_ES": "es_ES","eu_ES": "eu","fa_IR": "fa",
"fi_FI": "fi","fil_PH": "fil","fr_FR": "fr","hi_IN": "hi","hu_HU": "hu","id_ID": "id","it_IT": "it","ja_JP": "ja",
"kab_KAB": "kab","ko_KR": "ko","lt_LT": "lt","ms_MY": "ms","nl_NL": "nl","no_NO": "no","pcm_NG": "pcm","pl_PL": "pl",
"pt_BR": "pt_BR","pt_PT": "pt_PT","ro_RO": "ro","ru_RU": "ru","sk_SK": "sk","sl_SI": "sl","sq_AL": "sq",
"sv_SE": "sv_SE","th_TH": "th","tl_PH": "tl","tr_TR": "tr","uk_UA": "uk","ur_IN": "ur_IN","vi_VN": "vi",
"zh_CN": "zh_CN","zh_TW": "zh_TW",
},
"dest": "hub/ide/SiteManagement.properties",
"update_option": "update_as_unapproved",
"escape_special_characters": 0,
"escape_quotes": 0,
},
{
"source": "/ide-webapp/src/main/resources/locale/portlet/Analytics_en.properties",

"translation": "%original_path%/%file_name%!_%locale_with_underscore%.%file_extension%",
"translation_replace": {
"_en!": "","ar_SA": "ar","ar_OM": "aro","az_AZ": "az","ca_ES": "ca","ceb_PH": "ceb",
"co_FR": "co","cs_CZ": "cs","de_DE": "de","el_GR": "el","en_US": "en","es_ES": "es_ES","eu_ES": "eu","fa_IR": "fa",
"fi_FI": "fi","fil_PH": "fil","fr_FR": "fr","hi_IN": "hi","hu_HU": "hu","id_ID": "id","it_IT": "it","ja_JP": "ja",
"kab_KAB": "kab","ko_KR": "ko","lt_LT": "lt","ms_MY": "ms","nl_NL": "nl","no_NO": "no","pcm_NG": "pcm","pl_PL": "pl",
"pt_BR": "pt_BR","pt_PT": "pt_PT","ro_RO": "ro","ru_RU": "ru","sk_SK": "sk","sl_SI": "sl","sq_AL": "sq",
"sv_SE": "sv_SE","th_TH": "th","tl_PH": "tl","tr_TR": "tr","uk_UA": "uk","ur_IN": "ur_IN","vi_VN": "vi",
"zh_CN": "zh_CN","zh_TW": "zh_TW",
},
"dest": "hub/ide/Analytics.properties",
"update_option": "update_as_unapproved",
"escape_special_characters": 0,
"escape_quotes": 0,
}
]
8 changes: 6 additions & 2 deletions ide-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<rest.api.doc.version>1.0</rest.api.doc.version>
<rest.api.doc.description>Widget IDE endpoints</rest.api.doc.description>

<exo.test.coverage.ratio>0.95</exo.test.coverage.ratio>
<exo.test.coverage.ratio>0.87</exo.test.coverage.ratio>
</properties>
<dependencies>
<dependency>
Expand All @@ -47,7 +47,11 @@
<groupId>io.meeds.layout</groupId>
<artifactId>layout-service</artifactId>
</dependency>

<dependency>
<groupId>io.meeds.analytics</groupId>
<artifactId>analytics-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
23 changes: 23 additions & 0 deletions ide-service/src/main/java/io/meeds/ide/constant/WidgetType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io
*
* 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.ide.constant;

public enum WidgetType {
APP, CSS, JS
}
3 changes: 2 additions & 1 deletion ide-service/src/main/java/io/meeds/ide/dao/WidgetDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
package io.meeds.ide.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import io.meeds.ide.entity.WidgetEntity;

@Repository
public interface WidgetDAO extends JpaRepository<WidgetEntity, Long> {
public interface WidgetDAO extends JpaRepository<WidgetEntity, Long>, JpaSpecificationExecutor<WidgetEntity> {

boolean existsByPortletId(Long id);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io
*
* 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.ide.dao.query;

import io.meeds.ide.entity.WidgetEntity;
import jakarta.persistence.criteria.*;
import org.springframework.data.jpa.domain.Specification;

import java.util.Map;
import java.util.Objects;

public class WidgetQueryBuilder {

private WidgetQueryBuilder() {
// Static Utils methods
}

public static Specification<WidgetEntity> hasProperties(Map<String, String> properties) {
return (Root<WidgetEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
Predicate finalPredicate = cb.conjunction();

for (Map.Entry<String, String> entry : properties.entrySet()) {
Subquery<Long> subquery = Objects.requireNonNull(query).subquery(Long.class);
Root<WidgetEntity> subRoot = subquery.from(WidgetEntity.class);
MapJoin<WidgetEntity, String, String> subPropertiesJoin = subRoot.joinMap("properties");

subquery.select(cb.literal(1L))
.where(cb.equal(subRoot.get("id"), root.get("id")),
cb.equal(subPropertiesJoin.key(), entry.getKey()),
cb.equal(subPropertiesJoin.value(), entry.getValue()));

finalPredicate = cb.and(finalPredicate, cb.exists(subquery));
}

return finalPredicate;
};
}
}
38 changes: 22 additions & 16 deletions ide-service/src/main/java/io/meeds/ide/entity/WidgetEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
package io.meeds.ide.entity;

import java.time.LocalDateTime;
import java.util.Map;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import io.meeds.ide.constant.WidgetType;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -42,30 +38,40 @@ public class WidgetEntity {
@SequenceGenerator(name = "SEQ_IDE_WIDGET_ID", sequenceName = "SEQ_IDE_WIDGET_ID", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_IDE_WIDGET_ID")
@Column(name = "ID")
protected Long id;
protected Long id;

@Column(name = "PORTLET_ID")
protected Long portletId;
protected Long portletId;

@Column(name = "HTML")
private String html;
private String html;

@Column(name = "CSS")
private String css;
private String css;

@Column(name = "JS")
private String js;
private String js;

@Column(name = "CREATOR_ID")
protected Long creatorId;
protected Long creatorId;

@Column(name = "MODIFIER_ID")
protected Long modifierId;
protected Long modifierId;

@Column(name = "MODIFIED_DATE")
protected LocalDateTime modifiedDate;
protected LocalDateTime modifiedDate;

@Column(name = "CREATED_DATE")
protected LocalDateTime createdDate;
protected LocalDateTime createdDate;

@Enumerated(EnumType.ORDINAL)
@Column(name = "TYPE", nullable = false)
protected WidgetType type;

@ElementCollection(fetch = FetchType.EAGER)
@MapKeyColumn(name = "NAME")
@Column(name = "VALUE")
@CollectionTable(name = "IDE_WIDGETS_SETTINGS", joinColumns = { @JoinColumn(name = "ID") })
private Map<String, String> properties;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io
*
* 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.ide.listener;

import static io.meeds.analytics.utils.AnalyticsUtils.addStatisticData;
import static io.meeds.ide.service.StaticResourceService.SITE_NAME;
import static io.meeds.ide.service.WidgetService.IDE_WIDGET_CREATED_EVENT;

import io.meeds.ide.model.Widget;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import org.exoplatform.services.listener.Asynchronous;
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 jakarta.annotation.PostConstruct;

@Asynchronous
@Component
@Profile("layout")
public class StaticResourcesAnalyticsListener extends Listener<String, Widget> {

private static final String STATISTICS_TYPE_PARAM = "type";

@Autowired
private ListenerService listenerService;

@PostConstruct
public void init() {
listenerService.addListener(IDE_WIDGET_CREATED_EVENT, this);
}

@Override
public void onEvent(Event<String, Widget> event) {
Widget widget = event.getData();
if (widget == null || MapUtils.isEmpty(widget.getProperties())) {
return;
}
StatisticData statisticData = new StatisticData();
statisticData.setModule("portal");
statisticData.setSubModule("layout");
statisticData.setOperation("addStatisticResource");
statisticData.setUserId(widget.getCreatorId());
statisticData.addParameter(SITE_NAME, widget.getProperties().get(SITE_NAME));
statisticData.addParameter(STATISTICS_TYPE_PARAM, widget.getType());
addStatisticData(statisticData);
}
}
24 changes: 15 additions & 9 deletions ide-service/src/main/java/io/meeds/ide/model/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
package io.meeds.ide.model;

import java.time.LocalDateTime;
import java.util.Map;

import io.meeds.ide.constant.WidgetType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand All @@ -29,25 +31,29 @@
@Data
public class Widget {

protected Long id;
protected Long id;

/**
* Portlet instance identifier
*/
protected Long portletId;
protected Long portletId;

private String html;
private String html;

private String css;
private String css;

private String js;
private String js;

protected Long creatorId;
protected Long creatorId;

protected Long modifierId;
protected Long modifierId;

protected LocalDateTime modifiedDate;
protected LocalDateTime modifiedDate;

protected LocalDateTime createdDate;
protected LocalDateTime createdDate;

protected WidgetType type;

private Map<String, String> properties;

}
Loading