-
Notifications
You must be signed in to change notification settings - Fork 78
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 #3518 from LiteFarmOrg/LF-4471/Add_or_update_model…
…s_for_animal_movement_task LF-4471: Add or update models for animal movement task
- Loading branch information
Showing
9 changed files
with
327 additions
and
2 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
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,42 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
import Model from './baseFormatModel.js'; | ||
|
||
class AnimalMovementPurpose extends Model { | ||
static get tableName() { | ||
return 'animal_movement_purpose'; | ||
} | ||
|
||
static get idColumn() { | ||
return 'id'; | ||
} | ||
|
||
// Optional JSON schema. This is not the database schema! Nothing is generated | ||
// based on this. This is only used for validation. Whenever a model instance | ||
// is created it is checked against this schema. http://json-schema.org/. | ||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: ['key'], | ||
properties: { | ||
id: { type: 'integer' }, | ||
key: { type: 'string' }, | ||
}, | ||
additionalProperties: false, | ||
}; | ||
} | ||
} | ||
|
||
export default AnimalMovementPurpose; |
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,65 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Model from './baseFormatModel.js'; | ||
import TaskModel from './taskModel.js'; | ||
import AnimalMovementTaskPurposeRelationshipModel from './animalMovementTaskPurposeRelationshipModel.js'; | ||
|
||
class AnimalMovementTask extends Model { | ||
static get tableName() { | ||
return 'animal_movement_task'; | ||
} | ||
|
||
static get idColumn() { | ||
return 'task_id'; | ||
} | ||
|
||
// Optional JSON schema. This is not the database schema! Nothing is generated | ||
// based on this. This is only used for validation. Whenever a model instance | ||
// is created it is checked against this schema. http://json-schema.org/. | ||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: [], | ||
properties: { | ||
task_id: { type: 'integer' }, | ||
}, | ||
additionalProperties: false, | ||
}; | ||
} | ||
|
||
static get relationMappings() { | ||
return { | ||
task: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: TaskModel, | ||
join: { | ||
from: 'animal_movement_task.task_id', | ||
to: 'task.task_id', | ||
}, | ||
}, | ||
purpose_relationships: { | ||
relation: Model.HasManyRelation, | ||
modelClass: AnimalMovementTaskPurposeRelationshipModel, | ||
join: { | ||
from: 'animal_movement_task.task_id', | ||
to: 'animal_movement_task_purpose_relationship.task_id', | ||
}, | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
export default AnimalMovementTask; |
44 changes: 44 additions & 0 deletions
44
packages/api/src/models/animalMovementTaskPurposeRelationshipModel.js
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,44 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Model from './baseFormatModel.js'; | ||
|
||
class AnimalMovementTaskPurposeRelationship extends Model { | ||
static get tableName() { | ||
return 'animal_movement_task_purpose_relationship'; | ||
} | ||
|
||
static get idColumn() { | ||
return ['task_id', 'purpose_id']; | ||
} | ||
|
||
// Optional JSON schema. This is not the database schema! Nothing is generated | ||
// based on this. This is only used for validation. Whenever a model instance | ||
// is created it is checked against this schema. http://json-schema.org/. | ||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: ['task_id', 'purpose_id'], | ||
properties: { | ||
task_id: { type: 'integer' }, | ||
purpose_id: { type: 'integer' }, | ||
other_purpose: { type: ['string', 'null'], minLength: 1, maxLength: 255 }, | ||
}, | ||
additionalProperties: false, | ||
}; | ||
} | ||
} | ||
|
||
export default AnimalMovementTaskPurposeRelationship; |
43 changes: 43 additions & 0 deletions
43
packages/api/src/models/taskAnimalBatchRelationshipModel.js
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,43 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Model from './baseFormatModel.js'; | ||
|
||
class TaskAnimalBatchRelationshipModel extends Model { | ||
static get tableName() { | ||
return 'task_animal_batch_relationship'; | ||
} | ||
|
||
static get idColumn() { | ||
return ['task_id', 'animal_batch_id']; | ||
} | ||
|
||
// Optional JSON schema. This is not the database schema! Nothing is generated | ||
// based on this. This is only used for validation. Whenever a model instance | ||
// is created it is checked against this schema. http://json-schema.org/. | ||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: ['task_id', 'animal_batch_id'], | ||
properties: { | ||
task_id: { type: 'integer' }, | ||
animal_batch_id: { type: 'integer' }, | ||
}, | ||
additionalProperties: false, | ||
}; | ||
} | ||
} | ||
|
||
export default TaskAnimalBatchRelationshipModel; |
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,43 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Model from './baseFormatModel.js'; | ||
|
||
class TaskAnimalRelationshipModel extends Model { | ||
static get tableName() { | ||
return 'task_animal_relationship'; | ||
} | ||
|
||
static get idColumn() { | ||
return ['task_id', 'animal_id']; | ||
} | ||
|
||
// Optional JSON schema. This is not the database schema! Nothing is generated | ||
// based on this. This is only used for validation. Whenever a model instance | ||
// is created it is checked against this schema. http://json-schema.org/. | ||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: ['task_id', 'animal_id'], | ||
properties: { | ||
task_id: { type: 'integer' }, | ||
animal_id: { type: 'integer' }, | ||
}, | ||
additionalProperties: false, | ||
}; | ||
} | ||
} | ||
|
||
export default TaskAnimalRelationshipModel; |
Oops, something went wrong.