Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Motion Bank API
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Motion Bank
Services
Motion Bank API
Commits
0aa613d6
Commit
0aa613d6
authored
Apr 11, 2019
by
Anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old migrate and import scripts
parent
892278fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
166 deletions
+0
-166
bin/import.js
bin/import.js
+0
-87
bin/migrate.js
bin/migrate.js
+0
-79
No files found.
bin/import.js
deleted
100755 → 0
View file @
892278fe
const
Acl
=
require
(
'
acl
'
),
Backend
=
Acl
.
mongodbBackend
,
MongoClient
=
require
(
'
mongodb
'
).
MongoClient
,
path
=
require
(
'
path
'
),
fs
=
require
(
'
mz/fs
'
),
{
MongoDB
}
=
require
(
'
mbjs-persistence
'
),
{
ObjectUtil
}
=
require
(
'
mbjs-utils
'
),
config
=
require
(
'
config
'
)
const
folder
=
process
.
env
.
FOLDER
,
authorUUID
=
process
.
env
.
AUTHOR_UUID
,
authorName
=
process
.
env
.
AUTHOR_NAME
if
(
!
folder
)
throw
new
Error
(
'
no input folder specified
'
)
const
updateAuthor
=
entry
=>
{
if
(
!
entry
.
author
)
entry
.
author
=
{}
if
(
typeof
entry
.
author
===
'
string
'
)
entry
.
author
=
{
id
:
entry
.
author
}
if
(
authorName
)
entry
.
author
.
name
=
authorName
if
(
authorUUID
)
entry
.
author
.
id
=
authorUUID
return
entry
}
const
proc
=
async
function
(
folder
)
{
const
mapsClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
maps
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
mapsClient
.
connect
()
const
maps
=
await
fs
.
readdir
(
path
.
join
(
folder
,
'
maps
'
))
for
(
let
m
of
maps
)
{
if
(
m
[
0
]
===
'
.
'
)
continue
const
file
=
await
fs
.
readFile
(
path
.
join
(
folder
,
'
maps
'
,
m
))
const
entry
=
JSON
.
parse
(
file
)
const
existing
=
await
mapsClient
.
get
(
entry
.
uuid
)
if
(
existing
)
await
mapsClient
.
update
(
entry
.
uuid
,
updateAuthor
(
entry
))
else
await
mapsClient
.
create
(
updateAuthor
(
entry
))
}
const
annoClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
annotations
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
annoClient
.
connect
()
const
annos
=
await
fs
.
readdir
(
path
.
join
(
folder
,
'
annotations
'
))
for
(
let
a
of
annos
)
{
if
(
a
[
0
]
===
'
.
'
)
continue
const
file
=
await
fs
.
readFile
(
path
.
join
(
folder
,
'
annotations
'
,
a
))
const
entry
=
JSON
.
parse
(
file
)
const
existing
=
await
annoClient
.
get
(
entry
.
uuid
)
if
(
existing
)
await
annoClient
.
update
(
entry
.
uuid
,
updateAuthor
(
entry
))
else
await
annoClient
.
create
(
updateAuthor
(
entry
))
}
const
cfg
=
config
.
get
(
'
acl.mongodb
'
)
cfg
.
logger
=
console
const
db
=
await
new
Promise
((
resolve
,
reject
)
=>
{
MongoClient
.
connect
(
cfg
.
url
,
function
(
err
,
client
)
{
if
(
err
)
return
reject
(
err
)
cfg
.
logger
.
info
(
`ACL connected at
${
cfg
.
url
}
/
${
cfg
.
dbName
}
`
)
const
db
=
client
.
db
(
cfg
.
dbName
)
resolve
(
db
)
})
})
const
acl
=
new
Acl
(
new
Backend
(
db
))
const
acls
=
await
fs
.
readdir
(
path
.
join
(
folder
,
'
acl
'
))
for
(
let
a
of
acls
)
{
if
(
a
[
0
]
===
'
.
'
)
continue
const
file
=
await
fs
.
readFile
(
path
.
join
(
folder
,
'
acl
'
,
a
))
const
entry
=
JSON
.
parse
(
file
)
await
new
Promise
((
resolve
,
reject
)
=>
{
const
resource
=
a
.
replace
(
'
.json
'
,
''
)
acl
.
allow
(
entry
.
role
,
resource
,
entry
.
permissions
,
err
=>
{
if
(
err
)
reject
(
err
)
else
resolve
()
})
})
}
}
proc
(
folder
).
then
(()
=>
process
.
exit
(
0
))
bin/migrate.js
deleted
100644 → 0
View file @
892278fe
const
{
MongoDB
}
=
require
(
'
mbjs-persistence
'
),
{
ObjectUtil
,
uuid
}
=
require
(
'
mbjs-utils
'
),
config
=
require
(
'
config
'
),
{
Annotation
,
Map
}
=
require
(
'
mbjs-data-models/src/models
'
)
const
timelinePrefix
=
'
https://app.motionbank.org/piecemaker/timelines/
'
,
gridPrefix
=
'
https://app.motionbank.org/mosys/grids/
'
const
newPrefix
=
'
http://id.motionbank.org/
'
const
proc
=
async
function
()
{
console
.
log
(
'
MAPS
\n
--------------------------
\n\n
'
)
const
mapsClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
maps
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
mapsClient
.
connect
()
const
maps
=
await
mapsClient
.
find
({})
for
(
let
map
of
maps
)
{
Object
.
keys
(
map
).
forEach
(
key
=>
{
if
(
key
[
0
]
===
'
_
'
)
map
[
key
]
=
undefined
})
if
(
typeof
map
.
author
===
'
string
'
)
{
map
.
author
=
{
id
:
map
.
author
}
console
.
log
(
'
updating author to
'
,
map
.
author
)
}
const
mi
=
new
Map
(
map
)
await
mapsClient
.
update
(
mi
.
uuid
,
mi
.
toObject
(),
{})
}
console
.
log
(
'
ANNOTATIONS
\n
-------------------
\n\n
'
)
const
annoClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
annotations
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
annoClient
.
connect
()
const
annos
=
await
annoClient
.
find
({})
for
(
let
anno
of
annos
)
{
Object
.
keys
(
anno
).
forEach
(
key
=>
{
if
(
key
[
0
]
===
'
_
'
)
anno
[
key
]
=
undefined
})
if
(
typeof
anno
.
author
===
'
string
'
)
{
anno
.
author
=
{
id
:
anno
.
author
}
console
.
log
(
'
updating author to
'
,
anno
.
author
)
}
if
(
anno
.
target
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
anno
.
target
.
id
.
indexOf
(
timelinePrefix
)
===
0
)
{
anno
.
target
.
id
=
anno
.
target
.
id
.
replace
(
timelinePrefix
,
`
${
newPrefix
}
maps/`
)
console
.
log
(
'
updating timeline target to
'
,
anno
.
target
.
id
)
}
if
(
anno
.
target
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
anno
.
target
.
id
.
indexOf
(
gridPrefix
)
===
0
)
{
anno
.
target
.
id
=
anno
.
target
.
id
.
replace
(
gridPrefix
,
`
${
newPrefix
}
maps/`
)
console
.
log
(
'
updating grid target to
'
,
anno
.
target
.
id
)
}
if
(
anno
.
target
&&
anno
.
target
.
type
===
'
Video
'
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
uuid
.
isUUID
(
anno
.
target
.
id
))
{
anno
.
target
.
id
=
`
${
newPrefix
}
annotations/
${
anno
.
target
.
id
}
`
console
.
log
(
'
updating video target to
'
,
anno
.
target
.
id
)
}
if
(
anno
.
target
&&
anno
.
target
.
type
===
'
Annotation
'
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
uuid
.
isUUID
(
anno
.
target
.
id
))
{
anno
.
target
.
id
=
`
${
newPrefix
}
annotations/
${
anno
.
target
.
id
}
`
console
.
log
(
'
updating annotation target to
'
,
anno
.
target
.
id
)
}
if
(
anno
.
target
&&
anno
.
target
.
type
===
'
Timeline
'
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
uuid
.
isUUID
(
anno
.
target
.
id
))
{
anno
.
target
.
id
=
`
${
newPrefix
}
maps/
${
anno
.
target
.
id
}
`
console
.
log
(
'
updating timeline target to
'
,
anno
.
target
.
id
)
}
if
(
anno
.
target
&&
anno
.
target
.
type
===
'
2DGrid
'
&&
typeof
anno
.
target
.
id
===
'
string
'
&&
uuid
.
isUUID
(
anno
.
target
.
id
))
{
anno
.
target
.
id
=
`
${
newPrefix
}
maps/
${
anno
.
target
.
id
}
`
console
.
log
(
'
updating grid target to
'
,
anno
.
target
.
id
)
}
const
ai
=
new
Annotation
(
anno
)
await
annoClient
.
update
(
ai
.
uuid
,
ai
.
toObject
(),
{})
}
}
proc
().
then
(()
=>
process
.
exit
(
0
))
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