Skip to content
Snippets Groups Projects
Commit 239af135 authored by Alexandre TISON's avatar Alexandre TISON
Browse files

Added missing context methods + refactoring current method names

parent 7fcd481c
Branches
Tags
1 merge request!2Feature: context impl
......@@ -147,13 +147,13 @@ public class ArchivingConfigWriter {
return jdbi.withExtension(ContextsCommands.class, dao -> dao.insert(name, description, isActive));
}
public void updateIsActive(int id, boolean isActive) {
public void updateIsContextActive(int id, boolean isActive) {
logger.info("updating context {} with isActive {}", id, isActive);
jdbi.useExtension(ContextsCommands.class, dao -> dao.updateIsActive(id, isActive));
jdbi.useExtension(ContextsCommands.class, dao -> dao.updateIsContextActive(id, isActive));
}
public void updateIsActive(String name, boolean isActive) {
public void updateIsContextActive(String name, boolean isActive) {
logger.info("updating context {} with isActive {}", name, isActive);
jdbi.useExtension(ContextsCommands.class, dao -> dao.updateIsActive(name, isActive));
jdbi.useExtension(ContextsCommands.class, dao -> dao.updateIsContextActive(name, isActive));
}
}
......@@ -42,9 +42,9 @@ public interface ContextsCommands {
int insert(String name, String description, boolean isActive);
@SqlUpdate("UPDATE contexts SET isActive = ? WHERE context_id = ?")
void updateIsActive(int id, boolean isActive);
void updateIsContextActive(int id, boolean isActive);
@SqlUpdate("UPDATE contexts SET isActive = ? WHERE name = ?")
void updateIsActive(String name, boolean isActive);
void updateIsContextActive(String name, boolean isActive);
}
......@@ -40,13 +40,7 @@ import fr.soleil.tango.archiving.config.AttributeParameters;
import fr.soleil.tango.archiving.config.Context;
import fr.soleil.tango.archiving.config.InsertionModes;
import fr.soleil.tango.archiving.config.InsertionStatus;
import fr.soleil.tango.archiving.config.db.timescale.tables.AttributeConfigMapper;
import fr.soleil.tango.archiving.config.db.timescale.tables.AttributeConfigTable;
import fr.soleil.tango.archiving.config.db.timescale.tables.AttributeParametersMapper;
import fr.soleil.tango.archiving.config.db.timescale.tables.AttributeParametersTable;
import fr.soleil.tango.archiving.config.db.timescale.tables.ContextMapper;
import fr.soleil.tango.archiving.config.db.timescale.tables.InsertionModesMapper;
import fr.soleil.tango.archiving.config.db.timescale.tables.InsertionModesTable;
import fr.soleil.tango.archiving.config.db.timescale.tables.*;
import fr.soleil.tango.archiving.exception.NotArchivedAttributeException;
import org.jdbi.v3.core.Jdbi;
......@@ -222,6 +216,13 @@ public class ArchivingConfigFetcher {
return ContextMapper.getContext(jdbi.withExtension(ContextsQueries.class, dao -> dao.select(contextId)));
}
public List<Context> getAllContexts() {
List<Context> result = new ArrayList<>();
List<ContextTable> values = jdbi.withExtension(ContextsQueries.class, ContextsQueries::selectAll);
values.forEach(val -> result.add(ContextMapper.getContext(val)));
return result;
}
public boolean isContextActive(final int contextId) {
return jdbi.withExtension(ContextsQueries.class, dao -> dao.isActive(contextId));
}
......
......@@ -36,6 +36,8 @@ import fr.soleil.tango.archiving.config.db.timescale.tables.ContextTable;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import java.util.List;
public interface ContextsQueries {
@SqlQuery("select * from contexts where context_id = ?")
@RegisterBeanMapper(ContextTable.class)
......@@ -43,7 +45,7 @@ public interface ContextsQueries {
@SqlQuery("select * from contexts")
@RegisterBeanMapper(ContextTable.class)
ContextTable selectAll(int id);
List<ContextTable> selectAll();
@SqlQuery("select is_active from contexts where context_id = ?")
boolean isActive(int id);
......
......@@ -365,4 +365,11 @@ public class TangoArchivingConfigService {
return archivingConfigFetcher.isContextActive(contextId);
}
/**
* Get all archiving contexts
* @return The list of contexts
*/
public List<Context> getAllContexts() {
return archivingConfigFetcher.getAllContexts();
}
}
......@@ -140,8 +140,8 @@ public class TangoArchivingInserterService {
* @param name The context name
* @param isActive True if context is activated
*/
public void updateIsActive(String name, boolean isActive) {
archivingConfigWriter.updateIsActive(name, isActive);
public void updateIsContextActive(String name, boolean isActive) {
archivingConfigWriter.updateIsContextActive(name, isActive);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment