Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaPolit committed Jul 19, 2017
2 parents 91397e0 + 3ed2545 commit 18b979a
Show file tree
Hide file tree
Showing 40 changed files with 872 additions and 167 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PR check list:
- [ ] End-to-end test
- [ ] Pass code linter to client and server
- [ ] Update READ.me ?
- [ ] Update API documentation ?

QA check list:

Expand Down
1 change: 1 addition & 0 deletions app/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export default (app, server) => {
require('./settings/routes.js')(app);
require('./i18n/routes.js')(app);
require('./attachments/routes.js')(app);
require('./swagger/swaggerconfig.js')(app);
};
28 changes: 28 additions & 0 deletions app/api/attachments/routes.ref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @swagger
* /attachments/download:
* get:
* tags:
* - attachments
* description: Returns the attachments for a document
* parameters:
* - name: _id
* description: _id of the attachment requested
* in: query
* required: true
* type: string
* - name: file
* description: file name of the attachment requested
* in: query
* required: true
* type: string
* responses:
* 200:
* description: The original file
* schema:
* type: file
* 500:
* description: Server error
* schema:
* $ref: '#/definitions/Error'
*/
90 changes: 89 additions & 1 deletion app/api/entities/entitiesModel.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,97 @@
import mongoose from 'mongoose';
import instanceModel from 'api/odm';

/**
* @swagger
* definition:
* Entity:
* properties:
* _id:
* type: string
* description: A unique ID for this object in the database.
* sharedId:
* type: string
* description: A shared ID with the other copies of this object for the different languages.
* language:
* type: string
* type:
* type: string
* title:
* type: string
* template:
* type: string
* description: The template _id
* user:
* type: string
* description: The user _id
* file:
* description: Only for documents
* type: object
* properties:
* originalname:
* type: string
* filename:
* type: string
* mimetype:
* type: string
* size:
* type: integer
* icon:
* type: object
* properties:
* _id:
* type: string
* label:
* type: string
* type:
* type: string
* toc:
* type: array
* items:
* type: object
* properties:
* label:
* type: string
* indentation:
* type: integer
* range:
* type: object
* properties:
* start:
* type: integer
* end:
* type: integer
* attachments:
* type: array
* items:
* type: object
* properties:
* originalname:
* type: string
* filename:
* type: string
* mimetype:
* type: string
* size:
* type: integer
* creationDate:
* type: integer
* processed:
* type: boolean
* uploaded:
* type: boolean
* published:
* type: boolean
* metadata:
* type: object
* description: Changes depending on the template
* pdfInfo:
* type: object
*/

const entitySchema = new mongoose.Schema({
language: String,
sharedId: String,
sharedId: {type: String, index: true},
type: String,
title: String,
template: {type: mongoose.Schema.Types.ObjectId, ref: 'templates'},
Expand Down
146 changes: 146 additions & 0 deletions app/api/entities/routes.ref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
* @swagger
* /entities:
* post:
* tags:
* - entities
* description: Creates an entity
* parameters:
* - name: _id
* description: sharedId of the entity
* in: body
* required: true
* schema:
* $ref: '#/definitions/Entity'
* responses:
* 200:
* description: The entity created
* schema:
* $ref: '#/definitions/Entity'
* 401:
* description: Unauthorized
* schema:
* $ref: '#/definitions/Error'
*/

/**
* @swagger
* /entities/count_by_template:
* get:
* tags:
* - entities
* description: Returns the number of entities using the template
* parameters:
* - name: templateId
* description: _id of the template
* in: query
* required: true
* type: string
* responses:
* 200:
* description: The number of entities using the template in all the languages
* schema:
* type: integer
*/

/**
* @swagger
* /entities/uploads:
* get:
* deprecated: true
* tags:
* - entities
* description: Returns the entities uploaded by the current user
* responses:
* 200:
* description: An array with entities
* schema:
* type: object
* properties:
* rows:
* type: array
* items:
* $ref: '#/definitions/Entity'
*/

/**
* @swagger
* /entities:
* get:
* tags:
* - entities
* description: Returns an entity
* parameters:
* - name: _id
* description: sharedId of the entity
* in: query
* required: true
* type: string
* responses:
* 200:
* description: An object with rows containning the document
* schema:
* type: object
* properties:
* rows:
* type: array
* items:
* $ref: '#/definitions/Entity'
* 404:
* description: Not found
* schema:
* type: object
*/

/**
* @swagger
* /entities:
* delete:
* tags:
* - entities
* description: Deletes an entity
* parameters:
* - name: sharedId
* description: sharedId of the entity
* in: query
* required: true
* type: string
* responses:
* 200:
* description: An array with containning the deleted entities, one for each different language in the instance
* schema:
* type: array
* items:
* $ref: '#/definitions/Entity'
* 500:
* description: Server error
* schema:
* type: object
*/

/**
* @swagger
* /entities/multiple:
* delete:
* tags:
* - entities
* description: Deletes multiple entities
* parameters:
* - name: sharedIds
* description: URL encoded array of the sharedId of the entities
* in: query
* required: true
* type: string
* example: '["SHARED_ID_ONE","SHARED_ID_TWO"]'
* responses:
* 200:
* description: An array with containning the deleted entities, one for each different language in the instance
* schema:
* type: array
* items:
* $ref: '#/definitions/Entity'
* 500:
* description: Server error
* schema:
* type: object
*/
4 changes: 2 additions & 2 deletions app/api/references/connectionsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import mongoose from 'mongoose';
import instanceModel from 'api/odm';

const connectionSchema = new mongoose.Schema({
sourceDocument: String,
sourceDocument: {type: String, index: true},
sourceProperty: String,
sourceType: String,
relationType: String,
targetDocument: String,
targetDocument: {type: String, index: true},
sourceRange: {
start: Number,
end: Number,
Expand Down
1 change: 0 additions & 1 deletion app/api/references/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default {
g.templates = g.templates.map(excludeRefs);
});
}

return groupedReferences;
});
},
Expand Down
19 changes: 11 additions & 8 deletions app/api/search/documentQueryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default function () {
size: 30,
query: {
bool: {
must: [{match: {published: true}}]
must: [],
filter: [
{term: {published: true}}
]
}
},
sort: [],
Expand Down Expand Up @@ -49,9 +52,9 @@ export default function () {
},

includeUnpublished() {
const matchPulished = baseQuery.query.bool.must.find(i => i.match && i.match.published);
const matchPulished = baseQuery.query.bool.filter.find(i => i.term && i.term.published);
if (matchPulished) {
baseQuery.query.bool.must.splice(baseQuery.query.bool.must.indexOf(matchPulished), 1);
baseQuery.query.bool.filter.splice(baseQuery.query.bool.filter.indexOf(matchPulished), 1);
}
return this;
},
Expand Down Expand Up @@ -117,14 +120,14 @@ export default function () {
},

language(language) {
let match = {match: {language: language}};
baseQuery.query.bool.must.push(match);
let match = {term: {language: language}};
baseQuery.query.bool.filter.push(match);
aggregations.types.aggregations.filtered.filter.bool.must.push(match);
return this;
},

unpublished() {
baseQuery.query.bool.must[0].match.published = false;
baseQuery.query.bool.filter[0].term.published = false;
baseQuery.aggregations.all.aggregations.types.aggregations.filtered.filter.bool.must[0].match.published = false;
return this;
},
Expand Down Expand Up @@ -399,7 +402,7 @@ export default function () {
{terms: {template: _templates}}
]
}};
baseQuery.query.bool.must.push(match);
baseQuery.query.bool.filter.push(match);
return this;
}

Expand All @@ -420,7 +423,7 @@ export default function () {
}
if (_ids.length) {
let match = {terms: {'sharedId.raw': _ids}};
baseQuery.query.bool.must.push(match);
baseQuery.query.bool.filter.push(match);
}
return this;
},
Expand Down
Loading

0 comments on commit 18b979a

Please sign in to comment.