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
ffdba0be
Unverified
Commit
ffdba0be
authored
4 years ago
by
Amit Priyadarshi
Committed by
GitHub
4 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #562 from krgauraw/release-3.8.0
Issue #SC-2200 fix: code fixes for contentType
parents
f07f91e6
deebd4f6
schema-updates
3.9.0-prod-fix
4.1.0_fixes
AmiableAnil-patch-1
Gcloud_copy
Gcloud_fix
Remove_unwantedCode_Gcloud_fix
actors-test
bulk-upload-comptenecy-mapping
bulk-upload-excelsheet
bulk-upload-test_excel
bulk_upload
code-cleanup
csp-migration
dependabot/maven/platform-core/platform-telemetry/ch.qos.logback-logback-core-1.2.9
dependabot/maven/search-api/search-core/org.apache.httpcomponents-httpclient-4.5.13
knowlg-friday
knowlg-oneclick
local-setup-fix
local-setup-kube
m-4.2.0
master
master-data
org-target-enhancement
patch-1
patch-2
patch-3
poc_bulk_upload
qs-schema
rahul_bulk_upload_postgres
release-3.8.0
release-3.9.0
release-4.0.0
release-4.1.0
release-4.10.0
release-4.10.1
release-4.2.0
release-4.3.0
release-4.4.0
release-4.5.0
release-4.6.0
release-4.7.0
release-4.7.0-debug
release-4.8.0
release-4.8.0-debug
release-4.9.0
release-4.9.1
release-5.0.0
release-5.0.1
release-5.1.0
release-5.1.0-content
release-5.2.0
release-5.3.0
revert-718-visiblity-private-api
revert-719-assessment-private-read-api
revert-720-visiblity-public-search-api
revert-721-visiblity-private-search-api
review-4.1.0
s-debug
schema-update-4.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
release-4.9.1_RC1
release-4.9.0_RC8
release-4.9.0_RC7
release-4.9.0_RC6
release-4.9.0_RC5
release-4.9.0_RC4
release-4.9.0_RC3
release-4.9.0_RC2
release-4.9.0_RC1
release-4.8.0_RC5
release-4.8.0_RC4
release-4.8.0_RC3
release-4.8.0_RC2
release-4.8.0_RC1
release-4.7.0_RC6
release-4.7.0_RC5
release-4.7.0_RC4
release-4.7.0_RC3
release-4.7.0_RC2
release-4.7.0_RC1
release-4.6.0_RC2
release-4.6.0_RC1
release-4.5.0_RC2
release-4.5.0_RC1
release-4.4.0_RC6
release-4.4.0_RC5
release-4.4.0_RC4
release-4.4.0_RC3
release-4.4.0_RC2
release-4.4.0_RC1
release-4.3.0_RC10
release-4.3.0_RC9
release-4.3.0_RC8
release-4.3.0_RC7
release-4.3.0_RC6
release-4.3.0_RC5
release-4.3.0_RC4
release-4.3.0_RC3
release-4.3.0_RC2
release-4.3.0_RC1
release-4.2.0_RC13
release-4.2.0_RC12
release-4.2.0_RC11
release-4.2.0_RC10
release-4.2.0_RC9
release-4.2.0_RC8
release-4.2.0_RC7
release-4.2.0_RC6
release-4.2.0_RC5
release-4.2.0_RC4
release-4.2.0_RC3
release-4.2.0_RC2
release-4.2.0_RC1
release-4.1.0_RC13
release-4.1.0_RC12
release-4.1.0_RC11
release-4.1.0_RC10
release-4.1.0_RC9
release-4.1.0_RC8
release-4.1.0_RC7
release-4.1.0_RC6
release-4.1.0_RC5
release-4.1.0_RC4
release-4.1.0_RC3
release-4.1.0_RC2
release-4.1.0_RC1
release-4.0.0_RC9
release-4.0.0_RC8
release-4.0.0_RC7
release-4.0.0_RC6
release-4.0.0_RC5
release-4.0.0_RC4
release-4.0.0_RC3
release-4.0.0_RC2
release-4.0.0_RC1
release-3.9.0_RC12
release-3.9.0_RC11
release-3.9.0_RC10
release-3.9.0_RC9
release-3.9.0_RC8
release-3.9.0_RC7
release-3.9.0_RC6
release-3.9.0_RC5
release-3.9.0_RC4
release-3.9.0_RC3
release-3.9.0_RC2
release-3.9.0_RC1
release-3.8.0_RC9
release-3.8.0_RC8
release-3.8.0_RC7
release-3.8.0_RC6
release-3.8.0_RC5
release-3.8.0_RC4
release-3.8.0_RC3
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+7
-8
...rc/main/scala/org/sunbird/managers/HierarchyManager.scala
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala
+2
-2
...n/scala/org/sunbird/managers/UpdateHierarchyManager.scala
content-api/hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyBackwardCompatibilityUtil.scala
+18
-15
...rg/sunbird/utils/HierarchyBackwardCompatibilityUtil.scala
schemas/question/1.0/schema.json
+1
-1
schemas/question/1.0/schema.json
schemas/questionset/1.0/schema.json
+1
-1
schemas/questionset/1.0/schema.json
with
29 additions
and
27 deletions
+29
-27
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+
7
−
8
View file @
ffdba0be
...
...
@@ -41,7 +41,6 @@ object HierarchyManager {
val
mapPrimaryCategoriesEnabled
:
Boolean
=
if
(
Platform
.
config
.
hasPath
(
"collection.primarycategories.mapping.enabled"
))
Platform
.
config
.
getBoolean
(
"collection.primarycategories.mapping.enabled"
)
else
true
val
objectTypeAsContentEnabled
:
Boolean
=
if
(
Platform
.
config
.
hasPath
(
"objecttype.as.content.enabled"
))
Platform
.
config
.
getBoolean
(
"objecttype.as.content.enabled"
)
else
true
val
objectTypes
=
List
(
"Content"
,
"Collection"
)
@throws
[
Exception
]
def
addLeafNodesToHierarchy
(
request
:
Request
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
Future
[
Response
]
=
{
...
...
@@ -534,8 +533,8 @@ object HierarchyManager {
if
(
HierarchyConstants
.
RETIRED_STATUS
.
equalsIgnoreCase
(
metadata
.
getOrDefault
(
"status"
,
HierarchyConstants
.
RETIRED_STATUS
).
asInstanceOf
[
String
])){
children
.
remove
(
content
)
}
else
{
if
(
objectTypes
.
contains
(
metadata
.
get
(
"objectType"
).
asInstanceOf
[
String
])
&&
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
metadata
)
if
(
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
metadata
,
metadata
.
get
(
"objectType"
).
asInstanceOf
[
String
]
)
content
.
putAll
(
metadata
)
}
}
else
{
...
...
@@ -589,9 +588,9 @@ object HierarchyManager {
def
updateContentMappingInChildren
(
children
:
util.List
[
util.Map
[
String
,
AnyRef
]])
:
List
[
Any
]
=
{
children
.
toList
.
map
(
content
=>
{
if
(
mapPrimaryCategoriesEnabled
)
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
content
)
if
(
objectTypes
.
contains
(
content
.
get
(
"objectType"
).
asInstanceOf
[
String
])
&&
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
content
)
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
content
,
content
.
get
(
"objectType"
).
asInstanceOf
[
String
]
)
if
(
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
content
,
content
.
get
(
"objectType"
).
asInstanceOf
[
String
]
)
updateContentMappingInChildren
(
content
.
getOrDefault
(
"children"
,
new
util
.
ArrayList
[
Map
[
String
,
AnyRef
]]).
asInstanceOf
[
util.List
[
util.Map
[
String
,
AnyRef
]]])
})
}
...
...
@@ -600,8 +599,8 @@ object HierarchyManager {
val
updatedHierarchy
=
new
util
.
HashMap
[
String
,
AnyRef
](
hierarchy
)
if
(
mapPrimaryCategoriesEnabled
)
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
updatedHierarchy
)
if
(
objectTypes
.
contains
(
updatedHierarchy
.
get
(
"objectType"
).
asInstanceOf
[
String
])
&&
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
updatedHierarchy
)
if
(
objectTypeAsContentEnabled
)
HierarchyBackwardCompatibilityUtil
.
setObjectTypeForRead
(
updatedHierarchy
,
updatedHierarchy
.
get
(
"objectType"
).
asInstanceOf
[
String
]
)
val
children
=
new
util
.
HashMap
[
String
,
AnyRef
](
hierarchy
).
getOrDefault
(
"children"
,
new
util
.
ArrayList
[
java.util.Map
[
String
,
AnyRef
]]).
asInstanceOf
[
util.ArrayList
[
java.util.Map
[
String
,
AnyRef
]]]
updateContentMappingInChildren
(
children
)
updatedHierarchy
...
...
This diff is collapsed.
Click to expand it.
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala
+
2
−
2
View file @
ffdba0be
...
...
@@ -170,7 +170,7 @@ object UpdateHierarchyManager {
node
.
getMetadata
.
put
(
HierarchyConstants
.
PARENT
,
child
.
get
(
HierarchyConstants
.
PARENT
))
node
.
getMetadata
.
put
(
HierarchyConstants
.
INDEX
,
child
.
get
(
HierarchyConstants
.
INDEX
))
//TODO: Remove the Populate category mapping before updating for backward
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
node
.
getMetadata
)
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
node
.
getMetadata
,
node
.
getObjectType
)
HierarchyBackwardCompatibilityUtil
.
setNewObjectType
(
node
)
val
updatedNodes
=
node
::
nodes
updatedNodes
...
...
@@ -390,7 +390,7 @@ object UpdateHierarchyManager {
populateHierarchyRelatedData
(
node
,
depth
,
index
,
parent
)
node
.
getMetadata
.
put
(
HierarchyConstants
.
VISIBILITY
,
HierarchyConstants
.
DEFAULT
)
//TODO: Populate category mapping before updating for backward
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
node
.
getMetadata
)
HierarchyBackwardCompatibilityUtil
.
setContentAndCategoryTypes
(
node
.
getMetadata
,
node
.
getObjectType
)
HierarchyBackwardCompatibilityUtil
.
setNewObjectType
(
node
)
val
nxtEnrichedNodeList
=
node
::
enrichedNodeList
if
(
MapUtils
.
isNotEmpty
(
hierarchyStructure
.
getOrDefault
(
id
,
Map
[
String
,
Int
]())))
{
...
...
This diff is collapsed.
Click to expand it.
content-api/hierarchy-manager/src/main/scala/org/sunbird/utils/HierarchyBackwardCompatibilityUtil.scala
+
18
−
15
View file @
ffdba0be
...
...
@@ -18,22 +18,24 @@ object HierarchyBackwardCompatibilityUtil {
new
util
.
HashMap
[
String
,
AnyRef
]()).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]]
val
mimeTypesToCheck
=
List
(
"application/vnd.ekstep.h5p-archive"
,
"application/vnd.ekstep.html-archive"
,
"application/vnd.android.package-archive"
,
"video/webm"
,
"video/x-youtube"
,
"video/mp4"
)
val
objectTypes
=
List
(
"Content"
,
"Collection"
)
def
setContentAndCategoryTypes
(
input
:
java.util.Map
[
String
,
AnyRef
])
:
Unit
=
{
val
contentType
=
input
.
get
(
"contentType"
).
asInstanceOf
[
String
]
def
setContentAndCategoryTypes
(
input
:
util.Map
[
String
,
AnyRef
],
objType
:
String
=
""
)
:
Unit
=
{
if
(
StringUtils
.
isBlank
(
objType
)
||
objectTypes
.
contains
(
objType
))
{
val
contentType
=
input
.
get
(
"contentType"
).
asInstanceOf
[
String
]
val
primaryCategory
=
input
.
get
(
"primaryCategory"
).
asInstanceOf
[
String
]
val
(
updatedContentType
,
updatedPrimaryCategory
)
:
(
String
,
String
)
=
(
contentType
,
primaryCategory
)
match
{
case
(
x
:
String
,
y
:
String
)
=>
(
x
,
y
)
case
(
"Resource"
,
y
)
=>
(
contentType
,
getCategoryForResource
(
input
.
getOrDefault
(
"mimeType"
,
""
).
asInstanceOf
[
String
],
input
.
getOrDefault
(
"resourceType"
,
""
).
asInstanceOf
[
String
]))
case
(
x
:
String
,
y
)
=>
(
x
,
categoryMap
.
get
(
x
).
asInstanceOf
[
String
])
case
(
x
,
y
:
String
)
=>
(
categoryMap
.
asScala
.
filter
(
entry
=>
StringUtils
.
equalsIgnoreCase
(
entry
.
_2
.
asInstanceOf
[
String
],
y
)).
keys
.
headOption
.
getOrElse
(
""
),
y
)
case
_
=>
(
contentType
,
primaryCategory
)
}
val
primaryCategory
=
input
.
get
(
"primaryCategory"
).
asInstanceOf
[
String
]
val
(
updatedContentType
,
updatedPrimaryCategory
)
:
(
String
,
String
)
=
(
contentType
,
primaryCategory
)
match
{
case
(
x
:
String
,
y
:
String
)
=>
(
x
,
y
)
case
(
"Resource"
,
y
)
=>
(
contentType
,
getCategoryForResource
(
input
.
getOrDefault
(
"mimeType"
,
""
).
asInstanceOf
[
String
],
input
.
getOrDefault
(
"resourceType"
,
""
).
asInstanceOf
[
String
]))
case
(
x
:
String
,
y
)
=>
(
x
,
categoryMap
.
get
(
x
).
asInstanceOf
[
String
])
case
(
x
,
y
:
String
)
=>
(
categoryMap
.
asScala
.
filter
(
entry
=>
StringUtils
.
equalsIgnoreCase
(
entry
.
_2
.
asInstanceOf
[
String
],
y
)).
keys
.
headOption
.
getOrElse
(
""
),
y
)
case
_
=>
(
contentType
,
primaryCategory
)
input
.
put
(
"contentType"
,
updatedContentType
)
input
.
put
(
"primaryCategory"
,
updatedPrimaryCategory
)
}
input
.
put
(
"contentType"
,
updatedContentType
)
input
.
put
(
"primaryCategory"
,
updatedPrimaryCategory
)
}
private
def
getCategoryForResource
(
mimeType
:
String
,
resourceType
:
String
)
:
String
=
(
mimeType
,
resourceType
)
match
{
...
...
@@ -42,8 +44,9 @@ object HierarchyBackwardCompatibilityUtil {
case
(
x
:
String
,
y
:
String
)
=>
if
(
mimeTypesToCheck
.
contains
(
x
))
categoryMapForMimeType
.
get
(
x
).
asInstanceOf
[
util.List
[
String
]].
asScala
.
headOption
.
getOrElse
(
"Learning Resource"
)
else
categoryMapForResourceType
.
getOrDefault
(
y
,
"Learning Resource"
).
asInstanceOf
[
String
]
case
_
=>
"Learning Resource"
}
def
setObjectTypeForRead
(
result
:
java.util.Map
[
String
,
AnyRef
])
:
Unit
=
{
result
.
put
(
"objectType"
,
"Content"
)
def
setObjectTypeForRead
(
result
:
java.util.Map
[
String
,
AnyRef
],
objectType
:
String
=
""
)
:
Unit
=
{
if
(
objectTypes
.
contains
(
objectType
))
result
.
put
(
"objectType"
,
"Content"
)
}
def
setNewObjectType
(
node
:
Node
)
=
{
...
...
This diff is collapsed.
Click to expand it.
schemas/question/1.0/schema.json
+
1
−
1
View file @
ffdba0be
...
...
@@ -63,7 +63,7 @@
"enum"
:
[
"Student"
,
"Teacher"
,
"Admin"
"Admin
istrator
"
],
"default"
:
"Student"
}
...
...
This diff is collapsed.
Click to expand it.
schemas/questionset/1.0/schema.json
+
1
−
1
View file @
ffdba0be
...
...
@@ -63,7 +63,7 @@
"enum"
:
[
"Student"
,
"Teacher"
,
"Admin"
"Admin
istrator
"
],
"default"
:
"Student"
}
...
...
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