class CsvReportGenerator extends VolumeReportGenerator

Traits

Properties

Collection $options

Options for this report.

from  ReportGenerator
string $name

Name of the report for use in text.

string $filename

Name of the report for use as (part of) a filename.

string $extension

File extension of the report file.

protected mixed $source

Source this report belongs to (e.g. a volume).

from  ReportGenerator
protected array $tmpFiles

Temporary files that are created when generating a report.

from  ReportGenerator
protected Collection $labels

Cache for labels of all label trees that are used for this report.

from  ReportGenerator
protected AnnotationSession $annotationSession

Cache for the annotation session the report may be restricted to.

from  VolumeReportGenerator
protected PythonScriptRunner $pythonScriptRunner

Object that runs the Python script to generate a report.

from  VolumeReportGenerator

Methods

static ReportGenerator
get(string $sourceClass, ReportType $type, array $options = [])

Get the report generator for the given type.

__construct(array $options = [])

Create a report generator instance.

string
generate(mixed $source)

Generate the report.

generateReport(string $path)

Generate the report.

setSource(mixed $source)

Set the source.

string
getName()

Get the report name.

string
getFilename()

Get the filename.

string
getFullFilename()

Get the filename with extension.

string
expandLabelName(int $id)

Constructs a label name from the names of all parent labels and the label itself.

Collection
getSiblingLabels(int $id)

Get all labels that belong to the label tree of the given label.

bool
shouldSeparateLabelTrees()

Should this report separate the output files for different label trees?

bool
shouldSeparateUsers()

Should this report separate the output files for different user?

array
getOnlyLabels()

Returns the array of label ids to which this report should be restricted.

bool
isRestrictedToLabels()

Determines if this report is restricted to a subset of labels.

setPythonScriptRunner(mixed $runner)

Set the Python script runner object.

Collection
getVolumeLabels()

Get all labels that are attached to the volume of this report (through project label trees).

executeScript(string $scriptName, string $path)

Execute the external report parsing Python script.

bool
isRestrictedToAnnotationSession()

Should this report be restricted an annotation session?

getAnnotationSession()

Returns the annotation session this report should be restricted to.

string
getAnnotationSessionName()

Get the name of the annotation session if it exists.

bool
isRestrictedToNewestLabel()

Determines if this report should take only the newest label of each annotation.

Builder
restrictToLabelsQuery(Builder $query, string $table)

Callback to be used in a when query statement that restricts the results to a specific subset of annotation labels.

makeZip(array $files, string $path)

Create a ZIP archive as a report.

string
sanitizeFilename(string $name, string $extension)

Sanitizes a filename.

Builder
restrictToNewestLabelQuery(Builder $query, string $table)

Callback to be used in a when query statement that restricts the results to the newest annotation labels of each annotation.

Builder
initQuery(mixed $columns = [])

Assembles the part of the DB query that is the same for all annotation reports.

Builder
restrictToAnnotationSessionQuery(Builder $query)

Callback to be used in a when query statement that restricts the resulting annotation labels to the annotation session of this report.

Builder
query()

Assemble a new DB query for the video of this report.

createCsv(Collection $rows)

Create a CSV file for this report.

Details

in ReportGenerator at line 75
static ReportGenerator get(string $sourceClass, ReportType $type, array $options = [])

Get the report generator for the given type.

Parameters

string $sourceClass

Class name of the source model

ReportType $type

Type of the report to generate

array $options

Options for the report generator

Return Value

ReportGenerator

__construct(array $options = [])

Create a report generator instance.

Parameters

array $options

Options for the report

in ReportGenerator at line 116
string generate(mixed $source)

Generate the report.

Parameters

mixed $source

Source to generate the report for (e.g. a volume)

Return Value

string

Path to the generated report file.

at line 99
generateReport(string $path)

Generate the report.

Parameters

string $path

Path to write the report file to.

in ReportGenerator at line 163
setSource(mixed $source)

Set the source.

Parameters

mixed $source

at line 45
string getName()

Get the report name.

Return Value

string

at line 72
string getFilename()

Get the filename.

Return Value

string

in ReportGenerator at line 193
string getFullFilename()

Get the filename with extension.

Return Value

string

string expandLabelName(int $id)

Constructs a label name from the names of all parent labels and the label itself.

Example: Animalia > Annelida > Polychaeta > Buskiella sp

Parameters

int $id

Label ID

Return Value

string

in ReportGenerator at line 237
protected Collection getSiblingLabels(int $id)

Get all labels that belong to the label tree of the given label.

Parameters

int $id

Label ID

Return Value

Collection

in ReportGenerator at line 253
protected bool shouldSeparateLabelTrees()

Should this report separate the output files for different label trees?

Return Value

bool

in ReportGenerator at line 263
protected bool shouldSeparateUsers()

Should this report separate the output files for different user?

Return Value

bool

in ReportGenerator at line 273
protected array getOnlyLabels()

Returns the array of label ids to which this report should be restricted.

Return Value

array

in ReportGenerator at line 283
protected bool isRestrictedToLabels()

Determines if this report is restricted to a subset of labels.

Return Value

bool

setPythonScriptRunner(mixed $runner)

Set the Python script runner object.

Parameters

mixed $runner

protected Collection getVolumeLabels()

Get all labels that are attached to the volume of this report (through project label trees).

Return Value

Collection

protected executeScript(string $scriptName, string $path)

Execute the external report parsing Python script.

Parameters

string $scriptName

Name of the script to execute (in the reports.scripts config namespace)

string $path

Path to the file to store the generated report to

Exceptions

Exception

protected bool isRestrictedToAnnotationSession()

Should this report be restricted an annotation session?

Return Value

bool

protected AnnotationSession|null getAnnotationSession()

Returns the annotation session this report should be restricted to.

Return Value

AnnotationSession|null

protected string getAnnotationSessionName()

Get the name of the annotation session if it exists.

Return Value

string

protected bool isRestrictedToNewestLabel()

Determines if this report should take only the newest label of each annotation.

Return Value

bool

protected Builder restrictToLabelsQuery(Builder $query, string $table)

Callback to be used in a when query statement that restricts the results to a specific subset of annotation labels.

Parameters

Builder $query
string $table

Name of the annotation/image label DB table

Return Value

Builder

in MakesZipArchives at line 22
protected makeZip(array $files, string $path)

Create a ZIP archive as a report.

This function will create a ZIP archive at $this->availableReport->path.

Parameters

array $files

Array of files, with source path as keys and target filenames (in the ZIP) as values.

string $path

Path to the file to store the generated ZIP to

Exceptions

Exception

in MakesZipArchives at line 48
protected string sanitizeFilename(string $name, string $extension)

Sanitizes a filename.

Parameters

string $name

Filename to sanitize

string $extension

File extension to use (since dots are sanitized, too)

Return Value

string

Builder restrictToNewestLabelQuery(Builder $query, string $table)

Callback to be used in a when query statement that restricts the results to the newest annotation labels of each annotation.

Parameters

Builder $query
string $table

Name of the annotation label DB table

Return Value

Builder

at line 139
Builder initQuery(mixed $columns = [])

Assembles the part of the DB query that is the same for all annotation reports.

Parameters

mixed $columns

The columns to select

Return Value

Builder

at line 170
Builder restrictToAnnotationSessionQuery(Builder $query)

Callback to be used in a when query statement that restricts the resulting annotation labels to the annotation session of this report.

Parameters

Builder $query

Return Value

Builder

at line 192
protected Builder query()

Assemble a new DB query for the video of this report.

Return Value

Builder

at line 223
protected CsvFile createCsv(Collection $rows)

Create a CSV file for this report.

Parameters

Collection $rows

The rows for the CSV

Return Value

CsvFile