Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
ae773a83
Commit
ae773a83
authored
5 years ago
by
S.Listl
Browse files
Options
Downloads
Patches
Plain Diff
Tree sort function
parent
9fe74584
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js
+1
-1
1 addition, 1 deletion
...eRelation_entity/recordcontainers/jdito/contentProcess.js
process/Util_lib/process.js
+41
-0
41 additions, 0 deletions
process/Util_lib/process.js
with
42 additions
and
1 deletion
entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js
+
1
−
1
View file @
ae773a83
...
...
@@ -81,7 +81,7 @@ var attributeValues = db.table(attributeSql).map(function (row)
if
(
getTree
)
_fetchAttributes
(
attributeValues
.
map
(
function
(
row
)
{
return
row
[
1
]}));
allAttributes
=
_
sortArrayForTree
(
allAttributes
).
concat
(
attributeValues
);
allAttributes
=
TreeUtils
.
sortArrayForTree
(
allAttributes
).
concat
(
attributeValues
);
result
.
object
(
allAttributes
);
...
...
This diff is collapsed.
Click to expand it.
process/Util_lib/process.js
+
41
−
0
View file @
ae773a83
...
...
@@ -540,3 +540,44 @@ NumberSequencingUtils.getMaxUniqueNumber = function(pColumn, pTable, pCondition)
var
maxNum
=
db
.
cell
(
"
select max(
"
+
pColumn
+
"
) from
"
+
pTable
+
condition
);
return
maxNum
==
""
?
"
0
"
:
maxNum
;
}
/**
* functions for trees
*/
function
TreeUtils
()
{}
/**
* sorts an array in a way that a tree(-table) can be built
*
* @param {Array} pArray two-dimensional array to sort
* @param {Number} pUidIndex the index of the uid in a row
* @param {Number} pParentIdIndex the index of the parent id in a row
*
* @return {Array} the sorted array
*/
TreeUtils
.
sortArrayForTree
=
function
(
pArray
,
pUidIndex
,
pParentIdIndex
)
{
if
(
pArray
.
length
<=
1
)
return
pArray
;
var
rows
=
{};
var
allIds
=
{};
pArray
.
forEach
(
function
(
row
)
{
allIds
[
row
[
pUidIndex
]]
=
true
;});
var
index
=
0
;
do
{
var
oldIndex
=
index
;
pArray
.
forEach
(
function
(
row
)
{
if
(
!
(
row
[
pUidIndex
]
in
this
)
&&
(
row
[
pParentIdIndex
]
in
this
||
!
allIds
[
row
[
pParentIdIndex
]]))
this
[
row
[
pUidIndex
]]
=
{
data
:
row
,
index
:
index
++
};
},
rows
);
}
while
(
oldIndex
!=
index
);
var
sortedArray
=
new
Array
(
index
);
for
(
let
i
in
rows
)
sortedArray
[
rows
[
i
].
index
]
=
rows
[
i
].
data
;
return
sortedArray
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment