Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
keeleliin-wrapper
Commits
813413d6
Commit
813413d6
authored
Aug 14, 2015
by
taivo
Browse files
KEEL-78
parent
8c197676
Changes
4
Hide whitespace changes
Inline
Side-by-side
config_dist.js
View file @
813413d6
...
...
@@ -30,7 +30,9 @@ var config = require('./wrapper_configs/global');
}
});*/
//config.wrapper = config.availableWappers.<WRAPPERKEY>; //eg config.wrapper = config.availableWappers.TOKENIZER;
//config.serverUrl = 'http://dev.bitweb.ee';
//config.wrapper = config.availableWrappers.<WRAPPERKEY>; //eg config.wrapper = config.availableWrappers.TOKENIZER;
//config.wrapper.command.commandTemplate = 'python /home/priit/Programs/KEELELIIN/pyutil/tokenizer.py -i [data] -o [outputPath1]';
//config.fs.storagePath = "/home/priit/wrapper";
//config.fs.tmpPath = "/tmp/wrapper/";
...
...
controllers/api/v1/service.js
View file @
813413d6
...
...
@@ -4,6 +4,7 @@ var router = express.Router();
var
ServiceRequest
=
require
(
__base
+
'
/src/model/serviceRequest
'
);
var
wrapperService
=
require
(
__base
+
'
/src/service/wrapperService
'
);
var
fs
=
require
(
'
fs
'
);
var
installService
=
require
(
__base
+
'
/src/service/integration/installService
'
);
router
.
post
(
'
/
'
,
function
(
req
,
res
)
{
...
...
@@ -68,4 +69,10 @@ router.get('/:sessionId/kill', function(req, res) {
});
});
router
.
get
(
'
/install/external
'
,
function
(
req
,
res
)
{
installService
.
install
(
function
(
err
,
result
)
{
return
res
.
send
({
errors
:
err
,
data
:
result
});
});
});
module
.
exports
=
router
;
src/service/integration/installService.js
0 → 100644
View file @
813413d6
var
config
=
require
(
'
../../../config
'
);
var
request
=
require
(
'
request
'
);
var
logger
=
require
(
'
log4js
'
).
getLogger
(
'
installService
'
);
var
InstallService
=
function
()
{
var
self
=
this
;
this
.
install
=
function
(
cb
)
{
var
wrapper
=
config
.
wrapper
;
request
.
post
({
url
:
self
.
_composeInstallUrl
(
config
.
integration
.
installUrl
,
wrapper
.
id
,
self
.
_getApiKey
()),
json
:
self
.
getConfiguration
()
},
function
(
error
,
response
,
body
)
{
if
(
error
)
{
logger
.
error
(
error
);
return
cb
(
error
);
}
var
data
=
{
errors
:
null
,
data
:
null
};
if
(
body
!=
undefined
)
{
if
(
body
.
errors
)
{
data
.
errors
=
body
.
errors
;
}
if
(
body
.
data
)
{
data
.
data
=
body
.
data
;
}
}
logger
.
debug
(
data
);
return
cb
(
data
.
errors
,
data
.
data
);
});
};
this
.
getConfiguration
=
function
()
{
var
configuration
=
{};
var
wrapper
=
config
.
wrapper
;
if
(
wrapper
.
requestConf
)
{
configuration
.
sid
=
wrapper
.
id
;
configuration
.
name
=
wrapper
.
title
;
configuration
.
description
=
wrapper
.
description
;
configuration
.
url
=
self
.
_composeUrl
(
config
.
serverUrl
,
wrapper
.
port
);
configuration
.
inputTypes
=
[];
configuration
.
outputTypes
=
[];
if
(
wrapper
.
requestConf
)
{
var
requestFiles
=
wrapper
.
requestConf
.
requestFiles
;
for
(
var
key
in
requestFiles
)
{
if
(
requestFiles
.
hasOwnProperty
(
key
))
{
var
fileConfig
=
requestFiles
[
key
];
configuration
.
inputTypes
.
push
({
key
:
key
,
type
:
fileConfig
.
type
,
sizeLimit
:
fileConfig
.
sizeLimit
,
sizeUnit
:
fileConfig
.
sizeUnit
,
isList
:
fileConfig
.
isList
});
}
}
}
if
(
wrapper
.
outputTypes
)
{
configuration
.
outputTypes
=
wrapper
.
outputTypes
;
}
configuration
.
parameters
=
[];
var
requestBodyTemplate
=
wrapper
.
requestConf
.
requestBodyTemplate
;
for
(
var
property
in
requestBodyTemplate
){
if
(
requestBodyTemplate
.
hasOwnProperty
(
property
))
{
if
(
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
usageType
!=
config
.
paramUsageTypes
.
META
)
{
configuration
.
parameters
.
push
({
key
:
property
,
type
:
wrapper
.
requestConf
.
requestBodyParamsMappings
[
property
].
type
,
value
:
requestBodyTemplate
[
property
]
});
}
}
}
}
return
configuration
;
};
this
.
_composeUrl
=
function
(
serverUrl
,
port
)
{
return
serverUrl
+
(
port
?
'
:
'
+
port
:
''
)
+
'
/api/v1/
'
;
};
this
.
_composeInstallUrl
=
function
(
installUrl
,
serviceId
,
apiKey
)
{
return
installUrl
+
'
/sid/
'
+
serviceId
+
'
/apiKey/
'
+
apiKey
;
};
// Gets API key as argv, i.e., "apiKey=somethingsomething"
this
.
_getApiKey
=
function
()
{
var
apiKey
=
''
;
if
(
process
.
argv
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
process
.
argv
.
length
;
i
++
)
{
var
arg
=
process
.
argv
[
i
];
var
s
=
'
apiKey
'
;
if
(
arg
.
indexOf
(
s
)
>
-
1
)
{
apiKey
=
arg
.
substring
(
s
.
length
+
1
);
}
}
}
return
apiKey
;
}
};
module
.
exports
=
new
InstallService
();
\ No newline at end of file
wrapper_configs/global.js
View file @
813413d6
...
...
@@ -6,6 +6,8 @@ config.redis = {
port
:
6379
};
config
.
serverUrl
=
'
http://dev.bitweb.ee
'
;
config
.
fs
=
{
storagePath
:
"
/var/www/bitweb.ee/keeleliin.bitweb.ee/wrapper/tmp
"
,
tmpPath
:
"
/tmp/wrapper/
"
...
...
@@ -18,13 +20,19 @@ config.paramUsageTypes = {
};
config
.
wrapper
=
{
id
:
null
,
// unique service identifier
title
:
null
,
description
:
''
,
port
:
null
,
class
:
null
,
command
:
null
,
requestConf
:
null
};
config
.
integration
=
{
installUrl
:
'
http://localhost:3000/api/v1/service/install
'
};
config
.
log4js
=
{
appenders
:
[
{
type
:
'
console
'
,
...
...
@@ -116,6 +124,7 @@ config.log4js = {
var
simpleCommandRequest
=
{
requestBodyTemplate
:
{
isAsync
:
null
//key: null
},
requestBodyParamsMappings
:
{
isAsync
:
{
...
...
@@ -127,14 +136,37 @@ var simpleCommandRequest = {
allowEmpty
:
false
,
validator
:
function
(
value
,
request
){
return
true
;
}
}
/**
* , key: {
type: 'text',
usageType: config.paramUsageTypes.STRING,
filter: function(value){
return value == 1;
},
required: true,
allowEmpty: false,
validator: function(value, request){ return true; }
}
*/
},
requestFiles
:
{
content
:
null
content
:
{
type
:
'
text
'
,
sizeLimit
:
0
,
sizeUnit
:
'
byte
'
,
isList
:
false
}
},
staticParams
:
{
sessionMaxLifetime
:
600
,
isAsync
:
undefined
}
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}
]
};
config
.
availableCommands
=
{
...
...
@@ -167,10 +199,11 @@ config.availableCommands = {
}
};
config
.
availableWappers
=
{
config
.
availableW
r
appers
=
{
LAUSESTAJA
:
{
title
:
'
Lausestaja
'
,
description
:
''
,
id
:
'
lau
'
,
port
:
3001
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -179,6 +212,7 @@ config.availableWappers = {
},
MORFANALYSAATOR
:
{
title
:
'
Morfoloogiline analüüs
'
,
description
:
''
,
id
:
'
moa
'
,
port
:
3002
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -187,6 +221,7 @@ config.availableWappers = {
},
OSALAUSESTAJA
:
{
title
:
'
Osalausestaja
'
,
description
:
''
,
id
:
'
osl
'
,
port
:
3003
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -195,6 +230,7 @@ config.availableWappers = {
},
MORFYHESTAJA
:
{
title
:
'
Morfoloogiline ühestamine (kitsenduste grammatika)
'
,
description
:
''
,
id
:
'
moy
'
,
port
:
3004
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -203,6 +239,7 @@ config.availableWappers = {
},
PIND_SYN
:
{
title
:
'
Pindsüntaktiline analüüs
'
,
description
:
''
,
id
:
'
pia
'
,
port
:
3005
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -211,6 +248,7 @@ config.availableWappers = {
},
S6LT_SYN
:
{
title
:
'
Sõltuvussüntaktiline analüüs (ja järeltöötlus)
'
,
description
:
''
,
id
:
'
s6a
'
,
port
:
3006
,
class
:
'
simpleLocalCommand
'
,
...
...
@@ -220,35 +258,49 @@ config.availableWappers = {
ARCHIVE_EXTRACTOR
:
{
title
:
'
Arhiivi lahtipakkija
'
,
description
:
''
,
id
:
'
uzip
'
,
port
:
3007
,
class
:
'
archiveExtractor
'
,
requestConf
:
{
requestBodyTemplate
:
{
//
isAsync: null
isAsync
:
null
},
requestBodyParamsMappings
:
{
//isAsync: {
// usageType: config.paramUsageTypes.META,
// filter: function(value){
// return value == 1;
// },
// required: true,
// allowEmpty: false,
// validator: function(value, request){ return true; }
//}
isAsync
:
{
type
:
'
text
'
,
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
){
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
){
return
true
;
}
}
},
requestFiles
:
{
content
:
null
content
:
{
type
:
'
zip
'
,
sizeLimit
:
0
,
sizeUnit
:
'
byte
'
,
isList
:
false
}
},
staticParams
:
{
sessionMaxLifetime
:
600
,
isAsync
:
0
}
}
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}
]
},
TOKENIZER
:
{
title
:
'
Sõnestaja pipe
'
,
description
:
''
,
id
:
'
tok
'
,
port
:
3008
,
class
:
'
inputOutputLocalCommand
'
,
...
...
@@ -261,7 +313,52 @@ config.availableWappers = {
port
:
3009
,
class
:
'
simpleLocalCommand
'
,
command
:
config
.
availableCommands
.
CONCAT
,
requestConf
:
simpleCommandRequest
requestConf
:
{
requestBodyTemplate
:
{
isAsync
:
null
,
key
:
null
},
requestBodyParamsMappings
:
{
isAsync
:
{
usageType
:
config
.
paramUsageTypes
.
META
,
filter
:
function
(
value
)
{
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
)
{
return
true
;
}
},
key
:
{
type
:
'
text
'
,
usageType
:
config
.
paramUsageTypes
.
STRING
,
filter
:
function
(
value
){
return
value
==
1
;
},
required
:
true
,
allowEmpty
:
false
,
validator
:
function
(
value
,
request
){
return
true
;
}
}
},
requestFiles
:
{
content
:
{
type
:
'
text
'
,
sizeLimit
:
0
,
sizeUnit
:
'
byte
'
,
isList
:
true
}
},
staticParams
:
{
sessionMaxLifetime
:
600
,
isAsync
:
undefined
},
outputTypes
:
[
{
type
:
'
text
'
,
key
:
'
output
'
}
]
}
},
MORPH_TAGGER
:
{
title
:
'
Morfoloogiline ühestaja pipe
'
,
...
...
Write
Preview
Markdown
is supported
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