All files moved to /trunk directory (improving project structure in svn).
parent
aa88a16e4f
commit
69abc67c5c
@ -0,0 +1,27 @@
|
||||
//version compatibility: 2.0.0-SNAPSHOT
|
||||
|
||||
function removeStatisticsForDeletedCommunity(pid) {
|
||||
var countStatistics = db.statistics.find({pid: pid}).count();
|
||||
if(countStatistics > 0) {
|
||||
db.statistics.remove({pid: pid});
|
||||
}
|
||||
print("Removed " + countStatistics + " statistics entries for community: " + pid);
|
||||
}
|
||||
|
||||
function removeSubscribersForDeletedCommunity(pid) {
|
||||
var countSubscribers = db.communitySubscribers.find({pid: pid}).count();
|
||||
if(countSubscribers > 0) {
|
||||
db.communitySubscribers.remove({pid: pid});
|
||||
}
|
||||
print("Removed " + countSubscribers + " communitySubscribers entries for community: " + pid);
|
||||
}
|
||||
|
||||
use openaire_admin;
|
||||
|
||||
|
||||
// 08-10-2019
|
||||
removeStatisticsForDeletedCommunity("Transport Research");
|
||||
removeSubscribersForDeletedCommunity("Transport Research");
|
||||
|
||||
removeStatisticsForDeletedCommunity("European Plate Observing System");
|
||||
removeSubscribersForDeletedCommunity("European Plate Observing System");
|
@ -0,0 +1,38 @@
|
||||
!!!!Check the following for the override properties port
|
||||
|
||||
src/main/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplication.java
|
||||
|
||||
|
||||
!! properties here cannot be overwritten in dnet-override.properties
|
||||
src/main/resources/application.properties
|
||||
|
||||
!!Check dnet-override.properties that have override the properties from:
|
||||
|
||||
src/main/resources/admintools.properties
|
||||
|
||||
|
||||
**DEV NEW 05-07-2019**
|
||||
Replace admintool with admintool.mail on dnet-override properties
|
||||
|
||||
|
||||
|
||||
***BETA***
|
||||
PORT: 8380
|
||||
logs: /var/log/dnet/uoa-admin-tools/
|
||||
|
||||
#spring.data.mongodb.host=beta.services.openaire.eu
|
||||
#spring.data.mongodb.port=27017
|
||||
#spring.data.mongodb.database=openaireconnect
|
||||
|
||||
|
||||
***Production***
|
||||
|
||||
PORT: 8480
|
||||
logs: /var/log/dnet/uoa-admin-tools/
|
||||
|
||||
#spring.data.mongodb.host=services.openaire.eu
|
||||
#spring.data.mongodb.port=27017
|
||||
#spring.data.mongodb.database=openaireconnect
|
||||
#spring.data.mongodb.username=dnet8480
|
||||
#spring.data.mongodb.password=...
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,215 @@
|
||||
//version compatibility: 1.1.1-SNAPSHOT
|
||||
print("migrateCommunityIn_db script running...");
|
||||
|
||||
function migrate_community(communityPid, 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");
|
||||
|
||||
var beta_community = beta_db.community.findOne({ pid: communityPid } );
|
||||
|
||||
if(!beta_community) {
|
||||
print("ERROR: Community with pid: "+communityPid+" 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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// 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) {
|
||||
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 beta_page = beta_db.page.findOne( { _id: beta_pageObjectId } );
|
||||
if(beta_page) {
|
||||
var prod_page = prod_db.page.findOne( { route: beta_page.route } );
|
||||
if(prod_page) {
|
||||
prod_community_pages[prod_page._id.str] = beta_community_pages[beta_pageId];
|
||||
} else {
|
||||
print("\nERROR: Page with route: "+beta_page.route+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
} else {
|
||||
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");
|
||||
|
||||
// migrate community entities
|
||||
var beta_community_entities = beta_community.entities;
|
||||
var prod_community_entities = {}
|
||||
for (var beta_entityId in beta_community_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];
|
||||
} else {
|
||||
print("\nERROR: Entity with pid: "+beta_entity.pid+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
} else {
|
||||
print("\nERROR: Entity with id: "+beta_entityId+" does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
print("Community entities are ready to be migrated");
|
||||
|
||||
prod_db.community.save({"name" : beta_community.name, "pid" : communityPid, "pages" : prod_community_pages, "entities" : prod_community_entities});
|
||||
|
||||
print("Community 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 } );
|
||||
prod_db.statistics.save(beta_statistics);
|
||||
|
||||
print("Statistics for community 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});
|
||||
}
|
||||
|
||||
beta_communitySubscribers.forEach(function(beta_communitySubscriber) {
|
||||
var addInCommunity = true;
|
||||
|
||||
// if user exists in community subscribers already, do nothing
|
||||
if(prod_communitySubscribersEmails.indexOf(beta_communitySubscriber.email) >= 0) {
|
||||
addInCommunity = false;
|
||||
} else {
|
||||
var prod_subscriber = prod_db.subscriber.findOne({email: beta_communitySubscriber.email});
|
||||
|
||||
// if subscriber of beta does not exist in production, add him
|
||||
if(!prod_subscriber) {
|
||||
prod_subscriber = {email: beta_communitySubscriber.email};
|
||||
prod_db.subscriber.save(prod_subscriber);
|
||||
print("subscriber "+beta_communitySubscriber.email+" added in production DB");
|
||||
}
|
||||
}
|
||||
|
||||
if(addInCommunity) {
|
||||
var prod_communitySubscriber = prod_db.subscriber.findOne({email: beta_communitySubscriber.email});
|
||||
prod_communitySubscribers.push(prod_communitySubscriber);
|
||||
}
|
||||
})
|
||||
if(prod_communitySubscr) {
|
||||
prod_db.communitySubscribers.update({ "pid" : communityPid } , {$set: {subscribers : prod_communitySubscribers}});
|
||||
} else {
|
||||
prod_db.communitySubscribers.insert({ "pid" : communityPid, "subscribers" : prod_communitySubscribers });
|
||||
}
|
||||
|
||||
print("subscribers of community were migrated");
|
||||
} else {
|
||||
print("\nERROR: Subscribers not migrated. No CommunitySubscribers for this community 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;
|
||||
|
||||
if(prod_communityOldId) {
|
||||
prod_db.divHelpContent.remove({"community": prod_communityOldId});
|
||||
}
|
||||
//var beta_divHelpContents =
|
||||
beta_db.divHelpContent.find( { community: beta_communityId } ).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;
|
||||
if(prod_divId) {
|
||||
prod_db.divHelpContent.save({ "divId" : prod_divId._id.str, "community" : prod_communityId, "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");
|
||||
}
|
||||
} else {
|
||||
print("\nERROR: DivId with id: "+beta_divHelpContent.divId+" (of divHelpContent: "+beta_divHelpContent._id.str+") does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
//}
|
||||
});
|
||||
|
||||
print("divHelpContents of community were migrated");
|
||||
|
||||
// migrate pageHelpContents of community
|
||||
if(prod_communityOldId) {
|
||||
prod_db.pageHelpContent.remove({"community": prod_communityOldId});
|
||||
}
|
||||
beta_db.pageHelpContent.find( { community: beta_communityId } ).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;
|
||||
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 });
|
||||
} else {
|
||||
print("\nERROR: Page with route: "+beta_page.route+" does not exist on production db: "+prod_db_name+"\n");
|
||||
}
|
||||
} else {
|
||||
print("\nERROR: Page with id: "+beta_pageHelpContent.page+" (of pageHelpContent: "+beta_pageHelpContent._id.str+") does not exist on beta db: "+beta_db_name+"\n");
|
||||
}
|
||||
});
|
||||
|
||||
print("pageHelpContents of community 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 } );
|
||||
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){
|
||||
if(prod_notifications_emails.indexOf(preference.managerEmail) >= 0) {
|
||||
prod_db.notifications.update({ managerEmail: preference.managerEmail }, {$set: {notifyForNewManagers: preference.notifyForNewManagers, notifyForNewSubscribers: preference.notifyForNewSubscribers}})
|
||||
} else {
|
||||
prod_db.notifications.insert(preference);
|
||||
}
|
||||
});
|
||||
|
||||
print("Notification preferences of community were migrated");
|
||||
|
||||
}
|
||||
|
||||
migrate_community("egi", 'openaire_admin_copy', 'openaire_admin_prod');
|
||||
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>uoa-admin-tools</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>uoa-admin-tools</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.8.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId> org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.5.0-b01</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>20030203.000550</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!--3d answer: https://stackoverflow.com/questions/23260057/the-forked-vm-terminated-without-saying-properly-goodbye-vm-crash-or-system-exi-->
|
||||
<!--If you use openjdk there might be a problem with surfire plugin - uncomment following lines-->
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!--<artifactId>maven-surefire-plugin</artifactId>-->
|
||||
<!--<version>2.19.1</version>-->
|
||||
<!--<configuration>-->
|
||||
<!--<!–<testFailureIgnore>true</testFailureIgnore>–>-->
|
||||
<!--<useSystemClassLoader>false</useSystemClassLoader>-->
|
||||
<!--</configuration>-->
|
||||
<!--</plugin>-->
|
||||
</plugins>
|
||||
<finalName>uoa-admin-tools</finalName>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(UoaAdminToolsApplication.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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 org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.PropertySources;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySources({
|
||||
@PropertySource("classpath:admintools.properties"),
|
||||
@PropertySource(value = "file:/usr/share/tomcat7/lib/dnet-override.properties", ignoreResourceNotFound = true),
|
||||
@PropertySource(value = "file:/var/lib/tomcat_dnet/8380/lib/dnet-override.properties", ignoreResourceNotFound = true),
|
||||
@PropertySource(value = "file:/var/lib/tomcat8/lib/dnet-override.properties", ignoreResourceNotFound = true)
|
||||
})
|
||||
@EnableConfigurationProperties({SecurityConfig.class, MailConfig.class, GoogleConfig.class, MongoConfig.class})
|
||||
public class UoaAdminToolsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UoaAdminToolsApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package eu.dnetlib.uoaadmintools;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig;
|
||||
import eu.dnetlib.uoaadmintools.handlers.AuthorizationHandler;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
/**
|
||||
* Created by argirok on 23/2/2018.
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class UoaAdminToolsConfiguration extends WebMvcConfigurerAdapter {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private SecurityConfig securityConfig;
|
||||
|
||||
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new AuthorizationHandler(securityConfig.getUserInfoUrl(), securityConfig.getOriginServer(), securityConfig.getPostsAllowed()))
|
||||
.addPathPatterns("/**");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package eu.dnetlib.uoaadmintools.configuration.mongo;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackages = {"eu.dnetlib.uoaadmintools.dao"})
|
||||
public class MongoConnection {
|
||||
|
||||
@Autowired
|
||||
private MongoConfig mongoConfig;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public MongoDbFactory mongoDbFactory() {
|
||||
return new SimpleMongoDbFactory(getMongoClient(), mongoConfig.getDatabase());
|
||||
}
|
||||
|
||||
@Bean(name = "mongoTemplate")
|
||||
@Primary
|
||||
public MongoTemplate getMongoTemplate() {
|
||||
return new MongoTemplate(mongoDbFactory());
|
||||
}
|
||||
|
||||
private MongoClient getMongoClient() {
|
||||
if(mongoConfig.getUsername() != null && mongoConfig.getPassword() != null){
|
||||
return new MongoClient(Collections.singletonList(
|
||||
new ServerAddress(mongoConfig.getHost(), mongoConfig.getPort())),
|
||||
Collections.singletonList(MongoCredential.createCredential(mongoConfig.getUsername(), mongoConfig.getDatabase(), mongoConfig.getPassword().toCharArray())));
|
||||
} else {
|
||||
return new MongoClient(Collections.singletonList(new ServerAddress(mongoConfig.getHost(), mongoConfig.getPort())));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package eu.dnetlib.uoaadmintools.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("admintool.mongodb")
|
||||
public class MongoConfig {
|
||||
|
||||
private String host;
|
||||
private String database;
|
||||
private String username;
|
||||
private String password;
|
||||
private int port;
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package eu.dnetlib.uoaadmintools.configuration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ConfigurationProperties("admintool.security")
|
||||
public class SecurityConfig {
|
||||
|
||||
private String userInfoUrl;
|
||||
private String originServer;
|
||||
private List<String> postsAllowed = new ArrayList<>();
|
||||
|
||||
public void setUserInfoUrl(String userInfoUrl) {
|
||||
this.userInfoUrl = userInfoUrl;
|
||||
}
|
||||
|
||||
public void setOriginServer(String originServer) {
|
||||
this.originServer = originServer;
|
||||
}
|
||||
|
||||
|
||||
public void setPostsAllowed(List<String> posts) {
|
||||
this.postsAllowed = posts;
|
||||
}
|
||||
|
||||
public String getUserInfoUrl() {
|
||||
return userInfoUrl;
|
||||
}
|
||||
|
||||
public String getOriginServer() {
|
||||
return originServer;
|
||||
}
|
||||
|
||||
public List<String> getPostsAllowed() {
|
||||
return postsAllowed;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,543 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.*;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
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
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CommunityController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@Autowired
|
||||
private LayoutDAO layoutDAO;
|
||||
|
||||
@Autowired
|
||||
private PageDAO pageDAO;
|
||||
|
||||
@Autowired
|
||||
private EntityDAO entityDAO;
|
||||
|
||||
@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 = "/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 = "/communityFull/{pid}", method = RequestMethod.GET)
|
||||
public CommunityResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
|
||||
Community community = communityDAO.findByPid(pid);
|
||||
CommunityResponse communityResponse = new CommunityResponse(community);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/save", method = RequestMethod.POST)
|
||||
public CommunityResponse insertCommunity(@RequestBody Community community) {
|
||||
//Community community = this.getCommunityByCommunityResponse(communityResponse);
|
||||
|
||||
List<CommunityEntity> communityEntities = new ArrayList<>();
|
||||
List<CommunityPage> communityPages = new ArrayList<>();
|
||||
Map<String, Boolean> entities = new HashMap<>();
|
||||
Map<String, Boolean> pages = new HashMap<>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private Community getCommunityByCommunityResponse(CommunityResponse communityResponse) {
|
||||
Community community = new Community();
|
||||
community.setId(communityResponse.getId());
|
||||
community.setName(communityResponse.getName());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.CommunitySubscribersDAO;
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Community;
|
||||
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers;
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CommunitySubscribersController {
|
||||
@Autowired
|
||||
CommunitySubscribersDAO communitySubscriberDAO;
|
||||
@Autowired
|
||||
SubscriberDAO subscriberDAO;
|
||||
@Autowired
|
||||
CommunityDAO communityDAO;
|
||||
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
@RequestMapping(value = "/community/subscribers", method = RequestMethod.GET)
|
||||
public List<CommunitySubscribers> getAllCommunitySubscribers(){
|
||||
return communitySubscriberDAO.findAll();
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.GET)
|
||||
public CommunitySubscribers getSubscribersPerCommunity(@PathVariable(value="pid", required = true) String pid) throws ContentNotFoundException {
|
||||
CommunitySubscribers communitySubscribers = communitySubscriberDAO.findByPid(pid);
|
||||
if(communitySubscribers != null){
|
||||
return communitySubscribers;
|
||||
}else{
|
||||
throw new ContentNotFoundException("Community Subscribers not found");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST)
|
||||
public CommunitySubscribers addSubscriberInCommunity(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException {
|
||||
CommunitySubscribers communitySubscribers = communitySubscriberDAO.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 communitySubscriberDAO.save(communitySubscribers);
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/community/{pid}/subscribers/delete", method = RequestMethod.POST)
|
||||
public CommunitySubscribers deleteSubscriberFromCommunity(@PathVariable(value="pid", required = true) String pid, @RequestBody List<String> emails) throws ContentNotFoundException {
|
||||
CommunitySubscribers communitySubscribers = communitySubscriberDAO.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 communitySubscriberDAO.save(communitySubscribers);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subscriber/communities", method = RequestMethod.GET)
|
||||
public List<String> getCommunitiesPerSubcriber(@RequestParam(value="email", required = true) String email) {
|
||||
List<CommunitySubscribers> communitySubscribers = communitySubscriberDAO.findAll();
|
||||
List<String> list = new ArrayList<>();
|
||||
for(CommunitySubscribers s:communitySubscribers){
|
||||
for(Subscriber sub:s.getSubscribers()) {
|
||||
if (sub.getEmail().equals(email)) {
|
||||
list.add(s.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.CuratorDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
import eu.dnetlib.uoaadmintools.entities.CuratorResponse;
|
||||
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;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class CuratorController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private CuratorDAO curatorDAO;
|
||||
|
||||
|
||||
/**
|
||||
* Return a list with curator. If list of emails does not existed return all curators, else return
|
||||
* curators based on given list.
|
||||
*
|
||||
* @param emails
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/curator", method = RequestMethod.GET)
|
||||
public List<CuratorResponse> getCurators(@RequestParam(required = false) Optional<String> emails) {
|
||||
List<CuratorResponse> curators = new ArrayList<>();
|
||||
if(emails.isPresent()) {
|
||||
for(String email: emails.get().split(",")) {
|
||||
Curator curator = curatorDAO.findByEmail(email);
|
||||
if(curator != null) {
|
||||
curators.add(new CuratorResponse(curator));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(Curator curator: curatorDAO.findAll()) {
|
||||
curators.add(new CuratorResponse(curator));
|
||||
}
|
||||
}
|
||||
return curators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Curator with the given id.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/curator/{id}", method = RequestMethod.GET)
|
||||
public Curator getCuratorById(@PathVariable String id) {
|
||||
return curatorDAO.findById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update a curator, base on Curator object given on Request Body.
|
||||
*
|
||||
* @param curator
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/curator", method = RequestMethod.POST)
|
||||
public Curator insertCurator(@RequestBody Curator curator) {
|
||||
return curatorDAO.save(curator);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all curators if list of emails does not exist or curators based on given list.
|
||||
*
|
||||
* @param emails
|
||||
*/
|
||||
@RequestMapping(value = "/curator", method = RequestMethod.DELETE)
|
||||
public void deleteCurators(@RequestBody(required = false) Optional<List<String>> emails) {
|
||||
if(emails.isPresent()) {
|
||||
for(String email: emails.get()) {
|
||||
Curator curator = curatorDAO.findByEmail(email);
|
||||
if(curator != null) {
|
||||
curatorDAO.delete(curator.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
curatorDAO.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
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 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 EmailController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private EmailSender emailSender;
|
||||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
@Autowired
|
||||
private VerifyRecaptcha verifyRecaptcha;
|
||||
|
||||
@RequestMapping(value = "/contact", method = RequestMethod.POST)
|
||||
public Boolean contact(@RequestBody EmailRecaptcha form) throws InvalidReCaptchaException {
|
||||
verifyRecaptcha.processResponse(form.getRecaptcha());
|
||||
Email email = form.getEmail();
|
||||
ArrayList<String> sendTo = new ArrayList<>(email.getRecipients());
|
||||
return emailSender.send(sendTo, email.getSubject(), email.getBody(), false);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/sendMail", method = RequestMethod.POST)
|
||||
public Map<String, ArrayList<String>> sendEmail(@RequestBody Email email,
|
||||
@RequestParam(required = false) Optional<Boolean> optional) {
|
||||
String successString = "success";
|
||||
String failureString = "failure";
|
||||
Map<String, ArrayList<String>> mailResults = new HashMap<>();
|
||||
boolean bcc = (optional.isPresent())?optional.get():true;
|
||||
for(String userMail:email.getRecipients()){
|
||||
ArrayList<String> sendTo = new ArrayList<>();
|
||||
sendTo.add(userMail);
|
||||
boolean success =emailSender.send(sendTo,email.getSubject(),email.getBody(), bcc);
|
||||
if(success){
|
||||
if(!mailResults.containsKey(successString)) {
|
||||
mailResults.put(successString, new ArrayList<>());
|
||||
}
|
||||
mailResults.get(successString).add(userMail);
|
||||
} else {
|
||||
if(!mailResults.containsKey(failureString)) {
|
||||
mailResults.put(failureString, new ArrayList<>());
|
||||
}
|
||||
mailResults.get(failureString).add(userMail);
|
||||
}
|
||||
}
|
||||
return mailResults;
|
||||
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
for(String user:email.getRecipients()){
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
|
||||
|
||||
if(userNotifications == null || userNotifications.getNotifyForNewManagers()){
|
||||
notifyrecipients.add(user);
|
||||
}
|
||||
}
|
||||
if(notifyrecipients.size() > 0){
|
||||
return emailSender.send(notifyrecipients,email.getSubject(),email.getBody(), false);
|
||||
}else{
|
||||
log.debug("There are no users to notify ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@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");
|
||||
}
|
||||
for(String user:email.getRecipients()){
|
||||
Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
|
||||
|
||||
if(userNotifications == null || userNotifications.getNotifyForNewSubscribers()){
|
||||
notifyrecipients.add(user);
|
||||
}
|
||||
}
|
||||
if(notifyrecipients.size() > 0){
|
||||
return emailSender.send(notifyrecipients,email.getSubject(),email.getBody(), false);
|
||||
}else{
|
||||
log.debug("There are no users to notify ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
||||
public String test() throws Exception {
|
||||
log.debug("Test mail");
|
||||
List<String> mails = new ArrayList<>();
|
||||
mails.add("argirok@di.uoa.gr");
|
||||
mails.add("argirokokogiannaki@gmail.com");
|
||||
log.debug("Recipients"+mails);
|
||||
|
||||
Email email = new Email();
|
||||
email.setRecipients(mails);
|
||||
email.setBody("Test body");
|
||||
email.setSubject("Test theme");
|
||||
String response = "";
|
||||
response+=this.notifyNewManagers("ee", email);
|
||||
log.debug("Notify managers "+response);
|
||||
|
||||
response+=" ";
|
||||
response+=this.notifyNewSubscribers("ee", email);
|
||||
log.debug("Notify for subscr "+response);
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
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,101 @@
|
||||
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;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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 org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/7/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class NotificationsController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private NotificationsDAO notificationsDAO;
|
||||
@Autowired
|
||||
private CommunityDAO communityDAO;
|
||||
|
||||
@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");
|
||||
}
|
||||
List<Notifications> notifications = notificationsDAO.findByCommunityPid(pid);
|
||||
if(notifications == null || notifications.size() == 0){
|
||||
throw new ContentNotFoundException("Notifications settings not found");
|
||||
}
|
||||
return notifications;
|
||||
}
|
||||
@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);
|
||||
if(notifications!= null){
|
||||
notificationsDAO.delete(notifications.getId());
|
||||
}else{
|
||||
throw new ContentNotFoundException("Notifications not found");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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(notifications.getManagerEmail() != null && !notifications.getManagerEmail().isEmpty()){
|
||||
Notifications saved = notificationsDAO.findByManagerEmailAndCommunityPid(notifications.getManagerEmail(),pid);
|
||||
log.debug(saved);
|
||||
if(saved!= null){
|
||||
notifications.setId(saved.getId());
|
||||
}
|
||||
|
||||
notifications.setCommunityPid(pid);
|
||||
log.debug(notifications);
|
||||
Notifications savedNotifications = notificationsDAO.save(notifications);
|
||||
return savedNotifications;
|
||||
}else{
|
||||
log.error("No user e-mail specified");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,192 @@
|
||||
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,107 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
|
||||
import org.springframework.boot.autoconfigure.web.ErrorController;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by argirok on 8/3/2018.
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("/error")
|
||||
public class SimpleErrorController implements ErrorController {
|
||||
|
||||
private final ErrorAttributes errorAttributes;
|
||||
|
||||
@Autowired
|
||||
public SimpleErrorController(ErrorAttributes errorAttributes) {
|
||||
Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
|
||||
this.errorAttributes = errorAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
return "/error";
|
||||
}
|
||||
|
||||
@RequestMapping
|
||||
public Map<String, Object> error(HttpServletRequest aRequest){
|
||||
Map<String, Object> body = getErrorAttributes(aRequest,getTraceParameter(aRequest));
|
||||
String trace = (String) body.get("trace");
|
||||
if(trace != null){
|
||||
String[] lines = trace.split("\n\t");
|
||||
body.put("trace", lines);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
private boolean getTraceParameter(HttpServletRequest request) {
|
||||
String parameter = request.getParameter("trace");
|
||||
if (parameter == null) {
|
||||
return false;
|
||||
}
|
||||
return !"false".equals(parameter.toLowerCase());
|
||||
}
|
||||
|
||||
private Map<String, Object> getErrorAttributes(HttpServletRequest aRequest, boolean includeStackTrace) {
|
||||
RequestAttributes requestAttributes = new ServletRequestAttributes(aRequest);
|
||||
return errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.*;
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.*;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
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 StatisticsController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private StatisticsDAO statisticsDAO;
|
||||
|
||||
@RequestMapping(value = "/statistics", method = RequestMethod.GET)
|
||||
public List<Statistics> getAllStatistics() throws ContentNotFoundException {
|
||||
log.info("getAllStatistics");
|
||||
List<Statistics> statistics = statisticsDAO.findAll();
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found");
|
||||
}
|
||||
return statistics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/statistics/{pid}", method = RequestMethod.GET)
|
||||
public Statistics getStatistics(@PathVariable(value = "pid") String pid) throws ContentNotFoundException {
|
||||
Statistics statistics = statisticsDAO.findByPid(pid);
|
||||
if(statistics == null){
|
||||
throw new ContentNotFoundException("Statistics not found");
|
||||
}
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/statistics/save", method = RequestMethod.POST)
|
||||
public Statistics insertStatistics(@RequestBody Statistics statistics) {
|
||||
Statistics savedStatistics = statisticsDAO.save(statistics);
|
||||
return savedStatistics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/statistics/delete", method = RequestMethod.POST)
|
||||
public Boolean deleteStatistics(@RequestBody List<String> statistics) throws Exception {
|
||||
for (String id: statistics) {
|
||||
statisticsDAO.delete(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "statistics/{pid}/{entity}/charts", method = RequestMethod.POST)
|
||||
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");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
throw new ContentNotFoundException("Statistics not found for entity");
|
||||
}
|
||||
ChartsMap charts = statisticsEntity.getCharts();
|
||||
if(charts == null){
|
||||
throw new ContentNotFoundException("Statistics not found - no charts");
|
||||
}
|
||||
StatisticsStatus statisticsStatus= charts.getMap().get(key);
|
||||
if(statisticsStatus == null){
|
||||
throw new ContentNotFoundException("Statistics not found for key");
|
||||
}
|
||||
if(Boolean.parseBoolean(monitor)){
|
||||
statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
}else{
|
||||
statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
}
|
||||
// stats.put(key,statisticsStatus);
|
||||
return statisticsDAO.save(statistics);
|
||||
}
|
||||
@RequestMapping(value = "statistics/{pid}/{entity}/numbers", method = RequestMethod.POST)
|
||||
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");
|
||||
}
|
||||
StatisticsEntity statisticsEntity = statistics.getEntities().get(entity);
|
||||
if(statisticsEntity == null ){
|
||||
throw new ContentNotFoundException("Statistics not found for entity");
|
||||
}
|
||||
NumbersMap numbers = statisticsEntity.getNumbers();
|
||||
if(numbers == null){
|
||||
throw new ContentNotFoundException("Statistics not found - no numbers");
|
||||
}
|
||||
StatisticsStatus statisticsStatus= numbers.getMap().get(key);
|
||||
if(statisticsStatus == null){
|
||||
throw new ContentNotFoundException("Statistics not found for key");
|
||||
}
|
||||
if(Boolean.parseBoolean(monitor)){
|
||||
statisticsStatus.setShowInMonitor(Boolean.parseBoolean(status));
|
||||
}else{
|
||||
statisticsStatus.setShowInDashboard(Boolean.parseBoolean(status));
|
||||
}
|
||||
// stats.put(key,statisticsStatus);
|
||||
return statisticsDAO.save(statistics);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package eu.dnetlib.uoaadmintools.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO;
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class SubscriberController {
|
||||
private final Logger log = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private SubscriberDAO subscriberDAO;
|
||||
@RequestMapping(value = "/subscriber", method = RequestMethod.GET)
|
||||
public List<Subscriber> getSubscriber() throws ContentNotFoundException {
|
||||
List<Subscriber> list = subscriberDAO.findAll();
|
||||
if(list == null){
|
||||
throw new ContentNotFoundException("Subscribers not found");
|
||||
}
|
||||
return subscriberDAO.findAll();
|
||||
}
|
||||
@RequestMapping(value = "/subscriber/{email}", method = RequestMethod.GET)
|
||||
public Subscriber getSubscriber(@PathVariable(value="email", required = true) String email) throws ContentNotFoundException {
|
||||
Subscriber subscriber = subscriberDAO.findByEmail(email);
|
||||
if(subscriber == null){
|
||||
throw new ContentNotFoundException("Subscribers not found");
|
||||
}
|
||||
return subscriber;
|
||||
}
|
||||
@RequestMapping(value = "/subscriber", method = RequestMethod.POST)
|
||||
public Subscriber saveSubscriber(@RequestBody Subscriber subscriber) {
|
||||
return subscriberDAO.save(subscriber);
|
||||
}
|
||||
@RequestMapping(value = "/subscriber/{email}", method = RequestMethod.DELETE)
|
||||
public void deleteSubscriber(@PathVariable(value="email", required = true) String email) throws ContentNotFoundException {
|
||||
Subscriber subscriber = subscriberDAO.findByEmail(email);
|
||||
if(subscriber == null){
|
||||
throw new ContentNotFoundException("Subscribers not found");
|
||||
}
|
||||
subscriberDAO.delete(subscriber.getId());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CuratorDAO {
|
||||
|
||||
List<Curator> findAll();
|
||||
|
||||
Curator findById(String Id);
|
||||
|
||||
Curator findByEmail(String email);
|
||||
|
||||
Curator save(Curator curator);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LayoutDAO {
|
||||
List<Layout> findAll();
|
||||
|
||||
Layout findById(String Id);
|
||||
|
||||
Layout save(Layout entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Curator;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBCuratorDAO extends CuratorDAO, MongoRepository<Curator, String> {
|
||||
|
||||
List<Curator> findAll();
|
||||
|
||||
Curator findById(String Id);
|
||||
|
||||
Curator findByEmail(String email);
|
||||
|
||||
Curator save(Curator curator);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Layout;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBLayoutDAO extends LayoutDAO, MongoRepository<Layout, String> {
|
||||
|
||||
List<Layout> findAll();
|
||||
|
||||
Layout findById(String Id);
|
||||
|
||||
Layout save(Layout entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/7/2018.
|
||||
*/
|
||||
public interface MongoDBNotificationsDAO extends NotificationsDAO, MongoRepository<Notifications, String> {
|
||||
List<Notifications> findAll();
|
||||
|
||||
Notifications findById(String Id);
|
||||
|
||||
Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
|
||||
List<Notifications> findByCommunityPid(String communityPid);
|
||||
|
||||
Notifications save(Notifications entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBStatisticsDAO extends StatisticsDAO, MongoRepository<Statistics, String> {
|
||||
List<Statistics> findAll();
|
||||
|
||||
Statistics findById(String Id);
|
||||
|
||||
Statistics findByPid(String Pid);
|
||||
|
||||
Statistics save(Statistics statistic);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBSubscriberDAO extends SubscriberDAO, MongoRepository<Subscriber, String> {
|
||||
|
||||
List<Subscriber> findAll();
|
||||
|
||||
Subscriber findById(String Id);
|
||||
|
||||
Subscriber findByEmail(String email);
|
||||
|
||||
Subscriber save(Subscriber subscriber);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/7/2018.
|
||||
*/
|
||||
public interface NotificationsDAO {
|
||||
List<Notifications> findAll();
|
||||
|
||||
Notifications findById(String Id);
|
||||
|
||||
Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
|
||||
List<Notifications> findByCommunityPid(String communityPid);
|
||||
|
||||
Notifications save(Notifications entity);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
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,21 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 5/3/2018.
|
||||
*/
|
||||
public interface StatisticsDAO {
|
||||
List<Statistics> findAll();
|
||||
|
||||
Statistics findById(String Id);
|
||||
|
||||
Statistics findByPid(String Pid);
|
||||
|
||||
Statistics save(Statistics statistic);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package eu.dnetlib.uoaadmintools.dao;
|
||||
|
||||
import eu.dnetlib.uoaadmintools.entities.Subscriber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SubscriberDAO {
|
||||
|
||||
List<Subscriber> findAll();
|
||||
|
||||
Subscriber findById(String Id);
|
||||
|
||||
Subscriber findByEmail(String email);
|
||||
|
||||
Subscriber save(Subscriber subscriber);
|
||||
|
||||
void deleteAll();
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
public class Affiliation {
|
||||
|
||||
private String name;
|
||||
private String logo_url;
|
||||
private String website_url;
|
||||
|
||||
public Affiliation() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLogo_url() {
|
||||
return logo_url;
|
||||
}
|
||||
|
||||
public void setLogo_url(String logo_url) {
|
||||
this.logo_url = logo_url;
|
||||
}
|
||||
|
||||
public String getWebsite_url() {
|
||||
return website_url;
|
||||
}
|
||||
|
||||
public void setWebsite_url(String website_url) {
|
||||
this.website_url = website_url;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public String getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void setLayout(String layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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; }
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by argirok on 2/3/2018.
|
||||
*/
|
||||
public class CommunitySubscribers {
|
||||
@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){
|
||||
this.pid=pid;
|
||||
}
|
||||
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 List<Subscriber> getSubscribers() {
|
||||
return subscribers;
|
||||
}
|
||||
|
||||
public void setSubscribers(List<Subscriber> subscribers) {
|
||||
this.subscribers = subscribers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommunitySubscribers{" +
|
||||
"id='" + id + '\'' +
|
||||
", pid='" + pid + '\'' +
|
||||
", subscribers=" + subscribers +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Curator {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
private String email;
|
||||
private String name;
|
||||
private List<Affiliation> affiliations;
|
||||
private String photo;
|
||||
private String bio;
|
||||
|
||||
public Curator() {
|
||||
}
|
||||
|
||||
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 String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Affiliation> getAffiliations() {
|
||||
return affiliations;
|
||||
}
|
||||
|
||||
public void setAffiliation(List<Affiliation> affiliations) {
|
||||
this.affiliations = affiliations;
|
||||
}
|
||||
|
||||
public String getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public void setPhoto(String photo) {
|
||||
this.photo = photo;
|
||||
}
|
||||
|
||||
public String getBio() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CuratorResponse {
|
||||
|
||||
private String email;
|
||||
private String name;
|
||||
private List<Affiliation> affiliations;
|
||||
private String photo;
|
||||
private String bio;
|
||||
|
||||
public CuratorResponse() {
|
||||
}
|
||||
|
||||
public CuratorResponse(Curator curator) {
|
||||
this.email = curator.getEmail();
|
||||
this.name = curator.getName();
|
||||
this.affiliations = curator.getAffiliations();
|
||||
this.photo = curator.getPhoto();
|
||||
this.bio = curator.getBio();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Affiliation> getAffiliations() {
|
||||
return affiliations;
|
||||
}
|
||||
|
||||
public void setAffiliation(List<Affiliation> affiliations) {
|
||||
this.affiliations = affiliations;
|
||||
}
|
||||
|
||||
public String getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public void setPhoto(String photo) {
|
||||
this.photo = photo;
|
||||
}
|
||||
|
||||
public String getBio() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoaadmintools.entities.layoutEntities.Box;
|
||||
import eu.dnetlib.uoaadmintools.entities.layoutEntities.Buttons;
|
||||
import eu.dnetlib.uoaadmintools.entities.layoutEntities.Links;
|
||||
import eu.dnetlib.uoaadmintools.entities.layoutEntities.Panel;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
public class Layout {
|
||||
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
private String mainColor;
|
||||
private String secondaryColor;
|
||||
private Panel panel;
|
||||
private Box box;
|
||||
private Links links;
|
||||
private Buttons buttons;
|
||||
|
||||
|
||||
public Layout() { }
|
||||
|
||||
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons) {
|
||||
this.id = id;
|
||||
this.mainColor = mainColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
this.panel = panel;
|
||||
this.box = box;
|
||||
this.links = links;
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMainColor() {
|
||||
return mainColor;
|
||||
}
|
||||
|
||||
public void setMainColor(String mainColor) {
|
||||
this.mainColor = mainColor;
|
||||
}
|
||||
|
||||
public String getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
public void setSecondaryColor(String secondaryColor) {
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
public Panel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void setPanel(Panel panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public Box getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
public void setBox(Box box) {
|
||||
this.box = box;
|
||||
}
|
||||
|
||||
public Links getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(Links links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
public Buttons getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButtons(Buttons buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
* Created by argirok on 6/7/2018.
|
||||
*/
|
||||
public class Notifications {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
private String id;
|
||||
Boolean notifyForNewManagers = true;
|
||||
Boolean notifyForNewSubscribers = true;
|
||||
String managerEmail;
|
||||
String communityPid;
|
||||
public Notifications(){
|
||||
|
||||
}
|
||||
public Notifications(String managerEmail, String communityPid){
|
||||
this();
|
||||
this.communityPid = communityPid;
|
||||
this.managerEmail = managerEmail;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Boolean getNotifyForNewManagers() {
|
||||
return notifyForNewManagers;
|
||||
}
|
||||
|
||||
public void setNotifyForNewManagers(Boolean notifyForNewManagers) {
|
||||
this.notifyForNewManagers = notifyForNewManagers;
|
||||
}
|
||||
|
||||
public Boolean getNotifyForNewSubscribers() {
|
||||
return notifyForNewSubscribers;
|
||||
}
|
||||
|
||||
public void setNotifyForNewSubscribers(Boolean notifyForNewSubscribers) {
|
||||
this.notifyForNewSubscribers = notifyForNewSubscribers;
|
||||
}
|
||||
|
||||
public String getManagerEmail() {
|
||||
return managerEmail;
|
||||
}
|
||||
|
||||
public void setManagerEmail(String managerEmail) {
|
||||
this.managerEmail = managerEmail;
|
||||
}
|
||||
|
||||
public String getCommunityPid() {
|
||||
return communityPid;
|
||||
}
|
||||
|
||||
public void setCommunityPid(String communityPid) {
|
||||
this.communityPid = communityPid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Notifications{" +
|
||||
"id='" + id + '\'' +
|
||||
", notifyForNewManagers=" + notifyForNewManagers +
|
||||
", notifyForNewSubscribers=" + notifyForNewSubscribers +
|
||||
", managerEmail='" + managerEmail + '\'' +
|
||||
", communityPid='" + communityPid + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
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; }
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
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; }
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
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++;
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package eu.dnetlib.uoaadmintools.entities;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Subscriber{" +
|
||||
"id='" + id + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Background {
|
||||
|
||||
private String color;
|
||||
private String borderStyle;
|
||||
private String borderColor;
|
||||
private Integer borderWidth;
|
||||
|
||||
public Background() {
|
||||
}
|
||||
|
||||
public Background(String color, String borderStyle, String borderColor, Integer borderWidth) {
|
||||
this.color = color;
|
||||
this.borderStyle = borderStyle;
|
||||
this.borderColor = borderColor;
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getBorderStyle() {
|
||||
return borderStyle;
|
||||
}
|
||||
|
||||
public void setBorderStyle(String borderStyle) {
|
||||
this.borderStyle = borderStyle;
|
||||
}
|
||||
|
||||
public String getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(String borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public Integer getBorderWidth() {
|
||||
return borderWidth;
|
||||
}
|
||||
|
||||
public void setBorderWidth(Integer borderWidth) {
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Box {
|
||||
|
||||
private String borderColor;
|
||||
private String borderStyle;
|
||||
private String borderWidth;
|
||||
private Integer borderRadius;
|
||||
|
||||
public Box() {
|
||||
}
|
||||
|
||||
public Box(String borderColor, String borderStyle, String borderWidth, Integer borderRadius) {
|
||||
this.borderColor = borderColor;
|
||||
this.borderStyle = borderStyle;
|
||||
this.borderWidth = borderWidth;
|
||||
this.borderRadius = borderRadius;
|
||||
}
|
||||
|
||||
public String getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(String borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public String getBorderStyle() {
|
||||
return borderStyle;
|
||||
}
|
||||
|
||||
public void setBorderStyle(String borderStyle) {
|
||||
this.borderStyle = borderStyle;
|
||||
}
|
||||
|
||||
public String getBorderWidth() {
|
||||
return borderWidth;
|
||||
}
|
||||
|
||||
public void setBorderWidth(String borderWidth) {
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
public Integer getBorderRadius() {
|
||||
return borderRadius;
|
||||
}
|
||||
|
||||
public void setBorderRadius(Integer borderRadius) {
|
||||
this.borderRadius = borderRadius;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Button {
|
||||
|
||||
private String backgroundColor;
|
||||
private String color;
|
||||
private String borderStyle;
|
||||
private String borderColor;
|
||||
private Integer borderWidth;
|
||||
private Integer borderRadius;
|
||||
private OnHoverButton onHover;
|
||||
|
||||
public Button() {
|
||||
}
|
||||
|
||||
public Button(String backgroundColor, String color, String borderStyle, String borderColor, Integer borderWidth, Integer borderRadius, OnHoverButton onHover) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.color = color;
|
||||
this.borderStyle = borderStyle;
|
||||
this.borderColor = borderColor;
|
||||
this.borderWidth = borderWidth;
|
||||
this.borderRadius = borderRadius;
|
||||
this.onHover = onHover;
|
||||
}
|
||||
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getBorderStyle() {
|
||||
return borderStyle;
|
||||
}
|
||||
|
||||
public void setBorderStyle(String borderStyle) {
|
||||
this.borderStyle = borderStyle;
|
||||
}
|
||||
|
||||
public String getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(String borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public Integer getBorderWidth() {
|
||||
return borderWidth;
|
||||
}
|
||||
|
||||
public void setBorderWidth(Integer borderWidth) {
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
public Integer getBorderRadius() {
|
||||
return borderRadius;
|
||||
}
|
||||
|
||||
public void setBorderRadius(Integer borderRadius) {
|
||||
this.borderRadius = borderRadius;
|
||||
}
|
||||
|
||||
public OnHoverButton getOnHover() {
|
||||
return onHover;
|
||||
}
|
||||
|
||||
public void setOnHover(OnHoverButton onHover) {
|
||||
this.onHover = onHover;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Buttons {
|
||||
|
||||
private Button darkBackground;
|
||||
private Button lightBackground;
|
||||
|
||||
public Buttons() {
|
||||
}
|
||||
|
||||
public Buttons(Button darkBackground, Button lightBackground) {
|
||||
this.darkBackground = darkBackground;
|
||||
this.lightBackground = lightBackground;
|
||||
}
|
||||
|
||||
public Button getDarkBackground() {
|
||||
return darkBackground;
|
||||
}
|
||||
|
||||
public void setDarkBackground(Button darkBackground) {
|
||||
this.darkBackground = darkBackground;
|
||||
}
|
||||
|
||||
public Button getLightBackground() {
|
||||
return lightBackground;
|
||||
}
|
||||
|
||||
public void setLightBackground(Button lightBackground) {
|
||||
this.lightBackground = lightBackground;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Fonts {
|
||||
|
||||
private String color;
|
||||
private String family;
|
||||
private Integer size;
|
||||
private Integer weight;
|
||||
|
||||
public Fonts() {
|
||||
}
|
||||
|
||||
public Fonts(String color, String family, Integer size, Integer weight) {
|
||||
this.color = color;
|
||||
this.family = family;
|
||||
this.size = size;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return family;
|
||||
}
|
||||
|
||||
public void setFamily(String family) {
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Integer weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Link {
|
||||
|
||||
private String family;
|
||||
private Integer size;
|
||||
private Integer weight;
|
||||
private String color;
|
||||
private OnHoverLink onHover;
|
||||
|
||||
public Link() {
|
||||
}
|
||||
|
||||
public Link(String family, Integer size, Integer weight, String color, OnHoverLink onHover) {
|
||||
this.family = family;
|
||||
this.size = size;
|
||||
this.weight = weight;
|
||||
this.color = color;
|
||||
this.onHover = onHover;
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return family;
|
||||
}
|
||||
|
||||
public void setFamily(String family) {
|
||||
this.family = family;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(Integer weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public OnHoverLink getOnHover() {
|
||||
return onHover;
|
||||
}
|
||||
|
||||
public void setOnHover(OnHoverLink onHover) {
|
||||
this.onHover = onHover;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Links {
|
||||
|
||||
private Link darkBackground;
|
||||
private Link lightBackground;
|
||||
|
||||
public Links() {
|
||||
}
|
||||
|
||||
public Links(Link darkBackground, Link lightBackground) {
|
||||
this.darkBackground = darkBackground;
|
||||
this.lightBackground = lightBackground;
|
||||
}
|
||||
|
||||
public Link getDarkBackground() {
|
||||
return darkBackground;
|
||||
}
|
||||
|
||||
public void setDarkBackground(Link darkBackground) {
|
||||
this.darkBackground = darkBackground;
|
||||
}
|
||||
|
||||
public Link getLightBackground() {
|
||||
return lightBackground;
|
||||
}
|
||||
|
||||
public void setLightBackground(Link lightBackground) {
|
||||
this.lightBackground = lightBackground;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class OnHoverButton {
|
||||
|
||||
private String backgroundColor;
|
||||
private String color;
|
||||
private String borderColor;
|
||||
|
||||
public OnHoverButton() {
|
||||
}
|
||||
|
||||
public OnHoverButton(String backgroundColor, String color, String borderColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.color = color;
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public String getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(String borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class OnHoverLink {
|
||||
|
||||
private String color;
|
||||
|
||||
public OnHoverLink() {
|
||||
}
|
||||
|
||||
public OnHoverLink(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class Panel {
|
||||
|
||||
private Boolean onDarkBackground;
|
||||
private Background background;
|
||||
private Fonts fonts;
|
||||
private Fonts title;
|
||||
private PanelElements panelElements;
|
||||
|
||||
public Panel() {
|
||||
}
|
||||
|
||||
public Panel(Boolean onDarkBackground, Background background, Fonts fonts, Fonts title, PanelElements panelElements) {
|
||||
this.onDarkBackground = onDarkBackground;
|
||||
this.background = background;
|
||||
this.fonts = fonts;
|
||||
this.title = title;
|
||||
this.panelElements = panelElements;
|
||||
}
|
||||
|
||||
public Boolean getOnDarkBackground() {
|
||||
return onDarkBackground;
|
||||
}
|
||||
|
||||
public void setOnDarkBackground(Boolean onDarkBackground) {
|
||||
this.onDarkBackground = onDarkBackground;
|
||||
}
|
||||
|
||||
public Background getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
public void setBackground(Background background) {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
public Fonts getFonts() {
|
||||
return fonts;
|
||||
}
|
||||
|
||||
public void setFonts(Fonts fonts) {
|
||||
this.fonts = fonts;
|
||||
}
|
||||
|
||||
public Fonts getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(Fonts title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public PanelElements getPanelElements() {
|
||||
return panelElements;
|
||||
}
|
||||
|
||||
public void setPanelElements(PanelElements panelElements) {
|
||||
this.panelElements = panelElements;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.layoutEntities;
|
||||
|
||||
public class PanelElements {
|
||||
|
||||
private String backgroundColor;
|
||||
private String borderColor;
|
||||
private String color;
|
||||
|
||||
public PanelElements() {
|
||||
}
|
||||
|
||||
public PanelElements(String backgroundColor, String borderColor, String color) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.borderColor = borderColor;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public String getBorderColor() {
|
||||
return borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(String borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package eu.dnetlib.uoaadmintools.entities.statistics;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by argirok on 15/3/2018.
|
||||
*/
|
||||
public class ChartsMap {
|
||||
Map<String,StatisticsStatus> map = new HashMap<String, StatisticsStatus>();
|
||||
public ChartsMap(){
|
||||
map.put("timeline",new StatisticsStatus());
|
||||
map.put("graph",new StatisticsStatus());
|
||||
map.put("projectTable",new StatisticsStatus());
|
||||
map.put("projectColumn",new StatisticsStatus());
|
||||
map.put("projectPie",new StatisticsStatus());
|
||||
}
|
||||
|
||||
public Map<String, StatisticsStatus> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map<String, StatisticsStatus> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChartsMap{" +
|
||||
"entities=" + map +
|
||||
'}';
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue