, IovBaseRepository {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(IovId id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(Iov entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- Iov save(Iov entity);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataBaseCustom.java b/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataBaseCustom.java
deleted file mode 100644
index 6f27a4cc..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataBaseCustom.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.pojo.Payload;
-import hep.crest.swagger.model.PayloadDto;
-
-import java.io.InputStream;
-
-/**
- * @author formica
- *
- */
-public interface PayloadDataBaseCustom {
-
-
- /**
- * @param id
- * the String
- * @return String
- */
- String exists(String id);
-
- /**
- * @param id
- * the String
- * @return Payload
- */
- PayloadDto find(String id);
-
- /**
- * @param id
- * the String
- * @return Payload
- */
- InputStream findData(String id);
-
- /**
- * The method does not access blob data.
- *
- * @param id
- * the String
- * @return The payload or null.
- */
- PayloadDto findMetaInfo(String id);
-
- /**
- * @param entity
- * the PayloadDto
- * @return Either the entity which has been saved or null.
- * @throws CdbServiceException
- * It should in reality not throw any exception
- */
- PayloadDto save(PayloadDto entity);
-
- /**
- * @param entity
- * the PayloadDto
- * @param is
- * the InputStream
- * @return Either the entity which has been saved or null.
- * @throws CdbServiceException
- * If an Exception occurred
- */
- PayloadDto save(PayloadDto entity, InputStream is);
-
- /**
- * @return Payload
- */
- Payload saveNull();
-
- /**
- * @param id
- * the String
- * @return
- */
- void delete(String id);
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataDBImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataDBImpl.java
deleted file mode 100644
index 0a6181ca..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataDBImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import javax.sql.DataSource;
-import java.io.InputStream;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * An implementation for requests using Oracle and other database.
- *
- * @author formica
- */
-public class PayloadDataDBImpl extends AbstractPayloadDataGeneral implements PayloadDataBaseCustom {
-
- /**
- * @param ds the DataSource
- */
- public PayloadDataDBImpl(DataSource ds) {
- super(ds);
- }
-
- /**
- * @param rs
- * @param key
- * @return byte[]
- * @throws SQLException
- */
- @Override
- protected byte[] getBlob(ResultSet rs, String key) throws SQLException {
- return rs.getBytes(key);
- }
-
-
- /**
- * Transform the byte array from the Blob into a binary stream.
- *
- * @param rs
- * @param key
- * @return InputStream
- * @throws SQLException
- */
- @Override
- protected InputStream getBlobAsStream(ResultSet rs, String key) throws SQLException {
- return rs.getBlob(key).getBinaryStream();
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataPostgresImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataPostgresImpl.java
deleted file mode 100644
index 80fbda06..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataPostgresImpl.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.handlers.PostgresBlobHandler;
-import hep.crest.data.repositories.externals.SqlRequests;
-import hep.crest.swagger.model.PayloadDto;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.sql.DataSource;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Calendar;
-
-/**
- * An implementation for requests using Postgres database.
- *
- * @author formica
- */
-public class PayloadDataPostgresImpl extends AbstractPayloadDataGeneral implements PayloadDataBaseCustom {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(PayloadDataPostgresImpl.class);
-
- /**
- * Create Blob handler for postgres.
- */
- private PostgresBlobHandler bhandler = new PostgresBlobHandler();
-
- /**
- * @param ds the DataSource
- */
- public PayloadDataPostgresImpl(DataSource ds) {
- super(ds);
- }
-
- @Override
- protected InputStream getBlobAsStream(ResultSet rs, String key) {
- try {
- // Use the local getBlob
- byte[] buf = this.getBlob(rs, key);
- return new ByteArrayInputStream(buf);
- }
- catch (SQLException e) {
- log.error("Cannot get stream from byte array: {}", e.getMessage());
- }
- return null;
- }
-
- @Override
- protected byte[] getBlob(ResultSet rs, String key) throws SQLException {
- byte[] buf = null;
- Long oid = rs.getLong(key);
- log.info("Retrieve blob from oid {}", oid);
- try (Connection conn = super.getDs().getConnection();) {
- conn.setAutoCommit(false);
- buf = bhandler.getlargeObj(oid, conn);
- }
- return buf;
- }
-
- @Override
- protected PayloadDto saveBlobAsBytes(PayloadDto entity) {
-
- final String tablename = this.tablename();
-
- final String sql = SqlRequests.getInsertAllQuery(tablename);
-
- log.info("Insert Payload {} using JDBCTEMPLATE ", entity.getHash());
-
- final InputStream is = new ByteArrayInputStream(entity.getData());
- final InputStream sis = new ByteArrayInputStream(entity.getStreamerInfo());
-
- execute(is, sis, sql, entity);
- log.debug("Search for stored payload as a verification, use hash {}", entity.getHash());
- return findMetaInfo(entity.getHash());
- }
-
- @Override
- protected PayloadDto saveBlobAsStream(PayloadDto entity, InputStream is) {
- final String tablename = this.tablename();
-
- final String sql = SqlRequests.getInsertAllQuery(tablename);
-
- log.info("Insert Payload {} using JDBCTEMPLATE", entity.getHash());
- log.debug("Streamer info {} ", entity.getStreamerInfo());
- final InputStream sis = new ByteArrayInputStream(entity.getStreamerInfo());
-
- execute(is, sis, sql, entity);
- return findMetaInfo(entity.getHash());
- }
-
- /**
- * @param is the InputStream
- * @param sis the InputStream
- * @param sql the String
- * @param entity the PayloadDto
- * @return
- * @throws CdbServiceException If an Exception occurred
- */
- protected void execute(InputStream is, InputStream sis, String sql, PayloadDto entity) {
- final Calendar calendar = Calendar.getInstance();
- final java.sql.Date inserttime = new java.sql.Date(calendar.getTime().getTime());
- entity.setInsertionTime(calendar.getTime());
-
- try (Connection conn = super.getDs().getConnection();
- PreparedStatement ps = conn.prepareStatement(sql);) {
- conn.setAutoCommit(false);
- final long oid = bhandler.getLargeObjectId(conn, is, entity);
- final long sioid = bhandler.getLargeObjectId(conn, sis, null);
-
- ps.setString(1, entity.getHash());
- ps.setString(2, entity.getObjectType());
- ps.setString(3, entity.getVersion());
- ps.setLong(4, oid);
- ps.setLong(5, sioid);
- ps.setDate(6, inserttime);
- ps.setInt(7, entity.getSize());
- log.info("Dump preparedstatement {} ", ps);
- ps.executeUpdate();
- conn.commit();
- }
- catch (final SQLException e) {
- log.error("Sql exception when storing payload with sql {} : {}", sql, e.getMessage());
- }
- finally {
- try {
- is.close();
- sis.close();
- }
- catch (final IOException e) {
- log.error("Error in closing streams...potential leak: {}", e.getMessage());
- }
- }
- }
-
- @Override
- @Transactional
- public void delete(String id) {
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(super.getDs());
- final String tablename = this.tablename();
- final String sqlget = SqlRequests.getFindDataQuery(tablename);
- final String sql = SqlRequests.getDeleteQuery(tablename);
- log.info("Remove payload with hash {} using JDBC", id);
- Long oid = jdbcTemplate.queryForObject(sqlget,
- new Object[]{id},
- (rs, row) -> rs.getLong(1));
- jdbcTemplate.execute("select lo_unlink(" + oid + ")");
- jdbcTemplate.update(sql, id);
- log.debug("Entity removal done...");
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataSQLITEImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataSQLITEImpl.java
deleted file mode 100644
index 3d678337..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDataSQLITEImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.handlers.PayloadHandler;
-
-import javax.sql.DataSource;
-import javax.sql.rowset.serial.SerialBlob;
-import java.io.InputStream;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * An implementation for requests using SQLite database.
- *
- * @author formica
- */
-public class PayloadDataSQLITEImpl extends AbstractPayloadDataGeneral implements PayloadDataBaseCustom {
-
-
- /**
- * @param ds the DataSource
- */
- public PayloadDataSQLITEImpl(DataSource ds) {
- super(ds);
- }
-
- @Override
- protected byte[] getBlob(ResultSet rs, String key) throws SQLException {
- SerialBlob blob = new SerialBlob(rs.getBytes(key));
- return PayloadHandler.getBytesFromInputStream(blob.getBinaryStream());
- }
-
- @Override
- protected InputStream getBlobAsStream(ResultSet rs, String key) throws SQLException {
- SerialBlob blob = new SerialBlob(rs.getBytes(key));
- return blob.getBinaryStream();
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDirectoryImplementation.java b/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDirectoryImplementation.java
deleted file mode 100644
index 52078907..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/PayloadDirectoryImplementation.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.utils.DirectoryUtilities;
-import hep.crest.swagger.model.PayloadDto;
-
-/**
- * @author formica
- *
- */
-public class PayloadDirectoryImplementation {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(PayloadDirectoryImplementation.class);
-
- /**
- * Directory tools.
- */
- private DirectoryUtilities dirtools = null;
-
- /**
- * Default ctor.
- */
- public PayloadDirectoryImplementation() {
- super();
- }
-
- /**
- * @param dutils
- * the DirectoryUtilities
- */
- public PayloadDirectoryImplementation(DirectoryUtilities dutils) {
- super();
- this.dirtools = dutils;
- }
-
- /**
- * @param du
- * the DirectoryUtilities
- */
- public void setDirtools(DirectoryUtilities du) {
- this.dirtools = du;
- }
-
- /**
- * @param hash
- * the String
- * @return PayloadDto
- * @throws CdbServiceException
- * If an Exception occurred
- */
- public PayloadDto find(String hash) {
- final Path payloadpath = dirtools.getPayloadPath();
- final String hashdir = dirtools.hashdir(hash);
- final Path payloadhashpath = Paths.get(payloadpath.toString(), hashdir);
- if (!payloadhashpath.toFile().exists()) {
- throw new CdbServiceException("Cannot find hash dir " + payloadhashpath.toString());
- }
- final String filename = hash + ".blob";
- final Path payloadfilepath = Paths.get(payloadhashpath.toString(), filename);
- if (!payloadfilepath.toFile().exists()) {
- throw new CdbServiceException("Cannot find file for " + payloadfilepath.toString());
- }
-
- final StringBuilder buf = new StringBuilder();
- try (BufferedReader reader = Files.newBufferedReader(payloadfilepath,
- dirtools.getCharset())) {
- String line = null;
- while ((line = reader.readLine()) != null) {
- log.debug(line);
- buf.append(line);
- }
- final String jsonstring = buf.toString();
- if (jsonstring.isEmpty()) {
- return null;
- }
- return dirtools.getMapper().readValue(jsonstring, PayloadDto.class);
- }
- catch (final IOException x) {
- log.error("Cannot find payload for hash {}: {}", hash, x);
- }
- return null;
- }
-
- /**
- * @param dto
- * the PayloadDto
- * @return String
- */
- public String save(PayloadDto dto) {
-
- try {
- final String hash = dto.getHash();
- final Path payloadpath = dirtools.getPayloadPath();
-
- final String hashdir = dirtools.hashdir(hash);
- final String payloadfilename = hash + ".blob";
-
- final Path payloadhashdir = Paths.get(payloadpath.toString(), hashdir);
- if (!payloadhashdir.toFile().exists()) {
- Files.createDirectories(payloadhashdir);
- }
- final Path payloadfilepath = Paths.get(payloadhashdir.toString(), payloadfilename);
- if (!payloadfilepath.toFile().exists()) {
- // The payload does not exists: create the new file.
- Files.createFile(payloadfilepath);
- }
- else {
- // The payload already exists. Return directly the hash.
- return hash;
- }
- final String jsonstr = dirtools.getMapper().writeValueAsString(dto);
-
- this.writeBuffer(jsonstr, payloadfilepath);
- return hash;
- }
- catch (final RuntimeException | IOException x) {
- log.error("Cannot save payload dto {} : {}", dto, x);
- }
- return null;
- }
-
- /**
- * @param jsonstr
- * the String
- * @param payloadfilepath
- * the Path
- * @throws IOException
- * If an Exception occurred
- */
- protected void writeBuffer(String jsonstr, Path payloadfilepath) throws IOException {
- try (BufferedWriter writer = Files.newBufferedWriter(payloadfilepath,
- dirtools.getCharset())) {
- writer.write(jsonstr);
- }
- catch (final IOException x) {
- log.error("Cannot write string {} in {}", jsonstr, payloadfilepath);
- throw x;
- }
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagBaseRepository.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagBaseRepository.java
deleted file mode 100644
index be6bbeb7..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagBaseRepository.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories;
-
-import java.util.List;
-
-import org.springframework.data.querydsl.QuerydslPredicateExecutor;
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.transaction.annotation.Transactional;
-
-import hep.crest.data.pojo.Tag;
-
-/**
- * @author formica
- *
- */
-@Transactional(readOnly = true)
-public interface TagBaseRepository
- extends PagingAndSortingRepository, QuerydslPredicateExecutor {
-
- /**
- * @param name
- * the String
- * @return Tag
- */
- Tag findByName(@Param("name") String name);
-
- /**
- * @param name
- * the String
- * @return List
- */
- List findByNameLike(@Param("name") String name);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagDirectoryImplementation.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagDirectoryImplementation.java
deleted file mode 100644
index 1dcaa215..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagDirectoryImplementation.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.utils.DirectoryUtilities;
-import hep.crest.swagger.model.TagDto;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * @author formica
- *
- */
-public class TagDirectoryImplementation {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(TagDirectoryImplementation.class);
-
- /**
- * The directory tools.
- */
- private DirectoryUtilities dirtools = null;
-
- /**
- * Default ctor.
- */
- public TagDirectoryImplementation() {
- }
-
- /**
- * @param dutils
- * the DirectoryUtilities
- */
- public TagDirectoryImplementation(DirectoryUtilities dutils) {
- this.dirtools = dutils;
- }
-
- /**
- * @param du
- * the DirectoryUtilities
- */
- public void setDirtools(DirectoryUtilities du) {
- this.dirtools = du;
- }
-
- /**
- * @param id
- * the String
- * @return boolean
- */
- public boolean exists(String id) {
- try {
- dirtools.getTagPath(id);
- return true;
- }
- catch (final CdbServiceException e) {
- log.error("Cannot find tag directory {} : {}", id, e.getMessage());
- return false;
- }
- }
-
- /**
- * @param id
- * the String
- * @return TagDto
- */
- public TagDto findOne(String id) {
-
- Path tagfilepath;
- try {
- tagfilepath = dirtools.getTagFilePath(id);
- return readTagFile(tagfilepath);
- }
- catch (final CdbServiceException e) {
- log.error("Cannot find tag {} : {}", id, e.getMessage());
- }
- return null;
- }
-
- /**
- * @param tagfilepath
- * the Path
- * @return TagDto
- */
- protected TagDto readTagFile(Path tagfilepath) {
- final StringBuilder buf = new StringBuilder();
- try (BufferedReader reader = Files.newBufferedReader(tagfilepath, dirtools.getCharset())) {
- String line = null;
- while ((line = reader.readLine()) != null) {
- log.debug("Reading line from file {}", line);
- buf.append(line);
- }
- final String jsonstring = buf.toString();
- final TagDto readValue = dirtools.getMapper().readValue(jsonstring, TagDto.class);
- log.debug("Parsed json to get tag object {} with field {} " + " and description {}",
- readValue, readValue.getName(), readValue.getDescription());
- return readValue;
- }
- catch (final IOException e) {
- log.error("Error in reading tag file from path {}: {}", tagfilepath, e.getMessage());
- }
- return null;
- }
-
- /**
- * @return List
- */
- public List findAll() {
- List tagnames;
- tagnames = dirtools.getTagDirectories();
- return tagnames.stream().map(this::findOne).collect(Collectors.toList());
- }
-
- /**
- * @return long
- */
- public long count() {
- final List dtolist = this.findAll();
- return dtolist.size();
- }
-
- /**
- * @param name
- * the String
- * @return List
- */
- public List findByNameLike(String name) {
- final List filteredByNameList;
- filteredByNameList = dirtools.getTagDirectories().stream().filter(x -> x.matches(name))
- .collect(Collectors.toList());
- return filteredByNameList.stream().map(this::findOne).collect(Collectors.toList());
- }
-
- /**
- * @param entity
- * the TagDto
- * @return TagDto
- */
- public TagDto save(TagDto entity) {
- final String tagname = entity.getName();
- try {
- final Path tagpath = dirtools.createIfNotexistsTag(tagname);
- if (tagpath != null) {
- final Path filepath = Paths.get(tagpath.toString(), dirtools.getTagfile());
- Files.deleteIfExists(filepath);
- if (!filepath.toFile().exists()) {
- Files.createFile(filepath);
- }
- final String jsonstr = dirtools.getMapper().writeValueAsString(entity);
- writeTagFile(jsonstr, filepath);
- return entity;
- }
- }
- catch (final RuntimeException | IOException x) {
- log.error("Cannot save tag dto {} : {}", entity, x.getMessage());
- }
- return null;
- }
-
- /**
- * @param jsonstr
- * the String
- * @param filepath
- * the Path
- * @throws CdbServiceException
- * If an Exception occurred
- */
- protected void writeTagFile(String jsonstr, Path filepath) {
- try (BufferedWriter writer = Files.newBufferedWriter(filepath, dirtools.getCharset())) {
- writer.write(jsonstr);
- }
- catch (final IOException x) {
- throw new CdbServiceException("Cannot write " + jsonstr + " in JSON file", x);
- }
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDBImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDBImpl.java
deleted file mode 100644
index 014e59a4..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDBImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import javax.sql.DataSource;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * @author formica
- */
-public class TagMetaDBImpl extends TagMetaGeneral implements TagMetaDataBaseCustom {
-
- /**
- * Default ctor.
- *
- * @param ds the DataSource
- */
- public TagMetaDBImpl(DataSource ds) {
- super(ds);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see hep.crest.data.repositories.TagMetaGeneral#getBlob(java.sql.ResultSet,
- * java.lang.String)
- */
- @Override
- protected String getBlob(ResultSet rs, String key) throws SQLException {
- return new String(rs.getBytes(key));
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDataBaseCustom.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDataBaseCustom.java
deleted file mode 100644
index 422d11d2..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaDataBaseCustom.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.swagger.model.TagMetaDto;
-
-/**
- * @author formica
- *
- */
-public interface TagMetaDataBaseCustom {
-
- /**
- * @param id
- * the String
- * @return TagMetaDto
- */
- TagMetaDto find(String id);
-
- /**
- * The method does not access blob data.
- *
- * @param id
- * the String
- * @return The tag metadata or null.
- */
- TagMetaDto findMetaInfo(String id);
-
- /**
- * @param entity
- * the TagMetaDto
- * @return Either the entity which has been saved or null.
- * @throws CdbServiceException
- * It should in reality not throw any exception
- */
- TagMetaDto save(TagMetaDto entity);
-
- /**
- * @param entity
- * the TagMetaDto
- * @return Either the entity which has been updated or null.
- * @throws CdbServiceException
- * It should in reality not throw any exception
- */
- TagMetaDto update(TagMetaDto entity);
-
- /**
- * @param id
- * the String
- * @return
- */
- void delete(String id);
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaGeneral.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaGeneral.java
deleted file mode 100644
index 5486e38b..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaGeneral.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.handlers.PayloadHandler;
-import hep.crest.data.pojo.TagMeta;
-import hep.crest.data.repositories.externals.TagMetaRequests;
-import hep.crest.swagger.model.TagMetaDto;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.persistence.Table;
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Calendar;
-
-/**
- * General base class for repository implementations.
- *
- * @author formica
- */
-public abstract class TagMetaGeneral extends DataGeneral implements TagMetaDataBaseCustom {
-
- /**
- * Logger.
- */
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- /**
- * @param ds the DataSource
- */
- protected TagMetaGeneral(DataSource ds) {
- super(ds);
- super.setAnn(TagMeta.class.getAnnotation(Table.class));
- }
-
- @Override
- public TagMetaDto save(TagMetaDto entity) {
- TagMetaDto savedentity = null;
- try {
- savedentity = this.saveBlobAsBytes(entity);
- }
- catch (final Exception e) {
- log.error("Error in save paylod dto : {}", e.getMessage());
- }
- return savedentity;
- }
-
- @Override
- public TagMetaDto update(TagMetaDto entity) {
- TagMetaDto savedentity = null;
- try {
- savedentity = this.updateAsBytes(entity);
- }
- catch (final Exception e) {
- log.error("Error in save paylod dto : {}", e.getMessage());
- }
- return savedentity;
- }
-
- @Override
- @Transactional
- public void delete(String id) {
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getDeleteQuery(tablename);
- log.debug("Remove tag meta with tag name {} using JDBCTEMPLATE", id);
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(getDs());
- jdbcTemplate.update(sql, id);
- log.debug("Entity removal done...");
- }
-
- @Override
- @Transactional
- public TagMetaDto find(String id) {
- log.debug("Find tag meta {} using JDBCTEMPLATE", id);
- try {
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(getDs());
- final String tablename = this.tablename();
-
- final String sql = TagMetaRequests.getFindQuery(tablename);
- log.debug("Use sql request {}", sql);
- // Be careful, this seems not to work with Postgres: probably getBlob loads an
- // OID and not the byte[]
- // Temporarely, try to create a postgresql implementation of this class.
-
- return jdbcTemplate.queryForObject(sql, new Object[]{id}, (rs, num) -> {
- final TagMetaDto entity = new TagMetaDto();
- entity.setTagName(rs.getString("TAG_NAME"));
- entity.setDescription(rs.getString("DESCRIPTION"));
- entity.setChansize(rs.getInt("CHANNEL_SIZE"));
- entity.setColsize(rs.getInt("COLUMN_SIZE"));
- entity.setInsertionTime(rs.getDate("INSERTION_TIME"));
- entity.setTagInfo(getBlob(rs, "TAG_INFO"));
- return entity;
- });
- }
- catch (final Exception e) {
- log.warn("Could not find entry for tag name {}", id);
- }
- return null;
- }
-
- @Override
- @Transactional
- public TagMetaDto findMetaInfo(String id) {
- log.debug("Find tag meta info {} using JDBCTEMPLATE", id);
- try {
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(getDs());
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getFindMetaQuery(tablename);
-
- return jdbcTemplate.queryForObject(sql, new Object[]{id}, (rs, num) -> {
- final TagMetaDto entity = new TagMetaDto();
- entity.setTagName(rs.getString("TAG_NAME"));
- entity.setDescription(rs.getString("DESCRIPTION"));
- entity.setChansize(rs.getInt("CHANNEL_SIZE"));
- entity.setColsize(rs.getInt("COLUMN_SIZE"));
- entity.setInsertionTime(rs.getDate("INSERTION_TIME"));
- return entity;
- });
- }
- catch (final Exception e) {
- log.warn("Could not find entry for tag {}", id);
- }
- return null;
- }
-
- /**
- * @param is the InputStream
- * @param sql the String
- * @param entity the TagMetaDto
- * @return
- * @throws CdbServiceException If an Exception occurred
- */
- protected void execute(InputStream is, String sql, TagMetaDto entity) {
-
- final Calendar calendar = Calendar.getInstance();
- final java.sql.Date inserttime = new java.sql.Date(calendar.getTime().getTime());
- entity.setInsertionTime(calendar.getTime());
-
- if (is != null) {
- final byte[] blob = PayloadHandler.getBytesFromInputStream(is);
- if (blob != null) {
- entity.setTagInfo(new String(blob));
- log.debug("Read channel info blob of length {} ", blob.length);
- }
- }
-
- try (Connection conn = getDs().getConnection();
- PreparedStatement ps = conn.prepareStatement(sql);) {
- ps.setString(1, entity.getDescription());
- ps.setInt(2, entity.getChansize());
- ps.setInt(3, entity.getColsize());
- ps.setBytes(4, entity.getTagInfo().getBytes());
- ps.setDate(5, inserttime);
- // Now we set the update where condition, or tagname in insertion
- ps.setString(6, entity.getTagName());
-
- log.debug("Dump preparedstatement {}", ps);
- ps.execute();
- log.debug("Search for stored tag meta as a verification, use tag name {} ",
- entity.getTagName());
- }
- catch (final SQLException e) {
- log.error("Sql exception when storing payload with sql {} : {}", sql, e.getMessage());
- }
- finally {
- try {
- if (is != null) {
- is.close();
- }
- }
- catch (final IOException e) {
- log.error("Error in closing streams...potential leak");
- }
- }
- }
-
- /**
- * @param rs the ResultSet
- * @param key the String
- * @return byte[]
- * @throws SQLException If an Exception occurred
- */
- protected abstract String getBlob(ResultSet rs, String key) throws SQLException;
-
- /**
- * @param entity
- * @return TagMetaDto
- * @throws CdbServiceException
- */
- protected TagMetaDto saveBlobAsBytes(TagMetaDto entity) {
-
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getInsertAllQuery(tablename);
- log.info("Insert Tag meta {} using JDBCTEMPLATE ", entity.getTagName());
- execute(null, sql, entity);
- return findMetaInfo(entity.getTagName());
- }
-
- /**
- * @param entity
- * @return TagMetaDto
- * @throws CdbServiceException
- */
- protected TagMetaDto updateAsBytes(TagMetaDto entity) {
-
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getUpdateQuery(tablename);
- log.info("Update Tag meta {} using JDBCTEMPLATE ", entity.getTagName());
- execute(null, sql, entity);
- return findMetaInfo(entity.getTagName());
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaPostgresImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaPostgresImpl.java
deleted file mode 100644
index 0a2dace6..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaPostgresImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.exceptions.CdbServiceException;
-import hep.crest.data.handlers.PostgresBlobHandler;
-import hep.crest.data.repositories.externals.TagMetaRequests;
-import hep.crest.swagger.model.TagMetaDto;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.sql.DataSource;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Calendar;
-
-/**
- * @author formica
- *
- */
-public class TagMetaPostgresImpl extends TagMetaGeneral implements TagMetaDataBaseCustom {
-
- /**
- * Logger.
- */
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- /**
- * Create Blob handler for postgres.
- */
- private PostgresBlobHandler bhandler = new PostgresBlobHandler();
-
- /**
- * @param ds
- * the DataSource
- */
- public TagMetaPostgresImpl(DataSource ds) {
- super(ds);
- }
-
-
- @Override
- protected String getBlob(ResultSet rs, String key) throws SQLException {
- byte[] buf = null;
- Long oid = rs.getLong(key);
- log.info("Retrieve blob from oid {}", oid);
- try (Connection conn = super.getDs().getConnection();) {
- conn.setAutoCommit(false);
- buf = bhandler.getlargeObj(oid, conn);
- }
- return new String(buf);
- }
-
- /**
- * @param tis
- * the InputStream
- * @param sql
- * the String
- * @param entity
- * the TagMetaDto
- * @throws CdbServiceException
- * If an Exception occurred
- * @return
- */
- @Override
- protected void execute(InputStream tis, String sql, TagMetaDto entity) {
- final Calendar calendar = Calendar.getInstance();
- final java.sql.Date inserttime = new java.sql.Date(calendar.getTime().getTime());
- entity.setInsertionTime(calendar.getTime());
-
- try (Connection conn = super.getDs().getConnection();
- PreparedStatement ps = conn.prepareStatement(sql);) {
- conn.setAutoCommit(false);
- final long tid = bhandler.getLargeObjectId(conn, tis, null);
- ps.setString(1, entity.getDescription());
- ps.setInt(2, entity.getChansize());
- ps.setInt(3, entity.getColsize());
- ps.setLong(4, tid);
- ps.setDate(5, inserttime);
- ps.setString(6, entity.getTagName());
- log.debug("Dump preparedstatement {} ", ps);
- ps.executeUpdate();
- conn.commit();
- }
- catch (final SQLException e) {
- log.error("Sql exception when storing payload with sql {} : {}", sql, e.getMessage());
- }
- finally {
- try {
- tis.close();
- }
- catch (final IOException e) {
- log.error("Error in closing streams...potential leak");
- }
- }
- }
-
- @Override
- @Transactional
- public void delete(String id) {
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(super.getDs());
- final String tablename = this.tablename();
- final String sqlget = TagMetaRequests.getFindTagInfoQuery(tablename);
- final String sql = TagMetaRequests.getDeleteQuery(tablename);
- log.info("Remove payload with hash {} using JDBC", id);
- Long oid = jdbcTemplate.queryForObject(sqlget,
- new Object[]{id},
- (rs, row) -> rs.getLong(1));
- jdbcTemplate.execute("select lo_unlink(" + oid + ")");
- jdbcTemplate.update(sql, id);
- log.debug("Entity removal done...");
- }
-
-
- @Override
- protected TagMetaDto saveBlobAsBytes(TagMetaDto entity) {
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getInsertAllQuery(tablename);
- log.debug("Insert Tag meta {} using JDBCTEMPLATE ", entity.getTagName());
- final InputStream is = new ByteArrayInputStream(entity.getTagInfo().getBytes(StandardCharsets.UTF_8));
- execute(is, sql, entity);
- log.debug("Search for stored tag meta as a verification, use tag {}", entity.getTagName());
- return findMetaInfo(entity.getTagName());
- }
-
-
- @Override
- protected TagMetaDto updateAsBytes(TagMetaDto entity) {
- final String tablename = this.tablename();
- final String sql = TagMetaRequests.getUpdateQuery(tablename);
- log.debug("Update Tag meta {} using JDBCTEMPLATE ", entity.getTagName());
- final InputStream is = new ByteArrayInputStream(entity.getTagInfo().getBytes(StandardCharsets.UTF_8));
- execute(is, sql, entity);
- log.debug("Search for stored tag meta as a verification, use tag {}", entity.getTagName());
- return findMetaInfo(entity.getTagName());
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaSQLITEImpl.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaSQLITEImpl.java
deleted file mode 100644
index 803abcee..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagMetaSQLITEImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.repositories;
-
-import hep.crest.data.handlers.PayloadHandler;
-
-import javax.sql.DataSource;
-import javax.sql.rowset.serial.SerialBlob;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * @author formica
- */
-public class TagMetaSQLITEImpl extends TagMetaDBImpl implements TagMetaDataBaseCustom {
-
- /**
- * Default ctor.
- *
- * @param ds the DataSource
- */
- public TagMetaSQLITEImpl(DataSource ds) {
- super(ds);
- }
-
- @Override
- protected String getBlob(ResultSet rs, String key) throws SQLException {
- SerialBlob blob = new SerialBlob(rs.getBytes(key));
- return new String(PayloadHandler.getBytesFromInputStream(blob.getBinaryStream()));
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/TagRepository.java b/crestdb-data/src/main/java/hep/crest/data/repositories/TagRepository.java
deleted file mode 100644
index 7416358e..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/TagRepository.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories;
-
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-import hep.crest.data.pojo.Tag;
-
-/**
- * @author formica
- *
- */
-@Repository
-public interface TagRepository extends CrudRepository, TagBaseRepository {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(String id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(Tag entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- Tag save(Tag entity);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/SqlRequests.java b/crestdb-data/src/main/java/hep/crest/data/repositories/externals/SqlRequests.java
deleted file mode 100644
index 130110d1..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/SqlRequests.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.externals;
-
-/**
- * @author formica
- *
- */
-public final class SqlRequests {
-
- /**
- * Where condition on HASH.
- */
- private static final String WHERE_HASH = " WHERE HASH=? ";
- /**
- * Insert.
- */
- private static final String INSERT_INTO = "INSERT INTO ";
-
- /**
- * Private ctor.
- */
- private SqlRequests() {
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindQuery(String tablename) {
- return "select HASH,OBJECT_TYPE,VERSION,INSERTION_TIME,DATA,STREAMER_INFO, "
- + " DATA_SIZE from " + tablename + WHERE_HASH;
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getInsertQuery(String tablename) {
- return INSERT_INTO + tablename
- + "(HASH, OBJECT_TYPE, VERSION, DATA, STREAMER_INFO, INSERTION_TIME, DATA_SIZE) "
- + " VALUES (?,?,?,?,?,?,?)";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getExistsHashQuery(String tablename) {
- return "select HASH from " + tablename + WHERE_HASH;
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindMetaQuery(String tablename) {
- return "select HASH,OBJECT_TYPE,VERSION,INSERTION_TIME,STREAMER_INFO, "
- + " DATA_SIZE from " + tablename + WHERE_HASH;
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindDataHashQuery(String tablename) {
- return "select HASH,DATA from " + tablename + WHERE_HASH;
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindDataQuery(String tablename) {
- return "select DATA from " + tablename + WHERE_HASH;
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getInsertAllQuery(String tablename) {
- return INSERT_INTO + tablename
- + "(HASH, OBJECT_TYPE, VERSION, DATA, STREAMER_INFO, INSERTION_TIME,DATA_SIZE) "
- + " VALUES (?,?,?,?,?,?,?)";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getInsertMetaQuery(String tablename) {
- return INSERT_INTO + tablename
- + "(HASH, OBJECT_TYPE, VERSION, STREAMER_INFO, INSERTION_TIME,DATA_SIZE) "
- + " VALUES (?,?,?,?,?,?)";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getDeleteQuery(String tablename) {
- return "DELETE FROM " + tablename + WHERE_HASH;
- }
-
- /**
- * Get payload info query using range.
- *
- * @param tablename
- * @param payloadtablename
- * @return
- */
- public static final String getRangeIovPayloadQuery(String tablename, String payloadtablename) {
- return "select iv.TAG_NAME, iv.SINCE, iv.INSERTION_TIME, iv.PAYLOAD_HASH, pyld.STREAMER_INFO, "
- + " pyld.VERSION, pyld.OBJECT_TYPE, " + " pyld.DATA_SIZE from " + tablename + " iv "
- + " LEFT JOIN " + payloadtablename + " pyld " + " ON iv.PAYLOAD_HASH=pyld.HASH "
- + " where iv.TAG_NAME=? AND iv.SINCE>=COALESCE(" + " (SELECT max(iov2.SINCE) FROM "
- + tablename + " iov2 "
- + " WHERE iov2.TAG_NAME=? AND iov2.SINCE<=? AND iov2.INSERTION_TIME<=? ),0)"
- + " AND iv.SINCE<=? AND iv.INSERTION_TIME<=? "
- + " ORDER BY iv.SINCE ASC, iv.INSERTION_TIME DESC";
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/TagMetaRequests.java b/crestdb-data/src/main/java/hep/crest/data/repositories/externals/TagMetaRequests.java
deleted file mode 100644
index 35e6e594..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/TagMetaRequests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.externals;
-
-/**
- * @author formica
- *
- */
-public final class TagMetaRequests {
-
-
- /**
- * Private ctor.
- */
- private TagMetaRequests() {
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindQuery(String tablename) {
- return "select TAG_NAME,DESCRIPTION, CHANNEL_SIZE, COLUMN_SIZE,INSERTION_TIME,TAG_INFO,CHANNEL_SIZE from "
- + tablename + " where TAG_NAME=?";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindTagInfoQuery(String tablename) {
- return "select TAG_INFO from "
- + tablename + " where TAG_NAME=?";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getInsertAllQuery(String tablename) {
- return "INSERT INTO " + tablename
- + " (DESCRIPTION, CHANNEL_SIZE, COLUMN_SIZE, TAG_INFO, INSERTION_TIME, TAG_NAME) VALUES (?,?,?,?,?,?)";
-
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getFindMetaQuery(String tablename) {
- return "select TAG_NAME,DESCRIPTION,INSERTION_TIME,CHANNEL_SIZE,COLUMN_SIZE from "
- + tablename + " where TAG_NAME=?";
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getUpdateQuery(String tablename) {
- return "UPDATE " + tablename
- + " SET DESCRIPTION=?, CHANNEL_SIZE=?, COLUMN_SIZE=?, TAG_INFO=?, INSERTION_TIME=? WHERE TAG_NAME=?";
-
- }
-
- /**
- * @param tablename the String
- * @return String
- */
- public static final String getDeleteQuery(String tablename) {
- return "DELETE FROM " + tablename + " WHERE TAG_NAME=(?)";
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/package-info.java b/crestdb-data/src/main/java/hep/crest/data/repositories/externals/package-info.java
deleted file mode 100644
index bfbe56d5..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/externals/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author formica
- *
- */
-package hep.crest.data.repositories.externals;
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/package-info.java b/crestdb-data/src/main/java/hep/crest/data/repositories/package-info.java
deleted file mode 100644
index 52e3f994..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author aformic
- *
- */
-package hep.crest.data.repositories;
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderFiltering.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderFiltering.java
deleted file mode 100644
index 6e52098f..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderFiltering.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-/**
- * The utility filtering class to handle SQL requests for folder selection. The
- * methods used are implemented in @see FolderPredicates.
- *
- * @author aformic
- *
- */
-@Component("folderFiltering")
-public class FolderFiltering implements IFilteringCriteria {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(FolderFiltering.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * hep.phycdb.svc.querydsl.IFilteringCriteria#createFilteringConditions(java
- * .util.List, java.lang.Object)
- */
- @Override
- public List createFilteringConditions(List criteria) {
- final List expressions = new ArrayList<>();
- for (final SearchCriteria searchCriteria : criteria) {
- log.debug("search criteria {} {} {}", searchCriteria.getKey(),
- searchCriteria.getOperation(), searchCriteria.getValue());
- // Set to lower case for comparison
- final String key = searchCriteria.getKey().toLowerCase(Locale.ENGLISH);
- if ("nodefullpath".equals(key)) {
- // Filter based on nodefullpath
- final BooleanExpression namelike = FolderPredicates
- .hasNodeFullpathLike(searchCriteria.getValue().toString());
- expressions.add(namelike);
- }
- else if ("tagpattern".equals(key)) {
- // Filter based on tagpattern
- final BooleanExpression namelike = FolderPredicates
- .hasTagPatternLike(searchCriteria.getValue().toString());
- expressions.add(namelike);
- }
- else if ("grouprole".equals(key)) {
- // Filter based on grouprole
- final BooleanExpression namelike = FolderPredicates
- .hasGroupRoleLike(searchCriteria.getValue().toString());
- expressions.add(namelike);
- }
- }
- return expressions;
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderPredicates.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderPredicates.java
deleted file mode 100644
index 98d4b14d..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/FolderPredicates.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-import hep.crest.data.security.pojo.QCrestFolders;
-
-/**
- * @author aformic
- *
- */
-public final class FolderPredicates {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(FolderPredicates.class);
-
- /**
- * Default ctor.
- */
- private FolderPredicates() {
-
- }
-
- /**
- * @param nfp
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasNodeFullpathLike(String nfp) {
- log.debug("hasNodeFullpathLike: argument {}", nfp);
- return QCrestFolders.crestFolders.nodeFullpath.like("%" + nfp + "%");
- }
-
- /**
- * @param tagpt
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasTagPatternLike(String tagpt) {
- log.debug("hasTagPatternLike: argument {}", tagpt);
- return QCrestFolders.crestFolders.tagPattern.like("%" + tagpt + "%");
- }
-
- /**
- * @param gr
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasGroupRoleLike(String gr) {
- log.debug("hasGroupRoleLike: argument {}", gr);
- return QCrestFolders.crestFolders.groupRole.like("%" + gr + "%");
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagFiltering.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagFiltering.java
deleted file mode 100644
index d7ae17d6..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagFiltering.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-/**
- * The utility filtering class to handle SQL requests for folder selection. The
- * methods used are implemented in @see GlobalTagPredicates.
- *
- * @author aformic
- *
- */
-@Component("globalTagFiltering")
-public class GlobalTagFiltering implements IFilteringCriteria {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(GlobalTagFiltering.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * hep.phycdb.svc.querydsl.IFilteringCriteria#createFilteringConditions(java
- * .util.List, java.lang.Object)
- */
- @Override
- public List createFilteringConditions(List criteria) {
-
- final List expressions = new ArrayList<>();
- // Build the list of boolean expressions.
- for (final SearchCriteria searchCriteria : criteria) {
- log.debug("search criteria {} {} {}", searchCriteria.getKey(),
- searchCriteria.getOperation(), searchCriteria.getValue());
- final String key = searchCriteria.getKey().toLowerCase(Locale.US);
- if ("workflow".equals(key)) {
- // Filter based on the worlflow.
- final BooleanExpression wflike = GlobalTagPredicates
- .hasWorkflowLike(searchCriteria.getValue().toString());
- expressions.add(wflike);
- }
- else if ("name".equals(key)) {
- // Filter based on the global tag name.
- final BooleanExpression namelike = GlobalTagPredicates
- .hasNameLike(searchCriteria.getValue().toString());
- expressions.add(namelike);
- }
- else if ("release".equals(key)) {
- // Filter based on the release.
- final BooleanExpression releaselike = GlobalTagPredicates
- .hasReleaseLike(searchCriteria.getValue().toString());
- expressions.add(releaselike);
- }
- else if ("scenario".equals(key)) {
- // Filter based on the scenario.
- final BooleanExpression scenariolike = GlobalTagPredicates
- .hasScenarioLike(searchCriteria.getValue().toString());
- expressions.add(scenariolike);
- }
- else if ("validity".equals(key)) {
- // Filter based on the validity.
- final BooleanExpression validityxthan = GlobalTagPredicates.isValidityXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(validityxthan);
- }
- else if ("insertiontime".equals(key)) {
- // Filter based on the insertion time.
- final BooleanExpression insertionTimexthan = GlobalTagPredicates
- .isInsertionTimeXThan(searchCriteria.getOperation(),
- searchCriteria.getValue().toString());
- expressions.add(insertionTimexthan);
- }
- else if ("type".equals(key)) {
- // Filter based on the type of the global tag.
- final BooleanExpression typeeq = GlobalTagPredicates
- .isType(searchCriteria.getValue().toString());
- expressions.add(typeeq);
- }
- }
- return expressions;
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagPredicates.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagPredicates.java
deleted file mode 100644
index ae9acc8a..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/GlobalTagPredicates.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-import hep.crest.data.pojo.QGlobalTag;
-
-/**
- * @author aformic
- *
- */
-public final class GlobalTagPredicates {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(GlobalTagPredicates.class);
-
- /**
- * Private ctor.
- */
- private GlobalTagPredicates() {
-
- }
-
- /**
- * @param release
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasReleaseLike(String release) {
- log.debug("hasReleaseLike: argument {} ", release);
- return QGlobalTag.globalTag.release.like("%" + release + "%");
- }
-
- /**
- * @param wf
- * the String workflow
- * @return BooleanExpression
- */
- public static BooleanExpression hasWorkflowLike(String wf) {
- log.debug("hasWorkflowLike: argument {} ", wf);
- return QGlobalTag.globalTag.workflow.like("%" + wf + "%");
- }
-
- /**
- * @param name
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasNameLike(String name) {
- log.debug("hasNameLike: argument {} ", name);
- return QGlobalTag.globalTag.name.like("%" + name + "%");
- }
-
- /**
- * @param scenario
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasScenarioLike(String scenario) {
- log.debug("hasScenarioLike: argument {} ", scenario);
- return QGlobalTag.globalTag.scenario.like("%" + scenario + "%");
- }
-
- /**
- * @param oper
- * the String operation
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isValidityXThan(String oper, String num) {
- log.debug("isValidity: argument {} operation {}", num, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QGlobalTag.globalTag.validity.lt(new BigDecimal(num));
- }
- else if (">".equals(oper)) {
- pred = QGlobalTag.globalTag.validity.gt(new BigDecimal(num));
- }
- else if (":".equals(oper)) {
- pred = QGlobalTag.globalTag.validity.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String operation
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isInsertionTimeXThan(String oper, String num) {
- log.debug("isInsertionTimeXThan: argument {} operation {}", num, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QGlobalTag.globalTag.insertionTime.lt(new Date(Long.valueOf(num)));
- }
- else if (">".equals(oper)) {
- pred = QGlobalTag.globalTag.insertionTime.gt(new Date(Long.valueOf(num)));
- }
- else if (":".equals(oper)) {
- pred = QGlobalTag.globalTag.insertionTime.eq(new Date(Long.valueOf(num)));
- }
- return pred;
- }
-
- /**
- * @param typestr
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isType(String typestr) {
- log.debug("isType: argument {} ", typestr);
- final Character type = typestr.charAt(0);
- BooleanExpression pred = null;
- pred = QGlobalTag.globalTag.type.eq(type);
- return pred;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IFilteringCriteria.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IFilteringCriteria.java
deleted file mode 100644
index ce00aad3..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IFilteringCriteria.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.util.List;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-/**
- * @author aformic
- *
- */
-public interface IFilteringCriteria {
-
- /**
- * @param criteria
- * the List
- * @return List
- */
- List createFilteringConditions(List criteria);
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovFiltering.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovFiltering.java
deleted file mode 100644
index efa9b600..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovFiltering.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-/**
- * The utility filtering class to handle SQL requests for folder selection. The
- * methods used are implemented in @see IovPredicates.
- *
- * @author aformic
- *
- */
-@Component("iovFiltering")
-public class IovFiltering implements IFilteringCriteria {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(IovFiltering.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * hep.phycdb.svc.querydsl.IFilteringCriteria#createFilteringConditions(java
- * .util.List, java.lang.Object)
- */
- @Override
- public List createFilteringConditions(List criteria) {
- final List expressions = new ArrayList<>();
- // Build the list of boolean expressions.
- for (final SearchCriteria searchCriteria : criteria) {
- log.debug("search criteria {} {} {}", searchCriteria.getKey(),
- searchCriteria.getOperation(), searchCriteria.getValue());
- final String key = searchCriteria.getKey().toLowerCase(Locale.ENGLISH);
- if ("tagname".equals(key)) {
- // Filter based on the tag name.
- final BooleanExpression objtyplike = IovPredicates
- .hasTagName(searchCriteria.getValue().toString());
- expressions.add(objtyplike);
- }
- else if ("insertiontime".equals(key)) {
- // Filter based on the insertion time.
- final BooleanExpression insertionTimexthan = IovPredicates.isInsertionTimeXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(insertionTimexthan);
- }
- else if ("since".equals(key)) {
- // Filter based on the since time.
- final BigDecimal since = new BigDecimal(searchCriteria.getValue().toString());
- final BooleanExpression sincexthan = IovPredicates
- .isSinceXThan(searchCriteria.getOperation(), since);
- expressions.add(sincexthan);
- }
- }
- return expressions;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovPredicates.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovPredicates.java
deleted file mode 100644
index 4d6b9d8e..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/IovPredicates.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-import hep.crest.data.pojo.QIov;
-
-/**
- * @author aformic
- *
- */
-public final class IovPredicates {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(IovPredicates.class);
-
- /**
- * Default ctor.
- */
- private IovPredicates() {
-
- }
-
- /**
- * @param tagname
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasTagName(String tagname) {
- log.debug("hasTagName: argument {}", tagname);
- return QIov.iov.id.tagName.eq(tagname);
- }
-
- /**
- * @param oper
- * the String
- * @param since
- * the BigDecimal
- * @return BooleanExpression
- */
- public static BooleanExpression isSinceXThan(String oper, BigDecimal since) {
- log.debug("isSinceXThan: argument {} {}", since, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QIov.iov.id.since.lt(since);
- }
- else if (">".equals(oper)) {
- pred = QIov.iov.id.since.gt(since);
- }
- else if (":".equals(oper)) {
- pred = QIov.iov.id.since.eq(since);
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isInsertionTimeXThan(String oper, String num) {
- log.debug("isInsertionTimeXThan: argument {} operation {}", num, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QIov.iov.id.insertionTime.lt(new Date(Long.valueOf(num)));
- }
- else if (">".equals(oper)) {
- pred = QIov.iov.id.insertionTime.gt(new Date(Long.valueOf(num)));
- }
- else if (":".equals(oper)) {
- pred = QIov.iov.id.insertionTime.eq(new Date(Long.valueOf(num)));
- }
- return pred;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/SearchCriteria.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/SearchCriteria.java
deleted file mode 100644
index 38dd4d41..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/SearchCriteria.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-/**
- * Search criteria class. Contains the needed field to create requests to the
- * DB.
- *
- * @author aformic
- *
- */
-public class SearchCriteria {
-
- /**
- * The key.
- */
- private final String key;
- /**
- * The operation.
- */
- private final String operation;
- /**
- * The value.
- */
- private final Object value;
-
- /**
- * Default Ctor.
- *
- * @param key
- * the String
- * @param operation
- * the String
- * @param value
- * the Object
- */
- public SearchCriteria(String key, String operation, Object value) {
- super();
- this.key = key;
- this.operation = operation;
- this.value = value;
- }
-
- /**
- * @return the key
- */
- public String getKey() {
- return key;
- }
-
- /**
- * @return the operation
- */
- public String getOperation() {
- return operation;
- }
-
- /**
- * @return the value
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * @return String
- */
- public String dump() {
- return key + operation + value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "SearchCriteria [key=" + key + ", operation=" + operation + ", value=" + value + "]";
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagFiltering.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagFiltering.java
deleted file mode 100644
index 6ec68c21..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagFiltering.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-/**
- * The utility filtering class to handle SQL requests for folder selection. The
- * methods used are implemented in @see TagPredicates.
- *
- * @author aformic
- *
- */
-@Component("tagFiltering")
-public class TagFiltering implements IFilteringCriteria {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(TagFiltering.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * hep.phycdb.svc.querydsl.IFilteringCriteria#createFilteringConditions(java
- * .util.List, java.lang.Object)
- */
- @Override
- public List createFilteringConditions(List criteria) {
- final List expressions = new ArrayList<>();
- // Build the list of boolean expressions.
- for (final SearchCriteria searchCriteria : criteria) {
- log.debug("search criteria {} {} {}", searchCriteria.getKey(),
- searchCriteria.getOperation(), searchCriteria.getValue());
- final String key = searchCriteria.getKey().toLowerCase(Locale.ENGLISH);
- if ("objecttype".equals(key) || "payloadspec".equals(key)) {
- // Filter based on object type or payload spec (this depends on the versions:
- // ATLAS or CMS).
- final BooleanExpression objtyplike = TagPredicates
- .hasObjectTypeLike(searchCriteria.getValue().toString());
- expressions.add(objtyplike);
- }
- else if ("timetype".equals(key)) {
- // Filter based on time type.
- final BooleanExpression timtyplike = TagPredicates
- .hasTimeTypeLike(searchCriteria.getValue().toString());
- expressions.add(timtyplike);
- }
- else if ("insertiontime".equals(key)) {
- // Filter based on insertion time.
- final BooleanExpression insertionTimexthan = TagPredicates.isInsertionTimeXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(insertionTimexthan);
- }
- else if ("modificationtime".equals(key)) {
- // Filter based on modification time.
- final BooleanExpression modTimexthan = TagPredicates.isModificationTimeXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(modTimexthan);
- }
- else if ("name".equals(key)) {
- // Filter based on tag name.
- final BooleanExpression namelike = TagPredicates
- .hasNameLike(searchCriteria.getValue().toString());
- expressions.add(namelike);
- }
- }
- return expressions;
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagPredicates.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagPredicates.java
deleted file mode 100644
index 93d7df1d..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/TagPredicates.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- *
- */
-package hep.crest.data.repositories.querydsl;
-
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-import hep.crest.data.pojo.QTag;
-
-/**
- * @author aformic
- *
- */
-public final class TagPredicates {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(TagPredicates.class);
-
- /**
- * Private Ctor.
- */
- private TagPredicates() {
-
- }
-
- /**
- * @param name
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasNameLike(String name) {
- log.debug("hasNameLike: argument {}", name);
- return QTag.tag.name.like("%" + name + "%");
- }
-
- /**
- * @param ttype
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasTimeTypeLike(String ttype) {
- log.debug("hasTimeTypeLike: argument {}", ttype);
- return QTag.tag.timeType.like("%" + ttype + "%");
- }
-
- /**
- * @param objtype
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression hasObjectTypeLike(String objtype) {
- log.debug("hasObjectTypeLike: argument {}", objtype);
- return QTag.tag.objectType.like("%" + objtype + "%");
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isInsertionTimeXThan(String oper, String num) {
- log.debug("isInsertionTimeXThan: argument {} operation {}", num, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QTag.tag.insertionTime.lt(new Date(Long.valueOf(num)));
- }
- else if (">".equals(oper)) {
- pred = QTag.tag.insertionTime.gt(new Date(Long.valueOf(num)));
- }
- else if (":".equals(oper)) {
- pred = QTag.tag.insertionTime.eq(new Date(Long.valueOf(num)));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isModificationTimeXThan(String oper, String num) {
- log.debug("isModificationTimeXThan: argument {} operation {}", num, oper);
- BooleanExpression pred = null;
-
- if ("<".equals(oper)) {
- pred = QTag.tag.modificationTime.lt(new Date(Long.valueOf(num)));
- }
- else if (">".equals(oper)) {
- pred = QTag.tag.modificationTime.gt(new Date(Long.valueOf(num)));
- }
- else if (":".equals(oper)) {
- pred = QTag.tag.modificationTime.eq(new Date(Long.valueOf(num)));
- }
- return pred;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/package-info.java b/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/package-info.java
deleted file mode 100644
index 82a5b9ba..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/repositories/querydsl/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author aformic
- *
- */
-package hep.crest.data.repositories.querydsl;
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/RunLumiInfo.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/RunLumiInfo.java
deleted file mode 100644
index a4092ef7..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/RunLumiInfo.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package hep.crest.data.runinfo.pojo;
-// Generated Aug 2, 2016 3:50:25 PM by Hibernate Tools 3.2.2.GA
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.PrePersist;
-import javax.persistence.Table;
-
-import hep.crest.data.config.DatabasePropertyConfigurator;
-
-/**
- * GlobalTag generated by hbm2java.
- */
-@Entity
-@Table(name = "RUN_LUMI_INFO", schema = DatabasePropertyConfigurator.SCHEMA_NAME)
-public class RunLumiInfo implements java.io.Serializable {
-
- /**
- * Serializer.
- */
- private static final long serialVersionUID = 2748272207787384292L;
- /**
- * The since time.
- */
- private BigDecimal since;
- /**
- * The start time of this run.
- */
- private BigDecimal starttime;
- /**
- * The end time of this run.
- */
- private BigDecimal endtime;
- /**
- * The run number.
- */
- private BigDecimal runNumber;
- /**
- * The lumi block.
- */
- private BigDecimal lb;
- /**
- * The insertion time.
- */
- private Date insertionTime;
-
- /**
- * Default ctor.
- */
- public RunLumiInfo() {
- }
-
- /**
- * @param since
- * the BigDecimal
- * @param starttime
- * the BigDecimal
- * @param endtime
- * the BigDecimal
- * @param run
- * the BigDecimal
- * @param lb
- * the BigDecimal
- */
- public RunLumiInfo(BigDecimal since, BigDecimal starttime, BigDecimal endtime, BigDecimal run,
- BigDecimal lb) {
- super();
- this.since = since;
- this.starttime = starttime;
- this.endtime = endtime;
- this.runNumber = run;
- this.lb = lb;
- }
-
- /**
- * @return BigDecimal
- */
- @Id
- @Column(name = "SINCE", nullable = false, precision = 38, scale = 0)
- public BigDecimal getSince() {
- return since;
- }
-
- /**
- * @param since
- * the BigDecimal
- * @return
- */
- public void setSince(BigDecimal since) {
- this.since = since;
- }
-
- /**
- * @return BigDecimal
- */
- @Column(name = "START_TIME", nullable = false, precision = 38, scale = 0)
- public BigDecimal getStarttime() {
- return starttime;
- }
-
- /**
- * @param starttime
- * the BigDecimal
- * @return
- */
- public void setStarttime(BigDecimal starttime) {
- this.starttime = starttime;
- }
-
- /**
- * @return BigDecimal
- */
- @Column(name = "END_TIME", nullable = false, precision = 38, scale = 0)
- public BigDecimal getEndtime() {
- return endtime;
- }
-
- /**
- * @param endtime
- * the BigDecimal
- * @return
- */
- public void setEndtime(BigDecimal endtime) {
- this.endtime = endtime;
- }
-
- /**
- * @return BigDecimal
- */
- @Column(name = "RUN", nullable = false, precision = 38, scale = 0)
- public BigDecimal getRunNumber() {
- return runNumber;
- }
-
- /**
- * @param run
- * the BigDecimal
- * @return
- */
- public void setRunNumber(BigDecimal run) {
- this.runNumber = run;
- }
-
- /**
- * @return BigDecimal
- */
- @Column(name = "LUMI_BLOCK", nullable = false, precision = 38, scale = 0)
- public BigDecimal getLb() {
- return lb;
- }
-
- /**
- * @param lb
- * the BigDecimal
- * @return
- */
- public void setLb(BigDecimal lb) {
- this.lb = lb;
- }
-
- /**
- * @return Date
- */
- public Date getInsertionTime() {
- return insertionTime;
- }
-
- /**
- * @param insertionTime
- * the Date
- * @return
- */
- public void setInsertionTime(Date insertionTime) {
- this.insertionTime = insertionTime;
- }
-
- /**
- * Before saving.
- *
- * @return
- */
- @PrePersist
- public void prePersist() {
- if (this.getInsertionTime() == null) {
- final Timestamp now = new Timestamp(new Date().getTime());
- this.setInsertionTime(now);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "RunLumiInfo [since=" + since + ", starttime=" + starttime + ", endtime=" + endtime
- + ", run=" + runNumber + ", lb=" + lb + ", insertionTime=" + insertionTime + "]";
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/package-info.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/package-info.java
deleted file mode 100644
index 1191d0bc..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/pojo/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author formica
- *
- */
-package hep.crest.data.runinfo.pojo;
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoBaseRepository.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoBaseRepository.java
deleted file mode 100644
index 5b54fb56..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoBaseRepository.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- */
-package hep.crest.data.runinfo.repositories;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.querydsl.QuerydslPredicateExecutor;
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.transaction.annotation.Transactional;
-
-import hep.crest.data.runinfo.pojo.RunLumiInfo;
-
-/**
- * @author formica
- *
- */
-@Transactional(readOnly = true)
-public interface RunLumiInfoBaseRepository
- extends PagingAndSortingRepository,
- QuerydslPredicateExecutor {
-
- /**
- * @param run
- * the BigDecimal
- * @return RunLumiInfo
- */
- RunLumiInfo findByRunNumber(@Param("runNumber") BigDecimal run);
-
- /**
- * @param lower
- * the BigDecimal
- * @param upper
- * the BigDecimal
- * @return List
- */
- @Query("SELECT distinct p FROM RunLumiInfo p " + "WHERE p.runNumber <= ("
- + "SELECT min(pi.runNumber) FROM RunLumiInfo pi " + "WHERE pi.runNumber >= (:upper)) "
- + "AND p.runNumber >= (:lower)" + "ORDER BY p.runNumber ASC")
- List findByRunNumberInclusive(@Param("lower") BigDecimal lower,
- @Param("upper") BigDecimal upper);
-
- /**
- * @param lower
- * the Date
- * @param upper
- * the Date
- * @return List
- */
- @Query("SELECT distinct p FROM RunLumiInfo p "
- + "WHERE p.starttime <= ("
- + "SELECT min(pi.starttime) FROM RunLumiInfo pi "
- + "WHERE pi.starttime >= (:upper)) "
- + "AND p.endtime >= (:lower)"
- + "ORDER BY p.runNumber ASC")
- List findByDateInclusive(@Param("lower") BigDecimal lower, @Param("upper") BigDecimal upper);
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoRepository.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoRepository.java
deleted file mode 100644
index dc8b10c9..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/RunLumiInfoRepository.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- */
-package hep.crest.data.runinfo.repositories;
-
-import java.math.BigDecimal;
-
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-import hep.crest.data.runinfo.pojo.RunLumiInfo;
-
-/**
- * @author formica
- *
- */
-@Repository
-public interface RunLumiInfoRepository
- extends CrudRepository, RunLumiInfoBaseRepository {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(BigDecimal id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(RunLumiInfo entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- RunLumiInfo save(RunLumiInfo entity);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/package-info.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/package-info.java
deleted file mode 100644
index 2d321751..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * @author formica
- *
- */
-package hep.crest.data.runinfo.repositories;
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoFiltering.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoFiltering.java
deleted file mode 100644
index a7c65e3f..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoFiltering.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- */
-package hep.crest.data.runinfo.repositories.querydsl;
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-import hep.crest.data.repositories.querydsl.IFilteringCriteria;
-import hep.crest.data.repositories.querydsl.SearchCriteria;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author aformic
- *
- */
-@Component("runFiltering")
-public class RunLumiInfoFiltering implements IFilteringCriteria {
-
- /**
- * Logger.
- */
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- /*
- * (non-Javadoc)
- *
- * @see
- * hep.phycdb.svc.querydsl.IFilteringCriteria#createFilteringConditions(java
- * .util.List, java.lang.Object)
- */
- @Override
- public List createFilteringConditions(List criteria) {
- final List expressions = new ArrayList<>();
- for (final SearchCriteria searchCriteria : criteria) {
- log.debug("search criteria {} {} {}", searchCriteria.getKey(),
- searchCriteria.getOperation(), searchCriteria.getValue());
- if (searchCriteria.getKey().equals("run")) {
- final BooleanExpression runxthan = RunLumiInfoPredicates.isRunXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(runxthan);
- }
- else if (searchCriteria.getKey().equals("lb")) {
- final BooleanExpression lbxthan = RunLumiInfoPredicates.isLBXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(lbxthan);
- }
- else if (searchCriteria.getKey().equals("insertionTime")) {
- final BooleanExpression insertionTimexthan = RunLumiInfoPredicates
- .isInsertionTimeXThan(searchCriteria.getOperation(),
- searchCriteria.getValue().toString());
- expressions.add(insertionTimexthan);
- }
- else if (searchCriteria.getKey().equals("since")) {
- final BooleanExpression isSinceXThan = RunLumiInfoPredicates.isSinceXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(isSinceXThan);
- }
- else if (searchCriteria.getKey().equals("starttime")) {
- final BooleanExpression isStarttimeXThan = RunLumiInfoPredicates.isStarttimeXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(isStarttimeXThan);
- }
- else if (searchCriteria.getKey().equals("endtime")) {
- final BooleanExpression isEndtimeXThan = RunLumiInfoPredicates.isEndtimeXThan(
- searchCriteria.getOperation(), searchCriteria.getValue().toString());
- expressions.add(isEndtimeXThan);
- }
- }
- return expressions;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoPredicates.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoPredicates.java
deleted file mode 100644
index 0faddb29..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/RunLumiInfoPredicates.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- *
- */
-package hep.crest.data.runinfo.repositories.querydsl;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.querydsl.core.types.Predicate;
-import com.querydsl.core.types.dsl.BooleanExpression;
-
-import hep.crest.data.runinfo.pojo.QRunLumiInfo;
-
-/**
- * Querydsl conditions.
- *
- * @author aformic
- *
- */
-public final class RunLumiInfoPredicates {
-
- /**
- * Logger.
- */
- private static Logger log = LoggerFactory.getLogger(RunLumiInfoPredicates.class);
-
- /**
- * Default Ctor.
- */
- private RunLumiInfoPredicates() {
-
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isRunXThan(String oper, String num) {
- log.debug("isRunXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.runNumber.lt(new BigDecimal(num));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.runNumber.gt(new BigDecimal(num));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.runNumber.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isLBXThan(String oper, String num) {
- log.debug("isLBXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.lb.lt(new BigDecimal(num));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.lb.gt(new BigDecimal(num));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.lb.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isSinceXThan(String oper, String num) {
- log.debug("isSinceXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.since.lt(new BigDecimal(num));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.since.gt(new BigDecimal(num));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.since.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isStarttimeXThan(String oper, String num) {
- log.debug("isStarttimeXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.starttime.lt(new BigDecimal(num));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.starttime.gt(new BigDecimal(num));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.starttime.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isEndtimeXThan(String oper, String num) {
- log.debug("isEndtimeXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.endtime.lt(new BigDecimal(num));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.endtime.gt(new BigDecimal(num));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.endtime.eq(new BigDecimal(num));
- }
- return pred;
- }
-
- /**
- * @param since
- * the BigDecimal
- * @param until
- * the BigDecimal
- * @return BooleanExpression
- */
- public static BooleanExpression hasSinceBetween(BigDecimal since, BigDecimal until) {
- log.debug("hasSinceBetween: argument {} {} ", since, until);
- return QRunLumiInfo.runLumiInfo.since.between(since, until);
- }
-
- /**
- * @param since
- * the BigDecimal
- * @param until
- * the BigDecimal
- * @return BooleanExpression
- */
- public static BooleanExpression hasStarttimeBetween(BigDecimal since, BigDecimal until) {
- log.debug("hasStarttimeBetween: argument {} {} ", since, until);
- return QRunLumiInfo.runLumiInfo.starttime.between(since, until);
- }
-
- /**
- * @param since
- * the BigDecimal
- * @param until
- * the BigDecimal
- * @return BooleanExpression
- */
- public static BooleanExpression hasEndtimeBetween(BigDecimal since, BigDecimal until) {
- log.debug("hasEndtimeBetween: argument {} {} ", since, until);
- return QRunLumiInfo.runLumiInfo.endtime.between(since, until);
- }
-
- /**
- * @param oper
- * the String
- * @param num
- * the String
- * @return BooleanExpression
- */
- public static BooleanExpression isInsertionTimeXThan(String oper, String num) {
- log.debug("isInsertionTimeXThan: argument {} operation {} ", num, oper);
- BooleanExpression pred = null;
-
- if (oper.equals("<")) {
- pred = QRunLumiInfo.runLumiInfo.insertionTime.lt(new Date(Long.valueOf(num)));
- }
- else if (oper.equals(">")) {
- pred = QRunLumiInfo.runLumiInfo.insertionTime.gt(new Date(Long.valueOf(num)));
- }
- else if (oper.equals(":")) {
- pred = QRunLumiInfo.runLumiInfo.insertionTime.eq(new Date(Long.valueOf(num)));
- }
- return pred;
- }
-
- /**
- * @param exp
- * the BooleanExpression
- * @return Predicate
- */
- public static Predicate where(BooleanExpression exp) {
- return exp;
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/package-info.java b/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/package-info.java
deleted file mode 100644
index a0d4aef7..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/runinfo/repositories/querydsl/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author formica
- *
- */
-package hep.crest.data.runinfo.repositories.querydsl;
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestFolders.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestFolders.java
deleted file mode 100644
index 392b2089..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestFolders.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package hep.crest.data.security.pojo;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import hep.crest.data.config.DatabasePropertyConfigurator;
-
-/**
- * @author formica
- *
- */
-@Entity
-@Table(name = "CREST_FOLDERS", schema = DatabasePropertyConfigurator.SCHEMA_NAME)
-public class CrestFolders {
-
- /**
- * The node full path.
- */
- private String nodeFullpath;
- /**
- * The schema name.
- */
- private String schemaName;
- /**
- * The node name.
- */
- private String nodeName;
- /**
- * The node description.
- */
- private String nodeDescription;
- /**
- * The tag base name.
- */
- private String tagPattern;
- /**
- * The group role.
- */
- private String groupRole;
-
- /**
- * Default ctor.
- */
- public CrestFolders() {
- }
-
- /**
- * @param nodeFullpath
- * the String
- * @param schemaName
- * the String
- * @param nodeName
- * the String
- * @param nodeDescription
- * the String
- * @param tagPattern
- * the String
- * @param groupRole
- * the String
- */
- public CrestFolders(String nodeFullpath, String schemaName, String nodeName,
- String nodeDescription, String tagPattern, String groupRole) {
- super();
- this.nodeFullpath = nodeFullpath;
- this.schemaName = schemaName;
- this.nodeName = nodeName;
- this.nodeDescription = nodeDescription;
- this.tagPattern = tagPattern;
- this.groupRole = groupRole;
- }
-
- /**
- * @return String
- */
- @Id
- @Column(name = "CREST_NODE_FULLPATH", unique = true, nullable = false, length = 255)
- public String getNodeFullpath() {
- return nodeFullpath;
- }
-
- /**
- * @param nodeFullpath
- * the String
- * @return
- */
- public void setNodeFullpath(String nodeFullpath) {
- this.nodeFullpath = nodeFullpath;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_SCHEMA_NAME", unique = false, nullable = false, length = 255)
- public String getSchemaName() {
- return schemaName;
- }
-
- /**
- * @param schemaName
- * the String
- * @return
- */
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_NODE_NAME", unique = false, nullable = false, length = 255)
- public String getNodeName() {
- return nodeName;
- }
-
- /**
- * @param nodeName
- * the String
- * @return
- */
- public void setNodeName(String nodeName) {
- this.nodeName = nodeName;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_NODE_DESCRIPTION", unique = false, nullable = false, length = 2000)
- public String getNodeDescription() {
- return nodeDescription;
- }
-
- /**
- * @param nodeDescription
- * the String
- * @return
- */
- public void setNodeDescription(String nodeDescription) {
- this.nodeDescription = nodeDescription;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_TAG_PATTERN", unique = true, nullable = false, length = 255)
- public String getTagPattern() {
- return tagPattern;
- }
-
- /**
- * @param tagPattern
- * the String
- * @return
- */
- public void setTagPattern(String tagPattern) {
- this.tagPattern = tagPattern;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_GROUP_ROLE", unique = false, nullable = false, length = 100)
- public String getGroupRole() {
- return groupRole;
- }
-
- /**
- * @param groupRole
- * the String
- * @return
- */
- public void setGroupRole(String groupRole) {
- this.groupRole = groupRole;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "CrestFolders [nodeFullpath=" + nodeFullpath + ", nodeName=" + nodeName
- + ", nodeDescription=" + nodeDescription + ", tagPattern=" + tagPattern
- + ", groupRole=" + groupRole + "]";
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestRoles.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestRoles.java
deleted file mode 100644
index d5ac61e5..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestRoles.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package hep.crest.data.security.pojo;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import hep.crest.data.config.DatabasePropertyConfigurator;
-
-/**
- * @author formica
- *
- */
-@Entity
-@Table(name = "CREST_ROLES", schema = DatabasePropertyConfigurator.SCHEMA_NAME)
-public class CrestRoles {
-
- /**
- * The role ID.
- */
- private String id;
- /**
- * The role name.
- */
- private String role;
-
- /**
- * Default ctor.
- */
- public CrestRoles() {
- }
-
- /**
- * @param id
- * the String
- * @param role
- * the String
- */
- public CrestRoles(String id, String role) {
- this.id = id;
- this.role = role;
- }
-
- /**
- * @return String
- */
- @Id
- @Column(name = "CREST_USRID", unique = true, nullable = false, length = 100)
- public String getId() {
- return id;
- }
-
- /**
- * @param id
- * the String
- * @return
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_USRROLE", unique = false, nullable = false, length = 100)
- public String getRole() {
- return role;
- }
-
- /**
- * @param role
- * the String
- * @return
- */
- public void setRole(String role) {
- this.role = role;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestUser.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestUser.java
deleted file mode 100644
index f7f7abe0..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/CrestUser.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package hep.crest.data.security.pojo;
-
-import hep.crest.data.config.DatabasePropertyConfigurator;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * @author formica
- */
-@Entity
-@Table(name = "CREST_USERS", schema = DatabasePropertyConfigurator.SCHEMA_NAME)
-public class CrestUser {
-
- /**
- * The id of the user.
- */
- private String id;
- /**
- * The user name.
- */
- private String username;
- /**
- * The password.
- */
- private String password;
-
- /**
- * Default ctor.
- */
- public CrestUser() {
- }
-
- /**
- * @param username the String
- * @param password the String
- */
- public CrestUser(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- /**
- * @return String
- */
- @Id
- @Column(name = "CREST_USRID", unique = true, nullable = false, length = 100)
- public String getId() {
- return id;
- }
-
- /**
- * @param id the String
- * @return
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_USRNAME", unique = true, nullable = false, length = 100)
- public String getUsername() {
- return username;
- }
-
- /**
- * @param username the String
- * @return
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
- /**
- * @return String
- */
- @Column(name = "CREST_USRPSS", unique = true, nullable = false, length = 100)
- public String getPassword() {
- return password;
- }
-
- /**
- * @param password the String
- * @return
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/FolderRepository.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/FolderRepository.java
deleted file mode 100644
index 96e57db4..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/FolderRepository.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- *
- */
-package hep.crest.data.security.pojo;
-
-import java.util.List;
-
-import org.springframework.data.querydsl.QuerydslPredicateExecutor;
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author formica
- *
- */
-@Repository
-public interface FolderRepository extends PagingAndSortingRepository,
- QuerydslPredicateExecutor {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(String id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(CrestFolders entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- CrestFolders save(CrestFolders entity);
-
- /**
- * @param group
- * the String
- * @return List
- */
- List findByGroupRole(@Param("group") String group);
-
- /**
- * @param schema
- * the String
- * @return List
- */
- List findBySchemaName(@Param("schema") String schema);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/RoleRepository.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/RoleRepository.java
deleted file mode 100644
index 5d7531af..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/RoleRepository.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *
- */
-package hep.crest.data.security.pojo;
-
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author formica
- *
- */
-@Repository
-public interface RoleRepository extends CrudRepository {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(String id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(CrestRoles entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- CrestRoles save(CrestRoles entity);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/UserRepository.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/UserRepository.java
deleted file mode 100644
index 95044107..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/UserRepository.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *
- */
-package hep.crest.data.security.pojo;
-
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author formica
- *
- */
-@Repository
-public interface UserRepository extends CrudRepository {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.
- * Object)
- */
- @Override
- void deleteById(String id);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
- */
- @Override
- void delete(CrestUser entity);
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.CrudRepository#save(S)
- */
- @SuppressWarnings("unchecked")
- @Override
- CrestUser save(CrestUser entity);
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/security/pojo/package-info.java b/crestdb-data/src/main/java/hep/crest/data/security/pojo/package-info.java
deleted file mode 100644
index efa92544..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/security/pojo/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author formica
- *
- */
-package hep.crest.data.security.pojo;
diff --git a/crestdb-data/src/main/java/hep/crest/data/serializers/ByteArrayDeserializer.java b/crestdb-data/src/main/java/hep/crest/data/serializers/ByteArrayDeserializer.java
deleted file mode 100644
index 13c194e3..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/serializers/ByteArrayDeserializer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.serializers;
-
-import java.io.IOException;
-import java.util.Base64;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-/**
- * @author formica
- *
- */
-//@//Component
-public class ByteArrayDeserializer extends JsonDeserializer {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(ByteArrayDeserializer.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.
- * jackson.core.JsonParser,
- * com.fasterxml.jackson.databind.DeserializationContext)
- */
- @Override
- public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- log.info("Trying to deserialize json parser {}: {}", jp, jp.getText());
- final String blobstr = jp.getText();
- log.info("try to decode string {} to byte[]", blobstr);
- return Base64.getDecoder().decode(blobstr);
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/serializers/DateSerializer.java b/crestdb-data/src/main/java/hep/crest/data/serializers/DateSerializer.java
deleted file mode 100644
index 5bd614e6..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/serializers/DateSerializer.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- *
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.serializers;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-/**
- * @author formica
- *
- */
-//@//Component
-public class DateSerializer extends JsonSerializer {
-
- /**
- * The pattern: default to ISO_OFFSET_DATE_TIME.
- */
- private String pattern = "ISO_OFFSET_DATE_TIME";
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(DateSerializer.class);
-
- /**
- * Date Formatter.
- */
- private DateTimeFormatter locFormatter = null;
-
- /**
- * @param pattern
- * the pattern to set
- */
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object,
- * com.fasterxml.jackson.core.JsonGenerator,
- * com.fasterxml.jackson.databind.SerializerProvider)
- */
- @Override
- public void serialize(Date ts, JsonGenerator jg, SerializerProvider sp) throws IOException {
- log.debug("Use private version of serializer....{}", getLocformatter());
- jg.writeString(this.format(ts));
- }
-
- /**
- * @param ts
- * the Date
- * @return String
- */
- protected String format(Date ts) {
- final Instant fromEpochMilli = Instant.ofEpochMilli(ts.getTime());
- final ZonedDateTime zdt = fromEpochMilli.atZone(ZoneId.of("Z"));
- return zdt.format(getLocformatter());
- }
-
- /**
- * @return DateTimeFormatter
- */
- protected DateTimeFormatter getLocformatter() {
- if (this.locFormatter != null) {
- return locFormatter;
- }
- if ("ISO_OFFSET_DATE_TIME".equals(pattern)) {
- locFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
- }
- else if ("ISO_LOCAL_DATE_TIME".equals(pattern)) {
- locFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
- }
- else {
- locFormatter = DateTimeFormatter.ofPattern(pattern);
- }
- return locFormatter;
- }
-
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampDeserializer.java b/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampDeserializer.java
deleted file mode 100644
index 7e7e7efc..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampDeserializer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- *
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.serializers;
-
-import java.io.IOException;
-import java.sql.Timestamp;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-import hep.crest.data.handlers.DateFormatterHandler;
-
-/**
- * @author formica
- *
- */
-//@//Component
-public class TimestampDeserializer extends JsonDeserializer {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(TimestampDeserializer.class);
-
- /**
- * The Date formatter handler.
- */
- private final DateFormatterHandler handler = new DateFormatterHandler();
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.
- * jackson.core.JsonParser,
- * com.fasterxml.jackson.databind.DeserializationContext)
- */
- @Override
- public Timestamp deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- log.debug("Use private version of deserializer....{}", handler.getLocformatter());
- final String tstampstr = jp.getText();
- log.info("try to decode string {} to timestamp", tstampstr);
- return handler.format(tstampstr);
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampSerializer.java b/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampSerializer.java
deleted file mode 100644
index 9ef77d14..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/serializers/TimestampSerializer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *
- * This file is part of PhysCondDB.
- *
- * PhysCondDB is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhysCondDB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhysCondDB. If not, see .
- **/
-package hep.crest.data.serializers;
-
-import java.io.IOException;
-import java.sql.Timestamp;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-import hep.crest.data.handlers.DateFormatterHandler;
-
-/**
- * @author formica
- *
- */
-//@//Component
-public class TimestampSerializer extends JsonSerializer {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(TimestampSerializer.class);
-
- /**
- * The Date formatter handler.
- */
- private final DateFormatterHandler handler = new DateFormatterHandler();
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object,
- * com.fasterxml.jackson.core.JsonGenerator,
- * com.fasterxml.jackson.databind.SerializerProvider)
- */
- @Override
- public void serialize(Timestamp ts, JsonGenerator jg, SerializerProvider sp)
- throws IOException {
- log.debug("Use private version of serializer....{}", handler.getLocformatter());
- jg.writeString(handler.format(ts));
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/serializers/package-info.java b/crestdb-data/src/main/java/hep/crest/data/serializers/package-info.java
deleted file mode 100644
index 3aa9775f..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/serializers/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author aformic
- *
- */
-package hep.crest.data.serializers;
diff --git a/crestdb-data/src/main/java/hep/crest/data/utils/DirectoryUtilities.java b/crestdb-data/src/main/java/hep/crest/data/utils/DirectoryUtilities.java
deleted file mode 100644
index 9abeb313..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/utils/DirectoryUtilities.java
+++ /dev/null
@@ -1,459 +0,0 @@
-package hep.crest.data.utils;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.zip.GZIPOutputStream;
-
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
-import org.apache.commons.compress.utils.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import hep.crest.data.exceptions.CdbServiceException;
-
-/**
- * An utility class to deal with disk based storage.
- *
- * @author formica
- *
- */
-public class DirectoryUtilities {
-
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(DirectoryUtilities.class);
-
- /**
- * Name of the tag file.
- */
- private static final String TAG_FILE = "tag.json";
- /**
- * Name of the iov file.
- */
- private static final String IOV_FILE = "iovs.json";
- /**
- * Name of the payload directory.
- */
- private static final String PAYLOAD_DIR = "data";
-
- /**
- * Charset.
- */
- private static final Charset CHARSET = StandardCharsets.UTF_8;
-
- /**
- * Mapper.
- */
- private ObjectMapper mapper = new ObjectMapper();
-
- /**
- * Temporary default for base directory.
- */
- private String locbasedir = "/tmp/cdms";
-
- /**
- * Default Ctor.
- */
- public DirectoryUtilities() {
- super();
- }
-
- /**
- * @param basedir
- * the Base directory
- */
- public DirectoryUtilities(String basedir) {
- locbasedir = basedir;
- }
-
- /**
- * @return ObjectMapper
- */
- public ObjectMapper getMapper() {
- return mapper;
- }
-
- /**
- * @param mapper
- * the ObjectMapper
- * @return
- */
- public void setMapper(ObjectMapper mapper) {
- this.mapper = mapper;
- }
-
- /**
- * @return String
- */
- public String getTagfile() {
- return TAG_FILE;
- }
-
- /**
- * @return String
- */
- public String getIovfile() {
- return IOV_FILE;
- }
-
- /**
- * @return Charset
- */
- public Charset getCharset() {
- return CHARSET;
- }
-
- /**
- * @return Path
- */
- public Path getBasePath() {
- return this.getBasePath(locbasedir);
- }
-
- /**
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getTagPath(String tagname) {
- return this.getTagPath(locbasedir, tagname);
- }
-
- /**
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getTagFilePath(String tagname) {
- return this.getTagFilePath(locbasedir, tagname);
- }
-
- /**
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getIovFilePath(String tagname) {
- return this.getIovFilePath(locbasedir, tagname);
- }
-
- /**
- * @return List
- */
- public List getTagDirectories() {
- return this.getTagDirectories(locbasedir);
- }
-
- /**
- * @return Path
- */
- public Path getPayloadPath() {
- return getPayloadPath(locbasedir);
- }
-
- /**
- * @param name
- * the String
- * @return Path
- * @throws CdbServiceException If an Exception occurred
- */
- public Path createIfNotexistsTag(String name) {
- return createIfNotexistsTag(locbasedir, name);
- }
-
- /**
- * @param name
- * the String
- * @return Path
- * @throws CdbServiceException
- * If an Exception occurred
- */
- public Path createIfNotexistsIov(String name) {
- return createIfNotexistsIov(locbasedir, name);
- }
-
- /**
- * @param basedir
- * the String
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getTagPath(String basedir, String tagname) {
- final Path tagpath = Paths.get(basedir, tagname);
- if (!tagpath.toFile().exists()) {
- throw new CdbServiceException("DirectoryUtility: cannot find directory for tag name " + tagname);
- }
- return tagpath;
- }
-
- /**
- * @param basedir
- * the String
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getTagFilePath(String basedir, String tagname) {
- final Path tagpath = getTagPath(basedir, tagname);
- final Path tagfilepath = Paths.get(tagpath.toString(), TAG_FILE);
- if (!tagfilepath.toFile().exists()) {
- throw new CdbServiceException("DirectoryUtility: cannot find tag file for tag name " + tagname);
- }
- return tagfilepath;
- }
-
- /**
- * @param basedir
- * the String
- * @param tagname
- * the String
- * @throws CdbServiceException
- * If an Exception occurred
- * @return Path
- */
- public Path getIovFilePath(String basedir, String tagname) {
- final Path tagpath = getTagPath(basedir, tagname);
- final Path iovfilepath = Paths.get(tagpath.toString(), IOV_FILE);
- if (!iovfilepath.toFile().exists()) {
- throw new CdbServiceException("DirectoryUtility: cannot find iov file for tag name " + tagname);
- }
- return iovfilepath;
- }
-
- /**
- * @param basedir
- * the String
- * @return List
- */
- public List getTagDirectories(String basedir) {
- final Path basedirpath = Paths.get(basedir);
- List pfiles;
- try (Stream pstream = Files.walk(basedirpath);) {
- pfiles = pstream.collect(Collectors.toList());
- return pfiles.stream().filter(s -> s.getFileName().toString().contains(TAG_FILE))
- .map(x -> x.getName(x.getNameCount() - 2).toString())
- .collect(Collectors.toList());
- }
- catch (final IOException e) {
- log.error("Error getting tags directories from {}: {}", basedirpath, e);
- }
- return new ArrayList<>();
- }
-
- /**
- * @param basedir
- * the String
- * @return Path
- */
- public Path getBasePath(String basedir) {
- final Path base = Paths.get(basedir);
- log.info("creating directory {}", base);
- if (!base.toFile().exists()) {
- // create the directory
- try {
- Files.createDirectories(base);
- }
- catch (final IOException e) {
- log.error("Error creating base directory {}: {}", base, e);
- return null;
- }
- }
- return base;
- }
-
- /**
- * @param basedir
- * the String
- * @return Path
- */
- public Path getPayloadPath(String basedir) {
- final Path ppath = Paths.get(basedir, PAYLOAD_DIR);
- log.info("Creating directory if does not exists {}", ppath);
- if (!ppath.toFile().exists()) {
- // create the directory
- try {
- Files.createDirectories(ppath);
- }
- catch (final IOException e) {
- log.error("Error creating directory for payload {}: {}", ppath, e);
- return null;
- }
- }
- return ppath;
- }
-
- /**
- * @param basedir
- * the String
- * @param name
- * the String
- * @return Path
- * @throws CdbServiceException If an Exception occurred
- */
- public Path createIfNotexistsTag(String basedir, String name) {
- if (name == null) {
- throw new CdbServiceException("Cannot use null tag name");
- }
- final String tagname = name;
- final Path tagpath = Paths.get(basedir, tagname);
- if (tagpath.toFile().exists()) {
- return tagpath;
- }
- else {
- try {
- Files.createDirectories(tagpath);
- final Path tagfilepath = Paths.get(basedir, tagname, TAG_FILE);
- Files.createFile(tagfilepath);
- return tagpath;
- }
- catch (final IOException e) {
- log.error("Error creating directory for tag {}: {}", tagpath, e);
- }
- }
- return null;
- }
-
- /**
- * @param basedir
- * the String
- * @param name
- * the String
- * @return Path
- * @throws CdbServiceException
- * If an Exception occurred
- */
- public Path createIfNotexistsIov(String basedir, String name) {
- if (name == null) {
- throw new CdbServiceException("Cannot use null tag name");
- }
- final String tagname = name;
- final Path tagpath = Paths.get(basedir, tagname);
- if (!tagpath.toFile().exists()) {
- throw new CdbServiceException("Cannot find tag directory for tag name " + tagname);
- }
- else {
- try {
- final Path iovfilepath = Paths.get(basedir, tagname, IOV_FILE);
- Files.createFile(iovfilepath);
- return iovfilepath;
- }
- catch (final IOException e) {
- log.error("Error creating iov file for tag {}: {}", name, e);
- }
- }
- return null;
- }
-
- /**
- * @param hash
- * the String
- * @return String
- */
- public String hashdir(String hash) {
- return hash.substring(0, 2);
- }
-
- /**
- * @param apath
- * the Path
- * @param filename
- * the String
- * @return Boolean
- */
- public Boolean existsFile(Path apath, String filename) {
- if (!apath.toFile().exists()) {
- return false;
- }
- final Path filepath = Paths.get(apath.toString(), filename);
- return filepath.toFile().exists();
- }
-
- /**
- * @param source
- * the String
- * @param outdir
- * the String
- * @return String
- */
- public String createTarFile(String source, String outdir) {
- final String outtarfile = outdir.concat(".tar.gz");
- try (FileOutputStream fos = new FileOutputStream(outtarfile);
- GZIPOutputStream gos = new GZIPOutputStream(new BufferedOutputStream(fos));
- TarArchiveOutputStream tarOs = new TarArchiveOutputStream(gos);) {
- // Using input name to create output name
- final File folder = new File(source);
- final File[] fileNames = folder.listFiles();
- for (final File file : fileNames) {
- log.debug("PATH {}", file.getAbsolutePath());
- log.debug("File name {}", file.getName());
- addFileToTarGz(tarOs, file.getAbsolutePath(), "");
- }
- return outtarfile;
- }
- catch (final IOException e) {
- log.error("Cannot create tar file from source {} in dir {}: {}", source, outdir, e);
- }
- return "none";
- }
-
- /**
- * @param tOut
- * the TarArchiveOutputStream
- * @param path
- * the String
- * @param base
- * the String
- * @throws IOException
- * If an Exception occurred
- * @return
- */
- private void addFileToTarGz(TarArchiveOutputStream tOut, String path, String base)
- throws IOException {
- final File f = new File(path);
- log.debug("check if path {} exists...{}", path, f.exists());
- final String entryName = base + f.getName();
- final TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);
- tOut.putArchiveEntry(tarEntry);
- if (f.isFile()) {
- IOUtils.copy(new FileInputStream(f), tOut);
- tOut.closeArchiveEntry();
- }
- else {
- tOut.closeArchiveEntry();
- final File[] children = f.listFiles();
- if (children != null) {
- for (final File child : children) {
- log.debug(child.getName());
- addFileToTarGz(tOut, child.getAbsolutePath(), entryName + "/");
- }
- }
- }
- }
-}
diff --git a/crestdb-data/src/main/java/hep/crest/data/utils/package-info.java b/crestdb-data/src/main/java/hep/crest/data/utils/package-info.java
deleted file mode 100644
index 4cca9dc5..00000000
--- a/crestdb-data/src/main/java/hep/crest/data/utils/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author aformic
- *
- */
-package hep.crest.data.utils;
diff --git a/crestdb-data/src/test/java/hep/crest/data/test/PojoDtoConverterTests.java b/crestdb-data/src/test/java/hep/crest/data/test/PojoDtoConverterTests.java
deleted file mode 100644
index 74761bcf..00000000
--- a/crestdb-data/src/test/java/hep/crest/data/test/PojoDtoConverterTests.java
+++ /dev/null
@@ -1,560 +0,0 @@
-/**
- *
- */
-package hep.crest.data.test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import hep.crest.data.pojo.GlobalTag;
-import hep.crest.data.pojo.GlobalTagMap;
-import hep.crest.data.pojo.GlobalTagMapId;
-import hep.crest.data.pojo.Iov;
-import hep.crest.data.pojo.IovId;
-import hep.crest.data.pojo.Payload;
-import hep.crest.data.pojo.Tag;
-import hep.crest.data.runinfo.pojo.RunLumiInfo;
-import hep.crest.data.security.pojo.CrestFolders;
-import hep.crest.data.security.pojo.CrestRoles;
-import hep.crest.data.security.pojo.CrestUser;
-import hep.crest.data.test.tools.DataGenerator;
-import hep.crest.swagger.model.FolderDto;
-import hep.crest.swagger.model.FolderSetDto;
-import hep.crest.swagger.model.GenericMap;
-import hep.crest.swagger.model.GlobalTagDto;
-import hep.crest.swagger.model.GlobalTagMapDto;
-import hep.crest.swagger.model.GlobalTagMapSetDto;
-import hep.crest.swagger.model.GlobalTagSetDto;
-import hep.crest.swagger.model.GroupDto;
-import hep.crest.swagger.model.HTTPResponse;
-import hep.crest.swagger.model.IovDto;
-import hep.crest.swagger.model.IovPayloadDto;
-import hep.crest.swagger.model.IovPayloadSetDto;
-import hep.crest.swagger.model.IovSetDto;
-import hep.crest.swagger.model.PayloadDto;
-import hep.crest.swagger.model.PayloadSetDto;
-import hep.crest.swagger.model.PayloadTagInfoDto;
-import hep.crest.swagger.model.RunLumiInfoDto;
-import hep.crest.swagger.model.RunLumiSetDto;
-import hep.crest.swagger.model.TagDto;
-import hep.crest.swagger.model.TagMetaDto;
-import hep.crest.swagger.model.TagMetaSetDto;
-import hep.crest.swagger.model.TagSetDto;
-import hep.crest.swagger.model.TagSummaryDto;
-import hep.crest.swagger.model.TagSummarySetDto;
-import ma.glasnost.orika.MapperFacade;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author formica
- *
- */
-@SpringBootTest
-@RunWith(SpringRunner.class)
-public class PojoDtoConverterTests {
-
- @Autowired
- @Qualifier("mapper")
- private MapperFacade mapper;
-
- private static final Logger log = LoggerFactory.getLogger(PojoDtoConverterTests.class);
-
- @Test
- public void testGlobalTagConverter() throws Exception {
- final GlobalTag entity = DataGenerator.generateGlobalTag("GT-02");
- final GlobalTagDto dto = mapper.map(entity, GlobalTagDto.class);
- assertThat(entity.getName()).isEqualTo(dto.getName());
- assertThat(entity.toString().length()).isPositive();
- assertThat(dto.toString().length()).isPositive();
-
- final Instant now = Instant.now();
- final Date it = new Date(now.toEpochMilli());
-
- final GlobalTagDto dto1 = DataGenerator.generateGlobalTagDto("GT-02", it);
- assertThat(dto1.getDescription()).isEqualTo(dto.getDescription());
- assertThat(dto1).isNotEqualTo(dto); // Should be true
- assertThat(dto1.hashCode()).isNotZero();
- }
-
- @Test
- public void testTagConverter() throws Exception {
- final Tag entity = DataGenerator.generateTag("MT-02", "run");
- final TagDto dto = mapper.map(entity, TagDto.class);
- assertThat(entity.getName()).isEqualTo(dto.getName());
- assertThat(entity.toString().length()).isPositive();
- assertThat(dto.toString().length()).isPositive();
- assertThat(dto.hashCode()).isNotZero();
-
- final Tag entity1 = DataGenerator.generateTag("MT-02", "run");
- final TagDto dto1 = mapper.map(entity1, TagDto.class);
- assertThat(dto1).isNotNull().isEqualTo(dto);
- }
-
- @Test
- public void testMapsConverter() throws Exception {
- final GlobalTag gtag = DataGenerator.generateGlobalTag("MY-TEST-GT-03");
- final Tag tag1 = DataGenerator.generateTag("MY-TEST-02", "time");
- final GlobalTagMapId id1 = new GlobalTagMapId();
- id1.setGlobalTagName(gtag.getName());
- id1.setLabel("MY-TEST");
- id1.setRecord("aaa");
-
- final GlobalTagMap map1 = DataGenerator.generateMapping(gtag, tag1, id1);
- final GlobalTagMapDto dto = mapper.map(map1, GlobalTagMapDto.class);
- assertThat(dto.toString().length()).isPositive();
- assertThat(dto.getGlobalTagName()).isEqualTo(gtag.getName());
-
- final GlobalTagMapId id2 = new GlobalTagMapId(gtag.getName(), "aaa", "MY-TEST");
- assertThat(id2).isEqualTo(id1);
- assertThat(id2.hashCode()).isNotZero();
-
- }
-
- @Test
- public void testIovConverter() throws Exception {
- final IovDto dto = DataGenerator.generateIovDto("MYHASH", "MT-02", new BigDecimal(1000L));
- final Iov entity = mapper.map(dto, Iov.class);
- final IovId id = entity.getId();
- assertThat(id.getSince()).isEqualTo(new BigDecimal(1000L));
- log.info("Id of iov is {}", id);
-
- final Iov geniov = DataGenerator.generateIov("MYHASH", "MT-02", new BigDecimal(1000L));
- log.info("Generated iov {}", geniov);
- final IovId genid = geniov.getId();
- assertThat(genid).isNotNull();
-
- assertThat(entity.getPayloadHash()).isEqualTo(dto.getPayloadHash());
- assertThat(entity.toString().length()).isPositive();
- assertThat(dto.toString().length()).isPositive();
- assertThat(dto.hashCode()).isNotZero();
- assertThat(entity.hashCode()).isNotZero();
- }
-
- @Test
- public void testPayloadConverter() throws Exception {
- final Instant now = Instant.now();
- final Date time = new Date(now.toEpochMilli());
-
- final PayloadDto dto = DataGenerator.generatePayloadDto("myhash1", "mydata", "mystreamer",
- "test", time);
- final Payload entity = DataGenerator.generatePayload("myhash1", "test");
- assertThat(entity.getHash()).isEqualTo(dto.getHash());
- assertThat(entity.toString().length()).isPositive();
- assertThat(dto.toString().length()).isPositive();
- assertThat(dto.hashCode()).isNotZero();
- assertThat(entity.hashCode()).isNotZero();
- }
-
- @Test
- public void testGlobalTagSetsConverter() throws Exception {
- final Instant now = Instant.now();
- final Date it = new Date(now.toEpochMilli());
-
- final GlobalTagDto dto1 = DataGenerator.generateGlobalTagDto("MY-GTAG-01", it);
- final GlobalTagDto dto2 = DataGenerator.generateGlobalTagDto("MY-GTAG-02", it);
- final GlobalTagDto dto1bis = DataGenerator.generateGlobalTagDto("MY-GTAG-01", it);
- log.info("compare {} with {}", dto1, dto1bis);
- assertThat(dto1).isEqualTo(dto1bis);
- final GlobalTagSetDto setdto = new GlobalTagSetDto();
- setdto.datatype("globaltags");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1).addResourcesItem(dto2);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- final List resources = setdto.getResources();
- for (final GlobalTagDto gtDto : resources) {
- if (gtDto.getName().equals("MY-GTAG-01")) {
- assertThat(gtDto).isEqualTo(dto1);
- }
- }
- final GlobalTagSetDto setdto2 = new GlobalTagSetDto();
- setdto2.datatype("globaltags");
- setdto2.format("JSON");
- setdto2.setResources(resources);
- assertThat(setdto2).isEqualTo(setdto);
- }
-
- @Test
- public void testGlobalTagMapSetsConverter() throws Exception {
- final GlobalTagMapDto dto1 = DataGenerator.generateMappingDto("MY-GTAG-01", "T-01", "T",
- "a");
- final GlobalTagMapDto dto2 = DataGenerator.generateMappingDto("MY-GTAG-01", "S-02", "S",
- "b");
- assertThat(dto1.hashCode()).isNotZero();
- final GlobalTagMapDto dto1bis = DataGenerator.generateMappingDto("MY-GTAG-01", "T-01", "T",
- "a");
- assertThat(dto1).isEqualTo(dto1bis);
-
- final GlobalTagMapSetDto setdto = new GlobalTagMapSetDto();
- setdto.datatype("maps");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1).addResourcesItem(dto2);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- final List resources = setdto.getResources();
- for (final GlobalTagMapDto gtmapDto : resources) {
- if (gtmapDto.getGlobalTagName().equals("MY-GTAG-01")) {
- assertThat(gtmapDto).isEqualTo(dto1);
- }
- }
- final GlobalTagMapSetDto setdto2 = new GlobalTagMapSetDto();
- setdto2.datatype("maps");
- setdto2.format("JSON");
- setdto2.setResources(resources);
- assertThat(setdto2).isEqualTo(setdto);
- }
-
- @Test
- public void testIovSetsConverter() throws Exception {
- final IovDto dto1 = DataGenerator.generateIovDto("MYHASH1", "MT-02", new BigDecimal(1000L));
- final IovDto dto2 = DataGenerator.generateIovDto("MYHASH2", "MT-02", new BigDecimal(2000L));
- final IovSetDto setdto = new IovSetDto();
- setdto.datatype("iovs");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1).addResourcesItem(dto2);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- final List resources = setdto.getResources();
- for (final IovDto iovDto : resources) {
- if (iovDto.getPayloadHash().equals("MYHASH1")) {
- assertThat(iovDto).isEqualTo(dto1);
- }
- }
- final IovSetDto setdto2 = new IovSetDto();
- setdto2.datatype("iovs");
- setdto2.format("JSON");
- setdto2.setResources(resources);
- assertThat(setdto2).isEqualTo(setdto);
- }
-
- @Test
- public void testTagSetsConverter() throws Exception {
- final TagDto dto1 = DataGenerator.generateTagDto("MY-TAG-01", "time");
- final TagDto dto2 = DataGenerator.generateTagDto("MY-TAG-02", "time");
- final TagSetDto setdto = new TagSetDto();
- setdto.datatype("tags");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1).addResourcesItem(dto2);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
-
- final List resources = setdto.getResources();
- for (final TagDto tagDto : resources) {
- if (tagDto.getName().equals("MY-TAG-01")) {
- assertThat(tagDto).isEqualTo(dto1);
- }
- }
- final TagSetDto setdto2 = new TagSetDto();
- setdto2.datatype("tags");
- setdto2.format("JSON");
- setdto2.setResources(resources);
- assertThat(setdto2).isEqualTo(setdto);
- }
-
- @Test
- public void testTagSummarySetsConverter() throws Exception {
- final TagSummaryDto dto1 = DataGenerator.generateTagSummaryDto("MY-TAG-01", 10L);
- final TagSummaryDto dto2 = DataGenerator.generateTagSummaryDto("MY-TAG-02", 20L);
-
- final TagSummarySetDto setdto = new TagSummarySetDto();
- setdto.datatype("tags");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1).addResourcesItem(dto2);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- }
-
- @Test
- public void testRunInfoConverter() throws Exception {
- final Date start = new Date();
- final Date end = new Date(start.getTime()+3600000);
- final RunLumiInfoDto dto1 = DataGenerator.generateRunLumiInfoDto(new BigDecimal(start.getTime()), new BigDecimal(end.getTime()), new BigDecimal(100L));
-
- assertThat(dto1.toString().length()).isPositive();
- assertThat(dto1.hashCode()).isNotZero();
- final RunLumiInfo entity = mapper.map(dto1, RunLumiInfo.class);
- assertThat(dto1.getRunNumber()).isEqualTo(entity.getRunNumber());
- assertThat(entity.toString().length()).isPositive();
- assertThat(entity.hashCode()).isNotZero();
-
- final RunLumiSetDto setdto = new RunLumiSetDto();
- setdto.datatype("RunLumiSetDto");
- final GenericMap filterm = new GenericMap();
- filterm.put("run", "1000");
- assertThat(filterm.containsKey("run")).isTrue();
-
- setdto.filter(filterm);
- setdto.addResourcesItem(dto1);
- setdto.format("RunInfo");
-
- final RunLumiSetDto setdto2 = new RunLumiSetDto();
- setdto2.datatype("RunLumiSetDto");
- setdto2.filter(filterm);
- setdto2.format("RunInfo");
- setdto2.addResourcesItem(dto1);
- assertThat(setdto2).isEqualTo(setdto);
- assertThat(setdto.toString()).isNotNull();
- setdto2.filter(setdto.getFilter());
- setdto2.format(setdto.getFormat());
- }
-
- @Test
- public void testRunInfoSetConverter() throws Exception {
- final RunLumiInfoDto dto1 = DataGenerator.generateRunLumiInfoDto(new BigDecimal(2000L),
- new BigDecimal(33333L), new BigDecimal(200L));
-
- assertThat(dto1.toString().length()).isPositive();
- assertThat(dto1.hashCode()).isNotZero();
- final RunLumiSetDto setdto = new RunLumiSetDto();
- setdto.datatype("runs").format("json");
- setdto.addResourcesItem(dto1);
- setdto.size(1L);
- assertThat(setdto.toString().length()).isPositive();
-
- final RunLumiSetDto setdto1 = new RunLumiSetDto();
- setdto1.datatype("runs").format("json");
- setdto1.addResourcesItem(dto1);
- setdto1.size(1L);
-
- assertThat(setdto).isEqualTo(setdto1);
- assertThat(setdto.hashCode()).isNotZero();
-
- }
-
- @Test
- public void testFolderConverter() throws Exception {
- final FolderDto dto1 = DataGenerator.generateFolderDto("T0BLOB", "/MDT/T0BLOB",
- "COOLOFL_MDT");
-
- assertThat(dto1.toString().length()).isPositive();
- assertThat(dto1.hashCode()).isNotZero();
- final CrestFolders entity = mapper.map(dto1, CrestFolders.class);
- assertThat(dto1.getNodeFullpath()).isEqualTo(entity.getNodeFullpath());
- assertThat(entity.toString().length()).isPositive();
- assertThat(entity.hashCode()).isNotZero();
-
- dto1.setGroupRole("somerole");
- dto1.setNodeDescription("some node desc");
- dto1.setSchemaName("some_schema");
- dto1.setTagPattern("some_anode");
- dto1.setNodeName("anode");
- dto1.setNodeFullpath("/some/anode");
-
- final FolderDto dto2 = DataGenerator.generateFolderDto("T0BLOB", "/MDT/T0BLOB",
- "COOLOFL_MDT");
- assertThat(dto1).isNotEqualTo(dto2);
-
- }
-
- @Test
- public void testFolderSetConverter() throws Exception {
- final FolderDto dto1 = DataGenerator.generateFolderDto("T0BLOB", "/MDT/T0BLOB",
- "COOLOFL_MDT");
-
- assertThat(dto1.toString().length()).isPositive();
- assertThat(dto1.hashCode()).isNotZero();
- final FolderSetDto setdto = new FolderSetDto();
- setdto.datatype("folders").format("json");
- setdto.addResourcesItem(dto1);
- setdto.size(1L);
- assertThat(setdto.toString().length()).isPositive();
-
- final FolderSetDto setdto1 = new FolderSetDto();
- setdto1.datatype("folders").format("json");
- setdto1.addResourcesItem(dto1);
- setdto1.size(1L);
-
- assertThat(setdto).isEqualTo(setdto1);
- assertThat(setdto.hashCode()).isNotZero();
- }
-
- @Test
- public void testPayloadDtoSetsConverter() throws Exception {
- final Instant now = Instant.now();
- final Date time = new Date(now.toEpochMilli());
- final String data = "datastr";
- final String sinfo = "streaminfo";
- final PayloadDto dto1 = DataGenerator.generatePayloadDto("somehash", data, sinfo, "test",
- time);
- final PayloadDto dto1bis = DataGenerator.generatePayloadDto("somehash", data, sinfo, "test",
- time);
- log.info("compare {} with {} having hash {} and {}", dto1, dto1bis, dto1.hashCode(),
- dto1bis.hashCode());
- assertThat(dto1.getHash()).isEqualTo(dto1bis.getHash());
- final PayloadSetDto setdto = new PayloadSetDto();
- setdto.datatype("payloads");
- setdto.format("JSON");
- setdto.addResourcesItem(dto1);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- final List resources = setdto.getResources();
- for (final PayloadDto gtDto : resources) {
- if (gtDto.getHash().equals("somehash")) {
- assertThat(gtDto).isEqualTo(dto1);
- }
- }
- }
-
- @Test
- public void testIovPayloadSetsConverter() throws Exception {
- final Instant now = Instant.now();
- final Date time = new Date(now.toEpochMilli());
- final String data = "datastr";
- final String sinfo = "streaminfo";
- final IovDto dto1 = DataGenerator.generateIovDto("MYHASH3", "MT-02", new BigDecimal(3000L));
- final IovDto dto2 = DataGenerator.generateIovDto("MYHASH4", "MT-02", new BigDecimal(4000L));
- final PayloadDto pdto1 = DataGenerator.generatePayloadDto("MYHASH3", data, sinfo, "test",
- time);
- final PayloadDto pdto2 = DataGenerator.generatePayloadDto("MYHASH4", data, sinfo, "test",
- time);
-
- final IovPayloadDto ipdto1 = new IovPayloadDto().objectType(pdto1.getObjectType())
- .payloadHash(dto1.getPayloadHash()).since(dto1.getSince()).size(pdto1.getSize())
- .version(pdto1.getVersion());
- final IovPayloadDto ipdto2 = new IovPayloadDto().objectType(pdto2.getObjectType())
- .payloadHash(dto2.getPayloadHash()).since(dto2.getSince()).size(pdto2.getSize())
- .version(pdto2.getVersion());
-
- final IovPayloadSetDto psetdto = new IovPayloadSetDto();
- psetdto.addResourcesItem(ipdto1).addResourcesItem(ipdto2);
- psetdto.datatype("IovPayloadSetDto");
- psetdto.format("iovpayloaddto");
-
- assertThat(psetdto.getResources()).isNotNull();
- assertThat(ipdto1).isNotEqualTo(ipdto2);
-
- final List plist = new ArrayList<>();
- plist.add(ipdto1);
- plist.add(ipdto2);
- final IovPayloadSetDto psetdto1 = new IovPayloadSetDto();
- psetdto1.resources(plist);
- psetdto1.setDatatype("IovPayloadSetDto");
- psetdto1.setFormat("iovpayloaddto");
-
- assertThat(psetdto).isEqualTo(psetdto1);
- assertThat(psetdto.toString().length()).isPositive();
- }
-
- @Test
- public void testTagMetaDtoSetsConverter() throws Exception {
- final Instant now = Instant.now();
- final Date time = new Date(now.toEpochMilli());
- final String data = "{ \"key\" : \"value\" }";
- final TagMetaDto dto1 = DataGenerator.generateTagMetaDto("A_TAG", data, time);
- final TagMetaDto dto1bis = DataGenerator.generateTagMetaDto("A_TAG", data, time);
- log.info("compare {} with {} having hash code {} and {}", dto1, dto1bis, dto1.hashCode(),
- dto1bis.hashCode());
- assertThat(dto1.getTagName().equals(dto1bis.getTagName())).isTrue();
- final TagMetaSetDto setdto = new TagMetaSetDto();
- setdto.datatype("TagMetaSetDto");
- setdto.format("tagmetas");
- setdto.addResourcesItem(dto1);
- assertThat(setdto.toString().length()).isPositive();
- assertThat(setdto.hashCode()).isNotZero();
- final List resources = setdto.getResources();
- for (final TagMetaDto gtDto : resources) {
- if (gtDto.getTagName().equals("A_TAG")) {
- assertThat(gtDto).isEqualTo(dto1);
- }
- }
- }
-
- @Test
- public void testOtherDtos() throws Exception {
- final List groups = new ArrayList<>();
- groups.add(new BigDecimal(10L));
- groups.add(new BigDecimal(100L));
- final GroupDto dto = new GroupDto();
- dto.groups(groups);
- assertThat(dto.getGroups().size()).isPositive();
-
- final HTTPResponse resp = new HTTPResponse();
- resp.action("test");
- resp.code(200);
- resp.message("a successful test");
- resp.id("ahash");
- assertThat(resp.toString().length()).isPositive();
-
- final PayloadTagInfoDto ptdto = new PayloadTagInfoDto();
- ptdto.avgvolume(1.0F);
- ptdto.niovs(10);
- ptdto.tagname("A-TAG");
- ptdto.totvolume(1.2F);
- assertThat(ptdto.toString().length()).isPositive();
- ptdto.setAvgvolume(1.1F);
- ptdto.setNiovs(11);
- ptdto.setTagname("A-TAG-01");
- ptdto.setTotvolume(1.3F);
- assertThat(ptdto.toString().length()).isPositive();
- assertThat(ptdto.hashCode()).isNotZero();
-
- final PayloadTagInfoDto ptdto2 = new PayloadTagInfoDto();
- ptdto2.avgvolume(ptdto.getAvgvolume());
- ptdto2.tagname(ptdto.getTagname());
- ptdto2.totvolume(ptdto.getTotvolume());
- ptdto2.niovs(ptdto.getNiovs());
- assertThat(ptdto2).isEqualTo(ptdto);
-
- final CrestUser user = new CrestUser("user", "password");
- user.setId("someid");
- user.setUsername("anothername");
- assertThat(user.toString().length()).isPositive();
- user.setPassword("anewpass");
- assertThat(user.getId()).isEqualTo("someid");
- assertThat(user.getUsername()).isEqualTo("anothername");
- assertThat(user.getPassword()).isEqualTo("anewpass");
- final CrestUser usr1 = new CrestUser();
- assertThat(usr1).isNotNull();
-
- final CrestRoles role = new CrestRoles("roleid", "admin");
- role.setRole("guest");
- assertThat(role.toString().length()).isPositive();
- role.setId("anotherroleid");
- assertThat(role.getId()).isEqualTo("anotherroleid");
- assertThat(role.getRole()).isEqualTo("guest");
- final CrestRoles rol1 = new CrestRoles();
- assertThat(rol1).isNotNull();
- }
-
- @Test
- public void testDeserializer() {
- final ObjectMapper locmapper = new ObjectMapper();
-// final SimpleModule module = new SimpleModule();
-//
-// module.addDeserializer(Timestamp.class, new TimestampDeserializer());
-// module.addDeserializer(byte[].class, new ByteArrayDeserializer());
-
- final String json = "{ \"data\" : \"VGhpcyBpcyBhIG5vcm1hbCB0ZXh0Cg==\", " +
- "\"instime\" : \"2011-12-03T10:15:30+01:00\", " +
- "\"insdate\" : \"2020-12-03T22:15:30+01:00\", " +
- "\"name\" : \"MyTest\"}";
-
- try {
- log.info("Try to deserialize json {}", json);
- final TestItem m = locmapper.readValue(json, TestItem.class);
- assertThat(m.getName()).isEqualTo("MyTest");
-
- final String jsonout = locmapper.writeValueAsString(m);
- log.info("Serialized object is {}", jsonout);
- assertThat(jsonout).contains("MyTest");
- }
- catch (final IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
diff --git a/crestdb-data/src/test/java/hep/crest/data/test/PojoTests.java b/crestdb-data/src/test/java/hep/crest/data/test/PojoTests.java
deleted file mode 100644
index f211fa82..00000000
--- a/crestdb-data/src/test/java/hep/crest/data/test/PojoTests.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *
- */
-package hep.crest.data.test;
-
-import hep.crest.data.pojo.GlobalTag;
-import hep.crest.data.pojo.GlobalTagMap;
-import hep.crest.data.pojo.GlobalTagMapId;
-import hep.crest.data.pojo.IovId;
-import hep.crest.data.pojo.Payload;
-import hep.crest.data.pojo.Tag;
-import hep.crest.data.pojo.TagMeta;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.math.BigDecimal;
-import java.time.Instant;
-import java.util.Date;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author formica
- *
- */
-@SpringBootTest
-@RunWith(SpringRunner.class)
-public class PojoTests {
-
- private static final Logger log = LoggerFactory.getLogger(PojoTests.class);
-
- @Test
- public void testGlobalTagMap() throws Exception {
- GlobalTagMapId mapid = new GlobalTagMapId();
- mapid.setRecord("somerecord");
- mapid.setLabel("somelabel");
- mapid.setGlobalTagName("TGT-01");
-
- GlobalTagMapId mapid2 = new GlobalTagMapId();
- mapid2.setRecord("somerecord");
- mapid2.setLabel("somelabel");
- mapid2.setGlobalTagName("TGT-02");
-
- GlobalTagMapId mapid3 = new GlobalTagMapId();
- mapid3.setRecord("somerecord");
- mapid3.setLabel("somelabel2");
- mapid3.setGlobalTagName("TGT-01");
-
- assertThat(mapid).isNotEqualTo(mapid2).isNotEqualTo(mapid3);
- assertThat(mapid.hashCode()).isNotZero();
-
- mapid3.setRecord("somerecord2");
- mapid3.setLabel("somelabel");
- mapid3.setGlobalTagName("TGT-01");
- assertThat(mapid).isNotEqualTo(mapid3);
- assertThat(mapid3).isNotNull();
-
- Tag tag = new Tag("TAG-01");
- GlobalTag gtag = new GlobalTag("GT-01");
- GlobalTagMap map = new GlobalTagMap(mapid, tag, gtag);
- assertThat(map.getGlobalTag().getName()).isEqualTo("GT-01");
-
- assertThat(map).isNotNull();
- }
-
- @Test
- public void testIovId() throws Exception {
- IovId iovid = new IovId();
- Long now = Instant.now().toEpochMilli();
- iovid.setSince(new BigDecimal(now));
- iovid.setTagName("TEST-TAG-01");
- Date instime = iovid.getInsertionTime();
- iovid.setInsertionTime(new Date(now));
- IovId iovid1 = new IovId();
- iovid1.setSince(new BigDecimal(now));
- iovid1.setTagName("TEST-TAG-01");
- Date instime1 = iovid1.getInsertionTime();
- IovId iovid2 = new IovId();
- iovid2.setSince(new BigDecimal(now));
- iovid2.setTagName(null);
-
- assertThat(iovid.hashCode()).isNotZero();
- assertThat(iovid2).isNotNull().isNotEqualTo(iovid).isNotEqualTo(iovid1);
- }
-
- @Test
- public void testPayload() throws Exception {
- Payload pyld = new Payload();
- Long now = Instant.now().toEpochMilli();
- pyld.setSize(100);
- pyld.setHash("somehash");
- pyld.setInsertionTime(new Date(now));
- pyld.setObjectType("sometype");
- pyld.setVersion("someversion");
- assertThat(pyld.getSize()).isPositive();
- assertThat(pyld.getVersion().length()).isPositive();
- assertThat(pyld.getObjectType().length()).isPositive();
-
- assertThat(pyld.hashCode()).isNotZero();
-
- Payload pyld1 = new Payload("somehash","anotherobj", null, null, pyld.getInsertionTime());
- assertThat(pyld1).isNotNull();
- }
-
- @Test
- public void testTagMeta() throws Exception {
- TagMeta tagmeta = new TagMeta();
- Long now = Instant.now().toEpochMilli();
- tagmeta.setChansize(10);
- tagmeta.setTagName("PIPPO");
- tagmeta.setInsertionTime(new Date(now));
- tagmeta.setDescription("a test");
- tagmeta.setColsize(2);
- assertThat(tagmeta.getColsize()).isPositive();
- assertThat(tagmeta.getDescription().length()).isPositive();
- assertThat(tagmeta.getTagName().length()).isPositive();
- assertThat(tagmeta.hashCode()).isNotZero();
- }
-
-}
diff --git a/crestdb-data/src/test/java/hep/crest/data/test/QueryDslTests.java b/crestdb-data/src/test/java/hep/crest/data/test/QueryDslTests.java
deleted file mode 100644
index 2dbc8973..00000000
--- a/crestdb-data/src/test/java/hep/crest/data/test/QueryDslTests.java
+++ /dev/null
@@ -1,446 +0,0 @@
-package hep.crest.data.test;
-
-
-import com.querydsl.core.types.dsl.BooleanExpression;
-import hep.crest.data.pojo.GlobalTag;
-import hep.crest.data.pojo.GlobalTagMap;
-import hep.crest.data.pojo.GlobalTagMapId;
-import hep.crest.data.pojo.Iov;
-import hep.crest.data.pojo.IovId;
-import hep.crest.data.pojo.Tag;
-import hep.crest.data.repositories.GlobalTagMapRepository;
-import hep.crest.data.repositories.GlobalTagRepository;
-import hep.crest.data.repositories.IovRepository;
-import hep.crest.data.repositories.PayloadDataDBImpl;
-import hep.crest.data.repositories.TagRepository;
-import hep.crest.data.repositories.querydsl.FolderFiltering;
-import hep.crest.data.repositories.querydsl.GlobalTagFiltering;
-import hep.crest.data.repositories.querydsl.IFilteringCriteria;
-import hep.crest.data.repositories.querydsl.IovFiltering;
-import hep.crest.data.repositories.querydsl.SearchCriteria;
-import hep.crest.data.repositories.querydsl.TagFiltering;
-import hep.crest.data.runinfo.pojo.RunLumiInfo;
-import hep.crest.data.runinfo.repositories.RunLumiInfoRepository;
-import hep.crest.data.runinfo.repositories.querydsl.RunLumiInfoFiltering;
-import hep.crest.data.security.pojo.CrestFolders;
-import hep.crest.data.security.pojo.FolderRepository;
-import hep.crest.data.test.tools.DataGenerator;
-import hep.crest.swagger.model.PayloadDto;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.domain.Sort.Order;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@RunWith(SpringRunner.class)
-@DataJpaTest
-@ActiveProfiles("test")
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class QueryDslTests {
-
-
- private static final String SORT_PATTERN = "([a-zA-Z0-9_\\-\\.]+?)(:)([ASC|DESC]+?),";
- private static final String QRY_PATTERN = "([a-zA-Z0-9_\\-\\.]+?)(:|<|>)([a-zA-Z0-9_\\-\\/\\.\\*\\%]+?),";
-
- private static final Logger log = LoggerFactory.getLogger(QueryDslTests.class);
-
-
- @Autowired
- private GlobalTagRepository globaltagrepository;
-
- @Autowired
- private TagRepository tagrepository;
-
- @Autowired
- private IovRepository iovrepository;
-
- @Autowired
- private GlobalTagMapRepository tagmaprepository;
-
- @Autowired
- private RunLumiInfoRepository runrepository;
-
- @Autowired
- private FolderRepository folderRepository;
-
- @Autowired
- @Qualifier("dataSource")
- private DataSource mainDataSource;
-
- @Before
- public void setUp() {
- final Path bpath = Paths.get("/tmp/cdms");
- if (!bpath.toFile().exists()) {
- try {
- Files.createDirectories(bpath);
- }
- catch (final IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- final Path cpath = Paths.get("/tmp/crest-dump");
- if (!cpath.toFile().exists()) {
- try {
- Files.createDirectories(cpath);
- }
- catch (final IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
-
- @Test
- public void testGlobalTags() throws Exception {
- final GlobalTag gtag = DataGenerator.generateGlobalTag("MY-TEST-GT-01");
- globaltagrepository.save(gtag);
- final IFilteringCriteria filter = new GlobalTagFiltering();
- final PageRequest preq = createPageRequest(0, 10, "name:ASC");
-
- final List params = createMatcherCriteria("name:M,workflow:%,scenario:%,release:rel,"
- + "insertionTime>0");
- final List expressions = filter.createFilteringConditions(params);
- BooleanExpression wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist = globaltagrepository.findAll(wherepred, preq);
- assertThat(dtolist.getSize()).isPositive();
-
- final GlobalTag loaded = globaltagrepository.findByName("MY-TEST-GT-01");
- assertThat(loaded).isNotNull();
- }
-
- @Test
- public void testGlobalTags2() throws Exception {
- final GlobalTag gtag = DataGenerator.generateGlobalTag("MY-TEST-GT-02");
- globaltagrepository.save(gtag);
- final IFilteringCriteria filter = new GlobalTagFiltering();
- final PageRequest preq = createPageRequest(0, 10, "workflow:ASC");
-
- final List params = createMatcherCriteria("name:M,scenario:%,insertionTime>0,insertionTime<0,"
- + "insertionTime:0");
- final List expressions = filter.createFilteringConditions(params);
- BooleanExpression wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist = globaltagrepository.findAll(wherepred, preq);
- assertThat(dtolist.getSize()).isPositive();
-
- final List params2 = createMatcherCriteria("type:T,scenario:%,validity>0,validity<0,"
- + "validity:0");
- final List expressions2 = filter.createFilteringConditions(params2);
- wherepred = null;
-
- for (final BooleanExpression exp : expressions2) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist2 = globaltagrepository.findAll(wherepred, preq);
- assertThat(dtolist2.getSize()).isNotNegative();
- }
-
- @Test
- public void testTags() throws Exception {
- final Tag tag = DataGenerator.generateTag("MY-TEST-01", "time");
- tagrepository.save(tag);
- final IFilteringCriteria filter = new TagFiltering();
- final PageRequest preq = createPageRequest(0, 10, "name:ASC");
-
- List params = createMatcherCriteria("name:M,timetype:time,objecttype:%,insertiontime>-1,"
- + "insertiontime<2,insertiontime:0");
- List expressions = filter.createFilteringConditions(params);
- BooleanExpression wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist = tagrepository.findAll(wherepred, preq);
- assertThat(dtolist.getSize()).isPositive();
-
- params = createMatcherCriteria("name:M,timetype:time,end:%,modificationtime>0,modificationtime:0,"
- + "modificationtime<0");
- expressions = filter.createFilteringConditions(params);
- wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist2 = tagrepository.findAll(wherepred, preq);
- assertThat(dtolist2.getSize()).isNotNegative();
-
- final String dumpcriteria = params.get(0).toString();
- assertThat(dumpcriteria.length()).isPositive();
- final String dumpby = params.get(0).dump();
- assertThat(dumpby.length()).isPositive();
- }
-
- @Test
- public void testIovs() throws Exception {
- final Instant now = Instant.now();
- final Date time = new Date(now.toEpochMilli());
-
- final PayloadDataDBImpl repobean = new PayloadDataDBImpl(mainDataSource);
- final PayloadDto dto = DataGenerator.generatePayloadDto("myhash3", "myrepodata", "mystreamer",
- "test", time);
- log.debug("Save payload {}", dto);
- if (dto.getSize() == null) {
- dto.setSize(dto.getData().length);
- }
- final PayloadDto saved = repobean.save(dto);
- assertThat(saved).isNotNull();
-
- final Tag mtag = DataGenerator.generateTag("A-TEST-10", "test");
- final Tag savedtag = tagrepository.save(mtag);
- IovId id = new IovId("A-TEST-10", new BigDecimal(999L), new Date());
- Iov miov = new Iov(id, savedtag, saved.getHash());
- Iov savediov = iovrepository.save(miov);
- log.info("Saved iov {}", savediov);
- id = new IovId("A-TEST-10", new BigDecimal(2000L), new Date());
- miov = new Iov(id, savedtag, saved.getHash());
- savediov = iovrepository.save(miov);
- log.info("Saved iov {}", savediov);
-
- final List iovlist = iovrepository.findByIdTagName("A-TEST-10");
- assertThat(iovlist.size()).isPositive();
-
- final IFilteringCriteria filter = new IovFiltering();
- final PageRequest preq = createPageRequest(0, 10, "id.since:ASC");
-
- List params = createMatcherCriteria("tagname:A-TEST-10,since>100,insertiontime>0");
- List expressions = filter.createFilteringConditions(params);
- BooleanExpression wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist = iovrepository.findAll(wherepred, preq);
- assertThat(dtolist.getSize()).isPositive();
-
- params = createMatcherCriteria("tagname:A-TEST-10,since:100,insertiontime<2,insertiontime:0");
- expressions = filter.createFilteringConditions(params);
- wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist2 = iovrepository.findAll(wherepred, preq);
- assertThat(dtolist2.getSize()).isNotNegative();
- }
-
- @Test
- public void testMappingTags() throws Exception {
- final GlobalTag gtag = DataGenerator.generateGlobalTag("MY-TEST-GT-02");
- globaltagrepository.save(gtag);
- final Tag tag1 = DataGenerator.generateTag("MY-TEST-02", "time");
- final Tag tag2 = DataGenerator.generateTag("MY-SECOND-03", "time");
- tagrepository.save(tag1);
- tagrepository.save(tag2);
-
- final GlobalTagMapId id1 = new GlobalTagMapId();
- id1.setGlobalTagName(gtag.getName());
- id1.setLabel("MY-TEST");
- id1.setRecord("aaa");
- final GlobalTagMap map1 = DataGenerator.generateMapping(gtag, tag1, id1);
-
- final GlobalTagMapId id2 = new GlobalTagMapId();
- id2.setGlobalTagName(gtag.getName());
- id2.setLabel("MY-SECOND");
- id2.setRecord("bbb");
- final GlobalTagMap map2 = DataGenerator.generateMapping(gtag, tag2, id2);
-
- tagmaprepository.save(map1);
- tagmaprepository.save(map2);
-
- final List gmlist = tagmaprepository.findByGlobalTagName(gtag.getName());
- assertThat(gmlist.size()).isPositive();
-
- final List gmlistbytag = tagmaprepository.findByTagName(tag1.getName());
- assertThat(gmlistbytag.size()).isPositive();
-
- final List gmlistbygtaglabeltag =
- tagmaprepository.findByGlobalTagNameAndLabelAndTagNameLike(gtag.getName(), "MY-TEST", "%");
- assertThat(gmlistbygtaglabeltag.size()).isPositive();
- }
-
- @Test
- public void testRunLumi() throws Exception {
- final Date start = new Date();
- final Date end = new Date(start.getTime()+3600000);
- final RunLumiInfo entity = DataGenerator.generateRunLumiInfo(new BigDecimal(start.getTime()), new BigDecimal(end.getTime()), new BigDecimal(100L));
- runrepository.save(entity);
-
- final IFilteringCriteria filter = new RunLumiInfoFiltering();
- final PageRequest preq = createPageRequest(0, 10, "runNumber:ASC");
-
- final List params = createMatcherCriteria(
- "runNumber>10,runNumber<1000,startTime>0,endtime>0,startTime<" + end.getTime() + ",endtime<" + (
- end.getTime() + 1));
- final List expressions = filter.createFilteringConditions(params);
- BooleanExpression wherepred = null;
-
- for (final BooleanExpression exp : expressions) {
- if (wherepred == null) {
- wherepred = exp;
- }
- else {
- wherepred = wherepred.and(exp);
- }
- }
- final Page dtolist = runrepository.findAll(wherepred, preq);
- assertThat(dtolist.getSize()).isPositive();
-
- final List params1 = createMatcherCriteria(
- "runNumber:100,startTime:" + start.getTime() + ",endtime:" + end.getTime());
- final List expressions1 = filter.createFilteringConditions(params1);
- BooleanExpression wherepred1 = null;
-
- for (final BooleanExpression exp : expressions1) {
- if (wherepred1 == null) {
- wherepred1 = exp;
- }
- else {
- wherepred1 = wherepred1.and(exp);
- }
- }
- final Page