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
8b9af3bb
Commit
8b9af3bb
authored
3 years ago
by
amitpriyadarshi
Browse files
Options
Download
Plain Diff
Merge branch 'release-3.8.0' into release-3.9.0
parents
d1e7d1b6
132de1ae
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.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
No related merge requests found
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+5
-5
...rc/main/scala/org/sunbird/managers/HierarchyManager.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/CategoryDefinitionValidator.scala
+8
-6
...rg/sunbird/graph/schema/CategoryDefinitionValidator.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionDTO.scala
+1
-1
...c/main/scala/org/sunbird/graph/schema/DefinitionDTO.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionFactory.scala
+3
-2
...in/scala/org/sunbird/graph/schema/DefinitionFactory.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionNode.scala
+35
-26
.../main/scala/org/sunbird/graph/schema/DefinitionNode.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/IDefinition.scala
+2
-2
...src/main/scala/org/sunbird/graph/schema/IDefinition.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/ObjectCategoryDefinition.scala
+3
-0
...a/org/sunbird/graph/schema/ObjectCategoryDefinition.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/validator/BaseDefinitionNode.scala
+2
-2
...g/sunbird/graph/schema/validator/BaseDefinitionNode.scala
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/utils/NodeUtil.scala
+4
-4
....11/src/main/scala/org/sunbird/graph/utils/NodeUtil.scala
with
63 additions
and
48 deletions
+63
-48
content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/HierarchyManager.scala
+
5
−
5
View file @
8b9af3bb
...
...
@@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils
import
org.sunbird.cache.impl.RedisCache
import
org.sunbird.common.dto.
{
Request
,
Response
,
ResponseHandler
}
import
org.sunbird.common.exception.
{
ClientException
,
ErrorCodes
,
ResourceNotFoundException
,
ResponseCode
,
ServerException
}
import
org.sunbird.common.
{
JsonUtils
,
Platform
,
Slug
}
import
org.sunbird.common.
{
JsonUtils
,
Platform
}
import
org.sunbird.graph.dac.model.Node
import
org.sunbird.graph.nodes.DataNode
import
org.sunbird.graph.utils.
{
NodeUtil
,
ScalaJsonUtils
}
...
...
@@ -21,7 +21,7 @@ import com.mashape.unirest.http.HttpResponse
import
com.mashape.unirest.http.Unirest
import
org.apache.commons.collections4.
{
CollectionUtils
,
MapUtils
}
import
org.sunbird.graph.OntologyEngineContext
import
org.sunbird.graph.schema.DefinitionNode
import
org.sunbird.graph.schema.
{
DefinitionNode
,
ObjectCategoryDefinition
}
import
org.sunbird.utils.
{
HierarchyBackwardCompatibilityUtil
,
HierarchyConstants
,
HierarchyErrorCodes
}
object
HierarchyManager
{
...
...
@@ -608,9 +608,9 @@ object HierarchyManager {
def
validateLeafNodes
(
parentNode
:
java.util.Map
[
String
,
AnyRef
],
childNode
:
java.util.Map
[
String
,
AnyRef
])(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
=
{
val
primaryCategory
=
parentNode
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
]
val
channel
=
parentNode
.
getOrDefault
(
"channel"
,
"
_
all"
)
val
categoryId
=
if
(
StringUtils
.
isBlank
(
primaryCategory
))
""
else
"obj-cat:"
+
Slug
.
makeSlug
(
primaryCategory
+
"_"
+
parentNode
.
getOrDefault
(
"objectType"
,
""
).
asInstanceOf
[
String
].
toLowerCase
()
+
"_"
+
channel
)
val
outRelations
=
DefinitionNode
.
getOutRelations
(
HierarchyConstants
.
GRAPH_ID
,
"1.0"
,
parentNode
.
getOrDefault
(
"objectType"
,
""
).
asInstanceOf
[
String
].
toLowerCase
().
replace
(
"image"
,
""
),
categoryId
)
val
channel
:
String
=
parentNode
.
getOrDefault
(
"channel"
,
"all"
)
.
asInstanceOf
[
String
]
val
objectCategoryDefinition
:
ObjectCategoryDefinition
=
DefinitionNode
.
getObjectCategoryDefinition
(
primaryCategory
,
parentNode
.
getOrDefault
(
"objectType"
,
""
).
asInstanceOf
[
String
].
toLowerCase
()
,
channel
)
val
outRelations
=
DefinitionNode
.
getOutRelations
(
HierarchyConstants
.
GRAPH_ID
,
"1.0"
,
parentNode
.
getOrDefault
(
"objectType"
,
""
).
asInstanceOf
[
String
].
toLowerCase
().
replace
(
"image"
,
""
),
objectCategoryDefinition
)
val
configObjTypes
:
List
[
String
]
=
outRelations
.
find
(
_
.
keySet
.
contains
(
"children"
)).
orNull
.
getOrElse
(
"children"
,
Map
()).
asInstanceOf
[
java.util.Map
[
String
,
AnyRef
]].
getOrElse
(
"objects"
,
new
util
.
ArrayList
[
String
]()).
asInstanceOf
[
java.util.List
[
String
]].
toList
if
(
configObjTypes
.
nonEmpty
&&
!
configObjTypes
.
contains
(
childNode
.
getOrDefault
(
"objectType"
,
""
).
asInstanceOf
[
String
]))
throw
new
ClientException
(
"ERR_INVALID_CHILDREN"
,
"Invalid Children objectType "
+
childNode
.
get
(
"objectType"
)+
" found for : "
+
childNode
.
get
(
"identifier"
)
+
"| Please provide children having one of the objectType from "
+
configObjTypes
.
asJava
)
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/CategoryDefinitionValidator.scala
+
8
−
6
View file @
8b9af3bb
...
...
@@ -29,13 +29,14 @@ class CategoryDefinitionValidator(schemaName: String, version: String) extends B
null
}
def
loadSchema
(
categoryId
:
String
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
CategoryDefinitionValidator
=
{
def
loadSchema
(
ocd
:
ObjectCategoryDefinition
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
CategoryDefinitionValidator
=
{
val
categoryId
:
String
=
ObjectCategoryDefinitionMap
.
prepareCategoryId
(
ocd
.
categoryName
,
ocd
.
objectType
,
ocd
.
channel
)
if
(
ObjectCategoryDefinitionMap
.
containsKey
(
categoryId
)
&&
null
!=
ObjectCategoryDefinitionMap
.
get
(
categoryId
)){
this
.
schema
=
ObjectCategoryDefinitionMap
.
get
(
categoryId
).
getOrElse
(
"schema"
,
null
).
asInstanceOf
[
JsonSchema
]
this
.
config
=
ObjectCategoryDefinitionMap
.
get
(
categoryId
).
getOrElse
(
"config"
,
null
).
asInstanceOf
[
Config
]
}
}
else
{
val
(
schemaMap
,
configMap
)
=
prepareSchema
(
c
ategoryI
d
)
val
(
schemaMap
,
configMap
)
=
prepareSchema
(
o
cd
)
this
.
schema
=
readSchema
(
new
ByteArrayInputStream
(
JsonUtils
.
serialize
(
schemaMap
).
getBytes
))
this
.
config
=
ConfigFactory
.
parseMap
(
configMap
)
ObjectCategoryDefinitionMap
.
put
(
categoryId
,
Map
(
"schema"
->
schema
,
"config"
->
config
))
...
...
@@ -43,7 +44,8 @@ class CategoryDefinitionValidator(schemaName: String, version: String) extends B
this
}
def
prepareSchema
(
categoryId
:
String
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
(
java.util.Map
[
String
,
AnyRef
],
java
.
util
.
Map
[
String
,
AnyRef
])
=
{
def
prepareSchema
(
ocd
:
ObjectCategoryDefinition
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
(
java.util.Map
[
String
,
AnyRef
],
java
.
util
.
Map
[
String
,
AnyRef
])
=
{
val
categoryId
:
String
=
ObjectCategoryDefinitionMap
.
prepareCategoryId
(
ocd
.
categoryName
,
ocd
.
objectType
,
ocd
.
channel
)
val
request
:
Request
=
new
Request
()
val
context
=
new
util
.
HashMap
[
String
,
AnyRef
]()
context
.
put
(
"schemaName"
,
"objectcategorydefinition"
)
...
...
@@ -54,10 +56,10 @@ class CategoryDefinitionValidator(schemaName: String, version: String) extends B
val
resp
=
Await
.
result
(
oec
.
graphService
.
readExternalProps
(
request
,
List
(
"objectMetadata"
)),
Duration
.
apply
(
"30 seconds"
))
if
(
ResponseHandler
.
checkError
(
resp
))
{
if
(
StringUtils
.
equalsAnyIgnoreCase
(
resp
.
getResponseCode
.
name
(),
ResponseCode
.
RESOURCE_NOT_FOUND
.
name
()))
{
if
(
"all"
.
equalsIgnoreCase
(
categoryId
.
substring
(
categoryId
.
lastIndexOf
(
"_"
)
+
1
)
))
if
(
"all"
.
equalsIgnoreCase
(
ocd
.
channel
))
throw
new
ResourceNotFoundException
(
resp
.
getParams
.
getErr
,
resp
.
getParams
.
getErrmsg
+
" "
+
resp
.
getResult
)
else
{
val
updatedId
=
categoryId
.
replace
(
categoryId
.
substring
(
categoryId
.
lastIndexOf
(
"_"
)
+
1
)
,
"all"
)
val
updatedId
=
ObjectCategoryDefinitionMap
.
prepareCategoryId
(
ocd
.
categoryName
,
ocd
.
objectType
,
"all"
)
request
.
put
(
"identifier"
,
updatedId
)
val
channelCatResp
=
Await
.
result
(
oec
.
graphService
.
readExternalProps
(
request
,
List
(
"objectMetadata"
)),
Duration
.
apply
(
"30 seconds"
))
if
(
StringUtils
.
equalsAnyIgnoreCase
(
channelCatResp
.
getResponseCode
.
name
(),
ResponseCode
.
RESOURCE_NOT_FOUND
.
name
()))
{
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionDTO.scala
+
1
−
1
View file @
8b9af3bb
...
...
@@ -15,7 +15,7 @@ import org.sunbird.graph.schema.validator._
import
scala.collection.JavaConverters._
import
scala.concurrent.ExecutionContext
class
DefinitionDTO
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
extends
BaseDefinitionNode
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
with
VersionKeyValidator
with
VersioningNode
with
RelationValidator
with
FrameworkValidator
with
PropAsEdgeValidator
with
SchemaValidator
{
class
DefinitionDTO
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
extends
BaseDefinitionNode
(
graphId
,
schemaName
,
version
,
o
cd
)
with
VersionKeyValidator
with
VersioningNode
with
RelationValidator
with
FrameworkValidator
with
PropAsEdgeValidator
with
SchemaValidator
{
def
getOutRelationObjectTypes
:
List
[
String
]
=
outRelationObjectTypes
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionFactory.scala
+
3
−
2
View file @
8b9af3bb
...
...
@@ -8,9 +8,10 @@ object DefinitionFactory {
private
var
definitions
:
Map
[
String
,
DefinitionDTO
]
=
Map
()
def
getDefinition
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
DefinitionDTO
=
{
def
getDefinition
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
())(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
DefinitionDTO
=
{
val
categoryId
:
String
=
ObjectCategoryDefinitionMap
.
prepareCategoryId
(
ocd
.
categoryName
,
ocd
.
objectType
,
ocd
.
channel
)
val
key
=
getKey
(
graphId
,
schemaName
,
version
,
categoryId
)
val
definition
=
definitions
.
getOrElse
(
key
,
new
DefinitionDTO
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
))
val
definition
=
definitions
.
getOrElse
(
key
,
new
DefinitionDTO
(
graphId
,
schemaName
,
version
,
o
cd
))
if
(!
definitions
.
contains
(
key
))
definitions
+=
(
key
->
definition
)
definition
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/DefinitionNode.scala
+
35
−
26
View file @
8b9af3bb
...
...
@@ -20,49 +20,50 @@ object DefinitionNode {
val
graphId
:
String
=
request
.
getContext
.
get
(
"graph_id"
).
asInstanceOf
[
String
]
val
version
:
String
=
request
.
getContext
.
get
(
"version"
).
asInstanceOf
[
String
]
val
schemaName
:
String
=
request
.
getContext
.
get
(
"schemaName"
).
asInstanceOf
[
String
]
val
categoryId
:
String
=
getPrimaryCategory
(
request
.
getRequest
,
schemaName
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
categoryId
)
val
objectCategoryDefinition
:
ObjectCategoryDefinition
=
getObjectCategoryDefinition
(
request
.
getRequest
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
],
schemaName
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
objectCategoryDefinition
)
definition
.
validateRequest
(
request
)
val
inputNode
=
definition
.
getNode
(
request
.
getRequest
)
updateRelationMetadata
(
inputNode
)
definition
.
validate
(
inputNode
,
"create"
,
setDefaultValue
)
recoverWith
{
case
e
:
CompletionException
=>
throw
e
.
getCause
}
}
def
getExternalProps
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
getExternalProps
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getExternalProps
()
}
def
fetchJsonProps
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
fetchJsonProps
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
fetchJsonProps
()
}
def
getInRelations
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
Map
[
String
,
AnyRef
]]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
getInRelations
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
Map
[
String
,
AnyRef
]]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getInRelations
()
}
def
getOutRelations
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
Map
[
String
,
AnyRef
]]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
getOutRelations
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
Map
[
String
,
AnyRef
]]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getOutRelations
()
}
def
getRelationDefinitionMap
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
Map
[
String
,
AnyRef
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
getRelationDefinitionMap
(
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
Map
[
String
,
AnyRef
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getRelationDefinitionMap
()
}
def
getRelationsMap
(
request
:
Request
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
java.util.HashMap
[
String
,
AnyRef
]
=
{
def
getRelationsMap
(
request
:
Request
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
java.util.HashMap
[
String
,
AnyRef
]
=
{
val
graphId
:
String
=
request
.
getContext
.
get
(
"graph_id"
).
asInstanceOf
[
String
]
val
version
:
String
=
request
.
getContext
.
get
(
"version"
).
asInstanceOf
[
String
]
val
schemaName
:
String
=
request
.
getContext
.
get
(
"schemaName"
).
asInstanceOf
[
String
]
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getRelationsMap
()
}
def
getRestrictedProperties
(
graphId
:
String
,
version
:
String
,
operation
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)
def
getRestrictedProperties
(
graphId
:
String
,
version
:
String
,
operation
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
List
[
String
]
=
{
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)
definition
.
getRestrictPropsConfig
(
operation
)
}
...
...
@@ -85,12 +86,13 @@ object DefinitionNode {
val
definition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
)
definition
.
getNode
(
identifier
,
"update"
,
null
,
versioning
).
map
(
dbNode
=>
{
val
schema
=
dbNode
.
getObjectType
.
toLowerCase
.
replace
(
"image"
,
""
)
val
categoryId
:
String
=
getPrimaryCategory
(
dbNode
.
getMetadata
,
schema
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
categoryDefinition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schema
,
version
,
categoryId
)
val
primaryCategory
:
String
=
if
(
null
!=
dbNode
.
getMetadata
)
dbNode
.
getMetadata
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
]
else
""
val
objectCategoryDefinition
:
ObjectCategoryDefinition
=
getObjectCategoryDefinition
(
primaryCategory
,
schema
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
categoryDefinition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schema
,
version
,
objectCategoryDefinition
)
categoryDefinition
.
validateRequest
(
request
)
resetJsonProperties
(
dbNode
,
graphId
,
version
,
schema
,
categoryId
)
resetJsonProperties
(
dbNode
,
graphId
,
version
,
schema
,
objectCategoryDefinition
)
val
inputNode
:
Node
=
categoryDefinition
.
getNode
(
dbNode
.
getIdentifier
,
request
.
getRequest
,
dbNode
.
getNodeType
)
val
dbRels
=
getDBRelations
(
graphId
,
schema
,
version
,
req
,
dbNode
,
categoryId
)
val
dbRels
=
getDBRelations
(
graphId
,
schema
,
version
,
req
,
dbNode
,
objectCategoryDefinition
)
setRelationship
(
dbNode
,
inputNode
,
dbRels
)
if
(
dbNode
.
getIdentifier
.
endsWith
(
".img"
)
&&
StringUtils
.
equalsAnyIgnoreCase
(
"Yes"
,
dbNode
.
getMetadata
.
getOrDefault
(
"isImageNodeCreated"
,
""
).
asInstanceOf
[
String
]))
{
inputNode
.
getMetadata
.
put
(
"versionKey"
,
dbNode
.
getMetadata
.
getOrDefault
(
"versionKey"
,
""
))
...
...
@@ -115,8 +117,9 @@ object DefinitionNode {
val
graphId
:
String
=
request
.
getContext
.
get
(
"graph_id"
).
asInstanceOf
[
String
]
val
version
:
String
=
request
.
getContext
.
get
(
"version"
).
asInstanceOf
[
String
]
val
schemaName
:
String
=
request
.
getContext
.
get
(
"schemaName"
).
asInstanceOf
[
String
]
val
categoryId
:
String
=
getPrimaryCategory
(
node
.
getMetadata
,
schemaName
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
categoryDefinition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
categoryId
)
val
primaryCategory
:
String
=
if
(
null
!=
node
.
getMetadata
)
node
.
getMetadata
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
]
else
""
val
objectCategoryDefinition
:
ObjectCategoryDefinition
=
getObjectCategoryDefinition
(
primaryCategory
,
schemaName
,
request
.
getContext
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
categoryDefinition
=
DefinitionFactory
.
getDefinition
(
graphId
,
schemaName
,
version
,
objectCategoryDefinition
)
val
edgeKey
=
categoryDefinition
.
getEdgeKey
()
if
(
null
!=
edgeKey
&&
!
edgeKey
.
isEmpty
)
{
val
metadata
=
node
.
getMetadata
...
...
@@ -197,8 +200,8 @@ object DefinitionNode {
node
.
setAddedRelations
(
rels
)
}
def
resetJsonProperties
(
node
:
Node
,
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
Node
=
{
val
jsonPropList
=
fetchJsonProps
(
graphId
,
version
,
schemaName
,
c
ategoryI
d
)
def
resetJsonProperties
(
node
:
Node
,
graphId
:
String
,
version
:
String
,
schemaName
:
String
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
Node
=
{
val
jsonPropList
=
fetchJsonProps
(
graphId
,
version
,
schemaName
,
o
cd
)
if
(!
jsonPropList
.
isEmpty
){
node
.
getMetadata
.
entrySet
().
map
(
entry
=>
{
if
(
jsonPropList
.
contains
(
entry
.
getKey
)){
...
...
@@ -212,10 +215,10 @@ object DefinitionNode {
node
}
def
getDBRelations
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
,
request
:
util.Map
[
String
,
AnyRef
],
dbNode
:
Node
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
util.Map
[
String
,
util.List
[
Relation
]]
=
{
def
getDBRelations
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
,
request
:
util.Map
[
String
,
AnyRef
],
dbNode
:
Node
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
:
util.Map
[
String
,
util.List
[
Relation
]]
=
{
val
inRelations
=
new
util
.
ArrayList
[
Relation
]()
val
outRelations
=
new
util
.
ArrayList
[
Relation
]()
val
relDefMap
=
getRelationDefinitionMap
(
graphId
,
version
,
schemaName
,
c
ategoryI
d
);
val
relDefMap
=
getRelationDefinitionMap
(
graphId
,
version
,
schemaName
,
o
cd
);
if
(
null
!=
dbNode
)
{
if
(
CollectionUtils
.
isNotEmpty
(
dbNode
.
getInRelations
))
{
for
(
inRel
<-
dbNode
.
getInRelations
())
{
...
...
@@ -293,5 +296,11 @@ object DefinitionNode {
ObjectCategoryDefinitionMap
.
prepareCategoryId
(
categoryName
,
schemaName
,
channel
)
}
else
""
}
def
getObjectCategoryDefinition
(
primaryCategory
:
String
,
objectType
:
String
,
channel
:
String
=
"all"
)
:
ObjectCategoryDefinition
=
{
if
(
StringUtils
.
isNotBlank
(
primaryCategory
))
ObjectCategoryDefinition
(
primaryCategory
,
objectType
,
channel
)
else
ObjectCategoryDefinition
()
}
}
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/IDefinition.scala
+
2
−
2
View file @
8b9af3bb
...
...
@@ -6,9 +6,9 @@ import org.sunbird.schema.{ISchemaValidator, SchemaValidatorFactory}
import
scala.concurrent.
{
ExecutionContext
,
Future
}
abstract
class
IDefinition
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
extends
CoreDomainObject
(
graphId
,
schemaName
,
version
,
categoryId
)
{
abstract
class
IDefinition
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
{
//
extends CoreDomainObject(graphId, schemaName, version, categoryId) {
var
schemaValidator
:
ISchemaValidator
=
if
(
category
Id
.
isBlank
)
SchemaValidatorFactory
.
getInstance
(
schemaName
,
version
)
else
new
CategoryDefinitionValidator
(
schemaName
,
version
).
loadSchema
(
c
ategoryI
d
)
var
schemaValidator
:
ISchemaValidator
=
if
(
ocd
.
category
Name
.
isBlank
)
SchemaValidatorFactory
.
getInstance
(
schemaName
,
version
)
else
new
CategoryDefinitionValidator
(
schemaName
,
version
).
loadSchema
(
o
cd
)
def
getNode
(
input
:
java.util.Map
[
String
,
AnyRef
])
:
Node
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/ObjectCategoryDefinition.scala
0 → 100644
+
3
−
0
View file @
8b9af3bb
package
org.sunbird.graph.schema
case
class
ObjectCategoryDefinition
(
categoryName
:
String
=
""
,
objectType
:
String
=
""
,
channel
:
String
=
""
)
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/schema/validator/BaseDefinitionNode.scala
+
2
−
2
View file @
8b9af3bb
...
...
@@ -9,12 +9,12 @@ import org.sunbird.graph.OntologyEngineContext
import
org.sunbird.graph.common.Identifier
import
org.sunbird.graph.dac.enums.SystemNodeTypes
import
org.sunbird.graph.dac.model.
{
Node
,
Relation
}
import
org.sunbird.graph.schema.IDefinition
import
org.sunbird.graph.schema.
{
IDefinition
,
ObjectCategoryDefinition
}
import
scala.collection.JavaConverters._
import
scala.concurrent.
{
ExecutionContext
,
Future
}
class
BaseDefinitionNode
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
categoryId
:
String
=
""
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
extends
IDefinition
(
graphId
,
schemaName
,
version
,
c
ategoryI
d
)(
ec
,
oec
)
{
class
BaseDefinitionNode
(
graphId
:
String
,
schemaName
:
String
,
version
:
String
=
"1.0"
,
ocd
:
ObjectCategoryDefinition
=
ObjectCategoryDefinition
()
)(
implicit
ec
:
ExecutionContext
,
oec
:
OntologyEngineContext
)
extends
IDefinition
(
graphId
,
schemaName
,
version
,
o
cd
)(
ec
,
oec
)
{
val
inRelationsSchema
:
Map
[
String
,
AnyRef
]
=
relationsSchema
(
"in"
)
val
outRelationsSchema
:
Map
[
String
,
AnyRef
]
=
relationsSchema
(
"out"
)
...
...
This diff is collapsed.
Click to expand it.
ontology-engine/graph-engine_2.11/src/main/scala/org/sunbird/graph/utils/NodeUtil.scala
+
4
−
4
View file @
8b9af3bb
...
...
@@ -10,7 +10,7 @@ import org.sunbird.common.{JsonUtils, Platform}
import
org.sunbird.graph.OntologyEngineContext
import
org.sunbird.graph.common.enums.SystemProperties
import
org.sunbird.graph.dac.model.
{
Node
,
Relation
}
import
org.sunbird.graph.schema.
{
DefinitionNode
,
ObjectCategoryDefinitionMap
}
import
org.sunbird.graph.schema.
{
DefinitionNode
,
ObjectCategoryDefinition
,
ObjectCategoryDefinitionMap
}
import
scala.collection.JavaConverters
import
scala.collection.JavaConverters._
...
...
@@ -23,10 +23,10 @@ object NodeUtil {
def
serialize
(
node
:
Node
,
fields
:
util.List
[
String
],
schemaName
:
String
,
schemaVersion
:
String
,
withoutRelations
:
Boolean
=
false
)(
implicit
oec
:
OntologyEngineContext
,
ec
:
ExecutionContext
)
:
util.Map
[
String
,
AnyRef
]
=
{
val
metadataMap
=
node
.
getMetadata
val
c
ategoryDefinition
Id
=
ObjectCategoryDefinition
Map
.
prepareCategoryId
(
node
.
getMetadata
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
],
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
node
.
getMetadata
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
jsonProps
=
DefinitionNode
.
fetchJsonProps
(
node
.
getGraphId
,
schemaVersion
,
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
c
ategoryDefinition
Id
)
val
objectC
ategoryDefinition
:
ObjectCategoryDefinition
=
DefinitionNode
.
getObjectCategoryDefinition
(
node
.
getMetadata
.
getOrDefault
(
"primaryCategory"
,
""
).
asInstanceOf
[
String
],
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
node
.
getMetadata
.
getOrDefault
(
"channel"
,
"all"
).
asInstanceOf
[
String
])
val
jsonProps
=
DefinitionNode
.
fetchJsonProps
(
node
.
getGraphId
,
schemaVersion
,
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
objectC
ategoryDefinition
)
val
updatedMetadataMap
:
util.Map
[
String
,
AnyRef
]
=
metadataMap
.
entrySet
().
asScala
.
filter
(
entry
=>
null
!=
entry
.
getValue
).
map
((
entry
:
util.Map.Entry
[
String
,
AnyRef
])
=>
handleKeyNames
(
entry
,
fields
)
->
convertJsonProperties
(
entry
,
jsonProps
)).
toMap
.
asJava
val
definitionMap
=
DefinitionNode
.
getRelationDefinitionMap
(
node
.
getGraphId
,
schemaVersion
,
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
c
ategoryDefinition
Id
).
asJava
val
definitionMap
=
DefinitionNode
.
getRelationDefinitionMap
(
node
.
getGraphId
,
schemaVersion
,
node
.
getObjectType
.
toLowerCase
().
replace
(
"image"
,
""
),
objectC
ategoryDefinition
).
asJava
val
finalMetadata
=
new
util
.
HashMap
[
String
,
AnyRef
]()
finalMetadata
.
put
(
"objectType"
,
node
.
getObjectType
)
finalMetadata
.
putAll
(
updatedMetadataMap
)
...
...
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