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
ca85c978
Commit
ca85c978
authored
2 years ago
by
Jayaprakash n
Browse files
Options
Download
Patches
Plain Diff
Issue #KN-257 feat: Content Release DIAL codes API refactor.
parent
a85a0b32
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-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
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala
+28
-27
...src/main/scala/org/sunbird/content/dial/DIALManager.scala
with
28 additions
and
27 deletions
+28
-27
content-api/content-actors/src/main/scala/org/sunbird/content/dial/DIALManager.scala
+
28
−
27
View file @
ca85c978
...
...
@@ -127,23 +127,20 @@ object DIALManager {
req
.
put
(
ContentConstants
.
IDENTIFIER
,
objectId
)
req
.
put
(
ContentConstants
.
MODE
,
ContentConstants
.
EDIT_MODE
)
DataNode
.
read
(
req
).
flatMap
(
rootNode
=>
{
req
.
getContext
.
put
(
ContentConstants
.
SCHEMA_NAME
,
ContentConstants
.
COLLECTION_SCHEMA_NAME
)
req
.
getContext
.
put
(
ContentConstants
.
VERSION
,
ContentConstants
.
SCHEMA_VERSION
)
req
.
put
(
ContentConstants
.
ROOT_ID
,
objectId
)
HierarchyManager
.
getHierarchy
(
req
).
flatMap
(
getHierarchyResponse
=>
{
val
updatedChildrenHierarchy
=
getUpdatedChildrenHierarchy
(
getHierarchyResponse
,
requestMap
)
val
consolidatedUnitDIALMap
=
getConsolidatedUnitDIALMap
(
updatedChildrenHierarchy
,
requestMap
,
objectId
)
validateDuplicateDIALCodes
(
consolidatedUnitDIALMap
.
filter
(
rec
=>
rec
.
_2
.
asInstanceOf
[
List
[
String
]].
nonEmpty
))
val
hierarchyReq
=
getHierarchyRequest
(
req
,
objectId
,
updatedChildrenHierarchy
,
rootNode
)
oec
.
graphService
.
saveExternalProps
(
hierarchyReq
).
flatMap
(
rec
=>
if
(
requestMap
.
contains
(
objectId
))
{
val
updateReq
=
getLinkUpdateRequest
(
req
,
rootNode
,
requestMap
,
objectId
)
DataNode
.
update
(
updateReq
).
flatMap
(
response
=>
{
val
updateReq
=
getLinkUpdateRequest
(
req
,
rootNode
,
requestMap
,
objectId
)
DataNode
.
update
(
updateReq
).
flatMap
(
response
=>
{
req
.
getContext
.
put
(
ContentConstants
.
SCHEMA_NAME
,
ContentConstants
.
COLLECTION_SCHEMA_NAME
)
req
.
getContext
.
put
(
ContentConstants
.
VERSION
,
ContentConstants
.
SCHEMA_VERSION
)
req
.
put
(
ContentConstants
.
ROOT_ID
,
objectId
)
HierarchyManager
.
getHierarchy
(
req
).
flatMap
(
getHierarchyResponse
=>
{
val
updatedChildrenHierarchy
=
getUpdatedChildrenHierarchy
(
getHierarchyResponse
,
requestMap
)
val
consolidatedUnitDIALMap
=
getConsolidatedUnitDIALMap
(
updatedChildrenHierarchy
,
requestMap
,
objectId
)
validateDuplicateDIALCodes
(
consolidatedUnitDIALMap
.
filter
(
rec
=>
rec
.
_2
.
asInstanceOf
[
List
[
String
]].
nonEmpty
))
val
hierarchyReq
=
getHierarchyRequest
(
req
,
objectId
,
updatedChildrenHierarchy
,
rootNode
)
oec
.
graphService
.
saveExternalProps
(
hierarchyReq
).
flatMap
(
rec
=>
getResponseCollectionLink
(
requestMap
,
consolidatedUnitDIALMap
.
keySet
.
toList
,
requestMap
.
keySet
.
diff
(
consolidatedUnitDIALMap
.
keySet
).
toList
)
})
}
else
{
getResponseCollectionLink
(
requestMap
,
consolidatedUnitDIALMap
.
keySet
.
toList
,
requestMap
.
keySet
.
diff
(
consolidatedUnitDIALMap
.
keySet
).
toList
)
)
})
})
})
...
...
@@ -175,9 +172,9 @@ object DIALManager {
def
getLinkUpdateRequest
(
req
:
Request
,
rootNode
:
Node
,
requestMap
:
Map
[
String
,
List
[
String
]],
objectId
:
String
)
:
Request
=
{
val
updateReq
=
new
Request
(
req
)
updateReq
.
put
(
ContentConstants
.
IDENTIFIER
,
rootNode
.
getIdentifier
)
updateReq
.
put
(
DIALConstants
.
VERSION_KEY
,
rootNode
.
getMetadata
.
get
(
"versionKey"
))
updateReq
.
put
(
DIALConstants
.
VERSION_KEY
,
rootNode
.
getMetadata
.
get
(
"versionKey"
))
if
(
requestMap
(
objectId
)
.
isEmpty
)
if
(
!
requestMap
.
contains
(
objectId
))
updateReq
.
put
(
DIALConstants
.
DIALCODES
,
null
)
else
updateReq
.
put
(
DIALConstants
.
DIALCODES
,
requestMap
(
objectId
).
toArray
[
String
])
...
...
@@ -354,25 +351,29 @@ object DIALManager {
}
def
populateAssignedDialCodes
(
contentId
:
String
,
contentMetadata
:
util.Map
[
String
,
AnyRef
],
request
:
Request
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
Future
[
List
[
String
]]
=
{
request
.
put
(
ContentConstants
.
MODE
,
""
)
request
.
getContext
.
put
(
ContentConstants
.
SCHEMA_NAME
,
ContentConstants
.
COLLECTION_SCHEMA_NAME
)
request
.
getContext
.
put
(
ContentConstants
.
VERSION
,
ContentConstants
.
SCHEMA_VERSION
)
request
.
put
(
ContentConstants
.
ROOT_ID
,
contentId
)
request
.
put
(
ContentConstants
.
ROOT_ID
,
contentId
.
replaceAll
(
ContentConstants
.
IMAGE_SUFFIX
,
""
)
)
HierarchyManager
.
getHierarchy
(
request
).
flatMap
(
getHierarchyResponse
=>
{
val
collectionHierarchy
=
getHierarchyResponse
.
getResult
.
getOrDefault
(
ContentConstants
.
CONTENT
,
new
java
.
util
.
HashMap
[
String
,
AnyRef
]()).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
val
childrenHierarchy
=
collectionHierarchy
.
get
(
ContentConstants
.
CHILDREN
).
asInstanceOf
[
util.List
[
util.Map
[
String
,
AnyRef
]]].
asScala
.
toList
val
childrenAssignedDIALList
=
getAssignedDIALcodes
(
childrenHierarchy
)
val
contentAssignedDIALList
=
childrenAssignedDIALList
++
collectionHierarchy
.
getOrDefault
(
DIALConstants
.
DIALCODES
,
List
.
empty
[
String
]).
asInstanceOf
[
List
[
String
]]
val
contentAssignedDIALList
=
if
(
collectionHierarchy
.
containsKey
(
DIALConstants
.
DIALCODES
)
&&
collectionHierarchy
.
get
(
DIALConstants
.
DIALCODES
)
!=
null
)
childrenAssignedDIALList
++
collectionHierarchy
.
getOrDefault
(
DIALConstants
.
DIALCODES
,
List
.
empty
[
String
]).
asInstanceOf
[
List
[
String
]]
else
childrenAssignedDIALList
if
(
contentMetadata
.
getOrDefault
(
ContentConstants
.
IDENTIFIER
,
""
).
asInstanceOf
[
String
].
endsWith
(
ContentConstants
.
IMAGE_SUFFIX
))
{
request
.
put
(
ContentConstants
.
ROOT_ID
,
contentMetadata
.
getOrDefault
(
ContentConstants
.
IDENTIFIER
,
""
).
asInstanceOf
[
String
])
request
.
put
(
ContentConstants
.
MODE
,
ContentConstants
.
EDIT_MODE
)
HierarchyManager
.
getHierarchy
(
request
).
flatMap
(
getHierarchyResponse
=>
{
val
collectionHierarchy
=
getHierarchyResponse
.
getResult
.
getOrDefault
(
ContentConstants
.
CONTENT
,
new
java
.
util
.
HashMap
[
String
,
AnyRef
]()).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
val
childrenHierarchy
=
collectionHierarchy
.
get
(
ContentConstants
.
CHILDREN
).
asInstanceOf
[
util.List
[
util.Map
[
String
,
AnyRef
]]].
asScala
.
toList
val
childrenAssignedDIALList
=
getAssignedDIALcodes
(
childrenHierarchy
)
val
contentImageAssignedDIALList
=
childrenAssignedDIALList
++
collectionHierarchy
.
getOrDefault
(
DIALConstants
.
DIALCODES
,
List
.
empty
[
String
]).
asInstanceOf
[
List
[
String
]]
HierarchyManager
.
getHierarchy
(
request
).
flatMap
(
getImageHierarchyResponse
=>
{
val
imageCollectionHierarchy
=
getImageHierarchyResponse
.
getResult
.
getOrDefault
(
ContentConstants
.
CONTENT
,
new
java
.
util
.
HashMap
[
String
,
AnyRef
]()).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
val
imageChildrenHierarchy
=
imageCollectionHierarchy
.
get
(
ContentConstants
.
CHILDREN
).
asInstanceOf
[
util.List
[
util.Map
[
String
,
AnyRef
]]].
asScala
.
toList
val
imageChildrenAssignedDIALList
=
getAssignedDIALcodes
(
imageChildrenHierarchy
)
val
contentImageAssignedDIALList
=
if
(
imageCollectionHierarchy
.
containsKey
(
DIALConstants
.
DIALCODES
)
&&
imageCollectionHierarchy
.
get
(
DIALConstants
.
DIALCODES
)
!=
null
)
imageChildrenAssignedDIALList
++
imageCollectionHierarchy
.
getOrDefault
(
DIALConstants
.
DIALCODES
,
List
.
empty
[
String
]).
asInstanceOf
[
List
[
String
]]
else
imageChildrenAssignedDIALList
Future
(
contentImageAssignedDIALList
++
contentAssignedDIALList
)
})
...
...
@@ -387,7 +388,7 @@ object DIALManager {
else
List
.
empty
[
String
]
val
childDIALMap
=
if
(
child
.
get
(
DIALConstants
.
DIALCODES
)!=
null
)
child
.
get
(
DIALConstants
.
DIALCODES
).
asInstanceOf
[
List
[
String
]]
child
.
get
(
DIALConstants
.
DIALCODES
).
asInstanceOf
[
util.
List
[
String
]]
.
asScala
.
toList
else
List
.
empty
[
String
]
subChildrenDIALMap
++
childDIALMap
...
...
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