Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
C4Ai_DR-P
public-service-provider
Commits
9581c0dd
Commit
9581c0dd
authored
Jul 02, 2020
by
Mahdi Sellami
Browse files
-Added MongoDB -Implemented add Case application logic
parent
6b78c0de
Changes
7
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
9581c0dd
...
...
@@ -21,3 +21,9 @@ http.createServer(app).listen(serverPort, function () {
console
.
log
(
'
Swagger-ui is available on http://localhost:%d/docs
'
,
serverPort
);
});
//Set up mongoose connection
var
mongoose
=
require
(
'
mongoose
'
);
var
mongoDB
=
'
mongodb://127.0.0.1
'
;
mongoose
.
connect
(
mongoDB
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
});
var
db
=
mongoose
.
connection
;
db
.
on
(
'
error
'
,
console
.
error
.
bind
(
console
,
'
MongoDB connection error:
'
));
models/application.js
0 → 100644
View file @
9581c0dd
//Require Mongoose
var
mongoose
=
require
(
'
mongoose
'
);
//Define a schema
var
Schema
=
mongoose
.
Schema
;
var
ApplicationSchema
=
new
Schema
({
verfahrensId
:
String
,
leikaId
:
String
,
responsibleAuthority
:
String
,
statusId
:
String
,
statusDescription
:
String
,
statusLastChangeDate
:
String
,
decisionDate
:
String
,
decisionJustification
:
String
,
//applicant : {type: Schema.Types.ObjectId, ref: 'Person'}
});
//Export function to create "Application" model class
module
.
exports
=
Application
=
mongoose
.
model
(
'
Application
'
,
ApplicationSchema
);
\ No newline at end of file
models/person.js
0 → 100644
View file @
9581c0dd
//Require Mongoose
var
mongoose
=
require
(
'
mongoose
'
);
//Define a schema
var
Schema
=
mongoose
.
Schema
;
var
PersonSchema
=
new
Schema
({
personId
:
String
,
prename
:
String
,
surname
:
String
,
email
:
String
,
//address : {type: Schema.Types.ObjectId, ref: 'PersonAdress'}
});
//Export function to create "Person" model class
module
.
exports
=
mongoose
.
model
(
'
Person
'
,
PersonSchema
);
\ No newline at end of file
models/personAdress.js
0 → 100644
View file @
9581c0dd
//Require Mongoose
var
mongoose
=
require
(
'
mongoose
'
);
//Define a schema
var
Schema
=
mongoose
.
Schema
;
var
PersonAdressSchema
=
new
Schema
({
street
:
String
,
houseno
:
String
,
zip
:
String
,
city
:
String
,
country
:
String
});
//Export function to create "PersonAdress" model class
module
.
exports
=
mongoose
.
model
(
'
PersonAdress
'
,
PersonAdressSchema
);
\ No newline at end of file
package.json
View file @
9581c0dd
...
...
@@ -15,6 +15,7 @@
"dependencies"
:
{
"
connect
"
:
"
^3.2.0
"
,
"
js-yaml
"
:
"
^3.3.0
"
,
"
mongoose
"
:
"
^5.9.21
"
,
"
oas3-tools
"
:
"
^2.0.2
"
}
}
service/ApplicationService.js
View file @
9581c0dd
'
use strict
'
;
const
Application
=
require
(
'
../models/application
'
);
/**
* Submit a new application including the application documents for an administration case
...
...
@@ -9,50 +9,8 @@
**/
exports
.
postCaseApplication
=
function
(
body
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
examples
=
{};
examples
[
'
application/json
'
]
=
{
"
dataObjects
"
:
[
{
"
dataObjectId
"
:
"
dataObjectId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
title
"
:
"
title
"
,
"
type
"
:
"
type
"
,
"
content
"
:
{
}
},
{
"
dataObjectId
"
:
"
dataObjectId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
title
"
:
"
title
"
,
"
type
"
:
"
type
"
,
"
content
"
:
{
}
}
],
"
statusDescription
"
:
"
statusDescription
"
,
"
statusLastChangeDate
"
:
"
2000-01-23T04:56:07.000+00:00
"
,
"
statusId
"
:
"
statusId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
decisionJustification
"
:
"
decisionJustification
"
,
"
responsibleAuthority
"
:
"
responsibleAuthority
"
,
"
decisionDate
"
:
"
2000-01-23T04:56:07.000+00:00
"
,
"
applicant
"
:
{
"
address
"
:
{
"
zip
"
:
"
zip
"
,
"
country
"
:
"
country
"
,
"
city
"
:
"
city
"
,
"
street
"
:
"
street
"
,
"
houseno
"
:
"
houseno
"
},
"
surname
"
:
"
surname
"
,
"
personId
"
:
"
personId
"
,
"
prename
"
:
"
prename
"
,
"
email
"
:
"
email
"
}
};
if
(
Object
.
keys
(
examples
).
length
>
0
)
{
resolve
(
examples
[
Object
.
keys
(
examples
)[
0
]]);
}
else
{
resolve
();
}
const
applicationRecord
=
Application
.
create
(
body
);
resolve
(
applicationRecord
);
});
}
service/StatusService.js
View file @
9581c0dd
'
use strict
'
;
const
Application
=
require
(
'
../models/application
'
);
/**
...
...
@@ -9,50 +10,8 @@
**/
exports
.
getCaseByVerfahrensId
=
function
(
verfahrensId
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
examples
=
{};
examples
[
'
application/json
'
]
=
{
"
dataObjects
"
:
[
{
"
dataObjectId
"
:
"
dataObjectId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
title
"
:
"
title
"
,
"
type
"
:
"
type
"
,
"
content
"
:
{
}
},
{
"
dataObjectId
"
:
"
dataObjectId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
title
"
:
"
title
"
,
"
type
"
:
"
type
"
,
"
content
"
:
{
}
}
],
"
statusDescription
"
:
"
statusDescription
"
,
"
statusLastChangeDate
"
:
"
2000-01-23T04:56:07.000+00:00
"
,
"
statusId
"
:
"
statusId
"
,
"
leikaId
"
:
"
leikaId
"
,
"
verfahrensId
"
:
"
verfahrensId
"
,
"
decisionJustification
"
:
"
decisionJustification
"
,
"
responsibleAuthority
"
:
"
responsibleAuthority
"
,
"
decisionDate
"
:
"
2000-01-23T04:56:07.000+00:00
"
,
"
applicant
"
:
{
"
address
"
:
{
"
zip
"
:
"
zip
"
,
"
country
"
:
"
country
"
,
"
city
"
:
"
city
"
,
"
street
"
:
"
street
"
,
"
houseno
"
:
"
houseno
"
},
"
surname
"
:
"
surname
"
,
"
personId
"
:
"
personId
"
,
"
prename
"
:
"
prename
"
,
"
email
"
:
"
email
"
}
};
if
(
Object
.
keys
(
examples
).
length
>
0
)
{
resolve
(
examples
[
Object
.
keys
(
examples
)[
0
]]);
}
else
{
resolve
();
}
const
applicationRecord
=
Application
.
findById
(
verfahrensId
);
resolve
(
applicationRecord
);
});
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment