Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
knowledge-platform
Commits
696d0d3a
Commit
696d0d3a
authored
2 years ago
by
Karthikeyan R
Browse files
Options
Download
Patches
Plain Diff
SB-29856 | Fix for hierarchy update
parent
19f13761
release-5.3.0
AmiableAnil-patch-1
Gcloud_copy
Gcloud_fix
Remove_unwantedCode_Gcloud_fix
bulk-upload-comptenecy-mapping
bulk-upload-excelsheet
bulk-upload-test_excel
bulk_upload
csp-migration
knowlg-oneclick
local-setup-kube
master
patch-1
patch-2
patch-3
poc_bulk_upload
rahul_bulk_upload_postgres
release-4.10.0
release-4.10.1
release-5.0.0
release-5.0.1
release-5.1.0
release-5.1.0-content
release-5.2.0
release-5.2.0_RC2
release-5.2.0_RC1
release-5.1.0_RC1
release-5.0.0_RC2
release-5.0.0_RC1
release-4.10.0_RC2
release-4.10.0_RC1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala
+12
-5
...n/scala/org/sunbird/managers/UpdateHierarchyManager.scala
with
12 additions
and
5 deletions
+12
-5
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala
+
12
−
5
View file @
696d0d3a
...
@@ -345,7 +345,7 @@ object UpdateHierarchyManager {
...
@@ -345,7 +345,7 @@ object UpdateHierarchyManager {
if
(
MapUtils
.
isNotEmpty
(
childrenIdentifiersMap
))
{
if
(
MapUtils
.
isNotEmpty
(
childrenIdentifiersMap
))
{
val
updatedNodeList
=
getTempNode
(
nodeList
,
rootId
)
::
List
()
val
updatedNodeList
=
getTempNode
(
nodeList
,
rootId
)
::
List
()
updateHierarchyRelatedData
(
childrenIdentifiersMap
.
getOrElse
(
rootId
,
Map
[
String
,
Int
]()),
1
,
updateHierarchyRelatedData
(
childrenIdentifiersMap
.
getOrElse
(
rootId
,
Map
[
String
,
Int
]()),
1
,
rootId
,
nodeList
,
childrenIdentifiersMap
,
updatedNodeList
,
request
).
map
(
finalEnrichedNodeList
=>
{
rootId
,
nodeList
,
childrenIdentifiersMap
,
updatedNodeList
,
request
,
rootId
).
map
(
finalEnrichedNodeList
=>
{
TelemetryManager
.
info
(
"Final enriched list size: "
+
finalEnrichedNodeList
.
size
)
TelemetryManager
.
info
(
"Final enriched list size: "
+
finalEnrichedNodeList
.
size
)
val
childNodeIds
=
finalEnrichedNodeList
.
map
(
node
=>
node
.
getIdentifier
.
replaceAll
(
".img"
,
""
)).
filterNot
(
id
=>
StringUtils
.
containsIgnoreCase
(
rootId
,
id
)).
distinct
val
childNodeIds
=
finalEnrichedNodeList
.
map
(
node
=>
node
.
getIdentifier
.
replaceAll
(
".img"
,
""
)).
filterNot
(
id
=>
StringUtils
.
containsIgnoreCase
(
rootId
,
id
)).
distinct
TelemetryManager
.
info
(
"Final enriched ids (childNodes): "
+
childNodeIds
+
" :: size: "
+
childNodeIds
.
size
)
TelemetryManager
.
info
(
"Final enriched ids (childNodes): "
+
childNodeIds
+
" :: size: "
+
childNodeIds
.
size
)
...
@@ -368,7 +368,8 @@ object UpdateHierarchyManager {
...
@@ -368,7 +368,8 @@ object UpdateHierarchyManager {
}
}
@throws
[
Exception
]
@throws
[
Exception
]
private
def
updateHierarchyRelatedData
(
childrenIds
:
Map
[
String
,
Int
],
depth
:
Int
,
parent
:
String
,
nodeList
:
List
[
Node
],
hierarchyStructure
:
Map
[
String
,
Map
[
String
,
Int
]],
enrichedNodeList
:
scala.collection.immutable.List
[
Node
],
request
:
Request
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
Future
[
List
[
Node
]]
=
{
private
def
updateHierarchyRelatedData
(
childrenIds
:
Map
[
String
,
Int
],
depth
:
Int
,
parent
:
String
,
nodeList
:
List
[
Node
],
hierarchyStructure
:
Map
[
String
,
Map
[
String
,
Int
]],
enrichedNodeList
:
scala.collection.immutable.List
[
Node
],
request
:
Request
,
rootId
:
String
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
Future
[
List
[
Node
]]
=
{
val
rootResourceChange
:
Boolean
=
if
(
Platform
.
config
.
hasPath
(
"hierarchyUpdate.allow.resource.at.root.level"
))
Platform
.
config
.
getBoolean
(
"hierarchyUpdate.allow.resource.at.root.level"
)
else
false
val
futures
=
childrenIds
.
map
(
child
=>
{
val
futures
=
childrenIds
.
map
(
child
=>
{
val
id
=
child
.
_1
val
id
=
child
.
_1
val
index
=
child
.
_2
+
1
val
index
=
child
.
_2
+
1
...
@@ -378,13 +379,19 @@ object UpdateHierarchyManager {
...
@@ -378,13 +379,19 @@ object UpdateHierarchyManager {
val
nxtEnrichedNodeList
=
tempNode
::
enrichedNodeList
val
nxtEnrichedNodeList
=
tempNode
::
enrichedNodeList
if
(
MapUtils
.
isNotEmpty
(
hierarchyStructure
.
getOrDefault
(
child
.
_1
,
Map
[
String
,
Int
]())))
if
(
MapUtils
.
isNotEmpty
(
hierarchyStructure
.
getOrDefault
(
child
.
_1
,
Map
[
String
,
Int
]())))
updateHierarchyRelatedData
(
hierarchyStructure
.
getOrDefault
(
child
.
_1
,
Map
[
String
,
Int
]()),
updateHierarchyRelatedData
(
hierarchyStructure
.
getOrDefault
(
child
.
_1
,
Map
[
String
,
Int
]()),
tempNode
.
getMetadata
.
get
(
HierarchyConstants
.
DEPTH
).
asInstanceOf
[
Int
]
+
1
,
id
,
nodeList
,
hierarchyStructure
,
nxtEnrichedNodeList
,
request
)
tempNode
.
getMetadata
.
get
(
HierarchyConstants
.
DEPTH
).
asInstanceOf
[
Int
]
+
1
,
id
,
nodeList
,
hierarchyStructure
,
nxtEnrichedNodeList
,
request
,
rootId
)
else
else
Future
(
nxtEnrichedNodeList
)
Future
(
nxtEnrichedNodeList
)
}
else
{
}
else
{
// TelemetryManager.info("Get ContentNode as TempNode is null for ID: " + id)
// TelemetryManager.info("Get ContentNode as TempNode is null for ID: " + id)
getContentNode
(
id
,
HierarchyConstants
.
TAXONOMY_ID
).
map
(
node
=>
{
getContentNode
(
id
,
HierarchyConstants
.
TAXONOMY_ID
).
map
(
node
=>
{
val
parentNode
:
Node
=
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
parent
)).
orNull
val
parentNode
:
Node
=
if
(
rootResourceChange
&&
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
parent
)).
orNull
==
null
)
{
if
(
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
rootId
)).
orNull
==
null
)
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
rootId
+
".img"
)).
orNull
else
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
rootId
)).
orNull
}
else
nodeList
.
find
(
p
=>
p
.
getIdentifier
.
equals
(
parent
)).
orNull
val
nxtEnrichedNodeList
=
if
(
null
!=
parentNode
)
{
val
nxtEnrichedNodeList
=
if
(
null
!=
parentNode
)
{
TelemetryManager
.
info
(
s
"ObjectType for $parent is ${parentNode.getObjectType}..."
)
TelemetryManager
.
info
(
s
"ObjectType for $parent is ${parentNode.getObjectType}..."
)
val
parentMetadata
:
java.util.Map
[
String
,
AnyRef
]
=
NodeUtil
.
serialize
(
parentNode
,
new
java
.
util
.
ArrayList
[
String
](),
parentNode
.
getObjectType
.
toLowerCase
,
"1.0"
)
val
parentMetadata
:
java.util.Map
[
String
,
AnyRef
]
=
NodeUtil
.
serialize
(
parentNode
,
new
java
.
util
.
ArrayList
[
String
](),
parentNode
.
getObjectType
.
toLowerCase
,
"1.0"
)
...
@@ -401,7 +408,7 @@ object UpdateHierarchyManager {
...
@@ -401,7 +408,7 @@ object UpdateHierarchyManager {
enrichedNodeList
enrichedNodeList
}
}
if
(
MapUtils
.
isNotEmpty
(
hierarchyStructure
.
getOrDefault
(
id
,
Map
[
String
,
Int
]())))
{
if
(
MapUtils
.
isNotEmpty
(
hierarchyStructure
.
getOrDefault
(
id
,
Map
[
String
,
Int
]())))
{
updateHierarchyRelatedData
(
hierarchyStructure
.
getOrDefault
(
id
,
Map
[
String
,
Int
]()),
node
.
getMetadata
.
get
(
HierarchyConstants
.
DEPTH
).
asInstanceOf
[
Int
]
+
1
,
id
,
nodeList
,
hierarchyStructure
,
nxtEnrichedNodeList
,
request
)
updateHierarchyRelatedData
(
hierarchyStructure
.
getOrDefault
(
id
,
Map
[
String
,
Int
]()),
node
.
getMetadata
.
get
(
HierarchyConstants
.
DEPTH
).
asInstanceOf
[
Int
]
+
1
,
id
,
nodeList
,
hierarchyStructure
,
nxtEnrichedNodeList
,
request
,
rootId
)
}
else
}
else
Future
(
nxtEnrichedNodeList
)
Future
(
nxtEnrichedNodeList
)
}).
flatMap
(
f
=>
f
)
recoverWith
{
case
e
:
CompletionException
=>
throw
e
.
getCause
}
}).
flatMap
(
f
=>
f
)
recoverWith
{
case
e
:
CompletionException
=>
throw
e
.
getCause
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets