194 lines
7.8 KiB
Java
194 lines
7.8 KiB
Java
package eu.dnetlib.openaire.community.db;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import eu.dnetlib.openaire.community.db.model.DbProject;
|
|
import eu.dnetlib.openaire.community.db.repository.DbCommunityRepository;
|
|
import eu.dnetlib.openaire.community.db.repository.DbDatasourceRepository;
|
|
import eu.dnetlib.openaire.community.db.repository.DbOrganizationRepository;
|
|
import eu.dnetlib.openaire.community.db.repository.DbProjectRepository;
|
|
import eu.dnetlib.openaire.community.db.repository.DbSupportOrgRepository;
|
|
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
|
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
|
|
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
|
|
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
|
|
|
|
@Service
|
|
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
|
|
public class CommunityService {
|
|
|
|
@Autowired
|
|
private DbCommunityRepository dbCommunityRepository;
|
|
@Autowired
|
|
private DbProjectRepository dbProjectRepository;
|
|
@Autowired
|
|
private DbDatasourceRepository dbDatasourceRepository;
|
|
@Autowired
|
|
private DbOrganizationRepository dbOrganizationRepository;
|
|
@Autowired
|
|
private DbSupportOrgRepository dbSupportOrgRepository;
|
|
|
|
public List<CommunitySummary> listCommunities() throws CommunityException {
|
|
return dbCommunityRepository.findAll()
|
|
.stream()
|
|
.map(ConvertionUtils::toSummary)
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public void setCommunity(final String id, final CommunityWritableProperties details) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public List<CommunityProject> getCommunityProjects(final String id) throws CommunityException, ResourceNotFoundException {
|
|
return dbProjectRepository.findByCommunity(id)
|
|
.stream()
|
|
.map(ConvertionUtils::toCommunityProject)
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
public CommunityProject addCommunityProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException {
|
|
final DbProject p = ConvertionUtils.toDbProject(id, project);
|
|
dbProjectRepository.save(p);
|
|
return project;
|
|
}
|
|
|
|
public List<CommunityProject> addCommunityProjectList(final String id, final List<CommunityProject> projectList)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
|
|
final List<DbProject> list = projectList.stream()
|
|
.map(p -> ConvertionUtils.toDbProject(id, p))
|
|
.collect(Collectors.toList());
|
|
|
|
dbProjectRepository.saveAll(list);
|
|
|
|
return projectList;
|
|
}
|
|
|
|
public void removeCommunityProject(final String id, final Integer projectId) throws CommunityException, ResourceNotFoundException {
|
|
// dbProjectRepository.deleteById(new DbProjectPK(id, projectId));
|
|
}
|
|
|
|
public void removeCommunityProjectList(final String id, final List<Integer> projectIdList) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public List<CommunityContentprovider> getCommunityContentproviders(final String id) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityContentprovider addCommunityContentprovider(final String id, final CommunityContentprovider cp)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public void removeCommunityContentProvider(final String id, final Integer contentproviderId) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public List<CommunityContentprovider> addCommunityContentProvidersList(final String id, final List<CommunityContentprovider> contentprovidersList)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public void removeCommunityContentProviderList(final String id, final List<Integer> contentProviderIdList)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public void removeCommunityOrganization(final String id, final Integer organizationId) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public List<CommunityOrganization> getCommunityOrganizations(final String id) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails addCommunitySubjects(final String id, final List<String> subjects) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails removeCommunitySubjects(final String id, final List<String> subjects) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails addCommunityFOS(final String id, final List<String> foss) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails removeCommunityFOS(final String id, final List<String> foss) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails addCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails removeCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityDetails removeCommunityAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
}
|
|
|
|
public CommunityZenodoCommunity addCommunityZenodoCommunity(final String id, final CommunityZenodoCommunity zc)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityOpenAIRECommunities getOpenAIRECommunities(final String zenodoId) throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization)
|
|
throws CommunityException, ResourceNotFoundException {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
}
|