You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
12 KiB
195 lines
12 KiB
'use strict';
|
|
|
|
module.exports = (app, conf) => {
|
|
const {
|
|
Tender, TenderDirectory, V2Tenders, V2TenderChapters, V2TenderChapterVersions,
|
|
TenderImageLibrary, TenderImages, TenderImageTags, TenderImageTagRelation,
|
|
Solutions, SolutionChapters, SolutionChapterVersions,
|
|
PatentSolutions, PatentSolutionBaseFields, PatentSolutionChapters,
|
|
PatentSolutionChapterVersions, PatentSolutionDocVersions, PatentSolutionChatRecords,
|
|
PatentReviewTasks, PatentReviewFiles, PatentCoreReviewResults,
|
|
PatentGrantQueryResults, PatentCompareResults,
|
|
Book, BookChapter, BookChapterContent,
|
|
ReportSchemaVersion, ReportDataSource, ReportTemplate, ReportTemplateChapter, ReportTemplateBlock,
|
|
ReportTemplateBatchDimension, ReportTemplateBlockBatchBinding,
|
|
ReportGenerationBatch, ReportGenerationBatchItem,
|
|
ReportInstance, ReportChapter, ReportBlock,
|
|
PlagiarismCheckDocTypes, PlagiarismCheckTasks, PlagiarismCheckFiles, PlagiarismCheckFileBlocks,
|
|
PlagiarismCheckMatches, PlagiarismCheckFileSummaries
|
|
} = app.fs.dc.models;
|
|
|
|
TenderDirectory.belongsTo(Tender, { foreignKey: 'tenderId', targetKey: 'id' });
|
|
Tender.hasMany(TenderDirectory, { foreignKey: 'tenderId', sourceKey: 'id' });
|
|
|
|
V2TenderChapters.belongsTo(V2Tenders, { foreignKey: 'tenderId', targetKey: 'id' });
|
|
V2Tenders.hasMany(V2TenderChapters, { foreignKey: 'tenderId', sourceKey: 'id' });
|
|
|
|
V2TenderChapterVersions.belongsTo(V2TenderChapters, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
V2TenderChapters.hasMany(V2TenderChapterVersions, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
TenderImages.belongsTo(TenderImageLibrary, { foreignKey: 'libraryId', targetKey: 'id' });
|
|
TenderImageLibrary.hasMany(TenderImages, { foreignKey: 'libraryId', sourceKey: 'id' });
|
|
|
|
TenderImageTagRelation.belongsTo(TenderImages, { foreignKey: 'imageId', targetKey: 'id' });
|
|
TenderImages.hasMany(TenderImageTagRelation, { foreignKey: 'imageId', sourceKey: 'id' });
|
|
|
|
TenderImageTagRelation.belongsTo(TenderImageTags, { foreignKey: 'tagId', targetKey: 'id' });
|
|
TenderImageTags.hasMany(TenderImageTagRelation, { foreignKey: 'tagId', sourceKey: 'id' });
|
|
|
|
SolutionChapters.belongsTo(Solutions, { foreignKey: 'solutionId', targetKey: 'id' });
|
|
Solutions.hasMany(SolutionChapters, { foreignKey: 'solutionId', sourceKey: 'id' });
|
|
|
|
SolutionChapterVersions.belongsTo(SolutionChapters, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
SolutionChapters.hasMany(SolutionChapterVersions, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
PatentSolutionBaseFields.belongsTo(PatentSolutions, { foreignKey: 'solutionId', targetKey: 'id' });
|
|
PatentSolutions.hasMany(PatentSolutionBaseFields, { foreignKey: 'solutionId', sourceKey: 'id' });
|
|
|
|
PatentSolutionChapters.belongsTo(PatentSolutions, { foreignKey: 'solutionId', targetKey: 'id' });
|
|
PatentSolutions.hasMany(PatentSolutionChapters, { foreignKey: 'solutionId', sourceKey: 'id' });
|
|
|
|
PatentSolutionChapterVersions.belongsTo(PatentSolutionChapters, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
PatentSolutionChapters.hasMany(PatentSolutionChapterVersions, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
PatentSolutionDocVersions.belongsTo(PatentSolutions, { foreignKey: 'solutionId', targetKey: 'id' });
|
|
PatentSolutions.hasMany(PatentSolutionDocVersions, { foreignKey: 'solutionId', sourceKey: 'id' });
|
|
|
|
PatentSolutionChatRecords.belongsTo(PatentSolutions, { foreignKey: 'solutionId', targetKey: 'id' });
|
|
PatentSolutions.hasMany(PatentSolutionChatRecords, { foreignKey: 'solutionId', sourceKey: 'id' });
|
|
|
|
if (PatentReviewTasks && PatentReviewFiles) {
|
|
PatentReviewFiles.belongsTo(PatentReviewTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PatentReviewTasks.hasMany(PatentReviewFiles, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PatentReviewTasks && PatentCoreReviewResults) {
|
|
PatentCoreReviewResults.belongsTo(PatentReviewTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PatentReviewTasks.hasOne(PatentCoreReviewResults, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PatentReviewTasks && PatentGrantQueryResults) {
|
|
PatentGrantQueryResults.belongsTo(PatentReviewTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PatentReviewTasks.hasOne(PatentGrantQueryResults, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PatentReviewTasks && PatentCompareResults) {
|
|
PatentCompareResults.belongsTo(PatentReviewTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PatentReviewTasks.hasOne(PatentCompareResults, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
BookChapter.belongsTo(Book, { foreignKey: 'bookId', targetKey: 'id' });
|
|
Book.hasMany(BookChapter, { foreignKey: 'bookId', sourceKey: 'id' });
|
|
|
|
BookChapter.belongsTo(BookChapter, { as: 'parent', foreignKey: 'parentId', targetKey: 'id' });
|
|
BookChapter.hasMany(BookChapter, { as: 'children', foreignKey: 'parentId', sourceKey: 'id' });
|
|
|
|
BookChapterContent.belongsTo(BookChapter, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
BookChapter.hasMany(BookChapterContent, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
ReportTemplate.belongsTo(ReportSchemaVersion, { foreignKey: 'schemaVersionId', targetKey: 'id' });
|
|
ReportSchemaVersion.hasMany(ReportTemplate, { foreignKey: 'schemaVersionId', sourceKey: 'id' });
|
|
|
|
ReportTemplateChapter.belongsTo(ReportTemplate, { foreignKey: 'templateId', targetKey: 'id' });
|
|
ReportTemplate.hasMany(ReportTemplateChapter, { foreignKey: 'templateId', sourceKey: 'id' });
|
|
|
|
ReportTemplateChapter.belongsTo(ReportTemplateChapter, { as: 'parent', foreignKey: 'parentId', targetKey: 'id' });
|
|
ReportTemplateChapter.hasMany(ReportTemplateChapter, { as: 'children', foreignKey: 'parentId', sourceKey: 'id' });
|
|
|
|
ReportTemplateBlock.belongsTo(ReportTemplate, { foreignKey: 'templateId', targetKey: 'id' });
|
|
ReportTemplate.hasMany(ReportTemplateBlock, { foreignKey: 'templateId', sourceKey: 'id' });
|
|
|
|
ReportTemplateBlock.belongsTo(ReportTemplateChapter, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
ReportTemplateChapter.hasMany(ReportTemplateBlock, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
ReportTemplateBatchDimension.belongsTo(ReportTemplate, { foreignKey: 'templateId', targetKey: 'id' });
|
|
ReportTemplate.hasOne(ReportTemplateBatchDimension, { foreignKey: 'templateId', sourceKey: 'id' });
|
|
|
|
ReportTemplateBlockBatchBinding.belongsTo(ReportTemplateBlock, { foreignKey: 'templateBlockId', targetKey: 'id' });
|
|
ReportTemplateBlock.hasOne(ReportTemplateBlockBatchBinding, { foreignKey: 'templateBlockId', sourceKey: 'id' });
|
|
|
|
ReportTemplateBlockBatchBinding.belongsTo(ReportTemplateBatchDimension, { foreignKey: 'templateBatchDimensionId', targetKey: 'id' });
|
|
ReportTemplateBatchDimension.hasMany(ReportTemplateBlockBatchBinding, { foreignKey: 'templateBatchDimensionId', sourceKey: 'id' });
|
|
|
|
ReportGenerationBatch.belongsTo(ReportTemplate, { foreignKey: 'templateId', targetKey: 'id' });
|
|
ReportTemplate.hasMany(ReportGenerationBatch, { foreignKey: 'templateId', sourceKey: 'id' });
|
|
|
|
ReportGenerationBatch.belongsTo(ReportTemplateBatchDimension, { foreignKey: 'templateBatchDimensionId', targetKey: 'id' });
|
|
ReportTemplateBatchDimension.hasMany(ReportGenerationBatch, { foreignKey: 'templateBatchDimensionId', sourceKey: 'id' });
|
|
|
|
ReportGenerationBatchItem.belongsTo(ReportGenerationBatch, { foreignKey: 'batchId', targetKey: 'id' });
|
|
ReportGenerationBatch.hasMany(ReportGenerationBatchItem, { foreignKey: 'batchId', sourceKey: 'id' });
|
|
|
|
ReportInstance.belongsTo(ReportTemplate, { foreignKey: 'templateId', targetKey: 'id' });
|
|
ReportTemplate.hasMany(ReportInstance, { foreignKey: 'templateId', sourceKey: 'id' });
|
|
|
|
ReportInstance.belongsTo(ReportGenerationBatch, { foreignKey: 'generationBatchId', targetKey: 'id' });
|
|
ReportGenerationBatch.hasMany(ReportInstance, { foreignKey: 'generationBatchId', sourceKey: 'id' });
|
|
|
|
ReportInstance.belongsTo(ReportSchemaVersion, { foreignKey: 'schemaVersionId', targetKey: 'id' });
|
|
ReportSchemaVersion.hasMany(ReportInstance, { foreignKey: 'schemaVersionId', sourceKey: 'id' });
|
|
|
|
ReportInstance.belongsTo(ReportDataSource, { foreignKey: 'dataSourceId', targetKey: 'id' });
|
|
ReportDataSource.hasMany(ReportInstance, { foreignKey: 'dataSourceId', sourceKey: 'id' });
|
|
|
|
ReportChapter.belongsTo(ReportInstance, { foreignKey: 'instanceId', targetKey: 'id' });
|
|
ReportInstance.hasMany(ReportChapter, { foreignKey: 'instanceId', sourceKey: 'id' });
|
|
|
|
ReportChapter.belongsTo(ReportChapter, { as: 'parent', foreignKey: 'parentId', targetKey: 'id' });
|
|
ReportChapter.hasMany(ReportChapter, { as: 'children', foreignKey: 'parentId', sourceKey: 'id' });
|
|
|
|
ReportBlock.belongsTo(ReportInstance, { foreignKey: 'instanceId', targetKey: 'id' });
|
|
ReportInstance.hasMany(ReportBlock, { foreignKey: 'instanceId', sourceKey: 'id' });
|
|
|
|
ReportBlock.belongsTo(ReportChapter, { foreignKey: 'chapterId', targetKey: 'id' });
|
|
ReportChapter.hasMany(ReportBlock, { foreignKey: 'chapterId', sourceKey: 'id' });
|
|
|
|
ReportGenerationBatchItem.belongsTo(ReportInstance, { foreignKey: 'reportInstanceId', targetKey: 'id' });
|
|
ReportInstance.hasMany(ReportGenerationBatchItem, { foreignKey: 'reportInstanceId', sourceKey: 'id' });
|
|
|
|
if (PlagiarismCheckDocTypes && PlagiarismCheckFiles) {
|
|
PlagiarismCheckFiles.belongsTo(PlagiarismCheckDocTypes, { foreignKey: 'docTypeId', targetKey: 'id' });
|
|
PlagiarismCheckDocTypes.hasMany(PlagiarismCheckFiles, { foreignKey: 'docTypeId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckTasks && PlagiarismCheckFiles) {
|
|
PlagiarismCheckFiles.belongsTo(PlagiarismCheckTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PlagiarismCheckTasks.hasMany(PlagiarismCheckFiles, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckTasks && PlagiarismCheckFileBlocks) {
|
|
PlagiarismCheckFileBlocks.belongsTo(PlagiarismCheckTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PlagiarismCheckTasks.hasMany(PlagiarismCheckFileBlocks, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckFiles && PlagiarismCheckFileBlocks) {
|
|
PlagiarismCheckFileBlocks.belongsTo(PlagiarismCheckFiles, { foreignKey: 'fileId', targetKey: 'id' });
|
|
PlagiarismCheckFiles.hasMany(PlagiarismCheckFileBlocks, { foreignKey: 'fileId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckTasks && PlagiarismCheckMatches) {
|
|
PlagiarismCheckMatches.belongsTo(PlagiarismCheckTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PlagiarismCheckTasks.hasMany(PlagiarismCheckMatches, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckTasks && PlagiarismCheckFileSummaries) {
|
|
PlagiarismCheckFileSummaries.belongsTo(PlagiarismCheckTasks, { foreignKey: 'taskId', targetKey: 'id' });
|
|
PlagiarismCheckTasks.hasMany(PlagiarismCheckFileSummaries, { foreignKey: 'taskId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckFiles && PlagiarismCheckMatches) {
|
|
PlagiarismCheckMatches.belongsTo(PlagiarismCheckFiles, { as: 'leftFile', foreignKey: 'leftFileId', targetKey: 'id' });
|
|
PlagiarismCheckMatches.belongsTo(PlagiarismCheckFiles, { as: 'rightFile', foreignKey: 'rightFileId', targetKey: 'id' });
|
|
PlagiarismCheckFiles.hasMany(PlagiarismCheckMatches, { as: 'leftMatches', foreignKey: 'leftFileId', sourceKey: 'id' });
|
|
PlagiarismCheckFiles.hasMany(PlagiarismCheckMatches, { as: 'rightMatches', foreignKey: 'rightFileId', sourceKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckFileBlocks && PlagiarismCheckMatches) {
|
|
PlagiarismCheckMatches.belongsTo(PlagiarismCheckFileBlocks, { as: 'leftBlock', foreignKey: 'leftBlockId', targetKey: 'id' });
|
|
PlagiarismCheckMatches.belongsTo(PlagiarismCheckFileBlocks, { as: 'rightBlock', foreignKey: 'rightBlockId', targetKey: 'id' });
|
|
}
|
|
|
|
if (PlagiarismCheckFiles && PlagiarismCheckFileSummaries) {
|
|
PlagiarismCheckFileSummaries.belongsTo(PlagiarismCheckFiles, { foreignKey: 'fileId', targetKey: 'id' });
|
|
PlagiarismCheckFiles.hasOne(PlagiarismCheckFileSummaries, { foreignKey: 'fileId', sourceKey: 'id' });
|
|
}
|
|
};
|
|
|