Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio
Commits
eda3626e
Commit
eda3626e
authored
Jul 18, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gidstorage gid parser upgraded to assign several constraints to a metadata
parent
7a11c5e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
src/jio.storage/gidstorage.js
src/jio.storage/gidstorage.js
+27
-11
No files found.
src/jio.storage/gidstorage.js
View file @
eda3626e
...
@@ -166,22 +166,38 @@
...
@@ -166,22 +166,38 @@
* constraints
* constraints
*/
*/
function
gidFormat
(
metadata
,
constraints
)
{
function
gidFormat
(
metadata
,
constraints
)
{
var
types
,
i
,
meta_key
,
result
=
{},
tmp
;
var
types
,
i
,
j
,
meta_key
,
result
=
[],
tmp
,
constraint
,
actions
;
types
=
[
'
default
'
,
metadata
.
type
];
types
=
(
metadata_actions
.
list
(
metadata
.
type
)
||
[]).
slice
();
types
.
unshift
(
'
default
'
);
for
(
i
=
0
;
i
<
types
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
types
.
length
;
i
+=
1
)
{
for
(
meta_key
in
constraints
[
types
[
i
]])
{
constraint
=
constraints
[
types
[
i
]];
if
(
constraints
[
types
[
i
]].
hasOwnProperty
(
meta_key
))
{
for
(
meta_key
in
constraint
)
{
tmp
=
metadata_actions
[
if
(
constraint
.
hasOwnProperty
(
meta_key
))
{
constraints
[
types
[
i
]][
meta_key
]
actions
=
constraint
[
meta_key
];
](
metadata
[
meta_key
]);
if
(
!
Array
.
isArray
(
actions
))
{
if
(
tmp
===
undefined
)
{
actions
=
[
actions
];
return
;
}
}
result
[
meta_key
]
=
tmp
;
for
(
j
=
0
;
j
<
actions
.
length
;
j
+=
1
)
{
tmp
=
metadata_actions
[
actions
[
j
]
](
metadata
[
meta_key
]);
if
(
tmp
===
undefined
)
{
return
;
}
}
result
[
result
.
length
]
=
[
meta_key
,
tmp
];
}
}
}
}
}
}
return
JSON
.
stringify
(
result
);
// sort dict keys to make gid universal
result
.
sort
(
function
(
a
,
b
)
{
return
a
[
0
]
<
b
[
0
]
?
-
1
:
a
[
0
]
>
b
[
0
]
?
1
:
0
;
});
tmp
=
{};
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
)
{
tmp
[
result
[
i
][
0
]]
=
result
[
i
][
1
];
}
return
JSON
.
stringify
(
tmp
);
}
}
/**
/**
...
...
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