-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[O2B-1157] Improve QC flags get all API (#1515)
* [O2B-1157] Improve QC flags get all API * Fix tests * Fix tests * Fix linter * Fix more tests * Fixed linter again * Fix default ordering * Remove overview workaround * Delegate from/to to data/simulation pass qc flags * Fix more tests * Fix more tests * Fix linter * Remove spurious data pass id * Throw in adapter if qc flag is not eagerly fetched
- Loading branch information
1 parent
7e4fdcc
commit 9e97ec3
Showing
30 changed files
with
851 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
const { AdapterError } = require('../../server/errors/AdapterError.js'); | ||
|
||
/** | ||
* Adapter for data pass QC flag | ||
*/ | ||
class DataPassQcFlagAdapter { | ||
/** | ||
* Constructor | ||
*/ | ||
constructor() { | ||
this.toEntity = this.toEntity.bind(this); | ||
|
||
this.dataPassAdapter = null; | ||
this.qcFlagTypeAdapter = null; | ||
this.qcFlagVerificationAdapter = null; | ||
this.userAdapter = null; | ||
} | ||
|
||
/** | ||
* Converts the given database object to an entity object. | ||
* | ||
* @param {SequelizeDataPassQcFlag} databaseObject Object to convert. | ||
* @returns {DataPassQcFlag} Converted entity object. | ||
*/ | ||
toEntity(databaseObject) { | ||
const { | ||
dataPassId, | ||
qualityControlFlagId, | ||
qcFlag, | ||
createdAt, | ||
updatedAt, | ||
dataPass, | ||
} = databaseObject; | ||
|
||
if (qcFlag === null) { | ||
throw new AdapterError('Related QC flag missing in DataPassQcFlag.'); | ||
} | ||
|
||
return { | ||
dataPassId, | ||
qcFlagId: qualityControlFlagId, | ||
from: qcFlag.from, | ||
to: qcFlag.to, | ||
comment: qcFlag.comment, | ||
createdById: qcFlag.createdById, | ||
flagTypeId: qcFlag.flagTypeId, | ||
runNumber: qcFlag.runNumber, | ||
dplDetectorId: qcFlag.dplDetectorId, | ||
createdAt, | ||
updatedAt, | ||
dataPass: dataPass ? this.dataPassAdapter.toEntity(dataPass) : null, | ||
createdBy: qcFlag.createdBy ? this.userAdapter.toEntity(qcFlag.createdBy) : null, | ||
flagType: qcFlag.flagType ? this.qcFlagTypeAdapter.toEntity(qcFlag.flagType) : null, | ||
verifications: qcFlag.verifications ? this.qcFlagVerificationAdapter.toEntity(qcFlag.verifications) : null, | ||
}; | ||
} | ||
} | ||
|
||
exports.DataPassQcFlagAdapter = DataPassQcFlagAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
const { AdapterError } = require('../../server/errors/AdapterError.js'); | ||
|
||
/** | ||
* Adapter for simulation pass QC flag | ||
*/ | ||
class SimulationPassQcFlagAdapter { | ||
/** | ||
* Constructor | ||
*/ | ||
constructor() { | ||
this.toEntity = this.toEntity.bind(this); | ||
|
||
this.simulationPassAdapter = null; | ||
this.qcFlagTypeAdapter = null; | ||
this.qcFlagVerificationAdapter = null; | ||
this.userAdapter = null; | ||
} | ||
|
||
/** | ||
* Converts the given database object to an entity object. | ||
* | ||
* @param {SequelizeSimulationPassQcFlag} databaseObject Object to convert. | ||
* @returns {SimulationPassQcFlag} Converted entity object. | ||
*/ | ||
toEntity(databaseObject) { | ||
const { | ||
simulationPassId, | ||
qualityControlFlagId, | ||
qcFlag, | ||
createdAt, | ||
updatedAt, | ||
simulationPass, | ||
} = databaseObject; | ||
|
||
if (qcFlag === null) { | ||
throw new AdapterError('Related QC flag missing in SimulationPassQcFlag.'); | ||
} | ||
|
||
return { | ||
simulationPassId, | ||
qcFlagId: qualityControlFlagId, | ||
from: qcFlag.from, | ||
to: qcFlag.to, | ||
comment: qcFlag.comment, | ||
createdById: qcFlag.createdById, | ||
flagTypeId: qcFlag.flagTypeId, | ||
runNumber: qcFlag.runNumber, | ||
dplDetectorId: qcFlag.dplDetectorId, | ||
createdAt, | ||
updatedAt, | ||
simulationPass: simulationPass ? this.simulationPassAdapter.toEntity(simulationPass) : null, | ||
createdBy: qcFlag.createdBy ? this.userAdapter.toEntity(qcFlag.createdBy) : null, | ||
flagType: qcFlag.flagType ? this.qcFlagTypeAdapter.toEntity(qcFlag.flagType) : null, | ||
verifications: qcFlag.verifications ? this.qcFlagVerificationAdapter.toEntity(qcFlag.verifications) : null, | ||
}; | ||
} | ||
} | ||
|
||
exports.SimulationPassQcFlagAdapter = SimulationPassQcFlagAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
const Sequelize = require('sequelize'); | ||
|
||
module.exports = (sequelize) => { | ||
const QcFlag = sequelize.define( | ||
'DataPassQcFlag', | ||
{ | ||
dataPassId: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
}, | ||
qualityControlFlagId: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
}, | ||
}, | ||
{ tableName: 'data_pass_quality_control_flag' }, | ||
); | ||
|
||
QcFlag.associate = (models) => { | ||
QcFlag.belongsTo(models.QcFlag, { as: 'qcFlag', foreignKey: 'qualityControlFlagId', targetKey: 'id' }); | ||
QcFlag.belongsTo(models.DataPass, { as: 'dataPass' }); | ||
}; | ||
|
||
return QcFlag; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
const Sequelize = require('sequelize'); | ||
|
||
module.exports = (sequelize) => { | ||
const QcFlag = sequelize.define( | ||
'SimulationPassQcFlag', | ||
{ | ||
simulationPassId: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
}, | ||
qualityControlFlagId: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
}, | ||
}, | ||
{ tableName: 'simulation_pass_quality_control_flag' }, | ||
); | ||
|
||
QcFlag.associate = (models) => { | ||
QcFlag.belongsTo(models.QcFlag, { as: 'qcFlag', foreignKey: 'qualityControlFlagId', targetKey: 'id' }); | ||
QcFlag.belongsTo(models.SimulationPass, { as: 'simulationPass' }); | ||
}; | ||
|
||
return QcFlag; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
/** | ||
* @typedef SequelizeDataPassQcFlag | ||
* @property {number} dataPassId | ||
* @property {number} qualityControlFlagId | ||
* @property {number} createdAt | ||
* @property {number} updatedAt | ||
* @property {SequelizeQcFlag|null} qcFlag | ||
* @property {SequelizeDataPass|null} dataPass | ||
*/ |
Oops, something went wrong.