Compare commits

...

8 Commits

25 changed files with 103 additions and 41 deletions

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -27,6 +27,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import eu.dnetlib.openaire.community.model.DbCommunity;
import eu.dnetlib.openaire.community.model.DbCommunityType;
import eu.dnetlib.openaire.community.model.DbDatasource;
import eu.dnetlib.openaire.community.model.DbDatasourcePK;
import eu.dnetlib.openaire.community.model.DbOrganization;
@ -48,7 +49,6 @@ import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
import eu.dnetlib.openaire.exporter.model.community.CommunityType;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
import eu.dnetlib.openaire.exporter.model.community.SubCommunity;
import eu.dnetlib.openaire.exporter.model.community.SubCommunityWritableProperties;
@ -98,7 +98,7 @@ public class CommunityService {
@Transactional
public CommunityDetails getCommunity(final String id) {
final DbCommunity dbc = dbCommunityRepository.findById(id)
.filter(c -> c.getType() != CommunityType.subcommunity)
.filter(c -> c.getType() != DbCommunityType.subcommunity)
.filter(c -> c.getParent() == null)
.orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id));
@ -108,7 +108,7 @@ public class CommunityService {
@Transactional
public void updateCommunity(final String id, final CommunityWritableProperties details) {
final DbCommunity dbc = dbCommunityRepository.findById(id)
.filter(c -> c.getType() != CommunityType.subcommunity)
.filter(c -> c.getType() != DbCommunityType.subcommunity)
.filter(c -> c.getParent() == null)
.orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id));
@ -121,7 +121,7 @@ public class CommunityService {
@Transactional
public void removeCommunity(final String id) {
final DbCommunity dbc = dbCommunityRepository.findById(id)
.filter(c -> c.getType() != CommunityType.subcommunity)
.filter(c -> c.getType() != DbCommunityType.subcommunity)
.filter(c -> c.getParent() == null)
.orElseThrow(() -> new ResourceNotFoundException("Community not found: " + id));
@ -486,7 +486,7 @@ public class CommunityService {
public SubCommunity getSubCommunity(final String id, final String subCommunityId) {
return dbCommunityRepository.findById(subCommunityId)
.filter(c -> c.getId().startsWith(id + CommunityMappingUtils.COMMUNITY_ID_PARTS_SEPARATOR))
.filter(c -> c.getType() == CommunityType.subcommunity)
.filter(c -> c.getType() == DbCommunityType.subcommunity)
.filter(c -> c.getParent() != null)
.map(CommunityMappingUtils::toSubCommunity)
.orElseThrow(() -> new ResourceNotFoundException("Sub-Community not found: " + subCommunityId));
@ -497,7 +497,7 @@ public class CommunityService {
public List<SubCommunity> getSubCommunitiesForCommunity(final String id) {
return dbCommunityRepository.findByIdStartsWith(id + CommunityMappingUtils.COMMUNITY_ID_PARTS_SEPARATOR)
.stream()
.filter(c -> c.getType() == CommunityType.subcommunity)
.filter(c -> c.getType() == DbCommunityType.subcommunity)
.filter(c -> c.getParent() != null)
.map(CommunityMappingUtils::toSubCommunity)
.collect(Collectors.toList());
@ -506,7 +506,7 @@ public class CommunityService {
@Transactional
public void updateSubCommunity(final String subCommunityId, final SubCommunityWritableProperties details) {
final DbCommunity dbc = dbCommunityRepository.findById(subCommunityId)
.filter(c -> c.getType() == CommunityType.subcommunity)
.filter(c -> c.getType() == DbCommunityType.subcommunity)
.orElseThrow(() -> new ResourceNotFoundException("Community not found: " + subCommunityId));
CommunityMappingUtils.populateCommunity(dbc, details);
@ -539,7 +539,7 @@ public class CommunityService {
throw new CommunityException("The sub-collection id does not start with " + communityId);
}
final DbCommunity dbc = dbCommunityRepository.findById(subCommunityId)
.filter(c -> c.getType() == CommunityType.subcommunity)
.filter(c -> c.getType() == DbCommunityType.subcommunity)
.filter(c -> c.getParent() != null)
.orElseThrow(() -> new ResourceNotFoundException("SubCommunity not found: " + subCommunityId));

View File

@ -31,7 +31,6 @@ import eu.dnetlib.openaire.exporter.model.community.CommunityClaimType;
import eu.dnetlib.openaire.exporter.model.community.CommunityMembershipType;
import eu.dnetlib.openaire.exporter.model.community.CommunityPlanType;
import eu.dnetlib.openaire.exporter.model.community.CommunityStatus;
import eu.dnetlib.openaire.exporter.model.community.CommunityType;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
import eu.dnetlib.openaire.exporter.model.context.Param;
@ -78,7 +77,7 @@ public class DbCommunity implements Serializable {
@Column(name = "type")
@Enumerated(EnumType.STRING)
private CommunityType type;
private DbCommunityType type;
@Column(name = "claim")
@Convert(converter = CommunityClaimTypeConverter.class)
@ -131,6 +130,9 @@ public class DbCommunity implements Serializable {
@Enumerated(EnumType.STRING)
private CommunityPlanType plan;
@Column(name = "featured")
private Boolean featured;
@Type(type = "jsonb")
@Column(name = "sub_c_params")
private List<Param> params = new ArrayList<>();
@ -216,11 +218,11 @@ public class DbCommunity implements Serializable {
this.membership = membership;
}
public CommunityType getType() {
public DbCommunityType getType() {
return type;
}
public void setType(final CommunityType type) {
public void setType(final DbCommunityType type) {
this.type = type;
}
@ -328,6 +330,14 @@ public class DbCommunity implements Serializable {
this.plan = plan;
}
public Boolean getFeatured() {
return featured;
}
public void setFeatured(final Boolean featured) {
this.featured = featured;
}
public List<Param> getParams() {
return params;
}
@ -344,7 +354,7 @@ public class DbCommunity implements Serializable {
this.category = category;
}
public Boolean isClaimable() {
public Boolean getClaimable() {
return claimable;
}
@ -352,7 +362,7 @@ public class DbCommunity implements Serializable {
this.claimable = claimable;
}
public Boolean isBrowsable() {
public Boolean getBrowsable() {
return browsable;
}

View File

@ -0,0 +1,5 @@
package eu.dnetlib.openaire.community.model;
public enum DbCommunityType {
community, ri, subcommunity
}

View File

@ -18,6 +18,7 @@ import com.google.common.collect.Lists;
import eu.dnetlib.openaire.community.importer.CommunityImporterService;
import eu.dnetlib.openaire.community.model.DbCommunity;
import eu.dnetlib.openaire.community.model.DbCommunityType;
import eu.dnetlib.openaire.community.model.DbDatasource;
import eu.dnetlib.openaire.community.model.DbProject;
import eu.dnetlib.openaire.community.model.DbSupportOrg;
@ -60,7 +61,7 @@ public class CommunityMappingUtils {
c.setStatus(details.getStatus());
c.setLogoUrl(details.getLogoUrl());
c.setMembership(details.getMembership());
c.setType(details.getType());
c.setType(toDbCommunityType(details.getType()));
c.setClaim(details.getClaim());
c.setSubjects(toStringArray(details.getSubjects()));
c.setFos(toStringArray(details.getFos()));
@ -73,6 +74,8 @@ public class CommunityMappingUtils {
c.setPlan(details.getPlan());
c.setCreationDate(ObjectUtils.firstNonNull(details.getCreationDate(), LocalDateTime.now()));
c.setLastUpdateDate(LocalDateTime.now());
c.setFeatured(details.getFeatured());
return c;
}
@ -99,7 +102,7 @@ public class CommunityMappingUtils {
c.setMembership(details.getMembership());
}
if (details.getType() != null) {
c.setType(details.getType());
c.setType(toDbCommunityType(details.getType()));
}
if (details.getClaim() != null) {
c.setClaim(details.getClaim());
@ -131,6 +134,9 @@ public class CommunityMappingUtils {
if (details.getPlan() != null) {
c.setPlan(details.getPlan());
}
if (details.getFeatured() != null) {
c.setFeatured(details.getFeatured());
}
c.setLastUpdateDate(LocalDateTime.now());
}
@ -208,7 +214,7 @@ public class CommunityMappingUtils {
summary.setLastUpdateDate(c.getLastUpdateDate());
summary.setCreationDate(c.getCreationDate());
summary.setQueryId(c.getId() + PIPE_SEPARATOR + c.getShortName());
summary.setType(c.getType());
summary.setType(toCommunityType(c.getType()));
summary.setDescription(c.getDescription());
summary.setLogoUrl(c.getLogoUrl());
summary.setStatus(c.getStatus());
@ -216,6 +222,20 @@ public class CommunityMappingUtils {
summary.setMembership(c.getMembership());
summary.setZenodoCommunity(c.getMainZenodoCommunity());
summary.setPlan(c.getPlan());
summary.setFeatured(c.getFeatured());
}
private static DbCommunityType toDbCommunityType(final CommunityType type) {
if (type == CommunityType.community) { return DbCommunityType.community; }
if (type == CommunityType.ri) { return DbCommunityType.ri; }
return null;
}
private static CommunityType toCommunityType(final DbCommunityType type) {
if (type == DbCommunityType.community) { return CommunityType.community; }
if (type == DbCommunityType.ri) { return CommunityType.ri; }
if (type == DbCommunityType.subcommunity) { throw new RuntimeException("Invalid type (subcommunity)"); }
return null;
}
public static CommunityProject toCommunityProject(final DbProject dbEntry) {
@ -295,7 +315,7 @@ public class CommunityMappingUtils {
dbsc.setId(sub.getSubCommunityId());
dbsc.setParent(sub.getParent());
dbsc.setType(CommunityType.subcommunity);
dbsc.setType(DbCommunityType.subcommunity);
dbsc.setCategory(sub.getCategory());
dbsc.setName(sub.getLabel());
dbsc.setShortName(sub.getLabel());
@ -314,6 +334,7 @@ public class CommunityMappingUtils {
dbsc.setSuggestedAcknowledgements(toStringArray(sub.getSuggestedAcknowledgements()));
dbsc.setCreationDate(LocalDateTime.now());
dbsc.setLastUpdateDate(LocalDateTime.now());
dbsc.setFeatured(null);
return dbsc;
}
@ -327,8 +348,8 @@ public class CommunityMappingUtils {
sc.setCategory(sub.getCategory());
sc.setLabel(sub.getName());
sc.setParams(sub.getParams());
sc.setClaim(ObjectUtils.firstNonNull(sub.isClaimable(), false));
sc.setBrowsable(ObjectUtils.firstNonNull(sub.isBrowsable(), false));
sc.setClaim(ObjectUtils.firstNonNull(sub.getClaimable(), false));
sc.setBrowsable(ObjectUtils.firstNonNull(sub.getBrowsable(), false));
sc.setAdvancedConstraints(sub.getAdvancedConstraints());
sc.setRemoveConstraints(sub.getRemoveConstraints());
sc.setFos(Arrays.asList(sub.getFos()));

View File

@ -13,6 +13,7 @@ CREATE TABLE communities (
displayshortname text,
type text NOT NULL, -- community, ri, subcommunity
description text NOT NULL DEFAULT '',
featured boolean,
-- TODO how to manage this fields for sub-communityies ??
status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden, members

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -8,7 +8,7 @@
{{searchMessage}}
</span>
<span ng-if="!(orgs.totalElements || orgs.totalElements === 0)">
Total elements:<br />fr
Total elements:<br />
{{searchMessage}}
</span>
</p>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>cmd-line-apps</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -57,6 +57,9 @@ public class CommunitySummary {
@Schema(description = "community plan")
protected CommunityPlanType plan;
@Schema(description = "featured")
protected Boolean featured;
public CommunitySummary() {}
public CommunitySummary(
@ -73,7 +76,8 @@ public class CommunitySummary {
final String logoUrl,
final CommunityStatus status,
final String zenodoCommunity,
final CommunityPlanType plan) {
final CommunityPlanType plan,
final Boolean featured) {
this.id = id;
this.queryId = queryId;
this.type = type;
@ -88,6 +92,7 @@ public class CommunitySummary {
this.status = status;
this.zenodoCommunity = zenodoCommunity;
this.plan = plan;
this.featured = featured;
}
public CommunitySummary(final CommunitySummary summary) {
@ -104,7 +109,8 @@ public class CommunitySummary {
summary.getLogoUrl(),
summary.getStatus(),
summary.getZenodoCommunity(),
summary.getPlan());
summary.getPlan(),
summary.getFeatured());
}
public String getId() {
@ -235,4 +241,12 @@ public class CommunitySummary {
this.plan = plan;
}
public Boolean getFeatured() {
return featured;
}
public void setFeatured(final Boolean featured) {
this.featured = featured;
}
}

View File

@ -1,5 +1,5 @@
package eu.dnetlib.openaire.exporter.model.community;
public enum CommunityType {
subcommunity, community, ri
community, ri
}

View File

@ -64,6 +64,9 @@ public class CommunityWritableProperties {
@Schema(description = "community plan")
private CommunityPlanType plan;
@Schema(description = "featured")
private Boolean featured;
public List<String> getFos() {
return fos;
}
@ -208,4 +211,12 @@ public class CommunityWritableProperties {
this.plan = plan;
}
public Boolean getFeatured() {
return featured;
}
public void setFeatured(final Boolean featured) {
this.featured = featured;
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>libs</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

View File

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dnet-applications</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.6.2-SNAPSHOT</version>
<packaging>pom</packaging>
<licenses>