-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from IQSS/77-files-display-data-use-cases
Add use cases for file tab data visualization
- Loading branch information
Showing
42 changed files
with
1,859 additions
and
294 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
var config = require('./jest.config'); | ||
config.modulePathIgnorePatterns = ['<rootDir>/test/integration']; | ||
delete config.globalSetup; | ||
delete config.testTimeout; | ||
console.log('RUNNING UNIT TESTS'); | ||
module.exports = config; |
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
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 was deleted.
Oops, something went wrong.
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
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,39 @@ | ||
export interface File { | ||
id: number; | ||
persistentId: string; | ||
name: string; | ||
pidURL?: string; | ||
sizeBytes: number; | ||
version: number; | ||
description?: string; | ||
restricted: boolean; | ||
directoryLabel?: string; | ||
datasetVersionId?: number; | ||
categories?: string[]; | ||
contentType: string; | ||
embargo?: FileEmbargo; | ||
storageIdentifier?: string; | ||
originalFormat?: string; | ||
originalFormatLabel?: string; | ||
originalSize?: number; | ||
originalName?: string; | ||
UNF?: string; | ||
rootDataFileId?: number; | ||
previousDataFileId?: number; | ||
md5?: string; | ||
checksum?: FileChecksum; | ||
metadataId?: number; | ||
tabularTags?: string[]; | ||
creationDate?: Date; | ||
publicationDate?: Date; | ||
} | ||
|
||
export interface FileEmbargo { | ||
dateAvailable: Date; | ||
reason?: string; | ||
} | ||
|
||
export interface FileChecksum { | ||
type: string; | ||
value: string; | ||
} |
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,82 @@ | ||
export interface FileDataTable { | ||
varQuantity?: number; | ||
caseQuantity?: number; | ||
recordsPerCase?: number; | ||
UNF: string; | ||
dataVariables: FileDataVariable[]; | ||
} | ||
|
||
export interface FileDataVariable { | ||
id: number; | ||
name: string; | ||
label?: string; | ||
weighted: boolean; | ||
variableIntervalType?: FileDataVariableIntervalType; | ||
variableFormatType?: FileDataVariableFormatType; | ||
formatCategory?: string; | ||
format?: string; | ||
isOrderedCategorical: boolean; | ||
fileOrder: number; | ||
UNF: string; | ||
fileStartPosition?: number; | ||
fileEndPosition?: number; | ||
recordSegmentNumber?: number; | ||
numberOfDecimalPoints?: number; | ||
variableMetadata?: FileDataVariableMetadata[]; | ||
invalidRanges?: FileDataVariableInvalidRanges[]; | ||
summaryStatistics?: object; | ||
variableCategories?: FileDataVariableCategory[]; | ||
} | ||
|
||
export interface FileDataVariableMetadata { | ||
id: number; | ||
metadataId: number; | ||
label?: string; | ||
isWeightVar: boolean; | ||
isWeighted: boolean; | ||
weightVariableId?: number; | ||
literalQuestion?: string; | ||
interviewInstruction?: string; | ||
postQuestion?: string; | ||
universe?: string; | ||
notes?: string; | ||
categoryMetadatas: FileDataVariableCategoryMetadata[]; | ||
} | ||
|
||
export interface FileDataVariableCategoryMetadata { | ||
wFreq?: number; | ||
categoryValue?: string; | ||
} | ||
|
||
export interface FileDataVariableInvalidRanges { | ||
beginValue?: string; | ||
hasBeginValueType: boolean; | ||
isBeginValueTypePoint: boolean; | ||
isBeginValueTypeMin: boolean; | ||
isBeginValueTypeMinExcl: boolean; | ||
isBeginValueTypeMax: boolean; | ||
isBeginValueTypeMaxExcl: boolean; | ||
endValue?: string; | ||
hasEndValueType: boolean; | ||
endValueTypeMax: boolean; | ||
endValueTypeMaxExcl: boolean; | ||
} | ||
|
||
export interface FileDataVariableCategory { | ||
label?: string; | ||
value?: string; | ||
isMissing: boolean; | ||
frequency?: number; | ||
} | ||
|
||
export enum FileDataVariableIntervalType { | ||
DISCRETE = 'discrete', | ||
CONTIN = 'contin', | ||
NOMINAL = 'nominal', | ||
DICHOTOMOUS = 'dichotomous', | ||
} | ||
|
||
export enum FileDataVariableFormatType { | ||
NUMERIC = 'NUMERIC', | ||
CHARACTER = 'CHARACTER', | ||
} |
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,8 @@ | ||
export enum FileOrderCriteria { | ||
NAME_AZ = 'NameAZ', | ||
NAME_ZA = 'NameZA', | ||
NEWEST = 'Newest', | ||
OLDEST = 'Oldest', | ||
SIZE = 'Size', | ||
TYPE = 'Type', | ||
} |
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,4 @@ | ||
export interface FileUserPermissions { | ||
canDownloadFile: boolean; | ||
canEditOwnerDataset: boolean; | ||
} |
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,20 @@ | ||
import { FileOrderCriteria } from '../models/FileOrderCriteria'; | ||
import { File } from '../models/File'; | ||
import { FileDataTable } from '../models/FileDataTable'; | ||
import { FileUserPermissions } from '../models/FileUserPermissions'; | ||
|
||
export interface IFilesRepository { | ||
getDatasetFiles( | ||
datasetId: number | string, | ||
datasetVersionId?: string, | ||
limit?: number, | ||
offset?: number, | ||
orderCriteria?: FileOrderCriteria, | ||
): Promise<File[]>; | ||
|
||
getFileDownloadCount(fileId: number | string): Promise<number>; | ||
|
||
getFileUserPermissions(fileId: number | string): Promise<FileUserPermissions>; | ||
|
||
getFileDataTables(fileId: number | string): Promise<FileDataTable[]>; | ||
} |
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 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase'; | ||
import { FileOrderCriteria } from '../models/FileOrderCriteria'; | ||
import { IFilesRepository } from '../repositories/IFilesRepository'; | ||
import { File } from '../models/File'; | ||
|
||
export class GetDatasetFiles implements UseCase<File[]> { | ||
private filesRepository: IFilesRepository; | ||
|
||
constructor(filesRepository: IFilesRepository) { | ||
this.filesRepository = filesRepository; | ||
} | ||
|
||
async execute( | ||
datasetId: number | string, | ||
datasetVersionId?: string, | ||
limit?: number, | ||
offset?: number, | ||
orderCriteria?: FileOrderCriteria, | ||
): Promise<File[]> { | ||
return await this.filesRepository.getDatasetFiles(datasetId, datasetVersionId, limit, offset, orderCriteria); | ||
} | ||
} |
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,15 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase'; | ||
import { IFilesRepository } from '../repositories/IFilesRepository'; | ||
import { FileDataTable } from '../models/FileDataTable'; | ||
|
||
export class GetFileDataTables implements UseCase<FileDataTable[]> { | ||
private filesRepository: IFilesRepository; | ||
|
||
constructor(filesRepository: IFilesRepository) { | ||
this.filesRepository = filesRepository; | ||
} | ||
|
||
async execute(fileId: number | string): Promise<FileDataTable[]> { | ||
return await this.filesRepository.getFileDataTables(fileId); | ||
} | ||
} |
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,14 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase'; | ||
import { IFilesRepository } from '../repositories/IFilesRepository'; | ||
|
||
export class GetFileDownloadCount implements UseCase<number> { | ||
private filesRepository: IFilesRepository; | ||
|
||
constructor(filesRepository: IFilesRepository) { | ||
this.filesRepository = filesRepository; | ||
} | ||
|
||
async execute(fileId: number | string): Promise<number> { | ||
return await this.filesRepository.getFileDownloadCount(fileId); | ||
} | ||
} |
Oops, something went wrong.