Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perl pipeline] Do not duplicate violation entry if it already exists #896

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/scripts_md/MRI.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Inserts scans that do not correspond to any of the defined protocol from the
database.

INPUTS:
- $dbhr : database handle reference
- $db : database object
- $series\_desc : series description of the scan
- $minc\_location : location of the MINC file
- $patient\_name : patient name of the scan
Expand Down
1 change: 1 addition & 0 deletions docs/scripts_md/MRIProcessingUtility.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ INPUTS:
- $visit\_label : visit label associated with the scan
- $file : information about the scan
- $data\_dir : path to the LORIS MRI data directory
- $scan\_type : scan type associated to the file

### loadAndCreateObjectFile($minc, $upload\_id)

Expand Down
106 changes: 106 additions & 0 deletions docs/scripts_md/MriCandidateErrorsOB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# NAME

NeuroDB::objectBroker::MriCandidateErrorsOB -- An object broker for `MriCandidateErrors` records

# SYNOPSIS

use NeuroDB::Database;
use NeuroDB::objectBroker::MriCandidateErrorsOB;
use TryCatch;

my $db = NeuroDB::Database->new(
userName => 'user',
databaseName => 'my_db',
hostName => 'my_hostname',
password => 'pwd'
);

try {
$db->connect();
} catch(NeuroDB::DatabaseException $e) {
die sprintf(
"User %s failed to connect to %s on %s: %s (error code %d)\n",
'user',
'my_db',
'my_hostname',
$e->errorMessage,
$e->errorCode
);
}

.
.
.

my $mriCandidateErrorsOB = NeuroDB::objectBroker::MriCandidateErrorsOB->new(db => $db);
my $mriCandidateErrorsRef;
try {
$mriCandidateErrorsRef = $mriCandidateErrorsOB->getByTarchiveID(
[ 'TarchiveID' ], 12
);
} catch(NeuroDB::objectBroker::ObjectBrokerException $e) {
die sprintf(
"Failed to retrieve MriCandidateErrors records: %s",
$e->errorMessage
);
}

# DESCRIPTION

This class provides a set of methods to either fetch records from the `MRICandidateErrors`
table, insert new entries in it or update existing ones. If an operation cannot
be executed successfully, a `NeuroDB::objectBroker::ObjectBrokerException` is thrown.

## Methods

### new(db => $db) >> (constructor)

Create a new instance of this class. The only parameter to provide is the
`Database` object used to access the database.

INPUT: the database object used to read/modify the `MRICandidateErrors` table.

RETURN: new instance of this class.

### getWithTarchiveID($tarchiveID)

Fetches the records from the `MRICandidateErrors` table that have a specific `TarchiveID`.

INPUTS:
- ID of the tarchive used during the search.

RETURN: a reference to an array of hash references. Every hash contains the values for a given
row returned by the function call: the key/value pairs contain the name of a column
(listed in `@MRICANDIDATEERRORS_FIELDS`) and the value it holds, respectively.
As an example, suppose array `$r` contains the result of a call to this method with
`@$fieldsRef` set to `('TarchiveID', 'MincFile'` one would fetch the `MincFile`
of the 4th record returned using `$r-`\[3\]->{'MincFile'}>.

### insert($valuesRef)

Inserts a new record in the `MRICandidateErrors` table with the specified column values.
This method throws a `NeuroDB::objectBroker::ObjectBrokerException` if the operation
could not be completed successfully.

INPUT: a reference to a hash of the values to insert. The hash contains the column
names and associated record values used during insertion. All the keys of
`%$valuesRef` must exist in `@MRICANDIDATEERRORS_FIELDS` or an exception will be thrown.

RETURNS: the index of the MRI upload record inserted.

# TO DO

Nothing planned.

# BUGS

None reported.

# COPYRIGHT AND LICENSE

License: GPLv3

# AUTHORS

LORIS community <loris.info@mcin.ca> and McGill Centre for Integrative
Neuroscience
106 changes: 106 additions & 0 deletions docs/scripts_md/MriProtocolViolatedScansOB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# NAME

NeuroDB::objectBroker::MriProtocolViolatedScansOB -- An object broker for `mri_protocol_violated_scans` records

# SYNOPSIS

use NeuroDB::Database;
use NeuroDB::objectBroker::MriProtocolViolatedScansOB;
use TryCatch;

my $db = NeuroDB::Database->new(
userName => 'user',
databaseName => 'my_db',
hostName => 'my_hostname',
password => 'pwd'
);

try {
$db->connect();
} catch(NeuroDB::DatabaseException $e) {
die sprintf(
"User %s failed to connect to %s on %s: %s (error code %d)\n",
'user',
'my_db',
'my_hostname',
$e->errorMessage,
$e->errorCode
);
}

.
.
.

my $mriProtocolViolatedScansOB = NeuroDB::objectBroker::MriProtocolViolatedScansOB->new(db => $db);
my $mriProtocolViolatedScansOBRef;
try {
$mriProtocolViolatedScansOBRef = $mriProtocolViolatedScansOB->getByTarchiveID(
[ 'TarchiveID' ], 12
);
} catch(NeuroDB::objectBroker::ObjectBrokerException $e) {
die sprintf(
"Failed to retrieve mri_protocol_violated_scans records: %s",
$e->errorMessage
);
}

# DESCRIPTION

This class provides a set of methods to either fetch records from the `mri_protocol_violated_scans`
table, insert new entries in it or update existing ones. If an operation cannot
be executed successfully, a `NeuroDB::objectBroker::ObjectBrokerException` is thrown.

## Methods

### new(db => $db) >> (constructor)

Create a new instance of this class. The only parameter to provide is the
`Database` object used to access the database.

INPUT: the database object used to read/modify the `mri_protocol_violated_scans` table.

RETURN: new instance of this class.

### getWithTarchiveID($tarchiveID)

Fetches the records from the `mri_protocol_violated_scans` table that have a specific `TarchiveID`.

INPUTS:
- ID of the tarchive used during the search.

RETURN: a reference to an array of hash references. Every hash contains the values for a given
row returned by the function call: the key/value pairs contain the name of a column
(listed in `@MRIPROTOCOLVIOLATEDSCANS_FIELDS`) and the value it holds, respectively.
As an example, suppose array `$r` contains the result of a call to this method with
`@$fieldsRef` set to `('TarchiveID', 'minc_location'` one would fetch the `minc_location`
of the 4th record returned using `$r-`\[3\]->{'minc\_location'}>.

### insert($valuesRef)

Inserts a new record in the `mri_protocol_violated_scans` table with the specified column values.
This method throws a `NeuroDB::objectBroker::ObjectBrokerException` if the operation
could not be completed successfully.

INPUT: a reference to a hash of the values to insert. The hash contains the column
names and associated record values used during insertion. All the keys of
`%$valuesRef` must exist in `@MRIPROTOCOLVIOLATEDSCANS_FIELDS` or an exception will be thrown.

RETURNS: the index of the MRI upload record inserted.

# TO DO

Nothing planned.

# BUGS

None reported.

# COPYRIGHT AND LICENSE

License: GPLv3

# AUTHORS

LORIS community <loris.info@mcin.ca> and McGill Centre for Integrative
Neuroscience
106 changes: 106 additions & 0 deletions docs/scripts_md/MriViolationsLogOB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# NAME

NeuroDB::objectBroker::MriViolationsLogOB -- An object broker for `mri_violations_log` records

# SYNOPSIS

use NeuroDB::Database;
use NeuroDB::objectBroker::MriViolationsLogOB;
use TryCatch;

my $db = NeuroDB::Database->new(
userName => 'user',
databaseName => 'my_db',
hostName => 'my_hostname',
password => 'pwd'
);

try {
$db->connect();
} catch(NeuroDB::DatabaseException $e) {
die sprintf(
"User %s failed to connect to %s on %s: %s (error code %d)\n",
'user',
'my_db',
'my_hostname',
$e->errorMessage,
$e->errorCode
);
}

.
.
.

my $mriViolationsLogOB = NeuroDB::objectBroker::MriViolationsLogOB->new(db => $db);
my $mriProtocolViolatedScansOBRef;
try {
$mriViolationsLogOBRef = $mriViolationsLogOB->getByTarchiveID(
[ 'TarchiveID' ], 12
);
} catch(NeuroDB::objectBroker::ObjectBrokerException $e) {
die sprintf(
"Failed to retrieve mri_violations_log records: %s",
$e->errorMessage
);
}

# DESCRIPTION

This class provides a set of methods to either fetch records from the `mri_violations_log`
table, insert new entries in it or update existing ones. If an operation cannot
be executed successfully, a `NeuroDB::objectBroker::ObjectBrokerException` is thrown.

## Methods

### new(db => $db) >> (constructor)

Create a new instance of this class. The only parameter to provide is the
`Database` object used to access the database.

INPUT: the database object used to read/modify the `mri_violations_log` table.

RETURN: new instance of this class.

### getWithTarchiveID($tarchiveID)

Fetches the records from the `mri_violations_log` table that have a specific `TarchiveID`.

INPUTS:
- ID of the tarchive used during the search.

RETURN: a reference to an array of hash references. Every hash contains the values for a given
row returned by the function call: the key/value pairs contain the name of a column
(listed in `@MRIVIOLATIONSLOG_FIELDS`) and the value it holds, respectively.
As an example, suppose array `$r` contains the result of a call to this method with
`@$fieldsRef` set to `('TarchiveID', 'MincFile'` one would fetch the `MincFile`
of the 4th record returned using `$r-`\[3\]->{'MincFile'}>.

### insert($valuesRef)

Inserts a new record in the `mri_violations_log` table with the specified column values.
This method throws a `NeuroDB::objectBroker::ObjectBrokerException` if the operation
could not be completed successfully.

INPUT: a reference to a hash of the values to insert. The hash contains the column
names and associated record values used during insertion. All the keys of
`%$valuesRef` must exist in `@MRIVIOLATIONSLOG_FIELDS` or an exception will be thrown.

RETURNS: the index of the MRI upload record inserted.

# TO DO

Nothing planned.

# BUGS

None reported.

# COPYRIGHT AND LICENSE

License: GPLv3

# AUTHORS

LORIS community <loris.info@mcin.ca> and McGill Centre for Integrative
Neuroscience
Loading