added other dbs
This commit is contained in:
parent
a59aa01aac
commit
295767430e
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
./build.sh && ./start.sh
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
-- TODO: This variable should be obtained from the system ENV
|
||||
\set DB dnet_contexts
|
||||
CREATE DATABASE :DB;
|
||||
\c :DB
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE contexts (
|
||||
id text PRIMARY KEY,
|
||||
label text NOT NULL,
|
||||
type text NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_categories (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES contexts(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_0 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_categories(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_1 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_cat_concepts_lvl_0(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_2 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_cat_concepts_lvl_1(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX ON context_categories (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_0 (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_1 (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_2 (parent);
|
||||
|
||||
COMMIT;
|
|
@ -5,6 +5,49 @@ CREATE DATABASE :DB;
|
|||
|
||||
BEGIN;
|
||||
|
||||
-- PROTOCOLS
|
||||
CREATE TABLE protocols (
|
||||
id text PRIMARY KEY
|
||||
);
|
||||
INSERT INTO protocols(id) VALUES ('oai'),('oai_sets'),('http'),('file'),('classpath'),('fileCSV'),('httpCSV'),('ftp'),('sftp'),('filesystem'),('files_from_metadata'),('files_from_mdstore'),('mongoDump'),('targz'),('zip'),('fileGzip'),('httpList'),('remoteMdstore');
|
||||
|
||||
CREATE TABLE protocol_params (
|
||||
protocol text NOT NULL REFERENCES protocols(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
param_name text NOT NULL,
|
||||
param_label text NOT NULL,
|
||||
param_type text NOT NULL DEFAULT 'TEXT',
|
||||
optional boolean NOT NULL default false,
|
||||
has_sel_function boolean NOT NULL default false,
|
||||
PRIMARY KEY (protocol, param_name)
|
||||
);
|
||||
INSERT INTO protocol_params(protocol, param_name, param_label, param_type, optional, has_sel_function) VALUES
|
||||
('oai', 'set', 'OAI set', 'LIST', true, true),
|
||||
('oai', 'format', 'OAI Metadata Format', 'TEXT', false, false),
|
||||
('http', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('file', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('classpath', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('fileCSV', 'header', 'header', 'TEXT', false, false),
|
||||
('fileCSV', 'separator', 'separator', 'TEXT', false, false),
|
||||
('fileCSV', 'identifier', 'identifier', 'TEXT', false, false),
|
||||
('fileCSV', 'quote', 'quote', 'TEXT', false, false),
|
||||
('httpCSV', 'separator', 'separator', 'TEXT', false, false),
|
||||
('httpCSV', 'identifier', 'identifier', 'TEXT', false, false),
|
||||
('httpCSV', 'quote', 'quote', 'TEXT', false, false),
|
||||
('ftp', 'username', 'username', 'TEXT', false, false),
|
||||
('ftp', 'password', 'password', 'TEXT', false, false),
|
||||
('ftp', 'recursive', 'recursive', 'BOOLEAN', false, false),
|
||||
('ftp', 'extensions', 'extensions', 'LIST', false, false),
|
||||
('sftp', 'username', 'username', 'TEXT', false, false),
|
||||
('sftp', 'password', 'password', 'TEXT', true, false),
|
||||
('sftp', 'authMethod', 'authMethod', 'TEXT', true, false),
|
||||
('sftp', 'privateKeyPath', 'privateKeyPath', 'TEXT', true, false),
|
||||
('sftp', 'port', 'port', 'TEXT', true, false),
|
||||
('sftp', 'recursive', 'recursive', 'BOOLEAN', false, false),
|
||||
('sftp', 'extensions', 'extensions', 'LIST', false, false);
|
||||
|
||||
-- END PROTOCOLS
|
||||
|
||||
-- SERVICES
|
||||
CREATE TABLE dsm_services (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
namespaceprefix character(12) NOT NULL UNIQUE,
|
||||
|
@ -200,4 +243,6 @@ FROM
|
|||
dsm_services s
|
||||
LEFT JOIN dsm_api a ON (s.id = a.service);
|
||||
|
||||
-- END SERVICES
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
-- TODO
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
-- TODO: This variable should be obtained from the system ENV
|
||||
\set DB dnet_mdstores
|
||||
CREATE DATABASE :DB;
|
||||
\c :DB
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE mdstores (
|
||||
id text PRIMARY KEY,
|
||||
format text NOT NULL,
|
||||
layout text NOT NULL,
|
||||
interpretation text NOT NULL,
|
||||
type text NOT NULL,
|
||||
datasource_name text,
|
||||
datasource_id text,
|
||||
api_id text,
|
||||
creation_date timestamp NOT NULL DEFAULT now(),
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE mdstore_versions (
|
||||
id text PRIMARY KEY,
|
||||
mdstore text NOT NULL REFERENCES mdstores(id),
|
||||
writing boolean NOT NULL,
|
||||
readcount int NOT NULL DEFAULT 0,
|
||||
lastupdate timestamp NOT NULL DEFAULT now(),
|
||||
size bigint NOT NULL DEFAULT 0,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE mdstore_current_versions (
|
||||
mdstore text PRIMARY KEY REFERENCES mdstores(id),
|
||||
current_version text NOT NULL REFERENCES mdstore_versions(id)
|
||||
);
|
||||
|
||||
CREATE VIEW mdstores_with_info AS SELECT
|
||||
md.id AS id,
|
||||
md.format AS format,
|
||||
md.layout AS layout,
|
||||
md.type AS type,
|
||||
md.interpretation AS interpretation,
|
||||
md.datasource_name AS datasource_name,
|
||||
md.datasource_id AS datasource_id,
|
||||
md.api_id AS api_id,
|
||||
md.params AS params,
|
||||
md.creation_date as creation_date,
|
||||
cv.current_version AS current_version,
|
||||
v1.lastupdate AS lastupdate,
|
||||
v1.size AS size,
|
||||
count(v2.id) AS n_versions
|
||||
FROM
|
||||
mdstores md
|
||||
LEFT OUTER JOIN mdstore_current_versions cv ON (md.id = cv.mdstore)
|
||||
LEFT OUTER JOIN mdstore_versions v1 ON (cv.current_version = v1.id)
|
||||
LEFT OUTER JOIN mdstore_versions v2 ON (md.id = v2.mdstore)
|
||||
GROUP BY md.id,
|
||||
md.format,
|
||||
md.layout,
|
||||
md.interpretation,
|
||||
md.type,
|
||||
md.datasource_name,
|
||||
md.datasource_id,
|
||||
md.params,
|
||||
md.creation_date,
|
||||
md.api_id,
|
||||
cv.current_version,
|
||||
v1.lastupdate,
|
||||
v1.size;
|
||||
|
||||
COMMIT;
|
|
@ -2,112 +2,6 @@
|
|||
|
||||
BEGIN;
|
||||
|
||||
-- Vocabularies
|
||||
|
||||
CREATE TABLE vocabularies (
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
description text
|
||||
);
|
||||
|
||||
CREATE TABLE vocabulary_terms (
|
||||
vocabulary text NOT NULL REFERENCES vocabularies(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
code text NOT NULL,
|
||||
name text NOT NULL,
|
||||
encoding text DEFAULT 'OPENAIRE',
|
||||
synonyms jsonb,
|
||||
PRIMARY KEY (vocabulary, code)
|
||||
);
|
||||
|
||||
CREATE INDEX ON vocabulary_terms (vocabulary);
|
||||
|
||||
CREATE TABLE protocols (
|
||||
id text PRIMARY KEY
|
||||
);
|
||||
INSERT INTO protocols(id) VALUES ('oai'),('oai_sets'),('http'),('file'),('classpath'),('fileCSV'),('httpCSV'),('ftp'),('sftp'),('filesystem'),('files_from_metadata'),('files_from_mdstore'),('mongoDump'),('targz'),('zip'),('fileGzip'),('httpList'),('remoteMdstore');
|
||||
|
||||
CREATE TABLE protocol_params (
|
||||
protocol text NOT NULL REFERENCES protocols(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
param_name text NOT NULL,
|
||||
param_label text NOT NULL,
|
||||
param_type text NOT NULL DEFAULT 'TEXT',
|
||||
optional boolean NOT NULL default false,
|
||||
has_sel_function boolean NOT NULL default false,
|
||||
PRIMARY KEY (protocol, param_name)
|
||||
);
|
||||
INSERT INTO protocol_params(protocol, param_name, param_label, param_type, optional, has_sel_function) VALUES
|
||||
('oai', 'set', 'OAI set', 'LIST', true, true),
|
||||
('oai', 'format', 'OAI Metadata Format', 'TEXT', false, false),
|
||||
('http', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('file', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('classpath', 'splitOnElement', 'splitOnElement', 'TEXT', false, false),
|
||||
('fileCSV', 'header', 'header', 'TEXT', false, false),
|
||||
('fileCSV', 'separator', 'separator', 'TEXT', false, false),
|
||||
('fileCSV', 'identifier', 'identifier', 'TEXT', false, false),
|
||||
('fileCSV', 'quote', 'quote', 'TEXT', false, false),
|
||||
('httpCSV', 'separator', 'separator', 'TEXT', false, false),
|
||||
('httpCSV', 'identifier', 'identifier', 'TEXT', false, false),
|
||||
('httpCSV', 'quote', 'quote', 'TEXT', false, false),
|
||||
('ftp', 'username', 'username', 'TEXT', false, false),
|
||||
('ftp', 'password', 'password', 'TEXT', false, false),
|
||||
('ftp', 'recursive', 'recursive', 'BOOLEAN', false, false),
|
||||
('ftp', 'extensions', 'extensions', 'LIST', false, false),
|
||||
('sftp', 'username', 'username', 'TEXT', false, false),
|
||||
('sftp', 'password', 'password', 'TEXT', true, false),
|
||||
('sftp', 'authMethod', 'authMethod', 'TEXT', true, false),
|
||||
('sftp', 'privateKeyPath', 'privateKeyPath', 'TEXT', true, false),
|
||||
('sftp', 'port', 'port', 'TEXT', true, false),
|
||||
('sftp', 'recursive', 'recursive', 'BOOLEAN', false, false),
|
||||
('sftp', 'extensions', 'extensions', 'LIST', false, false);
|
||||
|
||||
-- Contexts
|
||||
|
||||
CREATE TABLE contexts (
|
||||
id text PRIMARY KEY,
|
||||
label text NOT NULL,
|
||||
type text NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_categories (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES contexts(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_0 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_categories(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_1 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_cat_concepts_lvl_0(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE context_cat_concepts_lvl_2 (
|
||||
id text NOT NULL PRIMARY KEY,
|
||||
parent text NOT NULL REFERENCES context_cat_concepts_lvl_1(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
label text NOT NULL,
|
||||
claim boolean NOT NULL,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX ON context_categories (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_0 (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_1 (parent);
|
||||
CREATE INDEX ON context_cat_concepts_lvl_2 (parent);
|
||||
|
||||
-- Other Resources
|
||||
|
||||
CREATE TABLE resource_types(
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
|
@ -120,7 +14,8 @@ INSERT INTO resource_types(id, name, content_type) VALUES
|
|||
('cleaning_rule', 'Cleaning Rules', 'application/xml'),
|
||||
('hadoop_job_configuration', 'Hadoop Job Configurations', 'application/xml'),
|
||||
('dedup_configuration', 'Dedup Configurations', 'application/json'),
|
||||
('wf_template', 'Workflow Templates', 'application/json');
|
||||
('wf_template', 'Workflow Templates', 'application/json'),
|
||||
('email_template', 'Email Templates', 'application/json');
|
||||
|
||||
CREATE TABLE resources (
|
||||
id text PRIMARY KEY,
|
||||
|
@ -130,7 +25,7 @@ CREATE TABLE resources (
|
|||
type text NOT NULL REFERENCES resource_types(id),
|
||||
subtype text,
|
||||
creation_date timestamp NOT NULL DEFAULT now(),
|
||||
modification_date timestamp NOT NULL DEFAULT now()
|
||||
modification_date timestamp NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE VIEW resource_types_view AS (
|
||||
|
@ -144,108 +39,6 @@ CREATE VIEW resource_types_view AS (
|
|||
LEFT OUTER JOIN resources r ON (r.type = t.id)
|
||||
GROUP BY t.id, t.name
|
||||
ORDER BY t.name
|
||||
) UNION ALL (
|
||||
SELECT
|
||||
'vocabulary' AS id,
|
||||
'Vocabularies' AS name,
|
||||
'text/plain' AS content_type,
|
||||
count(*) AS count,
|
||||
false AS simple
|
||||
FROM vocabularies
|
||||
) UNION ALL (
|
||||
SELECT
|
||||
'context' AS id,
|
||||
'Contexts' AS name,
|
||||
'text/plain' AS content_type,
|
||||
count(*) AS count,
|
||||
false AS simple
|
||||
FROM contexts
|
||||
) UNION ALL (
|
||||
SELECT
|
||||
'protocol' AS id,
|
||||
'Protocols' AS name,
|
||||
'text/plain' AS content_type,
|
||||
count(*) AS count,
|
||||
false AS simple
|
||||
FROM protocols
|
||||
) UNION ALL (
|
||||
SELECT
|
||||
'email' AS id,
|
||||
'Email templates' AS name,
|
||||
'text/plain' AS content_type,
|
||||
count(*) AS count,
|
||||
false AS simple
|
||||
FROM emails
|
||||
);
|
||||
|
||||
CREATE TABLE mdstores (
|
||||
id text PRIMARY KEY,
|
||||
format text NOT NULL,
|
||||
layout text NOT NULL,
|
||||
interpretation text NOT NULL,
|
||||
type text NOT NULL,
|
||||
datasource_name text,
|
||||
datasource_id text,
|
||||
api_id text,
|
||||
creation_date timestamp NOT NULL DEFAULT now(),
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE mdstore_versions (
|
||||
id text PRIMARY KEY,
|
||||
mdstore text NOT NULL REFERENCES mdstores(id),
|
||||
writing boolean NOT NULL,
|
||||
readcount int NOT NULL DEFAULT 0,
|
||||
lastupdate timestamp NOT NULL DEFAULT now(),
|
||||
size bigint NOT NULL DEFAULT 0,
|
||||
params jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE mdstore_current_versions (
|
||||
mdstore text PRIMARY KEY REFERENCES mdstores(id),
|
||||
current_version text NOT NULL REFERENCES mdstore_versions(id)
|
||||
);
|
||||
|
||||
CREATE VIEW mdstores_with_info AS SELECT
|
||||
md.id AS id,
|
||||
md.format AS format,
|
||||
md.layout AS layout,
|
||||
md.type AS type,
|
||||
md.interpretation AS interpretation,
|
||||
md.datasource_name AS datasource_name,
|
||||
md.datasource_id AS datasource_id,
|
||||
md.api_id AS api_id,
|
||||
md.params AS params,
|
||||
md.creation_date as creation_date,
|
||||
cv.current_version AS current_version,
|
||||
v1.lastupdate AS lastupdate,
|
||||
v1.size AS size,
|
||||
count(v2.id) AS n_versions
|
||||
FROM
|
||||
mdstores md
|
||||
LEFT OUTER JOIN mdstore_current_versions cv ON (md.id = cv.mdstore)
|
||||
LEFT OUTER JOIN mdstore_versions v1 ON (cv.current_version = v1.id)
|
||||
LEFT OUTER JOIN mdstore_versions v2 ON (md.id = v2.mdstore)
|
||||
GROUP BY md.id,
|
||||
md.format,
|
||||
md.layout,
|
||||
md.interpretation,
|
||||
md.type,
|
||||
md.datasource_name,
|
||||
md.datasource_id,
|
||||
md.params,
|
||||
md.creation_date,
|
||||
md.api_id,
|
||||
cv.current_version,
|
||||
v1.lastupdate,
|
||||
v1.size;
|
||||
|
||||
-- Email Templates
|
||||
CREATE TABLE emails (
|
||||
id text PRIMARY KEY,
|
||||
description text NOT NULL,
|
||||
subject text NOT NULL,
|
||||
message text NOT NULL
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
-- TODO: This variable should be obtained from the system ENV
|
||||
\set DB dnet_vocabularies
|
||||
CREATE DATABASE :DB;
|
||||
\c :DB
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE vocabularies (
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
description text
|
||||
);
|
||||
|
||||
CREATE TABLE vocabulary_terms (
|
||||
vocabulary text NOT NULL REFERENCES vocabularies(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
code text NOT NULL,
|
||||
name text NOT NULL,
|
||||
encoding text DEFAULT 'OPENAIRE',
|
||||
synonyms jsonb,
|
||||
PRIMARY KEY (vocabulary, code)
|
||||
);
|
||||
|
||||
CREATE INDEX ON vocabulary_terms (vocabulary);
|
||||
|
||||
COMMIT;
|
|
@ -52,8 +52,8 @@ CREATE TABLE wf_configurations (
|
|||
scheduling_enabled boolean NOT NULL DEFAULT false,
|
||||
scheduling_cron text,
|
||||
scheduling_min_interval int,
|
||||
workflow text REFERENCES resources(id),
|
||||
destroy_wf text REFERENCES resources(id),
|
||||
workflow text,
|
||||
destroy_wf text,
|
||||
system_params jsonb NOT NULL DEFAULT '{}',
|
||||
user_params jsonb NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
@ -62,7 +62,7 @@ CREATE TABLE wf_subscriptions (
|
|||
wf_conf_id text NOT NULL REFERENCES wf_configurations(id),
|
||||
condition text NOT NULL,
|
||||
email text NOT NULL,
|
||||
message_id text NOT NULL REFERENCES emails(id),
|
||||
message_id text NOT NULL,
|
||||
PRIMARY KEY (wf_conf_id, condition, email)
|
||||
);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.DnetRestController;
|
||||
|
@ -28,8 +29,20 @@ public class EmailAjaxController extends DnetRestController {
|
|||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public List<EmailTemplate> saveEmailTemplate(@RequestBody final EmailTemplate email) {
|
||||
emailService.saveEmailTemplate(email);
|
||||
public List<EmailTemplate> newEmailTemplate(@PathVariable final String id,
|
||||
@RequestParam(required = true) final String name,
|
||||
@RequestParam(required = false) final String desc,
|
||||
@RequestBody final EmailTemplate email) {
|
||||
emailService.saveEmailTemplate(null, name, desc, email);
|
||||
return emailService.listEmailTemplates();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}")
|
||||
public List<EmailTemplate> updateEmailTemplate(@PathVariable final String id,
|
||||
@RequestParam(required = false) final String name,
|
||||
@RequestParam(required = false) final String desc,
|
||||
@RequestBody final EmailTemplate email) {
|
||||
emailService.saveEmailTemplate(id, name, desc, email);
|
||||
return emailService.listEmailTemplates();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package eu.dnetlib.utils.mail.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import eu.dnetlib.domain.email.EmailTemplate;
|
||||
|
||||
public interface EmailTemplateRepository extends JpaRepository<EmailTemplate, String> {
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@ package eu.dnetlib.utils.mail.service;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.mail.Authenticator;
|
||||
|
@ -26,12 +26,14 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import eu.dnetlib.common.clients.DnetServiceClientFactory;
|
||||
import eu.dnetlib.common.clients.SimpleResourceClient;
|
||||
import eu.dnetlib.domain.email.EmailMessage;
|
||||
import eu.dnetlib.domain.email.EmailTemplate;
|
||||
import eu.dnetlib.domain.resource.SimpleResource;
|
||||
import eu.dnetlib.errors.DnetException;
|
||||
import eu.dnetlib.errors.DnetRuntimeException;
|
||||
import eu.dnetlib.utils.mail.EmailConfiguration;
|
||||
import eu.dnetlib.utils.mail.repository.EmailTemplateRepository;
|
||||
|
||||
@Service
|
||||
public class EmailService {
|
||||
|
@ -40,7 +42,7 @@ public class EmailService {
|
|||
private final BlockingQueue<Message> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
@Autowired
|
||||
private EmailTemplateRepository emailTemplateRepository;
|
||||
private DnetServiceClientFactory clientFactory;
|
||||
|
||||
@Autowired
|
||||
private EmailConfiguration conf;
|
||||
|
@ -69,19 +71,43 @@ public class EmailService {
|
|||
}
|
||||
|
||||
public List<EmailTemplate> listEmailTemplates() {
|
||||
return emailTemplateRepository.findAll();
|
||||
final SimpleResourceClient client = clientFactory.getClient(SimpleResourceClient.class);
|
||||
return client.listResources("email_template")
|
||||
.stream()
|
||||
.map(id -> client.findResourceContent(id, EmailTemplate.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void saveEmailTemplate(final EmailTemplate email) {
|
||||
if (StringUtils.isBlank(email.getId()) || (email.getId().length() < 10)) {
|
||||
email.setId("email-" + UUID.randomUUID());
|
||||
log.info("Saving new email with id: " + email.getId());
|
||||
public void saveEmailTemplate(final String id, final String name, final String desc, final EmailTemplate email) {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
final SimpleResource simpleResource = clientFactory.getClient(SimpleResourceClient.class).findResource(id);
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
simpleResource.setName(name);
|
||||
}
|
||||
if (StringUtils.isNotBlank(desc)) {
|
||||
simpleResource.setDescription(desc);
|
||||
}
|
||||
clientFactory.getClient(SimpleResourceClient.class).updateResource(simpleResource, email);
|
||||
} else {
|
||||
clientFactory.getClient(SimpleResourceClient.class).prepareNewResource(name, "", "email_template", email);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveEmailTemplate(final SimpleResource metadata, final EmailTemplate email) {
|
||||
|
||||
final SimpleResource simpleResource = new SimpleResource();
|
||||
simpleResource.setCreationDate(null);
|
||||
|
||||
if ((metadata == null) || StringUtils.isBlank(metadata.getId())) {
|
||||
clientFactory.getClient(SimpleResourceClient.class).prepareNewResource("New Mail", "", "email_template", email);
|
||||
} else {
|
||||
clientFactory.getClient(SimpleResourceClient.class).updateResource(simpleResource, email);
|
||||
}
|
||||
emailTemplateRepository.save(email);
|
||||
}
|
||||
|
||||
public void deleteEmailTemplate(final String id) {
|
||||
emailTemplateRepository.deleteById(id);
|
||||
clientFactory.getClient(SimpleResourceClient.class).deleteResource(id);
|
||||
}
|
||||
|
||||
public void sendMail(final EmailMessage email) throws DnetException {
|
||||
|
@ -154,4 +180,5 @@ public class EmailService {
|
|||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.dnetlib.common.clients;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.dnetlib.domain.resource.SimpleResource;
|
||||
|
||||
public class SimpleResourceClient extends DnetServiceClient {
|
||||
|
@ -8,6 +10,11 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
super(baseUrl);
|
||||
}
|
||||
|
||||
public List<String> listResources(final String type) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getResourceContent(final String id, final String type) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
@ -28,4 +35,14 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
|
||||
}
|
||||
|
||||
public void updateResource(final SimpleResource simpleResource, final Object content) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public SimpleResource prepareNewResource(final String name, final String desc, final String type, final Object content) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,46 +2,14 @@ package eu.dnetlib.domain.email;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "emails")
|
||||
public class EmailTemplate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8424437958140000626L;
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "subject")
|
||||
private String subject;
|
||||
|
||||
@Column(name = "message")
|
||||
private String message;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
(cd dnet-app && mvn clean install) && ./docker_start.sh
|
|
@ -9,7 +9,7 @@ services:
|
|||
depends_on:
|
||||
- db-main
|
||||
environment:
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_CONTEXTS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
||||
|
@ -22,7 +22,7 @@ services:
|
|||
depends_on:
|
||||
- db-main
|
||||
environment:
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_VOCS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
||||
|
@ -138,16 +138,22 @@ services:
|
|||
networks:
|
||||
- backend
|
||||
environment:
|
||||
POSTGRES_DB: ${PG_MAIN_DB}
|
||||
POSTGRES_DSM_DB: ${PG_DSM_DB}
|
||||
POSTGRES_WFS_DB: ${PG_WFS_DB}
|
||||
POSTGRES_USER: ${PG_USER}
|
||||
POSTGRES_PASSWORD: ${PG_PASSWORD}
|
||||
POSTGRES_DB: ${PG_MAIN_DB}
|
||||
POSTGRES_DB_DSM: ${PG_DSM_DB}
|
||||
POSTGRES_DB_WFS: ${PG_WFS_DB}
|
||||
POSTGRES_DB_VOCS: ${PG_VOCS_DB}
|
||||
POSTGRES_DB_CONTEXTS: ${PG_CONTEXTS_DB}
|
||||
POSTGRES_DB_MDSTORES: ${PG_MDSTORES_DB}
|
||||
volumes:
|
||||
- pg_main_data:/var/lib/postgresql/data
|
||||
- ./data/sql/resources.sql:/docker-entrypoint-initdb.d/init_resources.sql
|
||||
- ./data/sql/dsm.sql:/docker-entrypoint-initdb.d/init_dsm.sql
|
||||
- ./data/sql/wfs.sql:/docker-entrypoint-initdb.d/init_wfs.sql
|
||||
- ./data/sql/vocabularies.sql:/docker-entrypoint-initdb.d/init_vocabularies.sql
|
||||
- ./data/sql/contexts.sql:/docker-entrypoint-initdb.d/init_contexts.sql
|
||||
- ./data/sql/mdstores.sql:/docker-entrypoint-initdb.d/init_mdstores.sql
|
||||
|
||||
db-mdstores:
|
||||
image: postgres:15.4
|
||||
|
@ -157,11 +163,11 @@ services:
|
|||
networks:
|
||||
- backend
|
||||
environment:
|
||||
POSTGRES_DB: ${PG_MDSTORE_CONTENT_DB}
|
||||
POSTGRES_USER: ${PG_USER}
|
||||
POSTGRES_PASSWORD: ${PG_PASSWORD}
|
||||
POSTGRES_DB: ${PG_MDSTORE_DB}
|
||||
volumes:
|
||||
- ./data/sql/mdstores:/docker-entrypoint-initdb.d/init.sql
|
||||
- ./data/sql/mdstore_content.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- pg_mdstore_data:/var/lib/postgresql/data
|
||||
|
||||
solr:
|
||||
|
|
|
@ -9,7 +9,10 @@ export PG_USER=dnet
|
|||
export PG_PASSWORD=ax45vs#1A
|
||||
export PG_MAIN_DB=dnet_is
|
||||
export PG_DSM_DB=dnet_dsm
|
||||
export PG_MDSTORE_DB=dnet_mdstores
|
||||
export PG_MDSTORES_DB=dnet_mdstores
|
||||
export PG_WFS_DB=dnet_wfs
|
||||
export PG_VOCS_DB=dnet_vocabularies
|
||||
export PG_CONTEXTS_DB=dnet_contexts
|
||||
export PG_MDSTORE_CONTENT_DB=dnet_mdstore_content
|
||||
|
||||
docker-compose up --force-recreate --build
|
Loading…
Reference in New Issue