new_model_for_communities #15

Merged
michele.artini merged 81 commits from new_model_for_communities into master 2023-10-24 08:12:26 +02:00
1 changed files with 10 additions and 7 deletions
Showing only changes of commit 9e2638c9e4 - Show all commits

View File

@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.openaire.community.db.model.DbCommunity;
import eu.dnetlib.openaire.community.db.model.DbDatasource;
import eu.dnetlib.openaire.community.db.model.DbDatasourcePK;
import eu.dnetlib.openaire.community.db.model.DbOrganization;
import eu.dnetlib.openaire.community.db.model.DbProject;
import eu.dnetlib.openaire.community.db.model.DbProjectPK;
import eu.dnetlib.openaire.community.db.repository.DbCommunityRepository;
@ -48,7 +49,8 @@ public class CommunityService {
// 3) Gestire paginazione dei progetti
// 4) CommunityContentprovider sono le datasources?
// 5) Capire come gestire il campo Id (Integer) di CommunityContentprovider
// 5) Capire come gestire il campo Id (Integer) di CommunityOrganization
// 6) Capire come gestire il campo Id (Integer) di CommunityOrganization
// 7) Modificare le api per gestire le ZenodoCommunities (main + others)
@Autowired
private DbCommunityRepository dbCommunityRepository;
@ -162,6 +164,13 @@ public class CommunityService {
.collect(Collectors.toList());
}
public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization)
throws CommunityException, ResourceNotFoundException {
final DbOrganization o = ConvertionUtils.toDbOrganization(id, organization);
dbOrganizationRepository.save(o);
return organization;
}
@Transactional
public CommunityDetails addCommunitySubjects(final String id, final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return modifyElementToArrayField(id, subjects, c -> c.getSubjects(), (c, subs) -> c.setSubjects(subs), false);
@ -233,12 +242,6 @@ public class CommunityService {
return null;
}
public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
private CommunityDetails modifyElementToArrayField(final String id,
final List<String> values,
final Function<DbCommunity, String[]> getter,