[Trunk | Admin Tools]: Merging branch 'use-UoaAdminToolsLibrary' into trunk for revisions 58365:59468
This commit is contained in:
parent
5d10423c40
commit
f2ca4c4275
|
@ -1,41 +1,41 @@
|
|||
//version compatibility: 1.1.1-SNAPSHOT
|
||||
print("migrateCommunityIn_db script running...");
|
||||
|
||||
function migrate_community(communityPid, beta_db_name, prod_db_name) {
|
||||
function migrate_portal(portalPid, beta_db_name, prod_db_name) {
|
||||
beta_db = db.getSiblingDB(beta_db_name);
|
||||
prod_db = db.getSiblingDB(prod_db_name);
|
||||
|
||||
print("migrate_community: "+communityPid+" - both dbs are here");
|
||||
print("migrate_portal: "+portalPid+" - both dbs are here");
|
||||
|
||||
var beta_community = beta_db.community.findOne({ pid: communityPid } );
|
||||
var beta_portal = beta_db.portal.findOne({ pid: portalPid } );
|
||||
|
||||
if(!beta_community) {
|
||||
print("ERROR: Community with pid: "+communityPid+" does not exist in (beta) database: "+ beta_db_name);
|
||||
if(!beta_portal) {
|
||||
print("ERROR: Portal with pid: "+portalPid+" does not exist in (beta) database: "+ beta_db_name);
|
||||
return;
|
||||
}
|
||||
|
||||
var prod_communityOld = prod_db.community.findOne( { pid: communityPid } );
|
||||
var prod_communityOldId;
|
||||
if(prod_communityOld) {
|
||||
prod_communityOldId = prod_communityOld._id.str;
|
||||
var prod_portalOld = prod_db.portal.findOne( { pid: portalPid } );
|
||||
var prod_portalOldId;
|
||||
if(prod_portalOld) {
|
||||
prod_portalOldId = prod_portalOld._id.str;
|
||||
}
|
||||
|
||||
// delete community from production db
|
||||
prod_db.community.remove({"pid" : communityPid});
|
||||
print("Community with pid: "+communityPid+" is deleted (if existed) from production db: "+prod_db_name);
|
||||
// delete portal from production db
|
||||
prod_db.portal.remove({"pid" : portalPid});
|
||||
print("Portal with pid: "+portalPid+" is deleted (if existed) from production db: "+prod_db_name);
|
||||
|
||||
// migrate community pages
|
||||
//beta_community_pages = beta_db.community.findOne({ pid: communityPid } ).map( function(community) { return community.pages } );
|
||||
var beta_community_pages = beta_community.pages;
|
||||
var prod_community_pages = {}
|
||||
for (var beta_pageId in beta_community_pages) {
|
||||
// migrate portal pages
|
||||
//beta_portal_pages = beta_db.portal.findOne({ pid: portalPid } ).map( function(portal) { return portal.pages } );
|
||||
var beta_portal_pages = beta_portal.pages;
|
||||
var prod_portal_pages = {}
|
||||
for (var beta_pageId in beta_portal_pages) {
|
||||
var beta_pageObjectId = ObjectId(beta_pageId);
|
||||
//var prod_pageId = prod_db.community.find( { route: beta_db.page.find( { _id: beta_pageObjectId }).map( function(page) { return page.route; } ).toString() });
|
||||
//var prod_pageId = prod_db.portal.find( { route: beta_db.page.find( { _id: beta_pageObjectId }).map( function(page) { return page.route; } ).toString() });
|
||||
var beta_page = beta_db.page.findOne( { _id: beta_pageObjectId } );
|
||||
if(beta_page) {
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route } );
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route, portalType: beta_page.portalType } );
|
||||
if(prod_page) {
|
||||
prod_community_pages[prod_page._id.str] = beta_community_pages[beta_pageId];
|
||||
prod_portal_pages[prod_page._id.str] = beta_portal_pages[beta_pageId];
|
||||
} else {
|
||||
print("\nERROR: Page with route: "+beta_page.route+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
|
@ -43,18 +43,18 @@ function migrate_community(communityPid, beta_db_name, prod_db_name) {
|
|||
print("\nERROR: Page with id: "+beta_pageId+" does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
}
|
||||
print("Community pages are ready to be migrated");
|
||||
print("Portal pages are ready to be migrated");
|
||||
|
||||
// migrate community entities
|
||||
var beta_community_entities = beta_community.entities;
|
||||
var prod_community_entities = {}
|
||||
for (var beta_entityId in beta_community_entities) {
|
||||
// migrate portal entities
|
||||
var beta_portal_entities = beta_portal.entities;
|
||||
var prod_portal_entities = {}
|
||||
for (var beta_entityId in beta_portal_entities) {
|
||||
var beta_entityObjectId = ObjectId(beta_entityId);
|
||||
var beta_entity = beta_db.entity.findOne( { _id: beta_entityObjectId } );
|
||||
if(beta_entity) {
|
||||
var prod_entity = prod_db.entity.findOne( { pid: beta_entity.pid } );
|
||||
if(prod_entity) {
|
||||
prod_community_entities[prod_entity._id.str] = beta_community_entities[beta_entityId];
|
||||
prod_portal_entities[prod_entity._id.str] = beta_portal_entities[beta_entityId];
|
||||
} else {
|
||||
print("\nERROR: Entity with pid: "+beta_entity.pid+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
|
@ -63,82 +63,85 @@ function migrate_community(communityPid, beta_db_name, prod_db_name) {
|
|||
}
|
||||
}
|
||||
|
||||
print("Community entities are ready to be migrated");
|
||||
print("Portal entities are ready to be migrated");
|
||||
|
||||
prod_db.community.save({"name" : beta_community.name, "pid" : communityPid, "pages" : prod_community_pages, "entities" : prod_community_entities});
|
||||
prod_db.portal.save({
|
||||
"name" : beta_portal.name, "pid" : portalPid, "type": beta_portal.type,
|
||||
"pages" : prod_portal_pages, "entities" : prod_portal_entities
|
||||
});
|
||||
|
||||
print("Community is migrated");
|
||||
print("Portal is migrated");
|
||||
|
||||
// delete community statistics from production db
|
||||
prod_db.statistics.remove({"pid" : communityPid});
|
||||
print("Statistics for community with pid: "+communityPid+" are deleted (if existed) from production db: "+prod_db_name);
|
||||
// migrate statistics for community
|
||||
var beta_statistics = beta_db.statistics.findOne({ pid: communityPid } );
|
||||
// delete portal statistics from production db
|
||||
prod_db.statistics.remove({"pid" : portalPid});
|
||||
print("Statistics for portal with pid: "+portalPid+" are deleted (if existed) from production db: "+prod_db_name);
|
||||
// migrate statistics for portal
|
||||
var beta_statistics = beta_db.statistics.findOne({ pid: portalPid } );
|
||||
prod_db.statistics.save(beta_statistics);
|
||||
|
||||
print("Statistics for community were migrated");
|
||||
print("Statistics for portal were migrated");
|
||||
|
||||
// migrate subscribers of community
|
||||
var beta_communitySubscr = beta_db.communitySubscribers.findOne({ pid: communityPid } );
|
||||
if(beta_communitySubscr) {
|
||||
var beta_communitySubscribers = beta_communitySubscr.subscribers;
|
||||
var prod_communitySubscribers = [];
|
||||
var prod_communitySubscribersEmails = [];
|
||||
var prod_communitySubscr = prod_db.communitySubscribers.findOne({ "pid" : communityPid });
|
||||
if(prod_communitySubscr) {
|
||||
prod_communitySubscribers = prod_communitySubscr.subscribers;
|
||||
prod_communitySubscribersEmails = prod_communitySubscr.subscribers.map(function(subscriber){return subscriber.email});
|
||||
// migrate subscribers of portal
|
||||
var beta_portalSubscr = beta_db.portalSubscribers.findOne({ pid: portalPid } );
|
||||
if(beta_portalSubscr) {
|
||||
var beta_portalSubscribers = beta_portalSubscr.subscribers;
|
||||
var prod_portalSubscribers = [];
|
||||
var prod_portalSubscribersEmails = [];
|
||||
var prod_portalSubscr = prod_db.portalSubscribers.findOne({ "pid" : portalPid });
|
||||
if(prod_portalSubscr) {
|
||||
prod_portalSubscribers = prod_portalSubscr.subscribers;
|
||||
prod_portalSubscribersEmails = prod_portalSubscr.subscribers.map(function(subscriber){return subscriber.email});
|
||||
}
|
||||
|
||||
beta_communitySubscribers.forEach(function(beta_communitySubscriber) {
|
||||
var addInCommunity = true;
|
||||
beta_portalSubscribers.forEach(function(beta_portalSubscriber) {
|
||||
var addInPortal = true;
|
||||
|
||||
// if user exists in community subscribers already, do nothing
|
||||
if(prod_communitySubscribersEmails.indexOf(beta_communitySubscriber.email) >= 0) {
|
||||
addInCommunity = false;
|
||||
// if user exists in portal subscribers already, do nothing
|
||||
if(prod_portalSubscribersEmails.indexOf(beta_portalSubscriber.email) >= 0) {
|
||||
addInPortal = false;
|
||||
} else {
|
||||
var prod_subscriber = prod_db.subscriber.findOne({email: beta_communitySubscriber.email});
|
||||
var prod_subscriber = prod_db.subscriber.findOne({email: beta_portalSubscriber.email});
|
||||
|
||||
// if subscriber of beta does not exist in production, add him
|
||||
if(!prod_subscriber) {
|
||||
prod_subscriber = {email: beta_communitySubscriber.email};
|
||||
prod_subscriber = {email: beta_portalSubscriber.email};
|
||||
prod_db.subscriber.save(prod_subscriber);
|
||||
print("subscriber "+beta_communitySubscriber.email+" added in production DB");
|
||||
print("subscriber "+beta_portalSubscriber.email+" added in production DB");
|
||||
}
|
||||
}
|
||||
|
||||
if(addInCommunity) {
|
||||
var prod_communitySubscriber = prod_db.subscriber.findOne({email: beta_communitySubscriber.email});
|
||||
prod_communitySubscribers.push(prod_communitySubscriber);
|
||||
if(addInPortal) {
|
||||
var prod_portalSubscriber = prod_db.subscriber.findOne({email: beta_portalSubscriber.email});
|
||||
prod_portalSubscribers.push(prod_portalSubscriber);
|
||||
}
|
||||
})
|
||||
if(prod_communitySubscr) {
|
||||
prod_db.communitySubscribers.update({ "pid" : communityPid } , {$set: {subscribers : prod_communitySubscribers}});
|
||||
if(prod_portalSubscr) {
|
||||
prod_db.portalSubscribers.update({ "pid" : portalPid } , {$set: {subscribers : prod_portalSubscribers}});
|
||||
} else {
|
||||
prod_db.communitySubscribers.insert({ "pid" : communityPid, "subscribers" : prod_communitySubscribers });
|
||||
prod_db.portalSubscribers.insert({ "pid" : portalPid, "subscribers" : prod_portalSubscribers });
|
||||
}
|
||||
|
||||
print("subscribers of community were migrated");
|
||||
print("subscribers of portal were migrated");
|
||||
} else {
|
||||
print("\nERROR: Subscribers not migrated. No CommunitySubscribers for this community on beta db: "+beta_db_name+"\n");
|
||||
print("\nERROR: Subscribers not migrated. No PortalSubscribers for this portal on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
|
||||
// migrate divHelpContents of community
|
||||
var beta_communityId = beta_community._id.str;//beta_db.community.findOne( { pid: communityPid } )._id.str;
|
||||
var prod_communityId = prod_db.community.findOne( { pid: communityPid })._id.str;
|
||||
// migrate divHelpContents of portal
|
||||
var beta_portalId = beta_portal._id.str;//beta_db.portal.findOne( { pid: portalPid } )._id.str;
|
||||
var prod_portalId = prod_db.portal.findOne( { pid: portalPid })._id.str;
|
||||
|
||||
if(prod_communityOldId) {
|
||||
prod_db.divHelpContent.remove({"community": prod_communityOldId});
|
||||
if(prod_portalOldId) {
|
||||
prod_db.divHelpContent.remove({"portal": prod_portalOldId});
|
||||
}
|
||||
//var beta_divHelpContents =
|
||||
beta_db.divHelpContent.find( { community: beta_communityId } ).forEach(function(beta_divHelpContent){//.map( function(divHelpContent) { return divHelpContent; } );
|
||||
beta_db.divHelpContent.find( { portal: beta_portalId } ).forEach(function(beta_divHelpContent){//.map( function(divHelpContent) { return divHelpContent; } );
|
||||
//for (var beta_divHelpContent in beta_divHelpContents) {
|
||||
var beta_beta_divHelpContent_divId_ObjectId = ObjectId(beta_divHelpContent.divId);
|
||||
var beta_divId = beta_db.divId.findOne( { _id: beta_beta_divHelpContent_divId_ObjectId } );//.name;;
|
||||
if(beta_divId) {
|
||||
var prod_divId = prod_db.divId.findOne( { name: beta_divId.name } );//._id.str;
|
||||
var prod_divId = prod_db.divId.findOne( { name: beta_divId.name, portalType: beta_divId.portalType } );//._id.str;
|
||||
if(prod_divId) {
|
||||
prod_db.divHelpContent.save({ "divId" : prod_divId._id.str, "community" : prod_communityId, "content" : beta_divHelpContent.content, "isActive" : beta_divHelpContent.isActive });
|
||||
prod_db.divHelpContent.save({ "divId" : prod_divId._id.str, "portal" : prod_portalId, "content" : beta_divHelpContent.content, "isActive" : beta_divHelpContent.isActive });
|
||||
} else {
|
||||
print("\nERROR: DivId with name: "+beta_divId.name+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
|
@ -148,19 +151,19 @@ function migrate_community(communityPid, beta_db_name, prod_db_name) {
|
|||
//}
|
||||
});
|
||||
|
||||
print("divHelpContents of community were migrated");
|
||||
print("divHelpContents of portal were migrated");
|
||||
|
||||
// migrate pageHelpContents of community
|
||||
if(prod_communityOldId) {
|
||||
prod_db.pageHelpContent.remove({"community": prod_communityOldId});
|
||||
// migrate pageHelpContents of portal
|
||||
if(prod_portalOldId) {
|
||||
prod_db.pageHelpContent.remove({"portal": prod_portalOldId});
|
||||
}
|
||||
beta_db.pageHelpContent.find( { community: beta_communityId } ).forEach(function(beta_pageHelpContent){
|
||||
beta_db.pageHelpContent.find( { portal: beta_portalId } ).forEach(function(beta_pageHelpContent){
|
||||
var beta_beta_pageHelpContent_page_ObjectId = ObjectId(beta_pageHelpContent.page);
|
||||
var beta_page = beta_db.page.findOne( { _id: beta_beta_pageHelpContent_page_ObjectId } );//.route;
|
||||
if(beta_page) {
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route } );//._id.str;
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route, portalType: beta_page.portalType } );//._id.str;
|
||||
if(prod_page) {
|
||||
prod_db.pageHelpContent.save({ "page" : prod_page._id.str, "community" : prod_communityId, "content" : beta_pageHelpContent.content, "placement": beta_pageHelpContent.placement, "order": beta_pageHelpContent.order, "isActive": beta_pageHelpContent.isActive, "isPriorTo": beta_pageHelpContent.isPriorTo });
|
||||
prod_db.pageHelpContent.save({ "page" : prod_page._id.str, "portal" : prod_portalId, "content" : beta_pageHelpContent.content, "placement": beta_pageHelpContent.placement, "order": beta_pageHelpContent.order, "isActive": beta_pageHelpContent.isActive, "isPriorTo": beta_pageHelpContent.isPriorTo });
|
||||
} else {
|
||||
print("\nERROR: Page with route: "+beta_page.route+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
|
@ -169,47 +172,26 @@ function migrate_community(communityPid, beta_db_name, prod_db_name) {
|
|||
}
|
||||
});
|
||||
|
||||
print("pageHelpContents of community were migrated");
|
||||
print("pageHelpContents of portal were migrated");
|
||||
|
||||
// migrate htmlPageContents of community
|
||||
if(prod_communityOldId) {
|
||||
prod_db.htmlPageContent.remove({"community": prod_communityOldId});
|
||||
}
|
||||
beta_db.htmlPageContent.find( { community: beta_communityId } ).forEach(function(beta_htmlPageContent){
|
||||
var beta_beta_htmlPageContent_page_ObjectId = ObjectId(beta_htmlPageContent.page);
|
||||
var beta_htmlPage = beta_db.page.findOne( { _id: beta_beta_htmlPageContent_page_ObjectId } );//.route;
|
||||
if(beta_htmlPage) {
|
||||
var prod_htmlPage = prod_db.page.findOne( { route: beta_htmlPage.route } );//._id.str;
|
||||
if(prod_htmlPage) {
|
||||
prod_db.htmlPageContent.save({ "page" : prod_htmlPage._id.str, "community" : prod_communityId, "content" : beta_htmlPageContent.content });
|
||||
} else {
|
||||
print("\nERROR: Page with route: "+beta_htmlPage.route+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
} else {
|
||||
print("\nERROR: Page with id: "+beta_htmlPageContent.page+" (of htmlPageContent: "+beta_htmlPageContent._id.str+") does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
});
|
||||
|
||||
print("htmlPageContents of community were migrated");
|
||||
|
||||
// migrate notifications preferences of community
|
||||
var prod_notifications = prod_db.notifications.find({ communityPid: communityPid } );
|
||||
// migrate notifications preferences of portal
|
||||
var prod_notifications = prod_db.notifications.find({ portalPid: portalPid } );
|
||||
var prod_notifications_emails = [];
|
||||
if(prod_notifications) {
|
||||
prod_notifications_emails = prod_notifications.map(function(preference){return preference.managerEmail;})
|
||||
}
|
||||
|
||||
beta_db.notifications.find({ communityPid: communityPid } ).forEach(function(preference){
|
||||
beta_db.notifications.find({ portalPid: portalPid } ).forEach(function(preference){
|
||||
if(prod_notifications_emails.indexOf(preference.managerEmail) >= 0) {
|
||||
prod_db.notifications.update({ managerEmail: preference.managerEmail }, {$set: {notifyForNewManagers: preference.notifyForNewManagers, notifyForNewSubscribers: preference.notifyForNewSubscribers}})
|
||||
prod_db.notifications.update({ managerEmail: preference.managerEmail, portalPid: portalPid }, {$set: {notifyForNewManagers: preference.notifyForNewManagers, notifyForNewSubscribers: preference.notifyForNewSubscribers}})
|
||||
} else {
|
||||
prod_db.notifications.insert(preference);
|
||||
}
|
||||
});
|
||||
|
||||
print("Notification preferences of community were migrated");
|
||||
print("Notification preferences of portal were migrated");
|
||||
|
||||
}
|
||||
|
||||
migrate_community("egi", 'openaire_admin_copy', 'openaire_admin_prod');
|
||||
migrate_portal("egi", 'admin_beta_test_migration', 'admin_prod_test_migration');
|
||||
|
||||
|
|
16
pom.xml
16
pom.xml
|
@ -50,6 +50,11 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
|
@ -70,6 +75,17 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
<version>20030203.000550</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-admin-tools-library</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>eu.dnetlib</groupId>-->
|
||||
<!-- <artifactId>uoa-authorization-library</artifactId>-->
|
||||
<!-- <version>1.0.0-SNAPSHOT</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.GoogleConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MailConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
|
||||
//import eu.dnetlib.uoaauthorizationlibrary.configuration.AuthorizationConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.PropertySources;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = {"eu.dnetlib.uoaadmintools", "eu.dnetlib.uoaadmintoolslibrary"})
|
||||
@PropertySources({
|
||||
@PropertySource("classpath:admintools.properties"),
|
||||
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
|
||||
})
|
||||
@EnableConfigurationProperties({SecurityConfig.class, MailConfig.class, GoogleConfig.class, MongoConfig.class})
|
||||
@EnableConfigurationProperties({SecurityConfig.class, MongoConfig.class})
|
||||
//@Import(AuthorizationConfiguration.class)
|
||||
public class UoaAdminToolsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
|
|||
import java.util.Collections;
|
||||
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackages = {"eu.dnetlib.uoaadmintools.dao"})
|
||||
@EnableMongoRepositories(basePackages = {"eu.dnetlib.uoaadmintools.dao", "eu.dnetlib.uoaadmintoolslibrary.dao"})
|
||||
public class MongoConnection {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("admintool.google")
|
||||
public class GoogleConfig {
|
||||
|
||||
private String secret;
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("admintool.mail")
|
||||
public class MailConfig {
|
||||
|
||||
private String host;
|
||||
private String port;
|
||||
private String auth;
|
||||
private String from;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,543 +1,99 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import eu.dnetlib.uoaadmintools.services.LayoutService;
|
||||
import eu.dnetlib.uoaadmintools.services.StatisticsService;
|
||||
import eu.dnetlib.uoaadmintools.services.SubscriberService;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/community")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CommunityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
private LayoutService layoutService;
|
||||
|
||||
@Autowired
|
||||
private LayoutDAO layoutDAO;
|
||||
private StatisticsService statisticsService;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
private SubscriberService subscriberService;
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
private PortalService portalService;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentController pageHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private HtmlPageContentController htmlPageContentController;
|
||||
|
||||
@Autowired
|
||||
private DivIdController divIdController;
|
||||
|
||||
@Autowired
|
||||
private StatisticsDAO statisticsDAO;
|
||||
@Autowired
|
||||
private CommunitySubscribersDAO communitySubscribersDAO;
|
||||
|
||||
|
||||
@RequestMapping(value = "/community", method = RequestMethod.GET)
|
||||
public List<Community> getAllCommunities() {
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
|
||||
return communities;
|
||||
@RequestMapping(value = {"/"}, method = RequestMethod.GET)
|
||||
public List<Portal> getAllCommunities() {
|
||||
return portalService.getAllPortalsByType("community");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/communityFull", method = RequestMethod.GET)
|
||||
public List<CommunityResponse> getAllCommunitiesFull() {
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
List<CommunityResponse> communitiesResponse = new ArrayList<>();
|
||||
for(Community community : communities) {
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
log.debug("PAGES number="+pages.size());
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
log.debug("PAGES set");
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
log.debug("ENTITIES number="+entities.size());
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
Layout layout = layoutDAO.findById(community.getLayout());
|
||||
communityResponse.setLayout(layout);
|
||||
communitiesResponse.add(communityResponse);
|
||||
}
|
||||
return communitiesResponse;
|
||||
@RequestMapping(value = {"/full"}, method = RequestMethod.GET)
|
||||
public List<PortalResponse> getAllCommunitiesFull() {
|
||||
return portalService.getAllPortalsFullByType("community");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/communityFull/{pid}", method = RequestMethod.GET)
|
||||
public CommunityResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public PortalResponse updateCommunity(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.updatePortal(portal);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
String old_pid = portalResponse.getPid();
|
||||
String new_pid = portal.getPid();
|
||||
if(!old_pid.equals(new_pid)) {
|
||||
statisticsService.updatePid(old_pid, new_pid);
|
||||
subscriberService.updatePid(old_pid, new_pid);
|
||||
layoutService.updatePid(old_pid, new_pid);
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
Layout layout = layoutDAO.findById(community.getLayout());
|
||||
communityResponse.setLayout(layout);
|
||||
// communityResponse.setPages(this.getPagesForCommunityByType(community.getId(), null));
|
||||
// communityResponse.setEntities(this.getEntitiesForCommunity(community.getId()));
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
/*
|
||||
|
||||
@RequestMapping(value = "/communityFullByName/{name}", method = RequestMethod.GET)
|
||||
public CommunityResponse getCommunityFullByName(@PathVariable(value = "name") String name) {
|
||||
Community community = communityDAO.findByName(name);
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getId(), null, null);
|
||||
Iterator<CommunityPage> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
CommunityPage page = iteratorPages.next();
|
||||
if(!page.getIsEnabled()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setPages(pages);
|
||||
|
||||
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getId(), null);
|
||||
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
|
||||
while(iteratorEntities.hasNext()) {
|
||||
CommunityEntity entity = iteratorEntities.next();
|
||||
if(!entity.getIsEnabled()) {
|
||||
iteratorEntities.remove();
|
||||
}
|
||||
}
|
||||
communityResponse.setEntities(entities);
|
||||
|
||||
return communityResponse;
|
||||
}
|
||||
*/
|
||||
|
||||
@RequestMapping(value = "/community/update", method = RequestMethod.POST)
|
||||
public CommunityResponse updateCommunity(@RequestBody Community community) {
|
||||
Community com = communityDAO.findById(community.getId());
|
||||
|
||||
Statistics statistics = statisticsDAO.findByPid(com.getPid());
|
||||
statistics.setPid(community.getPid());
|
||||
statisticsDAO.save(statistics);
|
||||
|
||||
CommunitySubscribers communitySubscribers = communitySubscribersDAO.findByPid(com.getPid());
|
||||
communitySubscribers.setPid(community.getPid());
|
||||
communitySubscribersDAO.save(communitySubscribers);
|
||||
|
||||
com.setName(community.getName());
|
||||
com.setPid(community.getPid());
|
||||
// = this.getCommunityByCommunityResponse(communityResponse);
|
||||
communityDAO.save(com);
|
||||
CommunityResponse communityResponse = this.getCommunityFull(community.getPid());
|
||||
|
||||
return communityResponse;
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/save", method = RequestMethod.POST)
|
||||
public CommunityResponse insertCommunity(@RequestBody Community community) {
|
||||
//Community community = this.getCommunityByCommunityResponse(communityResponse);
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public PortalResponse insertCommunity(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.insertPortal(portal);
|
||||
|
||||
List<CommunityEntity> communityEntities = new ArrayList<>();
|
||||
List<CommunityPage> communityPages = new ArrayList<>();
|
||||
Map<String, Boolean> entities = new HashMap<>();
|
||||
Map<String, Boolean> pages = new HashMap<>();
|
||||
statisticsService.createPortalStatistics(portal.getPid());
|
||||
subscriberService.createPortalSubscribers(portal.getPid());
|
||||
|
||||
for(Entity entity : entityDAO.findAll()) {
|
||||
entities.put(entity.getId(), true);
|
||||
|
||||
CommunityEntity communityEntity = new CommunityEntity(entity);
|
||||
communityEntity.setIsEnabled(true);
|
||||
communityEntities.add(communityEntity);
|
||||
}
|
||||
|
||||
for(Page page : pageDAO.findAll()) {
|
||||
pages.put(page.getId(), true);
|
||||
|
||||
CommunityPage communityPage = new CommunityPage(page);
|
||||
if(page.getRoute().equals("/curators") || page.getRoute().equals("/organizations")) {
|
||||
communityPage.setIsEnabled(false);
|
||||
} else {
|
||||
communityPage.setIsEnabled(true);
|
||||
}
|
||||
|
||||
communityPages.add(communityPage);
|
||||
}
|
||||
|
||||
community.setEntities(entities);
|
||||
community.setPages(pages);
|
||||
Statistics statistics = new Statistics(community.getPid());
|
||||
statisticsDAO.save(statistics);
|
||||
CommunitySubscribers communitySubscribers = new CommunitySubscribers(community.getPid());
|
||||
communitySubscribersDAO.save(communitySubscribers);
|
||||
Community savedCommunity = communityDAO.save(community);
|
||||
CommunityResponse communityResponse = this.getCommunityFull(savedCommunity.getPid());
|
||||
|
||||
log.debug("pid of saved community: "+savedCommunity.getPid());
|
||||
|
||||
String id = savedCommunity.getId();
|
||||
|
||||
divHelpContentController.addDivHelpContentsInCommunity(savedCommunity.getPid(), id, null);
|
||||
pageHelpContentController.addPageHelpContentsInCommunity(savedCommunity.getPid(), id);
|
||||
/*
|
||||
Page page = null;
|
||||
page = pageDAO.findByRoute("/about" );
|
||||
if(page != null) {
|
||||
String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> About the community </div> <p> This is an introductory text. To be updated... </p> </div>";
|
||||
HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
|
||||
htmlPageContentController.updateHtmlPageContent(htmlPageContent);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
page = pageDAO.findByRoute("/organizations");
|
||||
if(page != null) {
|
||||
String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> Organizations related to the community </div> <p> This is an introductory text. Here follows the list of organizations... </p> <div class=\"uk-child-width-1-3@m uk-text-center uk-grid-match \" uk-grid > <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://upload.wikimedia.org/wikipedia/el/2/2b/Logo_uoa_blue.png\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.uoa.gr/\">University of Athens</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://pbs.twimg.com/profile_images/631127495933165569/ElbqhHK0_400x400.jpg\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.athena-innovation.gr/en\">Athena Research & Innovation center</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 1\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 1</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 2\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 2</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 3\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 3</a> </h3> </div> </div> </div></div>";
|
||||
HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
|
||||
htmlPageContentController.updateHtmlPageContent(htmlPageContent);
|
||||
}
|
||||
*/
|
||||
|
||||
return communityResponse;
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
private Community getCommunityByCommunityResponse(CommunityResponse communityResponse) {
|
||||
Community community = new Community();
|
||||
community.setId(communityResponse.getId());
|
||||
community.setName(communityResponse.getName());
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteCommunities(@RequestBody List<String> portals) {
|
||||
for (String id: portals) {
|
||||
String pid = portalService.deletePortal(id);
|
||||
|
||||
List<CommunityEntity> fullEntities = communityResponse.getEntities();
|
||||
Map<String, Boolean> entities = new HashMap<String, Boolean>();
|
||||
for(CommunityEntity entity : fullEntities) {
|
||||
entities.put(entity.getId(), true);
|
||||
}
|
||||
for(Entity entity : entityDAO.findAll()) {
|
||||
if(!entities.containsKey(entity.getId())) {
|
||||
entities.put(entity.getId(), false);
|
||||
}
|
||||
}
|
||||
community.setEntities(entities);
|
||||
|
||||
List<CommunityPage> fullPages = communityResponse.getPages();
|
||||
Map<String, Boolean> pages = new HashMap<String, Boolean>();
|
||||
for(CommunityPage page : fullPages) {
|
||||
pages.put(page.getId(), true);
|
||||
}
|
||||
for(Page page : pageDAO.findAll()) {
|
||||
if(!pages.containsKey(page.getId())) {
|
||||
pages.put(page.getId(), false);
|
||||
}
|
||||
}
|
||||
community.setPages(pages);
|
||||
Layout layout = communityResponse.getLayout();
|
||||
community.setLayout(layout.getId());
|
||||
|
||||
return community;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteCommunities(@RequestBody List<String> communities) throws Exception {
|
||||
for (String id: communities) {
|
||||
Community community = communityDAO.findById(id);
|
||||
String pid = community.getPid();
|
||||
|
||||
// delete div contents related to this community
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(pid, null, null, null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
// delete page contents related to this community
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(pid, null, null, null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
List<HtmlPageContent> htmlPageContents = htmlPageContentController.getHtmlPageContents(pid, null);
|
||||
for(HtmlPageContent htmlPageContent : htmlPageContents) {
|
||||
htmlPageContentController.deleteHtmlPageContent(htmlPageContent.getId());
|
||||
}
|
||||
|
||||
Statistics stats = statisticsDAO.findByPid(pid);
|
||||
if(stats != null) {
|
||||
statisticsDAO.delete(stats.getId());
|
||||
}
|
||||
|
||||
CommunitySubscribers communitySubscribers = communitySubscribersDAO.findByPid(pid);
|
||||
if(communitySubscribers != null) {
|
||||
communitySubscribersDAO.delete(communitySubscribers.getId());
|
||||
}
|
||||
|
||||
Layout layout = layoutDAO.findById(community.getLayout());
|
||||
if(layout != null) {
|
||||
layoutDAO.delete(layout.getId());
|
||||
}
|
||||
|
||||
communityDAO.delete(id);
|
||||
statisticsService.deleteByPid(pid);
|
||||
subscriberService.deletePortalSubscribers(pid);
|
||||
layoutService.deleteByPid(pid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/community", method = RequestMethod.DELETE)
|
||||
// public void deleteAllCommunities() {
|
||||
// communityDAO.deleteAll();
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/community", method = RequestMethod.POST)
|
||||
public Community insertOrUpdateCommunity(@RequestBody Community community) {
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}", method = RequestMethod.GET)
|
||||
public Community getCommunity(@PathVariable(value = "pid") String pid) {
|
||||
log.debug("PID: "+ pid);
|
||||
return communityDAO.findByPid(pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteCommunity(@PathVariable(value = "id") String id) {
|
||||
communityDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/pages", method = RequestMethod.GET)
|
||||
public List<CommunityPage> getPagesForCommunityByType(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(value="page_type", required=false) String page_type,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="div", required = false) String div) {
|
||||
List<CommunityPage> return_pages = new ArrayList<CommunityPage>();
|
||||
Map<String, Boolean> pages = communityDAO.findByPid(pid).getPages();
|
||||
|
||||
if(pages != null) {
|
||||
for (Map.Entry<String, Boolean> page : pages.entrySet()) {
|
||||
if(div != null && div.equals("true")) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
List<DivId> divIds = divIdDAO.findByPagesContaining(page.getKey());
|
||||
Iterator<DivId> divIdIterator = divIds.iterator();
|
||||
|
||||
while (divIdIterator.hasNext()) {
|
||||
DivId divId = divIdIterator.next();
|
||||
if((pid.equals("openaire") && !divId.getOpenaire()) ||
|
||||
(pid.equals("connect") && !divId.getConnect()) ||
|
||||
(!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities())) {
|
||||
divIdIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(divIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Page p = pageDAO.findById(page.getKey());
|
||||
|
||||
if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
|
||||
if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
|
||||
|| p.getRoute().equals(page_route)) {
|
||||
CommunityPage communityPage = new CommunityPage(p);
|
||||
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (String entity : p.getEntities()) {
|
||||
entities.add(entityDAO.findById(entity));
|
||||
}
|
||||
communityPage.setEntities(entities);
|
||||
communityPage.setIsEnabled(page.getValue());
|
||||
|
||||
return_pages.add(communityPage);
|
||||
|
||||
if (page_route != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return_pages.sort(Comparator.comparing(CommunityPage::getName));
|
||||
return return_pages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}/page", method = RequestMethod.POST)
|
||||
public Community insertOrUpdatePage(@PathVariable(value = "id") String id, @RequestBody CommunityPage page) {
|
||||
Community community = communityDAO.findById(id);
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
String name = page.getName();
|
||||
boolean isEnabled = page.getIsEnabled();
|
||||
|
||||
pages.put(name, isEnabled);
|
||||
community.setPages(pages);
|
||||
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "community/{pid}/page/toggle", method = RequestMethod.POST)
|
||||
public Community togglePage(@PathVariable(value = "pid") String pid, @RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
for (String pageId: pageIds) {
|
||||
log.debug("Toggle community page: " + pageId + " of community: " + pid + " to " + status);
|
||||
pages.put(pageId, Boolean.parseBoolean(status));
|
||||
}
|
||||
|
||||
community.setPages(pages);
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "community/{pid}/entity/toggle", method = RequestMethod.POST)
|
||||
public Community toggleEntity(@PathVariable(value = "pid") String pid, @RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
Map<String, Boolean> entities = community.getEntities();
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
|
||||
for (String entityId: entityIds) {
|
||||
log.debug("Toggle community entity: " + entityId + " of community: " + pid + " to " + status);
|
||||
|
||||
entities.put(entityId, Boolean.parseBoolean(status));
|
||||
|
||||
if(pages != null) {
|
||||
for (Map.Entry<String, Boolean> pageEntry : pages.entrySet()) {
|
||||
Page page = pageDAO.findById(pageEntry.getKey());
|
||||
if (page.getEntities().contains(entityId) && page.getType().equals("search")) {
|
||||
pages.put(pageEntry.getKey(), Boolean.parseBoolean(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
community.setEntities(entities);
|
||||
return communityDAO.save(community);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/entities", method = RequestMethod.GET)
|
||||
public List<CommunityEntity> getEntitiesForCommunity(@PathVariable(value = "pid") String pid, @RequestParam(value="entity", required=false) String entity) {
|
||||
List<CommunityEntity> return_entities = new ArrayList<CommunityEntity>();
|
||||
Map<String, Boolean> entities = communityDAO.findByPid(pid).getEntities();
|
||||
|
||||
log.debug("/community/"+pid+"/entities -- entity: "+entity);
|
||||
if (entity != null) {
|
||||
String entityId = entityDAO.findByPid(entity).getId();
|
||||
CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(entityId));
|
||||
communityEntity.setIsEnabled(entities.get(entityId));
|
||||
return_entities.add(communityEntity);
|
||||
} else {
|
||||
if(entities != null) {
|
||||
for (Map.Entry<String, Boolean> _entity : entities.entrySet()) {
|
||||
CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(_entity.getKey()));
|
||||
communityEntity.setIsEnabled(_entity.getValue());
|
||||
return_entities.add(communityEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return return_entities;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/{pid}/layout", method = RequestMethod.GET)
|
||||
public Layout getLayoutForCommunity(@PathVariable(value = "pid") String pid) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
if(community.getLayout() != null) {
|
||||
return layoutDAO.findById(community.getLayout());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return layoutService.findByPid(pid);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.POST)
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/layout", method = RequestMethod.POST)
|
||||
public Layout updateLayoutForCommunity(@PathVariable(value = "pid") String pid, @RequestBody Layout layout) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
if(community.getLayout() != null) {
|
||||
layout.setId(community.getLayout());
|
||||
layout = layoutDAO.save(layout);
|
||||
} else {
|
||||
layout = layoutDAO.save(layout);
|
||||
community.setLayout(layout.getId());
|
||||
communityDAO.save(community);
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/pagehelpcontent", method = RequestMethod.GET)
|
||||
public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
|
||||
|
||||
List<PageHelpContentResponse> pageHelpContents = null;
|
||||
pageHelpContents = pageHelpContentController.getPageHelpContents(pid, page, null, active, null);
|
||||
|
||||
pageHelpContentResponses.put("top", new ArrayList<>());
|
||||
pageHelpContentResponses.put("bottom", new ArrayList<>());
|
||||
pageHelpContentResponses.put("left", new ArrayList<>());
|
||||
pageHelpContentResponses.put("right", new ArrayList<>());
|
||||
|
||||
for (PageHelpContentResponse pageHelpContentResponse : pageHelpContents) {
|
||||
pageHelpContentResponses.get(pageHelpContentResponse.getPlacement()).add(pageHelpContentResponse);
|
||||
}
|
||||
|
||||
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/divhelpcontent", method = RequestMethod.GET)
|
||||
public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable(value = "pid") String pid,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String active) {
|
||||
Map<String, List<DivHelpContentResponse>> divHelpContentResponses = new HashMap<>();
|
||||
|
||||
List<DivHelpContentResponse> divHelpContents = null;
|
||||
divHelpContents = divHelpContentController.getDivHelpContents(pid, page, null, active);
|
||||
|
||||
for (DivHelpContentResponse divHelpContentResponse : divHelpContents) {
|
||||
if(!divHelpContentResponses.containsKey(divHelpContentResponse.getDivId())) {
|
||||
divHelpContentResponses.put(divHelpContentResponse.getDivId().getName(), new ArrayList<>());
|
||||
}
|
||||
divHelpContentResponses.get(divHelpContentResponse.getDivId().getName()).add(divHelpContentResponse);
|
||||
}
|
||||
|
||||
|
||||
return divHelpContentResponses;
|
||||
return layoutService.save(layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import eu.dnetlib.uoaadmintools.services.LayoutService;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/connect")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ConnectController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private LayoutService layoutService;
|
||||
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public PortalResponse updateCommunity(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.updatePortal(portal);
|
||||
|
||||
String old_pid = portalResponse.getPid();
|
||||
String new_pid = portal.getPid();
|
||||
if(!old_pid.equals(new_pid)) {
|
||||
layoutService.updatePid(old_pid, new_pid);
|
||||
}
|
||||
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public PortalResponse insertCommunity(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.insertPortal(portal);
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteCommunities(@RequestBody List<String> portals) {
|
||||
for (String id: portals) {
|
||||
String pid = portalService.deletePortal(id);
|
||||
layoutService.deleteByPid(pid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{pid}/layout", method = RequestMethod.GET)
|
||||
public Layout getLayoutForCommunity(@PathVariable(value = "pid") String pid) {
|
||||
return layoutService.findByPid(pid);
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(" +
|
||||
// "@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN, " +
|
||||
// "@AuthorizationService.curator(#portalType), @AuthorizationService.manager(#portalType, #pid))")
|
||||
@RequestMapping(value = "/{pid}/layout", method = RequestMethod.POST)
|
||||
public Layout updateLayoutForCommunity(@PathVariable(value = "pid") String pid, @RequestBody Layout layout) {
|
||||
return layoutService.save(layout);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CuratorDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
import eu.dnetlib.uoaadmintools.entities.CuratorResponse;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.CuratorResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.DivHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class DivHelpContentController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
DivIdController divIdController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentDAO divHelpContentDAO;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET)
|
||||
public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(required = false) String community,
|
||||
@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String div,
|
||||
@RequestParam(required = false) String active) {
|
||||
|
||||
Community _community = communityDAO.findByPid(community);
|
||||
String communityId = null;
|
||||
if(_community != null) {
|
||||
communityId = _community.getId();
|
||||
}
|
||||
|
||||
DivId divId = divIdDAO.findByName(div);
|
||||
String divIdId = null;
|
||||
if(divId != null) {
|
||||
divIdId = divId.getId();
|
||||
}
|
||||
|
||||
List<DivHelpContentResponse> divHelpContentResponses = new ArrayList<>();
|
||||
|
||||
List<DivHelpContent> divHelpContents = null;
|
||||
if(community != null && div != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndDivIdAndIsActive(communityId, divIdId, Boolean.parseBoolean(active));
|
||||
} else if(community != null && div != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndDivId(communityId, divIdId);
|
||||
} else if(community != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunityAndIsActive(communityId, Boolean.parseBoolean(active));
|
||||
} else if(div != null && active != null) {
|
||||
divHelpContents = divHelpContentDAO.findByDivIdAndIsActive(divIdId, Boolean.parseBoolean(active));
|
||||
} else if(community != null) {
|
||||
divHelpContents = divHelpContentDAO.findByCommunity(communityId);
|
||||
} else if(div != null) {
|
||||
divHelpContents = divHelpContentDAO.findByDivId(divIdId);
|
||||
} else if(active != null){
|
||||
divHelpContents = divHelpContentDAO.findByIsActive(Boolean.parseBoolean(active));
|
||||
} else {
|
||||
divHelpContents = divHelpContentDAO.findAll();
|
||||
}
|
||||
|
||||
for (DivHelpContent divHelpContent : divHelpContents) {
|
||||
DivIdResponse divIdResponse = null;
|
||||
if(div == null) {
|
||||
divId = divIdDAO.findById(divHelpContent.getDivId());
|
||||
}
|
||||
divIdResponse = divIdController.divIdResponseFromDivId(divId);
|
||||
|
||||
if(community == null) {
|
||||
_community = communityDAO.findById(divHelpContent.getCommunity());
|
||||
}
|
||||
|
||||
for(Page p : divIdResponse.getPages()) {
|
||||
if (page == null || p.getRoute().equals(page)) {
|
||||
DivHelpContentResponse divHelpContentResponse = new DivHelpContentResponse(divHelpContent);
|
||||
divHelpContentResponse.setDivId(divIdResponse);
|
||||
divHelpContentResponse.setCommunity(_community);
|
||||
divHelpContentResponses.add(divHelpContentResponse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return divHelpContentResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.GET)
|
||||
public DivHelpContent getDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
return divHelpContentDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.POST)
|
||||
public DivHelpContent insertOrUpdateDivHelpContent(@RequestBody DivHelpContent divHelpContent) {
|
||||
return divHelpContentDAO.save(divHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivHelpContent(@PathVariable(value = "id") String id) {
|
||||
divHelpContentDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivHelpContents(@RequestBody List<String> divHelpContents) throws Exception {
|
||||
for (String id: divHelpContents) {
|
||||
divHelpContentDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divhelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> toggleDivHelpContent(@RequestBody List<String> divHelpContents, @RequestParam String status) throws Exception {
|
||||
for (String id: divHelpContents) {
|
||||
log.debug("Id of divHelpContent: "+id);
|
||||
DivHelpContent divHelpContent = divHelpContentDAO.findById(id);
|
||||
divHelpContent.setIsActive(Boolean.parseBoolean(status));
|
||||
divHelpContentDAO.save(divHelpContent);
|
||||
}
|
||||
return divHelpContents;
|
||||
}
|
||||
|
||||
public void addDivHelpContentsInCommunity(String pid, String communityId, String divIdName) {
|
||||
//String organizations_class_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
|
||||
String link_context_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Select a research community and/or a category and search for a community concept, or browse to the community tree through the categories</div> </div>";
|
||||
String link_project_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Search for projects using project name or grant id. Limit results filtering by funder.</div> </div>";
|
||||
String link_result_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span></div> Search for research results in OpenAIRE information space, Datacite, CrossRef or ORCID. <div class=\"uk-text-small\">Use keywords, DOI (more than one - space separated), author's ORCID</div> </div>";
|
||||
String link_result_bulk_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef or Datacite and will be added to your selected research results.</div> <div class=\"uk-margin-top uk-text-small\"><span class=\"uk-text-bold\">CSV format:</span> <ul class=\"uk-list\"> <li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li> <li>The value "DOI" is required</li> <li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li> <li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li> <li>In case access mode is not available default value is "OPEN".</li> </ul> </div> </div>";
|
||||
String link_metadata_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\"> </span> Information:</span> Manage access mode & type of selected research results. For OpenAIRE this functionality isn't available.</div> </div>";
|
||||
|
||||
List<DivId> divIds = divIdController.getDivIds(null, divIdName, null);
|
||||
|
||||
for( DivId div : divIds ) {
|
||||
if (div != null && (
|
||||
(div.getOpenaire() && pid.equals("openaire")) ||
|
||||
(div.getConnect() && pid.equals("connect")) ||
|
||||
(div.getCommunities() && !pid.equals("openaire") && !pid.equals("connect"))
|
||||
)) {
|
||||
/*
|
||||
if (div.getName().equals("organizations")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, organizations_class_content, false));
|
||||
} else
|
||||
*/
|
||||
if (div.getName().equals("link-context-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_context_form_content, false));
|
||||
} else if (div.getName().equals("link-project-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_project_form_content, false));
|
||||
} else if (div.getName().equals("link-result-form")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_result_form_content, false));
|
||||
} else if (div.getName().equals("link-result-bulk")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_result_bulk_content, false));
|
||||
} else if (div.getName().equals("link-metadata")) {
|
||||
this.insertOrUpdateDivHelpContent(new DivHelpContent(div.getId(), communityId, link_metadata_content, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.MongoDBCommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class DivIdController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityController communityController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
DivIdController() {}
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.GET)
|
||||
public List<DivId> getDivIds(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value = "communityId", required = false) String pid) {
|
||||
List<DivId> divIds = null;
|
||||
|
||||
if(page != null && name != null) {
|
||||
DivId divId = divIdDAO.findByPagesContainingAndName(page, name);
|
||||
if(divId != null) {
|
||||
divIds = new ArrayList<>();
|
||||
divIds.add(divId);
|
||||
}
|
||||
} else if(page != null) {
|
||||
divIds = divIdDAO.findByPagesContaining(page);
|
||||
} else if(name != null) {
|
||||
DivId divId = divIdDAO.findByName(name);
|
||||
if(divId != null) {
|
||||
divIds = new ArrayList<>();
|
||||
divIds.add(divId);
|
||||
}
|
||||
} else {
|
||||
divIds = divIdDAO.findAll();
|
||||
}
|
||||
|
||||
if(pid != null) {
|
||||
Iterator<DivId> iteratorDivIds = divIds.iterator();
|
||||
while(iteratorDivIds.hasNext()) {
|
||||
DivId divId = iteratorDivIds.next();
|
||||
if (pid.equals("openaire") && !divId.getOpenaire()) {
|
||||
iteratorDivIds.remove();
|
||||
} else if (pid.equals("connect") && !divId.getConnect()) {
|
||||
iteratorDivIds.remove();
|
||||
} else if(!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities()){
|
||||
iteratorDivIds.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return divIds;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divFull", method = RequestMethod.GET)
|
||||
public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String page,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(value="communityId", required = false) String pid) {
|
||||
|
||||
List<DivId> divIds = this.getDivIds(page, name, pid);
|
||||
|
||||
List<DivIdResponse> divIdResponses = new ArrayList<>();
|
||||
for(DivId divId : divIds) {
|
||||
DivIdResponse divIdResponse = new DivIdResponse(divId);
|
||||
List<Page> pages = new ArrayList<>();
|
||||
for(String pageId : divId.getPages()) {
|
||||
pages.add(pageDAO.findById(pageId));
|
||||
}
|
||||
divIdResponse.setPages(pages);
|
||||
|
||||
divIdResponses.add(divIdResponse);
|
||||
}
|
||||
|
||||
return divIdResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.GET)
|
||||
public DivId getDivId(@PathVariable(value = "id") String id) {
|
||||
return divIdDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/divFull/{id}", method = RequestMethod.GET)
|
||||
public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) {
|
||||
DivId divId = divIdDAO.findById(id);
|
||||
return divIdResponseFromDivId(divId);
|
||||
}
|
||||
|
||||
public DivIdResponse divIdResponseFromDivId(DivId divId) {
|
||||
DivIdResponse divIdResponse = new DivIdResponse(divId);
|
||||
List<Page> pages = new ArrayList<>();
|
||||
for(String pageId : divId.getPages()) {
|
||||
pages.add(pageDAO.findById(pageId));
|
||||
}
|
||||
divIdResponse.setPages(pages);
|
||||
return divIdResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div", method = RequestMethod.DELETE)
|
||||
public void deleteAllDivIds() {
|
||||
divIdDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/save", method = RequestMethod.POST)
|
||||
public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
DivId divId = this.getDivIdByDivIdResponse(divIdResponse);
|
||||
|
||||
DivId savedDivId = divIdDAO.save(divId);
|
||||
divIdResponse.setId(savedDivId.getId());
|
||||
|
||||
return this.getDivIdFull(divId.getId());
|
||||
}
|
||||
|
||||
private DivId getDivIdByDivIdResponse(DivIdResponse divIdResponse) {
|
||||
DivId divId = new DivId();
|
||||
divId.setId(divIdResponse.getId());
|
||||
divId.setName(divIdResponse.getName());
|
||||
divId.setOpenaire(divIdResponse.getOpenaire());
|
||||
divId.setConnect(divIdResponse.getConnect());
|
||||
divId.setCommunities(divIdResponse.getCommunities());
|
||||
|
||||
List<Page> fullPages = divIdResponse.getPages();
|
||||
List<String> pages = new ArrayList<String>();
|
||||
for(Page page : fullPages) {
|
||||
pages.add(page.getId());
|
||||
}
|
||||
divId.setPages(pages);
|
||||
|
||||
return divId;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/update", method = RequestMethod.POST)
|
||||
public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) {
|
||||
/*
|
||||
DivId divId = divIdDAO.findById(_divId.getId());
|
||||
divId.setName(_divId.getName());
|
||||
divId.setPages(_divId.getPages());
|
||||
divIdDAO.save(divId);
|
||||
return this.getDivIdFull(divId.getId());
|
||||
*/
|
||||
DivId divIdOld = divIdDAO.findById(divIdResponse.getId());
|
||||
DivId divId = this.getDivIdByDivIdResponse(divIdResponse);
|
||||
divIdDAO.save(divId);
|
||||
|
||||
boolean openaireEnabled = divId.getOpenaire();
|
||||
boolean connectEnabled = divId.getConnect();
|
||||
|
||||
if(divId.getCommunities() && !divIdOld.getCommunities()) {
|
||||
List<Community> communities = communityController.getAllCommunities();
|
||||
for( Community community : communities ) {
|
||||
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) {
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(openaireEnabled && !divIdOld.getOpenaire()) {
|
||||
Community community = communityController.getCommunity("openaire");
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
|
||||
if(connectEnabled && !divIdOld.getConnect()) {
|
||||
Community community = communityController.getCommunity("connect");
|
||||
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName());
|
||||
}
|
||||
|
||||
if(!divId.getCommunities()) {
|
||||
List<Community> communities = communityController.getAllCommunities();
|
||||
for( Community community : communities ) {
|
||||
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) {
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(community.getPid(), null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!openaireEnabled) {
|
||||
Community community = communityController.getCommunity("openaire");
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("openaire", null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!connectEnabled) {
|
||||
Community community = communityController.getCommunity("connect");
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("connect", null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return divIdResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteDivIds(@RequestBody List<String> divIds) throws Exception {
|
||||
for (String id: divIds) {
|
||||
DivId divId = divIdDAO.findById(id);
|
||||
|
||||
// delete div contents related to this divId
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, null, divId.getName(), null);
|
||||
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
divIdDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteDivId(@PathVariable(value = "id") String id) {
|
||||
divIdDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/div/pages", method = RequestMethod.GET)
|
||||
public Set<String> getDivIdsPages(@RequestParam(value="communityId", required = false) String pid) {
|
||||
List<DivId> divIds = null;
|
||||
Set<String> hasCommunityPageDivIds = new HashSet<>();
|
||||
|
||||
if(pid != null) {
|
||||
if(pid.equals("openaire")) {
|
||||
divIds = divIdDAO.findByOpenaire(true);
|
||||
} else if(pid.equals("connect")) {
|
||||
divIds = divIdDAO.findByConnect(true);
|
||||
} else {
|
||||
divIds = divIdDAO.findByCommunities(true);
|
||||
}
|
||||
} else {
|
||||
divIds = divIdDAO.findAll();
|
||||
}
|
||||
|
||||
for(DivId divId : divIds) {
|
||||
for(String pageId : divId.getPages()) {
|
||||
hasCommunityPageDivIds.add(pageId);
|
||||
}
|
||||
}
|
||||
return hasCommunityPageDivIds;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
|
||||
import eu.dnetlib.uoaadmintools.emailSender.EmailSender;
|
||||
import eu.dnetlib.uoaadmintools.entities.EmailRecaptcha;
|
||||
import eu.dnetlib.uoaadmintools.entities.Email;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintools.handlers.InvalidReCaptchaException;
|
||||
import eu.dnetlib.uoaadmintools.recaptcha.VerifyRecaptcha;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.emailSender.EmailSender;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.email.Email;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.email.EmailRecaptcha;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.recaptcha.VerifyRecaptcha;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -25,13 +25,15 @@ public class EmailController {
|
|||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
private PortalDAO portalDAO;
|
||||
@Autowired
|
||||
private VerifyRecaptcha verifyRecaptcha;
|
||||
|
||||
@RequestMapping(value = "/contact", method = RequestMethod.POST)
|
||||
public Boolean contact(@RequestBody EmailRecaptcha form) throws InvalidReCaptchaException {
|
||||
verifyRecaptcha.processResponse(form.getRecaptcha());
|
||||
if(form.getRecaptcha() != null) {
|
||||
verifyRecaptcha.processResponse(form.getRecaptcha());
|
||||
}
|
||||
Email email = form.getEmail();
|
||||
ArrayList<String> sendTo = new ArrayList<>(email.getRecipients());
|
||||
return emailSender.send(sendTo, email.getSubject(), email.getBody(), false);
|
||||
|
@ -67,11 +69,11 @@ public class EmailController {
|
|||
@RequestMapping(value = "/notifyForNewManagers/{pid}", method = RequestMethod.POST)
|
||||
public Boolean notifyNewManagers(@PathVariable(value = "pid") String pid,@RequestBody Email email ) throws Exception {
|
||||
List<String> notifyrecipients = new ArrayList<String>();
|
||||
if(communityDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Community not found");
|
||||
if(portalDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Portal not found");
|
||||
}
|
||||
for(String user:email.getRecipients()){
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndPortalPid(user,pid);
|
||||
|
||||
if(userNotifications == null || userNotifications.getNotifyForNewManagers()){
|
||||
notifyrecipients.add(user);
|
||||
|
@ -88,11 +90,11 @@ public class EmailController {
|
|||
@RequestMapping(value = "/notifyForNewSubscribers/{pid}", method = RequestMethod.POST)
|
||||
public Boolean notifyNewSubscribers(@PathVariable(value = "pid") String pid,@RequestBody Email email ) throws Exception {
|
||||
List<String> notifyrecipients = new ArrayList<String>();
|
||||
if(communityDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Community not found");
|
||||
if(portalDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Portal not found");
|
||||
}
|
||||
for(String user:email.getRecipients()){
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndPortalPid(user,pid);
|
||||
|
||||
if(userNotifications == null || userNotifications.getNotifyForNewSubscribers()){
|
||||
notifyrecipients.add(user);
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.CommunityEntity;
|
||||
import eu.dnetlib.uoaadmintools.entities.Entity;
|
||||
import eu.dnetlib.uoaadmintools.dao.EntityDAO;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class EntityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.GET)
|
||||
public List<Entity> getAllEntities() {
|
||||
return entityDAO.findAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.DELETE)
|
||||
public void deleteAllEntities() {
|
||||
entityDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.POST)
|
||||
public Entity insertOrUpdateEntity(@RequestBody Entity entity) {
|
||||
return entityDAO.save(entity);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.GET)
|
||||
public Entity getEntity(@PathVariable(value = "id") String id) {
|
||||
return entityDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteEntity(@PathVariable(value = "id") String id) {
|
||||
entityDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/update", method = RequestMethod.POST)
|
||||
public CommunityEntity updateEntity(@RequestBody CommunityEntity communityEntity) {
|
||||
Entity entity = this.getEntityByCommunityEntity(communityEntity);
|
||||
entityDAO.save(entity);
|
||||
|
||||
return communityEntity;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/save", method = RequestMethod.POST)
|
||||
public CommunityEntity insertEntity(@RequestBody Entity entity) {
|
||||
//Entity entity = this.getEntityByCommunityEntity(communityEntity);
|
||||
Entity savedEntity = entityDAO.save(entity);
|
||||
CommunityEntity communityEntity = new CommunityEntity(savedEntity);
|
||||
|
||||
// add entity in communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> entities = community.getEntities();
|
||||
entities.put(entity.getId(), true);
|
||||
community.setEntities(entities);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
return communityEntity;
|
||||
}
|
||||
|
||||
private Entity getEntityByCommunityEntity(CommunityEntity communityEntity) {
|
||||
Entity entity = new Entity();
|
||||
entity.setId(communityEntity.getId());
|
||||
entity.setPid(communityEntity.getPid());
|
||||
entity.setName(communityEntity.getName());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteEntities(@RequestBody List<String> entities) throws Exception {
|
||||
for (String id: entities) {
|
||||
entityDAO.delete(id);
|
||||
|
||||
// delete entity from communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> communityEntities = community.getEntities();
|
||||
communityEntities.remove(id);
|
||||
community.setEntities(communityEntities);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
// delete entity from pages
|
||||
List<Page> pages = pageDAO.findAll();
|
||||
for( Page page : pages ) {
|
||||
List<String> pageEntities = page.getEntities();
|
||||
int index = 0;
|
||||
for(String pageEntity : pageEntities) {
|
||||
if(pageEntity == id) {
|
||||
pageEntities.remove(index);
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
page.setEntities(pageEntities);
|
||||
pageDAO.save(page);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/explore")
|
||||
@CrossOrigin(origins = "*")
|
||||
//@PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
public class ExploreController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public PortalResponse updateExplore(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.updatePortal(portal);
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public PortalResponse insertExplore(@RequestBody Portal portal) {
|
||||
PortalResponse portalResponse = portalService.insertPortal(portal);
|
||||
return portalResponse;
|
||||
}
|
||||
|
||||
// cannot handle MismatchingContent
|
||||
// @PreAuthorize("hasAnyAuthority(@AuthorizationService.SUPER_ADMIN, @AuthorizationService.PORTAL_ADMIN)")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteExplore(@RequestBody List<String> portals) throws Exception {
|
||||
for (String id : portals) {
|
||||
portalService.deletePortal(id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.HtmlPageContentDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.HtmlPageContent;
|
||||
import eu.dnetlib.uoaadmintools.entities.HtmlPageContentResponse;
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class HtmlPageContentController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private HtmlPageContentDAO htmlPageContentDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/htmlpagecontent", method = RequestMethod.GET)
|
||||
public List<HtmlPageContent> getHtmlPageContents(@RequestParam(required = false) String community,
|
||||
@RequestParam(required = false) String page) {
|
||||
List<HtmlPageContent> htmlPageContents = null;
|
||||
|
||||
Community _community = null;
|
||||
String communityId = null;
|
||||
if(community != null) {
|
||||
_community = communityDAO.findByPid(community);
|
||||
if(_community != null) {
|
||||
communityId = _community.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if(community != null) {
|
||||
htmlPageContents = htmlPageContentDAO.findByCommunity(communityId);
|
||||
} else {
|
||||
htmlPageContents = htmlPageContentDAO.findAll();
|
||||
}
|
||||
|
||||
Iterator<HtmlPageContent> iterator = htmlPageContents.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
HtmlPageContent htmlPageContent = iterator.next();
|
||||
|
||||
Page _page = pageDAO.findById(htmlPageContent.getPage());
|
||||
if (page != null && !page.equals(_page.getRoute())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return htmlPageContents;
|
||||
}
|
||||
|
||||
/*
|
||||
@RequestMapping(value = "/htmlpagecontent", method = RequestMethod.DELETE)
|
||||
public void deleteAllHtmlPageContents() {
|
||||
htmlPageContentDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/htmlpagecontent/save", method = RequestMethod.POST)
|
||||
public HtmlPageContent insertHtmlPageContent(@RequestBody HtmlPageContent htmlPageContent) {
|
||||
String communityId = communityDAO.findByPid(htmlPageContent.getCommunity()).getId();
|
||||
htmlPageContent.setCommunity(communityId);
|
||||
return htmlPageContentDAO.save(htmlPageContent);
|
||||
}*/
|
||||
|
||||
@RequestMapping(value = "/htmlpagecontent/update", method = RequestMethod.POST)
|
||||
public HtmlPageContent updateHtmlPageContent(@RequestBody HtmlPageContent htmlPageContent) {
|
||||
return htmlPageContentDAO.save(htmlPageContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/htmlpagecontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteHtmlPageContent(@PathVariable(value = "id") String id) {
|
||||
htmlPageContentDAO.delete(id);
|
||||
}
|
||||
/*
|
||||
@RequestMapping(value = "/htmlpagecontent/{id}", method = RequestMethod.GET)
|
||||
public HtmlPageContent getHtmlPageContent(@PathVariable(value = "id") String id) {
|
||||
return htmlPageContentDAO.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/htmlpagecontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteHtmlPageContents(@RequestBody List<String> htmlPageContents) throws Exception {
|
||||
for (String id: htmlPageContents) {
|
||||
htmlPageContentDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -21,14 +21,14 @@ public class NotificationsController {
|
|||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
private PortalDAO portalDAO;
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.GET)
|
||||
public List<Notifications> getNotifications(@PathVariable(value = "pid") String pid ) throws ContentNotFoundException {
|
||||
if(communityDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Community not found");
|
||||
if(portalDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Portal not found");
|
||||
}
|
||||
List<Notifications> notifications = notificationsDAO.findByCommunityPid(pid);
|
||||
List<Notifications> notifications = notificationsDAO.findByPortalPid(pid);
|
||||
if(notifications == null || notifications.size() == 0){
|
||||
throw new ContentNotFoundException("Notifications settings not found");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class NotificationsController {
|
|||
}
|
||||
@RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.DELETE)
|
||||
public void deleteEntity(@PathVariable(value = "pid") String pid, @RequestBody String email) throws ContentNotFoundException {
|
||||
Notifications notifications = notificationsDAO.findByManagerEmailAndCommunityPid(email,pid);
|
||||
Notifications notifications = notificationsDAO.findByManagerEmailAndPortalPid(email,pid);
|
||||
if(notifications!= null){
|
||||
notificationsDAO.delete(notifications.getId());
|
||||
}else{
|
||||
|
@ -47,18 +47,18 @@ public class NotificationsController {
|
|||
|
||||
@RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.POST)
|
||||
public Notifications saveEntity(@PathVariable(value = "pid") String pid, @RequestBody Notifications notifications) throws ContentNotFoundException {
|
||||
if(communityDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Community not found");
|
||||
if(portalDAO.findByPid(pid) == null){
|
||||
throw new ContentNotFoundException("Portal not found");
|
||||
}
|
||||
|
||||
if(notifications.getManagerEmail() != null && !notifications.getManagerEmail().isEmpty()){
|
||||
Notifications saved = notificationsDAO.findByManagerEmailAndCommunityPid(notifications.getManagerEmail(),pid);
|
||||
Notifications saved = notificationsDAO.findByManagerEmailAndPortalPid(notifications.getManagerEmail(),pid);
|
||||
log.debug(saved);
|
||||
if(saved!= null){
|
||||
notifications.setId(saved.getId());
|
||||
}
|
||||
|
||||
notifications.setCommunityPid(pid);
|
||||
notifications.setPortalPid(pid);
|
||||
log.debug(notifications);
|
||||
Notifications savedNotifications = notificationsDAO.save(notifications);
|
||||
return savedNotifications;
|
||||
|
|
|
@ -1,281 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.DivIdDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PageController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@Autowired
|
||||
private DivIdDAO divIdDAO;
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentController pageHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivHelpContentController divHelpContentController;
|
||||
|
||||
@Autowired
|
||||
private DivIdController divIdController;
|
||||
|
||||
@Autowired
|
||||
private EntityController entityController;
|
||||
|
||||
@RequestMapping(value = "/pageFull", method = RequestMethod.GET)
|
||||
public List<CommunityPage> getPagesFull(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route) {
|
||||
|
||||
List<Page> pages = this.getAllPages(pid, page_route, null);
|
||||
|
||||
List<CommunityPage> communityPages = new ArrayList<>();
|
||||
for(Page page : pages) {
|
||||
CommunityPage communityPage = new CommunityPage(page);
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for(String entityId : page.getEntities()) {
|
||||
entities.add(entityController.getEntity(entityId));
|
||||
}
|
||||
communityPage.setEntities(entities);
|
||||
|
||||
communityPages.add(communityPage);
|
||||
}
|
||||
|
||||
return communityPages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
public List<Page> getAllPages(@RequestParam(value="pid", required=false) String pid,
|
||||
@RequestParam(value="page_route", required=false) String page_route,
|
||||
@RequestParam(value="with_positions", required=false) String with_positions) {
|
||||
List<Page> pages;
|
||||
if (pid != null) {
|
||||
if (pid.equals("openaire")) {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByOpenaireAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByOpenaire(true);
|
||||
}
|
||||
} else if (pid.equals("connect")) {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByConnectAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByConnect(true);
|
||||
}
|
||||
} else {
|
||||
if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByCommunitiesAndRoute(true, page_route));
|
||||
} else {
|
||||
pages = pageDAO.findByCommunities(true);
|
||||
}
|
||||
}
|
||||
} else if (page_route != null) {
|
||||
pages = new ArrayList<Page>();
|
||||
pages.add(pageDAO.findByRoute(page_route));
|
||||
} else {
|
||||
pages = pageDAO.findAll();
|
||||
}
|
||||
|
||||
if (with_positions != null) {
|
||||
boolean at_least_one_position = Boolean.parseBoolean(with_positions);
|
||||
|
||||
Iterator<Page> iteratorPages = pages.iterator();
|
||||
while(iteratorPages.hasNext()) {
|
||||
Page page = iteratorPages.next();
|
||||
|
||||
if(at_least_one_position) {
|
||||
if(!page.getTop() && !page.getBottom() && !page.getLeft() && !page.getRight()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
} else {
|
||||
if(page.getTop() || page.getBottom() || page.getLeft() || page.getRight()) {
|
||||
iteratorPages.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pages.sort(Comparator.comparing(Page::getName));
|
||||
return pages;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.DELETE)
|
||||
public void deleteAllPages() {
|
||||
pageDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/update", method = RequestMethod.POST)
|
||||
public CommunityPage updatePage(@RequestBody CommunityPage communityPage) {
|
||||
this.deletePageHelpContentsForPositionsIfDisabled(communityPage);
|
||||
Page page = this.getPageByCommunityPage(communityPage);
|
||||
pageDAO.save(page);
|
||||
return communityPage;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/save", method = RequestMethod.POST)
|
||||
public CommunityPage insertPage(@RequestBody CommunityPage communityPage) {
|
||||
Page page = this.getPageByCommunityPage(communityPage);
|
||||
Page savedPage = pageDAO.save(page);
|
||||
communityPage.setId(savedPage.getId());
|
||||
|
||||
// add page in communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> pages = community.getPages();
|
||||
pages.put(page.getId(), true);
|
||||
community.setPages(pages);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
|
||||
return communityPage;
|
||||
}
|
||||
|
||||
private Page getPageByCommunityPage(CommunityPage communityPage) {
|
||||
Page page = new Page();
|
||||
page.setId(communityPage.getId());
|
||||
page.setRoute(communityPage.getRoute());
|
||||
page.setName(communityPage.getName());
|
||||
page.setType(communityPage.getType());
|
||||
page.setConnect(communityPage.getConnect());
|
||||
page.setCommunities(communityPage.getCommunities());
|
||||
page.setOpenaire(communityPage.getOpenaire());
|
||||
page.setTop(communityPage.getTop());
|
||||
page.setBottom(communityPage.getBottom());
|
||||
page.setLeft(communityPage.getLeft());
|
||||
page.setRight(communityPage.getRight());
|
||||
|
||||
List<Entity> fullEntities = communityPage.getEntities();
|
||||
List<String> entities = new ArrayList<String>();
|
||||
for(Entity entity : fullEntities) {
|
||||
entities.add(entity.getId());
|
||||
}
|
||||
page.setEntities(entities);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
private void deletePageHelpContentsForPositionsIfDisabled(CommunityPage communityPage) {
|
||||
|
||||
if(!communityPage.getTop()) {
|
||||
// delete page contents with position "top" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "top", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getBottom()) {
|
||||
// delete page contents with position "bottom" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "bottom", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getLeft()) {
|
||||
// delete page contents with position "left" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "left", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!communityPage.getRight()) {
|
||||
// delete page contents with position "right" related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, communityPage.getRoute(), "right", null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePages(@RequestBody List<String> pages) throws Exception {
|
||||
for (String id: pages) {
|
||||
pageDAO.delete(id);
|
||||
|
||||
// delete divIds related only to this page from all communities, otherwise remove this page from divIds
|
||||
List<DivId> divIds = divIdController.getDivIds(id, null, null);
|
||||
for(DivId divId : divIds) {
|
||||
if(divId.getPages().size() == 1) {
|
||||
divIdController.deleteDivId(divId.getId());
|
||||
|
||||
// delete div contents related to this page from all communities
|
||||
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, divId.getId(), null);
|
||||
for (DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
|
||||
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
|
||||
}
|
||||
} else {
|
||||
List<String> divIdPages = divId.getPages();
|
||||
divIdPages.remove(id);
|
||||
divId.setPages(divIdPages);
|
||||
divIdDAO.save(divId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete page contents related to this page from all communities
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(null, id, null, null, null);
|
||||
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
|
||||
pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
|
||||
}
|
||||
|
||||
// delete page from communities
|
||||
List<Community> communities = communityDAO.findAll();
|
||||
for( Community community : communities ) {
|
||||
Map<String, Boolean> communityPages = community.getPages();
|
||||
communityPages.remove(id);
|
||||
community.setPages(communityPages);
|
||||
communityDAO.save(community);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
|
||||
public Page getPage(@PathVariable(value = "id") String id) {
|
||||
return pageDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePage(@PathVariable(value = "id") String id) {
|
||||
pageDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{id}/entity", method = RequestMethod.GET)
|
||||
public List<String> getPageEntities(@PathVariable(value = "id") String id) {
|
||||
return pageDAO.findById(id).getEntities();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "page/{id}/entity/toggle", method = RequestMethod.POST)
|
||||
public Page togglePageEntity(@PathVariable(value = "id") String id, @RequestParam String entityId, @RequestParam String status) throws Exception {
|
||||
log.debug("Toggle entity : "+entityId +" of page: "+id+" to "+status);
|
||||
Page page = pageDAO.findById(id);
|
||||
List<String> entities = page.getEntities();
|
||||
if(Boolean.parseBoolean(status) && !entities.contains(entityId)) {
|
||||
entities.add(entityId);
|
||||
} else if (!Boolean.parseBoolean(status)) {
|
||||
entities.remove(entityId);
|
||||
}
|
||||
page.setEntities(entities);
|
||||
return pageDAO.save(page);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,192 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
import eu.dnetlib.uoaadmintools.entities.PageHelpContent;
|
||||
import eu.dnetlib.uoaadmintools.dao.PageHelpContentDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.PageHelpContentResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PageHelpContentController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PageHelpContentDAO pageHelpContentDAO;
|
||||
|
||||
@Autowired
|
||||
private PageController pageController;
|
||||
|
||||
@Autowired
|
||||
private CommunityController communityController;
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getPageHelpContents(@RequestParam(required=false) String community,
|
||||
@RequestParam(required=false) String page,
|
||||
@RequestParam(required=false) String position,
|
||||
@RequestParam(required=false) String active,
|
||||
@RequestParam(required=false) String before) {
|
||||
List<PageHelpContent> pageHelpContents = null;
|
||||
|
||||
Community _community = null;
|
||||
String communityId = null;
|
||||
if(community != null) {
|
||||
_community = communityController.getCommunity(community);
|
||||
if(_community != null) {
|
||||
communityId = _community.getId();
|
||||
}
|
||||
}
|
||||
//pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveAndisPriorToOrderByOrderAsc(community, position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
|
||||
if(community != null && position != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(communityId, position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null && position != null && active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(communityId, position, Boolean.parseBoolean(active));
|
||||
} else if(community != null && position != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(communityId, position, Boolean.parseBoolean(before));
|
||||
} else if(community != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(position != null && active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(position, Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null && position != null ) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndPlacementOrderByOrderAsc(communityId, position);
|
||||
} else if(community != null && active != null ) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(active));
|
||||
} else if(community != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(communityId, Boolean.parseBoolean(before));
|
||||
} else if(position != null && active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsActiveOrderByOrderAsc(position, Boolean.parseBoolean(active));
|
||||
} else if(position != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementAndIsPriorToOrderByOrderAsc(position, Boolean.parseBoolean(before));
|
||||
} else if(active != null && before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(Boolean.parseBoolean(active), Boolean.parseBoolean(before));
|
||||
} else if(community != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByCommunityOrderByPlacementAscOrderAsc(communityId);
|
||||
} else if(position != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByPlacementOrderByOrderAsc(position);
|
||||
} else if(active != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsActiveOrderByPlacementAscOrderAsc(Boolean.parseBoolean(active));
|
||||
} else if(before != null) {
|
||||
pageHelpContents = pageHelpContentDAO.findByIsPriorToOrderByPlacementAscOrderAsc(Boolean.parseBoolean(before));
|
||||
} else {
|
||||
pageHelpContents = pageHelpContentDAO.findAllByOrderByPlacementAscOrderAsc();
|
||||
}
|
||||
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = new ArrayList<>();
|
||||
for (PageHelpContent pageHelpContent : pageHelpContents) {
|
||||
Page _page = pageController.getPage(pageHelpContent.getPage());
|
||||
if(page == null || page.equals(_page.getRoute())) {
|
||||
PageHelpContentResponse pageHelpContentResponse = new PageHelpContentResponse(pageHelpContent);
|
||||
|
||||
pageHelpContentResponse.setPage(_page);
|
||||
pageHelpContentResponse.setCommunity(communityDAO.findById(pageHelpContent.getCommunity()));
|
||||
pageHelpContentResponses.add(pageHelpContentResponse);
|
||||
}
|
||||
}
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
/*
|
||||
@RequestMapping(value = "/pagehelpcontent/community/{id}", method = RequestMethod.GET)
|
||||
public List<PageHelpContentResponse> getCommunityPageHelpContents(@PathVariable(value = "id") String communityId) {
|
||||
List<PageHelpContent> pageHelpContents = pageHelpContentDAO.findByCommunity(communityId);
|
||||
List<PageHelpContentResponse> pageHelpContentResponses = new ArrayList<>();
|
||||
for (PageHelpContent pageHelpContent : pageHelpContents) {
|
||||
PageHelpContentResponse pageHelpContentResponse = new PageHelpContentResponse(pageHelpContent);
|
||||
pageHelpContentResponse.setPage(pageDAO.findById(pageHelpContent.getPage()));
|
||||
pageHelpContentResponse.setCommunity(communityDAO.findById(pageHelpContent.getCommunity()));
|
||||
pageHelpContentResponses.add(pageHelpContentResponse);
|
||||
}
|
||||
return pageHelpContentResponses;
|
||||
}
|
||||
*/
|
||||
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.DELETE)
|
||||
public void deleteAllPageHelpContents() {
|
||||
pageHelpContentDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/save", method = RequestMethod.POST)
|
||||
public PageHelpContent insertPageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
String communityId = communityController.getCommunity(pageHelpContent.getCommunity()).getId();
|
||||
pageHelpContent.setCommunity(communityId);
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/update", method = RequestMethod.POST)
|
||||
public PageHelpContent updatePageHelpContent(@RequestBody PageHelpContent pageHelpContent) {
|
||||
return pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.GET)
|
||||
public PageHelpContent getPageHelpContent(@PathVariable(value = "id") String id) {
|
||||
return pageHelpContentDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/toggle", method = RequestMethod.POST)
|
||||
public List<String> togglePageHelpContent(@RequestBody List<String> pageHelpContents, @RequestParam String status) throws Exception {
|
||||
for (String id: pageHelpContents) {
|
||||
log.debug("Id of pageHelpContent: "+id);
|
||||
PageHelpContent pageHelpContent = pageHelpContentDAO.findById(id);
|
||||
pageHelpContent.setIsActive(Boolean.parseBoolean(status));
|
||||
pageHelpContentDAO.save(pageHelpContent);
|
||||
}
|
||||
return pageHelpContents;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/{id}", method = RequestMethod.DELETE)
|
||||
public void deletePageHelpContent(@PathVariable(value = "id") String id) {
|
||||
pageHelpContentDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagehelpcontent/delete", method = RequestMethod.POST)
|
||||
public Boolean deletePageHelpContents(@RequestBody List<String> pageHelpContents) throws Exception {
|
||||
for (String id: pageHelpContents) {
|
||||
pageHelpContentDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPageHelpContentsInCommunity(String pid, String communityId) {
|
||||
if (pid != "connect" && pid != "openaire") {
|
||||
String organizations_page_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
|
||||
Page organizationsPage = (pageController.getAllPages(null, "/organizations", null)).get(0);
|
||||
|
||||
PageHelpContent organizations_pageHelpContent = new PageHelpContent(organizationsPage.getId(), pid, "top", 1, organizations_page_content, false, false);
|
||||
this.insertPageHelpContent(organizations_pageHelpContent);
|
||||
|
||||
String depositLearnHow_page_content = "" +
|
||||
"<div class=\"uk-width-3-5 uk-align-center\"> " +
|
||||
" <div class=\"uk-text-bold\">How to comply with funder Open Access policies</div> " +
|
||||
" <ul class=\"uk-list uk-list-bullet\"> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-publications\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on publications </a></li> " +
|
||||
" <li>Read the <a class=\"custom-external\" href=\"https://www.openaire.eu/how-to-comply-to-h2020-mandates-for-data\" target=\"_blank\"> OpenAIRE guide to learn how to comply with EC H2020 Open Access policy on research data </a></li> " +
|
||||
" <li>If you want to know about National Open Access policies, please check them out <a class=\"custom-external\" href=\"https://www.openaire.eu/frontpage/country-pages\" target=\"_blank\">here</a></li> " +
|
||||
" <li>All OpenAIRE guides can be found <a class=\"custom-external\" href=\"https://www.openaire.eu/guides\" target=\"_blank\">here</a></li> " +
|
||||
" </ul> " +
|
||||
"</div>";
|
||||
Page depositLearnHowPage = (pageController.getAllPages(null, "/participate/deposit/learn-how", null)).get(0);
|
||||
|
||||
PageHelpContent depositLearnHow_pageHelpContent = new PageHelpContent(depositLearnHowPage.getId(), pid, "bottom", 1, depositLearnHow_page_content, true, false);
|
||||
this.insertPageHelpContent(depositLearnHow_pageHelpContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
|
||||
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintools.handlers.utils.AuthorizationUtils;
|
||||
import eu.dnetlib.uoaadmintools.handlers.utils.UserInfo;
|
||||
import eu.dnetlib.uoaadmintools.responses.SingleValueWrapperResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class PortalSubscribersController {
|
||||
@Autowired
|
||||
PortalSubscribersDAO portalSubscribersDAO;
|
||||
@Autowired
|
||||
SubscriberDAO subscriberDAO;
|
||||
@Autowired
|
||||
PortalDAO portalDAO;
|
||||
|
||||
@Autowired
|
||||
private SecurityConfig securityConfig;
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscribers/count", method = RequestMethod.GET)
|
||||
public SingleValueWrapperResponse<Integer> getNumberOfSubscribersPerPortal(@PathVariable(value="pid", required = true) String pid) throws ContentNotFoundException {
|
||||
SingleValueWrapperResponse<Integer> singleValueWrapperResponse = new SingleValueWrapperResponse(0);
|
||||
|
||||
PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(portalSubscribers != null){
|
||||
if(portalSubscribers.getSubscribers() != null) {
|
||||
singleValueWrapperResponse.setValue(portalSubscribers.getSubscribers().size());
|
||||
}
|
||||
}else{
|
||||
throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
|
||||
}
|
||||
return singleValueWrapperResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/subscribers", method = RequestMethod.GET)
|
||||
public List<PortalSubscribers> getAllPortalSubscribers(){
|
||||
return portalSubscribersDAO.findAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.GET)
|
||||
public PortalSubscribers getSubscribersPerPortal(@PathVariable(value="pid", required = true) String pid) throws ContentNotFoundException {
|
||||
PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(portalSubscribers != null){
|
||||
return portalSubscribers;
|
||||
}else{
|
||||
throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// @RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST)
|
||||
// public PortalSubscribers addSubscriberInPortal(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException {
|
||||
// PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
// if(portalSubscribers == null){
|
||||
// throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
// }
|
||||
//
|
||||
// Subscriber savedSubscriber = subscriberDAO.findByEmail(subscriber.getEmail());
|
||||
// if(savedSubscriber==null){
|
||||
// savedSubscriber = subscriberDAO.save(subscriber);
|
||||
// }
|
||||
// for(Subscriber sub: portalSubscribers.getSubscribers()){
|
||||
// if(sub.getEmail().equals(subscriber.getEmail())){
|
||||
// //already subscribed
|
||||
// return portalSubscribers;
|
||||
// }
|
||||
// }
|
||||
// //not subscribed yet
|
||||
// portalSubscribers.getSubscribers().add(savedSubscriber);
|
||||
// return portalSubscribersDAO.save(portalSubscribers);
|
||||
//
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/is-subscriber", method = RequestMethod.GET)
|
||||
public Boolean getIsSubscribedToPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
//@RequestBody String email,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers != null) {
|
||||
if (communitySubscribers.getSubscribers() != null) {
|
||||
for (Subscriber subscriber : communitySubscribers.getSubscribers()) {
|
||||
if (subscriber.getEmail().equals(email)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ContentNotFoundException("Portal Subscribers not found");
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscriber", method = RequestMethod.POST)
|
||||
public Boolean addSubscriberInPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
Subscriber subscriber = new Subscriber(email);
|
||||
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers == null) {
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Subscriber savedSubscriber = subscriberDAO.findByEmail(email);
|
||||
if (savedSubscriber == null) {
|
||||
savedSubscriber = subscriberDAO.save(subscriber);
|
||||
}
|
||||
for (Subscriber sub : communitySubscribers.getSubscribers()) {
|
||||
if (sub.getEmail().equals(subscriber.getEmail())) {
|
||||
//already subscribed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//not subscribed yet
|
||||
communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
portalSubscribersDAO.save(communitySubscribers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscriber/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteSubscriberFromPortal(@PathVariable(value="pid", required = true) String pid,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) throws ContentNotFoundException {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
if(userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if (communitySubscribers == null) {
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Iterator<Subscriber> subscriberIterator = communitySubscribers.getSubscribers().iterator();
|
||||
while(subscriberIterator.hasNext()) {
|
||||
Subscriber subscriber = subscriberIterator.next();
|
||||
if(subscriber.getEmail().equals(email)) {
|
||||
subscriberIterator.remove();
|
||||
portalSubscribersDAO.save(communitySubscribers);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST)
|
||||
public PortalSubscribers addSubscriberInPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException {
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(communitySubscribers == null){
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
|
||||
Subscriber savedSubscriber = subscriberDAO.findByEmail(subscriber.getEmail());
|
||||
if(savedSubscriber==null){
|
||||
savedSubscriber = subscriberDAO.save(subscriber);
|
||||
}
|
||||
for(Subscriber sub:communitySubscribers.getSubscribers()){
|
||||
if(sub.getEmail().equals(subscriber.getEmail())){
|
||||
//already subscribed
|
||||
return communitySubscribers;
|
||||
}
|
||||
}
|
||||
//not subscribed yet
|
||||
communitySubscribers.getSubscribers().add(savedSubscriber);
|
||||
return portalSubscribersDAO.save(communitySubscribers);
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscribers/delete", method = RequestMethod.POST)
|
||||
public PortalSubscribers deleteSubscriberFromPortalByEmail(@PathVariable(value="pid", required = true) String pid, @RequestBody List<String> emails) throws ContentNotFoundException {
|
||||
PortalSubscribers communitySubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(communitySubscribers == null){
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
}
|
||||
List<Subscriber> list = new ArrayList<>();
|
||||
for(Subscriber s:communitySubscribers.getSubscribers()){
|
||||
if(emails.indexOf(s.getEmail())==-1){
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
communitySubscribers.setSubscribers(list);
|
||||
return portalSubscribersDAO.save(communitySubscribers);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subscriber/communities", method = RequestMethod.GET)
|
||||
public List<String> getPortalsPerSubcriber(//@RequestParam(value="email", required = true) String email,
|
||||
@RequestHeader("X-XSRF-TOKEN") String token) {
|
||||
AuthorizationUtils helper = new AuthorizationUtils();
|
||||
helper.setUserInfoUrl(securityConfig.getUserInfoUrl());
|
||||
UserInfo userInfo = helper.getUserInfo(token);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if (userInfo != null) {
|
||||
String email = userInfo.getEmail();
|
||||
List<PortalSubscribers> communitySubscribers = portalSubscribersDAO.findAll();
|
||||
|
||||
for (PortalSubscribers s : communitySubscribers) {
|
||||
for (Subscriber sub : s.getSubscribers()) {
|
||||
if (sub.getEmail().equals(email)) {
|
||||
list.add(s.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Question;
|
||||
import eu.dnetlib.uoaadmintools.entities.QuestionResponse;
|
||||
import eu.dnetlib.uoaadmintools.dao.QuestionDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Topic;
|
||||
import eu.dnetlib.uoaadmintools.dao.TopicDAO;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class QuestionController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private QuestionDAO questionDAO;
|
||||
|
||||
@Autowired
|
||||
private TopicDAO topicDAO;
|
||||
|
||||
@RequestMapping(value = "/question", method = RequestMethod.GET)
|
||||
public List<QuestionResponse> getAllQuestions() {
|
||||
List<Question> questions = questionDAO.findAll();
|
||||
List<QuestionResponse> questionResponses = new ArrayList<>();
|
||||
for (Question question : questions) {
|
||||
QuestionResponse questionResponse = new QuestionResponse(question);
|
||||
List<Topic> topics = new ArrayList<>();
|
||||
for (String topic : question.getTopics()) {
|
||||
topics.add(topicDAO.findById(topic));
|
||||
}
|
||||
questionResponse.setTopics(topics);
|
||||
questionResponses.add(questionResponse);
|
||||
}
|
||||
return questionResponses;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question", method = RequestMethod.DELETE)
|
||||
public void deleteAllQuestions() {
|
||||
questionDAO.deleteAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question", method = RequestMethod.POST)
|
||||
public QuestionResponse insertOrUpdateQuestion(@RequestBody Question question) {
|
||||
QuestionResponse questionResponse = new QuestionResponse(questionDAO.save(question));
|
||||
List<Topic> topics = new ArrayList<>();
|
||||
for (String topic : question.getTopics()) {
|
||||
topics.add(topicDAO.findById(topic));
|
||||
}
|
||||
questionResponse.setTopics(topics);
|
||||
return questionResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question/{id}", method = RequestMethod.GET)
|
||||
public QuestionResponse getQuestion(@PathVariable(value = "id") String id) {
|
||||
Question question = questionDAO.findById(id);
|
||||
QuestionResponse questionResponse = new QuestionResponse(question);
|
||||
List<Topic> topics = new ArrayList<>();
|
||||
for (String topic : question.getTopics()) {
|
||||
topics.add(topicDAO.findById(topic));
|
||||
}
|
||||
questionResponse.setTopics(topics);
|
||||
return questionResponse;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteQuestion(@PathVariable(value = "id") String id) {
|
||||
questionDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question/inc/{id}", method = RequestMethod.PUT)
|
||||
public Question incQuestion(@PathVariable(value = "id") String id) {
|
||||
Question question = questionDAO.findById(id);
|
||||
question.increment();
|
||||
questionDAO.save(question);
|
||||
return question;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question/delete", method = RequestMethod.POST)
|
||||
public void deleteQuestions(@RequestBody List<String> questions) {
|
||||
for (String question : questions) {
|
||||
deleteQuestion(question);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/question/toggle", method = RequestMethod.POST)
|
||||
public void toggleQuestions(@RequestBody List<String> questions, @RequestParam String status) throws Exception {
|
||||
for (String id: questions) {
|
||||
Question question = questionDAO.findById(id);
|
||||
question.setIsActive(Boolean.parseBoolean(status));
|
||||
questionDAO.save(question);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package eu.dnetlib.uoaadmintools.controllers;
|
|||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.*;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -70,7 +70,7 @@ public class StatisticsController {
|
|||
public Statistics toggleCharts(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found for community");
|
||||
throw new ContentNotFoundException("Statistics not found for portal");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
|
@ -96,7 +96,7 @@ public class StatisticsController {
|
|||
public Statistics toggleNumber(@PathVariable(value = "pid") String pid, @PathVariable(value = "entity") String entity, @RequestBody String key, @RequestParam String status, @RequestParam String monitor) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found for community");
|
||||
throw new ContentNotFoundException("Statistics not found for portal");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ContentNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Topic;
|
||||
import eu.dnetlib.uoaadmintools.dao.TopicDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Question;
|
||||
import eu.dnetlib.uoaadmintools.dao.QuestionDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.TopicResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class TopicController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private TopicDAO topicDAO;
|
||||
|
||||
@Autowired
|
||||
private QuestionDAO questionDAO;
|
||||
|
||||
@RequestMapping(value = "/topic", method = RequestMethod.GET)
|
||||
public List<Topic> getAllTopics() {
|
||||
return topicDAO.findAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic", method = RequestMethod.DELETE)
|
||||
public void deleteAllTopics() {
|
||||
topicDAO.deleteAll();
|
||||
}
|
||||
|
||||
//TODO: if id is provided check that it exists!
|
||||
@RequestMapping(value = "/topic", method = RequestMethod.POST)
|
||||
public Topic insertOrUpdateTopic(@RequestBody Topic topic) {
|
||||
return topicDAO.save(topic);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic/{id}", method = RequestMethod.GET)
|
||||
public Topic getTopic(@PathVariable(value = "id") String id) {
|
||||
return topicDAO.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic/{id}", method = RequestMethod.DELETE)
|
||||
public void deleteTopic(@PathVariable(value = "id") String id) {
|
||||
List<Question> questions = questionDAO.findByTopicsIn(id);
|
||||
for (Question question : questions) {
|
||||
List<String> topics = question.getTopics();
|
||||
topics.remove(id);
|
||||
if (topics.isEmpty()) {
|
||||
questionDAO.delete(question.getId());
|
||||
} else {
|
||||
questionDAO.save(question);
|
||||
}
|
||||
}
|
||||
topicDAO.delete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic/delete", method = RequestMethod.POST)
|
||||
public void deleteTopics(@RequestBody List<String> topics) {
|
||||
for (String topic : topics) {
|
||||
deleteTopic(topic);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic/toggle", method = RequestMethod.POST)
|
||||
public void toggleTopics(@RequestBody List<String> topics, @RequestParam(value="order", defaultValue = "") String order) throws Exception {
|
||||
for (String id: topics) {
|
||||
Topic topic = topicDAO.findById(id);
|
||||
topic.setQuestionOrder(order);
|
||||
topicDAO.save(topic);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/topic/active", method = RequestMethod.GET)
|
||||
public List<TopicResponse> getActiveTopic() {
|
||||
List<TopicResponse> topicResponses = new ArrayList<>();
|
||||
for(Topic topic : topicDAO.findAll()) {
|
||||
TopicResponse topicResponse = new TopicResponse(topic);
|
||||
List<Question> questions = questionDAO.findByTopicsInAndIsActiveIsTrue(topic.getId());
|
||||
if(topic.getQuestionOrder().equals("hits")) {
|
||||
questions.sort(Comparator.comparingInt(Question::getHitCount).reversed());
|
||||
} else if(topic.getQuestionOrder().equals("weight")) {
|
||||
questions.sort(Comparator.comparingDouble(Question::getWeight).reversed());
|
||||
}
|
||||
topicResponse.setQuestions(questions);
|
||||
topicResponses.add(topicResponse);
|
||||
}
|
||||
return topicResponses;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommunityDAO {
|
||||
List<Community> findAll();
|
||||
|
||||
Community findById(String Id);
|
||||
|
||||
Community findByPid(String Pid);
|
||||
|
||||
Community findByName(String Name);
|
||||
|
||||
Community save(Community community);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommunitySubscribersDAO {
|
||||
|
||||
List<CommunitySubscribers> findAll();
|
||||
|
||||
CommunitySubscribers findById(String Id);
|
||||
|
||||
CommunitySubscribers findByPid(String Pid);
|
||||
|
||||
CommunitySubscribers save(CommunitySubscribers communitySubscribers);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.DivHelpContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DivHelpContentDAO {
|
||||
List<DivHelpContent> findAll();
|
||||
|
||||
List<DivHelpContent> findByCommunity(String community);
|
||||
List<DivHelpContent> findByDivId(String divId);
|
||||
List<DivHelpContent> findByIsActive(boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivId(String community, String divId);
|
||||
List<DivHelpContent> findByCommunityAndIsActive(String community, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivIdAndIsActive(String community, String divId, boolean isActive);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
DivHelpContent save(DivHelpContent divHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.DivId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DivIdDAO {
|
||||
List<DivId> findAll();
|
||||
|
||||
List<DivId> findByPagesContaining(String page);
|
||||
|
||||
DivId findByPagesContainingAndName(String page, String name);
|
||||
DivId findByName(String name);
|
||||
|
||||
DivId findById(String Id);
|
||||
|
||||
List<DivId> findByConnect(boolean connect);
|
||||
List<DivId> findByCommunities(boolean communities);
|
||||
List<DivId> findByOpenaire(boolean openaire);
|
||||
|
||||
DivId save(DivId divId);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EntityDAO {
|
||||
List<Entity> findAll();
|
||||
|
||||
Entity findById(String Id);
|
||||
|
||||
Entity findByPid(String Pid);
|
||||
|
||||
Entity findByName(String name);
|
||||
|
||||
Entity save(Entity entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.HtmlPageContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HtmlPageContentDAO {
|
||||
List<HtmlPageContent> findAll();
|
||||
List<HtmlPageContent> findByCommunity(String communityId);
|
||||
HtmlPageContent findById(String Id);
|
||||
HtmlPageContent save(HtmlPageContent htmlPageContent);
|
||||
void deleteAll();
|
||||
void delete(String id);
|
||||
}
|
|
@ -9,7 +9,9 @@ public interface LayoutDAO {
|
|||
|
||||
Layout findById(String Id);
|
||||
|
||||
Layout save(Layout entity);
|
||||
Layout findByPortalPid(String portalPid);
|
||||
|
||||
Layout save(Layout layout);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBCommunityDAO extends CommunityDAO, MongoRepository<Community, String> {
|
||||
List<Community> findAll();
|
||||
|
||||
Community findById(String Id);
|
||||
|
||||
Community findByPid(String Pid);
|
||||
|
||||
Community findByName(String Name);
|
||||
|
||||
Community save(Community community);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBCommunitySubscribersDAO extends CommunitySubscribersDAO, MongoRepository<CommunitySubscribers, String> {
|
||||
|
||||
List<CommunitySubscribers> findAll();
|
||||
|
||||
CommunitySubscribers findById(String Id);
|
||||
|
||||
CommunitySubscribers findByPid(String Pid);
|
||||
|
||||
CommunitySubscribers save(CommunitySubscribers communitySubscribers);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
import eu.dnetlib.uoaadmintools.dao.CuratorDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.LayoutDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
|
@ -11,7 +12,9 @@ public interface MongoDBLayoutDAO extends LayoutDAO, MongoRepository<Layout, Str
|
|||
|
||||
Layout findById(String Id);
|
||||
|
||||
Layout save(Layout entity);
|
||||
Layout findByPortalPid(String portalPid);
|
||||
|
||||
Layout save(Layout layout);
|
||||
|
||||
void deleteAll();
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
|
@ -13,8 +14,8 @@ public interface MongoDBNotificationsDAO extends NotificationsDAO, MongoReposito
|
|||
|
||||
Notifications findById(String Id);
|
||||
|
||||
Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
|
||||
List<Notifications> findByCommunityPid(String communityPid);
|
||||
Notifications findByManagerEmailAndPortalPid(String managerEmail, String portalPid);
|
||||
List<Notifications> findByPortalPid(String portalPid);
|
||||
|
||||
Notifications save(Notifications entity);
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBPortalSubscribersDAO extends PortalSubscribersDAO, MongoRepository<PortalSubscribers, String> {
|
||||
|
||||
List<PortalSubscribers> findAll();
|
||||
|
||||
PortalSubscribers findById(String Id);
|
||||
|
||||
PortalSubscribers findByPid(String Pid);
|
||||
|
||||
PortalSubscribers save(PortalSubscribers portalSubscribers);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.StatisticsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
package eu.dnetlib.uoaadmintools.dao.MongoDBDAOs;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
|
@ -1,26 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.DivHelpContent;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBDivHelpContentDAO extends DivHelpContentDAO, MongoRepository<DivHelpContent, String> {
|
||||
List<DivHelpContent> findAll();
|
||||
|
||||
List<DivHelpContent> findByCommunity(String community);
|
||||
List<DivHelpContent> findByDivId(String divId);
|
||||
List<DivHelpContent> findByIsActive(boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivId(String community, String divId);
|
||||
List<DivHelpContent> findByCommunityAndIsActive(String community, boolean isActive);
|
||||
List<DivHelpContent> findByDivIdAndIsActive(String divId, boolean isActive);
|
||||
List<DivHelpContent> findByCommunityAndDivIdAndIsActive(String community, String divId, boolean isActive);
|
||||
|
||||
DivHelpContent findById(String Id);
|
||||
|
||||
DivHelpContent save(DivHelpContent divHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.DivId;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBDivIdDAO extends DivIdDAO, MongoRepository<DivId, String> {
|
||||
List<DivId> findAll();
|
||||
|
||||
List<DivId> findByPagesContaining(String page);
|
||||
|
||||
DivId findByPagesContainingAndName(String page, String name);
|
||||
DivId findByName(String name);
|
||||
|
||||
DivId findById(String Id);
|
||||
|
||||
List<DivId> findByConnect(boolean connect);
|
||||
List<DivId> findByCommunities(boolean communities);
|
||||
List<DivId> findByOpenaire(boolean openaire);
|
||||
|
||||
DivId save(DivId divId);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Entity;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBEntityDAO extends EntityDAO, MongoRepository<Entity, String> {
|
||||
List<Entity> findAll();
|
||||
|
||||
Entity findById(String Id);
|
||||
|
||||
Entity findByPid(String Pid);
|
||||
|
||||
Entity findByName(String name);
|
||||
|
||||
Entity save(Entity entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.HtmlPageContent;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBHtmlPageContentDAO extends HtmlPageContentDAO, MongoRepository<HtmlPageContent, String> {
|
||||
List<HtmlPageContent> findAll();
|
||||
List<HtmlPageContent> findByCommunity(String communityId);
|
||||
HtmlPageContent findById(String Id);
|
||||
HtmlPageContent save(HtmlPageContent htmlPageContent);
|
||||
void deleteAll();
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBPageDAO extends PageDAO, MongoRepository<Page, String> {
|
||||
List<Page> findAll();
|
||||
List<Page> findByConnect(boolean connect);
|
||||
List<Page> findByCommunities(boolean communities);
|
||||
List<Page> findByOpenaire(boolean openaire);
|
||||
|
||||
Page findByConnectAndRoute(boolean connect, String route);
|
||||
Page findByCommunitiesAndRoute(boolean communities, String route);
|
||||
Page findByOpenaireAndRoute(boolean openaire, String route);
|
||||
|
||||
Page findById(String Id);
|
||||
Page findByRoute(String route);
|
||||
|
||||
Page save(Page page);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.PageHelpContent;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBPageHelpContentDAO extends PageHelpContentDAO, MongoRepository<PageHelpContent, String> {
|
||||
List<PageHelpContent> findAll();
|
||||
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(String communityId, String position, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementOrderByOrderAsc(String communityId, String postion);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(String communityId, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveOrderByOrderAsc(String position, boolean isActive);
|
||||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityOrderByPlacementAscOrderAsc(String communityId);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
List<PageHelpContent> findByIsPriorToOrderByPlacementAscOrderAsc(boolean isPriorTo);
|
||||
List<PageHelpContent> findAllByOrderByPlacementAscOrderAsc();
|
||||
|
||||
|
||||
//List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndBeforeOrderByOrderAsc(String communityId, String postion, boolean isActive, boolean before);
|
||||
|
||||
PageHelpContent findById(String Id);
|
||||
|
||||
PageHelpContent findByIdOrderByOrder(String Id);
|
||||
|
||||
PageHelpContent save(PageHelpContent pageHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Question;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBQuestionDAO extends QuestionDAO, MongoRepository<Question, String> {
|
||||
List<Question> findAll();
|
||||
|
||||
Question findById(String id);
|
||||
|
||||
List<Question> findByTopicsIn(String id);
|
||||
|
||||
List<Question> findByTopicsInAndIsActiveIsTrue(String id);
|
||||
|
||||
Question save(Question question);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Topic;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBTopicDAO extends TopicDAO, MongoRepository<Topic, String> {
|
||||
List<Topic> findAll();
|
||||
|
||||
Topic findById(String Id);
|
||||
|
||||
Topic save(Topic topic);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -12,8 +12,8 @@ public interface NotificationsDAO {
|
|||
|
||||
Notifications findById(String Id);
|
||||
|
||||
Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
|
||||
List<Notifications> findByCommunityPid(String communityPid);
|
||||
Notifications findByManagerEmailAndPortalPid(String managerEmail, String portalPid);
|
||||
List<Notifications> findByPortalPid(String portalPid);
|
||||
|
||||
Notifications save(Notifications entity);
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PageDAO {
|
||||
List<Page> findAll();
|
||||
List<Page> findByConnect(boolean connect);
|
||||
List<Page> findByCommunities(boolean communities);
|
||||
List<Page> findByOpenaire(boolean openaire);
|
||||
|
||||
Page findByConnectAndRoute(boolean connect, String route);
|
||||
Page findByCommunitiesAndRoute(boolean communities, String route);
|
||||
Page findByOpenaireAndRoute(boolean openaire, String route);
|
||||
|
||||
Page findById(String Id);
|
||||
Page findByRoute(String route);
|
||||
|
||||
Page save(Page page);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.PageHelpContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PageHelpContentDAO {
|
||||
List<PageHelpContent> findAll();
|
||||
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsActiveOrderByOrderAsc(String communityId, String position, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndPlacementAndIsPriorToOrderByOrderAsc(String communityId, String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String position, boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityAndPlacementOrderByOrderAsc(String communityId, String postion);
|
||||
List<PageHelpContent> findByCommunityAndIsActiveOrderByPlacementAscOrderAsc(String communityId, boolean isActive);
|
||||
List<PageHelpContent> findByCommunityAndIsPriorToOrderByPlacementAscOrderAsc(String communityId, boolean isPriorTo);
|
||||
List<PageHelpContent> findByPlacementAndIsActiveOrderByOrderAsc(String position, boolean isActive);
|
||||
List<PageHelpContent> findByPlacementAndIsPriorToOrderByOrderAsc(String position, boolean isPriorTo);
|
||||
List<PageHelpContent> findByIsActiveAndIsPriorToOrderByPlacementAscOrderAsc(boolean isActive, boolean isPriorTo);
|
||||
List<PageHelpContent> findByCommunityOrderByPlacementAscOrderAsc(String communityId);
|
||||
List<PageHelpContent> findByPlacementOrderByOrderAsc(String postion);
|
||||
List<PageHelpContent> findByIsActiveOrderByPlacementAscOrderAsc(boolean isActive);
|
||||
List<PageHelpContent> findByIsPriorToOrderByPlacementAscOrderAsc(boolean isPriorTo);
|
||||
List<PageHelpContent> findAllByOrderByPlacementAscOrderAsc();
|
||||
|
||||
//List<PageHelpContent> findByCommunityAndPlacementAndIsActiveAndIsPriorToOrderByOrderAsc(String communityId, String postion, boolean isActive, boolean isBefore);
|
||||
|
||||
|
||||
PageHelpContent findById(String Id);
|
||||
|
||||
PageHelpContent findByIdOrderByOrder(String Id);
|
||||
|
||||
PageHelpContent save(PageHelpContent pageHelpContent);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PortalSubscribersDAO {
|
||||
|
||||
List<PortalSubscribers> findAll();
|
||||
|
||||
PortalSubscribers findById(String Id);
|
||||
|
||||
PortalSubscribers findByPid(String Pid);
|
||||
|
||||
PortalSubscribers save(PortalSubscribers portalSubscribers);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Question;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface QuestionDAO {
|
||||
List<Question> findAll();
|
||||
|
||||
Question findById(String id);
|
||||
|
||||
List<Question> findByTopicsIn(String id);
|
||||
|
||||
List<Question> findByTopicsInAndIsActiveIsTrue(String id);
|
||||
|
||||
Question save(Question question);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.Subscriber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Topic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TopicDAO {
|
||||
List<Topic> findAll();
|
||||
|
||||
Topic findById(String Id);
|
||||
|
||||
Topic save(Topic topic);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.emailSender;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MailConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Configurable
|
||||
public class EmailSender {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EmailSender.class);
|
||||
|
||||
@Autowired
|
||||
private MailConfig mailConfig;
|
||||
|
||||
public boolean send(List<String> recipients, String subject, String body, Boolean bcc) {
|
||||
// Get system properties
|
||||
Properties properties = System.getProperties();
|
||||
properties.setProperty("mail.smtp.host", mailConfig.getHost());
|
||||
properties.put("mail.smtp.port", mailConfig.getPort());
|
||||
properties.put("mail.smtp.auth", mailConfig.getAuth()); //enable authentication
|
||||
properties.put("mail.smtp.starttls.enable", "true");
|
||||
logger.debug("Try to connect to mail sender with "+ mailConfig.getUsername());
|
||||
Session session = Session.getInstance(properties,
|
||||
new javax.mail.Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(mailConfig.getUsername(), mailConfig.getPassword());
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
logger.debug("Try to sent e-mail to "+recipients.toString()+
|
||||
"\nSubject: "+subject+
|
||||
"\nBody:"+body);
|
||||
|
||||
// Create a default MimeMessage object.
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
|
||||
// Set From: header field of the header.
|
||||
message.setFrom(new InternetAddress(mailConfig.getFrom()));
|
||||
|
||||
// Set To: header field of the header.
|
||||
if(!bcc) {
|
||||
for (String to : recipients) {
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
|
||||
}
|
||||
}else{
|
||||
for (String to : recipients) {
|
||||
message.addRecipient(Message.RecipientType.BCC, new InternetAddress(to));
|
||||
}
|
||||
}
|
||||
|
||||
message.addRecipient(Message.RecipientType.BCC, new InternetAddress("openaire.test@gmail.com"));
|
||||
|
||||
// Set Subject: header field
|
||||
message.setSubject(subject, "UTF-8");
|
||||
|
||||
// For simple text setText() can be used instead of setContent()
|
||||
|
||||
// Send the actual HTML message, as big as you like
|
||||
message.setContent(body, "text/html; charset=UTF-8");
|
||||
|
||||
// Send message
|
||||
Transport.send(message);
|
||||
logger.debug("Sent message successfully....\n");
|
||||
return true;
|
||||
} catch (AddressException ae) {
|
||||
logger.error("Email could not be send.", ae);
|
||||
return false;
|
||||
} catch (MessagingException me) {
|
||||
logger.error("Email could not be send.", me);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Community {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private Map<String, Boolean> pages;
|
||||
private Map<String, Boolean> entities;
|
||||
private String layout;
|
||||
|
||||
public Community() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getPages() { return pages; }
|
||||
|
||||
public void setPages(Map<String, Boolean> pages) { this.pages = pages; }
|
||||
|
||||
public Map<String, Boolean> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(Map<String, Boolean> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Community{" +
|
||||
"id='" + id + '\'' +
|
||||
", pid='" + pid + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", pages=" + pages +
|
||||
", entities=" + entities +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(String layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunityEntity {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private Boolean isEnabled;
|
||||
|
||||
public CommunityEntity() {}
|
||||
|
||||
public CommunityEntity(Entity entity) {
|
||||
this.setId(entity.getId());
|
||||
this.setPid(entity.getPid());
|
||||
this.setName(entity.getName());
|
||||
this.setIsEnabled(true);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) { this.pid = pid; }
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; }
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunityPage {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String route;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<Entity> entities;
|
||||
private Boolean isEnabled;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
// Posiitions where help texts are allowed for this page
|
||||
private Boolean top;
|
||||
private Boolean bottom;
|
||||
private Boolean left;
|
||||
private Boolean right;
|
||||
|
||||
public CommunityPage() {}
|
||||
|
||||
public CommunityPage(Page page) {
|
||||
this.setId(page.getId());
|
||||
this.setRoute(page.getRoute());
|
||||
this.setName(page.getName());
|
||||
this.setType(page.getType());
|
||||
this.setConnect(page.getConnect());
|
||||
this.setCommunities(page.getCommunities());
|
||||
this.setOpenaire(page.getOpenaire());
|
||||
this.setTop(page.getTop());
|
||||
this.setBottom(page.getBottom());
|
||||
this.setLeft(page.getLeft());
|
||||
this.setRight(page.getRight());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
public void setRoute(String route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<Entity> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<Entity> entities) { this.entities = entities; }
|
||||
|
||||
public Boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; }
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() {
|
||||
return communities;
|
||||
}
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(Boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public Boolean getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public void setBottom(Boolean bottom) {
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public Boolean getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(Boolean left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public Boolean getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(Boolean right) {
|
||||
this.right = right;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityResponse {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
private List<CommunityPage> pages;
|
||||
private List<CommunityEntity> entities;
|
||||
private Layout layout;
|
||||
|
||||
public CommunityResponse() {}
|
||||
|
||||
public CommunityResponse(Community community) {
|
||||
this.setId(community.getId());
|
||||
this.setPid(community.getPid());
|
||||
this.setName(community.getName());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<CommunityPage> getPages() { return pages; }
|
||||
|
||||
public void setPages(List<CommunityPage> pages) { this.pages = pages; }
|
||||
|
||||
public List<CommunityEntity> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<CommunityEntity> entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public Layout getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(Layout layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class DivHelpContent {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String divId;
|
||||
private String community;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
|
||||
public DivHelpContent() {
|
||||
}
|
||||
|
||||
public DivHelpContent(String divId, String community, String content, boolean isActive) {
|
||||
this.divId = divId;
|
||||
this.community = community;
|
||||
this.content = content;
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDivId() {
|
||||
return divId;
|
||||
}
|
||||
|
||||
public void setDivId(String divId) {
|
||||
this.divId = divId;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(String community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class DivHelpContentResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private DivIdResponse divId;
|
||||
private Community community;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
|
||||
public DivHelpContentResponse(DivHelpContent divHelpContent) {
|
||||
this.id = divHelpContent.getId();
|
||||
this.content = divHelpContent.getContent();
|
||||
this.isActive = divHelpContent.getIsActive();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DivIdResponse getDivId() {
|
||||
return divId;
|
||||
}
|
||||
|
||||
public void setDivId(DivIdResponse divId) {
|
||||
this.divId = divId;
|
||||
}
|
||||
|
||||
public Community getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(Community community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DivId {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private List<String> pages;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
public DivId() {
|
||||
}
|
||||
|
||||
public DivId(DivId divId) {
|
||||
setName(divId.getName());
|
||||
setPages(divId.getPages());
|
||||
setConnect(divId.getConnect());
|
||||
setCommunities(divId.getCommunities());
|
||||
setOpenaire(divId.getOpenaire());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<String> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() { return communities; }
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DivIdResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private List<Page> pages;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
public DivIdResponse() {}
|
||||
|
||||
public DivIdResponse(DivId divId) {
|
||||
this.id = divId.getId();
|
||||
this.name = divId.getName();
|
||||
setConnect(divId.getConnect());
|
||||
setCommunities(divId.getCommunities());
|
||||
setOpenaire(divId.getOpenaire());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Page> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(List<Page> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() { return communities; }
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/7/2018.
|
||||
*/
|
||||
public class Email {
|
||||
String subject;
|
||||
List<String> recipients;
|
||||
String body;
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public List<String> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public void setRecipients(List<String> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
public class EmailRecaptcha {
|
||||
|
||||
private Email email;
|
||||
private String recaptcha;
|
||||
|
||||
public Email getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(Email email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getRecaptcha() {
|
||||
return recaptcha;
|
||||
}
|
||||
|
||||
public void setRecaptcha(String recaptcha) {
|
||||
this.recaptcha = recaptcha;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class Entity {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
private String name;
|
||||
|
||||
public Entity() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonPropertyOrder({
|
||||
"success",
|
||||
"challenge_ts",
|
||||
"hostname",
|
||||
"error-codes"
|
||||
})
|
||||
public class GoogleResponse {
|
||||
|
||||
@JsonProperty("success")
|
||||
private boolean success;
|
||||
|
||||
@JsonProperty("challenge_ts")
|
||||
private String challengeTs;
|
||||
|
||||
@JsonProperty("hostname")
|
||||
private String hostname;
|
||||
|
||||
@JsonProperty("error-codes")
|
||||
private ErrorCode[] errorCodes;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasClientError() {
|
||||
ErrorCode[] errors = getErrorCodes();
|
||||
if(errors == null) {
|
||||
return false;
|
||||
}
|
||||
for(ErrorCode error : errors) {
|
||||
switch(error) {
|
||||
case InvalidResponse:
|
||||
case MissingResponse:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static enum ErrorCode {
|
||||
MissingSecret, InvalidSecret,
|
||||
MissingResponse, InvalidResponse;
|
||||
|
||||
private static Map<String, ErrorCode> errorsMap = new HashMap<>(4);
|
||||
|
||||
static {
|
||||
errorsMap.put("missing-input-secret", MissingSecret);
|
||||
errorsMap.put("invalid-input-secret", InvalidSecret);
|
||||
errorsMap.put("missing-input-response", MissingResponse);
|
||||
errorsMap.put("invalid-input-response", InvalidResponse);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ErrorCode forValue(String value) {
|
||||
return errorsMap.get(value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getChallengeTs() {
|
||||
return challengeTs;
|
||||
}
|
||||
|
||||
public void setChallengeTs(String challengeTs) {
|
||||
this.challengeTs = challengeTs;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public ErrorCode[] getErrorCodes() {
|
||||
return errorCodes;
|
||||
}
|
||||
|
||||
public void setErrorCodes(ErrorCode[] errorCodes) {
|
||||
this.errorCodes = errorCodes;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class HtmlPageContent {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String page;
|
||||
private String community;
|
||||
private String content;
|
||||
|
||||
public HtmlPageContent() {
|
||||
}
|
||||
|
||||
public HtmlPageContent(String page, String community, String content) {
|
||||
this.page = page;
|
||||
this.community = community;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(String community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class HtmlPageContentResponse {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private Page page;
|
||||
private Community community;
|
||||
private String content;
|
||||
|
||||
public HtmlPageContentResponse() {
|
||||
}
|
||||
|
||||
public HtmlPageContentResponse(HtmlPageContent htmlPageContent) {
|
||||
this.id = htmlPageContent.getId();
|
||||
this.content = htmlPageContent.getContent();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Page getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Page page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public Community getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(Community community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
|
@ -19,10 +19,11 @@ public class Layout {
|
|||
private Links links;
|
||||
private Buttons buttons;
|
||||
|
||||
private String portalPid;
|
||||
|
||||
public Layout() { }
|
||||
|
||||
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons) {
|
||||
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons, String portalPid) {
|
||||
this.id = id;
|
||||
this.mainColor = mainColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
|
@ -30,6 +31,8 @@ public class Layout {
|
|||
this.box = box;
|
||||
this.links = links;
|
||||
this.buttons = buttons;
|
||||
|
||||
this.portalPid = portalPid;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -87,4 +90,12 @@ public class Layout {
|
|||
public void setButtons(Buttons buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public String getPortalPid() {
|
||||
return portalPid;
|
||||
}
|
||||
|
||||
public void setPortalPid(String portalPid) {
|
||||
this.portalPid = portalPid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ public class Notifications {
|
|||
Boolean notifyForNewManagers = true;
|
||||
Boolean notifyForNewSubscribers = true;
|
||||
String managerEmail;
|
||||
String communityPid;
|
||||
String portalPid;
|
||||
public Notifications(){
|
||||
|
||||
}
|
||||
public Notifications(String managerEmail, String communityPid){
|
||||
public Notifications(String managerEmail, String portalPid){
|
||||
this();
|
||||
this.communityPid = communityPid;
|
||||
this.portalPid = portalPid;
|
||||
this.managerEmail = managerEmail;
|
||||
}
|
||||
public String getId() {
|
||||
|
@ -54,12 +54,12 @@ public class Notifications {
|
|||
this.managerEmail = managerEmail;
|
||||
}
|
||||
|
||||
public String getCommunityPid() {
|
||||
return communityPid;
|
||||
public String getPortalPid() {
|
||||
return portalPid;
|
||||
}
|
||||
|
||||
public void setCommunityPid(String communityPid) {
|
||||
this.communityPid = communityPid;
|
||||
public void setPortalPid(String portalPid) {
|
||||
this.portalPid = portalPid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ public class Notifications {
|
|||
", notifyForNewManagers=" + notifyForNewManagers +
|
||||
", notifyForNewSubscribers=" + notifyForNewSubscribers +
|
||||
", managerEmail='" + managerEmail + '\'' +
|
||||
", communityPid='" + communityPid + '\'' +
|
||||
", portalPid='" + portalPid + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Page {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String route;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<String> entities;
|
||||
private Boolean connect;
|
||||
private Boolean communities;
|
||||
private Boolean openaire;
|
||||
|
||||
// Posiitions where help texts are allowed for this page
|
||||
private Boolean top;
|
||||
private Boolean bottom;
|
||||
private Boolean left;
|
||||
private Boolean right;
|
||||
|
||||
public Page() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
public void setRoute(String route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<String> getEntities() { return entities; }
|
||||
|
||||
public void setEntities(List<String> entities) { this.entities = entities; }
|
||||
|
||||
public Boolean getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(Boolean connect) { this.connect = connect; }
|
||||
|
||||
public Boolean getCommunities() {
|
||||
return communities;
|
||||
}
|
||||
|
||||
public void setCommunities(Boolean communities) {
|
||||
this.communities = communities;
|
||||
}
|
||||
|
||||
public Boolean getOpenaire() {
|
||||
return openaire;
|
||||
}
|
||||
|
||||
public void setOpenaire(Boolean openaire) {
|
||||
this.openaire = openaire;
|
||||
}
|
||||
|
||||
public Boolean getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(Boolean top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public Boolean getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public void setBottom(Boolean bottom) {
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public Boolean getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(Boolean left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public Boolean getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(Boolean right) {
|
||||
this.right = right;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class PageHelpContent {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String page;
|
||||
private String community;
|
||||
private String placement;
|
||||
private int order;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
private boolean isPriorTo = false;
|
||||
|
||||
public PageHelpContent() {}
|
||||
|
||||
public PageHelpContent(String page, String community, String placement, int order, String content, boolean isActive, boolean isPriorTo) {
|
||||
this.page = page;
|
||||
this.community = community;
|
||||
this.placement = placement;
|
||||
this.order = order;
|
||||
this.content = content;
|
||||
this.isActive = isActive;
|
||||
this.isPriorTo = isPriorTo;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(String page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(String community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getPlacement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
public void setPlacement(String placement) {
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public boolean getIsPriorTo() { return isPriorTo; }
|
||||
|
||||
public void setIsPriorTo(boolean isPriorTo) { this.isPriorTo = isPriorTo; }
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class PageHelpContentResponse {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private Page page;
|
||||
private Community community;
|
||||
private String placement;
|
||||
private int order;
|
||||
private String content;
|
||||
private boolean isActive = true;
|
||||
private boolean isPriorTo = false;
|
||||
|
||||
public PageHelpContentResponse() {
|
||||
}
|
||||
|
||||
public PageHelpContentResponse(PageHelpContent pageHelpContent) {
|
||||
this.id = pageHelpContent.getId();
|
||||
this.placement = pageHelpContent.getPlacement();
|
||||
this.order = pageHelpContent.getOrder();
|
||||
this.content = pageHelpContent.getContent();
|
||||
this.isActive = pageHelpContent.getIsActive();
|
||||
this.isPriorTo = pageHelpContent.getIsPriorTo();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Page getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Page page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public Community getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
||||
public void setCommunity(Community community) {
|
||||
this.community = community;
|
||||
}
|
||||
|
||||
public String getPlacement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
public void setPlacement(String placement) {
|
||||
this.placement = placement;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public boolean getIsPriorTo() { return isPriorTo; }
|
||||
|
||||
public void setIsPriorTo(boolean isPriorTo) { this.isPriorTo = isPriorTo; }
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Question {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String question;
|
||||
private String answer;
|
||||
private Date date = new Date();
|
||||
private boolean isActive = true;
|
||||
private Float weight;
|
||||
private int hitCount = 0;
|
||||
private List<String> topics;
|
||||
|
||||
public Question() {
|
||||
}
|
||||
|
||||
/*
|
||||
public Question(String question, String answer, boolean isActive, Float weight, List<String> topics) {
|
||||
this.question = question;
|
||||
this.answer = answer;
|
||||
this.isActive = isActive;
|
||||
this.weight = weight;
|
||||
this.topics = topics;
|
||||
this.hitCount = 0;
|
||||
this.isActive = true;
|
||||
}
|
||||
*/
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public int getHitCount() {
|
||||
return hitCount;
|
||||
}
|
||||
|
||||
public void setHitCount(int hitCount) {
|
||||
this.hitCount = hitCount;
|
||||
}
|
||||
|
||||
public List<String> getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
public void setTopics(List<String> topics) {
|
||||
this.topics = topics;
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
hitCount++;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class QuestionResponse {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String question;
|
||||
private String answer;
|
||||
private Date date = new Date();
|
||||
private boolean isActive = true;
|
||||
private Float weight;
|
||||
private int hitCount = 0;
|
||||
private List<Topic> topics;
|
||||
|
||||
public QuestionResponse() {
|
||||
}
|
||||
|
||||
public QuestionResponse(Question question) {
|
||||
this.id = question.getId();
|
||||
this.question = question.getQuestion();
|
||||
this.answer = question.getAnswer();
|
||||
this.date = question.getDate();
|
||||
this.isActive = question.getIsActive();
|
||||
this.weight = question.getWeight();
|
||||
this.hitCount = question.getHitCount();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public boolean getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(boolean isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public int getHitCount() {
|
||||
return hitCount;
|
||||
}
|
||||
|
||||
public void setHitCount(int hitCount) {
|
||||
this.hitCount = hitCount;
|
||||
}
|
||||
|
||||
public List<Topic> getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
public void setTopics(List<Topic> topics) {
|
||||
this.topics = topics;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Topic {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private Date date = new Date();
|
||||
private Float weight;
|
||||
private String questionOrder;
|
||||
|
||||
public Topic() {
|
||||
}
|
||||
|
||||
/*
|
||||
public Topic(String name, String description, Float weight, String questionOrder) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.weight = weight;
|
||||
this.questionOrder = questionOrder;
|
||||
}
|
||||
*/
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getQuestionOrder() {
|
||||
return questionOrder;
|
||||
}
|
||||
|
||||
public void setQuestionOrder(String questionOrder) {
|
||||
this.questionOrder = questionOrder;
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TopicResponse {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private Date date = new Date();
|
||||
private Float weight;
|
||||
private String questionOrder;
|
||||
private List<Question> questions;
|
||||
|
||||
|
||||
public TopicResponse() {
|
||||
}
|
||||
|
||||
public TopicResponse(Topic topic) {
|
||||
this.id = topic.getId();
|
||||
this.name = topic.getName();
|
||||
this.description = topic.getDescription();
|
||||
this.date = topic.getDate();
|
||||
this.weight = topic.getWeight();
|
||||
this.questionOrder = topic.getQuestionOrder();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Float getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Float weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getQuestionOrder() {
|
||||
return questionOrder;
|
||||
}
|
||||
|
||||
public void setQuestionOrder(String questionOrder) {
|
||||
this.questionOrder = questionOrder;
|
||||
}
|
||||
|
||||
public List<Question> getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
public void setQuestions(List<Question> questions) {
|
||||
this.questions = questions;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
package eu.dnetlib.uoaadmintools.entities.curator;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoaadmintools.entities.Affiliation;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
|
@ -1,4 +1,6 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
package eu.dnetlib.uoaadmintools.entities.curator;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Affiliation;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.uoaadmintools.entities;
|
||||
package eu.dnetlib.uoaadmintools.entities.subscriber;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
@ -9,14 +9,14 @@ import java.util.List;
|
|||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
public class CommunitySubscribers {
|
||||
public class PortalSubscribers {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
private String pid;
|
||||
private List<Subscriber> subscribers = new ArrayList<Subscriber>();
|
||||
private List<Subscriber> pendingSubscribers = new ArrayList<Subscriber>();
|
||||
public CommunitySubscribers(String pid){
|
||||
public PortalSubscribers(String pid){
|
||||
this.pid=pid;
|
||||
}
|
||||
public String getId() {
|
||||
|
@ -45,7 +45,7 @@ public class CommunitySubscribers {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommunitySubscribers{" +
|
||||
return "PortalSubscribers{" +
|
||||
"id='" + id + '\'' +
|
||||
", pid='" + pid + '\'' +
|
||||
", subscribers=" + subscribers +
|
|
@ -0,0 +1,46 @@
|
|||
package eu.dnetlib.uoaadmintools.entities.subscriber;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
public class Subscriber {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
|
||||
private String email;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Subscriber() {}
|
||||
public Subscriber(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Subscriber{" +
|
||||
"id='" + id + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.handlers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/3/2018.
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class ContentNotFoundException extends RuntimeException {
|
||||
public ContentNotFoundException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package eu.dnetlib.uoaadmintools.handlers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.responses.ExceptionResponse;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.responses.ExceptionResponse;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -9,50 +10,45 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
|
|||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionsHandler {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public ResponseEntity<ExceptionResponse> invalidInput(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Validation Error");
|
||||
response.setErrorMessage("Invalid inputs.");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("invalidInput exception");
|
||||
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@ExceptionHandler(ContentNotFoundException.class)
|
||||
public ResponseEntity<ErrorDetails> contentNotFound(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("No content found");
|
||||
response.setErrorMessage(ex.getMessage());
|
||||
response.setErrors(ex.getMessage());
|
||||
ErrorDetails errorDetails = new ErrorDetails(new Date(),ex.getMessage(),ex.getMessage());
|
||||
log.debug("contentNotFound exception" + response.getErrorCode()+ " "+response.getErrorMessage());
|
||||
|
||||
return new ResponseEntity<ErrorDetails>(errorDetails, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@ExceptionHandler(NullPointerException.class)
|
||||
public ResponseEntity<ExceptionResponse> nullPointerException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Null pointer Exception");
|
||||
response.setErrorMessage("Null pointer Exception");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("nullPointerException exception");
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(InvalidReCaptchaException.class)
|
||||
public ResponseEntity<ExceptionResponse> invalidReCaptchaException(Exception ex) {
|
||||
ExceptionResponse response = new ExceptionResponse();
|
||||
response.setErrorCode("Invalid ReCaptcha Exception");
|
||||
response.setErrorMessage("Invalid ReCaptcha Exception");
|
||||
response.setErrors(ex.getMessage());
|
||||
log.debug("invalidReCaptchaException exception");
|
||||
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// @ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
// public ResponseEntity<ExceptionResponse> invalidInput(Exception ex) {
|
||||
// ExceptionResponse response = new ExceptionResponse();
|
||||
// response.setErrorCode("Validation Error");
|
||||
// response.setErrorMessage("Invalid inputs.");
|
||||
// response.setErrors(ex.getMessage());
|
||||
// log.debug("invalidInput exception");
|
||||
//
|
||||
// return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
// }
|
||||
// @ExceptionHandler(ContentNotFoundException2.class)
|
||||
// public ResponseEntity<ExceptionResponse> contentNotFound(Exception ex) {
|
||||
// ExceptionResponse response = new ExceptionResponse();
|
||||
// response.setErrorCode("No content found");
|
||||
// response.setErrorMessage(ex.getMessage());
|
||||
// response.setErrors(ex.getMessage());
|
||||
// log.debug("contentNotFound exception" + response.getErrorCode()+ " "+response.getErrorMessage());
|
||||
// return new ResponseEntity<ExceptionResponse>(response, HttpStatus.NOT_FOUND);
|
||||
// }
|
||||
// @ExceptionHandler(NullPointerException.class)
|
||||
// public ResponseEntity<ExceptionResponse> nullPointerException(Exception ex) {
|
||||
// ExceptionResponse response = new ExceptionResponse();
|
||||
// response.setErrorCode("Null pointer Exception");
|
||||
// response.setErrorMessage("Null pointer Exception");
|
||||
// response.setErrors(ex.getMessage());
|
||||
// log.debug("nullPointerException exception");
|
||||
// return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
// }
|
||||
// @ExceptionHandler(InvalidReCaptchaException.class)
|
||||
// public ResponseEntity<ExceptionResponse> invalidReCaptchaException(Exception ex) {
|
||||
// ExceptionResponse response = new ExceptionResponse();
|
||||
// response.setErrorCode("Invalid ReCaptcha Exception");
|
||||
// response.setErrorMessage("Invalid ReCaptcha Exception");
|
||||
// response.setErrors(ex.getMessage());
|
||||
// log.debug("invalidReCaptchaException exception");
|
||||
// return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.handlers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
|
||||
public class InvalidReCaptchaException extends RuntimeException{
|
||||
public InvalidReCaptchaException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools.recaptcha;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.GoogleConfig;
|
||||
import eu.dnetlib.uoaadmintools.entities.GoogleResponse;
|
||||
import eu.dnetlib.uoaadmintools.handlers.InvalidReCaptchaException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.spi.ErrorCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@Configurable
|
||||
public class VerifyRecaptcha {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private RestOperations restTemplate;
|
||||
|
||||
@Autowired
|
||||
private GoogleConfig googleConfig;
|
||||
|
||||
private static Pattern RESPONSE_PATTERN = Pattern.compile("[A-Za-z0-9_-]+");
|
||||
|
||||
@Bean
|
||||
public RestOperations restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void processResponse(String response) throws InvalidReCaptchaException{
|
||||
if(!responseSanityCheck(response)) {
|
||||
InvalidReCaptchaException e = new InvalidReCaptchaException("Response contains invalid characters");
|
||||
log.error("Response contains invalid characters", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
URI verifyUri = URI.create(String.format(
|
||||
"https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s",
|
||||
googleConfig.getSecret(), response));
|
||||
|
||||
GoogleResponse googleResponse = restTemplate.getForObject(verifyUri, GoogleResponse.class);
|
||||
|
||||
if(!googleResponse.isSuccess()) {
|
||||
log.error("Has client error:"+googleResponse.hasClientError());
|
||||
InvalidReCaptchaException e = new InvalidReCaptchaException("reCaptcha was not successfully validated");
|
||||
log.error("reCaptcha was not successfully validated", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean responseSanityCheck(String response) {
|
||||
return StringUtils.hasLength(response) && RESPONSE_PATTERN.matcher(response).matches();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package eu.dnetlib.uoaadmintools.services;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.LayoutDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LayoutService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private LayoutDAO layoutDAO;
|
||||
|
||||
public void updatePid(String old_pid, String new_pid) {
|
||||
Layout layout = layoutDAO.findByPortalPid(old_pid);
|
||||
layout.setPortalPid(new_pid);
|
||||
layoutDAO.save(layout);
|
||||
}
|
||||
|
||||
public void deleteByPid(String pid) {
|
||||
// TODO check maybe we can delete by portalId without find first
|
||||
Layout layout = layoutDAO.findByPortalPid(pid);
|
||||
if(layout != null) {
|
||||
layoutDAO.delete(layout.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public Layout findByPid(String pid) {
|
||||
return layoutDAO.findByPortalPid(pid);
|
||||
}
|
||||
|
||||
public Layout save(Layout layout) {
|
||||
return layoutDAO.save(layout);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.dnetlib.uoaadmintools.services;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.StatisticsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class StatisticsService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private StatisticsDAO statisticsDAO;
|
||||
|
||||
public void updatePid(String old_pid, String new_pid) {
|
||||
Statistics statistics = statisticsDAO.findByPid(old_pid);
|
||||
statistics.setPid(new_pid);
|
||||
statisticsDAO.save(statistics);
|
||||
}
|
||||
|
||||
public void createPortalStatistics(String pid) {
|
||||
Statistics statistics = new Statistics(pid);
|
||||
statisticsDAO.save(statistics);
|
||||
}
|
||||
|
||||
public void deleteByPid(String pid) {
|
||||
Statistics stats = statisticsDAO.findByPid(pid);
|
||||
if(stats != null) {
|
||||
statisticsDAO.delete(stats.getId());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.dnetlib.uoaadmintools.services;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.PortalSubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.subscriber.PortalSubscribers;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SubscriberService {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PortalSubscribersDAO portalSubscribersDAO;
|
||||
|
||||
public void updatePid(String old_pid, String new_pid) {
|
||||
PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(old_pid);
|
||||
portalSubscribers.setPid(new_pid);
|
||||
portalSubscribersDAO.save(portalSubscribers);
|
||||
}
|
||||
|
||||
public void createPortalSubscribers(String pid) {
|
||||
PortalSubscribers portalSubscribers = new PortalSubscribers(pid);
|
||||
portalSubscribersDAO.save(portalSubscribers);
|
||||
}
|
||||
|
||||
public void deletePortalSubscribers(String pid) {
|
||||
PortalSubscribers portalSubscribers = portalSubscribersDAO.findByPid(pid);
|
||||
if(portalSubscribers != null) {
|
||||
portalSubscribersDAO.delete(portalSubscribers.getId());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
#dev
|
||||
admintool.security.userInfoUrl = http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
|
||||
admintool.security.originServer = .di.uoa.gr
|
||||
admintool.security.postsAllowed = /contact,/contact/
|
||||
admintool.mail.host = smtp.gmail.com
|
||||
admintool.mail.port = 587
|
||||
admintool.mail.auth = true
|
||||
admintool.mail.from = openaire.test@gmail.com
|
||||
admintool.mail.username = openaire.test@gmail.com
|
||||
admintool.mail.password =
|
||||
admintool.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
|
||||
admintool.mongodb.host=localhost
|
||||
admintool.mongodb.port=27017
|
||||
admintool.mongodb.database=openaire_admin
|
||||
#admintool.security.userInfoUrl = http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
|
||||
#admintool.security.originServer = .di.uoa.gr
|
||||
#admintool.security.postsAllowed = /contact,/contact/
|
||||
#admintool.mail.host = smtp.gmail.com
|
||||
#admintool.mail.port = 587
|
||||
#admintool.mail.auth = true
|
||||
#admintool.mail.from = openaire.test@gmail.com
|
||||
#admintool.mail.username = openaire.test@gmail.com
|
||||
#admintool.mail.password =
|
||||
#admintool.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
|
||||
#admintool.mongodb.host=localhost
|
||||
#admintool.mongodb.port=27017
|
||||
#admintool.mongodb.database=openaire_admin_beta_20191105
|
||||
|
||||
#beta
|
||||
#admintool.security.userInfoUrl = https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CommunityTests {
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String id="egi";
|
||||
Community community = communityDAO.findByPid(id);
|
||||
// community.getPages()
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void remove() {
|
||||
List <Community> communities = communityDAO.findAll();
|
||||
for(Community com : communities){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import eu.dnetlib.uoaadmintools.entities.Page;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
|||
public class NotificationsTests {
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
private PortalDAO communityDAO;
|
||||
|
||||
|
||||
@Autowired
|
||||
|
@ -27,19 +27,19 @@ public class NotificationsTests {
|
|||
public void test() {
|
||||
String mail = "sofie.mpl@gmail.com";
|
||||
String id="ni";
|
||||
System.out.println(notificationsDAO.findByCommunityPid(id));
|
||||
System.out.println(notificationsDAO.findByPortalPid(id));
|
||||
|
||||
Notifications notifications = notificationsDAO.findByManagerEmailAndCommunityPid(mail , id);
|
||||
Notifications notifications = notificationsDAO.findByManagerEmailAndPortalPid(mail , id);
|
||||
if(notifications == null){
|
||||
notifications = new Notifications();
|
||||
notifications.setCommunityPid(id);
|
||||
notifications.setPortalPid(id);
|
||||
notifications.setManagerEmail(mail);
|
||||
}
|
||||
notifications.setNotifyForNewManagers(false);
|
||||
notifications.setNotifyForNewSubscribers(false);
|
||||
|
||||
notificationsDAO.save(notifications);
|
||||
System.out.println(notificationsDAO.findByCommunityPid(id));
|
||||
System.out.println(notificationsDAO.findByPortalPid(id));
|
||||
|
||||
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class NotificationsTests {
|
|||
|
||||
@Test
|
||||
public void remove() {
|
||||
List <Community> communities = communityDAO.findAll();
|
||||
for(Community com : communities){
|
||||
List <Notifications> notificationsList = notificationsDAO.findByCommunityPid(com.getPid());
|
||||
List <Portal> communities = communityDAO.findAll();
|
||||
for(Portal com : communities){
|
||||
List <Notifications> notificationsList = notificationsDAO.findByPortalPid(com.getPid());
|
||||
for(Notifications notifications:notificationsList){
|
||||
// notificationsDAO.delete(notifications.getId());
|
||||
}
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.dao.*;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class UoaAdminToolsApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
private PortalDAO communityDAO;
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
|
@ -40,7 +35,7 @@ public class UoaAdminToolsApplicationTests {
|
|||
private SubscriberDAO subscriberDAO;
|
||||
|
||||
@Autowired
|
||||
private CommunitySubscribersDAO communitySubscribersDAO;
|
||||
private PortalSubscribersDAO portalSubscribersDAO;
|
||||
|
||||
/*
|
||||
|
||||
|
@ -205,22 +200,22 @@ public class UoaAdminToolsApplicationTests {
|
|||
// for(Community c:communities){
|
||||
// String pid = c.getPid();
|
||||
// System.out.println("Community :" +pid);
|
||||
// CommunitySubscribers communitySubscribers= communitySubscribersDAO.findByPid(pid);
|
||||
// PortalSubscribers communitySubscribers= portalSubscribersDAO.findByPid(pid);
|
||||
// if(communitySubscribers == null){
|
||||
// communitySubscribers = new CommunitySubscribers(pid);
|
||||
// communitySubscribersDAO.save(communitySubscribers);
|
||||
// communitySubscribers = new PortalSubscribers(pid);
|
||||
// portalSubscribersDAO.save(communitySubscribers);
|
||||
// System.out.println("Saved community subscribers for :" +pid);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPages() {
|
||||
|
||||
System.out.println( pageDAO.findByConnect(false).size());
|
||||
for (Page p: pageDAO.findByConnect(false) ){
|
||||
System.out.println(p.getRoute()+" Con: "+p.getConnect()+" Op: "+p.getOpenaire());
|
||||
}
|
||||
}
|
||||
// @Test
|
||||
// public void testPages() {
|
||||
//
|
||||
// System.out.println( pageDAO.findByConnect(false).size());
|
||||
// for (Page p: pageDAO.findByConnect(false) ){
|
||||
// System.out.println(p.getRoute()+" Con: "+p.getConnect()+" Op: "+p.getOpenaire());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*Authentication???
|
||||
// Authentication???
|
||||
|
||||
// 1. copy database with name "test" in folder "/home/konstantina/mongo_backups"
|
||||
mongodump --db test --out /home/konstantina/mongo_backups
|
||||
// mongodump --db test --out /home/konstantina/mongo_backups
|
||||
|
||||
// 2. paste database with name "test", which is in folder "/home/konstantina/mongo_backups/test", into database with name "test2" | Drop collections if test2 already exists
|
||||
mongorestore --db test2 --drop /home/konstantina/mongo_backups/test
|
||||
// mongorestore --db test2 --drop /home/konstantina/mongo_backups/test
|
||||
|
||||
// Be careful with function parameters: names of dbs, name of community
|
||||
// Be careful with function parameters: names of dbs, name of portal
|
||||
// 3. If needed run init script
|
||||
|
||||
// 4. Run synchronize_dbs.js
|
||||
|
||||
// 5. Run migrateCommunityIn_db.js
|
||||
*/
|
||||
|
||||
|
||||
//version compatibility: 1.1.1-SNAPSHOT
|
||||
print("synchronization of DBs script running...");
|
||||
|
@ -36,16 +36,16 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
//prod_entityId = prod_db.entity.find( { pid: beta_entity.pid }).map( function(prod_entity) { return prod_entity._id.str; } ).toString();
|
||||
var prod_entity_id = prod_db.entity.findOne( { pid: beta_entity.pid })._id.str;
|
||||
|
||||
beta_db.community.find().forEach(function(beta_community){
|
||||
var prod_community = prod_db.community.findOne( { pid: beta_community.pid } );
|
||||
if(prod_community) {
|
||||
var prod_community_entities = prod_community.entities;
|
||||
prod_community_entities[prod_entity_id] = beta_community.entities[beta_entity._id.str];
|
||||
prod_db.community.update({ pid: prod_community.pid }, {$set: {entities: prod_community_entities}})
|
||||
beta_db.portal.find().forEach(function(beta_portal){
|
||||
var prod_portal = prod_db.portal.findOne( { pid: beta_portal.pid } );
|
||||
if(prod_portal) {
|
||||
var prod_portal_entities = prod_portal.entities;
|
||||
prod_portal_entities[prod_entity_id] = beta_portal.entities[beta_entity._id.str];
|
||||
prod_db.portal.update({ pid: prod_portal.pid }, {$set: {entities: prod_portal_entities}})
|
||||
|
||||
print("Entity was created for community with pid: "+prod_community.pid+" that exists on production db: "+production_db_name);
|
||||
print("Entity was created for portal with pid: "+prod_portal.pid+" that exists on production db: "+production_db_name);
|
||||
} else {
|
||||
print("\nERROR: Community with pid: "+ beta_community.pid+" does not exist on production db: "+production_db_name+"\n");
|
||||
print("\nERROR: Portal with pid: "+ beta_portal.pid+" does not exist on production db: "+production_db_name+"\n");
|
||||
}
|
||||
});
|
||||
print("");
|
||||
|
@ -57,7 +57,7 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
// synchronize pages
|
||||
beta_db.page.find().forEach(function(beta_page){
|
||||
//var prod_pageId = prod_db.page.find( { route: beta_page.route }).map( function(prod_page) { return prod_page._id.str; } ).toString();
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route });//._id.str;
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route, portalType: beta_page.portalType });//._id.str;
|
||||
if(!prod_page) {
|
||||
|
||||
var prod_page_entities = [];
|
||||
|
@ -78,31 +78,33 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
}
|
||||
})
|
||||
|
||||
prod_db.page.save({"name": beta_page.name, "route": beta_page.route, "type": beta_page.type, "connect": beta_page.connect, "openaire": beta_page.openaire, "entities" : prod_page_entities});
|
||||
prod_db.page.save({
|
||||
"name": beta_page.name,
|
||||
"route": beta_page.route,
|
||||
"type": beta_page.type,
|
||||
"portalType": beta_page.portalType,
|
||||
"entities" : prod_page_entities,
|
||||
"top": beta_page.top, "bottom": beta_page.bottom, "left": beta_page.left, "right": beta_page.right
|
||||
});
|
||||
|
||||
print("Page: "+beta_page.name+" is created in "+production_db_name+" database");
|
||||
|
||||
// synchronize this page and its contents for all available communities
|
||||
//prod_pageId = prod_db.page.find( { route: beta_page.route }).map( function(prod_page) { return prod_page._id.str; } ).toString();
|
||||
var prod_pageId = prod_db.page.findOne( { route: beta_page.route })._id.str;
|
||||
beta_db.community.find().forEach(function(beta_community){
|
||||
var prod_community = prod_db.community.findOne( { pid: beta_community.pid } );
|
||||
if(prod_community) {
|
||||
var prod_community_pages = prod_community.pages;
|
||||
prod_community_pages[prod_pageId] = beta_community.pages[beta_page._id.str];
|
||||
prod_db.community.update({ pid: prod_community.pid }, {$set: {pages: prod_community_pages}})
|
||||
var prod_pageId = prod_db.page.findOne( { route: beta_page.route, portalType: beta_page.portalType })._id.str;
|
||||
beta_db.portal.find({type: beta_page.portalType}).forEach(function(beta_portal){
|
||||
var prod_portal = prod_db.portal.findOne( { pid: beta_portal.pid } );
|
||||
if(prod_portal) {
|
||||
var prod_portal_pages = prod_portal.pages;
|
||||
prod_portal_pages[prod_pageId] = beta_portal.pages[beta_page._id.str];
|
||||
prod_db.portal.update({ pid: prod_portal.pid }, {$set: {pages: prod_portal_pages}})
|
||||
|
||||
print("Page was created for community: "+prod_community.name+" that exists on production");
|
||||
print("Page was created for portal: "+prod_portal.name+" that exists on production");
|
||||
|
||||
beta_db.pageHelpContent.find({community: beta_community._id.str, page: beta_page._id.str}).forEach(function(beta_pageHelpContent) {
|
||||
prod_db.pageHelpContent.save({ "page" : prod_pageId, "community" : prod_community._id.str, "content" : beta_pageHelpContent.content, "placement": beta_pageHelpContent.placement, "order": beta_pageHelpContent.order, "isActive": beta_pageHelpContent.isActive, "isPriorTo": beta_pageHelpContent.isPriorTo });
|
||||
beta_db.pageHelpContent.find({portal: beta_portal._id.str, page: beta_page._id.str}).forEach(function(beta_pageHelpContent) {
|
||||
prod_db.pageHelpContent.save({ "page" : prod_pageId, "portal" : prod_portal._id.str, "content" : beta_pageHelpContent.content, "placement": beta_pageHelpContent.placement, "order": beta_pageHelpContent.order, "isActive": beta_pageHelpContent.isActive, "isPriorTo": beta_pageHelpContent.isPriorTo });
|
||||
});
|
||||
print("PageHelpContents were created for community: "+prod_community.name+" that exists on production");
|
||||
|
||||
beta_db.htmlPageContent.find({community: beta_community._id.str, page: beta_page._id.str}).forEach(function(beta_htmlPageContent) {
|
||||
prod_db.htmlPageContent.save({ "page" : prod_pageId, "community" : prod_community._id.str, "content" : beta_htmlPageContent.content });
|
||||
});
|
||||
print("HtmlPageContents were created for community: "+prod_community.name+" that exists on production");
|
||||
print("PageHelpContents were created for portal: "+prod_portal.name+" that exists on production");
|
||||
}
|
||||
print("");
|
||||
});
|
||||
|
@ -115,7 +117,7 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
// synchronize divIds
|
||||
beta_db.divId.find().forEach(function(beta_divId){
|
||||
//var prod_divIdId = prod_db.divId.find( { name: beta_divId.name }).map( function(prod_divId) { return prod_divId._id.str; } ).toString();
|
||||
var prod_divId = prod_db.divId.findOne( { name: beta_divId.name });//._id.str;
|
||||
var prod_divId = prod_db.divId.findOne( { name: beta_divId.name, portalType: beta_divId.portalType });//._id.str;
|
||||
if(!prod_divId) {
|
||||
var prod_divId_pages = [];
|
||||
beta_divId.pages.forEach(function(beta_divId_page) {
|
||||
|
@ -124,7 +126,7 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
var beta_divIdPage = beta_db.page.findOne( { _id: beta_divId_page_ObjectId });//.route;
|
||||
if(beta_divIdPage) {
|
||||
//var prod_divIdPage_id = prod_db.page.find( { route: beta_divIdPage_route } ).map(function(page) { return page._id.str; }).toString();
|
||||
var prod_divIdPage = prod_db.page.findOne( { route: beta_divIdPage.route });//._id.str;
|
||||
var prod_divIdPage = prod_db.page.findOne( { route: beta_divIdPage.route, portalType: beta_divIdPage.portalType });//._id.str;
|
||||
if(prod_divIdPage) {
|
||||
prod_divId_pages.push(prod_divIdPage._id.str);
|
||||
} else {
|
||||
|
@ -134,20 +136,20 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
print("\nERROR: Page with id: "+beta_divId_page+" (of divId: "+beta_divId.name+") does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
})
|
||||
prod_db.divId.save({"name": beta_divId.name, "pages" : prod_divId_pages});
|
||||
prod_db.divId.save({"name": beta_divId.name, "pages" : prod_divId_pages, "portalType": beta_divId.portalType});
|
||||
|
||||
print("DivId: "+beta_divId.name+" is created in "+production_db_name+" database");
|
||||
|
||||
// synchronize this divId's contents for all available communities
|
||||
//prod_divIdId = prod_db.divId.find( { name: beta_divId.name }).map( function(prod_divId) { return prod_divId._id.str; } ).toString();
|
||||
var prod_divIdId = prod_db.divId.findOne( { name: beta_divId.name })._id.str;
|
||||
beta_db.community.find().forEach(function(beta_community){
|
||||
var prod_community = prod_db.community.findOne( { pid: beta_community.pid } );
|
||||
if(prod_community) {
|
||||
beta_db.divHelpContent.find({community: beta_community._id.str, divId: beta_divId._id.str}).forEach(function(beta_divHelpContent) {
|
||||
prod_db.divHelpContent.save({ "divId" : prod_divIdId, "community" : prod_community._id.str, "content" : beta_divHelpContent.content, "isActive" : beta_divHelpContent.isActive });
|
||||
var prod_divIdId = prod_db.divId.findOne( { name: beta_divId.name, portalType: beta_divId.portalType })._id.str;
|
||||
beta_db.portal.find({type: beta_divId.portalType}).forEach(function(beta_portal){
|
||||
var prod_portal = prod_db.portal.findOne( { pid: beta_portal.pid } );
|
||||
if(prod_portal) {
|
||||
beta_db.divHelpContent.find({portal: beta_portal._id.str, divId: beta_divId._id.str}).forEach(function(beta_divHelpContent) {
|
||||
prod_db.divHelpContent.save({ "divId" : prod_divIdId, "portal" : prod_portal._id.str, "content" : beta_divHelpContent.content, "isActive" : beta_divHelpContent.isActive });
|
||||
});
|
||||
print("DivHelpContents were created for community: "+prod_community.name+" that exists on production");
|
||||
print("DivHelpContents were created for portal: "+prod_portal.name+" that exists on production");
|
||||
}
|
||||
});
|
||||
print("");
|
||||
|
@ -158,5 +160,5 @@ function keep_Beta_Production_DBs_synchronized(beta_db_name, production_db_name)
|
|||
|
||||
}
|
||||
|
||||
keep_Beta_Production_DBs_synchronized("openaire_admin_copy", "openaire_admin_prod");
|
||||
keep_Beta_Production_DBs_synchronized("admin_beta_test_migration", "admin_prod_test_migration");
|
||||
|
||||
|
|
378
update_db.js
378
update_db.js
|
@ -1429,162 +1429,271 @@ function addSearchResearchOutcomesPages() {
|
|||
softwareId = db.entity.find( { pid: "software" }).map( function(entity) { return entity._id.str; } ).toString()
|
||||
orpId = db.entity.find( { pid: "orp" }).map( function(entity) { return entity._id.str; } ).toString();
|
||||
|
||||
searchResearchOutcomesId = db.page.insertOne({"name" : "Search Research Outcomes", "route" : "/search/find/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId]}).insertedId.str;
|
||||
avancedSearchResearchOutcomesId = db.page.insertOne({"name" : "Advanced Search Research Outcomes", "route" : "/search/advanced/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId]}).insertedId.str;
|
||||
searchResearchOutcomesId = db.page.insertOne({"name" : "Search Research Outcomes", "route" : "/search/find/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
||||
avancedSearchResearchOutcomesId = db.page.insertOne({"name" : "Advanced Search Research Outcomes", "route" : "/search/advanced/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
||||
|
||||
print("Creating Search Research Outcomes page with id " + searchResearchOutcomesId);
|
||||
print("Creating Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId);
|
||||
|
||||
communities = db.community.find().map( function(community) { return community; } );
|
||||
for (var i = 0; i < communities.length; i++) {
|
||||
community_pages = communities[i].pages;
|
||||
|
||||
community_pages[searchResearchOutcomesId] = true;
|
||||
community_pages[avancedSearchResearchOutcomesId] = true;
|
||||
|
||||
community_pid = communities[i].pid;
|
||||
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}});
|
||||
print("Add Search Research Outcomes page with id " + searchResearchOutcomesId + " on community " + community_pid);
|
||||
print("Add Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId + " on community " + community_pid);
|
||||
}
|
||||
}
|
||||
|
||||
function createNewPagesForConnect() {
|
||||
// Connect pages
|
||||
publicationsId = db.page.insertOne({
|
||||
"name": "Publications",
|
||||
"route": "/publications",
|
||||
"type": "other",
|
||||
"connect": true,
|
||||
"openaire": false,
|
||||
"communities": false,
|
||||
"entities": [],
|
||||
"top": true,
|
||||
"bottom": false,
|
||||
"right": false,
|
||||
"left": false
|
||||
}).insertedId.str;
|
||||
print("Connect: Creating Publications page with id " + publicationsId);
|
||||
|
||||
var connectCommunity = db.community.findOne({pid: "connect"});
|
||||
connect_pages = connectCommunity.pages;
|
||||
connect_pages[publicationsId] = true;
|
||||
db.community.update({"pid": "connect"}, {$set: {"pages": connect_pages}});
|
||||
print("Add Publications page with id " + publicationsId + " on community connect");
|
||||
}
|
||||
|
||||
function createNewPagesForCommunities() {
|
||||
// Community pages
|
||||
sourcesId = db.page.insertOne({"name" : "Sources and methology", "route" : "/content", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
||||
print("Communities: Creating Sources and methology page with id " + sourcesId);
|
||||
|
||||
projectsId = db.page.insertOne({"name" : "Projects and funding opportunities", "route" : "/projects", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
||||
print("Communities: Creating Projects page with id " + projectsId);
|
||||
|
||||
nationalBulletinsId = db.page.insertOne({"name" : "National Bulletins", "route" : "/national-bulletins", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
||||
print("Communities: Creating National Bulletins page with id " + nationalBulletinsId);
|
||||
|
||||
subjectsId = db.page.insertOne({"name" : "Subjects", "route" : "/subjects", "type" : "other", "connect":false,"openaire":false, "communities": true, "entities" : [], "top":true,"bottom":true,"right":false,"left":false}).insertedId.str;
|
||||
print("Communities: Creating Subjects page with id " + subjectsId);
|
||||
|
||||
communities = db.community.find().map( function(community) { return community; } );
|
||||
for (var i = 0; i < communities.length; i++) {
|
||||
community_pages = communities[i].pages;
|
||||
|
||||
community_pages[sourcesId] = true;
|
||||
community_pages[projectsId] = false;
|
||||
community_pages[nationalBulletinsId] = false;
|
||||
community_pages[subjectsId] = false;
|
||||
community_pages[searchResearchOutcomesId] = true;
|
||||
community_pages[avancedSearchResearchOutcomesId] = true;
|
||||
|
||||
community_pid = communities[i].pid;
|
||||
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}});
|
||||
print("Add Sources and methology page with id " + sourcesId + " on community " + community_pid);
|
||||
print("Add Projects page with id " + projectsId + " on community " + community_pid);
|
||||
print("Add National Bulletins page with id " + nationalBulletinsId + " on community " + community_pid);
|
||||
print("Add Subjects page with id " + subjectsId + " on community " + community_pid);
|
||||
print("Add Search Research Outcomes page with id " + searchResearchOutcomesId + " on community " + community_pid);
|
||||
print("Add Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId + " on community " + community_pid);
|
||||
}
|
||||
}
|
||||
|
||||
function removeContentPolicyPageAndAddHelpTextInCommunitiesSourcesPage() {
|
||||
contentId = db.page.find({route: "/content", "connect": true}).map(function (page) {
|
||||
return page._id.str;
|
||||
}).toString();
|
||||
db.page.remove({"route": "/content", "connect": true});
|
||||
print("Remove Content Policy page with id " + contentId + " and connect: true");
|
||||
|
||||
var connectCommunity = db.community.findOne({pid: "connect"});
|
||||
// connect_pages = connectCommunity.pages;
|
||||
// delete connect_pages[contentId];
|
||||
// db.community.update({"pid": "connect"}, {$set: {"pages": connect_pages}});
|
||||
// print("Remove Content Policy page with id " + contentId + " on community: connect");
|
||||
|
||||
communities_contentId = db.page.find({route: "/content", "communities": true}).map(function (page) {
|
||||
return page._id.str;
|
||||
}).toString();
|
||||
communities = db.community.find().map(function (community) {
|
||||
return community;
|
||||
});
|
||||
function addPortalType() {
|
||||
communities = db.community.find().map( function(community) { return community; } );
|
||||
for (var i = 0; i < communities.length; i++) {
|
||||
community_pages = communities[i].pages;
|
||||
delete community_pages[contentId];
|
||||
db.community.update({"pid": communities[i].pid}, {$set: {"pages": community_pages}});
|
||||
print("Remove Content Policy page with id " + contentId + " on community: "+communities[i].pid);
|
||||
community = communities[i];
|
||||
if(community.pid == "openaire") {
|
||||
community['type'] = "explore";
|
||||
} else if(community.pid == "connect") {
|
||||
community['type'] = "connect";
|
||||
} else {
|
||||
community['type'] = "community";
|
||||
}
|
||||
db.community.save(community);
|
||||
}
|
||||
}
|
||||
|
||||
db.pageHelpContent.find({
|
||||
community: connectCommunity._id.str,
|
||||
page: contentId
|
||||
}).forEach(function (pageHelpContentForContentPolicy) {
|
||||
if(communities[i].pid != "openaire" && communities[i].pid != "connect") {
|
||||
newCommunityPageHelpContent = db.pageHelpContent.save({
|
||||
"page": communities_contentId, "community": communities[i]._id.str,
|
||||
"content": pageHelpContentForContentPolicy.content,
|
||||
"placement": pageHelpContentForContentPolicy.placement, "order": pageHelpContentForContentPolicy.order,
|
||||
"isActive": pageHelpContentForContentPolicy.isActive, "isPriorTo": pageHelpContentForContentPolicy.isPriorTo
|
||||
});
|
||||
function createPagesForEachPortalType() {
|
||||
pages = db.page.find().map( function(page) { return page; } );
|
||||
for (var i = 0; i < pages.length; i++) {
|
||||
page = pages[i];
|
||||
|
||||
print("Add pageHelpContent on community " + communities[i].pid);
|
||||
print("createPagesForEachPortalType: page["+i+"] = "+page.name + " ( "+page._id.str+" ) -> openaire: "+page.openaire+" - connect: "+page.connect + " - communities: "+page.communities);
|
||||
|
||||
if(page.openaire == false) { // do not include this page in portal profile
|
||||
communityOpenaire = db.community.findOne({pid: "openaire"});
|
||||
removePageFromPortal(communityOpenaire, page._id, communityOpenaire.pages);
|
||||
}
|
||||
if(page.connect == false) { // do not include this page in portal profile
|
||||
communityConnect = db.community.findOne({pid: "connect"});
|
||||
removePageFromPortal(communityConnect, page._id, communityConnect.pages);
|
||||
}
|
||||
if(page.communities == false) {
|
||||
communities = db.community.find({ "type" : "community" }).map( function(community) { return community; } );
|
||||
for (var j = 0; j < communities.length; j++) {
|
||||
removePageFromPortal(communities[j], page._id, communities[j].pages);
|
||||
}
|
||||
}
|
||||
|
||||
if(page.openaire == true && page.connect == true && page.communities == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for communities");
|
||||
|
||||
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore");
|
||||
//print("Delete and create other for explore");
|
||||
|
||||
createAndUpdatePageAndContentsForPortal(page, "connect", "connect");
|
||||
//print("Delete and create other for connect");
|
||||
|
||||
} else if(page.openaire == true && page.connect == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "connect", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for connect");
|
||||
|
||||
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore");
|
||||
//print("Delete and create other for explore");
|
||||
|
||||
} else if(page.openaire == true && page.communities == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for community");
|
||||
|
||||
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore");
|
||||
//print("Delete and create other for explore");
|
||||
|
||||
} else if(page.connect == true && page.communities == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for community");
|
||||
|
||||
createAndUpdatePageAndContentsForPortal(page, "connect", "connect");
|
||||
//print("Delete and create other for connect");
|
||||
|
||||
} else if(page.openaire == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "explore", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for explore");
|
||||
|
||||
} else if(page.connect == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "connect", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for connect");
|
||||
|
||||
} else if(page.communities == true) {
|
||||
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
print("Keep for community");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAndUpdatePageAndContentsForPortal(page, pid, portalType) {
|
||||
db.page.save({"name" : page.name, "route" : page.route, "type" : page.type, "portalType": portalType, "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left});
|
||||
pageIdForPortalType = db.page.find({portalType: portalType, "route" : page.route}).map(function (page) { return page._id.str; }).toString();
|
||||
print("portalType: "+ portalType + " --> new page id: "+ pageIdForPortalType);
|
||||
|
||||
community = db.community.findOne({pid: pid});
|
||||
|
||||
community_pages = community.pages;
|
||||
community_pages[pageIdForPortalType] = community_pages[page._id.str];
|
||||
removePageFromPortal(community, page._id, community_pages);
|
||||
if(portalType == "explore") {
|
||||
print(" Delete page: "+page._id.str + " = (should be null) "+community.pages[page._id.str]
|
||||
+ " - new page: "+pageIdForPortalType+" = "+community.pages[pageIdForPortalType]);
|
||||
}
|
||||
|
||||
updatePageHelpContentsForPortalPage(page._id.str, pageIdForPortalType, community._id.str);
|
||||
}
|
||||
|
||||
function removePageFromPortal(community, pageId, community_pages) {
|
||||
delete community_pages[pageId.str];
|
||||
db.community.update({"pid": community.pid}, {$set: {"pages": community_pages}});
|
||||
}
|
||||
|
||||
function updatePageHelpContentsForPortalPage(pageId, newPageId, communityId) {
|
||||
pageHelpContents = db.pageHelpContent.find({"page" : pageId, "community" : communityId,}).map( function(pageHelpContent) { return pageHelpContent; } );
|
||||
for (var i = 0; i < pageHelpContents.length; i++) {
|
||||
pageHelpContent = pageHelpContents[i];
|
||||
db.pageHelpContent.save({
|
||||
"_id": pageHelpContent._id,
|
||||
"page": newPageId,
|
||||
"community": communityId,
|
||||
"placement": pageHelpContent.placement,
|
||||
"order": pageHelpContent.order,
|
||||
"content": pageHelpContent.content,
|
||||
"isActive": pageHelpContent.isActive,
|
||||
"isPriorTo": pageHelpContent.isPriorTo
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pageHelpContentsForContentPolicy = db.pageHelpContent.find({
|
||||
community: connectCommunity._id.str,
|
||||
page: contentId
|
||||
}).map(function (pageHelpContent) {
|
||||
return pageHelpContent;
|
||||
});
|
||||
for (var i = 0; i < pageHelpContentsForContentPolicy.length; i++) {
|
||||
db.pageHelpContent.remove({"_id": pageHelpContentsForContentPolicy[i]._id});
|
||||
print("Removed pageHelpContent with id " + pageHelpContentsForContentPolicy[i]._id.str + " from community: connect");
|
||||
function createDivIdsForEachPortalType() {
|
||||
divIds = db.divId.find().map( function(divId) { return divId; } );
|
||||
for (var i = 0; i < divIds.length; i++) {
|
||||
divId = divIds[i];
|
||||
|
||||
print("createDivIdsForEachPortalType: divId["+i+"] = "+divId.name + " -> openaire: "+divId.openaire+" - connect: "+divId.connect + " - communities: "+divId.communities);
|
||||
|
||||
if(divId.openaire == true && divId.connect == true && divId.communities == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false);
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true);
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, "connect", "connect", true);
|
||||
|
||||
} else if(divId.openaire == true && divId.connect == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "connect", false);
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true);
|
||||
|
||||
} else if(divId.openaire == true && divId.communities == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false);
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true);
|
||||
|
||||
} else if(divId.connect == true && divId.communities == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false);
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, "connect", "connect", true);
|
||||
|
||||
} else if(divId.openaire == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "explore", false);
|
||||
|
||||
} else if(divId.connect == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "connect", false);
|
||||
|
||||
} else if(divId.communities == true) {
|
||||
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addFAQsPage() {
|
||||
db.page.save({"name" : "About - FAQs",
|
||||
"route" : "/about/faq",
|
||||
"type" : "other",
|
||||
"connect":true,
|
||||
"communities":false,
|
||||
"openaire":false,
|
||||
"entities" : [],
|
||||
"top":true,
|
||||
"bottom":false,
|
||||
"right":false,
|
||||
"left":false
|
||||
});
|
||||
faq = db.page.find( { route: "/about/faq" }).map( function(page) { return page._id.str; } ).toString();
|
||||
communities = db.community.find().map( function(community) { return community; } );
|
||||
for (var i = 0; i < communities.length; i++) {
|
||||
community_pages = communities[i].pages;
|
||||
function updateDivIdPages(pages, portalType) {
|
||||
var newPages = [];
|
||||
for (var i = 0; i < pages.length; i++) {
|
||||
page = db.page.findOne({"_id": ObjectId(pages[i])});
|
||||
pageForPortalType = db.page.findOne({portalType: portalType, "route" : page.route});
|
||||
if(pageForPortalType) {
|
||||
print("page in divId: "+pages[i] + " will be replaced with "+pageForPortalType._id.str);
|
||||
newPages.push(pageForPortalType._id.str);
|
||||
} else {
|
||||
print("page in divId: "+pages[i] + " will be not be replaced. pageForPortalType: "+pageForPortalType);
|
||||
}
|
||||
}
|
||||
return newPages;
|
||||
}
|
||||
|
||||
community_pages[faq] = true;
|
||||
community_pid = communities[i].pid;
|
||||
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}});
|
||||
print("Update pages for " + community_pid);
|
||||
function createAndUpdateDivIdAndContentsForPortal(divId, pid, portalType, create) {
|
||||
var pages = updateDivIdPages(divId.pages, portalType);
|
||||
if(pages.length == 0) {
|
||||
db.divId.remove({"_id": divId._id});
|
||||
communities = db.community.find({ "type" : portalType }).map( function(community) { return community; } );
|
||||
for (var j = 0; j < communities.length; j++) {
|
||||
db.divHelpContent.remove({"divId": divId._id.str, "community": communities[j]._id.str});
|
||||
}
|
||||
} else {
|
||||
if (create) {
|
||||
db.divId.save({"name": divId.name, "pages": pages, "portalType": portalType});
|
||||
|
||||
divIdForPortalType = db.divId.find({portalType: portalType, "name" : divId.name}).map(function (divId) { return divId._id.str; }).toString();
|
||||
|
||||
communityId = db.community.find({pid: pid}).map(function (community) { return community._id.str; }).toString();
|
||||
|
||||
updateDivIdHelpContentsForPortalPage(divId._id.str, divIdForPortalType, communityId);
|
||||
} else {
|
||||
db.divId.save({"_id": divId._id, "name": divId.name, "pages": pages, "portalType": portalType});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use openaire_admin;
|
||||
function updateDivIdHelpContentsForPortalPage(divIdId, newDivIdId, communityId) {
|
||||
divHelpContents = db.divHelpContent.find({"divId" : divIdId, "community" : communityId,}).map( function(divHelpContent) { return divHelpContent; } );
|
||||
for (var i = 0; i < divHelpContents.length; i++) {
|
||||
divHelpContent = divHelpContents[i];
|
||||
|
||||
db.divHelpContent.save({
|
||||
"_id": divHelpContent._id,
|
||||
"divId" : newDivIdId,
|
||||
"community" : communityId,
|
||||
"content" : divHelpContent.content,
|
||||
"isActive" : divHelpContent.isActive
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renameCollectionAndFields() {
|
||||
db.community.renameCollection("portal");
|
||||
db.communitySubscribers.renameCollection("portalSubscribers");
|
||||
|
||||
db.divHelpContent.update({"community": {$exists: true}}, {$rename:{"community":"portal"}}, false, true);
|
||||
db.pageHelpContent.update({"community": {$exists: true}}, {$rename:{"community":"portal"}}, false, true);
|
||||
db.notifications.update({"communityPid": {$exists: true}}, {$rename:{"communityPid":"portalPid"}}, false, true);
|
||||
}
|
||||
|
||||
function addPortalPidInLayoutRecords() {
|
||||
communities = db.portal.find().map( function(community) { return community; } );
|
||||
for (var j = 0; j < communities.length; j++) {
|
||||
community = communities[j];
|
||||
if(community.layout) {
|
||||
layout = db.layout.findOne({"_id": ObjectId(community.layout)});
|
||||
db.layout.save({
|
||||
"_id": layout._id,
|
||||
"mainColor": layout.mainColor,
|
||||
"secondaryColor": layout.secondaryColor,
|
||||
"panel": layout.panel,
|
||||
"box": layout.box,
|
||||
"links": layout.links,
|
||||
"buttons": layout.buttons,
|
||||
"portalPid": community.pid
|
||||
})
|
||||
|
||||
db.portal.update({"_id": community._id}, {$unset: {layout:""}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use openaireconnect;
|
||||
|
||||
//updatePages();
|
||||
|
||||
|
@ -1650,10 +1759,9 @@ use openaire_admin;
|
|||
// 13-03-2020
|
||||
//addSearchResearchOutcomesPages();
|
||||
|
||||
// 10-04-2020
|
||||
// createNewPagesForConnect();
|
||||
// createNewPagesForCommunities();
|
||||
// removeContentPolicyPageAndAddHelpTextInCommunitiesSourcesPage();
|
||||
|
||||
//24-04-2020
|
||||
addFAQsPage();
|
||||
// 02-02-2020 - 19-03-2020
|
||||
addPortalType();
|
||||
createPagesForEachPortalType();
|
||||
createDivIdsForEachPortalType();
|
||||
renameCollectionAndFields();
|
||||
addPortalPidInLayoutRecords();
|
Loading…
Reference in New Issue