# Preface:

- This is a view model created through discussion in the PubSweet meeting in July 2018.
- These models do not use Collections and Fragments, instead they are standalone models in separate tables.
- JATS is used as a vocabulary and a source of data types, wherever appropriate.
- All models have 'created' and 'updated' dates (with the exception of AuditLog, which does not have an `updated` date)
- All models have an 'id' UUID 
- Dates are ISO-8601 strings, as PostgreSQL recommends this as date input, JATS allows it, and GraphQL can handle it.

# Models
##  Organization
|   | type  | JATS  | comment  |  
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| name | String | | |
| journals | [Journal] | | |

##  Journal
|   | type  | JATS  | comment  |  
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| journalTitle  | String  | `<journal-title>`  |   |
| manuscripts  | [Manuscript]  |   |  |
| meta | JournalMetadata | | 
|  └ meta.publisherName | String | `<publisher-name>` |

## AuditLog
| | type | JATS | comment |
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| userId | | | |
| action | String | | |
| objectId | | | |
| objectType | | | |
| meta | | | |

## Team
All groups of people should be grouped in Teams. Teams are given permissions to an object. Permissions are based on the role.

|   | type  | JATS  | comment  |  
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| members | [TeamMember] | | |  
|  &nbsp;&nbsp;└ member.user | User | | |
|  &nbsp;&nbsp;└ member.status | String | | |
|  &nbsp;&nbsp;└ member.alias | Object | | |
| role  | String  |  | e.g. 'reviewers', 'editors' |
| objectId | | | |
| objectType | | | |

### Roles
#### Default
`'submitter'`,
`'author'`,
`'reviewer'`,
`'admin'`
#### Specialized examples
`'deputyEditor'`, `'handlingEditor'`, `'seniorEditor'`, `'suggestedReviewer'`, `'opposedReviewer'` 

## User
|   | type  | JATS  | comment  |  
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| identities | | | |
| &nbsp;&nbsp;└ local | | | local identity (not from ORCID, etc.)|
| &nbsp;&nbsp;&nbsp;&nbsp;└ local.email | String | | |
| &nbsp;&nbsp;&nbsp;&nbsp;└ local.password | Hash | | |
| &nbsp;&nbsp;&nbsp;&nbsp;└ local.name | String or Object| | |
| &nbsp;&nbsp;&nbsp;&nbsp;└ local.[] | | | Profile extensions |
| &nbsp;&nbsp;└ [] | | | other identities|
| defaultIdentity | | | Ex. 'local' |

##  Manuscript
|   | type  | JATS  | comment  |  
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| manuscriptVersions  | [ManuscriptVersion]  | | |
| files | [File]  | `<graphic>`, `<media>`,`<supplementary-material>` | |
| teams | [Team] | | |
| reviews | [Review] | | |
| status | String  |  | e.g. `initial` or `QA`  |
| formState | String  |  | persists serialized form state as JSON |
| decision  | String | | |
| meta  | ManuscriptMetadata  | | |
|  └ meta.articleType | String | `@article-type` | |
|  └ meta.notes | [Note] | `<notes>` | |
|  &nbsp;&nbsp;└ note.notesType | String | `@notes-type` | |
|  &nbsp;&nbsp;└ note.content | String | | |
|  └ meta.articleIds | [ArticleId] | `<article-id>` | |
|  &nbsp;&nbsp;└ articleId.pubIdType | String | `@pub-id-type` | doi, pmid, etc. |
|  &nbsp;&nbsp;└ articleId.id | String | | |
|  └ meta.title | String | `<title>` | |
|  └ meta.abstract | String | `<abstract>` | |
|  └ meta.subjects | [String] | `<subject>` | |
|  └meta.history | [MetaDate] | `<history><date>`| |
|  &nbsp;&nbsp;└&nbsp;metaDate.type | String | `@date-type`| epub, ppub, etc. |
|  &nbsp;&nbsp;└&nbsp;metaDate.date | Date | `@iso-8601-date` | epub, ppub, etc. |
|  └meta.publicationDates | [MetaDate] | `<pub-date>`| |
|  &nbsp;&nbsp;└&nbsp;metaDate.type | String | `@pub-type`| epub, ppub, etc. |
|  &nbsp;&nbsp;└&nbsp;metaDate.date | Date | `@iso-8601-date`| date |

## ManuscriptVersion

Manuscript version is a snapshot copy of a manuscript, whenever the manuscript is changed in such a way that a new version should be created and the previous recorded as history.

## File
| | type | JATS | comment |
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| type | String | `<fig>`, `<supplementary-material>`, `<table-wrap>` | e.g. 'figure', 'supplementary', 'table' |
| label | String | `<label>` | e.g. 'F1', 'Fig 1', 'S1' |
| filename | String | `<media>`, `<graphic>` | |
| url | String | `@xlink:href` | |
| mimeType | String | `@mime-type`, `@mime-subtype` | e.g. 'image/jpeg', 'application/zip' |
| size | Number | | |

## Review
| | type  | JATS   | comment |
|---|---|---|---|
| id | UUID | | |
| created | Date | | |
| updated | Date | | |
| comments | [Comment] | | |
|  &nbsp;&nbsp;└ comment.type | String | | |
|  &nbsp;&nbsp;└ comment.content | String | | |
|  &nbsp;&nbsp;└ files | [File] | | |
| recommendation | String| | |
| open | Boolean | | |
| user | | | |